From 8395a5c991cfe1bee9d62b1d3e184dc7a417f806 Mon Sep 17 00:00:00 2001 From: brandon Date: Mon, 13 Jun 2016 14:18:00 +1000 Subject: [PATCH] Reformatted ALL THE THINGS! --- .../draconicevolution/DraconicEvolution.java | 104 +- .../api/GeneratorOverride.java | 80 +- .../api/IExtendedRFStorage.java | 19 +- .../draconicevolution/api/package-info.java | 3 +- .../draconicevolution/client/ClientProxy.java | 364 ++- .../client/ReactorSound.java | 68 +- .../client/creativetab/DETab.java | 61 +- .../client/gui/ConfigGUI.java | 12 +- .../client/gui/CustomGuiButton.java | 28 +- .../client/gui/DEGUIFactory.java | 30 +- .../client/gui/GUIContainerTemplate.java | 70 +- .../client/gui/GUIDissEnchanter.java | 114 +- .../client/gui/GUIDraconiumChest.java | 267 +- .../client/gui/GUIEnergyInfuser.java | 244 +- .../client/gui/GUIFlowGate.java | 208 +- .../client/gui/GUIGenerator.java | 150 +- .../client/gui/GUIGrinder.java | 170 +- .../client/gui/GUIParticleGenerator.java | 1607 ++++++----- .../client/gui/GUIPlayerDetector.java | 419 ++- .../client/gui/GUISunDial.java | 108 +- .../client/gui/GUITeleporter.java | 1015 ++++--- .../client/gui/GUIUpgradeModifier.java | 442 ++- .../client/gui/GUIWeatherController.java | 155 +- .../client/gui/GuiButtonAHeight.java | 72 +- .../client/gui/GuiButtonTextOnly.java | 90 +- .../client/gui/GuiHandler.java | 328 +-- .../client/gui/GuiHudConfig.java | 338 ++- .../client/gui/GuiTextureButton.java | 67 +- .../client/gui/componentguis/GUIManual.java | 821 +++--- .../client/gui/componentguis/GUIReactor.java | 305 +-- .../gui/componentguis/GUIToolConfig.java | 387 ++- .../gui/componentguis/GUIToolInventory.java | 111 +- .../client/gui/componentguis/ManualPage.java | 56 +- .../ComponentConfigItemButton.java | 103 +- .../ComponentContributorsPage.java | 267 +- .../guicomponents/ComponentFieldAdjuster.java | 328 ++- .../guicomponents/ComponentFieldButton.java | 131 +- .../guicomponents/ComponentIndexButton.java | 94 +- .../guicomponents/ComponentManualPage.java | 691 +++-- .../client/handler/ClientEventHandler.java | 277 +- .../client/handler/HudHandler.java | 260 +- .../client/handler/ParticleHandler.java | 134 +- .../client/handler/ResourceHandler.java | 385 ++- .../client/keybinding/KeyBindings.java | 28 +- .../client/keybinding/KeyInputHandler.java | 154 +- .../client/model/ModelChaosCrystal.java | 59 +- .../client/model/ModelDraconicArmor.java | 286 +- .../client/model/ModelDraconicArmorOld.java | 958 ++++--- .../model/ModelReactorEnergyInjector.java | 30 +- .../model/ModelReactorStabilizerCore.java | 42 +- .../model/ModelReactorStabilizerRing.java | 340 +-- .../client/model/ModelRenderOBJ.java | 201 +- .../client/model/ModelTeleporterStand.java | 125 +- .../client/model/ModelWyvernArmor.java | 282 +- .../model/special/ModelContributorWings.java | 35 +- .../special/ModelStaffOfTheGreatOne.java | 156 +- .../client/render/IRenderTweak.java | 2 +- .../client/render/block/RenderCrystal.java | 87 +- .../render/block/RenderDraconiumChest.java | 48 +- .../render/block/RenderEnergyInfuser.java | 45 +- .../render/block/RenderParticleGen.java | 54 +- .../client/render/block/RenderPortal.java | 260 +- .../render/block/RenderReactorCore.java | 42 +- .../block/RenderReactorEnergyInjector.java | 44 +- .../render/block/RenderReactorStabilizer.java | 52 +- .../render/block/RenderTeleporterStand.java | 38 +- .../render/block/RenderUpgradeModifier.java | 43 +- .../render/entity/RenderChaosCrystal.java | 160 +- .../render/entity/RenderChaosDrill.java | 14 +- .../client/render/entity/RenderDragon.java | 577 ++-- .../render/entity/RenderDragonHeart.java | 104 +- .../render/entity/RenderDragonProjectile.java | 150 +- .../entity/RenderEntityChaosVortex.java | 54 +- .../entity/RenderEntityCustomArrow.java | 123 +- .../client/render/item/RenderArmor.java | 63 +- .../client/render/item/RenderBow.java | 258 +- .../client/render/item/RenderBowModel.java | 197 +- .../render/item/RenderChaosFragment.java | 47 +- .../client/render/item/RenderChaosShard.java | 41 +- .../client/render/item/RenderMobSoul.java | 144 +- .../render/item/RenderStabilizerPart.java | 111 +- .../client/render/item/RenderTool.java | 52 +- .../render/particle/ParticleCustom.java | 144 +- .../render/particle/ParticleDistortion.java | 144 +- .../render/particle/ParticleEnergy.java | 211 +- .../render/particle/ParticleEnergyBeam.java | 368 +-- .../render/particle/ParticleEnergyField.java | 191 +- .../render/particle/ParticleReactorBeam.java | 342 ++- .../client/render/particle/Particles.java | 2414 ++++++++--------- .../render/tile/RenderTileChaosShard.java | 137 +- .../client/render/tile/RenderTileCrystal.java | 217 +- .../render/tile/RenderTileCustomSpawner.java | 123 +- .../render/tile/RenderTileDissEnchanter.java | 130 +- .../render/tile/RenderTileDraconiumChest.java | 115 +- .../render/tile/RenderTileEnergyInfiser.java | 418 ++- .../render/tile/RenderTileEnergyPylon.java | 134 +- .../tile/RenderTileEnergyStorageCore.java | 136 +- .../render/tile/RenderTileParticleGen.java | 1290 +++++---- .../render/tile/RenderTilePlacedItem.java | 282 +- .../render/tile/RenderTileReactorCore.java | 130 +- .../tile/RenderTileReactorEnergyInjector.java | 53 +- .../tile/RenderTileReactorStabilizer.java | 73 +- .../tile/RenderTileTeleporterStand.java | 204 +- .../render/tile/RenderTileTestBlock.java | 74 +- .../tile/RenderTileUpgradeModifier.java | 354 ++- .../client/utill/CustomResourceLocation.java | 30 +- .../draconicevolution/common/CommonProxy.java | 296 +- .../draconicevolution/common/ModBlocks.java | 201 +- .../draconicevolution/common/ModItems.java | 271 +- .../common/achievements/Achievements.java | 227 +- .../common/blocks/BlockContainerDE.java | 48 +- .../common/blocks/BlockContainerTemplate.java | 121 +- .../common/blocks/BlockCustomDrop.java | 95 +- .../common/blocks/BlockDE.java | 47 +- .../common/blocks/CKeyStone.java | 161 +- .../common/blocks/ChaosCrystal.java | 136 +- .../common/blocks/ChaosShardAtmos.java | 44 +- .../common/blocks/CustomSpawner.java | 377 ++- .../common/blocks/DraconicBlock.java | 58 +- .../common/blocks/DraconiumBlock.java | 154 +- .../common/blocks/DraconiumChest.java | 401 ++- .../common/blocks/DraconiumOre.java | 95 +- .../common/blocks/InfusedObsidian.java | 81 +- .../common/blocks/ParticleGenerator.java | 343 ++- .../common/blocks/PlacedItem.java | 336 +-- .../common/blocks/Potentiometer.java | 477 ++-- .../common/blocks/RainSensor.java | 182 +- .../common/blocks/SafetyFlame.java | 54 +- .../common/blocks/TeleporterStand.java | 174 +- .../common/blocks/TestBlock.java | 164 +- .../common/blocks/XRayBlock.java | 161 +- .../blocks/itemblocks/CKeyStoneItemBlock.java | 68 +- .../itemblocks/DraconiumChestItemBlock.java | 50 +- .../blocks/itemblocks/DraconiumItemBlock.java | 136 +- .../itemblocks/EnergyCrystalItemBlock.java | 38 +- .../itemblocks/ItemBlockCustomData.java | 64 +- .../blocks/itemblocks/ItemBlockFrowGate.java | 24 +- .../blocks/itemblocks/LRDItemBlock.java | 24 +- .../blocks/itemblocks/TestItemBlock.java | 26 +- .../common/blocks/machine/DissEnchanter.java | 161 +- .../common/blocks/machine/EnergyCrystal.java | 362 ++- .../common/blocks/machine/EnergyInfuser.java | 114 +- .../common/blocks/machine/FlowGate.java | 319 ++- .../common/blocks/machine/Generator.java | 408 ++- .../common/blocks/machine/Grinder.java | 369 ++- .../blocks/machine/LongRangeDislocator.java | 217 +- .../common/blocks/machine/PlayerDetector.java | 248 +- .../machine/PlayerDetectorAdvanced.java | 267 +- .../common/blocks/machine/SunDial.java | 125 +- .../blocks/machine/UpgradeModifier.java | 114 +- .../blocks/machine/WeatherController.java | 225 +- .../multiblock/DislocatorReceptacle.java | 173 +- .../common/blocks/multiblock/EnergyPylon.java | 242 +- .../blocks/multiblock/EnergyStorageCore.java | 193 +- .../blocks/multiblock/IReactorPart.java | 30 +- .../multiblock/InvisibleMultiblock.java | 348 ++- .../blocks/multiblock/MultiblockHelper.java | 202 +- .../common/blocks/multiblock/Portal.java | 171 +- .../common/blocks/multiblock/ReactorCore.java | 104 +- .../multiblock/ReactorEnergyInjector.java | 201 +- .../blocks/multiblock/ReactorStabilizer.java | 163 +- .../common/container/ContainerAdvTool.java | 235 +- .../common/container/ContainerDataSync.java | 55 +- .../container/ContainerDissEnchanter.java | 239 +- .../container/ContainerDraconiumChest.java | 413 ++- .../container/ContainerEnergyInfuser.java | 119 +- .../common/container/ContainerGenerator.java | 121 +- .../common/container/ContainerGrinder.java | 132 +- .../container/ContainerPlayerDetector.java | 185 +- .../common/container/ContainerReactor.java | 379 ++- .../common/container/ContainerSunDial.java | 34 +- .../common/container/ContainerTemplate.java | 99 +- .../container/ContainerUpgradeModifier.java | 245 +- .../container/ContainerWeatherController.java | 91 +- .../common/container/DummyContainer.java | 14 +- .../common/entity/ChaosImplosion.java | 79 +- .../common/entity/ChaosImplosionTrace.java | 81 +- .../common/entity/EntityChaosBolt.java | 118 +- .../common/entity/EntityChaosCrystal.java | 320 ++- .../common/entity/EntityChaosDrill.java | 131 +- .../common/entity/EntityChaosGuardian.java | 1789 ++++++------ .../common/entity/EntityChaosVortex.java | 106 +- .../common/entity/EntityCustomArrow.java | 854 +++--- .../common/entity/EntityCustomDragon.java | 1254 +++++---- .../common/entity/EntityDraconicArrow.java | 915 +++---- .../common/entity/EntityDragonHeart.java | 444 ++- .../common/entity/EntityDragonProjectile.java | 574 ++-- .../common/entity/EntityEnderArrow.java | 565 ++-- .../common/entity/EntityPersistentItem.java | 256 +- .../common/entity/ExtendedPlayer.java | 82 +- .../common/handler/BalanceConfigHandler.java | 460 +--- .../common/handler/ConfigHandler.java | 245 +- .../common/handler/ContributorHandler.java | 403 ++- .../common/handler/CraftingHandler.java | 372 +-- .../common/handler/FMLEventHandler.java | 68 +- .../handler/MinecraftForgeEventHandler.java | 594 ++-- .../common/inventory/GenericInventory.java | 138 +- .../inventory/InventoryCraftingChest.java | 258 +- .../InventoryCraftingChestResult.java | 214 +- .../common/inventory/InventoryTool.java | 329 +-- .../common/inventory/SlotChargable.java | 41 +- .../common/inventory/SlotItemValid.java | 67 +- .../common/inventory/SlotOpaqueBlock.java | 39 +- .../common/inventory/SlotOutput.java | 24 +- .../common/items/AwakenedCore.java | 18 +- .../common/items/ChaosFragment.java | 30 +- .../common/items/ChaosShard.java | 31 +- .../common/items/ChaoticCore.java | 18 +- .../common/items/DezilsMarshmallow.java | 50 +- .../common/items/DraconicCore.java | 65 +- .../common/items/DraconicIngot.java | 10 +- .../common/items/DraconiumBlend.java | 10 +- .../common/items/DraconiumDust.java | 10 +- .../common/items/DraconiumEnergyCore.java | 60 +- .../common/items/DraconiumIngot.java | 10 +- .../common/items/DragonHeart.java | 28 +- .../common/items/InfoTablet.java | 32 +- .../common/items/ItemDE.java | 41 +- .../draconicevolution/common/items/Key.java | 74 +- .../common/items/MobSoul.java | 77 +- .../common/items/Nugget.java | 52 +- .../common/items/ReactorStabiliserPart.java | 50 +- .../common/items/SunFocus.java | 10 +- .../common/items/Tclogo.java | 278 +- .../common/items/WyvernCore.java | 10 +- .../items/armor/CustomArmorHandler.java | 580 ++-- .../common/items/armor/DraconicArmor.java | 824 +++--- .../common/items/armor/WyvernArmor.java | 671 +++-- .../common/items/tools/AdminSpawnEgg.java | 147 +- .../items/tools/CreativeStructureSpawner.java | 196 +- .../common/items/tools/DraconicAxe.java | 336 +-- .../items/tools/DraconicDistructionStaff.java | 284 +- .../common/items/tools/DraconicHoe.java | 516 ++-- .../common/items/tools/DraconicPickaxe.java | 185 +- .../common/items/tools/DraconicShovel.java | 192 +- .../items/tools/DraconiumFluxCapacitor.java | 301 +- .../common/items/tools/EnderArrow.java | 30 +- .../common/items/tools/Magnet.java | 158 +- .../items/tools/ObliterationCatalyst.java | 78 +- .../common/items/tools/SafetyMatch.java | 173 +- .../common/items/tools/TeleporterMKI.java | 219 +- .../common/items/tools/TeleporterMKII.java | 256 +- .../common/items/tools/Wrench.java | 177 +- .../common/items/tools/WyvernPickaxe.java | 183 +- .../common/items/tools/WyvernShovel.java | 186 +- .../items/tools/baseclasses/MiningTool.java | 456 ++-- .../items/tools/baseclasses/RFItemBase.java | 196 +- .../items/tools/baseclasses/ToolBase.java | 378 ++- .../items/tools/baseclasses/ToolHandler.java | 329 ++- .../common/items/weapons/BowHandler.java | 330 ++- .../common/items/weapons/DraconicBow.java | 541 ++-- .../common/items/weapons/DraconicSword.java | 475 ++-- .../weapons/IEnergyContainerWeaponItem.java | 3 +- .../common/items/weapons/WyvernBow.java | 537 ++-- .../common/items/weapons/WyvernSword.java | 481 ++-- .../common/lib/OreDoublingRegistry.java | 73 +- .../common/lib/References.java | 60 +- .../draconicevolution/common/lib/Strings.java | 138 +- .../common/lib/VersionHandler.java | 11 +- .../common/magic/EnchantmentReaper.java | 32 +- .../common/magic/PotionHandler.java | 29 +- .../common/network/BlockUpdatePacket.java | 56 +- .../common/network/ButtonPacket.java | 225 +- .../common/network/ContributorPacket.java | 88 +- .../common/network/GenericParticlePacket.java | 201 +- .../common/network/ItemConfigPacket.java | 124 +- .../common/network/MountUpdatePacket.java | 60 +- .../common/network/ParticleGenPacket.java | 584 ++-- .../common/network/PlacedItemPacket.java | 101 +- .../network/PlayerDetectorButtonPacket.java | 88 +- .../network/PlayerDetectorStringPacket.java | 67 +- .../common/network/ShieldHitPacket.java | 59 +- .../common/network/SpeedRequestPacket.java | 63 +- .../common/network/TeleporterPacket.java | 423 ++- .../common/network/TileObjectPacket.java | 154 +- .../common/network/ToolModePacket.java | 51 +- .../tileentities/CustomSpawnerBaseLogic.java | 448 +-- .../common/tileentities/TileCKeyStone.java | 279 +- .../common/tileentities/TileChaosShard.java | 124 +- .../tileentities/TileContainerTemplate.java | 231 +- .../tileentities/TileCustomSpawner.java | 109 +- .../tileentities/TileDissEnchanter.java | 443 ++- .../tileentities/TileDraconiumChest.java | 1028 ++++--- .../tileentities/TileEnergyInfuser.java | 506 ++-- .../common/tileentities/TileGenerator.java | 451 ++- .../common/tileentities/TileGrinder.java | 635 +++-- .../common/tileentities/TileObjectSync.java | 44 +- .../tileentities/TileParticleGenerator.java | 885 +++--- .../common/tileentities/TilePlacedItem.java | 90 +- .../tileentities/TilePlayerDetector.java | 162 +- .../TilePlayerDetectorAdvanced.java | 485 ++-- .../tileentities/TilePotentiometer.java | 151 +- .../common/tileentities/TileSunDial.java | 353 ++- .../tileentities/TileTeleporterStand.java | 211 +- .../common/tileentities/TileTestBlock.java | 145 +- .../tileentities/TileUpgradeModifier.java | 260 +- .../tileentities/TileWeatherController.java | 463 ++-- .../energynet/IRemoteEnergyHandler.java | 31 +- .../energynet/LinkedReceiver.java | 127 +- .../energynet/TileEnergyRelay.java | 116 +- .../energynet/TileEnergyTransceiver.java | 242 +- .../energynet/TileRemoteEnergyBase.java | 597 ++-- .../TileWirelessEnergyTransceiver.java | 299 +- .../tileentities/gates/TileFluidGate.java | 133 +- .../tileentities/gates/TileFluxGate.java | 123 +- .../common/tileentities/gates/TileGate.java | 201 +- .../TileDislocatorReceptacle.java | 324 ++- .../TileEnderResurrection.java | 653 +++-- .../multiblocktiles/TileEnergyPylon.java | 582 ++-- .../TileEnergyStorageCore.java | 1383 +++++----- .../TileInvisibleMultiblock.java | 107 +- .../multiblocktiles/TilePortalBlock.java | 113 +- .../reactor/ReactorExplosion.java | 79 +- .../reactor/ReactorExplosionTrace.java | 107 +- .../reactor/TileReactorCore.java | 937 ++++--- .../reactor/TileReactorEnergyInjector.java | 368 ++- .../common/utills/DamageSourceChaos.java | 28 +- .../common/utills/DragonChunkLoader.java | 121 +- .../common/utills/EnergyStorage.java | 239 +- .../common/utills/IConfigurableItem.java | 88 +- .../common/utills/ICustomItemData.java | 6 +- .../common/utills/IHudDisplayBlock.java | 2 +- .../common/utills/IHudDisplayItem.java | 2 +- .../common/utills/IInventoryTool.java | 6 +- .../common/utills/ItemConfigField.java | 310 ++- .../common/utills/LogHelper.java | 41 +- .../common/utills/PortalHelper.java | 303 ++- .../common/utills/ShapedOreEnergyRecipe.java | 41 +- .../common/utills/UpdateChecker.java | 186 +- .../common/world/ChaosWorldGenHandler.java | 488 ++-- .../common/world/DraconicWorldGenerator.java | 126 +- .../common/world/WorldGenChaosIsland.java | 251 +- .../common/world/WorldGenEnderComet.java | 164 +- .../common/world/WorldGenEnderIsland.java | 396 +-- .../integration/ModHelper.java | 36 +- .../computers/CCOCIntegration.java | 63 +- .../integration/computers/IDEPeripheral.java | 18 +- .../integration/computers/cc/CCAdapter.java | 62 +- .../computers/oc/DEManagedPeripheral.java | 40 +- .../nei/CraftingChestOverlayHandler.java | 465 ++-- .../nei/CraftingChestStackPositioner.java | 43 +- .../integration/nei/DENEIGuiHandler.java | 34 +- .../nei/NEIDraconicevolutionConfig.java | 55 +- 343 files changed, 38094 insertions(+), 39888 deletions(-) diff --git a/src/main/java/com/brandon3055/draconicevolution/DraconicEvolution.java b/src/main/java/com/brandon3055/draconicevolution/DraconicEvolution.java index da9d0fd3..af7f79aa 100644 --- a/src/main/java/com/brandon3055/draconicevolution/DraconicEvolution.java +++ b/src/main/java/com/brandon3055/draconicevolution/DraconicEvolution.java @@ -15,38 +15,36 @@ import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; -@Mod(modid = References.MODID, name = References.MODNAME, version = References.VERSION, canBeDeactivated = false, guiFactory = References.GUIFACTORY, dependencies = "after:NotEnoughItems;" + - "after:NotEnoughItems;" + - "after:ThermalExpansion;" + - "after:ThermalFoundation;" + - "required-after:BrandonsCore@[1.0.0.11,);") +@Mod(modid = References.MODID, name = References.MODNAME, version = References.VERSION, canBeDeactivated = false, guiFactory = References.GUIFACTORY, dependencies = "after:NotEnoughItems;" + + "after:NotEnoughItems;" + + "after:ThermalExpansion;" + + "after:ThermalFoundation;" + + "required-after:BrandonsCore@[1.0.0.11,);") public class DraconicEvolution { - @Mod.Instance(References.MODID) - public static DraconicEvolution instance; + @Mod.Instance(References.MODID) + public static DraconicEvolution instance; - @SidedProxy(clientSide = References.CLIENTPROXYLOCATION, serverSide = References.SERVERPROXYLOCATION) - public static CommonProxy proxy; + @SidedProxy(clientSide = References.CLIENTPROXYLOCATION, serverSide = References.SERVERPROXYLOCATION) + public static CommonProxy proxy; - public static CreativeTabs tabToolsWeapons = new DETab(CreativeTabs.getNextID(), References.MODID, "toolsAndWeapons", 0); - public static CreativeTabs tabBlocksItems = new DETab(CreativeTabs.getNextID(), References.MODID, "blocksAndItems", 1); + public static CreativeTabs tabToolsWeapons = new DETab(CreativeTabs.getNextID(), References.MODID, "toolsAndWeapons", 0); + public static CreativeTabs tabBlocksItems = new DETab(CreativeTabs.getNextID(), References.MODID, "blocksAndItems", 1); - public static final String networkChannelName = "DEvolutionNC"; - public static SimpleNetworkWrapper network; + public static final String networkChannelName = "DEvolutionNC"; + public static SimpleNetworkWrapper network; - public static boolean debug = false;//todo + public static boolean debug = false;//todo - public static Enchantment reaperEnchant; - - public DraconicEvolution() - { - LogHelper.info("Hello Minecraft!!!"); - } - - @Mod.EventHandler - public static void preInit(final FMLPreInitializationEvent event) - {if(debug) - LogHelper.info("Initialization"); + public static Enchantment reaperEnchant; + + public DraconicEvolution() { + LogHelper.info("Hello Minecraft!!!"); + } + + @Mod.EventHandler + public static void preInit(final FMLPreInitializationEvent event) { + if (debug) LogHelper.info("Initialization"); // event.getModMetadata().autogenerated = false; // event.getModMetadata().credits = ""; @@ -56,39 +54,37 @@ public class DraconicEvolution { // event.getModMetadata().url = "http://www.brandon3055.com/"; // event.getModMetadata().version = References.VERSION + "-MC1.7.10"; - proxy.preInit(event); + proxy.preInit(event); - } + } - @Mod.EventHandler - public void init(final FMLInitializationEvent event) - {if(debug) - System.out.println("init()"); - proxy.init(event); + @Mod.EventHandler + public void init(final FMLInitializationEvent event) { + if (debug) System.out.println("init()"); + proxy.init(event); - // === + // === - // === - } + // === + } - @Mod.EventHandler - public void postInit(final FMLPostInitializationEvent event) - {if(debug) - System.out.println("postInit()"); - - proxy.postInit(event); - } + @Mod.EventHandler + public void postInit(final FMLPostInitializationEvent event) { + if (debug) System.out.println("postInit()"); - //FMLInterModComms.sendMessage("DraconicEvolution", "addChestRecipe:item.coal", new ItemStack(Items.diamond, 2)); - @Mod.EventHandler - public void processMessage(FMLInterModComms.IMCEvent event) { - for (FMLInterModComms.IMCMessage m : event.getMessages()) { - LogHelper.info(m.key); - if (m.isItemStackMessage() && m.key.contains("addChestRecipe:")) { - String s = m.key.substring(m.key.indexOf("addChestRecipe:") + 15); - OreDoublingRegistry.resultOverrides.put(s, m.getItemStackValue()); - LogHelper.info("Added Chest recipe override: " + s + " to " + m.getItemStackValue()); - } - } - } + proxy.postInit(event); + } + + //FMLInterModComms.sendMessage("DraconicEvolution", "addChestRecipe:item.coal", new ItemStack(Items.diamond, 2)); + @Mod.EventHandler + public void processMessage(FMLInterModComms.IMCEvent event) { + for (FMLInterModComms.IMCMessage m : event.getMessages()) { + LogHelper.info(m.key); + if (m.isItemStackMessage() && m.key.contains("addChestRecipe:")) { + String s = m.key.substring(m.key.indexOf("addChestRecipe:") + 15); + OreDoublingRegistry.resultOverrides.put(s, m.getItemStackValue()); + LogHelper.info("Added Chest recipe override: " + s + " to " + m.getItemStackValue()); + } + } + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/api/GeneratorOverride.java b/src/main/java/com/brandon3055/draconicevolution/api/GeneratorOverride.java index f4463be2..70db6b76 100644 --- a/src/main/java/com/brandon3055/draconicevolution/api/GeneratorOverride.java +++ b/src/main/java/com/brandon3055/draconicevolution/api/GeneratorOverride.java @@ -14,44 +14,54 @@ import java.util.Random; */ public class GeneratorOverride { - /**Spawns a comet at the given x y z coordinates*/ - public void spawnCometAt(World world, int x, int y, int z, Random rand) { - new WorldGenEnderComet().generate(world, rand, x, y, z); - } + /** + * Spawns a comet at the given x y z coordinates + */ + public void spawnCometAt(World world, int x, int y, int z, Random rand) { + new WorldGenEnderComet().generate(world, rand, x, y, z); + } - /**This nolonger dose anything!*/ - @Deprecated - public void spawnChaosIslendAt(World world, int x, int y, int z, Random rand) { - new WorldGenEnderIsland().generate(world, rand, x, y, z); - } + /** + * This nolonger dose anything! + */ + @Deprecated + public void spawnChaosIslendAt(World world, int x, int y, int z, Random rand) { + new WorldGenEnderIsland().generate(world, rand, x, y, z); + } - /** - * This can be used to generate a chaos island at a given set of coordinates - * This method needs to be called foe every chunk in a 360 x 360 block area. - * Its ok to run it on a larger area it just wont do anything to chunks outside that area. - * - * @param chunkX the x pos of the chunk being generated (this is the xCoord divided by 16 not the xCoord itself) - * @param chunkZ the z pos of the chunk being generated (this is the zCoord divided by 16 not the zCoord itself) - * @param centerX this should be the center of the area you are spawning the island it (this is the actual xCoord) - * @param centerZ this should be the center of the area you are spawning the island it (this is the actual zCoord) - * @param random a random - * */ - public static void generateChaosChunk(World world, int chunkX, int chunkZ, int centerX, int centerZ, Random random){ - ChaosWorldGenHandler.generateChunk(world, chunkX, chunkZ, new DataUtills.XZPair(centerX, centerZ), random); - } + /** + * This can be used to generate a chaos island at a given set of coordinates + * This method needs to be called foe every chunk in a 360 x 360 block area. + * Its ok to run it on a larger area it just wont do anything to chunks outside that area. + * + * @param chunkX the x pos of the chunk being generated (this is the xCoord divided by 16 not the xCoord itself) + * @param chunkZ the z pos of the chunk being generated (this is the zCoord divided by 16 not the zCoord itself) + * @param centerX this should be the center of the area you are spawning the island it (this is the actual xCoord) + * @param centerZ this should be the center of the area you are spawning the island it (this is the actual zCoord) + * @param random a random + */ + public static void generateChaosChunk(World world, int chunkX, int chunkZ, int centerX, int centerZ, Random random) { + ChaosWorldGenHandler.generateChunk(world, chunkX, chunkZ, new DataUtills.XZPair(centerX, centerZ), random); + } - /**Use this at startup to disable / re enable default chaos island generation*/ - public static void setChaosIslandsEnabled(boolean chaosIslandsEnabled) { - DraconicWorldGenerator.chaosIslandsEnabled = chaosIslandsEnabled; - } + /** + * Use this at startup to disable / re enable default chaos island generation + */ + public static void setChaosIslandsEnabled(boolean chaosIslandsEnabled) { + DraconicWorldGenerator.chaosIslandsEnabled = chaosIslandsEnabled; + } - /**Use this at startup to disable / re enable default comet*/ - public static void setCometsEnabled(boolean cometsEnabled) { - DraconicWorldGenerator.cometsEnabled = cometsEnabled; - } + /** + * Use this at startup to disable / re enable default comet + */ + public static void setCometsEnabled(boolean cometsEnabled) { + DraconicWorldGenerator.cometsEnabled = cometsEnabled; + } - /**Use this at startup to disable / re enable default draconium generation in the end*/ - public static void setOreEnabledInEnd(boolean cometsEnabled) { - DraconicWorldGenerator.oreEnabledInEnd = cometsEnabled; - } + /** + * Use this at startup to disable / re enable default draconium generation in the end + */ + public static void setOreEnabledInEnd(boolean cometsEnabled) { + DraconicWorldGenerator.oreEnabledInEnd = cometsEnabled; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/api/IExtendedRFStorage.java b/src/main/java/com/brandon3055/draconicevolution/api/IExtendedRFStorage.java index 2cf215f0..95a085b5 100644 --- a/src/main/java/com/brandon3055/draconicevolution/api/IExtendedRFStorage.java +++ b/src/main/java/com/brandon3055/draconicevolution/api/IExtendedRFStorage.java @@ -3,16 +3,17 @@ package com.brandon3055.draconicevolution.api; /** * Created by Brandon on 6/03/2015. */ -public interface IExtendedRFStorage -{ - /**I will probably leave these here forever but i highly recommend switching as i may remove then at some point.*/ - @Deprecated - double getEnergyStored(); +public interface IExtendedRFStorage { + /** + * I will probably leave these here forever but i highly recommend switching as i may remove then at some point. + */ + @Deprecated + double getEnergyStored(); - @Deprecated - double getMaxEnergyStored(); + @Deprecated + double getMaxEnergyStored(); - long getExtendedStorage(); + long getExtendedStorage(); - long getExtendedCapacity(); + long getExtendedCapacity(); } diff --git a/src/main/java/com/brandon3055/draconicevolution/api/package-info.java b/src/main/java/com/brandon3055/draconicevolution/api/package-info.java index 5fd88b21..bc967e25 100644 --- a/src/main/java/com/brandon3055/draconicevolution/api/package-info.java +++ b/src/main/java/com/brandon3055/draconicevolution/api/package-info.java @@ -1,7 +1,6 @@ /** * Created by Brandon on 19/03/2015. */ -@API(apiVersion = "1.2", owner = "DraconicEvolution", provides = "DraconicEvolution|API") -package com.brandon3055.draconicevolution.api; +@API(apiVersion = "1.2", owner = "DraconicEvolution", provides = "DraconicEvolution|API") package com.brandon3055.draconicevolution.api; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/client/ClientProxy.java b/src/main/java/com/brandon3055/draconicevolution/client/ClientProxy.java index bc6527be..5130f6b7 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/ClientProxy.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/ClientProxy.java @@ -49,16 +49,15 @@ import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.common.MinecraftForge; public class ClientProxy extends CommonProxy { - private final static boolean debug = DraconicEvolution.debug; - public static String downloadLocation; - - @Override - public void preInit(FMLPreInitializationEvent event) - {if(debug) - System.out.println("on Client side"); - super.preInit(event); + private final static boolean debug = DraconicEvolution.debug; + public static String downloadLocation; - ResourceHandler.init(event); + @Override + public void preInit(FMLPreInitializationEvent event) { + if (debug) System.out.println("on Client side"); + super.preInit(event); + + ResourceHandler.init(event); // downloadLocation = event.getModConfigurationDirectory().getParentFile().getAbsolutePath() + "/mods/derspack"; // downloadLocation = downloadLocation.replaceAll("\\\\", "/"); @@ -107,211 +106,188 @@ public class ClientProxy extends CommonProxy { // } - } + } - @Override - public void init(FMLInitializationEvent event) - { - super.init(event); - FMLCommonHandler.instance().bus().register(new KeyInputHandler()); - FMLCommonHandler.instance().bus().register(new ClientEventHandler()); - if (ConfigHandler.enableVersionChecker) FMLCommonHandler.instance().bus().register(new UpdateChecker()); - MinecraftForge.EVENT_BUS.register(new HudHandler()); - MinecraftForge.EVENT_BUS.register(new ClientEventHandler()); - KeyBindings.init(); - registerRenderIDs(); - registerRendering(); - ResourceHandler.instance.tick(null); - } + @Override + public void init(FMLInitializationEvent event) { + super.init(event); + FMLCommonHandler.instance().bus().register(new KeyInputHandler()); + FMLCommonHandler.instance().bus().register(new ClientEventHandler()); + if (ConfigHandler.enableVersionChecker) FMLCommonHandler.instance().bus().register(new UpdateChecker()); + MinecraftForge.EVENT_BUS.register(new HudHandler()); + MinecraftForge.EVENT_BUS.register(new ClientEventHandler()); + KeyBindings.init(); + registerRenderIDs(); + registerRendering(); + ResourceHandler.instance.tick(null); + } - @Override - public void postInit(FMLPostInitializationEvent event) - { - super.postInit(event); - ResourceHandler.instance.tick(null); - } + @Override + public void postInit(FMLPostInitializationEvent event) { + super.postInit(event); + ResourceHandler.instance.tick(null); + } - public void registerRendering() - { - //Item Renderers - MinecraftForgeClient.registerItemRenderer(ModItems.wyvernBow, new RenderBow()); - MinecraftForgeClient.registerItemRenderer(ModItems.draconicBow, new RenderBow()); - MinecraftForgeClient.registerItemRenderer(ModItems.mobSoul, new RenderMobSoul()); - MinecraftForgeClient.registerItemRenderer(ModItems.chaosShard, new RenderChaosShard()); - MinecraftForgeClient.registerItemRenderer(ModItems.reactorStabilizerParts, new RenderStabilizerPart()); - MinecraftForgeClient.registerItemRenderer(ModItems.chaosFragment, new RenderChaosFragment()); + public void registerRendering() { + //Item Renderers + MinecraftForgeClient.registerItemRenderer(ModItems.wyvernBow, new RenderBow()); + MinecraftForgeClient.registerItemRenderer(ModItems.draconicBow, new RenderBow()); + MinecraftForgeClient.registerItemRenderer(ModItems.mobSoul, new RenderMobSoul()); + MinecraftForgeClient.registerItemRenderer(ModItems.chaosShard, new RenderChaosShard()); + MinecraftForgeClient.registerItemRenderer(ModItems.reactorStabilizerParts, new RenderStabilizerPart()); + MinecraftForgeClient.registerItemRenderer(ModItems.chaosFragment, new RenderChaosFragment()); - if (!ConfigHandler.useOldArmorModel) - { - MinecraftForgeClient.registerItemRenderer(ModItems.wyvernHelm, new RenderArmor(ModItems.wyvernHelm)); - MinecraftForgeClient.registerItemRenderer(ModItems.wyvernChest, new RenderArmor(ModItems.wyvernChest)); - MinecraftForgeClient.registerItemRenderer(ModItems.wyvernLeggs, new RenderArmor(ModItems.wyvernLeggs)); - MinecraftForgeClient.registerItemRenderer(ModItems.wyvernBoots, new RenderArmor(ModItems.wyvernBoots)); - MinecraftForgeClient.registerItemRenderer(ModItems.draconicHelm, new RenderArmor(ModItems.draconicHelm)); - MinecraftForgeClient.registerItemRenderer(ModItems.draconicChest, new RenderArmor(ModItems.draconicChest)); - MinecraftForgeClient.registerItemRenderer(ModItems.draconicLeggs, new RenderArmor(ModItems.draconicLeggs)); - MinecraftForgeClient.registerItemRenderer(ModItems.draconicBoots, new RenderArmor(ModItems.draconicBoots)); - } + if (!ConfigHandler.useOldArmorModel) { + MinecraftForgeClient.registerItemRenderer(ModItems.wyvernHelm, new RenderArmor(ModItems.wyvernHelm)); + MinecraftForgeClient.registerItemRenderer(ModItems.wyvernChest, new RenderArmor(ModItems.wyvernChest)); + MinecraftForgeClient.registerItemRenderer(ModItems.wyvernLeggs, new RenderArmor(ModItems.wyvernLeggs)); + MinecraftForgeClient.registerItemRenderer(ModItems.wyvernBoots, new RenderArmor(ModItems.wyvernBoots)); + MinecraftForgeClient.registerItemRenderer(ModItems.draconicHelm, new RenderArmor(ModItems.draconicHelm)); + MinecraftForgeClient.registerItemRenderer(ModItems.draconicChest, new RenderArmor(ModItems.draconicChest)); + MinecraftForgeClient.registerItemRenderer(ModItems.draconicLeggs, new RenderArmor(ModItems.draconicLeggs)); + MinecraftForgeClient.registerItemRenderer(ModItems.draconicBoots, new RenderArmor(ModItems.draconicBoots)); + } - if (!ConfigHandler.useOldD2DToolTextures) - { - MinecraftForgeClient.registerItemRenderer(ModItems.draconicSword, new RenderTool("models/tools/DraconicSword.obj", "textures/models/tools/DraconicSword.png", (IRenderTweak) ModItems.draconicSword)); - MinecraftForgeClient.registerItemRenderer(ModItems.wyvernPickaxe, new RenderTool("models/tools/Pickaxe.obj", "textures/models/tools/Pickaxe.png", (IRenderTweak) ModItems.wyvernPickaxe)); - MinecraftForgeClient.registerItemRenderer(ModItems.draconicPickaxe, new RenderTool("models/tools/DraconicPickaxe.obj", "textures/models/tools/DraconicPickaxe.png", (IRenderTweak) ModItems.draconicPickaxe)); - MinecraftForgeClient.registerItemRenderer(ModItems.draconicAxe, new RenderTool("models/tools/DraconicLumberAxe.obj", "textures/models/tools/DraconicLumberAxe.png", (IRenderTweak) ModItems.draconicAxe)); - MinecraftForgeClient.registerItemRenderer(ModItems.wyvernShovel, new RenderTool("models/tools/Shovel.obj", "textures/models/tools/Shovel.png", (IRenderTweak) ModItems.wyvernShovel)); - MinecraftForgeClient.registerItemRenderer(ModItems.draconicShovel, new RenderTool("models/tools/DraconicShovel.obj", "textures/models/tools/DraconicShovel.png", (IRenderTweak) ModItems.draconicShovel)); - MinecraftForgeClient.registerItemRenderer(ModItems.wyvernSword, new RenderTool("models/tools/Sword.obj", "textures/models/tools/Sword.png", (IRenderTweak) ModItems.wyvernSword)); - MinecraftForgeClient.registerItemRenderer(ModItems.draconicDestructionStaff, new RenderTool("models/tools/DraconicStaffOfPower.obj", "textures/models/tools/DraconicStaffOfPower.png", (IRenderTweak) ModItems.draconicDestructionStaff)); - MinecraftForgeClient.registerItemRenderer(ModItems.draconicHoe, new RenderTool("models/tools/DraconicHoe.obj", "textures/models/tools/DraconicHoe.png", (IRenderTweak) ModItems.draconicHoe)); - MinecraftForgeClient.registerItemRenderer(ModItems.draconicBow, new RenderBowModel(true)); - MinecraftForgeClient.registerItemRenderer(ModItems.wyvernBow, new RenderBowModel(false)); - } + if (!ConfigHandler.useOldD2DToolTextures) { + MinecraftForgeClient.registerItemRenderer(ModItems.draconicSword, new RenderTool("models/tools/DraconicSword.obj", "textures/models/tools/DraconicSword.png", (IRenderTweak) ModItems.draconicSword)); + MinecraftForgeClient.registerItemRenderer(ModItems.wyvernPickaxe, new RenderTool("models/tools/Pickaxe.obj", "textures/models/tools/Pickaxe.png", (IRenderTweak) ModItems.wyvernPickaxe)); + MinecraftForgeClient.registerItemRenderer(ModItems.draconicPickaxe, new RenderTool("models/tools/DraconicPickaxe.obj", "textures/models/tools/DraconicPickaxe.png", (IRenderTweak) ModItems.draconicPickaxe)); + MinecraftForgeClient.registerItemRenderer(ModItems.draconicAxe, new RenderTool("models/tools/DraconicLumberAxe.obj", "textures/models/tools/DraconicLumberAxe.png", (IRenderTweak) ModItems.draconicAxe)); + MinecraftForgeClient.registerItemRenderer(ModItems.wyvernShovel, new RenderTool("models/tools/Shovel.obj", "textures/models/tools/Shovel.png", (IRenderTweak) ModItems.wyvernShovel)); + MinecraftForgeClient.registerItemRenderer(ModItems.draconicShovel, new RenderTool("models/tools/DraconicShovel.obj", "textures/models/tools/DraconicShovel.png", (IRenderTweak) ModItems.draconicShovel)); + MinecraftForgeClient.registerItemRenderer(ModItems.wyvernSword, new RenderTool("models/tools/Sword.obj", "textures/models/tools/Sword.png", (IRenderTweak) ModItems.wyvernSword)); + MinecraftForgeClient.registerItemRenderer(ModItems.draconicDestructionStaff, new RenderTool("models/tools/DraconicStaffOfPower.obj", "textures/models/tools/DraconicStaffOfPower.png", (IRenderTweak) ModItems.draconicDestructionStaff)); + MinecraftForgeClient.registerItemRenderer(ModItems.draconicHoe, new RenderTool("models/tools/DraconicHoe.obj", "textures/models/tools/DraconicHoe.png", (IRenderTweak) ModItems.draconicHoe)); + MinecraftForgeClient.registerItemRenderer(ModItems.draconicBow, new RenderBowModel(true)); + MinecraftForgeClient.registerItemRenderer(ModItems.wyvernBow, new RenderBowModel(false)); + } - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.draconiumChest), new RenderDraconiumChest()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.particleGenerator), new RenderParticleGen()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.energyInfuser), new RenderEnergyInfuser()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.energyCrystal), new RenderCrystal()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.reactorStabilizer), new RenderReactorStabilizer()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.reactorEnergyInjector), new RenderReactorEnergyInjector()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.reactorCore), new RenderReactorCore()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.chaosCrystal), new RenderChaosShard()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.upgradeModifier), new RenderUpgradeModifier()); - - //ISimpleBlockRendering - RenderingRegistry.registerBlockHandler(new RenderTeleporterStand()); - RenderingRegistry.registerBlockHandler(new RenderPortal()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.draconiumChest), new RenderDraconiumChest()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.particleGenerator), new RenderParticleGen()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.energyInfuser), new RenderEnergyInfuser()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.energyCrystal), new RenderCrystal()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.reactorStabilizer), new RenderReactorStabilizer()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.reactorEnergyInjector), new RenderReactorEnergyInjector()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.reactorCore), new RenderReactorCore()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.chaosCrystal), new RenderChaosShard()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.upgradeModifier), new RenderUpgradeModifier()); - //TileEntitySpecialRenderers - ClientRegistry.bindTileEntitySpecialRenderer(TileParticleGenerator.class, new RenderTileParticleGen()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyInfuser.class, new RenderTileEnergyInfiser()); - ClientRegistry.bindTileEntitySpecialRenderer(TileCustomSpawner.class, new RenderTileCustomSpawner()); - //ClientRegistry.bindTileEntitySpecialRenderer(TileTestBlock.class, new RenderTileCrystal()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyStorageCore.class, new RenderTileEnergyStorageCore()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyPylon.class, new RenderTileEnergyPylon()); - ClientRegistry.bindTileEntitySpecialRenderer(TilePlacedItem.class, new RenderTilePlacedItem()); - ClientRegistry.bindTileEntitySpecialRenderer(TileDissEnchanter.class, new RenderTileDissEnchanter()); - ClientRegistry.bindTileEntitySpecialRenderer(TileTeleporterStand.class, new RenderTileTeleporterStand()); - ClientRegistry.bindTileEntitySpecialRenderer(TileDraconiumChest.class, new RenderTileDraconiumChest()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyRelay.class, new RenderTileCrystal()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyTransceiver.class, new RenderTileCrystal()); - ClientRegistry.bindTileEntitySpecialRenderer(TileWirelessEnergyTransceiver.class, new RenderTileCrystal()); - ClientRegistry.bindTileEntitySpecialRenderer(TileReactorCore.class, new RenderTileReactorCore()); - ClientRegistry.bindTileEntitySpecialRenderer(TileReactorStabilizer.class, new RenderTileReactorStabilizer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileReactorEnergyInjector.class, new RenderTileReactorEnergyInjector()); - ClientRegistry.bindTileEntitySpecialRenderer(TileChaosShard.class, new RenderTileChaosShard()); - ClientRegistry.bindTileEntitySpecialRenderer(TileUpgradeModifier.class, new RenderTileUpgradeModifier()); + //ISimpleBlockRendering + RenderingRegistry.registerBlockHandler(new RenderTeleporterStand()); + RenderingRegistry.registerBlockHandler(new RenderPortal()); - //Entitys - RenderingRegistry.registerEntityRenderingHandler(EntityCustomDragon.class, new RenderDragon()); - RenderingRegistry.registerEntityRenderingHandler(EntityChaosGuardian.class, new RenderDragon()); - RenderingRegistry.registerEntityRenderingHandler(EntityDragonHeart.class, new RenderDragonHeart()); - RenderingRegistry.registerEntityRenderingHandler(EntityDragonProjectile.class, new RenderDragonProjectile()); - RenderingRegistry.registerEntityRenderingHandler(EntityChaosCrystal.class, new RenderChaosCrystal()); - RenderingRegistry.registerEntityRenderingHandler(EntityChaosVortex.class, new RenderEntityChaosVortex()); - RenderingRegistry.registerEntityRenderingHandler(EntityCustomArrow.class, new RenderEntityCustomArrow()); - } + //TileEntitySpecialRenderers + ClientRegistry.bindTileEntitySpecialRenderer(TileParticleGenerator.class, new RenderTileParticleGen()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyInfuser.class, new RenderTileEnergyInfiser()); + ClientRegistry.bindTileEntitySpecialRenderer(TileCustomSpawner.class, new RenderTileCustomSpawner()); + //ClientRegistry.bindTileEntitySpecialRenderer(TileTestBlock.class, new RenderTileCrystal()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyStorageCore.class, new RenderTileEnergyStorageCore()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyPylon.class, new RenderTileEnergyPylon()); + ClientRegistry.bindTileEntitySpecialRenderer(TilePlacedItem.class, new RenderTilePlacedItem()); + ClientRegistry.bindTileEntitySpecialRenderer(TileDissEnchanter.class, new RenderTileDissEnchanter()); + ClientRegistry.bindTileEntitySpecialRenderer(TileTeleporterStand.class, new RenderTileTeleporterStand()); + ClientRegistry.bindTileEntitySpecialRenderer(TileDraconiumChest.class, new RenderTileDraconiumChest()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyRelay.class, new RenderTileCrystal()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyTransceiver.class, new RenderTileCrystal()); + ClientRegistry.bindTileEntitySpecialRenderer(TileWirelessEnergyTransceiver.class, new RenderTileCrystal()); + ClientRegistry.bindTileEntitySpecialRenderer(TileReactorCore.class, new RenderTileReactorCore()); + ClientRegistry.bindTileEntitySpecialRenderer(TileReactorStabilizer.class, new RenderTileReactorStabilizer()); + ClientRegistry.bindTileEntitySpecialRenderer(TileReactorEnergyInjector.class, new RenderTileReactorEnergyInjector()); + ClientRegistry.bindTileEntitySpecialRenderer(TileChaosShard.class, new RenderTileChaosShard()); + ClientRegistry.bindTileEntitySpecialRenderer(TileUpgradeModifier.class, new RenderTileUpgradeModifier()); - public void registerRenderIDs (){ - References.idTeleporterStand = RenderingRegistry.getNextAvailableRenderId(); - References.idPortal = RenderingRegistry.getNextAvailableRenderId(); - } + //Entitys + RenderingRegistry.registerEntityRenderingHandler(EntityCustomDragon.class, new RenderDragon()); + RenderingRegistry.registerEntityRenderingHandler(EntityChaosGuardian.class, new RenderDragon()); + RenderingRegistry.registerEntityRenderingHandler(EntityDragonHeart.class, new RenderDragonHeart()); + RenderingRegistry.registerEntityRenderingHandler(EntityDragonProjectile.class, new RenderDragonProjectile()); + RenderingRegistry.registerEntityRenderingHandler(EntityChaosCrystal.class, new RenderChaosCrystal()); + RenderingRegistry.registerEntityRenderingHandler(EntityChaosVortex.class, new RenderEntityChaosVortex()); + RenderingRegistry.registerEntityRenderingHandler(EntityCustomArrow.class, new RenderEntityCustomArrow()); + } - @Override - public ParticleEnergyBeam energyBeam(World worldObj, double x, double y, double z, double tx, double ty, double tz, int powerFlow, boolean advanced, ParticleEnergyBeam oldBeam, boolean render, int beamType) { - if (!worldObj.isRemote) return null; - ParticleEnergyBeam beam = oldBeam; - boolean inRange = ParticleHandler.isInRange(x, y, z, 50) || ParticleHandler.isInRange(tx, ty, tz, 50); + public void registerRenderIDs() { + References.idTeleporterStand = RenderingRegistry.getNextAvailableRenderId(); + References.idPortal = RenderingRegistry.getNextAvailableRenderId(); + } - if (beam == null || beam.isDead) - { - if (inRange) - { - beam = new ParticleEnergyBeam(worldObj, x, y, z, tx, ty, tz, 8, powerFlow, advanced, beamType); + @Override + public ParticleEnergyBeam energyBeam(World worldObj, double x, double y, double z, double tx, double ty, double tz, int powerFlow, boolean advanced, ParticleEnergyBeam oldBeam, boolean render, int beamType) { + if (!worldObj.isRemote) return null; + ParticleEnergyBeam beam = oldBeam; + boolean inRange = ParticleHandler.isInRange(x, y, z, 50) || ParticleHandler.isInRange(tx, ty, tz, 50); - FMLClientHandler.instance().getClient().effectRenderer.addEffect(beam); - } - } - else if (!inRange) - { - beam.setDead(); - return null; - } - else - { - beam.update(powerFlow, render); - } - return beam; - } + if (beam == null || beam.isDead) { + if (inRange) { + beam = new ParticleEnergyBeam(worldObj, x, y, z, tx, ty, tz, 8, powerFlow, advanced, beamType); - @Override - public ParticleEnergyField energyField(World worldObj, double x, double y, double z, int type, boolean advanced, ParticleEnergyField oldBeam, boolean render) { - if (!worldObj.isRemote) return null; - ParticleEnergyField beam = oldBeam; - boolean inRange = ParticleHandler.isInRange(x, y, z, 50); + FMLClientHandler.instance().getClient().effectRenderer.addEffect(beam); + } + } else if (!inRange) { + beam.setDead(); + return null; + } else { + beam.update(powerFlow, render); + } + return beam; + } - if (beam == null || beam.isDead) - { - if (inRange) - { - beam = new ParticleEnergyField(worldObj, x, y, z, 8, type, advanced); + @Override + public ParticleEnergyField energyField(World worldObj, double x, double y, double z, int type, boolean advanced, ParticleEnergyField oldBeam, boolean render) { + if (!worldObj.isRemote) return null; + ParticleEnergyField beam = oldBeam; + boolean inRange = ParticleHandler.isInRange(x, y, z, 50); - FMLClientHandler.instance().getClient().effectRenderer.addEffect(beam); - } - } - else if (!inRange) - { - beam.setDead(); - return null; - } - else - { - beam.update(render); - } - return beam; - } + if (beam == null || beam.isDead) { + if (inRange) { + beam = new ParticleEnergyField(worldObj, x, y, z, 8, type, advanced); - @Override - public ParticleReactorBeam reactorBeam(TileEntity tile, ParticleReactorBeam oldBeam, boolean render) { - if (!tile.getWorldObj().isRemote || !(tile instanceof IReactorPart)) return null; - ParticleReactorBeam beam = oldBeam; - boolean inRange = ParticleHandler.isInRange(tile.xCoord, tile.yCoord, tile.zCoord, 50); + FMLClientHandler.instance().getClient().effectRenderer.addEffect(beam); + } + } else if (!inRange) { + beam.setDead(); + return null; + } else { + beam.update(render); + } + return beam; + } - if (beam == null || beam.isDead) - { - if (inRange) - { - beam = new ParticleReactorBeam(tile); + @Override + public ParticleReactorBeam reactorBeam(TileEntity tile, ParticleReactorBeam oldBeam, boolean render) { + if (!tile.getWorldObj().isRemote || !(tile instanceof IReactorPart)) return null; + ParticleReactorBeam beam = oldBeam; + boolean inRange = ParticleHandler.isInRange(tile.xCoord, tile.yCoord, tile.zCoord, 50); - FMLClientHandler.instance().getClient().effectRenderer.addEffect(beam); - } - } - else if (!inRange) - { - beam.setDead(); - return null; - } - else - { - beam.update(render); - } - return beam; - } + if (beam == null || beam.isDead) { + if (inRange) { + beam = new ParticleReactorBeam(tile); + + FMLClientHandler.instance().getClient().effectRenderer.addEffect(beam); + } + } else if (!inRange) { + beam.setDead(); + return null; + } else { + beam.update(render); + } + return beam; + } - public boolean isOp(String paramString) - { - return Minecraft.getMinecraft().theWorld.getWorldInfo().getGameType().isCreative(); - } + public boolean isOp(String paramString) { + return Minecraft.getMinecraft().theWorld.getWorldInfo().getGameType().isCreative(); + } - @Override - public void spawnParticle(Object particle, int range) { - if (particle instanceof EntityFX && ((EntityFX)particle).worldObj.isRemote) ParticleHandler.spawnCustomParticle((EntityFX)particle, range); - } + @Override + public void spawnParticle(Object particle, int range) { + if (particle instanceof EntityFX && ((EntityFX) particle).worldObj.isRemote) + ParticleHandler.spawnCustomParticle((EntityFX) particle, range); + } - @Override - public ISound playISound(ISound sound) { - FMLClientHandler.instance().getClient().getSoundHandler().playSound(sound); - return sound; - } + @Override + public ISound playISound(ISound sound) { + FMLClientHandler.instance().getClient().getSoundHandler().playSound(sound); + return sound; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/ReactorSound.java b/src/main/java/com/brandon3055/draconicevolution/client/ReactorSound.java index 053843d0..721ceb3d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/ReactorSound.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/ReactorSound.java @@ -10,44 +10,44 @@ import net.minecraft.util.ResourceLocation; * Created by brandon3055 on 4/10/2015. */ public class ReactorSound extends PositionedSound implements ITickableSound { - private static ResourceLocation sound = new ResourceLocation(References.RESOURCESPREFIX + "coreSound"); - public boolean donePlaying = false; - private TileReactorCore tile; + private static ResourceLocation sound = new ResourceLocation(References.RESOURCESPREFIX + "coreSound"); + public boolean donePlaying = false; + private TileReactorCore tile; - public ReactorSound(TileReactorCore tile) { - super(sound); - this.tile = tile; - this.xPosF = (float)tile.xCoord + 0.5F; - this.yPosF = (float)tile.yCoord + 0.5F; - this.zPosF = (float)tile.zCoord + 0.5F; - this.repeat = true; - this.volume = 1.5F; - } + public ReactorSound(TileReactorCore tile) { + super(sound); + this.tile = tile; + this.xPosF = (float) tile.xCoord + 0.5F; + this.yPosF = (float) tile.yCoord + 0.5F; + this.zPosF = (float) tile.zCoord + 0.5F; + this.repeat = true; + this.volume = 1.5F; + } - @Override - public boolean isDonePlaying() { - return donePlaying; - } + @Override + public boolean isDonePlaying() { + return donePlaying; + } - @Override - public void update() { + @Override + public void update() { - volume = (tile.renderSpeed-0.5F) * 2F; - if (tile.reactionTemperature > 8000){ - volume += (float)((tile.reactionTemperature-8000D) / 1000D); - } - if (tile.reactionTemperature > 2000 && tile.maxFieldCharge > 0 && tile.fieldCharge < (tile.maxFieldCharge * 0.2D)){ - volume += 2D - ((tile.fieldCharge / tile.maxFieldCharge) * 10D); - } - if (tile.reactionTemperature > 2000 && tile.reactorFuel + tile.convertedFuel > 0 && tile.reactorFuel < (double)(tile.reactorFuel + tile.convertedFuel) * 0.2D){ - volume += 2D - ((tile.reactorFuel / (tile.reactorFuel + tile.convertedFuel)) * 10D); - } + volume = (tile.renderSpeed - 0.5F) * 2F; + if (tile.reactionTemperature > 8000) { + volume += (float) ((tile.reactionTemperature - 8000D) / 1000D); + } + if (tile.reactionTemperature > 2000 && tile.maxFieldCharge > 0 && tile.fieldCharge < (tile.maxFieldCharge * 0.2D)) { + volume += 2D - ((tile.fieldCharge / tile.maxFieldCharge) * 10D); + } + if (tile.reactionTemperature > 2000 && tile.reactorFuel + tile.convertedFuel > 0 && tile.reactorFuel < (double) (tile.reactorFuel + tile.convertedFuel) * 0.2D) { + volume += 2D - ((tile.reactorFuel / (tile.reactorFuel + tile.convertedFuel)) * 10D); + } - field_147663_c = 0.5F + volume/2F; + field_147663_c = 0.5F + volume / 2F; - if (tile.isInvalid() || !tile.getWorldObj().getChunkFromBlockCoords(tile.xCoord, tile.zCoord).isChunkLoaded){// || player == null || tile.getDistanceFrom(player.posX, player.posY, player.posZ) > 512){ - donePlaying = true; - repeat = false; - } - } + if (tile.isInvalid() || !tile.getWorldObj().getChunkFromBlockCoords(tile.xCoord, tile.zCoord).isChunkLoaded) {// || player == null || tile.getDistanceFrom(player.posX, player.posY, player.posZ) > 512){ + donePlaying = true; + repeat = false; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/creativetab/DETab.java b/src/main/java/com/brandon3055/draconicevolution/client/creativetab/DETab.java index 1bc8f831..936205c9 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/creativetab/DETab.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/creativetab/DETab.java @@ -11,41 +11,40 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class DETab extends CreativeTabs { - private String label; - private int tab; + private String label; + private int tab; - static ItemStack iconStackStaff; + static ItemStack iconStackStaff; - public static void initialize() { - if (ModItems.isEnabled(ModItems.draconicDestructionStaff)) iconStackStaff = ItemNBTHelper.setInteger(new ItemStack(ModItems.draconicDestructionStaff), "Energy", 30000000); - else iconStackStaff = new ItemStack(Items.stick); - } + public static void initialize() { + if (ModItems.isEnabled(ModItems.draconicDestructionStaff)) + iconStackStaff = ItemNBTHelper.setInteger(new ItemStack(ModItems.draconicDestructionStaff), "Energy", 30000000); + else iconStackStaff = new ItemStack(Items.stick); + } - public DETab(int id, String modid, String label, int tab) { - super(id, modid); - this.label = label; - this.tab = tab; - } + public DETab(int id, String modid, String label, int tab) { + super(id, modid); + this.label = label; + this.tab = tab; + } - @Override - @SideOnly(Side.CLIENT) - public ItemStack getIconItemStack() { + @Override + @SideOnly(Side.CLIENT) + public ItemStack getIconItemStack() { - if (tab == 0) return iconStackStaff; - else if (ModBlocks.isEnabled(ModBlocks.energyInfuser)) return new ItemStack(ModBlocks.energyInfuser); - return new ItemStack(Items.ender_eye); - } + if (tab == 0) return iconStackStaff; + else if (ModBlocks.isEnabled(ModBlocks.energyInfuser)) return new ItemStack(ModBlocks.energyInfuser); + return new ItemStack(Items.ender_eye); + } - @Override - @SideOnly(Side.CLIENT) - public Item getTabIconItem() - { - return getIconItemStack().getItem(); - } - - @Override - public String getTabLabel() - { - return this.label; - } + @Override + @SideOnly(Side.CLIENT) + public Item getTabIconItem() { + return getIconItemStack().getItem(); + } + + @Override + public String getTabLabel() { + return this.label; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/ConfigGUI.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/ConfigGUI.java index e499c566..4569af49 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/ConfigGUI.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/ConfigGUI.java @@ -10,12 +10,12 @@ import net.minecraftforge.common.config.Configuration; /** * Created by Brandon on 6/08/2014. */ -public class ConfigGUI extends GuiConfig { - public ConfigGUI(GuiScreen parent) { - super(parent, new ConfigElement(ConfigHandler.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements() , References.MODID, false, false, GuiConfig.getAbridgedConfigPath(ConfigHandler.config.toString())); - configElements.addAll(new ConfigElement(ConfigHandler.config.getCategory("spawner")).getChildElements()); - configElements.addAll(new ConfigElement(ConfigHandler.config.getCategory("long range dislocator")).getChildElements()); - } +public class ConfigGUI extends GuiConfig { + public ConfigGUI(GuiScreen parent) { + super(parent, new ConfigElement(ConfigHandler.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), References.MODID, false, false, GuiConfig.getAbridgedConfigPath(ConfigHandler.config.toString())); + configElements.addAll(new ConfigElement(ConfigHandler.config.getCategory("spawner")).getChildElements()); + configElements.addAll(new ConfigElement(ConfigHandler.config.getCategory("long range dislocator")).getChildElements()); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/CustomGuiButton.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/CustomGuiButton.java index ca8a244b..ded293b2 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/CustomGuiButton.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/CustomGuiButton.java @@ -7,17 +7,14 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.renderer.OpenGlHelper; -public class CustomGuiButton extends GuiButton -{ +public class CustomGuiButton extends GuiButton { - public CustomGuiButton(int id, int left, int top, int width, int hight, String text) { - super(id, left, top, width, hight, text); - } - - public void drawButton(Minecraft minecraft, int p_146112_2_, int p_146112_3_) - { - if (this.visible) - { + public CustomGuiButton(int id, int left, int top, int width, int hight, String text) { + super(id, left, top, width, hight, text); + } + + public void drawButton(Minecraft minecraft, int p_146112_2_, int p_146112_3_) { + if (this.visible) { FontRenderer fontrenderer = minecraft.fontRenderer; minecraft.getTextureManager().bindTexture(buttonTextures); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); @@ -31,16 +28,11 @@ public class CustomGuiButton extends GuiButton this.mouseDragged(minecraft, p_146112_2_, p_146112_3_); int l = 14737632; - if (packedFGColour != 0) - { + if (packedFGColour != 0) { l = packedFGColour; - } - else if (!this.enabled) - { + } else if (!this.enabled) { l = 10526880; - } - else if (this.field_146123_n) - { + } else if (this.field_146123_n) { l = 16777120; } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/DEGUIFactory.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/DEGUIFactory.java index 13bd61f7..8c0eb50c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/DEGUIFactory.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/DEGUIFactory.java @@ -10,23 +10,23 @@ import java.util.Set; * Created by Brandon on 6/08/2014. */ public class DEGUIFactory implements IModGuiFactory { - @Override - public void initialize(Minecraft minecraftInstance) { + @Override + public void initialize(Minecraft minecraftInstance) { - } + } - @Override - public Class mainConfigGuiClass() { - return ConfigGUI.class; - } + @Override + public Class mainConfigGuiClass() { + return ConfigGUI.class; + } - @Override - public Set runtimeGuiCategories() { - return null; - } + @Override + public Set runtimeGuiCategories() { + return null; + } - @Override - public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { - return null; - } + @Override + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { + return null; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIContainerTemplate.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIContainerTemplate.java index 029d1535..540dbb92 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIContainerTemplate.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIContainerTemplate.java @@ -16,55 +16,55 @@ import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GUIContainerTemplate extends GuiContainer { - public EntityPlayer player; - private TileContainerTemplate tile; + public EntityPlayer player; + private TileContainerTemplate tile; - public GUIContainerTemplate(InventoryPlayer invPlayer, TileContainerTemplate tile) { - super(new ContainerTemplate(invPlayer, tile)); + public GUIContainerTemplate(InventoryPlayer invPlayer, TileContainerTemplate tile) { + super(new ContainerTemplate(invPlayer, tile)); - xSize = 176; - ySize = 140; + xSize = 176; + ySize = 140; - this.tile = tile; - this.player = invPlayer.player; - } + this.tile = tile; + this.player = invPlayer.player; + } - private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/.png"); + private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/.png"); - @Override - protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { - GL11.glColor4f(1F, 1F, 1F, 1F); - Minecraft.getMinecraft().getTextureManager().bindTexture(texture); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + @Override + protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { + GL11.glColor4f(1F, 1F, 1F, 1F); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - } + } - @Override - protected void drawGuiContainerForegroundLayer(int x, int y) { - fontRendererObj.drawStringWithShadow("Energy Infuser", 49, -9, 0x00FFFF); - //bindTexture(texture); + @Override + protected void drawGuiContainerForegroundLayer(int x, int y) { + fontRendererObj.drawStringWithShadow("Energy Infuser", 49, -9, 0x00FFFF); + //bindTexture(texture); - //fontRendererObj.drawString("Charges: " + charges, 90, 25, 0x000000); - //drawCenteredString(fontRendererObj, "Charges: " + charges, 117, 25, 0x000000); - //drawCenteredString(fontRendererObj, "Weather Controller", xSize/2, -15, 0x2a4ed0); + //fontRendererObj.drawString("Charges: " + charges, 90, 25, 0x000000); + //drawCenteredString(fontRendererObj, "Charges: " + charges, 117, 25, 0x000000); + //drawCenteredString(fontRendererObj, "Weather Controller", xSize/2, -15, 0x2a4ed0); - } + } - @Override - public void initGui() { - super.initGui(); + @Override + public void initGui() { + super.initGui(); - } + } - @Override - protected void actionPerformed(GuiButton button) { + @Override + protected void actionPerformed(GuiButton button) { - } + } - @Override - public void updateScreen() { - super.updateScreen(); + @Override + public void updateScreen() { + super.updateScreen(); - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIDissEnchanter.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIDissEnchanter.java index cc723496..ab1009bd 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIDissEnchanter.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIDissEnchanter.java @@ -19,73 +19,73 @@ import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GUIDissEnchanter extends GuiContainer { - public EntityPlayer player; - private TileDissEnchanter tile; - private boolean cachRecipeValid = false; - private int cachCost = 0; + public EntityPlayer player; + private TileDissEnchanter tile; + private boolean cachRecipeValid = false; + private int cachCost = 0; - public GUIDissEnchanter(InventoryPlayer invPlayer, TileDissEnchanter tile) { - super(new ContainerDissEnchanter(invPlayer, tile)); + public GUIDissEnchanter(InventoryPlayer invPlayer, TileDissEnchanter tile) { + super(new ContainerDissEnchanter(invPlayer, tile)); - xSize = 176; - ySize = 142; + xSize = 176; + ySize = 142; - this.tile = tile; - this.player = invPlayer.player; - } + this.tile = tile; + this.player = invPlayer.player; + } - private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/DissEnchanter.png"); + private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/DissEnchanter.png"); - @Override - protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { - GL11.glColor4f(1F, 1F, 1F, 1F); - Minecraft.getMinecraft().getTextureManager().bindTexture(texture); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + @Override + protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { + GL11.glColor4f(1F, 1F, 1F, 1F); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - } + } - @Override - protected void drawGuiContainerForegroundLayer(int x, int y) { - drawCenteredString(fontRendererObj, StatCollector.translateToLocal("tile.draconicevolution:dissEnchanter.name"), 88, 4, 0x00FFFF); + @Override + protected void drawGuiContainerForegroundLayer(int x, int y) { + drawCenteredString(fontRendererObj, StatCollector.translateToLocal("tile.draconicevolution:dissEnchanter.name"), 88, 4, 0x00FFFF); - fontRendererObj.drawString("Item", 5, 40, 0x0000ff); - fontRendererObj.drawString("Damage: " + (40 - tile.bookPower) + "%", 5, 49, 0x0000ff); - } + fontRendererObj.drawString("Item", 5, 40, 0x0000ff); + fontRendererObj.drawString("Damage: " + (40 - tile.bookPower) + "%", 5, 49, 0x0000ff); + } - @SuppressWarnings("unchecked") - @Override - public void initGui() { - super.initGui(); - buttonList.clear(); - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - buttonList.add(new GuiButtonAHeight(0, posX+108, posY+45, 60, 12, "")); - updateButtonState(); - } + @SuppressWarnings("unchecked") + @Override + public void initGui() { + super.initGui(); + buttonList.clear(); + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + buttonList.add(new GuiButtonAHeight(0, posX + 108, posY + 45, 60, 12, "")); + updateButtonState(); + } - @Override - protected void actionPerformed(GuiButton button) { - if (button.id == 0) DraconicEvolution.network.sendToServer(new ButtonPacket((byte) 1, true)); - } + @Override + protected void actionPerformed(GuiButton button) { + if (button.id == 0) DraconicEvolution.network.sendToServer(new ButtonPacket((byte) 1, true)); + } - @Override - public void updateScreen() { - super.updateScreen(); - if (cachRecipeValid != tile.isValidRecipe) { - cachRecipeValid = tile.isValidRecipe; - updateButtonState(); - } - if (cachCost != tile.dissenchantCost){ - cachCost = tile.dissenchantCost; - updateButtonState(); - } - } + @Override + public void updateScreen() { + super.updateScreen(); + if (cachRecipeValid != tile.isValidRecipe) { + cachRecipeValid = tile.isValidRecipe; + updateButtonState(); + } + if (cachCost != tile.dissenchantCost) { + cachCost = tile.dissenchantCost; + updateButtonState(); + } + } - private void updateButtonState(){ - boolean flag = cachRecipeValid; - if (flag && player.experienceLevel < tile.dissenchantCost && !player.capabilities.isCreativeMode) flag = false; - ((GuiButtonAHeight)buttonList.get(0)).enabled = flag; - ((GuiButtonAHeight)buttonList.get(0)).packedFGColour = cachRecipeValid ? 0x000000 : 0xdf0000; - ((GuiButtonAHeight)buttonList.get(0)).displayString = "Cost: " + tile.dissenchantCost; - } + private void updateButtonState() { + boolean flag = cachRecipeValid; + if (flag && player.experienceLevel < tile.dissenchantCost && !player.capabilities.isCreativeMode) flag = false; + ((GuiButtonAHeight) buttonList.get(0)).enabled = flag; + ((GuiButtonAHeight) buttonList.get(0)).packedFGColour = cachRecipeValid ? 0x000000 : 0xdf0000; + ((GuiButtonAHeight) buttonList.get(0)).displayString = "Cost: " + tile.dissenchantCost; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIDraconiumChest.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIDraconiumChest.java index 388c0e85..3e22f8db 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIDraconiumChest.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIDraconiumChest.java @@ -31,154 +31,159 @@ import java.util.List; @SideOnly(Side.CLIENT) @Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems") -public class GUIDraconiumChest extends GuiContainer implements INEIGuiHandler -{ - public EntityPlayer player; - private TileDraconiumChest tile; - private static final ResourceLocation textureLeft = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/DraconicChestLeft.png"); - private static final ResourceLocation textureRight = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/DraconicChestRight.png"); - private int lastAutoFeed = -1; +public class GUIDraconiumChest extends GuiContainer implements INEIGuiHandler { + public EntityPlayer player; + private TileDraconiumChest tile; + private static final ResourceLocation textureLeft = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/DraconicChestLeft.png"); + private static final ResourceLocation textureRight = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/DraconicChestRight.png"); + private int lastAutoFeed = -1; - public GUIDraconiumChest(InventoryPlayer invPlayer, TileDraconiumChest tile) { - super(new ContainerDraconiumChest(invPlayer, tile)); + public GUIDraconiumChest(InventoryPlayer invPlayer, TileDraconiumChest tile) { + super(new ContainerDraconiumChest(invPlayer, tile)); - this.xSize = 481; - this.ySize = 256; + this.xSize = 481; + this.ySize = 256; - this.tile = tile; - this.player = invPlayer.player; - } + this.tile = tile; + this.player = invPlayer.player; + } - @Override - protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { - GL11.glColor4f(1F, 1F, 1F, 1F); - Minecraft.getMinecraft().getTextureManager().bindTexture(textureRight); - drawTexturedModalRect(guiLeft + 256, guiTop, 0, 0, 225, ySize); - Minecraft.getMinecraft().getTextureManager().bindTexture(textureLeft); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, 256, ySize); - drawTexturedModalRect(guiLeft+140, guiTop+216, 3, 176, 16, 23); - drawTexturedModalRect(guiLeft+387, guiTop+236, 44, 177, 90, 16); - drawTexturedModalRect(guiLeft+387, guiTop+180, 44, 177, 90, 16); + @Override + protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { + GL11.glColor4f(1F, 1F, 1F, 1F); + Minecraft.getMinecraft().getTextureManager().bindTexture(textureRight); + drawTexturedModalRect(guiLeft + 256, guiTop, 0, 0, 225, ySize); + Minecraft.getMinecraft().getTextureManager().bindTexture(textureLeft); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, 256, ySize); + drawTexturedModalRect(guiLeft + 140, guiTop + 216, 3, 176, 16, 23); + drawTexturedModalRect(guiLeft + 387, guiTop + 236, 44, 177, 90, 16); + drawTexturedModalRect(guiLeft + 387, guiTop + 180, 44, 177, 90, 16); - if (tile.lockOutputSlots) { - ResourceHandler.bindResource("textures/gui/Widgets.png"); - GL11.glColor4f(1f, 1f, 1f, 1f); - for (int i = 0; i < 5; i++) drawTexturedModalRect(guiLeft + 385 + i * 18, guiTop + 158, 138, 18, 18, 18); - Minecraft.getMinecraft().getTextureManager().bindTexture(textureLeft); - } + if (tile.lockOutputSlots) { + ResourceHandler.bindResource("textures/gui/Widgets.png"); + GL11.glColor4f(1f, 1f, 1f, 1f); + for (int i = 0; i < 5; i++) drawTexturedModalRect(guiLeft + 385 + i * 18, guiTop + 158, 138, 18, 18, 18); + Minecraft.getMinecraft().getTextureManager().bindTexture(textureLeft); + } - int arrowHight = (int)(((float)tile.smeltingProgressTime / (float)tile.smeltingCompleateTime) * 22f); - drawTexturedModalRect(guiLeft+140, guiTop+192+22-arrowHight, 140, 216+22-arrowHight, 16, arrowHight); + int arrowHight = (int) (((float) tile.smeltingProgressTime / (float) tile.smeltingCompleateTime) * 22f); + drawTexturedModalRect(guiLeft + 140, guiTop + 192 + 22 - arrowHight, 140, 216 + 22 - arrowHight, 16, arrowHight); - Minecraft.getMinecraft().getTextureManager().bindTexture(textureRight); - int energyWidth = (int)(((float)tile.getEnergyStored(ForgeDirection.DOWN) / (float)tile.getMaxEnergyStored(ForgeDirection.DOWN)) * 90f); - drawTexturedModalRect(guiLeft+44, guiTop+235, 131, 236, energyWidth, 16); + Minecraft.getMinecraft().getTextureManager().bindTexture(textureRight); + int energyWidth = (int) (((float) tile.getEnergyStored(ForgeDirection.DOWN) / (float) tile.getMaxEnergyStored(ForgeDirection.DOWN)) * 90f); + drawTexturedModalRect(guiLeft + 44, guiTop + 235, 131, 236, energyWidth, 16); - int flameHight = (int)(((float)tile.smeltingBurnSpeed / (float)tile.smeltingMaxBurnSpeed) * 13f); - //flameHight = tile.smeltingProgressTime <= 0 ? 0 : Math.min(flameHight, 13); - drawTexturedModalRect(guiLeft + 45, guiTop + 217 + 13 - flameHight, 132, 180 + 13 - flameHight, 88, flameHight); - } + int flameHight = (int) (((float) tile.smeltingBurnSpeed / (float) tile.smeltingMaxBurnSpeed) * 13f); + //flameHight = tile.smeltingProgressTime <= 0 ? 0 : Math.min(flameHight, 13); + drawTexturedModalRect(guiLeft + 45, guiTop + 217 + 13 - flameHight, 132, 180 + 13 - flameHight, 88, flameHight); + } - @Override - protected void drawGuiContainerForegroundLayer(int x, int y) { - fontRendererObj.drawString(tile.getInventoryName(), 4, 4, 0x222222); - //fontRendererObj.drawStringWithShadow(StatCollector.translateToLocal("button.de.chestAutoFeed.txt"), 4, 180, 0x00FFFF); + @Override + protected void drawGuiContainerForegroundLayer(int x, int y) { + fontRendererObj.drawString(tile.getInventoryName(), 4, 4, 0x222222); + //fontRendererObj.drawStringWithShadow(StatCollector.translateToLocal("button.de.chestAutoFeed.txt"), 4, 180, 0x00FFFF); - ArrayList list = new ArrayList(); - list.add(String.valueOf(tile.getEnergyStored(ForgeDirection.DOWN)) + "/" + String.valueOf(tile.getMaxEnergyStored(ForgeDirection.DOWN)) + "RF"); - if (GuiHelper.isInRect(44, 235, 90, 16, x-guiLeft, y-guiTop))drawHoveringText(list, x-guiLeft, y-guiTop, fontRendererObj); - list.clear(); - String s = StatCollector.translateToLocal("button.de.chestAutoFeed0.txt"); - if (GuiHelper.isInRect(4, 180, 38, 12, x-guiLeft, y-guiTop)){ - list.add(s.substring(s.indexOf(".")+1)); - drawHoveringText(list, x-guiLeft, y-guiTop, fontRendererObj); - } - if (GuiHelper.isInRect(4, 193, 38, 12, x-guiLeft, y-guiTop)){ - s = StatCollector.translateToLocal("button.de.chestAutoFeed1.txt"); - list.add(s.substring(s.indexOf(".")+1)); - drawHoveringText(list, x-guiLeft, y-guiTop, fontRendererObj); - } - if (GuiHelper.isInRect(4, 206, 38, 12, x-guiLeft, y-guiTop)){ - s = StatCollector.translateToLocal("button.de.chestAutoFeed2.txt"); - list.add(s.substring(s.indexOf(".")+1)); - drawHoveringText(list, x-guiLeft, y-guiTop, fontRendererObj); - } - if (GuiHelper.isInRect(4, 219, 38, 12, x-guiLeft, y-guiTop)){ - s = StatCollector.translateToLocal("button.de.chestAutoFeed3.txt"); - list.add(s.substring(s.indexOf(".")+1)); - drawHoveringText(list, x-guiLeft, y-guiTop, fontRendererObj); - } - if (GuiHelper.isInRect(398, 180, 70, 12, x-guiLeft, y-guiTop)){ - s = StatCollector.translateToLocal("button.de.chestLockOutput.txt"); - list.add(s.substring(s.indexOf(".")+1)); - drawHoveringText(list, x-guiLeft, y-guiTop, fontRendererObj); - } + ArrayList list = new ArrayList(); + list.add(String.valueOf(tile.getEnergyStored(ForgeDirection.DOWN)) + "/" + String.valueOf(tile.getMaxEnergyStored(ForgeDirection.DOWN)) + "RF"); + if (GuiHelper.isInRect(44, 235, 90, 16, x - guiLeft, y - guiTop)) + drawHoveringText(list, x - guiLeft, y - guiTop, fontRendererObj); + list.clear(); + String s = StatCollector.translateToLocal("button.de.chestAutoFeed0.txt"); + if (GuiHelper.isInRect(4, 180, 38, 12, x - guiLeft, y - guiTop)) { + list.add(s.substring(s.indexOf(".") + 1)); + drawHoveringText(list, x - guiLeft, y - guiTop, fontRendererObj); + } + if (GuiHelper.isInRect(4, 193, 38, 12, x - guiLeft, y - guiTop)) { + s = StatCollector.translateToLocal("button.de.chestAutoFeed1.txt"); + list.add(s.substring(s.indexOf(".") + 1)); + drawHoveringText(list, x - guiLeft, y - guiTop, fontRendererObj); + } + if (GuiHelper.isInRect(4, 206, 38, 12, x - guiLeft, y - guiTop)) { + s = StatCollector.translateToLocal("button.de.chestAutoFeed2.txt"); + list.add(s.substring(s.indexOf(".") + 1)); + drawHoveringText(list, x - guiLeft, y - guiTop, fontRendererObj); + } + if (GuiHelper.isInRect(4, 219, 38, 12, x - guiLeft, y - guiTop)) { + s = StatCollector.translateToLocal("button.de.chestAutoFeed3.txt"); + list.add(s.substring(s.indexOf(".") + 1)); + drawHoveringText(list, x - guiLeft, y - guiTop, fontRendererObj); + } + if (GuiHelper.isInRect(398, 180, 70, 12, x - guiLeft, y - guiTop)) { + s = StatCollector.translateToLocal("button.de.chestLockOutput.txt"); + list.add(s.substring(s.indexOf(".") + 1)); + drawHoveringText(list, x - guiLeft, y - guiTop, fontRendererObj); + } - RenderHelper.enableGUIStandardItemLighting(); - } + RenderHelper.enableGUIStandardItemLighting(); + } - @SuppressWarnings("unchecked") - @Override - public void initGui() { - super.initGui(); - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - buttonList.clear(); - String s = StatCollector.translateToLocal("button.de.chestAutoFeed0.txt"); - buttonList.add(new GuiButtonAHeight(0, posX+4, posY+180, 38, 12, s.substring(0, s.indexOf(".")))); - s = StatCollector.translateToLocal("button.de.chestAutoFeed1.txt"); - buttonList.add(new GuiButtonAHeight(1, posX+4, posY+193, 38, 12, s.substring(0, s.indexOf(".")))); - s = StatCollector.translateToLocal("button.de.chestAutoFeed2.txt"); - buttonList.add(new GuiButtonAHeight(2, posX+4, posY+206, 38, 12, s.substring(0, s.indexOf(".")))); - s = StatCollector.translateToLocal("button.de.chestAutoFeed3.txt"); - buttonList.add(new GuiButtonAHeight(3, posX+4, posY+219, 38, 12, s.substring(0, s.indexOf(".")))); - s = StatCollector.translateToLocal("button.de.chestLockOutput.txt"); - buttonList.add(new GuiButtonAHeight(4, posX+398, posY+180, 70, 12, s.substring(0, s.indexOf(".")))); - } + @SuppressWarnings("unchecked") + @Override + public void initGui() { + super.initGui(); + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + buttonList.clear(); + String s = StatCollector.translateToLocal("button.de.chestAutoFeed0.txt"); + buttonList.add(new GuiButtonAHeight(0, posX + 4, posY + 180, 38, 12, s.substring(0, s.indexOf(".")))); + s = StatCollector.translateToLocal("button.de.chestAutoFeed1.txt"); + buttonList.add(new GuiButtonAHeight(1, posX + 4, posY + 193, 38, 12, s.substring(0, s.indexOf(".")))); + s = StatCollector.translateToLocal("button.de.chestAutoFeed2.txt"); + buttonList.add(new GuiButtonAHeight(2, posX + 4, posY + 206, 38, 12, s.substring(0, s.indexOf(".")))); + s = StatCollector.translateToLocal("button.de.chestAutoFeed3.txt"); + buttonList.add(new GuiButtonAHeight(3, posX + 4, posY + 219, 38, 12, s.substring(0, s.indexOf(".")))); + s = StatCollector.translateToLocal("button.de.chestLockOutput.txt"); + buttonList.add(new GuiButtonAHeight(4, posX + 398, posY + 180, 70, 12, s.substring(0, s.indexOf(".")))); + } - @Override - protected void actionPerformed(GuiButton button) { - if (button.id == 0)DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_DRACONIUMCHEST0, false)); - else if (button.id == 1)DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_DRACONIUMCHEST1, false)); - else if (button.id == 2)DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_DRACONIUMCHEST2, false)); - else if (button.id == 3)DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_DRACONIUMCHEST3, false)); - else if (button.id == 4)DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_DRACONIUMCHEST4, false)); - } + @Override + protected void actionPerformed(GuiButton button) { + if (button.id == 0) + DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_DRACONIUMCHEST0, false)); + else if (button.id == 1) + DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_DRACONIUMCHEST1, false)); + else if (button.id == 2) + DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_DRACONIUMCHEST2, false)); + else if (button.id == 3) + DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_DRACONIUMCHEST3, false)); + else if (button.id == 4) + DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_DRACONIUMCHEST4, false)); + } - @Override - public void updateScreen() { - super.updateScreen(); - if (lastAutoFeed != tile.smeltingAutoFeed){ - lastAutoFeed = tile.smeltingAutoFeed; - ((GuiButton)buttonList.get(0)).enabled = lastAutoFeed != 0; - ((GuiButton)buttonList.get(1)).enabled = lastAutoFeed != 1; - ((GuiButton)buttonList.get(2)).enabled = lastAutoFeed != 2; - ((GuiButton)buttonList.get(3)).enabled = lastAutoFeed != 3; - } - } + @Override + public void updateScreen() { + super.updateScreen(); + if (lastAutoFeed != tile.smeltingAutoFeed) { + lastAutoFeed = tile.smeltingAutoFeed; + ((GuiButton) buttonList.get(0)).enabled = lastAutoFeed != 0; + ((GuiButton) buttonList.get(1)).enabled = lastAutoFeed != 1; + ((GuiButton) buttonList.get(2)).enabled = lastAutoFeed != 2; + ((GuiButton) buttonList.get(3)).enabled = lastAutoFeed != 3; + } + } - @Override - public VisiblityData modifyVisiblity(GuiContainer guiContainer, VisiblityData visiblityData) { - return null; - } + @Override + public VisiblityData modifyVisiblity(GuiContainer guiContainer, VisiblityData visiblityData) { + return null; + } - @Override - public Iterable getItemSpawnSlots(GuiContainer guiContainer, ItemStack stack) { - return null; - } + @Override + public Iterable getItemSpawnSlots(GuiContainer guiContainer, ItemStack stack) { + return null; + } - @Override - public List getInventoryAreas(GuiContainer guiContainer) { - return Collections.emptyList(); - } + @Override + public List getInventoryAreas(GuiContainer guiContainer) { + return Collections.emptyList(); + } - @Override - public boolean handleDragNDrop(GuiContainer guiContainer, int i, int i2, ItemStack stack, int i3) { - return false; - } + @Override + public boolean handleDragNDrop(GuiContainer guiContainer, int i, int i2, ItemStack stack, int i3) { + return false; + } - @Override - public boolean hideItemPanelSlot(GuiContainer guiContainer, int i, int i2, int i3, int i4) { - return false; - } + @Override + public boolean hideItemPanelSlot(GuiContainer guiContainer, int i, int i2, int i3, int i4) { + return false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIEnergyInfuser.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIEnergyInfuser.java index e85539ef..2b85acbd 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIEnergyInfuser.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIEnergyInfuser.java @@ -23,158 +23,158 @@ import java.util.Random; @SideOnly(Side.CLIENT) public class GUIEnergyInfuser extends GuiContainer { - public EntityPlayer player; - private TileEnergyInfuser tile; - private float rotation = 0; + public EntityPlayer player; + private TileEnergyInfuser tile; + private float rotation = 0; - public GUIEnergyInfuser(InventoryPlayer invPlayer, TileEnergyInfuser tile) { - super(new ContainerEnergyInfuser(invPlayer, tile)); + public GUIEnergyInfuser(InventoryPlayer invPlayer, TileEnergyInfuser tile) { + super(new ContainerEnergyInfuser(invPlayer, tile)); - xSize = 176; - ySize = 140; + xSize = 176; + ySize = 140; - this.tile = tile; - this.player = invPlayer.player; - } + this.tile = tile; + this.player = invPlayer.player; + } - private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/EnergyInfuser.png"); + private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/EnergyInfuser.png"); - @Override - protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { - GL11.glColor4f(1F, 1F, 1F, 1F); - Minecraft.getMinecraft().getTextureManager().bindTexture(texture); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - if (tile.getStackInSlot(0) == null) - drawTexturedModalRect(guiLeft + 63, guiTop + 34, 36, ySize, 18, 18);//fuel box + @Override + protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { + GL11.glColor4f(1F, 1F, 1F, 1F); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + if (tile.getStackInSlot(0) == null) + drawTexturedModalRect(guiLeft + 63, guiTop + 34, 36, ySize, 18, 18);//fuel box - float power = (float) tile.energy.getEnergyStored() / (float) tile.energy.getMaxEnergyStored() * -1F + 1F; - drawTexturedModalRect(guiLeft + 49, guiTop + 7 + (int) (power * 45), xSize, (int) (power * 45), 8, 45 - (int) (power * 45));//Power bar + float power = (float) tile.energy.getEnergyStored() / (float) tile.energy.getMaxEnergyStored() * -1F + 1F; + drawTexturedModalRect(guiLeft + 49, guiTop + 7 + (int) (power * 45), xSize, (int) (power * 45), 8, 45 - (int) (power * 45));//Power bar - if (tile.running && tile.getStackInSlot(0) != null && tile.getStackInSlot(0).getItem() instanceof IEnergyContainerItem) { - IEnergyContainerItem item = (IEnergyContainerItem) tile.getStackInSlot(0).getItem(); - float charge = (float) item.getEnergyStored(tile.getStackInSlot(0)) / (float) item.getMaxEnergyStored(tile.getStackInSlot(0)) * -1F + 1F; - drawTexturedModalRect(guiLeft + 119, guiTop + 7 + (int) (charge * 45), xSize, (int) (charge * 45), 8, 45 - (int) (charge * 45));//Item Power bar - } + if (tile.running && tile.getStackInSlot(0) != null && tile.getStackInSlot(0).getItem() instanceof IEnergyContainerItem) { + IEnergyContainerItem item = (IEnergyContainerItem) tile.getStackInSlot(0).getItem(); + float charge = (float) item.getEnergyStored(tile.getStackInSlot(0)) / (float) item.getMaxEnergyStored(tile.getStackInSlot(0)) * -1F + 1F; + drawTexturedModalRect(guiLeft + 119, guiTop + 7 + (int) (charge * 45), xSize, (int) (charge * 45), 8, 45 - (int) (charge * 45));//Item Power bar + } - drawAnimatedParts(); - } + drawAnimatedParts(); + } - @Override - protected void drawGuiContainerForegroundLayer(int x, int y) { - fontRendererObj.drawStringWithShadow("Energy Infuser", 49, -9, 0x00FFFF); + @Override + protected void drawGuiContainerForegroundLayer(int x, int y) { + fontRendererObj.drawStringWithShadow("Energy Infuser", 49, -9, 0x00FFFF); - //bindTexture(texture); + //bindTexture(texture); - //fontRendererObj.drawString("Charges: " + charges, 90, 25, 0x000000); - //drawCenteredString(fontRendererObj, "Charges: " + charges, 117, 25, 0x000000); - //drawCenteredString(fontRendererObj, "Weather Controller", xSize/2, -15, 0x2a4ed0); + //fontRendererObj.drawString("Charges: " + charges, 90, 25, 0x000000); + //drawCenteredString(fontRendererObj, "Charges: " + charges, 117, 25, 0x000000); + //drawCenteredString(fontRendererObj, "Weather Controller", xSize/2, -15, 0x2a4ed0); - } + } - @Override - public void drawScreen(int x, int y, float p_73863_3_) { - super.drawScreen(x, y, p_73863_3_); - drawEnergyBarHoverText(x - guiLeft, y - guiTop); - } + @Override + public void drawScreen(int x, int y, float p_73863_3_) { + super.drawScreen(x, y, p_73863_3_); + drawEnergyBarHoverText(x - guiLeft, y - guiTop); + } - @Override - public void initGui() { - super.initGui(); + @Override + public void initGui() { + super.initGui(); - //ID - //buttonList.add(new GuiButton(0, guiLeft + 85, guiTop , 85, 20, text)); - } + //ID + //buttonList.add(new GuiButton(0, guiLeft + 85, guiTop , 85, 20, text)); + } - @Override - protected void actionPerformed(GuiButton button) { + @Override + protected void actionPerformed(GuiButton button) { - } + } - @Override - public void updateScreen() { - super.updateScreen(); + @Override + public void updateScreen() { + super.updateScreen(); - } + } - private void drawEnergyBarHoverText(int x, int y) { - if (GuiHelper.isInRect(48, 6, 9, 46, x, y)) { - ArrayList internal = new ArrayList(); - internal.add(StatCollector.translateToLocal("gui.de.internalStorage.txt")); - internal.add("" + EnumChatFormatting.DARK_BLUE + tile.energy.getEnergyStored() + "/" + tile.energy.getMaxEnergyStored()); - GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); - drawHoveringText(internal, x + guiLeft, y + guiTop, fontRendererObj); - GL11.glPopAttrib(); - } + private void drawEnergyBarHoverText(int x, int y) { + if (GuiHelper.isInRect(48, 6, 9, 46, x, y)) { + ArrayList internal = new ArrayList(); + internal.add(StatCollector.translateToLocal("gui.de.internalStorage.txt")); + internal.add("" + EnumChatFormatting.DARK_BLUE + tile.energy.getEnergyStored() + "/" + tile.energy.getMaxEnergyStored()); + GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); + drawHoveringText(internal, x + guiLeft, y + guiTop, fontRendererObj); + GL11.glPopAttrib(); + } - if (GuiHelper.isInRect(118, 6, 10, 46, x, y) && tile.running && tile.getStackInSlot(0) != null && tile.getStackInSlot(0).getItem() instanceof IEnergyContainerItem) { - IEnergyContainerItem item = (IEnergyContainerItem) tile.getStackInSlot(0).getItem(); - ArrayList internal = new ArrayList(); - internal.add(StatCollector.translateToLocal("gui.de.itemStorage.txt")); - internal.add("" + EnumChatFormatting.DARK_BLUE + item.getEnergyStored(tile.getStackInSlot(0)) + "/" + item.getMaxEnergyStored(tile.getStackInSlot(0))); - GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); - drawHoveringText(internal, x + guiLeft, y + guiTop, fontRendererObj); - GL11.glPopAttrib(); - } - } + if (GuiHelper.isInRect(118, 6, 10, 46, x, y) && tile.running && tile.getStackInSlot(0) != null && tile.getStackInSlot(0).getItem() instanceof IEnergyContainerItem) { + IEnergyContainerItem item = (IEnergyContainerItem) tile.getStackInSlot(0).getItem(); + ArrayList internal = new ArrayList(); + internal.add(StatCollector.translateToLocal("gui.de.itemStorage.txt")); + internal.add("" + EnumChatFormatting.DARK_BLUE + item.getEnergyStored(tile.getStackInSlot(0)) + "/" + item.getMaxEnergyStored(tile.getStackInSlot(0))); + GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); + drawHoveringText(internal, x + guiLeft, y + guiTop, fontRendererObj); + GL11.glPopAttrib(); + } + } - private void drawAnimatedParts() { - if (!tile.running) drawTexturedModalRect(guiLeft + 79, guiTop + 21, xSize, 45, 18, 18); - if (tile.running) rotation += 0.2F; - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glTranslatef(guiLeft + 62, guiTop + 4, 0); - {//Draw Ring - GL11.glTranslatef(26, 26, 0); - GL11.glRotatef(rotation, 0, 0, 1); - GL11.glTranslatef(-26, -26, 0); - drawTexturedModalRect(0, 0, xSize, 63, 52, 52); - } - if (tile.running && tile.transfer){ - Random rand = tile.getWorldObj().rand; - int boltL = rand.nextInt(4); - int boltS = rand.nextInt(3); - int boltT = rand.nextInt(10); - drawTexturedModalRect(0, 0, xSize, 115, 52, 52); + private void drawAnimatedParts() { + if (!tile.running) drawTexturedModalRect(guiLeft + 79, guiTop + 21, xSize, 45, 18, 18); + if (tile.running) rotation += 0.2F; + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glTranslatef(guiLeft + 62, guiTop + 4, 0); + {//Draw Ring + GL11.glTranslatef(26, 26, 0); + GL11.glRotatef(rotation, 0, 0, 1); + GL11.glTranslatef(-26, -26, 0); + drawTexturedModalRect(0, 0, xSize, 63, 52, 52); + } + if (tile.running && tile.transfer) { + Random rand = tile.getWorldObj().rand; + int boltL = rand.nextInt(4); + int boltS = rand.nextInt(3); + int boltT = rand.nextInt(10); + drawTexturedModalRect(0, 0, xSize, 115, 52, 52); - GL11.glColor4f(1F, 1F, 1F, 0.5F + (rand.nextFloat() / 2F)); - drawTexturedModalRect(0, 0, xSize, 167, 52, 52); - GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glColor4f(1F, 1F, 1F, 0.5F + (rand.nextFloat() / 2F)); + drawTexturedModalRect(0, 0, xSize, 167, 52, 52); + GL11.glColor4f(1F, 1F, 1F, 1F); - if (boltT == 5) { - GL11.glTranslatef(26, 26, 0); - GL11.glRotatef(boltL * 90, 0, 0, 1); - GL11.glTranslatef(-26, -26, 0); + if (boltT == 5) { + GL11.glTranslatef(26, 26, 0); + GL11.glRotatef(boltL * 90, 0, 0, 1); + GL11.glTranslatef(-26, -26, 0); - if (boltS == 0) { - GL11.glTranslatef(-(guiLeft + 62), -(guiTop + 4), 0); - GL11.glTranslatef(guiLeft + 68, guiTop + 23, 0); - drawTexturedModalRect(0, 0, 0, ySize, 27, 15); - } - if (boltS == 1) { - GL11.glTranslatef(-(guiLeft + 62), -(guiTop + 4), 0); - GL11.glTranslatef(guiLeft + 68, guiTop + 26, 0); - drawTexturedModalRect(0, 0, 0, 156, 25, 8); - } - if (boltS == 2) { - GL11.glTranslatef(-(guiLeft + 62), -(guiTop + 4), 0); - GL11.glTranslatef(guiLeft + 68, guiTop + 27, 0); - drawTexturedModalRect(0, 0, 0, 165, 23, 7); - } - if (boltS == 3) { - GL11.glTranslatef(-(guiLeft + 62), -(guiTop + 4), 0); - GL11.glTranslatef(guiLeft + 68, guiTop + 26, 0); - drawTexturedModalRect(0, 0, 0, 173, 26, 8); - } - } + if (boltS == 0) { + GL11.glTranslatef(-(guiLeft + 62), -(guiTop + 4), 0); + GL11.glTranslatef(guiLeft + 68, guiTop + 23, 0); + drawTexturedModalRect(0, 0, 0, ySize, 27, 15); + } + if (boltS == 1) { + GL11.glTranslatef(-(guiLeft + 62), -(guiTop + 4), 0); + GL11.glTranslatef(guiLeft + 68, guiTop + 26, 0); + drawTexturedModalRect(0, 0, 0, 156, 25, 8); + } + if (boltS == 2) { + GL11.glTranslatef(-(guiLeft + 62), -(guiTop + 4), 0); + GL11.glTranslatef(guiLeft + 68, guiTop + 27, 0); + drawTexturedModalRect(0, 0, 0, 165, 23, 7); + } + if (boltS == 3) { + GL11.glTranslatef(-(guiLeft + 62), -(guiTop + 4), 0); + GL11.glTranslatef(guiLeft + 68, guiTop + 26, 0); + drawTexturedModalRect(0, 0, 0, 173, 26, 8); + } + } - } + } - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIFlowGate.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIFlowGate.java index 1595292b..a76d3c13 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIFlowGate.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIFlowGate.java @@ -18,129 +18,139 @@ import java.util.List; */ public class GUIFlowGate extends GuiScreen { - public TileGate tile; + public TileGate tile; - public GUIFlowGate(TileGate gate){ - this.tile = gate; - } + public GUIFlowGate(TileGate gate) { + this.tile = gate; + } - @Override - public void initGui() { - int guiLeft = (width / 2) - (197 / 2); - int guiTop = (height / 2) - (88 / 2); - buttonList.clear(); - if (tile.flowOverridden) return; - buttonList.add(new GuiTextureButton(0, guiLeft + 20, guiTop + 20, 0, 108, 18, 18, "")); - buttonList.add(new GuiTextureButton(1, guiLeft + 159, guiTop + 20, 0, 54, 18, 18, "")); + @Override + public void initGui() { + int guiLeft = (width / 2) - (197 / 2); + int guiTop = (height / 2) - (88 / 2); + buttonList.clear(); + if (tile.flowOverridden) return; + buttonList.add(new GuiTextureButton(0, guiLeft + 20, guiTop + 20, 0, 108, 18, 18, "")); + buttonList.add(new GuiTextureButton(1, guiLeft + 159, guiTop + 20, 0, 54, 18, 18, "")); - buttonList.add(new GuiTextureButton(2, guiLeft + 20, guiTop + 50, 0, 108, 18, 18, "")); - buttonList.add(new GuiTextureButton(3, guiLeft + 159, guiTop + 50, 0, 54, 18, 18, "")); - } + buttonList.add(new GuiTextureButton(2, guiLeft + 20, guiTop + 50, 0, 108, 18, 18, "")); + buttonList.add(new GuiTextureButton(3, guiLeft + 159, guiTop + 50, 0, 54, 18, 18, "")); + } - @Override - public void drawScreen(int x, int y, float pt) { - int guiLeft = (width / 2) - (197 / 2); - int guiCrt = (width / 2); - int guiTop = (height / 2) - (88 / 2); + @Override + public void drawScreen(int x, int y, float pt) { + int guiLeft = (width / 2) - (197 / 2); + int guiCrt = (width / 2); + int guiTop = (height / 2) - (88 / 2); - drawDefaultBackground(); - ResourceHandler.bindResource("textures/gui/ToolConfig.png"); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, 197, 88); - fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.flowGate.name"), guiCrt - (fontRendererObj.getStringWidth(StatCollector.translateToLocal("gui.de.flowGate.name")) / 2), guiTop+5, 0x2c2c2c); + drawDefaultBackground(); + ResourceHandler.bindResource("textures/gui/ToolConfig.png"); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, 197, 88); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.flowGate.name"), guiCrt - (fontRendererObj.getStringWidth(StatCollector.translateToLocal("gui.de.flowGate.name")) / 2), guiTop + 5, 0x2c2c2c); - if (!tile.flowOverridden) - { - String flowRSLow = tile.getFlowSetting(0); - String flowRSHeigh = tile.getFlowSetting(1); - fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.flowGateRSHigh.name"), guiCrt - (fontRendererObj.getStringWidth(StatCollector.translateToLocal("gui.de.flowGateRSHigh.name")) / 2), guiTop + 20, 0xff0000); - fontRendererObj.drawString(flowRSHeigh, guiCrt - (fontRendererObj.getStringWidth(flowRSHeigh) / 2), guiTop + 31, 0x2c2c2c); - fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.flowGateRSLow.name"), guiCrt - (fontRendererObj.getStringWidth(StatCollector.translateToLocal("gui.de.flowGateRSLow.name")) / 2), guiTop + 50, 0x660000); - fontRendererObj.drawString(flowRSLow, guiCrt - (fontRendererObj.getStringWidth(flowRSLow) / 2), guiTop + 61, 0x2c2c2c); - }else drawCenteredString(fontRendererObj, StatCollector.translateToLocal("gui.de.flowGateOverridden.txt"), width / 2, height / 2 - 30, 0x00FF00); + if (!tile.flowOverridden) { + String flowRSLow = tile.getFlowSetting(0); + String flowRSHeigh = tile.getFlowSetting(1); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.flowGateRSHigh.name"), guiCrt - (fontRendererObj.getStringWidth(StatCollector.translateToLocal("gui.de.flowGateRSHigh.name")) / 2), guiTop + 20, 0xff0000); + fontRendererObj.drawString(flowRSHeigh, guiCrt - (fontRendererObj.getStringWidth(flowRSHeigh) / 2), guiTop + 31, 0x2c2c2c); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.flowGateRSLow.name"), guiCrt - (fontRendererObj.getStringWidth(StatCollector.translateToLocal("gui.de.flowGateRSLow.name")) / 2), guiTop + 50, 0x660000); + fontRendererObj.drawString(flowRSLow, guiCrt - (fontRendererObj.getStringWidth(flowRSLow) / 2), guiTop + 61, 0x2c2c2c); + } else + drawCenteredString(fontRendererObj, StatCollector.translateToLocal("gui.de.flowGateOverridden.txt"), width / 2, height / 2 - 30, 0x00FF00); - String flow = StatCollector.translateToLocal("gui.de.flowGateCurrentFlow.name") + ": " + Utills.addCommas(tile.getActualFlow()); - fontRendererObj.drawString(flow, guiCrt - (fontRendererObj.getStringWidth(flow) / 2), guiTop + 76, 0x2c2c2c); + String flow = StatCollector.translateToLocal("gui.de.flowGateCurrentFlow.name") + ": " + Utills.addCommas(tile.getActualFlow()); + fontRendererObj.drawString(flow, guiCrt - (fontRendererObj.getStringWidth(flow) / 2), guiTop + 76, 0x2c2c2c); - if (!tile.flowOverridden) - { - fontRendererObj.drawSplitString(StatCollector.translateToLocal("gui.de.flowGatePartialSignal.name"), guiLeft + 5, guiTop + 90, 197, 0xFFFFFF); - fontRendererObj.drawSplitString(StatCollector.translateToLocal("gui.de.ctrlAndShift.name"), guiLeft + 200, guiTop + 5, 100, 0xFFFFFF); + if (!tile.flowOverridden) { + fontRendererObj.drawSplitString(StatCollector.translateToLocal("gui.de.flowGatePartialSignal.name"), guiLeft + 5, guiTop + 90, 197, 0xFFFFFF); + fontRendererObj.drawSplitString(StatCollector.translateToLocal("gui.de.ctrlAndShift.name"), guiLeft + 200, guiTop + 5, 100, 0xFFFFFF); - ResourceHandler.bindResource("textures/gui/Widgets.png"); - super.drawScreen(x, y, pt); + ResourceHandler.bindResource("textures/gui/Widgets.png"); + super.drawScreen(x, y, pt); - List hoverText = new ArrayList(); - boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); - boolean ctrl = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); + List hoverText = new ArrayList(); + boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + boolean ctrl = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); - if (GuiHelper.isInRect(guiLeft + 20, guiTop + 20, 18, 18, x, y)) - { - hoverText.add(StatCollector.translateToLocal("gui.de.decrement.name") + " " + tile.getToolTip(1, shift, ctrl)); - } - if (GuiHelper.isInRect(guiLeft + 159, guiTop + 20, 18, 18, x, y)) - { - hoverText.add(StatCollector.translateToLocal("gui.de.increment.name") + " " + tile.getToolTip(1, shift, ctrl)); - } + if (GuiHelper.isInRect(guiLeft + 20, guiTop + 20, 18, 18, x, y)) { + hoverText.add(StatCollector.translateToLocal("gui.de.decrement.name") + " " + tile.getToolTip(1, shift, ctrl)); + } + if (GuiHelper.isInRect(guiLeft + 159, guiTop + 20, 18, 18, x, y)) { + hoverText.add(StatCollector.translateToLocal("gui.de.increment.name") + " " + tile.getToolTip(1, shift, ctrl)); + } - if (GuiHelper.isInRect(guiLeft + 20, guiTop + 50, 18, 18, x, y)) - { - hoverText.add(StatCollector.translateToLocal("gui.de.decrement.name") + " " + tile.getToolTip(0, shift, ctrl)); - } - if (GuiHelper.isInRect(guiLeft + 159, guiTop + 50, 18, 18, x, y)) - { - hoverText.add(StatCollector.translateToLocal("gui.de.increment.name") + " " + tile.getToolTip(0, shift, ctrl)); - } + if (GuiHelper.isInRect(guiLeft + 20, guiTop + 50, 18, 18, x, y)) { + hoverText.add(StatCollector.translateToLocal("gui.de.decrement.name") + " " + tile.getToolTip(0, shift, ctrl)); + } + if (GuiHelper.isInRect(guiLeft + 159, guiTop + 50, 18, 18, x, y)) { + hoverText.add(StatCollector.translateToLocal("gui.de.increment.name") + " " + tile.getToolTip(0, shift, ctrl)); + } - if (!hoverText.isEmpty()) - { - hoverText.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("gui.de.pressOrScroll.name")); - drawHoveringText(hoverText, x - (x < width / 2 ? fontRendererObj.getStringWidth(StatCollector.translateToLocal("gui.de.decrement.name") + " " + tile.getToolTip(1, shift, ctrl)) + 25 : 0), y, fontRendererObj); - } - } - } + if (!hoverText.isEmpty()) { + hoverText.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("gui.de.pressOrScroll.name")); + drawHoveringText(hoverText, x - (x < width / 2 ? fontRendererObj.getStringWidth(StatCollector.translateToLocal("gui.de.decrement.name") + " " + tile.getToolTip(1, shift, ctrl)) + 25 : 0), y, fontRendererObj); + } + } + } - @Override - protected void mouseClicked(int x, int y, int button) { - int guiLeft = (width / 2) - (197 / 2); - int guiTop = (height / 2) - (88 / 2); - boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); - boolean ctrl = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); + @Override + protected void mouseClicked(int x, int y, int button) { + int guiLeft = (width / 2) - (197 / 2); + int guiTop = (height / 2) - (88 / 2); + boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + boolean ctrl = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); - if (GuiHelper.isInRect(guiLeft + 20, guiTop + 20, 18, 18, x, y)){ tile.incrementFlow(1, ctrl, shift, false, button); } - if (GuiHelper.isInRect(guiLeft + 159, guiTop + 20, 18, 18, x, y)){ tile.incrementFlow(1, ctrl, shift, true, button); } + if (GuiHelper.isInRect(guiLeft + 20, guiTop + 20, 18, 18, x, y)) { + tile.incrementFlow(1, ctrl, shift, false, button); + } + if (GuiHelper.isInRect(guiLeft + 159, guiTop + 20, 18, 18, x, y)) { + tile.incrementFlow(1, ctrl, shift, true, button); + } - if (GuiHelper.isInRect(guiLeft + 20, guiTop + 50, 18, 18, x, y)){ tile.incrementFlow(0, ctrl, shift, false, button); } - if (GuiHelper.isInRect(guiLeft + 159, guiTop + 50, 18, 18, x, y)){ tile.incrementFlow(0, ctrl, shift, true, button); } + if (GuiHelper.isInRect(guiLeft + 20, guiTop + 50, 18, 18, x, y)) { + tile.incrementFlow(0, ctrl, shift, false, button); + } + if (GuiHelper.isInRect(guiLeft + 159, guiTop + 50, 18, 18, x, y)) { + tile.incrementFlow(0, ctrl, shift, true, button); + } - super.mouseClicked(x, y, button); - } + super.mouseClicked(x, y, button); + } - @Override - public void handleMouseInput() { - int guiLeft = (width / 2) - (197 / 2); - int guiTop = (height / 2) - (88 / 2); - int x = Mouse.getEventX() * this.width / this.mc.displayWidth; - int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; - boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); - boolean ctrl = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); - int i = org.lwjgl.input.Mouse.getEventDWheel(); + @Override + public void handleMouseInput() { + int guiLeft = (width / 2) - (197 / 2); + int guiTop = (height / 2) - (88 / 2); + int x = Mouse.getEventX() * this.width / this.mc.displayWidth; + int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; + boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + boolean ctrl = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); + int i = org.lwjgl.input.Mouse.getEventDWheel(); - if (i != 0 && GuiHelper.isInRect(guiLeft + 20, guiTop + 20, 18, 18, x, y)){ tile.incrementFlow(1, ctrl, shift, i < 0, 0); } - if (i != 0 && GuiHelper.isInRect(guiLeft + 159, guiTop + 20, 18, 18, x, y)){ tile.incrementFlow(1, ctrl, shift, i > 0, 0); } + if (i != 0 && GuiHelper.isInRect(guiLeft + 20, guiTop + 20, 18, 18, x, y)) { + tile.incrementFlow(1, ctrl, shift, i < 0, 0); + } + if (i != 0 && GuiHelper.isInRect(guiLeft + 159, guiTop + 20, 18, 18, x, y)) { + tile.incrementFlow(1, ctrl, shift, i > 0, 0); + } - if (i != 0 && GuiHelper.isInRect(guiLeft + 20, guiTop + 50, 18, 18, x, y)){ tile.incrementFlow(0, ctrl, shift, i < 0, 0); } - if (i != 0 && GuiHelper.isInRect(guiLeft + 159, guiTop + 50, 18, 18, x, y)){ tile.incrementFlow(0, ctrl, shift, i > 0, 0); } + if (i != 0 && GuiHelper.isInRect(guiLeft + 20, guiTop + 50, 18, 18, x, y)) { + tile.incrementFlow(0, ctrl, shift, i < 0, 0); + } + if (i != 0 && GuiHelper.isInRect(guiLeft + 159, guiTop + 50, 18, 18, x, y)) { + tile.incrementFlow(0, ctrl, shift, i > 0, 0); + } - super.handleMouseInput(); - } + super.handleMouseInput(); + } - @Override - public boolean doesGuiPauseGame() { - return false; - } + @Override + public boolean doesGuiPauseGame() { + return false; + } protected void keyTyped(char p_73869_1_, int key) { - if (key == 1 || key == this.mc.gameSettings.keyBindInventory.getKeyCode()){ + if (key == 1 || key == this.mc.gameSettings.keyBindInventory.getKeyCode()) { this.mc.displayGuiScreen(null); this.mc.setIngameFocus(); } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIGenerator.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIGenerator.java index 0486b856..861afa94 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIGenerator.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIGenerator.java @@ -21,94 +21,90 @@ import java.util.ArrayList; @SideOnly(Side.CLIENT) public class GUIGenerator extends GuiContainer { - public EntityPlayer player; - private TileGenerator tile; - private int guiUpdateTick; + public EntityPlayer player; + private TileGenerator tile; + private int guiUpdateTick; - public GUIGenerator(InventoryPlayer invPlayer, TileGenerator tile) { - super(new ContainerGenerator(invPlayer, tile)); + public GUIGenerator(InventoryPlayer invPlayer, TileGenerator tile) { + super(new ContainerGenerator(invPlayer, tile)); - xSize = 176; - ySize = 162; - - this.tile = tile; - this.player = invPlayer.player; - } + xSize = 176; + ySize = 162; - private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/Grinder.png"); + this.tile = tile; + this.player = invPlayer.player; + } - @Override - protected void drawGuiContainerBackgroundLayer(float f, int X, int Y) - { - GL11.glColor4f(1, 1, 1, 1); + private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/Grinder.png"); - Minecraft.getMinecraft().getTextureManager().bindTexture(texture); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - drawTexturedModalRect(guiLeft + 63, guiTop + 34, 0, ySize, 18, 18);//fuel box - drawTexturedModalRect(guiLeft + 97, guiTop + 34, 18, ySize, 18, 18);//flame box - if (tile.getStackInSlot(0) == null) - drawTexturedModalRect(guiLeft + 63, guiTop + 34, 36, ySize, 18, 18);//fuel box - - float power = (float)tile.getEnergyStored(ForgeDirection.DOWN) / (float)tile.getMaxEnergyStored(ForgeDirection.DOWN) * -1 + 1; - float fuel = tile.burnTimeRemaining / ((float)tile.burnTime) * -1 + 1; - - drawTexturedModalRect(guiLeft + 83, guiTop + 11 + (int)(power*40), xSize, 0 + (int)(power*40), 12, 40 - (int)(power*40));//Power bar - drawTexturedModalRect(guiLeft + 100, guiTop + 37 + (int)(fuel*13), xSize, 40 + (int)(fuel*13), 18, 18 - (int)(fuel*13));//Power bar + @Override + protected void drawGuiContainerBackgroundLayer(float f, int X, int Y) { + GL11.glColor4f(1, 1, 1, 1); - fontRendererObj.drawStringWithShadow("Generator", guiLeft + 64, guiTop + 0, 0x00FFFF); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + drawTexturedModalRect(guiLeft + 63, guiTop + 34, 0, ySize, 18, 18);//fuel box + drawTexturedModalRect(guiLeft + 97, guiTop + 34, 18, ySize, 18, 18);//flame box + if (tile.getStackInSlot(0) == null) + drawTexturedModalRect(guiLeft + 63, guiTop + 34, 36, ySize, 18, 18);//fuel box - int x = X - guiLeft; - int y = Y - guiTop; - if (GuiHelper.isInRect(83, 10, 12, 40, x, y)) { - ArrayList internal = new ArrayList(); - internal.add("Internal Storage"); - internal.add("" + EnumChatFormatting.DARK_BLUE + tile.getEnergyStored(ForgeDirection.UP) + "/" + tile.getMaxEnergyStored(ForgeDirection.UP)); - drawHoveringText(internal, x + guiLeft, y + guiTop, fontRendererObj); - } - } - - @Override - protected void drawGuiContainerForegroundLayer(int X, int Y) - { + float power = (float) tile.getEnergyStored(ForgeDirection.DOWN) / (float) tile.getMaxEnergyStored(ForgeDirection.DOWN) * -1 + 1; + float fuel = tile.burnTimeRemaining / ((float) tile.burnTime) * -1 + 1; - int x = X - guiLeft; - int y = Y - guiTop; - /* if (GuiHelper.isInRect(83, 10, 95, 50, x, y)) { + drawTexturedModalRect(guiLeft + 83, guiTop + 11 + (int) (power * 40), xSize, 0 + (int) (power * 40), 12, 40 - (int) (power * 40));//Power bar + drawTexturedModalRect(guiLeft + 100, guiTop + 37 + (int) (fuel * 13), xSize, 40 + (int) (fuel * 13), 18, 18 - (int) (fuel * 13));//Power bar + + fontRendererObj.drawStringWithShadow("Generator", guiLeft + 64, guiTop + 0, 0x00FFFF); + + int x = X - guiLeft; + int y = Y - guiTop; + if (GuiHelper.isInRect(83, 10, 12, 40, x, y)) { + ArrayList internal = new ArrayList(); + internal.add("Internal Storage"); + internal.add("" + EnumChatFormatting.DARK_BLUE + tile.getEnergyStored(ForgeDirection.UP) + "/" + tile.getMaxEnergyStored(ForgeDirection.UP)); + drawHoveringText(internal, x + guiLeft, y + guiTop, fontRendererObj); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int X, int Y) { + + int x = X - guiLeft; + int y = Y - guiTop; + /* if (GuiHelper.isInRect(83, 10, 95, 50, x, y)) { ArrayList internal = new ArrayList(); internal.add("Internal Storage"); internal.add("" + EnumChatFormatting.DARK_BLUE + tile.getEnergyStored(ForgeDirection.UP) + "/" + tile.getMaxEnergyStored(ForgeDirection.UP)); drawHoveringText(internal, x, y, fontRendererObj); } -*/ } - - @Override - public void initGui() - { - super.initGui(); - - //ID - //buttonList.add(new GuiButton(0, guiLeft + 85, guiTop , 85, 20, text)); - } - - @Override - protected void actionPerformed(GuiButton button) - { - - - } - - @Override - public void updateScreen() - { - guiUpdateTick++; - if (guiUpdateTick >= 10){ - initGui(); - guiUpdateTick = 0; - } - super.updateScreen(); - - } - - // ####Draw at############ read from size - //drawTexturedModalRect(guiLeft + 37, guiTop + 4, 0, 143, 37, 38); +*/ + } + + @Override + public void initGui() { + super.initGui(); + + //ID + //buttonList.add(new GuiButton(0, guiLeft + 85, guiTop , 85, 20, text)); + } + + @Override + protected void actionPerformed(GuiButton button) { + + + } + + @Override + public void updateScreen() { + guiUpdateTick++; + if (guiUpdateTick >= 10) { + initGui(); + guiUpdateTick = 0; + } + super.updateScreen(); + + } + + // ####Draw at############ read from size + //drawTexturedModalRect(guiLeft + 37, guiTop + 4, 0, 143, 37, 38); } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIGrinder.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIGrinder.java index 386a365f..0d5e0e61 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIGrinder.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIGrinder.java @@ -21,100 +21,94 @@ import java.util.ArrayList; @SideOnly(Side.CLIENT) public class GUIGrinder extends GuiContainer { - public EntityPlayer player; - private TileGrinder tile; - private int guiUpdateTick; - - public GUIGrinder(InventoryPlayer invPlayer, TileGrinder tile) { - super(new ContainerGrinder(invPlayer, tile)); + public EntityPlayer player; + private TileGrinder tile; + private int guiUpdateTick; - xSize = 176; - ySize = 162; - - this.tile = tile; - this.player = invPlayer.player; - } + public GUIGrinder(InventoryPlayer invPlayer, TileGrinder tile) { + super(new ContainerGrinder(invPlayer, tile)); - private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/Grinder.png"); + xSize = 176; + ySize = 162; - @Override - protected void drawGuiContainerBackgroundLayer(float f, int X, int Y) { - GL11.glColor4f(1, 1, 1, 1); + this.tile = tile; + this.player = invPlayer.player; + } - Minecraft.getMinecraft().getTextureManager().bindTexture(texture); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - if (!tile.isExternallyPowered()) - drawTexturedModalRect(guiLeft + 63, guiTop + 34, 0, ySize, 18, 18);//fuel box - drawTexturedModalRect(guiLeft + 97, guiTop + 34, 18, ySize, 18, 18);//flame box - if (tile.getStackInSlot(0) == null && !tile.isExternallyPowered()) - drawTexturedModalRect(guiLeft + 63, guiTop + 34, 36, ySize, 18, 18);//fuel box + private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/Grinder.png"); - float power; - if (tile.isExternallyPowered()){ - power = (float) tile.getEnergyStored(ForgeDirection.DOWN) / (float) tile.getMaxEnergyStored(ForgeDirection.DOWN) * -1 + 1; - }else { - power = (float) tile.getInternalBuffer().getEnergyStored() / (float) tile.getInternalBuffer().getMaxEnergyStored() * -1 + 1; - } - float fuel = tile.burnTimeRemaining / ((float)tile.burnTime) * -1 + 1; - - drawTexturedModalRect(guiLeft + 83, guiTop + 11 + (int)(power*40), xSize, 0 + (int)(power*40), 12, 40 - (int)(power*40));//Power bar - drawTexturedModalRect(guiLeft + 100, guiTop + 37 + (int)(fuel*13), xSize, 40 + (int)(fuel*13), 18, 18 - (int)(fuel*13));//Power bar - if (tile.isExternallyPowered()) - drawTexturedModalRect(guiLeft + 100, guiTop + 37, xSize, 66, 13, 13); + @Override + protected void drawGuiContainerBackgroundLayer(float f, int X, int Y) { + GL11.glColor4f(1, 1, 1, 1); - fontRendererObj.drawStringWithShadow("Grinder", guiLeft + 71, guiTop + 0, 0x00FFFF); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + if (!tile.isExternallyPowered()) drawTexturedModalRect(guiLeft + 63, guiTop + 34, 0, ySize, 18, 18);//fuel box + drawTexturedModalRect(guiLeft + 97, guiTop + 34, 18, ySize, 18, 18);//flame box + if (tile.getStackInSlot(0) == null && !tile.isExternallyPowered()) + drawTexturedModalRect(guiLeft + 63, guiTop + 34, 36, ySize, 18, 18);//fuel box - int x = X - guiLeft; - int y = Y - guiTop; - if (GuiHelper.isInRect(83, 10, 12, 40, x, y)) { - ArrayList internal = new ArrayList(); - internal.add("Energy Buffer"); - if (tile.isExternallyPowered()) { - internal.add("" + EnumChatFormatting.DARK_BLUE + tile.getEnergyStored(ForgeDirection.UP) + "/" + tile.getMaxEnergyStored(ForgeDirection.UP)); - } else { - internal.add("" + EnumChatFormatting.DARK_BLUE + tile.getInternalBuffer().getEnergyStored() + "/" + tile.getInternalBuffer().getMaxEnergyStored()); - } - drawHoveringText(internal, x + guiLeft, y + guiTop, fontRendererObj); - } - } - - @Override - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) - { - //fontRendererObj.drawString("Charges: " + charges, 90, 25, 0x000000); - //drawCenteredString(fontRendererObj, "Charges: " + charges, 117, 25, 0x000000); - //drawCenteredString(fontRendererObj, "Weather Controller", xSize/2, -15, 0x2a4ed0); - - } - - @Override - public void initGui() - { - super.initGui(); - - //ID - //buttonList.add(new GuiButton(0, guiLeft + 85, guiTop , 85, 20, text)); - } - - @Override - protected void actionPerformed(GuiButton button) - { - - - } - - @Override - public void updateScreen() - { - guiUpdateTick++; - if (guiUpdateTick >= 10){ - initGui(); - guiUpdateTick = 0; - } - super.updateScreen(); - - } + float power; + if (tile.isExternallyPowered()) { + power = (float) tile.getEnergyStored(ForgeDirection.DOWN) / (float) tile.getMaxEnergyStored(ForgeDirection.DOWN) * -1 + 1; + } else { + power = (float) tile.getInternalBuffer().getEnergyStored() / (float) tile.getInternalBuffer().getMaxEnergyStored() * -1 + 1; + } + float fuel = tile.burnTimeRemaining / ((float) tile.burnTime) * -1 + 1; - // ####Draw at############ read from size - //drawTexturedModalRect(guiLeft + 37, guiTop + 4, 0, 143, 37, 38); + drawTexturedModalRect(guiLeft + 83, guiTop + 11 + (int) (power * 40), xSize, 0 + (int) (power * 40), 12, 40 - (int) (power * 40));//Power bar + drawTexturedModalRect(guiLeft + 100, guiTop + 37 + (int) (fuel * 13), xSize, 40 + (int) (fuel * 13), 18, 18 - (int) (fuel * 13));//Power bar + if (tile.isExternallyPowered()) drawTexturedModalRect(guiLeft + 100, guiTop + 37, xSize, 66, 13, 13); + + fontRendererObj.drawStringWithShadow("Grinder", guiLeft + 71, guiTop + 0, 0x00FFFF); + + int x = X - guiLeft; + int y = Y - guiTop; + if (GuiHelper.isInRect(83, 10, 12, 40, x, y)) { + ArrayList internal = new ArrayList(); + internal.add("Energy Buffer"); + if (tile.isExternallyPowered()) { + internal.add("" + EnumChatFormatting.DARK_BLUE + tile.getEnergyStored(ForgeDirection.UP) + "/" + tile.getMaxEnergyStored(ForgeDirection.UP)); + } else { + internal.add("" + EnumChatFormatting.DARK_BLUE + tile.getInternalBuffer().getEnergyStored() + "/" + tile.getInternalBuffer().getMaxEnergyStored()); + } + drawHoveringText(internal, x + guiLeft, y + guiTop, fontRendererObj); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { + //fontRendererObj.drawString("Charges: " + charges, 90, 25, 0x000000); + //drawCenteredString(fontRendererObj, "Charges: " + charges, 117, 25, 0x000000); + //drawCenteredString(fontRendererObj, "Weather Controller", xSize/2, -15, 0x2a4ed0); + + } + + @Override + public void initGui() { + super.initGui(); + + //ID + //buttonList.add(new GuiButton(0, guiLeft + 85, guiTop , 85, 20, text)); + } + + @Override + protected void actionPerformed(GuiButton button) { + + + } + + @Override + public void updateScreen() { + guiUpdateTick++; + if (guiUpdateTick >= 10) { + initGui(); + guiUpdateTick = 0; + } + super.updateScreen(); + + } + + // ####Draw at############ read from size + //drawTexturedModalRect(guiLeft + 37, guiTop + 4, 0, 143, 37, 38); } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIParticleGenerator.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIParticleGenerator.java index e984e758..2489b105 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIParticleGenerator.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIParticleGenerator.java @@ -14,811 +14,806 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; public class GUIParticleGenerator extends GuiScreen { - private final int xSize = 212; - private final int ySize = 198; - private ResourceLocation guiTexture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/ParticleGenerator.png"); - private int page = 1; - private int infoPage = 0; - private boolean hasInitialized = false; - - //Particle variables - private boolean particles_enabled = true; - - private int red = 0; - private int green = 0; - private int blue = 0; - private int random_red = 0; - private int random_green = 0; - private int random_blue = 0; - private float motion_x = 0F; - private float motion_y = 0F; - private float motion_z = 0F; - private float random_motion_x = 0F; - private float random_motion_y = 0F; - private float random_motion_z = 0F; - private float scale = 0F; - private float random_scale = 0F; - private int life = 0; - private int random_life = 0; - private float spawn_x = 0F; - private float spawn_y = 0F; - private float spawn_z = 0F; - private float random_spawn_x = 0F; - private float random_spawn_y = 0F; - private float random_spawn_z = 0F; - private int fade = 0; - private int spawn_rate = 0; - private boolean collide = false; - private int selected_particle = 1; - private int selected_max = 3; - private float gravity = 0F; - - //Beam variables - private boolean beam_enabled = false; - private boolean render_core = false; - - private int beam_red = 0; - private int beam_green = 0; - private int beam_blue = 0; - private float beam_scale = 0F; - private float beam_pitch = 0F; - private float beam_yaw = 0F; - private float beam_length = 0F; - private float beam_rotation = 0F; - - - //Buttons - - //Info Page - //particle selection - - private TileParticleGenerator tile; - - public GUIParticleGenerator(TileParticleGenerator tile, EntityPlayer player) { - super(); - this.tile = tile; - syncWithServer(); - } - - String[] InfoText = {"" + "The Particle Generator is a decorative device that allows you to create your own custom particle effects. " + "It is fairly easy you use this device you simply adjust the fields (variables) in the interface to change how the generated particles look and behave. " + "This block is a work in progress and new features and particles are likely to be added in future versions. " + "The following is a list of all of the fields in the interface and what they do.", "The first thing to note is that most fields have a random modifier which will add a random number between 0 and whatever max (or min) value you give it to the field. " + "-The first 3 fields (Red, Green & Blue) control the colour of the particle. Most people should be familiar with this colour system if not google RGB colours. Note: the max value for each colour can not go higher then 255 so the colour field limits the random modifier e.g. if the colour field is set to 255 and the random modifier is set to 20 the result will always be 255", "-The next 3 fields (Motion X, Y & Z) control the direction and speed of the particle " + "-The \"Life\" field sets how long (in ticks) before the particle despawns. " + "-The \"Size\" field sets the size of the particle. " + "-The next 3 fields (Spawn X, Y & Z) Sets the spawn location of the particle (relative to the location of the particle generator)", "-The \"Delay\" field sets the delay (in ticks) between each particle spawn e.g. 1=20/s, 20=1/s, 100=1/5s " + "-The \"Fade\" field sets how long (in ticks) it takes the partile to fade out of existance. Note: This adds to the life of the particle " + "-The \"Gravity\" field sets how the particle is affected by gravity. " + "-\"Block Collision\" Toggles weather or not the particle will collide with blocks " + "-\"Particle Selected\" Switches between the different particles available.", EnumChatFormatting.DARK_RED + " Redstone Control" + EnumChatFormatting.BLACK + "\nBy default a redstone signal is required for the generator to run." + "\n\nHowever if you shift right click the generator with an empty hand it will switch to inverted mode." + "\nThe redstone mode is indicated by the 8 cubes at the corners of the block.", EnumChatFormatting.DARK_RED + " Computer Control" + EnumChatFormatting.BLACK + "\nThe Generator can be controlled via a computer" + "\nIt exposes a relatively straight forward API:" + "\n\n setGeneratorProperty(property, value)\n getGeneratorState()\n resetGeneratorState()" + "\n\nGenerator state is obtained as a whole from getGeneratorState, whereas properties are modified one at a time using setGeneratorProperty. Property names are strings and mostly correspond to button labels in the GUI."}; - - //@formatter:off - @Override - public void drawScreen(int x, int y, float f) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - Minecraft.getMinecraft().renderEngine.bindTexture(guiTexture); - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - drawTexturedModalRect(posX, posY, 0, 0, xSize, ySize); - if (page < 3) fontRendererObj.drawStringWithShadow("Particle Generator", posX + 60, posY + 5, 0x00FFFF); - else if (page < 10) fontRendererObj.drawStringWithShadow("Beam Generator", posX + 65, posY + 5, 0x00FFFF); - else fontRendererObj.drawStringWithShadow("Information", posX + 75, posY + 5, 0x00FFFF); - - if (page == 1) page1Txt(); - else if (page == 2) page2Txt(); - else if (page == 3) page3Txt(); - else if (page == 10) { - fontRendererObj.drawSplitString(InfoText[infoPage], posX + 5, posY + 20, 200, 0x000000); - fontRendererObj.drawSplitString("Page: " + (infoPage + 1), posX + 88, posY + 180, 200, 0xFF0000); - } - - fontRendererObj.drawStringWithShadow("Hold:", posX + 215, posY + 11, 0xFFFFFF); - fontRendererObj.drawStringWithShadow("Shift +- 10", posX + 215, posY + 21, 0xFFFFFF); - fontRendererObj.drawStringWithShadow("Ctrl +- 50", posX + 215, posY + 31, 0xFFFFFF); - fontRendererObj.drawStringWithShadow("Shift+Ctrl +- 100", posX + 215, posY + 41, 0xFFFFFF); - - super.drawScreen(x, y, f); - } - //@formatter:on - - @Override - protected void mouseClicked(int x, int y, int button) { - super.mouseClicked(x, y, button); - } - - @SuppressWarnings("unchecked") - @Override - public void initGui() { - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - buttonList.clear(); - - if (page < 10) - { - buttonList.add(new GuiButton(33, posX + 213, posY + 177, 47, 20, "===>")); - buttonList.add(new GuiButton(32, posX - 47, posY + 177, 47, 20, "<===")); - } - - if (page == 1) page1Buttons(); - else if (page == 2) page2Buttons(); - else if (page == 3) page3Buttons(); - else if (page == 10){ - buttonList.add(new GuiButton(57, posX + 4, posY + 174, 80, 20, "Previous page")); - buttonList.add(new GuiButton(56, posX + 128, posY + 174, 80, 20, "Next page")); - } - - if (page < 10) buttonList.add(new GuiButton(54, posX - 21, posY + 3, 20, 20, "i")); - else buttonList.add(new GuiButton(55, posX - 31, posY + 23, 30, 20, "Back")); - - - - - } - - @Override - protected void actionPerformed(GuiButton button) { - if (button.id < 100) particleActions(button); - else beamActions(button); - } - - private void particleActions(GuiButton button) { - int value = 1; - float value_F; - short packetValue = 0; - if (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)) value = 10; - if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) value = 50; - if ((Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54))) - value = 100; - - value_F = (value) / 1000F; - - switch (button.id) - { - case 0://Red + - red = (red + value) > 255 ? 255 : red + value; - packetValue = (short) red; - break; - case 1://Green + - green = (green + value) > 255 ? 255 : green + value; - packetValue = (short) green; - break; - case 2://Blue + - blue = (blue + value) > 255 ? 255 : blue + value; - packetValue = (short) blue; - break; - case 3://MX + - motion_x = (motion_x + value_F) > 5F ? 5F : motion_x + value_F; - packetValue = (short) (motion_x * 1000F); - break; - case 4://MY + - motion_y = (motion_y + value_F) > 5F ? 5F : motion_y + value_F; - packetValue = (short) (motion_y * 1000F); - break; - case 5://MZ + - motion_z = (motion_z + value_F) > 5F ? 5F : motion_z + value_F; - packetValue = (short) (motion_z * 1000F); - break; - case 6://Red - - red = (red - value) < 0 ? 0 : red - value; - packetValue = (short) red; - break; - case 7://Green - - green = (green - value) < 0 ? 0 : green - value; - packetValue = (short) green; - break; - case 8://Blue - - blue = (blue - value) < 0 ? 0 : blue - value; - packetValue = (short) blue; - break; - case 9://MX - - motion_x = (motion_x - value_F) < -5F ? -5F : motion_x - value_F; - packetValue = (short) (motion_x * 1000F); - break; - case 10://MY - - motion_y = (motion_y - value_F) < -5F ? -5F : motion_y - value_F; - packetValue = (short) (motion_y * 1000F); - break; - case 11://MZ - - motion_z = (motion_z - value_F) < -5F ? -5F : motion_z - value_F; - packetValue = (short) (motion_z * 1000F); - break; - case 12://RRed + - random_red = (random_red + value) > 255 ? 255 : random_red + value; - packetValue = (short) random_red; - break; - case 13://RGreen + - random_green = (random_green + value) > 255 ? 255 : random_green + value; - packetValue = (short) random_green; - break; - case 14://RBlue + - random_blue = (random_blue + value) > 255 ? 255 : random_blue + value; - packetValue = (short) random_blue; - break; - case 15://RMX + - random_motion_x = (random_motion_x + value_F) > 5F ? 5F : random_motion_x + value_F; - packetValue = (short) (random_motion_x * 1000F); - break; - case 16://RMY + - random_motion_y = (random_motion_y + value_F) > 5F ? 5F : random_motion_y + value_F; - packetValue = (short) (random_motion_y * 1000F); - break; - case 17://RMZ + - random_motion_z = (random_motion_z + value_F) > 5F ? 5F : random_motion_z + value_F; - packetValue = (short) (random_motion_z * 1000F); - break; - case 18://RRed - - random_red = (random_red - value) < 0 ? 0 : random_red - value; - packetValue = (short) random_red; - break; - case 19://RGreen - - random_green = (random_green - value) < 0 ? 0 : random_green - value; - packetValue = (short) random_green; - break; - case 20://RBlue - - random_blue = (random_blue - value) < 0 ? 0 : random_blue - value; - packetValue = (short) random_blue; - break; - case 21://RMX - - random_motion_x = (random_motion_x - value_F) < -5F ? -5F : random_motion_x - value_F; - packetValue = (short) (random_motion_x * 1000F); - break; - case 22://RMY - - random_motion_y = (random_motion_y - value_F) < -5F ? -5F : random_motion_y - value_F; - packetValue = (short) (random_motion_y * 1000F); - break; - case 23://RMZ - - random_motion_z = (random_motion_z - value_F) < -5F ? -5F : random_motion_z - value_F; - packetValue = (short) (random_motion_z * 1000F); - break; - case 24://Life + - life = (life + value) > 1000 ? 1000 : life + value; - packetValue = (short) life; - break; - case 25://Life - - life = (life - value) < 0 ? 0 : life - value; - packetValue = (short) life; - break; - case 26://RLife + - random_life = (random_life + value) > 1000 ? 1000 : random_life + value; - packetValue = (short) random_life; - break; - case 27://RLife - - random_life = (random_life - value) < 0 ? 0 : random_life - value; - packetValue = (short) random_life; - break; - case 28://Size + - scale = (scale + value_F * 10F) > 50F ? 50F : scale + value_F * 10F; - packetValue = (short) (scale * 100F); - break; - case 29://Size - - scale = (scale - value_F * 10F) < 0.01F ? 0.01F : scale - value_F * 10F; - packetValue = (short) (scale * 100F); - break; - case 30://RSize + - random_scale = (random_scale + value_F * 10F) > 50F ? 50F : random_scale + value_F * 10F; - packetValue = (short) (random_scale * 100F); - break; - case 31://RSize - - random_scale = (random_scale - value_F * 10F) < 0.0F ? 0.0F : random_scale - value_F * 10F; - packetValue = (short) (random_scale * 100F); - break; - case 32://Page 2 - if (page > 1) page--; - packetValue = (short) page; - initGui(); - break; - case 33://Page 1 - if (page < 3) page++; - initGui(); - packetValue = (short) page; - break; - case 34://SX + - spawn_x = (spawn_x + value_F * 100F) > 50F ? 50F : spawn_x + value_F * 100F; - packetValue = (short) (spawn_x * 100F); - break; - case 35://SX - - spawn_x = (spawn_x - value_F * 100F) < -50F ? -50F : spawn_x - value_F * 100F; - packetValue = (short) (spawn_x * 100F); - break; - case 36://RSX + - random_spawn_x = (random_spawn_x + value_F * 100F) > 50F ? 50F : random_spawn_x + value_F * 100F; - packetValue = (short) (random_spawn_x * 100F); - break; - case 37://RSX - - random_spawn_x = (random_spawn_x - value_F * 100F) < -50F ? -50F : random_spawn_x - value_F * 100F; - packetValue = (short) (random_spawn_x * 100F); - break; - case 38://SY + - spawn_y = (spawn_y + value_F * 100F) > 50F ? 50F : spawn_y + value_F * 100F; - packetValue = (short) (spawn_y * 100F); - break; - case 39://SY - - spawn_y = (spawn_y - value_F * 100F) < -50F ? -50F : spawn_y - value_F * 100F; - packetValue = (short) (spawn_y * 100F); - break; - case 40://RSY + - random_spawn_y = (random_spawn_y + value_F * 100F) > 50F ? 50F : random_spawn_y + value_F * 100F; - packetValue = (short) (random_spawn_y * 100F); - break; - case 41://RSY - - random_spawn_y = (random_spawn_y - value_F * 100F) < -50F ? -50F : random_spawn_y - value_F * 100F; - packetValue = (short) (random_spawn_y * 100F); - break; - case 42://SZ + - spawn_z = (spawn_z + value_F * 100F) > 50F ? 50F : spawn_z + value_F * 100F; - packetValue = (short) (spawn_z * 100F); - break; - case 43://SZ - - spawn_z = (spawn_z - value_F * 100F) < -50F ? -50F : spawn_z - value_F * 100F; - packetValue = (short) (spawn_z * 100F); - break; - case 44://RSZ + - random_spawn_z = (random_spawn_z + value_F * 100F) > 50F ? 50F : random_spawn_z + value_F * 100F; - packetValue = (short) (random_spawn_z * 100F); - break; - case 45://RSZ - - random_spawn_z = (random_spawn_z - value_F * 100F) < -50F ? -50F : random_spawn_z - value_F * 100F; - packetValue = (short) (random_spawn_z * 100F); - break; - case 46://Delay + - spawn_rate = (spawn_rate + value) > 200 ? 200 : spawn_rate + value; - packetValue = (short) spawn_rate; - break; - case 47://Delay - - spawn_rate = (spawn_rate - value) < 1 ? 1 : spawn_rate - value; - packetValue = (short) spawn_rate; - break; - case 48://Fade + - fade = (fade + value) > 100 ? 100 : fade + value; - packetValue = (short) fade; - break; - case 49://Fade - - fade = (fade - value) < 0 ? 0 : fade - value; - packetValue = (short) fade; - break; - case 50://Toggle Collision - collide = !collide; - packetValue = (short) (collide ? 1 : 0); - initGui(); - break; - case 51://cycle particle selection - selected_particle = selected_particle < selected_max ? selected_particle + 1 : 1; - packetValue = (short) selected_particle; - initGui(); - break; - case 52://RSZ + - gravity = (gravity + value_F) > 5F ? 5F : gravity + value_F; - packetValue = (short) (gravity * 1000F); - break; - case 53://RSZ - - gravity = (gravity - value_F) < -5F ? -5F : gravity - value_F; - packetValue = (short) (gravity * 1000F); - break; - case 54://Info Page - page = 10; - initGui(); - packetValue = (short) page; - break; - case 55://Back Page - page = 1; - initGui(); - packetValue = (short) page; - break; - case 56://Info Next Page - if (infoPage < 5) infoPage++; - else initGui(); - break; - case 57://Info Previous Page - if (infoPage > 0) infoPage--; - else initGui(); - break; - case 58://particles Enabled - particles_enabled = !particles_enabled; - packetValue = particles_enabled ? (byte)1 : (byte)0; - initGui(); - break; - } - DraconicEvolution.network.sendToServer(new ParticleGenPacket((byte) button.id, packetValue, tile.xCoord, tile.yCoord, tile.zCoord)); - } - - @Override - public void keyTyped(char key, int keyN) { - if ((key == 'e') || key == '') { - this.mc.displayGuiScreen(null); - this.mc.setIngameFocus(); - } - } - - @Override - public void updateScreen() { - } - - @Override - public boolean doesGuiPauseGame() { - return false; - } - - private void syncWithServer() { - red = tile.red; - green = tile.green; - blue = tile.blue; - random_red = tile.random_red; - random_green = tile.random_green; - random_blue = tile.random_blue; - motion_x = tile.motion_x; - motion_y = tile.motion_y; - motion_z = tile.motion_z; - random_motion_x = tile.random_motion_x; - random_motion_y = tile.random_motion_y; - random_motion_z = tile.random_motion_z; - scale = tile.scale; - random_scale = tile.random_scale; - life = tile.life; - random_life = tile.random_life; - spawn_x = tile.spawn_x; - spawn_y = tile.spawn_y; - spawn_z = tile.spawn_z; - random_spawn_x = tile.random_spawn_x; - random_spawn_y = tile.random_spawn_y; - random_spawn_z = tile.random_spawn_z; - page = tile.page; - spawn_rate = tile.spawn_rate; - collide = tile.collide; - fade = tile.fade; - selected_particle = tile.selected_particle; - gravity = tile.gravity; - particles_enabled = tile.particles_enabled; - - render_core = tile.render_core; - beam_enabled = tile.beam_enabled; - beam_red = tile.beam_red; - beam_green = tile.beam_green; - beam_blue = tile.beam_blue; - beam_scale = tile.beam_scale; - beam_pitch = tile.beam_pitch; - beam_yaw = tile.beam_yaw; - beam_length = tile.beam_length; - beam_rotation = tile.beam_rotation; - } - - //@formatter:off - private void page1Txt() { - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - - String motionX = String.valueOf(Math.round(motion_x * 1000F) / 1000F); - String motionY = String.valueOf(Math.round(motion_y * 1000F) / 1000F); - String motionZ = String.valueOf(Math.round(motion_z * 1000F) / 1000F); - String random_motionX = String.valueOf(Math.round(random_motion_x * 1000F) / 1000F); - String random_motionY = String.valueOf(Math.round(random_motion_y * 1000F) / 1000F); - String random_motionZ = String.valueOf(Math.round(random_motion_z * 1000F) / 1000F); - String scale1 = String.valueOf(Math.round(scale * 100F) / 100F); - String random_scale1 = String.valueOf(Math.round(random_scale * 100F) / 100F); - - int col1 = posX + 30; - int col2 = posX + 141; - int ln1 = 20; - int ln2 = 30; - - fontRendererObj.drawString("Red:", col1, posY + ln1 + 0 * 22, 0x000000, false); - fontRendererObj.drawString(String.valueOf(red), col1, posY + ln2 + 0 * 22, 0x000000, false); - fontRendererObj.drawString("Green:", col1, posY + ln1 + 1 * 22, 0x000000, false); - fontRendererObj.drawString(String.valueOf(green), col1, posY + ln2 + 1 * 22, 0x000000, false); - fontRendererObj.drawString("Blue:", col1, posY + ln1 + 2 * 22, 0x000000, false); - fontRendererObj.drawString(String.valueOf(blue), col1, posY + ln2 + 2 * 22, 0x000000, false); - fontRendererObj.drawString("Motion X:", col1, posY + ln1 + 3 * 22, 0x000000, false); - fontRendererObj.drawString(motionX, col1, posY + ln2 + 3 * 22, 0x000000, false); - fontRendererObj.drawString("Motion Y:", col1, posY + ln1 + 4 * 22, 0x000000, false); - fontRendererObj.drawString(motionY, col1, posY + ln2 + 4 * 22, 0x000000, false); - fontRendererObj.drawString("Motion Z:", col1, posY + ln1 + 5 * 22, 0x000000, false); - fontRendererObj.drawString(motionZ, col1, posY + ln2 + 5 * 22, 0x000000, false); - fontRendererObj.drawString("Life:", col1, posY + ln1 + 6 * 22, 0x000000, false); - fontRendererObj.drawString("" + life + " T", col1, posY + ln2 + 6 * 22, 0x000000, false); - fontRendererObj.drawString("Size:", col1, posY + ln1 + 7 * 22, 0x000000, false); - fontRendererObj.drawString("" + scale1, col1, posY + ln2 + 7 * 22, 0x000000, false); - - for (int i = 0; i < 8; i++) - fontRendererObj.drawStringWithShadow("(+)", posX + 98, posY + 25 + i * 22, 0xFFFFFF); - - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 0 * 22, 0x000000, false); - fontRendererObj.drawString("> " + random_red, col2, posY + ln2 + 0 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 1 * 22, 0x000000, false); - fontRendererObj.drawString("> " + random_green, col2, posY + ln2 + 1 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 2 * 22, 0x000000, false); - fontRendererObj.drawString("> " + random_blue, col2, posY + ln2 + 2 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 3 * 22, 0x000000, false); - fontRendererObj.drawString("> " + random_motionX, col2, posY + ln2 + 3 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 4 * 22, 0x000000, false); - fontRendererObj.drawString("> " + random_motionY, col2, posY + ln2 + 4 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 5 * 22, 0x000000, false); - fontRendererObj.drawString("> " + random_motionZ, col2, posY + ln2 + 5 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 6 * 22, 0x000000, false); - fontRendererObj.drawString("> " + random_life, col2, posY + ln2 + 6 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 7 * 22, 0x000000, false); - fontRendererObj.drawString("> " + random_scale1, col2, posY + ln2 + 7 * 22, 0x000000, false); - } - - @SuppressWarnings("unchecked") - private void page1Buttons() { - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - int DX1 = 5; - int DX2 = DX1 + 71; - int DX3 = DX2 + 40; - int DX4 = DX3 + 71; - int y1 = 19; - - buttonList.add(new GuiButton(0, posX + DX1, posY + y1 + 0 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(1, posX + DX1, posY + y1 + 1 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(2, posX + DX1, posY + y1 + 2 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(3, posX + DX1, posY + y1 + 3 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(4, posX + DX1, posY + y1 + 4 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(5, posX + DX1, posY + y1 + 5 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(24, posX + DX1, posY + y1 + 6 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(28, posX + DX1, posY + y1 + 7 * 22, 20, 20, "+")); - - buttonList.add(new GuiButton(6, posX + DX2, posY + y1 + 0 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(7, posX + DX2, posY + y1 + 1 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(8, posX + DX2, posY + y1 + 2 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(9, posX + DX2, posY + y1 + 3 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(10, posX + DX2, posY + y1 + 4 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(11, posX + DX2, posY + y1 + 5 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(25, posX + DX2, posY + y1 + 6 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(29, posX + DX2, posY + y1 + 7 * 22, 20, 20, "-")); - - buttonList.add(new GuiButton(12, posX + DX3, posY + y1 + 0 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(13, posX + DX3, posY + y1 + 1 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(14, posX + DX3, posY + y1 + 2 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(15, posX + DX3, posY + y1 + 3 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(16, posX + DX3, posY + y1 + 4 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(17, posX + DX3, posY + y1 + 5 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(26, posX + DX3, posY + y1 + 6 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(30, posX + DX3, posY + y1 + 7 * 22, 20, 20, "+")); - - buttonList.add(new GuiButton(18, posX + DX4, posY + y1 + 0 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(19, posX + DX4, posY + y1 + 1 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(20, posX + DX4, posY + y1 + 2 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(21, posX + DX4, posY + y1 + 3 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(22, posX + DX4, posY + y1 + 4 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(23, posX + DX4, posY + y1 + 5 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(27, posX + DX4, posY + y1 + 6 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(31, posX + DX4, posY + y1 + 7 * 22, 20, 20, "-")); - - - } - - private void page2Txt() { - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - - int col1 = posX + 30; - int col2 = posX + 141; - int ln1 = 20; - int ln2 = 30; - - String spawn_X = String.valueOf(Math.round(spawn_x * 10F) / 10F); - String spawn_Y = String.valueOf(Math.round(spawn_y * 10F) / 10F); - String spawn_Z = String.valueOf(Math.round(spawn_z * 10F) / 10F); - String random_spawn_X = String.valueOf(Math.round(random_spawn_x * 10F) / 10F); - String random_spawn_Y = String.valueOf(Math.round(random_spawn_y * 10F) / 10F); - String random_spawn_Z = String.valueOf(Math.round(random_spawn_z * 10F) / 10F); - String Gravity = String.valueOf(Math.round(gravity * 1000F) / 1000F); - - fontRendererObj.drawString("Spawn X:", col1, posY + ln1 + 0 * 22, 0x000000, false); - fontRendererObj.drawString(spawn_X, col1, posY + ln2 + 0 * 22, 0x000000, false); - fontRendererObj.drawString("Spawn Y:", col1, posY + ln1 + 1 * 22, 0x000000, false); - fontRendererObj.drawString(spawn_Y, col1, posY + ln2 + 1 * 22, 0x000000, false); - fontRendererObj.drawString("Spawn Z:", col1, posY + ln1 + 2 * 22, 0x000000, false); - fontRendererObj.drawString(spawn_Z, col1, posY + ln2 + 2 * 22, 0x000000, false); - - for (int i = 0; i < 3; i++) - fontRendererObj.drawStringWithShadow("(+)", posX + 98, posY + 25 + i * 22, 0xFFFFFF); - - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 0 * 22, 0x000000, false); - fontRendererObj.drawString("> " + random_spawn_X, col2, posY + ln2 + 0 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 1 * 22, 0x000000, false); - fontRendererObj.drawString("> " + random_spawn_Y, col2, posY + ln2 + 1 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 2 * 22, 0x000000, false); - fontRendererObj.drawString("> " + random_spawn_Z, col2, posY + ln2 + 2 * 22, 0x000000, false); - - fontRendererObj.drawString("Delay:", col1, posY + ln1 + 3 * 22, 0x000000, false); - fontRendererObj.drawString("" + spawn_rate, col1, posY + ln2 + 3 * 22, 0x000000, false); - fontRendererObj.drawString("Fade:", col1, posY + ln1 + 4 * 22, 0x000000, false); - fontRendererObj.drawString("" + fade, col1, posY + ln2 + 4 * 22, 0x000000, false); - fontRendererObj.drawString("Gravity:", col1, posY + ln1 + 5 * 22, 0x000000, false); - fontRendererObj.drawString(Gravity, col1, posY + ln2 + 5 * 22, 0x000000, false); - - } - - @SuppressWarnings("unchecked") - private void page2Buttons() { - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - int DX1 = 5; - int DX2 = DX1 + 71; - int DX3 = DX2 + 40; - int DX4 = DX3 + 71; - int y1 = 19; - - buttonList.add(new GuiButton(34, posX + DX1, posY + y1 + 0 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(38, posX + DX1, posY + y1 + 1 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(42, posX + DX1, posY + y1 + 2 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(46, posX + DX1, posY + y1 + 3 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(48, posX + DX1, posY + y1 + 4 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(52, posX + DX1, posY + y1 + 5 * 22, 20, 20, "+")); - - buttonList.add(new GuiButton(35, posX + DX2, posY + y1 + 0 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(39, posX + DX2, posY + y1 + 1 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(43, posX + DX2, posY + y1 + 2 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(47, posX + DX2, posY + y1 + 3 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(49, posX + DX2, posY + y1 + 4 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(53, posX + DX2, posY + y1 + 5 * 22, 20, 20, "-")); - - buttonList.add(new GuiButton(36, posX + DX3, posY + y1 + 0 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(40, posX + DX3, posY + y1 + 1 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(44, posX + DX3, posY + y1 + 2 * 22, 20, 20, "+")); - - buttonList.add(new GuiButton(37, posX + DX4, posY + y1 + 0 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(41, posX + DX4, posY + y1 + 1 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(45, posX + DX4, posY + y1 + 2 * 22, 20, 20, "-")); - - buttonList.add(new GuiButton(50, posX + DX3 - 11, posY + y1 + 3 * 22, 102, 20, "Block Collision: " + (collide ? "on" : "off"))); - buttonList.add(new GuiButton(51, posX + DX3 - 11, posY + y1 + 4 * 22, 102, 20, "Particle Selected: " + selected_particle)); - - buttonList.add(new GuiButton(58, posX + DX3 - 11, posY + y1 + 5 * 22, 102, 20, "Enabled: " + (particles_enabled ? "on" : "off"))); - } - - private void page3Txt() { - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - - int col1 = posX + 30; - int col2 = posX + 141; - int ln1 = 20; - int ln2 = 30; - - String pitch = String.valueOf(Math.round(beam_pitch * 100F) / 100F); - String yaw = String.valueOf(Math.round(beam_yaw * 100F) / 100F); - String length = String.valueOf(Math.round(beam_length * 100F) / 100F); - String rotation = String.valueOf(Math.round(beam_rotation * 100F) / 100F); - String scale = String.valueOf(Math.round(beam_scale * 100F) / 100F); - - fontRendererObj.drawString("Red:", col1, posY + ln1 + 0 * 22, 0x000000, false); - fontRendererObj.drawString(String.valueOf(beam_red), col1, posY + ln2 + 0 * 22, 0x000000, false); - fontRendererObj.drawString("Green:", col1, posY + ln1 + 1 * 22, 0x000000, false); - fontRendererObj.drawString(String.valueOf(beam_green), col1, posY + ln2 + 1 * 22, 0x000000, false); - fontRendererObj.drawString("Blue:", col1, posY + ln1 + 2 * 22, 0x000000, false); - fontRendererObj.drawString(String.valueOf(beam_blue), col1, posY + ln2 + 2 * 22, 0x000000, false); - - fontRendererObj.drawString("Y Rot:", col1, posY + ln1 + 3 * 22, 0x000000, false); - fontRendererObj.drawString(pitch, col1, posY + ln2 + 3 * 22, 0x000000, false); - fontRendererObj.drawString("Z,X Rot:", col1, posY + ln1 + 4 * 22, 0x000000, false); - fontRendererObj.drawString(yaw, col1, posY + ln2 + 4 * 22, 0x000000, false); - fontRendererObj.drawString("Length:", col1, posY + ln1 + 5 * 22, 0x000000, false); - fontRendererObj.drawString(length, col1, posY + ln2 + 5 * 22, 0x000000, false); - fontRendererObj.drawString("Rotation:", col1, posY + ln1 + 6 * 22, 0x000000, false); - fontRendererObj.drawString(rotation, col1, posY + ln2 + 6 * 22, 0x000000, false); - fontRendererObj.drawString("Scale:", col1, posY + ln1 + 7 * 22, 0x000000, false); - fontRendererObj.drawString(scale, col1, posY + ln2 + 7 * 22, 0x000000, false); - - } - - @SuppressWarnings("unchecked") - private void page3Buttons() { - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - int DX1 = 5;//x pos for row 1,2,3,4 - int DX2 = DX1 + 71; - int DX3 = DX2 + 40; - int DX4 = DX3 + 71; - int y1 = 19; - - buttonList.add(new GuiButton(100, posX + DX1, posY + y1 + 0 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(101, posX + DX1, posY + y1 + 1 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(102, posX + DX1, posY + y1 + 2 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(103, posX + DX1, posY + y1 + 3 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(104, posX + DX1, posY + y1 + 4 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(105, posX + DX1, posY + y1 + 5 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(106, posX + DX1, posY + y1 + 6 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(107, posX + DX1, posY + y1 + 7 * 22, 20, 20, "+")); - - buttonList.add(new GuiButton(108, posX + DX2, posY + y1 + 0 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(109, posX + DX2, posY + y1 + 1 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(110, posX + DX2, posY + y1 + 2 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(111, posX + DX2, posY + y1 + 3 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(112, posX + DX2, posY + y1 + 4 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(113, posX + DX2, posY + y1 + 5 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(114, posX + DX2, posY + y1 + 6 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(115, posX + DX2, posY + y1 + 7 * 22, 20, 20, "-")); - - buttonList.add(new GuiButton(116, posX + DX3 - 11, posY + y1 + 0 * 22, 102, 20, "Enabled: " + (beam_enabled ? "on" : "off"))); - buttonList.add(new GuiButton(117, posX + DX3 - 11, posY + y1 + 1 * 22, 102, 20, "Render Core: " + (render_core ? "on" : "off"))); - - - buttonList.add(new GuiButton(127, posX + DX3 - 11, posY + y1 + 7 * 22, 102, 20, "Take note of values")); - } - - private void beamActions(GuiButton button) { - int value = 1; - float value_F; - short packetValue = 0; - if (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)) value = 10; - if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) value = 100; - if ((Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54))) - value = 1000; - - value_F = (value) / 100F; - - switch (button.id) - { - case 100: //beam red + - beam_red = (beam_red + value) > 255 ? 255 : beam_red + value; - packetValue = (short) beam_red; - break; - case 101: //beam green + - beam_green = (beam_green + value) > 255 ? 255 : beam_green + value; - packetValue = (short) beam_green; - break; - case 102: //beam blue + - beam_blue = (beam_blue + value) > 255 ? 255 : beam_blue + value; - packetValue = (short) beam_blue; - break; - case 103: //beam pitch + - beam_pitch = (beam_pitch + value_F) > 180F ? 180F : beam_pitch + value_F; - packetValue = (short) (beam_pitch * 100F); - break; - case 104: //beam yaw + - beam_yaw = (beam_yaw + value_F) > 180F ? 180F : beam_yaw + value_F; - packetValue = (short) (beam_yaw * 100F); - break; - case 105: //beam length + - beam_length = (beam_length + value_F) > 320F ? 320F : beam_length + value_F; - packetValue = (short) (beam_length * 100F); - break; - case 106: //beam rotation + - beam_rotation = (beam_rotation + value_F) > 1F ? 1F : beam_rotation + value_F; - packetValue = (short) (beam_rotation * 100F); - break; - case 107: //beam scale + - beam_scale = (beam_scale + value_F) > 5F ? 5F : beam_scale + value_F; - packetValue = (short) (beam_scale * 100F); - break; - case 108: //beam red - - beam_red = (beam_red - value) < 0 ? 0 : beam_red - value; - packetValue = (short) beam_red; - break; - case 109: //beam green - - beam_green = (beam_green - value) < 0 ? 0 : beam_green - value; - packetValue = (short) beam_green; - break; - case 110: //beam blue - - beam_blue = (beam_blue - value) < 0 ? 0 : beam_blue - value; - packetValue = (short) beam_blue; - break; - case 111: //beam pitch - - beam_pitch = (beam_pitch - value_F) < -180F ? -180F : beam_pitch - value_F; - packetValue = (short) (beam_pitch * 100F); - break; - case 112: //beam yaw - - beam_yaw = (beam_yaw - value_F) < -180F ? -180F : beam_yaw - value_F; - packetValue = (short) (beam_yaw * 100F); - break; - case 113: //beam length - - beam_length = (beam_length - value_F) < -0F ? -0F : beam_length - value_F; - packetValue = (short) (beam_length * 100F); - break; - case 114: //beam rotation - - beam_rotation = (beam_rotation - value_F) < -1F ? -1F : beam_rotation - value_F; - packetValue = (short) (beam_rotation * 100F); - break; - case 115: //beam scale - - beam_scale = (beam_scale - value_F) < -0F ? -0F : beam_scale - value_F; - packetValue = (short) (beam_scale * 100F); - break; - case 116: //beam enabled - beam_enabled = !beam_enabled; - packetValue = beam_enabled ? (byte) 1 : (byte) 0; - initGui(); - break; - case 117: //beam enabled - render_core = !render_core; - packetValue = render_core ? (byte) 1 : (byte) 0; - initGui(); - break; - - } - DraconicEvolution.network.sendToServer(new ParticleGenPacket((byte) button.id, packetValue, tile.xCoord, tile.yCoord, tile.zCoord)); - } - //@formatter:on + private final int xSize = 212; + private final int ySize = 198; + private ResourceLocation guiTexture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/ParticleGenerator.png"); + private int page = 1; + private int infoPage = 0; + private boolean hasInitialized = false; + + //Particle variables + private boolean particles_enabled = true; + + private int red = 0; + private int green = 0; + private int blue = 0; + private int random_red = 0; + private int random_green = 0; + private int random_blue = 0; + private float motion_x = 0F; + private float motion_y = 0F; + private float motion_z = 0F; + private float random_motion_x = 0F; + private float random_motion_y = 0F; + private float random_motion_z = 0F; + private float scale = 0F; + private float random_scale = 0F; + private int life = 0; + private int random_life = 0; + private float spawn_x = 0F; + private float spawn_y = 0F; + private float spawn_z = 0F; + private float random_spawn_x = 0F; + private float random_spawn_y = 0F; + private float random_spawn_z = 0F; + private int fade = 0; + private int spawn_rate = 0; + private boolean collide = false; + private int selected_particle = 1; + private int selected_max = 3; + private float gravity = 0F; + + //Beam variables + private boolean beam_enabled = false; + private boolean render_core = false; + + private int beam_red = 0; + private int beam_green = 0; + private int beam_blue = 0; + private float beam_scale = 0F; + private float beam_pitch = 0F; + private float beam_yaw = 0F; + private float beam_length = 0F; + private float beam_rotation = 0F; + + + //Buttons + + //Info Page + //particle selection + + private TileParticleGenerator tile; + + public GUIParticleGenerator(TileParticleGenerator tile, EntityPlayer player) { + super(); + this.tile = tile; + syncWithServer(); + } + + String[] InfoText = {"" + "The Particle Generator is a decorative device that allows you to create your own custom particle effects. " + "It is fairly easy you use this device you simply adjust the fields (variables) in the interface to change how the generated particles look and behave. " + "This block is a work in progress and new features and particles are likely to be added in future versions. " + "The following is a list of all of the fields in the interface and what they do.", "The first thing to note is that most fields have a random modifier which will add a random number between 0 and whatever max (or min) value you give it to the field. " + "-The first 3 fields (Red, Green & Blue) control the colour of the particle. Most people should be familiar with this colour system if not google RGB colours. Note: the max value for each colour can not go higher then 255 so the colour field limits the random modifier e.g. if the colour field is set to 255 and the random modifier is set to 20 the result will always be 255", "-The next 3 fields (Motion X, Y & Z) control the direction and speed of the particle " + "-The \"Life\" field sets how long (in ticks) before the particle despawns. " + "-The \"Size\" field sets the size of the particle. " + "-The next 3 fields (Spawn X, Y & Z) Sets the spawn location of the particle (relative to the location of the particle generator)", "-The \"Delay\" field sets the delay (in ticks) between each particle spawn e.g. 1=20/s, 20=1/s, 100=1/5s " + "-The \"Fade\" field sets how long (in ticks) it takes the partile to fade out of existance. Note: This adds to the life of the particle " + "-The \"Gravity\" field sets how the particle is affected by gravity. " + "-\"Block Collision\" Toggles weather or not the particle will collide with blocks " + "-\"Particle Selected\" Switches between the different particles available.", EnumChatFormatting.DARK_RED + " Redstone Control" + EnumChatFormatting.BLACK + "\nBy default a redstone signal is required for the generator to run." + "\n\nHowever if you shift right click the generator with an empty hand it will switch to inverted mode." + "\nThe redstone mode is indicated by the 8 cubes at the corners of the block.", EnumChatFormatting.DARK_RED + " Computer Control" + EnumChatFormatting.BLACK + "\nThe Generator can be controlled via a computer" + "\nIt exposes a relatively straight forward API:" + "\n\n setGeneratorProperty(property, value)\n getGeneratorState()\n resetGeneratorState()" + "\n\nGenerator state is obtained as a whole from getGeneratorState, whereas properties are modified one at a time using setGeneratorProperty. Property names are strings and mostly correspond to button labels in the GUI."}; + + //@formatter:off + @Override + public void drawScreen(int x, int y, float f) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getMinecraft().renderEngine.bindTexture(guiTexture); + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + drawTexturedModalRect(posX, posY, 0, 0, xSize, ySize); + if (page < 3) fontRendererObj.drawStringWithShadow("Particle Generator", posX + 60, posY + 5, 0x00FFFF); + else if (page < 10) fontRendererObj.drawStringWithShadow("Beam Generator", posX + 65, posY + 5, 0x00FFFF); + else fontRendererObj.drawStringWithShadow("Information", posX + 75, posY + 5, 0x00FFFF); + + if (page == 1) page1Txt(); + else if (page == 2) page2Txt(); + else if (page == 3) page3Txt(); + else if (page == 10) { + fontRendererObj.drawSplitString(InfoText[infoPage], posX + 5, posY + 20, 200, 0x000000); + fontRendererObj.drawSplitString("Page: " + (infoPage + 1), posX + 88, posY + 180, 200, 0xFF0000); + } + + fontRendererObj.drawStringWithShadow("Hold:", posX + 215, posY + 11, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Shift +- 10", posX + 215, posY + 21, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Ctrl +- 50", posX + 215, posY + 31, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Shift+Ctrl +- 100", posX + 215, posY + 41, 0xFFFFFF); + + super.drawScreen(x, y, f); + } + //@formatter:on + + @Override + protected void mouseClicked(int x, int y, int button) { + super.mouseClicked(x, y, button); + } + + @SuppressWarnings("unchecked") + @Override + public void initGui() { + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + buttonList.clear(); + + if (page < 10) { + buttonList.add(new GuiButton(33, posX + 213, posY + 177, 47, 20, "===>")); + buttonList.add(new GuiButton(32, posX - 47, posY + 177, 47, 20, "<===")); + } + + if (page == 1) page1Buttons(); + else if (page == 2) page2Buttons(); + else if (page == 3) page3Buttons(); + else if (page == 10) { + buttonList.add(new GuiButton(57, posX + 4, posY + 174, 80, 20, "Previous page")); + buttonList.add(new GuiButton(56, posX + 128, posY + 174, 80, 20, "Next page")); + } + + if (page < 10) buttonList.add(new GuiButton(54, posX - 21, posY + 3, 20, 20, "i")); + else buttonList.add(new GuiButton(55, posX - 31, posY + 23, 30, 20, "Back")); + + + } + + @Override + protected void actionPerformed(GuiButton button) { + if (button.id < 100) particleActions(button); + else beamActions(button); + } + + private void particleActions(GuiButton button) { + int value = 1; + float value_F; + short packetValue = 0; + if (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)) value = 10; + if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) value = 50; + if ((Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54))) + value = 100; + + value_F = (value) / 1000F; + + switch (button.id) { + case 0://Red + + red = (red + value) > 255 ? 255 : red + value; + packetValue = (short) red; + break; + case 1://Green + + green = (green + value) > 255 ? 255 : green + value; + packetValue = (short) green; + break; + case 2://Blue + + blue = (blue + value) > 255 ? 255 : blue + value; + packetValue = (short) blue; + break; + case 3://MX + + motion_x = (motion_x + value_F) > 5F ? 5F : motion_x + value_F; + packetValue = (short) (motion_x * 1000F); + break; + case 4://MY + + motion_y = (motion_y + value_F) > 5F ? 5F : motion_y + value_F; + packetValue = (short) (motion_y * 1000F); + break; + case 5://MZ + + motion_z = (motion_z + value_F) > 5F ? 5F : motion_z + value_F; + packetValue = (short) (motion_z * 1000F); + break; + case 6://Red - + red = (red - value) < 0 ? 0 : red - value; + packetValue = (short) red; + break; + case 7://Green - + green = (green - value) < 0 ? 0 : green - value; + packetValue = (short) green; + break; + case 8://Blue - + blue = (blue - value) < 0 ? 0 : blue - value; + packetValue = (short) blue; + break; + case 9://MX - + motion_x = (motion_x - value_F) < -5F ? -5F : motion_x - value_F; + packetValue = (short) (motion_x * 1000F); + break; + case 10://MY - + motion_y = (motion_y - value_F) < -5F ? -5F : motion_y - value_F; + packetValue = (short) (motion_y * 1000F); + break; + case 11://MZ - + motion_z = (motion_z - value_F) < -5F ? -5F : motion_z - value_F; + packetValue = (short) (motion_z * 1000F); + break; + case 12://RRed + + random_red = (random_red + value) > 255 ? 255 : random_red + value; + packetValue = (short) random_red; + break; + case 13://RGreen + + random_green = (random_green + value) > 255 ? 255 : random_green + value; + packetValue = (short) random_green; + break; + case 14://RBlue + + random_blue = (random_blue + value) > 255 ? 255 : random_blue + value; + packetValue = (short) random_blue; + break; + case 15://RMX + + random_motion_x = (random_motion_x + value_F) > 5F ? 5F : random_motion_x + value_F; + packetValue = (short) (random_motion_x * 1000F); + break; + case 16://RMY + + random_motion_y = (random_motion_y + value_F) > 5F ? 5F : random_motion_y + value_F; + packetValue = (short) (random_motion_y * 1000F); + break; + case 17://RMZ + + random_motion_z = (random_motion_z + value_F) > 5F ? 5F : random_motion_z + value_F; + packetValue = (short) (random_motion_z * 1000F); + break; + case 18://RRed - + random_red = (random_red - value) < 0 ? 0 : random_red - value; + packetValue = (short) random_red; + break; + case 19://RGreen - + random_green = (random_green - value) < 0 ? 0 : random_green - value; + packetValue = (short) random_green; + break; + case 20://RBlue - + random_blue = (random_blue - value) < 0 ? 0 : random_blue - value; + packetValue = (short) random_blue; + break; + case 21://RMX - + random_motion_x = (random_motion_x - value_F) < -5F ? -5F : random_motion_x - value_F; + packetValue = (short) (random_motion_x * 1000F); + break; + case 22://RMY - + random_motion_y = (random_motion_y - value_F) < -5F ? -5F : random_motion_y - value_F; + packetValue = (short) (random_motion_y * 1000F); + break; + case 23://RMZ - + random_motion_z = (random_motion_z - value_F) < -5F ? -5F : random_motion_z - value_F; + packetValue = (short) (random_motion_z * 1000F); + break; + case 24://Life + + life = (life + value) > 1000 ? 1000 : life + value; + packetValue = (short) life; + break; + case 25://Life - + life = (life - value) < 0 ? 0 : life - value; + packetValue = (short) life; + break; + case 26://RLife + + random_life = (random_life + value) > 1000 ? 1000 : random_life + value; + packetValue = (short) random_life; + break; + case 27://RLife - + random_life = (random_life - value) < 0 ? 0 : random_life - value; + packetValue = (short) random_life; + break; + case 28://Size + + scale = (scale + value_F * 10F) > 50F ? 50F : scale + value_F * 10F; + packetValue = (short) (scale * 100F); + break; + case 29://Size - + scale = (scale - value_F * 10F) < 0.01F ? 0.01F : scale - value_F * 10F; + packetValue = (short) (scale * 100F); + break; + case 30://RSize + + random_scale = (random_scale + value_F * 10F) > 50F ? 50F : random_scale + value_F * 10F; + packetValue = (short) (random_scale * 100F); + break; + case 31://RSize - + random_scale = (random_scale - value_F * 10F) < 0.0F ? 0.0F : random_scale - value_F * 10F; + packetValue = (short) (random_scale * 100F); + break; + case 32://Page 2 + if (page > 1) page--; + packetValue = (short) page; + initGui(); + break; + case 33://Page 1 + if (page < 3) page++; + initGui(); + packetValue = (short) page; + break; + case 34://SX + + spawn_x = (spawn_x + value_F * 100F) > 50F ? 50F : spawn_x + value_F * 100F; + packetValue = (short) (spawn_x * 100F); + break; + case 35://SX - + spawn_x = (spawn_x - value_F * 100F) < -50F ? -50F : spawn_x - value_F * 100F; + packetValue = (short) (spawn_x * 100F); + break; + case 36://RSX + + random_spawn_x = (random_spawn_x + value_F * 100F) > 50F ? 50F : random_spawn_x + value_F * 100F; + packetValue = (short) (random_spawn_x * 100F); + break; + case 37://RSX - + random_spawn_x = (random_spawn_x - value_F * 100F) < -50F ? -50F : random_spawn_x - value_F * 100F; + packetValue = (short) (random_spawn_x * 100F); + break; + case 38://SY + + spawn_y = (spawn_y + value_F * 100F) > 50F ? 50F : spawn_y + value_F * 100F; + packetValue = (short) (spawn_y * 100F); + break; + case 39://SY - + spawn_y = (spawn_y - value_F * 100F) < -50F ? -50F : spawn_y - value_F * 100F; + packetValue = (short) (spawn_y * 100F); + break; + case 40://RSY + + random_spawn_y = (random_spawn_y + value_F * 100F) > 50F ? 50F : random_spawn_y + value_F * 100F; + packetValue = (short) (random_spawn_y * 100F); + break; + case 41://RSY - + random_spawn_y = (random_spawn_y - value_F * 100F) < -50F ? -50F : random_spawn_y - value_F * 100F; + packetValue = (short) (random_spawn_y * 100F); + break; + case 42://SZ + + spawn_z = (spawn_z + value_F * 100F) > 50F ? 50F : spawn_z + value_F * 100F; + packetValue = (short) (spawn_z * 100F); + break; + case 43://SZ - + spawn_z = (spawn_z - value_F * 100F) < -50F ? -50F : spawn_z - value_F * 100F; + packetValue = (short) (spawn_z * 100F); + break; + case 44://RSZ + + random_spawn_z = (random_spawn_z + value_F * 100F) > 50F ? 50F : random_spawn_z + value_F * 100F; + packetValue = (short) (random_spawn_z * 100F); + break; + case 45://RSZ - + random_spawn_z = (random_spawn_z - value_F * 100F) < -50F ? -50F : random_spawn_z - value_F * 100F; + packetValue = (short) (random_spawn_z * 100F); + break; + case 46://Delay + + spawn_rate = (spawn_rate + value) > 200 ? 200 : spawn_rate + value; + packetValue = (short) spawn_rate; + break; + case 47://Delay - + spawn_rate = (spawn_rate - value) < 1 ? 1 : spawn_rate - value; + packetValue = (short) spawn_rate; + break; + case 48://Fade + + fade = (fade + value) > 100 ? 100 : fade + value; + packetValue = (short) fade; + break; + case 49://Fade - + fade = (fade - value) < 0 ? 0 : fade - value; + packetValue = (short) fade; + break; + case 50://Toggle Collision + collide = !collide; + packetValue = (short) (collide ? 1 : 0); + initGui(); + break; + case 51://cycle particle selection + selected_particle = selected_particle < selected_max ? selected_particle + 1 : 1; + packetValue = (short) selected_particle; + initGui(); + break; + case 52://RSZ + + gravity = (gravity + value_F) > 5F ? 5F : gravity + value_F; + packetValue = (short) (gravity * 1000F); + break; + case 53://RSZ - + gravity = (gravity - value_F) < -5F ? -5F : gravity - value_F; + packetValue = (short) (gravity * 1000F); + break; + case 54://Info Page + page = 10; + initGui(); + packetValue = (short) page; + break; + case 55://Back Page + page = 1; + initGui(); + packetValue = (short) page; + break; + case 56://Info Next Page + if (infoPage < 5) infoPage++; + else initGui(); + break; + case 57://Info Previous Page + if (infoPage > 0) infoPage--; + else initGui(); + break; + case 58://particles Enabled + particles_enabled = !particles_enabled; + packetValue = particles_enabled ? (byte) 1 : (byte) 0; + initGui(); + break; + } + DraconicEvolution.network.sendToServer(new ParticleGenPacket((byte) button.id, packetValue, tile.xCoord, tile.yCoord, tile.zCoord)); + } + + @Override + public void keyTyped(char key, int keyN) { + if ((key == 'e') || key == '') { + this.mc.displayGuiScreen(null); + this.mc.setIngameFocus(); + } + } + + @Override + public void updateScreen() { + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } + + private void syncWithServer() { + red = tile.red; + green = tile.green; + blue = tile.blue; + random_red = tile.random_red; + random_green = tile.random_green; + random_blue = tile.random_blue; + motion_x = tile.motion_x; + motion_y = tile.motion_y; + motion_z = tile.motion_z; + random_motion_x = tile.random_motion_x; + random_motion_y = tile.random_motion_y; + random_motion_z = tile.random_motion_z; + scale = tile.scale; + random_scale = tile.random_scale; + life = tile.life; + random_life = tile.random_life; + spawn_x = tile.spawn_x; + spawn_y = tile.spawn_y; + spawn_z = tile.spawn_z; + random_spawn_x = tile.random_spawn_x; + random_spawn_y = tile.random_spawn_y; + random_spawn_z = tile.random_spawn_z; + page = tile.page; + spawn_rate = tile.spawn_rate; + collide = tile.collide; + fade = tile.fade; + selected_particle = tile.selected_particle; + gravity = tile.gravity; + particles_enabled = tile.particles_enabled; + + render_core = tile.render_core; + beam_enabled = tile.beam_enabled; + beam_red = tile.beam_red; + beam_green = tile.beam_green; + beam_blue = tile.beam_blue; + beam_scale = tile.beam_scale; + beam_pitch = tile.beam_pitch; + beam_yaw = tile.beam_yaw; + beam_length = tile.beam_length; + beam_rotation = tile.beam_rotation; + } + + //@formatter:off + private void page1Txt() { + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + + String motionX = String.valueOf(Math.round(motion_x * 1000F) / 1000F); + String motionY = String.valueOf(Math.round(motion_y * 1000F) / 1000F); + String motionZ = String.valueOf(Math.round(motion_z * 1000F) / 1000F); + String random_motionX = String.valueOf(Math.round(random_motion_x * 1000F) / 1000F); + String random_motionY = String.valueOf(Math.round(random_motion_y * 1000F) / 1000F); + String random_motionZ = String.valueOf(Math.round(random_motion_z * 1000F) / 1000F); + String scale1 = String.valueOf(Math.round(scale * 100F) / 100F); + String random_scale1 = String.valueOf(Math.round(random_scale * 100F) / 100F); + + int col1 = posX + 30; + int col2 = posX + 141; + int ln1 = 20; + int ln2 = 30; + + fontRendererObj.drawString("Red:", col1, posY + ln1 + 0 * 22, 0x000000, false); + fontRendererObj.drawString(String.valueOf(red), col1, posY + ln2 + 0 * 22, 0x000000, false); + fontRendererObj.drawString("Green:", col1, posY + ln1 + 1 * 22, 0x000000, false); + fontRendererObj.drawString(String.valueOf(green), col1, posY + ln2 + 1 * 22, 0x000000, false); + fontRendererObj.drawString("Blue:", col1, posY + ln1 + 2 * 22, 0x000000, false); + fontRendererObj.drawString(String.valueOf(blue), col1, posY + ln2 + 2 * 22, 0x000000, false); + fontRendererObj.drawString("Motion X:", col1, posY + ln1 + 3 * 22, 0x000000, false); + fontRendererObj.drawString(motionX, col1, posY + ln2 + 3 * 22, 0x000000, false); + fontRendererObj.drawString("Motion Y:", col1, posY + ln1 + 4 * 22, 0x000000, false); + fontRendererObj.drawString(motionY, col1, posY + ln2 + 4 * 22, 0x000000, false); + fontRendererObj.drawString("Motion Z:", col1, posY + ln1 + 5 * 22, 0x000000, false); + fontRendererObj.drawString(motionZ, col1, posY + ln2 + 5 * 22, 0x000000, false); + fontRendererObj.drawString("Life:", col1, posY + ln1 + 6 * 22, 0x000000, false); + fontRendererObj.drawString("" + life + " T", col1, posY + ln2 + 6 * 22, 0x000000, false); + fontRendererObj.drawString("Size:", col1, posY + ln1 + 7 * 22, 0x000000, false); + fontRendererObj.drawString("" + scale1, col1, posY + ln2 + 7 * 22, 0x000000, false); + + for (int i = 0; i < 8; i++) + fontRendererObj.drawStringWithShadow("(+)", posX + 98, posY + 25 + i * 22, 0xFFFFFF); + + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 0 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_red, col2, posY + ln2 + 0 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 1 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_green, col2, posY + ln2 + 1 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 2 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_blue, col2, posY + ln2 + 2 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 3 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_motionX, col2, posY + ln2 + 3 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 4 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_motionY, col2, posY + ln2 + 4 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 5 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_motionZ, col2, posY + ln2 + 5 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 6 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_life, col2, posY + ln2 + 6 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 7 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_scale1, col2, posY + ln2 + 7 * 22, 0x000000, false); + } + + @SuppressWarnings("unchecked") + private void page1Buttons() { + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + int DX1 = 5; + int DX2 = DX1 + 71; + int DX3 = DX2 + 40; + int DX4 = DX3 + 71; + int y1 = 19; + + buttonList.add(new GuiButton(0, posX + DX1, posY + y1 + 0 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(1, posX + DX1, posY + y1 + 1 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(2, posX + DX1, posY + y1 + 2 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(3, posX + DX1, posY + y1 + 3 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(4, posX + DX1, posY + y1 + 4 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(5, posX + DX1, posY + y1 + 5 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(24, posX + DX1, posY + y1 + 6 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(28, posX + DX1, posY + y1 + 7 * 22, 20, 20, "+")); + + buttonList.add(new GuiButton(6, posX + DX2, posY + y1 + 0 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(7, posX + DX2, posY + y1 + 1 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(8, posX + DX2, posY + y1 + 2 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(9, posX + DX2, posY + y1 + 3 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(10, posX + DX2, posY + y1 + 4 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(11, posX + DX2, posY + y1 + 5 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(25, posX + DX2, posY + y1 + 6 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(29, posX + DX2, posY + y1 + 7 * 22, 20, 20, "-")); + + buttonList.add(new GuiButton(12, posX + DX3, posY + y1 + 0 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(13, posX + DX3, posY + y1 + 1 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(14, posX + DX3, posY + y1 + 2 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(15, posX + DX3, posY + y1 + 3 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(16, posX + DX3, posY + y1 + 4 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(17, posX + DX3, posY + y1 + 5 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(26, posX + DX3, posY + y1 + 6 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(30, posX + DX3, posY + y1 + 7 * 22, 20, 20, "+")); + + buttonList.add(new GuiButton(18, posX + DX4, posY + y1 + 0 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(19, posX + DX4, posY + y1 + 1 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(20, posX + DX4, posY + y1 + 2 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(21, posX + DX4, posY + y1 + 3 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(22, posX + DX4, posY + y1 + 4 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(23, posX + DX4, posY + y1 + 5 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(27, posX + DX4, posY + y1 + 6 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(31, posX + DX4, posY + y1 + 7 * 22, 20, 20, "-")); + + + } + + private void page2Txt() { + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + + int col1 = posX + 30; + int col2 = posX + 141; + int ln1 = 20; + int ln2 = 30; + + String spawn_X = String.valueOf(Math.round(spawn_x * 10F) / 10F); + String spawn_Y = String.valueOf(Math.round(spawn_y * 10F) / 10F); + String spawn_Z = String.valueOf(Math.round(spawn_z * 10F) / 10F); + String random_spawn_X = String.valueOf(Math.round(random_spawn_x * 10F) / 10F); + String random_spawn_Y = String.valueOf(Math.round(random_spawn_y * 10F) / 10F); + String random_spawn_Z = String.valueOf(Math.round(random_spawn_z * 10F) / 10F); + String Gravity = String.valueOf(Math.round(gravity * 1000F) / 1000F); + + fontRendererObj.drawString("Spawn X:", col1, posY + ln1 + 0 * 22, 0x000000, false); + fontRendererObj.drawString(spawn_X, col1, posY + ln2 + 0 * 22, 0x000000, false); + fontRendererObj.drawString("Spawn Y:", col1, posY + ln1 + 1 * 22, 0x000000, false); + fontRendererObj.drawString(spawn_Y, col1, posY + ln2 + 1 * 22, 0x000000, false); + fontRendererObj.drawString("Spawn Z:", col1, posY + ln1 + 2 * 22, 0x000000, false); + fontRendererObj.drawString(spawn_Z, col1, posY + ln2 + 2 * 22, 0x000000, false); + + for (int i = 0; i < 3; i++) + fontRendererObj.drawStringWithShadow("(+)", posX + 98, posY + 25 + i * 22, 0xFFFFFF); + + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 0 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_spawn_X, col2, posY + ln2 + 0 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 1 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_spawn_Y, col2, posY + ln2 + 1 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 2 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_spawn_Z, col2, posY + ln2 + 2 * 22, 0x000000, false); + + fontRendererObj.drawString("Delay:", col1, posY + ln1 + 3 * 22, 0x000000, false); + fontRendererObj.drawString("" + spawn_rate, col1, posY + ln2 + 3 * 22, 0x000000, false); + fontRendererObj.drawString("Fade:", col1, posY + ln1 + 4 * 22, 0x000000, false); + fontRendererObj.drawString("" + fade, col1, posY + ln2 + 4 * 22, 0x000000, false); + fontRendererObj.drawString("Gravity:", col1, posY + ln1 + 5 * 22, 0x000000, false); + fontRendererObj.drawString(Gravity, col1, posY + ln2 + 5 * 22, 0x000000, false); + + } + + @SuppressWarnings("unchecked") + private void page2Buttons() { + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + int DX1 = 5; + int DX2 = DX1 + 71; + int DX3 = DX2 + 40; + int DX4 = DX3 + 71; + int y1 = 19; + + buttonList.add(new GuiButton(34, posX + DX1, posY + y1 + 0 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(38, posX + DX1, posY + y1 + 1 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(42, posX + DX1, posY + y1 + 2 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(46, posX + DX1, posY + y1 + 3 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(48, posX + DX1, posY + y1 + 4 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(52, posX + DX1, posY + y1 + 5 * 22, 20, 20, "+")); + + buttonList.add(new GuiButton(35, posX + DX2, posY + y1 + 0 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(39, posX + DX2, posY + y1 + 1 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(43, posX + DX2, posY + y1 + 2 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(47, posX + DX2, posY + y1 + 3 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(49, posX + DX2, posY + y1 + 4 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(53, posX + DX2, posY + y1 + 5 * 22, 20, 20, "-")); + + buttonList.add(new GuiButton(36, posX + DX3, posY + y1 + 0 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(40, posX + DX3, posY + y1 + 1 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(44, posX + DX3, posY + y1 + 2 * 22, 20, 20, "+")); + + buttonList.add(new GuiButton(37, posX + DX4, posY + y1 + 0 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(41, posX + DX4, posY + y1 + 1 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(45, posX + DX4, posY + y1 + 2 * 22, 20, 20, "-")); + + buttonList.add(new GuiButton(50, posX + DX3 - 11, posY + y1 + 3 * 22, 102, 20, "Block Collision: " + (collide ? "on" : "off"))); + buttonList.add(new GuiButton(51, posX + DX3 - 11, posY + y1 + 4 * 22, 102, 20, "Particle Selected: " + selected_particle)); + + buttonList.add(new GuiButton(58, posX + DX3 - 11, posY + y1 + 5 * 22, 102, 20, "Enabled: " + (particles_enabled ? "on" : "off"))); + } + + private void page3Txt() { + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + + int col1 = posX + 30; + int col2 = posX + 141; + int ln1 = 20; + int ln2 = 30; + + String pitch = String.valueOf(Math.round(beam_pitch * 100F) / 100F); + String yaw = String.valueOf(Math.round(beam_yaw * 100F) / 100F); + String length = String.valueOf(Math.round(beam_length * 100F) / 100F); + String rotation = String.valueOf(Math.round(beam_rotation * 100F) / 100F); + String scale = String.valueOf(Math.round(beam_scale * 100F) / 100F); + + fontRendererObj.drawString("Red:", col1, posY + ln1 + 0 * 22, 0x000000, false); + fontRendererObj.drawString(String.valueOf(beam_red), col1, posY + ln2 + 0 * 22, 0x000000, false); + fontRendererObj.drawString("Green:", col1, posY + ln1 + 1 * 22, 0x000000, false); + fontRendererObj.drawString(String.valueOf(beam_green), col1, posY + ln2 + 1 * 22, 0x000000, false); + fontRendererObj.drawString("Blue:", col1, posY + ln1 + 2 * 22, 0x000000, false); + fontRendererObj.drawString(String.valueOf(beam_blue), col1, posY + ln2 + 2 * 22, 0x000000, false); + + fontRendererObj.drawString("Y Rot:", col1, posY + ln1 + 3 * 22, 0x000000, false); + fontRendererObj.drawString(pitch, col1, posY + ln2 + 3 * 22, 0x000000, false); + fontRendererObj.drawString("Z,X Rot:", col1, posY + ln1 + 4 * 22, 0x000000, false); + fontRendererObj.drawString(yaw, col1, posY + ln2 + 4 * 22, 0x000000, false); + fontRendererObj.drawString("Length:", col1, posY + ln1 + 5 * 22, 0x000000, false); + fontRendererObj.drawString(length, col1, posY + ln2 + 5 * 22, 0x000000, false); + fontRendererObj.drawString("Rotation:", col1, posY + ln1 + 6 * 22, 0x000000, false); + fontRendererObj.drawString(rotation, col1, posY + ln2 + 6 * 22, 0x000000, false); + fontRendererObj.drawString("Scale:", col1, posY + ln1 + 7 * 22, 0x000000, false); + fontRendererObj.drawString(scale, col1, posY + ln2 + 7 * 22, 0x000000, false); + + } + + @SuppressWarnings("unchecked") + private void page3Buttons() { + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + int DX1 = 5;//x pos for row 1,2,3,4 + int DX2 = DX1 + 71; + int DX3 = DX2 + 40; + int DX4 = DX3 + 71; + int y1 = 19; + + buttonList.add(new GuiButton(100, posX + DX1, posY + y1 + 0 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(101, posX + DX1, posY + y1 + 1 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(102, posX + DX1, posY + y1 + 2 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(103, posX + DX1, posY + y1 + 3 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(104, posX + DX1, posY + y1 + 4 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(105, posX + DX1, posY + y1 + 5 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(106, posX + DX1, posY + y1 + 6 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(107, posX + DX1, posY + y1 + 7 * 22, 20, 20, "+")); + + buttonList.add(new GuiButton(108, posX + DX2, posY + y1 + 0 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(109, posX + DX2, posY + y1 + 1 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(110, posX + DX2, posY + y1 + 2 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(111, posX + DX2, posY + y1 + 3 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(112, posX + DX2, posY + y1 + 4 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(113, posX + DX2, posY + y1 + 5 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(114, posX + DX2, posY + y1 + 6 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(115, posX + DX2, posY + y1 + 7 * 22, 20, 20, "-")); + + buttonList.add(new GuiButton(116, posX + DX3 - 11, posY + y1 + 0 * 22, 102, 20, "Enabled: " + (beam_enabled ? "on" : "off"))); + buttonList.add(new GuiButton(117, posX + DX3 - 11, posY + y1 + 1 * 22, 102, 20, "Render Core: " + (render_core ? "on" : "off"))); + + + buttonList.add(new GuiButton(127, posX + DX3 - 11, posY + y1 + 7 * 22, 102, 20, "Take note of values")); + } + + private void beamActions(GuiButton button) { + int value = 1; + float value_F; + short packetValue = 0; + if (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)) value = 10; + if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) value = 100; + if ((Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54))) + value = 1000; + + value_F = (value) / 100F; + + switch (button.id) { + case 100: //beam red + + beam_red = (beam_red + value) > 255 ? 255 : beam_red + value; + packetValue = (short) beam_red; + break; + case 101: //beam green + + beam_green = (beam_green + value) > 255 ? 255 : beam_green + value; + packetValue = (short) beam_green; + break; + case 102: //beam blue + + beam_blue = (beam_blue + value) > 255 ? 255 : beam_blue + value; + packetValue = (short) beam_blue; + break; + case 103: //beam pitch + + beam_pitch = (beam_pitch + value_F) > 180F ? 180F : beam_pitch + value_F; + packetValue = (short) (beam_pitch * 100F); + break; + case 104: //beam yaw + + beam_yaw = (beam_yaw + value_F) > 180F ? 180F : beam_yaw + value_F; + packetValue = (short) (beam_yaw * 100F); + break; + case 105: //beam length + + beam_length = (beam_length + value_F) > 320F ? 320F : beam_length + value_F; + packetValue = (short) (beam_length * 100F); + break; + case 106: //beam rotation + + beam_rotation = (beam_rotation + value_F) > 1F ? 1F : beam_rotation + value_F; + packetValue = (short) (beam_rotation * 100F); + break; + case 107: //beam scale + + beam_scale = (beam_scale + value_F) > 5F ? 5F : beam_scale + value_F; + packetValue = (short) (beam_scale * 100F); + break; + case 108: //beam red - + beam_red = (beam_red - value) < 0 ? 0 : beam_red - value; + packetValue = (short) beam_red; + break; + case 109: //beam green - + beam_green = (beam_green - value) < 0 ? 0 : beam_green - value; + packetValue = (short) beam_green; + break; + case 110: //beam blue - + beam_blue = (beam_blue - value) < 0 ? 0 : beam_blue - value; + packetValue = (short) beam_blue; + break; + case 111: //beam pitch - + beam_pitch = (beam_pitch - value_F) < -180F ? -180F : beam_pitch - value_F; + packetValue = (short) (beam_pitch * 100F); + break; + case 112: //beam yaw - + beam_yaw = (beam_yaw - value_F) < -180F ? -180F : beam_yaw - value_F; + packetValue = (short) (beam_yaw * 100F); + break; + case 113: //beam length - + beam_length = (beam_length - value_F) < -0F ? -0F : beam_length - value_F; + packetValue = (short) (beam_length * 100F); + break; + case 114: //beam rotation - + beam_rotation = (beam_rotation - value_F) < -1F ? -1F : beam_rotation - value_F; + packetValue = (short) (beam_rotation * 100F); + break; + case 115: //beam scale - + beam_scale = (beam_scale - value_F) < -0F ? -0F : beam_scale - value_F; + packetValue = (short) (beam_scale * 100F); + break; + case 116: //beam enabled + beam_enabled = !beam_enabled; + packetValue = beam_enabled ? (byte) 1 : (byte) 0; + initGui(); + break; + case 117: //beam enabled + render_core = !render_core; + packetValue = render_core ? (byte) 1 : (byte) 0; + initGui(); + break; + + } + DraconicEvolution.network.sendToServer(new ParticleGenPacket((byte) button.id, packetValue, tile.xCoord, tile.yCoord, tile.zCoord)); + } + //@formatter:on } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIPlayerDetector.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIPlayerDetector.java index b74f3a6c..e2c5cc95 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIPlayerDetector.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIPlayerDetector.java @@ -20,277 +20,236 @@ import org.lwjgl.opengl.GL11; import java.util.ArrayList; @SideOnly(Side.CLIENT) -public class GUIPlayerDetector extends GuiContainer -{ +public class GUIPlayerDetector extends GuiContainer { - public EntityPlayer player; - private TilePlayerDetectorAdvanced detector; - public boolean showInvSlots = true; - private boolean editMode = false; - private int range = 0; - private int maxRange = 20; - private boolean whitelist = false; - private boolean initScedualed = false; - private int initTick = 0; - private String[] names = new String[42]; - private GuiTextField selectedNameText; - private int selected = -1; + public EntityPlayer player; + private TilePlayerDetectorAdvanced detector; + public boolean showInvSlots = true; + private boolean editMode = false; + private int range = 0; + private int maxRange = 20; + private boolean whitelist = false; + private boolean initScedualed = false; + private int initTick = 0; + private String[] names = new String[42]; + private GuiTextField selectedNameText; + private int selected = -1; private boolean outputInverted = false; - public GUIPlayerDetector(InventoryPlayer invPlayer, TilePlayerDetectorAdvanced detector) { - super(detector.getGuiContainer(invPlayer)); - this.inventorySlots = new ContainerPlayerDetector(invPlayer, detector, this); + public GUIPlayerDetector(InventoryPlayer invPlayer, TilePlayerDetectorAdvanced detector) { + super(detector.getGuiContainer(invPlayer)); + this.inventorySlots = new ContainerPlayerDetector(invPlayer, detector, this); - for (int i = 0; i < names.length; i++) - names[i] = ""; + for (int i = 0; i < names.length; i++) + names[i] = ""; - xSize = 176; - ySize = 198; + xSize = 176; + ySize = 198; - this.detector = detector; - this.player = invPlayer.player; - syncWithServer(); - } + this.detector = detector; + this.player = invPlayer.player; + syncWithServer(); + } - private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/PlayerDetector.png"); + private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/PlayerDetector.png"); - @Override - protected void drawGuiContainerBackgroundLayer(float f, int x, int y) - { - GL11.glColor4f(1, 1, 1, 1); + @Override + protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { + GL11.glColor4f(1, 1, 1, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(texture); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - if (editMode) - { - drawTexturedModalRect(guiLeft + 3, guiTop + ySize / 2, 3, 3, xSize - 6, (ySize / 2) - 3); - drawNameChart(x, y); - } + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + if (editMode) { + drawTexturedModalRect(guiLeft + 3, guiTop + ySize / 2, 3, 3, xSize - 6, (ySize / 2) - 3); + drawNameChart(x, y); + } - if (showInvSlots) - drawTexturedModalRect(guiLeft + 142, guiTop + 19, xSize, 0, 23, 41); + if (showInvSlots) drawTexturedModalRect(guiLeft + 142, guiTop + 19, xSize, 0, 23, 41); - } + } - @Override - protected void drawGuiContainerForegroundLayer(int x, int y) - { - drawGuiText(x, y); + @Override + protected void drawGuiContainerForegroundLayer(int x, int y) { + drawGuiText(x, y); - } + } - @Override - public void drawScreen(int x, int y, float p_73863_3_) { - super.drawScreen(x, y, p_73863_3_); - ArrayList lines = new ArrayList(); - lines.add("Camouflage"); - if ((x - guiLeft > 142 && x - guiLeft < 160) && (y - guiTop > 19 && y - guiTop < 37) && showInvSlots) - drawHoveringText(lines, x, y, fontRendererObj); - } + @Override + public void drawScreen(int x, int y, float p_73863_3_) { + super.drawScreen(x, y, p_73863_3_); + ArrayList lines = new ArrayList(); + lines.add("Camouflage"); + if ((x - guiLeft > 142 && x - guiLeft < 160) && (y - guiTop > 19 && y - guiTop < 37) && showInvSlots) + drawHoveringText(lines, x, y, fontRendererObj); + } - @SuppressWarnings("unchecked") - @Override - public void initGui() - { - super.initGui(); - buttonList.clear(); - if (!editMode) - { - String wt = whitelist ? "White List" : "Black List"; - int centre = width / 2; - buttonList.add(new GuiButton(0, centre - 20 - 20, guiTop + 20, 20, 20, "+")); - buttonList.add(new GuiButton(1, centre + 20, guiTop + 20, 20, 20, "-")); - buttonList.add(new GuiButton(3, centre - 40, guiTop + 45, 60, 20, wt)); - buttonList.add(new GuiButton(4, centre + 20, guiTop + 45, 20, 20, "!")); + @SuppressWarnings("unchecked") + @Override + public void initGui() { + super.initGui(); + buttonList.clear(); + if (!editMode) { + String wt = whitelist ? "White List" : "Black List"; + int centre = width / 2; + buttonList.add(new GuiButton(0, centre - 20 - 20, guiTop + 20, 20, 20, "+")); + buttonList.add(new GuiButton(1, centre + 20, guiTop + 20, 20, 20, "-")); + buttonList.add(new GuiButton(3, centre - 40, guiTop + 45, 60, 20, wt)); + buttonList.add(new GuiButton(4, centre + 20, guiTop + 45, 20, 20, "!")); buttonList.add(new GuiButton(6, centre - 40, guiTop + 70, 80, 20, "Invert Output")); - } else - { - buttonList.add(new GuiButton(5, guiLeft - 40, guiTop + ySize - 20, 40, 20, "Back")); - } + } else { + buttonList.add(new GuiButton(5, guiLeft - 40, guiTop + ySize - 20, 40, 20, "Back")); + } - selectedNameText = new GuiTextField(fontRendererObj, 4, -12, 168, 12); - selectedNameText.setTextColor(-1); - selectedNameText.setDisabledTextColour(-1); - selectedNameText.setEnableBackgroundDrawing(true); - selectedNameText.setMaxStringLength(40); - selectedNameText.setVisible(editMode); + selectedNameText = new GuiTextField(fontRendererObj, 4, -12, 168, 12); + selectedNameText.setTextColor(-1); + selectedNameText.setDisabledTextColour(-1); + selectedNameText.setEnableBackgroundDrawing(true); + selectedNameText.setMaxStringLength(40); + selectedNameText.setVisible(editMode); - //ID - //buttonList.add(new GuiButton(0, guiLeft + 85, guiTop , 85, 20, "sgASGgs")); + //ID + //buttonList.add(new GuiButton(0, guiLeft + 85, guiTop , 85, 20, "sgASGgs")); - //syncWithServer(); - } + //syncWithServer(); + } - @Override - protected void actionPerformed(GuiButton button) - { - switch (button.id) { - case 0: //Range + - range = (range < maxRange) ? range + 1 : maxRange; - DraconicEvolution.network.sendToServer(new PlayerDetectorButtonPacket((byte)0, (byte)range)); - break; - case 1: //Range - - range = (range > 1) ? range - 1 : 1; - DraconicEvolution.network.sendToServer(new PlayerDetectorButtonPacket((byte)0, (byte)range)); - break; - case 3: //White List - - initScedualed = true; - editMode = true; - showInvSlots = false; - ((ContainerPlayerDetector) this.inventorySlots).updateContainerSlots(); - break; - case 4: //Toggle White List - - whitelist = !whitelist; - initScedualed = true; - byte val = (byte) (whitelist ? 1 : 0); - DraconicEvolution.network.sendToServer(new PlayerDetectorButtonPacket((byte)1, val)); - break; - case 5: //Back - - editMode = false; - showInvSlots = true; - ((ContainerPlayerDetector) this.inventorySlots).updateContainerSlots(); - initScedualed = true; - break; + @Override + protected void actionPerformed(GuiButton button) { + switch (button.id) { + case 0: //Range + + range = (range < maxRange) ? range + 1 : maxRange; + DraconicEvolution.network.sendToServer(new PlayerDetectorButtonPacket((byte) 0, (byte) range)); + break; + case 1: //Range - + range = (range > 1) ? range - 1 : 1; + DraconicEvolution.network.sendToServer(new PlayerDetectorButtonPacket((byte) 0, (byte) range)); + break; + case 3: //White List - + initScedualed = true; + editMode = true; + showInvSlots = false; + ((ContainerPlayerDetector) this.inventorySlots).updateContainerSlots(); + break; + case 4: //Toggle White List - + whitelist = !whitelist; + initScedualed = true; + byte val = (byte) (whitelist ? 1 : 0); + DraconicEvolution.network.sendToServer(new PlayerDetectorButtonPacket((byte) 1, val)); + break; + case 5: //Back - + editMode = false; + showInvSlots = true; + ((ContainerPlayerDetector) this.inventorySlots).updateContainerSlots(); + initScedualed = true; + break; case 6: //Back - outputInverted = !outputInverted; initScedualed = true; byte val2 = (byte) (outputInverted ? 1 : 0); - DraconicEvolution.network.sendToServer(new PlayerDetectorButtonPacket((byte)2, val2)); + DraconicEvolution.network.sendToServer(new PlayerDetectorButtonPacket((byte) 2, val2)); break; - } + } - //DraconicEvolution.channelHandler.sendToServer(new ButtonPacket((byte) 0, true)); + //DraconicEvolution.channelHandler.sendToServer(new ButtonPacket((byte) 0, true)); - } + } - @Override - protected void keyTyped(char par1, int par2) - { - if(this.selectedNameText.textboxKeyTyped(par1, par2)) - return; - else if (par2 == 28) - { - if (selectedNameText.isFocused()) - { - names[selected] = selectedNameText.getText(); - selectedNameText.setText(""); - selectedNameText.setFocused(false); - DraconicEvolution.network.sendToServer(new PlayerDetectorStringPacket((byte)selected, names[selected])); - selected = -1; - } - }else - super.keyTyped(par1, par2); - } + @Override + protected void keyTyped(char par1, int par2) { + if (this.selectedNameText.textboxKeyTyped(par1, par2)) return; + else if (par2 == 28) { + if (selectedNameText.isFocused()) { + names[selected] = selectedNameText.getText(); + selectedNameText.setText(""); + selectedNameText.setFocused(false); + DraconicEvolution.network.sendToServer(new PlayerDetectorStringPacket((byte) selected, names[selected])); + selected = -1; + } + } else super.keyTyped(par1, par2); + } - @Override - public void updateScreen() - { - if (initScedualed) - initTick++; - if (initTick > 1) - { - initTick = 0; - initScedualed = false; - initGui(); - } - super.updateScreen(); - } + @Override + public void updateScreen() { + if (initScedualed) initTick++; + if (initTick > 1) { + initTick = 0; + initScedualed = false; + initGui(); + } + super.updateScreen(); + } - @Override - protected void mouseClicked(int x, int y, int par3) - { - super.mouseClicked(x, y, par3); + @Override + protected void mouseClicked(int x, int y, int par3) { + super.mouseClicked(x, y, par3); - if (editMode) - selectName(x - guiLeft, y - guiTop); + if (editMode) selectName(x - guiLeft, y - guiTop); - //this.selectedNameText.mouseClicked(x - guiLeft, y - guiTop, par3); - } + //this.selectedNameText.mouseClicked(x - guiLeft, y - guiTop, par3); + } - private void drawGuiText(int rawX, int rawY) - { - if (!editMode) - { - drawCenteredString(fontRendererObj, "Advanced Player Detector", xSize/2, 5, 0x00FFFF); - - fontRendererObj.drawString("Range:", 73, 21, 0x000000, false); + private void drawGuiText(int rawX, int rawY) { + if (!editMode) { + drawCenteredString(fontRendererObj, "Advanced Player Detector", xSize / 2, 5, 0x00FFFF); + + fontRendererObj.drawString("Range:", 73, 21, 0x000000, false); fontRendererObj.drawString("Output Inverted: " + String.valueOf(outputInverted), 33, 97, 0x000000, false); - if (range < 10) - fontRendererObj.drawString("" + range, 85, 31, 0x000000, false); - else - fontRendererObj.drawString("" + range, 82, 31, 0x000000, false); - } else - { - if (selected != -1) - drawCenteredString(fontRendererObj, "Press Enter to save", xSize/2, -22, 0xFF0000); - - for (int i = 0; i < 21; i++) - { - for (int j = 0; j < 2; j++) - { - if (i + j * 21 != selected) - { - String s = names[i + j * 21]; - if (s.length() > 13) - s = s.substring(0, 13) + "..."; - fontRendererObj.drawString(s, 5 + j * 84, 6 + i * 9, 0x980000); - } - } - } - } + if (range < 10) fontRendererObj.drawString("" + range, 85, 31, 0x000000, false); + else fontRendererObj.drawString("" + range, 82, 31, 0x000000, false); + } else { + if (selected != -1) drawCenteredString(fontRendererObj, "Press Enter to save", xSize / 2, -22, 0xFF0000); - selectedNameText.drawTextBox(); - } + for (int i = 0; i < 21; i++) { + for (int j = 0; j < 2; j++) { + if (i + j * 21 != selected) { + String s = names[i + j * 21]; + if (s.length() > 13) s = s.substring(0, 13) + "..."; + fontRendererObj.drawString(s, 5 + j * 84, 6 + i * 9, 0x980000); + } + } + } + } - private void drawNameChart(int rawX, int rawY) - { - int x = rawX - guiLeft; - int y = rawY - guiTop; + selectedNameText.drawTextBox(); + } - for (int i = 0; i < 21; i++) - { - drawTexturedModalRect(guiLeft + 4, guiTop + 4 + i * 9, 0, ySize, 186, 10); - } + private void drawNameChart(int rawX, int rawY) { + int x = rawX - guiLeft; + int y = rawY - guiTop; - for (int i = 0; i < 21; i++) - { - for (int j = 0; j < 2; j++) - { - if ((x > 4 + j * 84 && x < (xSize / 2) - 1 + j * 82) && (y > 4 + i * 9 && y < 13 + i * 9) || i + j * 21 == selected) - drawTexturedModalRect(guiLeft + 5 + j * 84, guiTop + 5 + i * 9, 0, ySize + 10, 82, 8); - } - } - } + for (int i = 0; i < 21; i++) { + drawTexturedModalRect(guiLeft + 4, guiTop + 4 + i * 9, 0, ySize, 186, 10); + } - public void selectName(int x, int y) - { - if (initScedualed) - return; + for (int i = 0; i < 21; i++) { + for (int j = 0; j < 2; j++) { + if ((x > 4 + j * 84 && x < (xSize / 2) - 1 + j * 82) && (y > 4 + i * 9 && y < 13 + i * 9) || i + j * 21 == selected) + drawTexturedModalRect(guiLeft + 5 + j * 84, guiTop + 5 + i * 9, 0, ySize + 10, 82, 8); + } + } + } - for (int i = 0; i < 21; i++) - { - for (int j = 0; j < 2; j++) - { - if ((x > 4 + j * 84 && x < (xSize / 2) - 1 + j * 82) && (y > 4 + i * 9 && y < 13 + i * 9)) - { - selected = i + j * 21; - selectedNameText.setText(names[i + j * 21]); - selectedNameText.setFocused(true); - } - } - } - } + public void selectName(int x, int y) { + if (initScedualed) return; - private void syncWithServer() - { - this.whitelist = detector.whiteList; - for (int i = 0; i < detector.names.length; i++) - { - if (detector.names[i] != null) - names[i] = detector.names[i]; - } - range = detector.range; + for (int i = 0; i < 21; i++) { + for (int j = 0; j < 2; j++) { + if ((x > 4 + j * 84 && x < (xSize / 2) - 1 + j * 82) && (y > 4 + i * 9 && y < 13 + i * 9)) { + selected = i + j * 21; + selectedNameText.setText(names[i + j * 21]); + selectedNameText.setFocused(true); + } + } + } + } + + private void syncWithServer() { + this.whitelist = detector.whiteList; + for (int i = 0; i < detector.names.length; i++) { + if (detector.names[i] != null) names[i] = detector.names[i]; + } + range = detector.range; outputInverted = detector.outputInverted; - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUISunDial.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUISunDial.java index ffc4be63..ef4c1a2f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUISunDial.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUISunDial.java @@ -19,66 +19,60 @@ import com.brandon3055.draconicevolution.common.tileentities.TileSunDial; @SideOnly(Side.CLIENT) public class GUISunDial extends GuiContainer { - private int guiUpdateTick; - - public GUISunDial(InventoryPlayer invPlayer, TileSunDial te1) { - super(new ContainerSunDial(invPlayer, te1)); + private int guiUpdateTick; - xSize = 176; - ySize = 90; - - } + public GUISunDial(InventoryPlayer invPlayer, TileSunDial te1) { + super(new ContainerSunDial(invPlayer, te1)); - private static final ResourceLocation texture = new ResourceLocation(References.MODID, "textures/gui/SunDial.png"); + xSize = 176; + ySize = 90; - @Override - protected void drawGuiContainerBackgroundLayer(float f, int x, int y) - { - GL11.glColor4f(1, 1, 1, 1); + } + + private static final ResourceLocation texture = new ResourceLocation(References.MODID, "textures/gui/SunDial.png"); + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { + GL11.glColor4f(1, 1, 1, 1); + + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + + } + + @Override + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { + //fontRendererObj.drawString("Charges: " + charges, 90, 25, 0x000000); + //drawCenteredString(fontRendererObj, "Charges: " + charges, 117, 25, 0x000000); + //drawCenteredString(fontRendererObj, "Weather Controller", xSize/2, -15, 0x2a4ed0); + + } + + @SuppressWarnings("unchecked") + @Override + public void initGui() { + super.initGui(); + //ID + buttonList.add(new GuiButton(0, guiLeft + 10, guiTop + 10, 85, 20, "")); + } + + @Override + protected void actionPerformed(GuiButton button) { + if (button.id == 0) { + DraconicEvolution.network.sendToServer(new TeleporterPacket()); + } + + } + + @Override + public void updateScreen() { + guiUpdateTick++; + if (guiUpdateTick >= 10) { + initGui(); + guiUpdateTick = 0; + } + super.updateScreen(); + } - Minecraft.getMinecraft().getTextureManager().bindTexture(texture); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - - } - - @Override - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) - { - //fontRendererObj.drawString("Charges: " + charges, 90, 25, 0x000000); - //drawCenteredString(fontRendererObj, "Charges: " + charges, 117, 25, 0x000000); - //drawCenteredString(fontRendererObj, "Weather Controller", xSize/2, -15, 0x2a4ed0); - - } - - @SuppressWarnings("unchecked") - @Override - public void initGui() - { - super.initGui(); - //ID - buttonList.add(new GuiButton(0, guiLeft +10, guiTop + 10, 85, 20, "")); - } - - @Override - protected void actionPerformed(GuiButton button) - { - if (button.id == 0){ - DraconicEvolution.network.sendToServer(new TeleporterPacket()); - } - - } - - @Override - public void updateScreen() - { - guiUpdateTick++; - if (guiUpdateTick >= 10){ - initGui(); - guiUpdateTick = 0; - } - super.updateScreen(); - } - - } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUITeleporter.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUITeleporter.java index e9f858ac..0b57f295 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUITeleporter.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUITeleporter.java @@ -30,520 +30,503 @@ import java.util.ArrayList; import java.util.List; @SideOnly(Side.CLIENT) -public class GUITeleporter extends GuiScreen -{ - private final int xSize = 182; - private final int ySize = 141; - private ResourceLocation guiTexture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/TeleporterMKII.png"); - private ItemStack teleporterItem; - protected List locations = new ArrayList(0); - - private int selected = 0; - private int selectionOffset = 0; - private int maxOffset = 0; - private int fuel = 0; - private boolean editingExisting = false; - private boolean editingNew = false; - private boolean showFuelLight = true; - private int tick = 0; - private GuiTextField textBeingEdited; - - private EntityPlayer player; - - public GUITeleporter(EntityPlayer player) { - super(); - this.player = player; - if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().isItemEqual(new ItemStack(ModItems.teleporterMKII))) - { - this.teleporterItem = player.getCurrentEquippedItem(); - readDataFromItem(teleporterItem); - } - } - - @Override - public void drawScreen(int x, int y, float f){ - drawDefaultBackground(); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - Minecraft.getMinecraft().renderEngine.bindTexture(guiTexture); - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - drawTexturedModalRect(posX, posY, 0, 0, xSize, ySize); - - if (fuel <= 5) drawTexturedModalRect(posX+169, posY+86, 40, 150, 7, 7); - if (fuel <= 5 && showFuelLight || (fuel > 5 && fuel < 10)) drawTexturedModalRect(posX+169, posY+86, 40, 143, 7, 7); - - drawArrows(x-posX, y-posY); - - drawLocations(x-posX, y-posY); - - drawSelectionInfo(); - - textBeingEdited.drawTextBox(); - - String colour = EnumChatFormatting.GREEN + ""; - if (fuel < 10) colour = EnumChatFormatting.YELLOW + ""; - if (fuel == 0) colour = EnumChatFormatting.DARK_RED + ""; - fontRendererObj.drawString(colour+StatCollector.translateToLocal("info.teleporterInfFuel.txt") + " " + fuel, posX + 115, posY + 87, 0x000000); - - super.drawScreen(x, y, f); - - for (int i = 0; i < Math.min(12, locations.size()); i++){ - if (GuiHelper.isInRect(17, 6+i*11, 80, 10, x - posX, y - posY)) { - List l = new ArrayList(); - l.add(StatCollector.translateToLocal("info.de.rightClickToTeleport.txt")); - drawHoveringText(l, x, y, fontRendererObj); - } - } - } - - private void drawLocations(int x, int y){ - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - - for (int i = 0; i < Math.min(12, locations.size()); i++){ - if (GuiHelper.isInRect(17, 6+i*11, 80, 10, x, y)) { - drawTexturedModalRect(posX+19, posY+5+i*11, 0, 188, 80, 10); - } - - if (getLocationSafely(i + selectionOffset).getWriteProtected()){ - if (GuiHelper.isInRect(102, 7+i*11, 6, 6, x, y)) drawTexturedModalRect(posX+102, posY+7+i*11, 26, 149, 6, 6); - else drawTexturedModalRect(posX+102, posY+7+i*11, 26, 143, 6, 6); - }else{ - if (GuiHelper.isInRect(101, 7+i*11, 8, 7, x, y)) drawTexturedModalRect(posX+101, posY+7+i*11, 32, 150, 8, 7); - else drawTexturedModalRect(posX+101, posY+7+i*11, 32, 143, 8, 7); - } - } - - drawTexturedModalRect(posX+19, posY+5+selected*11, 0, 188, 80, 10); - - int yl = 0; - for (int i = selectionOffset; i < locations.size() && i < selectionOffset + 12; i++){ - String s = getLocationSafely(i).getName(); - if (fontRendererObj.getStringWidth(s) > 80) { - int safety = 0; - while (fontRendererObj.getStringWidth(s) > 70){ - s = s.substring(0, s.length()-1); - safety++; - if (safety > 200) break; - } - s = s+"..."; - } - fontRendererObj.drawString(s, posX + 21, posY + 7 + (yl * 11), 0x000000); - yl++; - } - } - - private void drawArrows(int x, int y){ - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - - if (selectionOffset > 0){ - boolean highLighted = GuiHelper.isInRect(4, 4, 13, 15, x, y); - if (highLighted) drawTexturedModalRect(posX+4, posY+4, 0, 158, 13, 15); - else drawTexturedModalRect(posX+4, posY+4, 0, 143, 13, 15); - }else drawTexturedModalRect(posX+4, posY+4, 0, 173, 13, 15); - if (selectionOffset < maxOffset){ - boolean highLighted = GuiHelper.isInRect(4, 122, 13, 15, x, y); - if (highLighted) drawTexturedModalRect(posX+4, posY+122, 13, 158, 13, 15); - else drawTexturedModalRect(posX+4, posY+122, 13, 143, 13, 15); - } else drawTexturedModalRect(posX+4, posY+122, 13, 173, 13, 15); - - float percent = locations.size() <= 12 ? 1f : 12F / (float)locations.size(); - int drawSize = (int)(percent * 99F); - int space = 99 - drawSize; - float location = (float) selectionOffset / (float)(locations.size()-12); - int yOffset = (int) (location * (float)space); - drawTexturedModalRect(posX+5, posY+21+yOffset, 182, 0, 11, drawSize); - drawTexturedModalRect(posX+5, posY+21+drawSize-1+yOffset, 182, 98, 11, 1); - } - - private void drawSelectionInfo(){ - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - if (locations.size() <= 0) return; - fontRendererObj.drawString(EnumChatFormatting.GOLD+"X: "+(int)getLocationSafely(selected + selectionOffset).getXCoord(), posX+114, posY+7, 0x000000); - fontRendererObj.drawString(EnumChatFormatting.GOLD + "Y: " + (int) getLocationSafely(selected + selectionOffset).getYCoord(), posX + 114, posY + 16, 0x000000); - fontRendererObj.drawString(EnumChatFormatting.GOLD + "Z: " + (int) getLocationSafely(selected + selectionOffset).getZCoord(), posX + 114, posY + 25, 0x000000); - fontRendererObj.drawString(EnumChatFormatting.GOLD+""+ getLocationSafely(selected + selectionOffset).getDimensionName(), posX+114, posY+34, 0x000000); - } - - @Override - protected void mouseClicked(int x, int y, int button){ - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - - boolean offsetChanged = false; - boolean selectionChanged = false; - - if (textBeingEdited.getVisible()) textBeingEdited.mouseClicked(x, y, button); - - //Check for arrow click - if (selectionOffset > 0 && GuiHelper.isInRect(3, 5, 13, 15, x-posX, y-posY)){ - selectionOffset--; - offsetChanged = true; - if (selected < 11) { - selected++; - selectionChanged = true; - } - } - if (selectionOffset < maxOffset && GuiHelper.isInRect(3, 123, 13, 15, x-posX, y-posY)){ - selectionOffset++; - offsetChanged = true; - if (selected > 0) { - selected--; - selectionChanged = true; - } - } - - //Check for location or lock clicked - for (int i = 0; i < Math.min(12, locations.size()); i++){ - if (GuiHelper.isInRect(17, 6+i*11, 80, 10, x-posX, y-posY)) { - if (!(getLocationSafely(i + selectionOffset).getWriteProtected() && editingExisting) && button == 0) - { - selected = i; - selectionChanged = true; - } - if (!(getLocationSafely(i + selectionOffset).getWriteProtected() && editingExisting) && button == 1) - { - if (locations.isEmpty()) return; - - if (!player.capabilities.isCreativeMode && fuel <= 0) - { - player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfFuel.txt")); - } - - if (player.capabilities.isCreativeMode || fuel > 0) { - if (!player.capabilities.isCreativeMode) fuel--; - DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.TELEPORT, i+ selectionOffset, false)); - } - } - } - - if (GuiHelper.isInRect(99, 8+i*11, 8, 7, x-posX, y-posY)) { - getLocationSafely(i + selectionOffset).setWriteProtected(!getLocationSafely(i + selectionOffset).getWriteProtected()); - DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.UPDATELOCK, i+ selectionOffset, getLocationSafely(i + selectionOffset).getWriteProtected())); - } - } - - - if (selectionChanged) DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.CHANGESELECTION, selected, false)); - if (offsetChanged) DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.UPDATEOFFSET, selectionOffset, false)); - - updateButtons(); - super.mouseClicked(x, y, button); - } - - @Override - 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_); - } - - @Override - public void handleMouseInput() { - int i = org.lwjgl.input.Mouse.getEventDWheel(); - boolean offsetChanged = false; - boolean selectionChanged = false; - if (i < 0 && selectionOffset < maxOffset) { - selectionOffset++; - offsetChanged = true; - if (selected > 0) { - selected--; - selectionChanged = true; - } - updateButtons(); - } - if (i > 0 && selectionOffset > 0) { - selectionOffset--; - offsetChanged = true; - if (selected < 11) { - selected++; - selectionChanged = true; - } - updateButtons(); - } - - if (selectionChanged) DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.CHANGESELECTION, selected, false)); - if (offsetChanged) DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.UPDATEOFFSET, selectionOffset, false)); - - super.handleMouseInput(); - } - - private void updateButtons(){ - if (locations.size() > 12) maxOffset = locations.size() - 12; - else maxOffset = 0; - if (selectionOffset > maxOffset) selectionOffset = maxOffset; - if (selected > locations.size() || selected < 0) selected = Math.max(locations.size() - 1, 0); - if ((selected + selectionOffset)+1 > locations.size()){ - selected = 0; - selectionOffset = 0; - DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.CHANGESELECTION, selected, false)); - DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.UPDATEOFFSET, selectionOffset, false)); - } - if (locations.size() == 0 || getLocationSafely(selected + selectionOffset).getWriteProtected()) { - ((GuiButton) buttonList.get(0)).enabled = false; - ((GuiButton) buttonList.get(1)).enabled = false; - ((GuiButton) buttonList.get(2)).enabled = false; - } else { - ((GuiButton) buttonList.get(0)).enabled = true; - ((GuiButton) buttonList.get(1)).enabled = true; - ((GuiButton) buttonList.get(2)).enabled = true; - } - if (editingNew){ - ((GuiButton) buttonList.get(4)).enabled = !textBeingEdited.getText().isEmpty(); - ((GuiButton) buttonList.get(4)).displayString = StatCollector.translateToLocal("button.de.commit.txt"); - } - if (editingExisting){ - ((GuiButton) buttonList.get(0)).enabled = !textBeingEdited.getText().isEmpty(); - ((GuiButton) buttonList.get(0)).displayString = StatCollector.translateToLocal("button.de.commit.txt"); - } - if (locations.size() >= 100) ((GuiButton) buttonList.get(4)).enabled = false; - else if (!editingNew) ((GuiButton) buttonList.get(4)).enabled = true; - } - - @SuppressWarnings("unchecked") - @Override - public void initGui(){ - buttonList.clear(); - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - - //updateTeleporter(); - - buttonList.add(new GuiButtonAHeight(0, posX + 112, posY + 45, 66, 12, StatCollector.translateToLocal("button.de.rename.txt"))); - buttonList.add(new GuiButtonAHeight(1, posX + 112, posY + 58, 66, 12, StatCollector.translateToLocal("button.de.setHere.txt"))); - buttonList.add(new GuiButtonAHeight(2, posX + 112, posY + 71, 66, 12, StatCollector.translateToLocal("button.de.remove.txt"))); - - buttonList.add(new GuiButtonAHeight(3, posX + 112, posY + 99, 33, 12, StatCollector.translateToLocal("button.de.UP.txt"))); - - buttonList.add(new GuiButtonAHeight(4, posX + 112, posY + 112, 66, 12, StatCollector.translateToLocal("button.de.addNew.txt"))); - buttonList.add(new GuiButtonAHeight(5, posX + 112, posY + 125, 66, 12, StatCollector.translateToLocal("button.de.addFuel.txt"))); - buttonList.add(new GuiButtonAHeight(6, posX+xSize-63, posY-15, 60, 15, StatCollector.translateToLocal("button.de.cancel.txt"))); - - buttonList.add(new GuiButtonAHeight(7, posX + 112 + 34, posY + 99, 33, 12, StatCollector.translateToLocal("button.de.DOWN.txt"))); - ((GuiButton) buttonList.get(6)).visible = false; - - textBeingEdited = new GuiTextField(fontRendererObj, posX+3, posY-14, xSize-67, 12); - textBeingEdited.setTextColor(-1); - textBeingEdited.setDisabledTextColour(-1); - textBeingEdited.setEnableBackgroundDrawing(true); - textBeingEdited.setMaxStringLength(40); - textBeingEdited.setVisible(false); - - updateButtons(); - } - - @Override - protected void actionPerformed(GuiButton button){ - if (button.id == 0 || button.id == 6 && !editingNew){ - if(button.id == 6){ - editingExisting = false; - ((GuiButton) buttonList.get(0)).displayString = StatCollector.translateToLocal("button.de.rename.txt"); - ((GuiButton) buttonList.get(6)).visible = false; - textBeingEdited.setVisible(false); - ((GuiButton) buttonList.get(0)).enabled = true; - return; - } - if (!editingExisting){ - editingExisting = true; - textBeingEdited.setVisible(true); - textBeingEdited.setText(getLocationSafely(selected + selectionOffset).getName()); - textBeingEdited.setSelectionPos(0); - textBeingEdited.setFocused(true); - ((GuiButton) buttonList.get(6)).visible = true; - }else{ - if (!textBeingEdited.getText().isEmpty()){ - getLocationSafely(selected + selectionOffset).setName(textBeingEdited.getText()); - TeleportLocation location = new TeleportLocation(); - location.setName(textBeingEdited.getText()); - DraconicEvolution.network.sendToServer(new TeleporterPacket(location, TeleporterPacket.UPDATENAME, selected+ selectionOffset)); - ((GuiButton) buttonList.get(0)).displayString = StatCollector.translateToLocal("button.de.rename.txt"); - editingExisting = false; - textBeingEdited.setVisible(false); - ((GuiButton) buttonList.get(6)).visible = false; - } - } - } - - if (button.id == 1){ - TeleportLocation location = new TeleportLocation(player.posX, player.posY-1.62, player.posZ, player.dimension, player.rotationPitch, player.rotationYaw, getLocationSafely(selected + selectionOffset).getName()); - DraconicEvolution.network.sendToServer(new TeleporterPacket(location, TeleporterPacket.UPDATEDESTINATION, selected+ selectionOffset)); - locations.set(selected + selectionOffset, location); - } - - if (button.id == 2) { - DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.REMOVEDESTINATION, selected+ selectionOffset, false)); - locations.remove(selected+ selectionOffset); - if (selectionOffset > 0) selectionOffset--; - if (selected >= locations.size()) selected--; - } - - if (button.id == 3 || button.id == 7) - { - if (button.id == 3) - { - if (selected > 0) - { - TeleportLocation temp = getLocationSafely(selected + selectionOffset); - locations.set(selected + selectionOffset, getLocationSafely(selected + selectionOffset - 1)); - locations.set(selected + selectionOffset - 1, temp); - selected--; - } - } - else - { - if (selected < Math.min(11, locations.size()-1)) - { - TeleportLocation temp = getLocationSafely(selected + selectionOffset); - locations.set(selected + selectionOffset, getLocationSafely(selected + selectionOffset + 1)); - locations.set(selected + selectionOffset + 1, temp); - selected++; - } - } - - DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.MOVELOCATION, selected+ selectionOffset, button.id == 3)); - } - - if (button.id == 4 || button.id == 6 && !editingExisting){ - if(button.id == 6){ - editingNew = false; - ((GuiButton) buttonList.get(4)).displayString = StatCollector.translateToLocal("button.de.addNew.txt"); - ((GuiButton) buttonList.get(6)).visible = false; - ((GuiButton) buttonList.get(4)).enabled = true; - textBeingEdited.setVisible(false); - return; - } - if (!editingNew){ - editingNew = true; - textBeingEdited.setVisible(true); - textBeingEdited.setText(""+(int)player.posX+" "+(int)player.posY+" "+(int)player.posZ); - textBeingEdited.setSelectionPos(0); - textBeingEdited.setFocused(true); - ((GuiButton) buttonList.get(6)).visible = true; - }else{ - if (!textBeingEdited.getText().isEmpty()){ - addCurrentLocationToList(textBeingEdited.getText()); - ((GuiButton) buttonList.get(4)).displayString = StatCollector.translateToLocal("button.de.addNew.txt"); - editingNew = false; - textBeingEdited.setVisible(false); - ((GuiButton) buttonList.get(6)).visible = false; - } - } - } - - if (button.id == 5) - { - if (player.inventory.hasItem(Items.ender_pearl)) - { - if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) - { - DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.ADDFUEL, 1, false)); - this.fuel += ConfigHandler.teleporterUsesPerPearl; - }else if (hasPearls(16)) - { - DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.ADDFUEL, 16, false)); - this.fuel += ConfigHandler.teleporterUsesPerPearl * 16; - }else - player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfPearls.txt")); - } - else - player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfPearls.txt")); - } - updateButtons(); - } - - public boolean hasPearls(int number){ - int found = 0; - ItemStack stack; - for (int i = 0; i < player.inventory.getSizeInventory(); i++) - { - stack = player.inventory.getStackInSlot(i); - if (stack != null && stack.isItemEqual(new ItemStack(Items.ender_pearl))) - found += stack.stackSize; - - if (found >= number) - return true; - } - return false; - } - - @Override - public void keyTyped(char key, int keyN){ - if(this.textBeingEdited.textboxKeyTyped(key, keyN)) { - if (editingNew){ - ((GuiButton) buttonList.get(4)).enabled = !textBeingEdited.getText().isEmpty(); - ((GuiButton) buttonList.get(4)).displayString = StatCollector.translateToLocal("button.de.commit.txt"); - } - if (editingExisting){ - ((GuiButton) buttonList.get(0)).enabled = !textBeingEdited.getText().isEmpty(); - ((GuiButton) buttonList.get(0)).displayString = StatCollector.translateToLocal("button.de.commit.txt"); - } - return; - } - - if (keyN == 28 && editingNew) actionPerformed((GuiButton)buttonList.get(4)); - if (keyN == 28 && editingExisting) actionPerformed((GuiButton)buttonList.get(0)); - - if ((key == 'e' && (!editingExisting || !editingNew)) || key == '') - { - this.mc.displayGuiScreen(null); - this.mc.setIngameFocus(); - } - } - - @Override - public void updateScreen(){ - if (player.getCurrentEquippedItem() == null || !player.getCurrentEquippedItem().isItemEqual(new ItemStack(ModItems.teleporterMKII)) || player.isDead) - { - this.mc.displayGuiScreen(null); - this.mc.setIngameFocus(); - } - - if (tick % 5 == 0 && locations.size() > 0 && getLocationSafely(selected + selectionOffset).getDimensionName().equals("") && player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.teleporterMKII) readDataFromItem(player.getHeldItem()); - - tick++; - if (tick >= 10){ - tick = 0; - showFuelLight = !showFuelLight; - } - } - - @Override - public boolean doesGuiPauseGame() - { - return false; - } - - private void readDataFromItem(ItemStack teleporter){ - this.selected = ItemNBTHelper.getShort(teleporter, "Selection", (short) 0); - this.selectionOffset = ItemNBTHelper.getInteger(teleporter, "SelectionOffset", 0); - this.fuel = ItemNBTHelper.getInteger(teleporter, "Fuel", 0); - - locations.clear(); - - NBTTagCompound compound = teleporter.getTagCompound(); - if(compound == null || compound.getTagList("Locations", 0) == null) return; - NBTTagList list = (NBTTagList)compound.getTag("Locations"); - if (list == null) list = new NBTTagList(); - - for (int i = 0; i < list.tagCount(); i++){ - NBTTagCompound tagLocation = list.getCompoundTagAt(i); - //TeleportLocation location = new TeleportLocation(tagLocation.getDouble("X"), tagLocation.getDouble("Y"), tagLocation.getDouble("Z"), tagLocation.getInteger("Dimension"), tagLocation.getFloat("Pitch"), tagLocation.getFloat("Yaw"), tagLocation.getString("Name")); - TeleportLocation location = new TeleportLocation(); - location.readFromNBT(tagLocation); - location.setWriteProtected(tagLocation.getBoolean("WP")); - locations.add(location); - } - } - - private void addCurrentLocationToList(String name){ - TeleportLocation currentLocation = new TeleportLocation(player.posX, player.posY-1.62, player.posZ, player.dimension, player.rotationPitch, player.rotationYaw, name); - DraconicEvolution.network.sendToServer(new TeleporterPacket(currentLocation, TeleporterPacket.ADDDESTINATION)); - locations.add(currentLocation); - } - - private TeleportLocation getLocationSafely(int index) - { - if (index < locations.size() && index >= 0) return locations.get(index); - return new TeleportLocation(0, 0, 0, 0, 0, 0, EnumChatFormatting.DARK_RED + "[Index Error]"); - } +public class GUITeleporter extends GuiScreen { + private final int xSize = 182; + private final int ySize = 141; + private ResourceLocation guiTexture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/TeleporterMKII.png"); + private ItemStack teleporterItem; + protected List locations = new ArrayList(0); + + private int selected = 0; + private int selectionOffset = 0; + private int maxOffset = 0; + private int fuel = 0; + private boolean editingExisting = false; + private boolean editingNew = false; + private boolean showFuelLight = true; + private int tick = 0; + private GuiTextField textBeingEdited; + + private EntityPlayer player; + + public GUITeleporter(EntityPlayer player) { + super(); + this.player = player; + if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().isItemEqual(new ItemStack(ModItems.teleporterMKII))) { + this.teleporterItem = player.getCurrentEquippedItem(); + readDataFromItem(teleporterItem); + } + } + + @Override + public void drawScreen(int x, int y, float f) { + drawDefaultBackground(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getMinecraft().renderEngine.bindTexture(guiTexture); + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + drawTexturedModalRect(posX, posY, 0, 0, xSize, ySize); + + if (fuel <= 5) drawTexturedModalRect(posX + 169, posY + 86, 40, 150, 7, 7); + if (fuel <= 5 && showFuelLight || (fuel > 5 && fuel < 10)) + drawTexturedModalRect(posX + 169, posY + 86, 40, 143, 7, 7); + + drawArrows(x - posX, y - posY); + + drawLocations(x - posX, y - posY); + + drawSelectionInfo(); + + textBeingEdited.drawTextBox(); + + String colour = EnumChatFormatting.GREEN + ""; + if (fuel < 10) colour = EnumChatFormatting.YELLOW + ""; + if (fuel == 0) colour = EnumChatFormatting.DARK_RED + ""; + fontRendererObj.drawString(colour + StatCollector.translateToLocal("info.teleporterInfFuel.txt") + " " + fuel, posX + 115, posY + 87, 0x000000); + + super.drawScreen(x, y, f); + + for (int i = 0; i < Math.min(12, locations.size()); i++) { + if (GuiHelper.isInRect(17, 6 + i * 11, 80, 10, x - posX, y - posY)) { + List l = new ArrayList(); + l.add(StatCollector.translateToLocal("info.de.rightClickToTeleport.txt")); + drawHoveringText(l, x, y, fontRendererObj); + } + } + } + + private void drawLocations(int x, int y) { + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + + for (int i = 0; i < Math.min(12, locations.size()); i++) { + if (GuiHelper.isInRect(17, 6 + i * 11, 80, 10, x, y)) { + drawTexturedModalRect(posX + 19, posY + 5 + i * 11, 0, 188, 80, 10); + } + + if (getLocationSafely(i + selectionOffset).getWriteProtected()) { + if (GuiHelper.isInRect(102, 7 + i * 11, 6, 6, x, y)) + drawTexturedModalRect(posX + 102, posY + 7 + i * 11, 26, 149, 6, 6); + else drawTexturedModalRect(posX + 102, posY + 7 + i * 11, 26, 143, 6, 6); + } else { + if (GuiHelper.isInRect(101, 7 + i * 11, 8, 7, x, y)) + drawTexturedModalRect(posX + 101, posY + 7 + i * 11, 32, 150, 8, 7); + else drawTexturedModalRect(posX + 101, posY + 7 + i * 11, 32, 143, 8, 7); + } + } + + drawTexturedModalRect(posX + 19, posY + 5 + selected * 11, 0, 188, 80, 10); + + int yl = 0; + for (int i = selectionOffset; i < locations.size() && i < selectionOffset + 12; i++) { + String s = getLocationSafely(i).getName(); + if (fontRendererObj.getStringWidth(s) > 80) { + int safety = 0; + while (fontRendererObj.getStringWidth(s) > 70) { + s = s.substring(0, s.length() - 1); + safety++; + if (safety > 200) break; + } + s = s + "..."; + } + fontRendererObj.drawString(s, posX + 21, posY + 7 + (yl * 11), 0x000000); + yl++; + } + } + + private void drawArrows(int x, int y) { + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + + if (selectionOffset > 0) { + boolean highLighted = GuiHelper.isInRect(4, 4, 13, 15, x, y); + if (highLighted) drawTexturedModalRect(posX + 4, posY + 4, 0, 158, 13, 15); + else drawTexturedModalRect(posX + 4, posY + 4, 0, 143, 13, 15); + } else drawTexturedModalRect(posX + 4, posY + 4, 0, 173, 13, 15); + if (selectionOffset < maxOffset) { + boolean highLighted = GuiHelper.isInRect(4, 122, 13, 15, x, y); + if (highLighted) drawTexturedModalRect(posX + 4, posY + 122, 13, 158, 13, 15); + else drawTexturedModalRect(posX + 4, posY + 122, 13, 143, 13, 15); + } else drawTexturedModalRect(posX + 4, posY + 122, 13, 173, 13, 15); + + float percent = locations.size() <= 12 ? 1f : 12F / (float) locations.size(); + int drawSize = (int) (percent * 99F); + int space = 99 - drawSize; + float location = (float) selectionOffset / (float) (locations.size() - 12); + int yOffset = (int) (location * (float) space); + drawTexturedModalRect(posX + 5, posY + 21 + yOffset, 182, 0, 11, drawSize); + drawTexturedModalRect(posX + 5, posY + 21 + drawSize - 1 + yOffset, 182, 98, 11, 1); + } + + private void drawSelectionInfo() { + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + if (locations.size() <= 0) return; + fontRendererObj.drawString(EnumChatFormatting.GOLD + "X: " + (int) getLocationSafely(selected + selectionOffset).getXCoord(), posX + 114, posY + 7, 0x000000); + fontRendererObj.drawString(EnumChatFormatting.GOLD + "Y: " + (int) getLocationSafely(selected + selectionOffset).getYCoord(), posX + 114, posY + 16, 0x000000); + fontRendererObj.drawString(EnumChatFormatting.GOLD + "Z: " + (int) getLocationSafely(selected + selectionOffset).getZCoord(), posX + 114, posY + 25, 0x000000); + fontRendererObj.drawString(EnumChatFormatting.GOLD + "" + getLocationSafely(selected + selectionOffset).getDimensionName(), posX + 114, posY + 34, 0x000000); + } + + @Override + protected void mouseClicked(int x, int y, int button) { + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + + boolean offsetChanged = false; + boolean selectionChanged = false; + + if (textBeingEdited.getVisible()) textBeingEdited.mouseClicked(x, y, button); + + //Check for arrow click + if (selectionOffset > 0 && GuiHelper.isInRect(3, 5, 13, 15, x - posX, y - posY)) { + selectionOffset--; + offsetChanged = true; + if (selected < 11) { + selected++; + selectionChanged = true; + } + } + if (selectionOffset < maxOffset && GuiHelper.isInRect(3, 123, 13, 15, x - posX, y - posY)) { + selectionOffset++; + offsetChanged = true; + if (selected > 0) { + selected--; + selectionChanged = true; + } + } + + //Check for location or lock clicked + for (int i = 0; i < Math.min(12, locations.size()); i++) { + if (GuiHelper.isInRect(17, 6 + i * 11, 80, 10, x - posX, y - posY)) { + if (!(getLocationSafely(i + selectionOffset).getWriteProtected() && editingExisting) && button == 0) { + selected = i; + selectionChanged = true; + } + if (!(getLocationSafely(i + selectionOffset).getWriteProtected() && editingExisting) && button == 1) { + if (locations.isEmpty()) return; + + if (!player.capabilities.isCreativeMode && fuel <= 0) { + player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfFuel.txt")); + } + + if (player.capabilities.isCreativeMode || fuel > 0) { + if (!player.capabilities.isCreativeMode) fuel--; + DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.TELEPORT, i + selectionOffset, false)); + } + } + } + + if (GuiHelper.isInRect(99, 8 + i * 11, 8, 7, x - posX, y - posY)) { + getLocationSafely(i + selectionOffset).setWriteProtected(!getLocationSafely(i + selectionOffset).getWriteProtected()); + DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.UPDATELOCK, i + selectionOffset, getLocationSafely(i + selectionOffset).getWriteProtected())); + } + } + + + if (selectionChanged) + DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.CHANGESELECTION, selected, false)); + if (offsetChanged) + DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.UPDATEOFFSET, selectionOffset, false)); + + updateButtons(); + super.mouseClicked(x, y, button); + } + + @Override + 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_); + } + + @Override + public void handleMouseInput() { + int i = org.lwjgl.input.Mouse.getEventDWheel(); + boolean offsetChanged = false; + boolean selectionChanged = false; + if (i < 0 && selectionOffset < maxOffset) { + selectionOffset++; + offsetChanged = true; + if (selected > 0) { + selected--; + selectionChanged = true; + } + updateButtons(); + } + if (i > 0 && selectionOffset > 0) { + selectionOffset--; + offsetChanged = true; + if (selected < 11) { + selected++; + selectionChanged = true; + } + updateButtons(); + } + + if (selectionChanged) + DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.CHANGESELECTION, selected, false)); + if (offsetChanged) + DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.UPDATEOFFSET, selectionOffset, false)); + + super.handleMouseInput(); + } + + private void updateButtons() { + if (locations.size() > 12) maxOffset = locations.size() - 12; + else maxOffset = 0; + if (selectionOffset > maxOffset) selectionOffset = maxOffset; + if (selected > locations.size() || selected < 0) selected = Math.max(locations.size() - 1, 0); + if ((selected + selectionOffset) + 1 > locations.size()) { + selected = 0; + selectionOffset = 0; + DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.CHANGESELECTION, selected, false)); + DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.UPDATEOFFSET, selectionOffset, false)); + } + if (locations.size() == 0 || getLocationSafely(selected + selectionOffset).getWriteProtected()) { + ((GuiButton) buttonList.get(0)).enabled = false; + ((GuiButton) buttonList.get(1)).enabled = false; + ((GuiButton) buttonList.get(2)).enabled = false; + } else { + ((GuiButton) buttonList.get(0)).enabled = true; + ((GuiButton) buttonList.get(1)).enabled = true; + ((GuiButton) buttonList.get(2)).enabled = true; + } + if (editingNew) { + ((GuiButton) buttonList.get(4)).enabled = !textBeingEdited.getText().isEmpty(); + ((GuiButton) buttonList.get(4)).displayString = StatCollector.translateToLocal("button.de.commit.txt"); + } + if (editingExisting) { + ((GuiButton) buttonList.get(0)).enabled = !textBeingEdited.getText().isEmpty(); + ((GuiButton) buttonList.get(0)).displayString = StatCollector.translateToLocal("button.de.commit.txt"); + } + if (locations.size() >= 100) ((GuiButton) buttonList.get(4)).enabled = false; + else if (!editingNew) ((GuiButton) buttonList.get(4)).enabled = true; + } + + @SuppressWarnings("unchecked") + @Override + public void initGui() { + buttonList.clear(); + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + + //updateTeleporter(); + + buttonList.add(new GuiButtonAHeight(0, posX + 112, posY + 45, 66, 12, StatCollector.translateToLocal("button.de.rename.txt"))); + buttonList.add(new GuiButtonAHeight(1, posX + 112, posY + 58, 66, 12, StatCollector.translateToLocal("button.de.setHere.txt"))); + buttonList.add(new GuiButtonAHeight(2, posX + 112, posY + 71, 66, 12, StatCollector.translateToLocal("button.de.remove.txt"))); + + buttonList.add(new GuiButtonAHeight(3, posX + 112, posY + 99, 33, 12, StatCollector.translateToLocal("button.de.UP.txt"))); + + buttonList.add(new GuiButtonAHeight(4, posX + 112, posY + 112, 66, 12, StatCollector.translateToLocal("button.de.addNew.txt"))); + buttonList.add(new GuiButtonAHeight(5, posX + 112, posY + 125, 66, 12, StatCollector.translateToLocal("button.de.addFuel.txt"))); + buttonList.add(new GuiButtonAHeight(6, posX + xSize - 63, posY - 15, 60, 15, StatCollector.translateToLocal("button.de.cancel.txt"))); + + buttonList.add(new GuiButtonAHeight(7, posX + 112 + 34, posY + 99, 33, 12, StatCollector.translateToLocal("button.de.DOWN.txt"))); + ((GuiButton) buttonList.get(6)).visible = false; + + textBeingEdited = new GuiTextField(fontRendererObj, posX + 3, posY - 14, xSize - 67, 12); + textBeingEdited.setTextColor(-1); + textBeingEdited.setDisabledTextColour(-1); + textBeingEdited.setEnableBackgroundDrawing(true); + textBeingEdited.setMaxStringLength(40); + textBeingEdited.setVisible(false); + + updateButtons(); + } + + @Override + protected void actionPerformed(GuiButton button) { + if (button.id == 0 || button.id == 6 && !editingNew) { + if (button.id == 6) { + editingExisting = false; + ((GuiButton) buttonList.get(0)).displayString = StatCollector.translateToLocal("button.de.rename.txt"); + ((GuiButton) buttonList.get(6)).visible = false; + textBeingEdited.setVisible(false); + ((GuiButton) buttonList.get(0)).enabled = true; + return; + } + if (!editingExisting) { + editingExisting = true; + textBeingEdited.setVisible(true); + textBeingEdited.setText(getLocationSafely(selected + selectionOffset).getName()); + textBeingEdited.setSelectionPos(0); + textBeingEdited.setFocused(true); + ((GuiButton) buttonList.get(6)).visible = true; + } else { + if (!textBeingEdited.getText().isEmpty()) { + getLocationSafely(selected + selectionOffset).setName(textBeingEdited.getText()); + TeleportLocation location = new TeleportLocation(); + location.setName(textBeingEdited.getText()); + DraconicEvolution.network.sendToServer(new TeleporterPacket(location, TeleporterPacket.UPDATENAME, selected + selectionOffset)); + ((GuiButton) buttonList.get(0)).displayString = StatCollector.translateToLocal("button.de.rename.txt"); + editingExisting = false; + textBeingEdited.setVisible(false); + ((GuiButton) buttonList.get(6)).visible = false; + } + } + } + + if (button.id == 1) { + TeleportLocation location = new TeleportLocation(player.posX, player.posY - 1.62, player.posZ, player.dimension, player.rotationPitch, player.rotationYaw, getLocationSafely(selected + selectionOffset).getName()); + DraconicEvolution.network.sendToServer(new TeleporterPacket(location, TeleporterPacket.UPDATEDESTINATION, selected + selectionOffset)); + locations.set(selected + selectionOffset, location); + } + + if (button.id == 2) { + DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.REMOVEDESTINATION, selected + selectionOffset, false)); + locations.remove(selected + selectionOffset); + if (selectionOffset > 0) selectionOffset--; + if (selected >= locations.size()) selected--; + } + + if (button.id == 3 || button.id == 7) { + if (button.id == 3) { + if (selected > 0) { + TeleportLocation temp = getLocationSafely(selected + selectionOffset); + locations.set(selected + selectionOffset, getLocationSafely(selected + selectionOffset - 1)); + locations.set(selected + selectionOffset - 1, temp); + selected--; + } + } else { + if (selected < Math.min(11, locations.size() - 1)) { + TeleportLocation temp = getLocationSafely(selected + selectionOffset); + locations.set(selected + selectionOffset, getLocationSafely(selected + selectionOffset + 1)); + locations.set(selected + selectionOffset + 1, temp); + selected++; + } + } + + DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.MOVELOCATION, selected + selectionOffset, button.id == 3)); + } + + if (button.id == 4 || button.id == 6 && !editingExisting) { + if (button.id == 6) { + editingNew = false; + ((GuiButton) buttonList.get(4)).displayString = StatCollector.translateToLocal("button.de.addNew.txt"); + ((GuiButton) buttonList.get(6)).visible = false; + ((GuiButton) buttonList.get(4)).enabled = true; + textBeingEdited.setVisible(false); + return; + } + if (!editingNew) { + editingNew = true; + textBeingEdited.setVisible(true); + textBeingEdited.setText("" + (int) player.posX + " " + (int) player.posY + " " + (int) player.posZ); + textBeingEdited.setSelectionPos(0); + textBeingEdited.setFocused(true); + ((GuiButton) buttonList.get(6)).visible = true; + } else { + if (!textBeingEdited.getText().isEmpty()) { + addCurrentLocationToList(textBeingEdited.getText()); + ((GuiButton) buttonList.get(4)).displayString = StatCollector.translateToLocal("button.de.addNew.txt"); + editingNew = false; + textBeingEdited.setVisible(false); + ((GuiButton) buttonList.get(6)).visible = false; + } + } + } + + if (button.id == 5) { + if (player.inventory.hasItem(Items.ender_pearl)) { + if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) { + DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.ADDFUEL, 1, false)); + this.fuel += ConfigHandler.teleporterUsesPerPearl; + } else if (hasPearls(16)) { + DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.ADDFUEL, 16, false)); + this.fuel += ConfigHandler.teleporterUsesPerPearl * 16; + } else player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfPearls.txt")); + } else player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfPearls.txt")); + } + updateButtons(); + } + + public boolean hasPearls(int number) { + int found = 0; + ItemStack stack; + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { + stack = player.inventory.getStackInSlot(i); + if (stack != null && stack.isItemEqual(new ItemStack(Items.ender_pearl))) found += stack.stackSize; + + if (found >= number) return true; + } + return false; + } + + @Override + public void keyTyped(char key, int keyN) { + if (this.textBeingEdited.textboxKeyTyped(key, keyN)) { + if (editingNew) { + ((GuiButton) buttonList.get(4)).enabled = !textBeingEdited.getText().isEmpty(); + ((GuiButton) buttonList.get(4)).displayString = StatCollector.translateToLocal("button.de.commit.txt"); + } + if (editingExisting) { + ((GuiButton) buttonList.get(0)).enabled = !textBeingEdited.getText().isEmpty(); + ((GuiButton) buttonList.get(0)).displayString = StatCollector.translateToLocal("button.de.commit.txt"); + } + return; + } + + if (keyN == 28 && editingNew) actionPerformed((GuiButton) buttonList.get(4)); + if (keyN == 28 && editingExisting) actionPerformed((GuiButton) buttonList.get(0)); + + if ((key == 'e' && (!editingExisting || !editingNew)) || key == '') { + this.mc.displayGuiScreen(null); + this.mc.setIngameFocus(); + } + } + + @Override + public void updateScreen() { + if (player.getCurrentEquippedItem() == null || !player.getCurrentEquippedItem().isItemEqual(new ItemStack(ModItems.teleporterMKII)) || player.isDead) { + this.mc.displayGuiScreen(null); + this.mc.setIngameFocus(); + } + + if (tick % 5 == 0 && locations.size() > 0 && getLocationSafely(selected + selectionOffset).getDimensionName().equals("") && player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.teleporterMKII) + readDataFromItem(player.getHeldItem()); + + tick++; + if (tick >= 10) { + tick = 0; + showFuelLight = !showFuelLight; + } + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } + + private void readDataFromItem(ItemStack teleporter) { + this.selected = ItemNBTHelper.getShort(teleporter, "Selection", (short) 0); + this.selectionOffset = ItemNBTHelper.getInteger(teleporter, "SelectionOffset", 0); + this.fuel = ItemNBTHelper.getInteger(teleporter, "Fuel", 0); + + locations.clear(); + + NBTTagCompound compound = teleporter.getTagCompound(); + if (compound == null || compound.getTagList("Locations", 0) == null) return; + NBTTagList list = (NBTTagList) compound.getTag("Locations"); + if (list == null) list = new NBTTagList(); + + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound tagLocation = list.getCompoundTagAt(i); + //TeleportLocation location = new TeleportLocation(tagLocation.getDouble("X"), tagLocation.getDouble("Y"), tagLocation.getDouble("Z"), tagLocation.getInteger("Dimension"), tagLocation.getFloat("Pitch"), tagLocation.getFloat("Yaw"), tagLocation.getString("Name")); + TeleportLocation location = new TeleportLocation(); + location.readFromNBT(tagLocation); + location.setWriteProtected(tagLocation.getBoolean("WP")); + locations.add(location); + } + } + + private void addCurrentLocationToList(String name) { + TeleportLocation currentLocation = new TeleportLocation(player.posX, player.posY - 1.62, player.posZ, player.dimension, player.rotationPitch, player.rotationYaw, name); + DraconicEvolution.network.sendToServer(new TeleporterPacket(currentLocation, TeleporterPacket.ADDDESTINATION)); + locations.add(currentLocation); + } + + private TeleportLocation getLocationSafely(int index) { + if (index < locations.size() && index >= 0) return locations.get(index); + return new TeleportLocation(0, 0, 0, 0, 0, 0, EnumChatFormatting.DARK_RED + "[Index Error]"); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIUpgradeModifier.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIUpgradeModifier.java index 4a56f1c6..54bf6c84 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIUpgradeModifier.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIUpgradeModifier.java @@ -26,282 +26,276 @@ import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GUIUpgradeModifier extends GuiContainer { - public EntityPlayer player; - private TileUpgradeModifier tile; + public EntityPlayer player; + private TileUpgradeModifier tile; - public boolean inUse = false; - private IUpgradableItem upgradableItem = null; - private ItemStack stack = null; - private List itemUpgrades = new ArrayList(); - private ContainerUpgradeModifier containerEM; + public boolean inUse = false; + private IUpgradableItem upgradableItem = null; + private ItemStack stack = null; + private List itemUpgrades = new ArrayList(); + private ContainerUpgradeModifier containerEM; - public GUIUpgradeModifier(InventoryPlayer invPlayer, TileUpgradeModifier tile, ContainerUpgradeModifier containerEM) { - super(containerEM); - this.containerEM = containerEM; + public GUIUpgradeModifier(InventoryPlayer invPlayer, TileUpgradeModifier tile, ContainerUpgradeModifier containerEM) { + super(containerEM); + this.containerEM = containerEM; - xSize = 176; - ySize = 190; + xSize = 176; + ySize = 190; - this.tile = tile; - this.player = invPlayer.player; - } + this.tile = tile; + this.player = invPlayer.player; + } - @Override - protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { - GL11.glColor4f(1F, 1F, 1F, 1F); - ResourceHandler.bindResource("textures/gui/UpgradeModifier.png"); + @Override + protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { + GL11.glColor4f(1F, 1F, 1F, 1F); + ResourceHandler.bindResource("textures/gui/UpgradeModifier.png"); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - drawTexturedModalRect(guiLeft + 70, guiTop + 6, 60, 106, 100, 50); - drawTexturedModalRect(guiLeft + 70, guiTop + 56, 60, 106, 100, 50); + drawTexturedModalRect(guiLeft + 70, guiTop + 6, 60, 106, 100, 50); + drawTexturedModalRect(guiLeft + 70, guiTop + 56, 60, 106, 100, 50); - GL11.glPushMatrix(); - GL11.glTranslated(guiLeft + 70, guiTop + 6, 0); - GL11.glTranslatef(50, 50, 0); - GL11.glRotatef(tile.rotation + (f * tile.rotationSpeed), 0, 0, 1); - GL11.glTranslatef(-50, -50, 0); - drawTexturedModalRect(0, 0, 70, 6, 100, 100); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslated(guiLeft + 70, guiTop + 6, 0); + GL11.glTranslatef(50, 50, 0); + GL11.glRotatef(tile.rotation + (f * tile.rotationSpeed), 0, 0, 1); + GL11.glTranslatef(-50, -50, 0); + drawTexturedModalRect(0, 0, 70, 6, 100, 100); + GL11.glPopMatrix(); - if (!inUse){ - drawTexturedModalRect(guiLeft + 3, guiTop + 77, 60, 106, 56, 55); - drawTexturedModalRect(guiLeft + 3, guiTop + 132, 60, 106, 56, 55); - }else - { - drawFlippedTexturedModalRect(guiLeft + 59, guiTop + 77, 3, 77, 56, 110); - drawTexturedModalRect(guiLeft + 115, guiTop + 77, 3, 77, 56, 110); - drawFlippedTexturedModalRect(guiLeft + 171, guiTop + 77, 57, 77, 2, 110); - } + if (!inUse) { + drawTexturedModalRect(guiLeft + 3, guiTop + 77, 60, 106, 56, 55); + drawTexturedModalRect(guiLeft + 3, guiTop + 132, 60, 106, 56, 55); + } else { + drawFlippedTexturedModalRect(guiLeft + 59, guiTop + 77, 3, 77, 56, 110); + drawTexturedModalRect(guiLeft + 115, guiTop + 77, 3, 77, 56, 110); + drawFlippedTexturedModalRect(guiLeft + 171, guiTop + 77, 57, 77, 2, 110); + } - if (!inUse)drawSlots(); - else renderUpgrades(x, y); + if (!inUse) drawSlots(); + else renderUpgrades(x, y); - if (inUse) drawHoveringText(upgradableItem.getUpgradeStats(stack), guiLeft+xSize-9, guiTop+17, fontRendererObj); - } + if (inUse) + drawHoveringText(upgradableItem.getUpgradeStats(stack), guiLeft + xSize - 9, guiTop + 17, fontRendererObj); + } - @Override - protected void drawGuiContainerForegroundLayer(int x, int y) { - drawCenteredString(fontRendererObj, tile.getBlockType().getLocalizedName(), xSize/2, -9, 0x00FFFF); - } + @Override + protected void drawGuiContainerForegroundLayer(int x, int y) { + drawCenteredString(fontRendererObj, tile.getBlockType().getLocalizedName(), xSize / 2, -9, 0x00FFFF); + } - @Override - public void initGui() { - super.initGui(); + @Override + public void initGui() { + super.initGui(); - } + } - @Override - protected void actionPerformed(GuiButton button) { + @Override + protected void actionPerformed(GuiButton button) { - } + } - private int coreSlots = 0; - private int coreTier = 0; - private int usedSlots = 0; - private boolean[] coreInInventory = new boolean[4]; + private int coreSlots = 0; + private int coreTier = 0; + private int usedSlots = 0; + private boolean[] coreInInventory = new boolean[4]; - @Override - public void updateScreen() { - super.updateScreen(); - if (tile.getStackInSlot(0) != null && tile.getStackInSlot(0).getItem() instanceof IUpgradableItem) - { - stack = tile.getStackInSlot(0); - upgradableItem = (IUpgradableItem) stack.getItem(); - itemUpgrades = upgradableItem.getUpgrades(stack); - inUse = true; - coreSlots = upgradableItem.getUpgradeCap(stack); - coreTier = upgradableItem.getMaxTier(stack); - usedSlots = 0; - coreInInventory[0] = player.inventory.hasItem(ModItems.draconicCore); - coreInInventory[1] = player.inventory.hasItem(ModItems.wyvernCore); - coreInInventory[2] = player.inventory.hasItem(ModItems.awakenedCore); - coreInInventory[3] = player.inventory.hasItem(ModItems.chaoticCore); + @Override + public void updateScreen() { + super.updateScreen(); + if (tile.getStackInSlot(0) != null && tile.getStackInSlot(0).getItem() instanceof IUpgradableItem) { + stack = tile.getStackInSlot(0); + upgradableItem = (IUpgradableItem) stack.getItem(); + itemUpgrades = upgradableItem.getUpgrades(stack); + inUse = true; + coreSlots = upgradableItem.getUpgradeCap(stack); + coreTier = upgradableItem.getMaxTier(stack); + usedSlots = 0; + coreInInventory[0] = player.inventory.hasItem(ModItems.draconicCore); + coreInInventory[1] = player.inventory.hasItem(ModItems.wyvernCore); + coreInInventory[2] = player.inventory.hasItem(ModItems.awakenedCore); + coreInInventory[3] = player.inventory.hasItem(ModItems.chaoticCore); - for (EnumUpgrade upgrade : upgradableItem.getUpgrades(stack)) { - for (Integer i : upgrade.getCoresApplied(stack)) usedSlots += i; - } + for (EnumUpgrade upgrade : upgradableItem.getUpgrades(stack)) { + for (Integer i : upgrade.getCoresApplied(stack)) usedSlots += i; + } - } - else inUse = false; - } + } else inUse = false; + } - private void drawSlots() { - ResourceHandler.bindResource("textures/gui/Widgets.png"); + private void drawSlots() { + ResourceHandler.bindResource("textures/gui/Widgets.png"); - int xPos = guiLeft + ((xSize - 162) / 2); - int yPos = guiTop + 110; + int xPos = guiLeft + ((xSize - 162) / 2); + int yPos = guiTop + 110; - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 9; x++) { - drawTexturedModalRect(xPos + x*18, yPos + y*18, 138, 0, 18, 18); - } - } + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + drawTexturedModalRect(xPos + x * 18, yPos + y * 18, 138, 0, 18, 18); + } + } - for (int x = 0; x < 9; x++) { - drawTexturedModalRect(xPos + x*18, yPos + 56, 138, 0, 18, 18); - } + for (int x = 0; x < 9; x++) { + drawTexturedModalRect(xPos + x * 18, yPos + 56, 138, 0, 18, 18); + } - drawTexturedModalRect(guiLeft + 111, guiTop + 47, 138, 0, 18, 18); - } + drawTexturedModalRect(guiLeft + 111, guiTop + 47, 138, 0, 18, 18); + } - @Override - protected void mouseClicked(int x, int y, int button) { - super.mouseClicked(x, y, button); + @Override + protected void mouseClicked(int x, int y, int button) { + super.mouseClicked(x, y, button); - for (EnumUpgrade upgrade : itemUpgrades) - { - int xIndex = itemUpgrades.indexOf(upgrade); - int spacing = (xSize-6) / itemUpgrades.size(); - int xPos = guiLeft + (xIndex * spacing) + ((spacing - 23) / 2) + 4; - int yPos = guiTop + 90; + for (EnumUpgrade upgrade : itemUpgrades) { + int xIndex = itemUpgrades.indexOf(upgrade); + int spacing = (xSize - 6) / itemUpgrades.size(); + int xPos = guiLeft + (xIndex * spacing) + ((spacing - 23) / 2) + 4; + int yPos = guiTop + 90; - int[] appliedCores = upgrade.getCoresApplied(tile.getStackInSlot(0)); + int[] appliedCores = upgrade.getCoresApplied(tile.getStackInSlot(0)); - for (int i = 0; i <= coreTier; i++) - { - //Check + buttons - if (coreInInventory[i] && coreSlots > usedSlots && GuiHelper.isInRect(xPos, yPos+33 + i*18, 8, 8, x, y) && upgrade.getUpgradePoints(stack) < upgradableItem.getMaxUpgradePoints(upgrade.index, stack)){ - containerEM.sendObjectToServer(null, upgrade.index, i*2); - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(ResourceHandler.getResourceWOP("gui.button.press"), 1.0F)); - } + for (int i = 0; i <= coreTier; i++) { + //Check + buttons + if (coreInInventory[i] && coreSlots > usedSlots && GuiHelper.isInRect(xPos, yPos + 33 + i * 18, 8, 8, x, y) && upgrade.getUpgradePoints(stack) < upgradableItem.getMaxUpgradePoints(upgrade.index, stack)) { + containerEM.sendObjectToServer(null, upgrade.index, i * 2); + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(ResourceHandler.getResourceWOP("gui.button.press"), 1.0F)); + } - //Check - buttons - if (appliedCores[i] > 0 && GuiHelper.isInRect(xPos + 16, yPos+33 + i*18, 8, 8, x, y)){ - containerEM.sendObjectToServer(null, upgrade.index, 1 + i*2); - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(ResourceHandler.getResourceWOP("gui.button.press"), 1.0F)); - } - } - } + //Check - buttons + if (appliedCores[i] > 0 && GuiHelper.isInRect(xPos + 16, yPos + 33 + i * 18, 8, 8, x, y)) { + containerEM.sendObjectToServer(null, upgrade.index, 1 + i * 2); + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(ResourceHandler.getResourceWOP("gui.button.press"), 1.0F)); + } + } + } - } + } - private void renderUpgrades(int x, int y){ - //First Draw - for (EnumUpgrade upgrade : itemUpgrades) - { - int xIndex = itemUpgrades.indexOf(upgrade); - int spacing = (xSize-6) / itemUpgrades.size(); - int xPos = guiLeft + (xIndex * spacing) + ((spacing - 23) / 2) + 4; - int yPos = guiTop + 90; + private void renderUpgrades(int x, int y) { + //First Draw + for (EnumUpgrade upgrade : itemUpgrades) { + int xIndex = itemUpgrades.indexOf(upgrade); + int spacing = (xSize - 6) / itemUpgrades.size(); + int xPos = guiLeft + (xIndex * spacing) + ((spacing - 23) / 2) + 4; + int yPos = guiTop + 90; - ResourceHandler.bindResource("textures/gui/UpgradeModifier.png"); + ResourceHandler.bindResource("textures/gui/UpgradeModifier.png"); - drawTexturedModalRect(xPos, yPos, 0, 190, 24, 24); - drawTexturedModalRect(xPos+3, yPos+3, upgrade.index * 18, 220, 18, 18); - drawTexturedModalRect(xPos+2, yPos-10, 126, 190, 20, 11); + drawTexturedModalRect(xPos, yPos, 0, 190, 24, 24); + drawTexturedModalRect(xPos + 3, yPos + 3, upgrade.index * 18, 220, 18, 18); + drawTexturedModalRect(xPos + 2, yPos - 10, 126, 190, 20, 11); - int[] appliedCores = upgrade.getCoresApplied(tile.getStackInSlot(0)); + int[] appliedCores = upgrade.getCoresApplied(tile.getStackInSlot(0)); - for (int i = 0; i <= coreTier; i++) { - drawTexturedModalRect(xPos+3, yPos+24 + i*18, 24 + i*18, 190, 18, 18); - drawTexturedModalRect(xPos+3, yPos+24 + i*18, 24 + i*18, 190, 18, 18); + for (int i = 0; i <= coreTier; i++) { + drawTexturedModalRect(xPos + 3, yPos + 24 + i * 18, 24 + i * 18, 190, 18, 18); + drawTexturedModalRect(xPos + 3, yPos + 24 + i * 18, 24 + i * 18, 190, 18, 18); - GL11.glEnable(GL11.GL_BLEND); - GL11.glColor4f(0F, 0F, 0F, 0.9F); - if (appliedCores[i] < 10) drawTexturedModalRect(xPos + 8, yPos + 28 + i * 18, 3, 3, 7, 9); - else drawTexturedModalRect(xPos + 5, yPos + 28 + i * 18, 3, 3, 13, 9); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(0F, 0F, 0F, 0.9F); + if (appliedCores[i] < 10) drawTexturedModalRect(xPos + 8, yPos + 28 + i * 18, 3, 3, 7, 9); + else drawTexturedModalRect(xPos + 5, yPos + 28 + i * 18, 3, 3, 13, 9); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glDisable(GL11.GL_BLEND); - //Draw + buttons - if (coreSlots > usedSlots && upgrade.getUpgradePoints(stack) < upgradableItem.getMaxUpgradePoints(upgrade.index, stack)){ - boolean hovering = GuiHelper.isInRect(xPos, yPos+33 + i*18, 8, 8, x, y); - if (!coreInInventory[i]) drawTexturedModalRect(xPos, yPos+33 + i*18, 24, 208, 8, 8); - else drawTexturedModalRect(xPos, yPos+33 + i*18, 32 + (hovering ? 8 : 0), 208, 8, 8); - } + //Draw + buttons + if (coreSlots > usedSlots && upgrade.getUpgradePoints(stack) < upgradableItem.getMaxUpgradePoints(upgrade.index, stack)) { + boolean hovering = GuiHelper.isInRect(xPos, yPos + 33 + i * 18, 8, 8, x, y); + if (!coreInInventory[i]) drawTexturedModalRect(xPos, yPos + 33 + i * 18, 24, 208, 8, 8); + else drawTexturedModalRect(xPos, yPos + 33 + i * 18, 32 + (hovering ? 8 : 0), 208, 8, 8); + } - //Draw - buttons - if (appliedCores[i] > 0){ - boolean hovering = GuiHelper.isInRect(xPos + 16, yPos+33 + i*18, 8, 8, x, y); - drawTexturedModalRect(xPos + 16, yPos+33 + i*18, 56 + (hovering ? 8 : 0), 208, 8, 8); - } + //Draw - buttons + if (appliedCores[i] > 0) { + boolean hovering = GuiHelper.isInRect(xPos + 16, yPos + 33 + i * 18, 8, 8, x, y); + drawTexturedModalRect(xPos + 16, yPos + 33 + i * 18, 56 + (hovering ? 8 : 0), 208, 8, 8); + } - } - for (int i = 0; i <= coreTier; i++) fontRendererObj.drawString(String.valueOf(appliedCores[i]), xPos + 12 - fontRendererObj.getStringWidth(String.valueOf(appliedCores[i]))/2, yPos + 29 + i * 18, 0xFFFFFF); - fontRendererObj.drawString(String.valueOf(upgrade.getUpgradePoints(stack)), xPos + 12 - fontRendererObj.getStringWidth(String.valueOf(upgrade.getUpgradePoints(stack)))/2, yPos - 8, 0xFFFFFF); - } + } + for (int i = 0; i <= coreTier; i++) + fontRendererObj.drawString(String.valueOf(appliedCores[i]), xPos + 12 - fontRendererObj.getStringWidth(String.valueOf(appliedCores[i])) / 2, yPos + 29 + i * 18, 0xFFFFFF); + fontRendererObj.drawString(String.valueOf(upgrade.getUpgradePoints(stack)), xPos + 12 - fontRendererObj.getStringWidth(String.valueOf(upgrade.getUpgradePoints(stack))) / 2, yPos - 8, 0xFFFFFF); + } - fontRendererObj.drawStringWithShadow(StatCollector.translateToLocal("gui.de.cores.txt"), guiLeft + 4, guiTop + 4, 0x00ff00); - fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.cap.txt"), guiLeft + 4, guiTop + 16, 0x000000); - fontRendererObj.drawString(">"+coreSlots, guiLeft + 4, guiTop + 25, 0x000000); - fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.installed.txt"), guiLeft + 4, guiTop + 37, 0x000000); - fontRendererObj.drawString(">"+usedSlots, guiLeft + 4, guiTop + 46, 0x000000); - fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.free.txt"), guiLeft + 4, guiTop + 58, 0x000000); - fontRendererObj.drawString(">"+(coreSlots-usedSlots), guiLeft + 4, guiTop + 67, 0x000000); - } + fontRendererObj.drawStringWithShadow(StatCollector.translateToLocal("gui.de.cores.txt"), guiLeft + 4, guiTop + 4, 0x00ff00); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.cap.txt"), guiLeft + 4, guiTop + 16, 0x000000); + fontRendererObj.drawString(">" + coreSlots, guiLeft + 4, guiTop + 25, 0x000000); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.installed.txt"), guiLeft + 4, guiTop + 37, 0x000000); + fontRendererObj.drawString(">" + usedSlots, guiLeft + 4, guiTop + 46, 0x000000); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.free.txt"), guiLeft + 4, guiTop + 58, 0x000000); + fontRendererObj.drawString(">" + (coreSlots - usedSlots), guiLeft + 4, guiTop + 67, 0x000000); + } - @SuppressWarnings("unchecked") - @Override - public void drawScreen(int x, int y, float f) { - super.drawScreen(x, y, f); + @SuppressWarnings("unchecked") + @Override + public void drawScreen(int x, int y, float f) { + super.drawScreen(x, y, f); - if (!inUse) return; - //Second Draw - for (EnumUpgrade upgrade : itemUpgrades) - { - int xIndex = itemUpgrades.indexOf(upgrade); - int spacing = (xSize-6) / itemUpgrades.size(); - int xPos = guiLeft + (xIndex * spacing) + ((spacing - 23) / 2) + 4; - int yPos = guiTop + 90; - int[] appliedCores = upgrade.getCoresApplied(tile.getStackInSlot(0)); + if (!inUse) return; + //Second Draw + for (EnumUpgrade upgrade : itemUpgrades) { + int xIndex = itemUpgrades.indexOf(upgrade); + int spacing = (xSize - 6) / itemUpgrades.size(); + int xPos = guiLeft + (xIndex * spacing) + ((spacing - 23) / 2) + 4; + int yPos = guiTop + 90; + int[] appliedCores = upgrade.getCoresApplied(tile.getStackInSlot(0)); - if (GuiHelper.isInRect(xPos, yPos, 24, 24, x, y)){ - List list = new ArrayList(); - list.add(upgrade.getLocalizedName()); - drawHoveringText(list, x, y, fontRendererObj); - } + if (GuiHelper.isInRect(xPos, yPos, 24, 24, x, y)) { + List list = new ArrayList(); + list.add(upgrade.getLocalizedName()); + drawHoveringText(list, x, y, fontRendererObj); + } - if (GuiHelper.isInRect(xPos+3, yPos-9, 18, 8, x, y)){ - List list = new ArrayList(); - list.add(StatCollector.translateToLocal("gui.de.basePoints.txt")+": "+upgradableItem.getBaseUpgradePoints(upgrade.index)); - list.add(StatCollector.translateToLocal("gui.de.maxPoints.txt")+": "+upgradableItem.getMaxUpgradePoints(upgrade.index, stack)); - list.add(StatCollector.translateToLocal("gui.de.pointCost.txt")+": "+upgrade.pointConversion); - drawHoveringText(list, x, y, fontRendererObj); - } + if (GuiHelper.isInRect(xPos + 3, yPos - 9, 18, 8, x, y)) { + List list = new ArrayList(); + list.add(StatCollector.translateToLocal("gui.de.basePoints.txt") + ": " + upgradableItem.getBaseUpgradePoints(upgrade.index)); + list.add(StatCollector.translateToLocal("gui.de.maxPoints.txt") + ": " + upgradableItem.getMaxUpgradePoints(upgrade.index, stack)); + list.add(StatCollector.translateToLocal("gui.de.pointCost.txt") + ": " + upgrade.pointConversion); + drawHoveringText(list, x, y, fontRendererObj); + } - for (int i = 0; i <= coreTier; i++) { - if (GuiHelper.isInRect(xPos+9, yPos+25 + i*18, 6, 15, x, y)){ - List list = new ArrayList(); - double value = Math.pow(2, i) / upgrade.pointConversion; - String string = StatCollector.translateToLocal("gui.de.value.txt")+": "+value+" "+ (value == 1 ? StatCollector.translateToLocal("gui.de.point.txt") : StatCollector.translateToLocal("gui.de.points.txt")); - list.add(string.replace(".0", "")); - drawHoveringText(list, x, y, fontRendererObj); - } + for (int i = 0; i <= coreTier; i++) { + if (GuiHelper.isInRect(xPos + 9, yPos + 25 + i * 18, 6, 15, x, y)) { + List list = new ArrayList(); + double value = Math.pow(2, i) / upgrade.pointConversion; + String string = StatCollector.translateToLocal("gui.de.value.txt") + ": " + value + " " + (value == 1 ? StatCollector.translateToLocal("gui.de.point.txt") : StatCollector.translateToLocal("gui.de.points.txt")); + list.add(string.replace(".0", "")); + drawHoveringText(list, x, y, fontRendererObj); + } - //Draw Button Text (add) - if (coreSlots > usedSlots && GuiHelper.isInRect(xPos, yPos+33 + i*18, 8, 8, x, y)) { - List list = new ArrayList(); - if (coreInInventory[i]) list.add(StatCollector.translateToLocal("gui.de.addCore.txt")); - else list.add(StatCollector.translateToLocal("gui.de.noCoresInInventory" + i + ".txt")); - drawHoveringText(list, x, y, fontRendererObj); - } + //Draw Button Text (add) + if (coreSlots > usedSlots && GuiHelper.isInRect(xPos, yPos + 33 + i * 18, 8, 8, x, y)) { + List list = new ArrayList(); + if (coreInInventory[i]) list.add(StatCollector.translateToLocal("gui.de.addCore.txt")); + else list.add(StatCollector.translateToLocal("gui.de.noCoresInInventory" + i + ".txt")); + drawHoveringText(list, x, y, fontRendererObj); + } - //Draw Button Text (remove) - if (appliedCores[i] > 0 && GuiHelper.isInRect(xPos + 16, yPos+33 + i*18, 8, 8, x, y)) { - List list = new ArrayList(); - if (coreInInventory[i]) list.add(StatCollector.translateToLocal("gui.de.removeCore.txt")); - drawHoveringText(list, x, y, fontRendererObj); - } - } - } + //Draw Button Text (remove) + if (appliedCores[i] > 0 && GuiHelper.isInRect(xPos + 16, yPos + 33 + i * 18, 8, 8, x, y)) { + List list = new ArrayList(); + if (coreInInventory[i]) list.add(StatCollector.translateToLocal("gui.de.removeCore.txt")); + drawHoveringText(list, x, y, fontRendererObj); + } + } + } - } + } - public void drawFlippedTexturedModalRect(int xPos, int yPos, int texXPos, int texYPos, int xSize, int ySize) - { - float f = 0.00390625F; - float f1 = 0.00390625F; - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.addVertexWithUV((double)(xPos) , (double)(yPos + ySize), (double)this.zLevel, (double)((float)(texXPos + xSize) * f) , (double)((float)(texYPos + ySize) * f1)); - tessellator.addVertexWithUV((double)(xPos + xSize) , (double)(yPos + ySize), (double)this.zLevel, (double)((float)(texXPos) * f) , (double)((float)(texYPos + ySize) * f1)); - tessellator.addVertexWithUV((double)(xPos + xSize) , (double)(yPos) , (double)this.zLevel, (double)((float)(texXPos) * f) , (double)((float)(texYPos) * f1)); - tessellator.addVertexWithUV((double)(xPos) , (double)(yPos) , (double)this.zLevel, (double)((float)(texXPos + xSize) * f) , (double)((float)(texYPos) * f1)); - tessellator.draw(); - } + public void drawFlippedTexturedModalRect(int xPos, int yPos, int texXPos, int texYPos, int xSize, int ySize) { + float f = 0.00390625F; + float f1 = 0.00390625F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double) (xPos), (double) (yPos + ySize), (double) this.zLevel, (double) ((float) (texXPos + xSize) * f), (double) ((float) (texYPos + ySize) * f1)); + tessellator.addVertexWithUV((double) (xPos + xSize), (double) (yPos + ySize), (double) this.zLevel, (double) ((float) (texXPos) * f), (double) ((float) (texYPos + ySize) * f1)); + tessellator.addVertexWithUV((double) (xPos + xSize), (double) (yPos), (double) this.zLevel, (double) ((float) (texXPos) * f), (double) ((float) (texYPos) * f1)); + tessellator.addVertexWithUV((double) (xPos), (double) (yPos), (double) this.zLevel, (double) ((float) (texXPos + xSize) * f), (double) ((float) (texYPos) * f1)); + tessellator.draw(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIWeatherController.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIWeatherController.java index b8f60222..c367acec 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIWeatherController.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GUIWeatherController.java @@ -20,93 +20,80 @@ import com.brandon3055.draconicevolution.common.tileentities.TileWeatherControll @SideOnly(Side.CLIENT) public class GUIWeatherController extends GuiContainer { - public EntityPlayer player; - private TileWeatherController tileWC; - private int charges; - private int guiUpdateTick; - - public GUIWeatherController(InventoryPlayer invPlayer, TileWeatherController tileWC) { - super(new ContainerWeatherController(invPlayer, tileWC)); + public EntityPlayer player; + private TileWeatherController tileWC; + private int charges; + private int guiUpdateTick; - xSize = 176; - ySize = 143; - - this.tileWC = tileWC; - this.charges = tileWC.charges; - this.player = invPlayer.player; - } + public GUIWeatherController(InventoryPlayer invPlayer, TileWeatherController tileWC) { + super(new ContainerWeatherController(invPlayer, tileWC)); - private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/WeatherController.png"); + xSize = 176; + ySize = 143; - @Override - protected void drawGuiContainerBackgroundLayer(float f, int x, int y) - { - GL11.glColor4f(1, 1, 1, 1); + this.tileWC = tileWC; + this.charges = tileWC.charges; + this.player = invPlayer.player; + } + + private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/WeatherController.png"); + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { + GL11.glColor4f(1, 1, 1, 1); + + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + + if (charges > 0) drawTexturedModalRect(guiLeft + 37, guiTop + 4, 0, 143, 37, 38); + } + + @Override + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { + fontRendererObj.drawString("Charges: " + charges, 90, 25, 0x000000); + //drawCenteredString(fontRendererObj, "Charges: " + charges, 117, 25, 0x000000); + drawCenteredString(fontRendererObj, "Weather Controller", xSize / 2, -15, 0x2a4ed0); + + } + + public static final String RAIN_ON_TEXT = "Turn rain on"; + public static final String RAIN_OFF_TEXT = "Turn rain off"; + public static final String STORM_TEXT = "Thunder Storm"; + public static String text; + + @SuppressWarnings("unchecked") + @Override + public void initGui() { + super.initGui(); + buttonList.clear(); + if (tileWC.mode == 0) text = RAIN_OFF_TEXT; + else if (tileWC.mode == 1) text = RAIN_ON_TEXT; + else text = STORM_TEXT; + //ID + buttonList.add(new GuiButton(0, guiLeft + 85, guiTop, 85, 20, text)); + } + + @Override + protected void actionPerformed(GuiButton button) { + if (button.id == 0) { + DraconicEvolution.network.sendToServer(new ButtonPacket((byte) 0, true)); + if (button.displayString.equals(STORM_TEXT)) button.displayString = RAIN_OFF_TEXT; + else if (button.displayString.equals(RAIN_OFF_TEXT)) button.displayString = RAIN_ON_TEXT; + else button.displayString = STORM_TEXT; + } + + } + + @Override + public void updateScreen() { + guiUpdateTick++; + if (guiUpdateTick >= 10) { + initGui(); + guiUpdateTick = 0; + } + super.updateScreen(); + this.charges = tileWC.charges; + } - Minecraft.getMinecraft().getTextureManager().bindTexture(texture); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - - if(charges > 0) - drawTexturedModalRect(guiLeft + 37, guiTop + 4, 0, 143, 37, 38); - } - - @Override - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) - { - fontRendererObj.drawString("Charges: " + charges, 90, 25, 0x000000); - //drawCenteredString(fontRendererObj, "Charges: " + charges, 117, 25, 0x000000); - drawCenteredString(fontRendererObj, "Weather Controller", xSize/2, -15, 0x2a4ed0); - - } - - public static final String RAIN_ON_TEXT = "Turn rain on"; - public static final String RAIN_OFF_TEXT = "Turn rain off"; - public static final String STORM_TEXT = "Thunder Storm"; - public static String text; - - @SuppressWarnings("unchecked") - @Override - public void initGui() - { - super.initGui(); - buttonList.clear(); - if (tileWC.mode == 0) - text = RAIN_OFF_TEXT; - else if (tileWC.mode == 1) - text = RAIN_ON_TEXT; - else - text = STORM_TEXT; - //ID - buttonList.add(new GuiButton(0, guiLeft + 85, guiTop , 85, 20, text)); - } - - @Override - protected void actionPerformed(GuiButton button) - { - if (button.id == 0){ - DraconicEvolution.network.sendToServer(new ButtonPacket((byte) 0, true)); - if (button.displayString.equals(STORM_TEXT)) - button.displayString = RAIN_OFF_TEXT; - else if (button.displayString.equals(RAIN_OFF_TEXT)) - button.displayString = RAIN_ON_TEXT; - else - button.displayString = STORM_TEXT; - } - - } - - @Override - public void updateScreen() - { - guiUpdateTick++; - if (guiUpdateTick >= 10){ - initGui(); - guiUpdateTick = 0; - } - super.updateScreen(); - this.charges = tileWC.charges; - } - - } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiButtonAHeight.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiButtonAHeight.java index 1832e5af..8b30754e 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiButtonAHeight.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiButtonAHeight.java @@ -9,47 +9,41 @@ import org.lwjgl.opengl.GL11; /** * Created by Brandon on 17/09/2014. */ -public class GuiButtonAHeight extends GuiButton{ +public class GuiButtonAHeight extends GuiButton { - public GuiButtonAHeight(int id, int xPos, int yPos, int width, int hight, String displayString) { - super(id, xPos, yPos, width, hight, displayString); - } + public GuiButtonAHeight(int id, int xPos, int yPos, int width, int hight, String displayString) { + super(id, xPos, yPos, width, hight, displayString); + } - @Override - public void drawButton(Minecraft minecraft, int mouseX, int mouseY) { - if (this.visible) - { - FontRenderer fontrenderer = minecraft.fontRenderer; - minecraft.getTextureManager().bindTexture(buttonTextures); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; - int k = this.getHoverState(this.field_146123_n); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, width % 2 + this.width / 2, this.height); - this.drawTexturedModalRect(width % 2 + this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height); - if (this.height < 20){ + @Override + public void drawButton(Minecraft minecraft, int mouseX, int mouseY) { + if (this.visible) { + FontRenderer fontrenderer = minecraft.fontRenderer; + minecraft.getTextureManager().bindTexture(buttonTextures); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; + int k = this.getHoverState(this.field_146123_n); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, width % 2 + this.width / 2, this.height); + this.drawTexturedModalRect(width % 2 + this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height); + if (this.height < 20) { - this.drawTexturedModalRect(xPosition, yPosition+3, 0, (46 + k * 20)+20-height+3, width % 2 + width / 2, height-3); - this.drawTexturedModalRect(width % 2 + xPosition + width / 2, yPosition+3, 200 - width / 2, (46 + k * 20)+20-height+3, width / 2, height-3); - } - this.mouseDragged(minecraft, mouseX, mouseY); - int l = 14737632; + this.drawTexturedModalRect(xPosition, yPosition + 3, 0, (46 + k * 20) + 20 - height + 3, width % 2 + width / 2, height - 3); + this.drawTexturedModalRect(width % 2 + xPosition + width / 2, yPosition + 3, 200 - width / 2, (46 + k * 20) + 20 - height + 3, width / 2, height - 3); + } + this.mouseDragged(minecraft, mouseX, mouseY); + int l = 14737632; - if (packedFGColour != 0) - { - l = packedFGColour; - } - else if (!this.enabled) - { - l = 10526880; - } - else if (this.field_146123_n) - { - l = 16777120; - } - this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l); - } - } + if (packedFGColour != 0) { + l = packedFGColour; + } else if (!this.enabled) { + l = 10526880; + } else if (this.field_146123_n) { + l = 16777120; + } + this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiButtonTextOnly.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiButtonTextOnly.java index 2876d779..961f2cc0 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiButtonTextOnly.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiButtonTextOnly.java @@ -10,55 +10,55 @@ import org.lwjgl.opengl.GL11; /** * Created by Brandon on 17/09/2014. */ -public class GuiButtonTextOnly extends GuiButton{ - public String LINKED_PAGE; - public int textColour; +public class GuiButtonTextOnly extends GuiButton { + public String LINKED_PAGE; + public int textColour; - public GuiButtonTextOnly(int id, int xPos, int yPos, int width, int hight, String displayString, String linkedPage, int colour) { - super(id, xPos, yPos, width, hight, displayString); - this.LINKED_PAGE = linkedPage; - this.textColour = colour; - } + public GuiButtonTextOnly(int id, int xPos, int yPos, int width, int hight, String displayString, String linkedPage, int colour) { + super(id, xPos, yPos, width, hight, displayString); + this.LINKED_PAGE = linkedPage; + this.textColour = colour; + } - @Override - public void drawButton(Minecraft minecraft, int mouseX, int mouseY) { - if (this.visible) - { - FontRenderer fontrenderer = minecraft.fontRenderer; - minecraft.getTextureManager().bindTexture(buttonTextures); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + @Override + public void drawButton(Minecraft minecraft, int mouseX, int mouseY) { + if (this.visible) { + FontRenderer fontrenderer = minecraft.fontRenderer; + minecraft.getTextureManager().bindTexture(buttonTextures); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - this.mouseDragged(minecraft, mouseX, mouseY); + this.mouseDragged(minecraft, mouseX, mouseY); - String trimmedDisplayString = displayString; - if (fontrenderer.getStringWidth(displayString) > width+30 && !this.field_146123_n){ - int energencyBreak = 0; - while (fontrenderer.getStringWidth(trimmedDisplayString)*0.7 > width-5){ - trimmedDisplayString = trimmedDisplayString.substring(0, trimmedDisplayString.length()-1); - energencyBreak++; - if (energencyBreak > 100) break; - } - trimmedDisplayString+="..."; - } + String trimmedDisplayString = displayString; + if (fontrenderer.getStringWidth(displayString) > width + 30 && !this.field_146123_n) { + int energencyBreak = 0; + while (fontrenderer.getStringWidth(trimmedDisplayString) * 0.7 > width - 5) { + trimmedDisplayString = trimmedDisplayString.substring(0, trimmedDisplayString.length() - 1); + energencyBreak++; + if (energencyBreak > 100) break; + } + trimmedDisplayString += "..."; + } - if (this.field_146123_n) - { - trimmedDisplayString = EnumChatFormatting.BOLD+""+EnumChatFormatting.ITALIC+trimmedDisplayString; - GL11.glPushMatrix(); - GL11.glColor4f(0f, 0f, 0f, 1f); - drawTexturedModalRect(xPosition+(int)(xPosition*0.01), yPosition+(int)(yPosition*0.01), 0, 46, (int)(fontrenderer.getStringWidth(trimmedDisplayString)*0.72)+2, 8); - GL11.glPopMatrix(); - } - GL11.glPushMatrix(); - GL11.glScalef(0.7F, 0.7F, 1); - fontrenderer.drawString(trimmedDisplayString, (int)(xPosition*1.45), (int)((yPosition + (height - 8) / 2)*1.45), textColour); - GL11.glPopMatrix(); - } - } + if (this.field_146123_n) { + trimmedDisplayString = EnumChatFormatting.BOLD + "" + EnumChatFormatting.ITALIC + trimmedDisplayString; + GL11.glPushMatrix(); + GL11.glColor4f(0f, 0f, 0f, 1f); + drawTexturedModalRect(xPosition + (int) (xPosition * 0.01), yPosition + (int) (yPosition * 0.01), 0, 46, (int) (fontrenderer.getStringWidth(trimmedDisplayString) * 0.72) + 2, 8); + GL11.glPopMatrix(); + } + GL11.glPushMatrix(); + GL11.glScalef(0.7F, 0.7F, 1); + fontrenderer.drawString(trimmedDisplayString, (int) (xPosition * 1.45), (int) ((yPosition + (height - 8) / 2) * 1.45), textColour); + GL11.glPopMatrix(); + } + } - public boolean getIsHovering(){return field_146123_n;} + public boolean getIsHovering() { + return field_146123_n; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiHandler.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiHandler.java index 8a87f074..154f9b59 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiHandler.java @@ -17,92 +17,92 @@ import net.minecraft.world.World; public class GuiHandler implements IGuiHandler { - public static final int GUIID_WEATHER_CONTROLLER = 0; - public static final int GUIID_SUN_DIAL = 1; - public static final int GUIID_GRINDER = 2; - public static final int GUIID_TELEPORTER = 3; - public static final int GUIID_PARTICLEGEN = 5; - public static final int GUIID_PLAYERDETECTOR = 6; - public static final int GUIID_ENERGY_INFUSER = 7; - public static final int GUIID_GENERATOR = 8; - public static final int GUIID_MANUAL = 9; - public static final int GUIID_DISSENCHANTER = 10; - public static final int GUIID_DRACONIC_CHEST = 11; - public static final int GUIID_TOOL_CONFIG = 12; - public static final int GUIID_FLOW_GATE = 13; - public static final int GUIID_REACTOR = 14; - public static final int GUIID_UPGRADE_MODIFIER = 15; - public static final int GUIID_CONTAINER_TEMPLATE = 100; + public static final int GUIID_WEATHER_CONTROLLER = 0; + public static final int GUIID_SUN_DIAL = 1; + public static final int GUIID_GRINDER = 2; + public static final int GUIID_TELEPORTER = 3; + public static final int GUIID_PARTICLEGEN = 5; + public static final int GUIID_PLAYERDETECTOR = 6; + public static final int GUIID_ENERGY_INFUSER = 7; + public static final int GUIID_GENERATOR = 8; + public static final int GUIID_MANUAL = 9; + public static final int GUIID_DISSENCHANTER = 10; + public static final int GUIID_DRACONIC_CHEST = 11; + public static final int GUIID_TOOL_CONFIG = 12; + public static final int GUIID_FLOW_GATE = 13; + public static final int GUIID_REACTOR = 14; + public static final int GUIID_UPGRADE_MODIFIER = 15; + public static final int GUIID_CONTAINER_TEMPLATE = 100; - public GuiHandler() { - NetworkRegistry.INSTANCE.registerGuiHandler(DraconicEvolution.instance, this); - } + public GuiHandler() { + NetworkRegistry.INSTANCE.registerGuiHandler(DraconicEvolution.instance, this); + } - @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - switch (ID) { - case GUIID_WEATHER_CONTROLLER: - TileEntity te = world.getTileEntity(x, y, z); - if (te != null && te instanceof TileWeatherController) { - return new ContainerWeatherController(player.inventory, (TileWeatherController) te); - } - break; - case GUIID_SUN_DIAL: - TileEntity te1 = world.getTileEntity(x, y, z); - if (te1 != null && te1 instanceof TileSunDial) { - return new ContainerSunDial(player.inventory, (TileSunDial) te1); - } - break; - case GUIID_GRINDER: - TileEntity te2 = world.getTileEntity(x, y, z); - if (te2 != null && te2 instanceof TileGrinder) { - return new ContainerGrinder(player.inventory, (TileGrinder) te2); - } - break; - case GUIID_PLAYERDETECTOR: - TileEntity detector = world.getTileEntity(x, y, z); - if (detector != null && detector instanceof TilePlayerDetectorAdvanced) { - return new ContainerPlayerDetector(player.inventory, (TilePlayerDetectorAdvanced) detector); - } - break; - case GUIID_ENERGY_INFUSER: - TileEntity infuser = world.getTileEntity(x, y, z); - if (infuser != null && infuser instanceof TileEnergyInfuser) { - return new ContainerEnergyInfuser(player.inventory, (TileEnergyInfuser) infuser); - } - break; - case GUIID_GENERATOR: - TileEntity generator = world.getTileEntity(x, y, z); - if (generator != null && generator instanceof TileGenerator) { - return new ContainerGenerator(player.inventory, (TileGenerator) generator); - } - break; - case GUIID_DISSENCHANTER: - TileEntity dissenchanter = world.getTileEntity(x, y, z); - if (dissenchanter != null && dissenchanter instanceof TileDissEnchanter) { - return new ContainerDissEnchanter(player.inventory, (TileDissEnchanter) dissenchanter); - } - break; - case GUIID_DRACONIC_CHEST: - TileEntity containerChest = world.getTileEntity(x, y, z); - if (containerChest != null && containerChest instanceof TileDraconiumChest) { - return new ContainerDraconiumChest(player.inventory, (TileDraconiumChest) containerChest); - } - break; - case GUIID_REACTOR: - TileEntity reactor = world.getTileEntity(x, y, z); - if (reactor != null && reactor instanceof TileReactorCore) { - return new ContainerReactor(player, (TileReactorCore) reactor); - } - break; - case GUIID_TOOL_CONFIG: - return new ContainerAdvTool(player.inventory, new InventoryTool(player, null)); - case GUIID_UPGRADE_MODIFIER: - TileEntity containerTemp = world.getTileEntity(x, y, z); - if (containerTemp != null && containerTemp instanceof TileUpgradeModifier) { - return new ContainerUpgradeModifier(player.inventory, (TileUpgradeModifier) containerTemp); - } - break; + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + switch (ID) { + case GUIID_WEATHER_CONTROLLER: + TileEntity te = world.getTileEntity(x, y, z); + if (te != null && te instanceof TileWeatherController) { + return new ContainerWeatherController(player.inventory, (TileWeatherController) te); + } + break; + case GUIID_SUN_DIAL: + TileEntity te1 = world.getTileEntity(x, y, z); + if (te1 != null && te1 instanceof TileSunDial) { + return new ContainerSunDial(player.inventory, (TileSunDial) te1); + } + break; + case GUIID_GRINDER: + TileEntity te2 = world.getTileEntity(x, y, z); + if (te2 != null && te2 instanceof TileGrinder) { + return new ContainerGrinder(player.inventory, (TileGrinder) te2); + } + break; + case GUIID_PLAYERDETECTOR: + TileEntity detector = world.getTileEntity(x, y, z); + if (detector != null && detector instanceof TilePlayerDetectorAdvanced) { + return new ContainerPlayerDetector(player.inventory, (TilePlayerDetectorAdvanced) detector); + } + break; + case GUIID_ENERGY_INFUSER: + TileEntity infuser = world.getTileEntity(x, y, z); + if (infuser != null && infuser instanceof TileEnergyInfuser) { + return new ContainerEnergyInfuser(player.inventory, (TileEnergyInfuser) infuser); + } + break; + case GUIID_GENERATOR: + TileEntity generator = world.getTileEntity(x, y, z); + if (generator != null && generator instanceof TileGenerator) { + return new ContainerGenerator(player.inventory, (TileGenerator) generator); + } + break; + case GUIID_DISSENCHANTER: + TileEntity dissenchanter = world.getTileEntity(x, y, z); + if (dissenchanter != null && dissenchanter instanceof TileDissEnchanter) { + return new ContainerDissEnchanter(player.inventory, (TileDissEnchanter) dissenchanter); + } + break; + case GUIID_DRACONIC_CHEST: + TileEntity containerChest = world.getTileEntity(x, y, z); + if (containerChest != null && containerChest instanceof TileDraconiumChest) { + return new ContainerDraconiumChest(player.inventory, (TileDraconiumChest) containerChest); + } + break; + case GUIID_REACTOR: + TileEntity reactor = world.getTileEntity(x, y, z); + if (reactor != null && reactor instanceof TileReactorCore) { + return new ContainerReactor(player, (TileReactorCore) reactor); + } + break; + case GUIID_TOOL_CONFIG: + return new ContainerAdvTool(player.inventory, new InventoryTool(player, null)); + case GUIID_UPGRADE_MODIFIER: + TileEntity containerTemp = world.getTileEntity(x, y, z); + if (containerTemp != null && containerTemp instanceof TileUpgradeModifier) { + return new ContainerUpgradeModifier(player.inventory, (TileUpgradeModifier) containerTemp); + } + break; // case GUIID_CONTAINER_TEMPLATE: @@ -111,85 +111,85 @@ public class GuiHandler implements IGuiHandler { // return new ContainerTemplate(player.inventory, (TileContainerTemplate) containerTemp); // } // break; - } + } - return null; - } + return null; + } - @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - switch (ID) { - case GUIID_WEATHER_CONTROLLER: - TileEntity te = world.getTileEntity(x, y, z); - if (te != null && te instanceof TileWeatherController) { - return new GUIWeatherController(player.inventory, (TileWeatherController) te); - } - break; - case GUIID_SUN_DIAL: - TileEntity te1 = world.getTileEntity(x, y, z); - if (te1 != null && te1 instanceof TileSunDial) { - return new GUISunDial(player.inventory, (TileSunDial) te1); - } - break; - case GUIID_TELEPORTER: - return new GUITeleporter(player); - case GUIID_GRINDER: - TileEntity te2 = world.getTileEntity(x, y, z); - if (te2 != null && te2 instanceof TileGrinder) { - return new GUIGrinder(player.inventory, (TileGrinder) te2); - } - break; - case GUIID_PARTICLEGEN: - TileEntity gen = world.getTileEntity(x, y, z); - return (gen != null && gen instanceof TileParticleGenerator) ? new GUIParticleGenerator((TileParticleGenerator) gen, player) : null; - case GUIID_PLAYERDETECTOR: - TileEntity detector = world.getTileEntity(x, y, z); - if (detector != null && detector instanceof TilePlayerDetectorAdvanced) { - return new GUIPlayerDetector(player.inventory, (TilePlayerDetectorAdvanced) detector); - } - break; - case GUIID_ENERGY_INFUSER: - TileEntity infuser = world.getTileEntity(x, y, z); - if (infuser != null && infuser instanceof TileEnergyInfuser) { - return new GUIEnergyInfuser(player.inventory, (TileEnergyInfuser) infuser); - } - break; - case GUIID_GENERATOR: - TileEntity generator = world.getTileEntity(x, y, z); - if (generator != null && generator instanceof TileGenerator) { - return new GUIGenerator(player.inventory, (TileGenerator) generator); - } - break; - case GUIID_MANUAL: - return new GUIManual(); - case GUIID_DISSENCHANTER: - TileEntity dissenchanter = world.getTileEntity(x, y, z); - if (dissenchanter != null && dissenchanter instanceof TileDissEnchanter) { - return new GUIDissEnchanter(player.inventory, (TileDissEnchanter) dissenchanter); - } - break; - case GUIID_DRACONIC_CHEST: - TileEntity containerChest = world.getTileEntity(x, y, z); - if (containerChest != null && containerChest instanceof TileDraconiumChest) { - return new GUIDraconiumChest(player.inventory, (TileDraconiumChest) containerChest); - } - break; - case GUIID_REACTOR: - TileEntity reactor = world.getTileEntity(x, y, z); - if (reactor != null && reactor instanceof TileReactorCore) { - return new GUIReactor(player, (TileReactorCore) reactor, new ContainerReactor(player, (TileReactorCore) reactor)); - } - break; - case GUIID_TOOL_CONFIG: - return new GUIToolConfig(player, new ContainerAdvTool(player.inventory, new InventoryTool(player, null))); - case GUIID_FLOW_GATE: - return world.getTileEntity(x, y, z) instanceof TileGate ? new GUIFlowGate((TileGate)world.getTileEntity(x, y, z)) : null; - case GUIID_UPGRADE_MODIFIER: - TileEntity containerTemp = world.getTileEntity(x, y, z); - if (containerTemp != null && containerTemp instanceof TileUpgradeModifier) { - return new GUIUpgradeModifier(player.inventory, (TileUpgradeModifier) containerTemp, new ContainerUpgradeModifier(player.inventory, (TileUpgradeModifier) containerTemp)); - } - break; + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + switch (ID) { + case GUIID_WEATHER_CONTROLLER: + TileEntity te = world.getTileEntity(x, y, z); + if (te != null && te instanceof TileWeatherController) { + return new GUIWeatherController(player.inventory, (TileWeatherController) te); + } + break; + case GUIID_SUN_DIAL: + TileEntity te1 = world.getTileEntity(x, y, z); + if (te1 != null && te1 instanceof TileSunDial) { + return new GUISunDial(player.inventory, (TileSunDial) te1); + } + break; + case GUIID_TELEPORTER: + return new GUITeleporter(player); + case GUIID_GRINDER: + TileEntity te2 = world.getTileEntity(x, y, z); + if (te2 != null && te2 instanceof TileGrinder) { + return new GUIGrinder(player.inventory, (TileGrinder) te2); + } + break; + case GUIID_PARTICLEGEN: + TileEntity gen = world.getTileEntity(x, y, z); + return (gen != null && gen instanceof TileParticleGenerator) ? new GUIParticleGenerator((TileParticleGenerator) gen, player) : null; + case GUIID_PLAYERDETECTOR: + TileEntity detector = world.getTileEntity(x, y, z); + if (detector != null && detector instanceof TilePlayerDetectorAdvanced) { + return new GUIPlayerDetector(player.inventory, (TilePlayerDetectorAdvanced) detector); + } + break; + case GUIID_ENERGY_INFUSER: + TileEntity infuser = world.getTileEntity(x, y, z); + if (infuser != null && infuser instanceof TileEnergyInfuser) { + return new GUIEnergyInfuser(player.inventory, (TileEnergyInfuser) infuser); + } + break; + case GUIID_GENERATOR: + TileEntity generator = world.getTileEntity(x, y, z); + if (generator != null && generator instanceof TileGenerator) { + return new GUIGenerator(player.inventory, (TileGenerator) generator); + } + break; + case GUIID_MANUAL: + return new GUIManual(); + case GUIID_DISSENCHANTER: + TileEntity dissenchanter = world.getTileEntity(x, y, z); + if (dissenchanter != null && dissenchanter instanceof TileDissEnchanter) { + return new GUIDissEnchanter(player.inventory, (TileDissEnchanter) dissenchanter); + } + break; + case GUIID_DRACONIC_CHEST: + TileEntity containerChest = world.getTileEntity(x, y, z); + if (containerChest != null && containerChest instanceof TileDraconiumChest) { + return new GUIDraconiumChest(player.inventory, (TileDraconiumChest) containerChest); + } + break; + case GUIID_REACTOR: + TileEntity reactor = world.getTileEntity(x, y, z); + if (reactor != null && reactor instanceof TileReactorCore) { + return new GUIReactor(player, (TileReactorCore) reactor, new ContainerReactor(player, (TileReactorCore) reactor)); + } + break; + case GUIID_TOOL_CONFIG: + return new GUIToolConfig(player, new ContainerAdvTool(player.inventory, new InventoryTool(player, null))); + case GUIID_FLOW_GATE: + return world.getTileEntity(x, y, z) instanceof TileGate ? new GUIFlowGate((TileGate) world.getTileEntity(x, y, z)) : null; + case GUIID_UPGRADE_MODIFIER: + TileEntity containerTemp = world.getTileEntity(x, y, z); + if (containerTemp != null && containerTemp instanceof TileUpgradeModifier) { + return new GUIUpgradeModifier(player.inventory, (TileUpgradeModifier) containerTemp, new ContainerUpgradeModifier(player.inventory, (TileUpgradeModifier) containerTemp)); + } + break; // case GUIID_CONTAINER_TEMPLATE: // TileEntity containerTemp = world.getTileEntity(x, y, z); @@ -197,9 +197,9 @@ public class GuiHandler implements IGuiHandler { // return new GUIContainerTemplate(player.inventory, (TileContainerTemplate) containerTemp); // } // break; - } + } - return null; - } + return null; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiHudConfig.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiHudConfig.java index 4edfc1c4..0a25a680 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiHudConfig.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiHudConfig.java @@ -17,204 +17,194 @@ import java.util.ArrayList; * Created by brandon3055 on 11/2/2016. */ public class GuiHudConfig extends GuiScreen { - private GUIBase parent; - private GuiButton buttonHudFade; - private GuiButton buttonArmorFade; - private GuiButton buttonArmorNumeric; - private boolean draggingArmor = false; - private boolean draggingHud = false; - private int dragOffsetX = 0; - private int dragOffsetY = 0; + private GUIBase parent; + private GuiButton buttonHudFade; + private GuiButton buttonArmorFade; + private GuiButton buttonArmorNumeric; + private boolean draggingArmor = false; + private boolean draggingHud = false; + private int dragOffsetX = 0; + private int dragOffsetY = 0; - public GuiHudConfig(GUIBase parent){ - this.parent = parent; - } + public GuiHudConfig(GUIBase parent) { + this.parent = parent; + } - @SuppressWarnings("unchecked") - @Override - public void initGui() { - super.initGui(); - buttonList.clear(); + @SuppressWarnings("unchecked") + @Override + public void initGui() { + super.initGui(); + buttonList.clear(); - int x = width/2; - int y = height/2 - 30; + int x = width / 2; + int y = height / 2 - 30; - buttonList.add(new GuiButtonAHeight(0, x-35, y+95, 70, 15, StatCollector.translateToLocal("gui.back"))); + buttonList.add(new GuiButtonAHeight(0, x - 35, y + 95, 70, 15, StatCollector.translateToLocal("gui.back"))); - buttonList.add(new GuiButtonAHeight(1, x+2, y-37, 80, 15, StatCollector.translateToLocal("button.de.scaleUp.txt"))); - buttonList.add(new GuiButtonAHeight(2, x-81, y-37, 80, 15, StatCollector.translateToLocal("button.de.scaleDown.txt"))); - buttonList.add(buttonHudFade = new GuiButtonAHeight(3, x-81, y-20, 163, 15, "")); - buttonList.add(new GuiButtonAHeight(9, x-81, y-3, 163, 15, StatCollector.translateToLocal("button.de.toggleHidden.txt"))); + buttonList.add(new GuiButtonAHeight(1, x + 2, y - 37, 80, 15, StatCollector.translateToLocal("button.de.scaleUp.txt"))); + buttonList.add(new GuiButtonAHeight(2, x - 81, y - 37, 80, 15, StatCollector.translateToLocal("button.de.scaleDown.txt"))); + buttonList.add(buttonHudFade = new GuiButtonAHeight(3, x - 81, y - 20, 163, 15, "")); + buttonList.add(new GuiButtonAHeight(9, x - 81, y - 3, 163, 15, StatCollector.translateToLocal("button.de.toggleHidden.txt"))); - buttonList.add(new GuiButtonAHeight(4, x+2, y+25, 80, 15, StatCollector.translateToLocal("button.de.scaleUp.txt"))); - buttonList.add(new GuiButtonAHeight(5, x-81, y+25, 80, 15, StatCollector.translateToLocal("button.de.scaleDown.txt"))); - buttonList.add(buttonArmorFade = new GuiButtonAHeight(6, x-81, y+42, 163, 15, "")); - buttonList.add(buttonArmorNumeric = new GuiButtonAHeight(7, x+2, y+59, 80, 15, "")); - buttonList.add(new GuiButtonAHeight(8, x-81, y+59, 80, 15, StatCollector.translateToLocal("button.de.rotate.txt"))); - buttonList.add(new GuiButtonAHeight(10, x-81, y+76, 163, 15, StatCollector.translateToLocal("button.de.toggleHidden.txt"))); - } + buttonList.add(new GuiButtonAHeight(4, x + 2, y + 25, 80, 15, StatCollector.translateToLocal("button.de.scaleUp.txt"))); + buttonList.add(new GuiButtonAHeight(5, x - 81, y + 25, 80, 15, StatCollector.translateToLocal("button.de.scaleDown.txt"))); + buttonList.add(buttonArmorFade = new GuiButtonAHeight(6, x - 81, y + 42, 163, 15, "")); + buttonList.add(buttonArmorNumeric = new GuiButtonAHeight(7, x + 2, y + 59, 80, 15, "")); + buttonList.add(new GuiButtonAHeight(8, x - 81, y + 59, 80, 15, StatCollector.translateToLocal("button.de.rotate.txt"))); + buttonList.add(new GuiButtonAHeight(10, x - 81, y + 76, 163, 15, StatCollector.translateToLocal("button.de.toggleHidden.txt"))); + } - @Override - public void updateScreen() { - buttonHudFade.displayString = StatCollector.translateToLocal("button.de.fadeMode"+ ConfigHandler.hudSettings[6]+".txt"); - buttonArmorFade.displayString = StatCollector.translateToLocal("button.de.fadeMode"+ ConfigHandler.hudSettings[7]+".txt"); - buttonArmorNumeric.displayString = StatCollector.translateToLocal("button.de.numeric.txt")+" "+(ConfigHandler.hudSettings[9] == 0 ? StatCollector.translateToLocal("gui.de.off.txt") : StatCollector.translateToLocal("gui.de.on.txt")); - } + @Override + public void updateScreen() { + buttonHudFade.displayString = StatCollector.translateToLocal("button.de.fadeMode" + ConfigHandler.hudSettings[6] + ".txt"); + buttonArmorFade.displayString = StatCollector.translateToLocal("button.de.fadeMode" + ConfigHandler.hudSettings[7] + ".txt"); + buttonArmorNumeric.displayString = StatCollector.translateToLocal("button.de.numeric.txt") + " " + (ConfigHandler.hudSettings[9] == 0 ? StatCollector.translateToLocal("gui.de.off.txt") : StatCollector.translateToLocal("gui.de.on.txt")); + } - @Override - protected void actionPerformed(GuiButton button) { - if (button.id == 0) { - Minecraft.getMinecraft().displayGuiScreen(parent); - return; - } - else if (button.id == 1 && ConfigHandler.hudSettings[4] < 300){ - ConfigHandler.hudSettings[4] += 10; - } - else if (button.id == 2 && ConfigHandler.hudSettings[4] > 30){ - ConfigHandler.hudSettings[4] -= 10; - } - else if (button.id == 3){ - if (ConfigHandler.hudSettings[6] < 4) ConfigHandler.hudSettings[6]++; - else ConfigHandler.hudSettings[6] = 0; - } - else if (button.id == 4 && ConfigHandler.hudSettings[5] < 300){ - ConfigHandler.hudSettings[5] += 10; - } - else if (button.id == 5 && ConfigHandler.hudSettings[5] > 30){ - ConfigHandler.hudSettings[5] -= 10; - } - else if (button.id == 6){ - if (ConfigHandler.hudSettings[7] < 4) ConfigHandler.hudSettings[7]++; - else ConfigHandler.hudSettings[7] = 0; - } - else if (button.id == 7){ - if (ConfigHandler.hudSettings[9] == 0) ConfigHandler.hudSettings[9] = 1; - else ConfigHandler.hudSettings[9] = 0; - } - else if (button.id == 8){ - if (ConfigHandler.hudSettings[8] == 0) ConfigHandler.hudSettings[8] = 1; - else ConfigHandler.hudSettings[8] = 0; - } - else if (button.id == 9){ - if (ConfigHandler.hudSettings[10] == 0) ConfigHandler.hudSettings[10] = 1; - else ConfigHandler.hudSettings[10] = 0; - } - else if (button.id == 10){ - if (ConfigHandler.hudSettings[11] == 0) ConfigHandler.hudSettings[11] = 1; - else ConfigHandler.hudSettings[11] = 0; - } + @Override + protected void actionPerformed(GuiButton button) { + if (button.id == 0) { + Minecraft.getMinecraft().displayGuiScreen(parent); + return; + } else if (button.id == 1 && ConfigHandler.hudSettings[4] < 300) { + ConfigHandler.hudSettings[4] += 10; + } else if (button.id == 2 && ConfigHandler.hudSettings[4] > 30) { + ConfigHandler.hudSettings[4] -= 10; + } else if (button.id == 3) { + if (ConfigHandler.hudSettings[6] < 4) ConfigHandler.hudSettings[6]++; + else ConfigHandler.hudSettings[6] = 0; + } else if (button.id == 4 && ConfigHandler.hudSettings[5] < 300) { + ConfigHandler.hudSettings[5] += 10; + } else if (button.id == 5 && ConfigHandler.hudSettings[5] > 30) { + ConfigHandler.hudSettings[5] -= 10; + } else if (button.id == 6) { + if (ConfigHandler.hudSettings[7] < 4) ConfigHandler.hudSettings[7]++; + else ConfigHandler.hudSettings[7] = 0; + } else if (button.id == 7) { + if (ConfigHandler.hudSettings[9] == 0) ConfigHandler.hudSettings[9] = 1; + else ConfigHandler.hudSettings[9] = 0; + } else if (button.id == 8) { + if (ConfigHandler.hudSettings[8] == 0) ConfigHandler.hudSettings[8] = 1; + else ConfigHandler.hudSettings[8] = 0; + } else if (button.id == 9) { + if (ConfigHandler.hudSettings[10] == 0) ConfigHandler.hudSettings[10] = 1; + else ConfigHandler.hudSettings[10] = 0; + } else if (button.id == 10) { + if (ConfigHandler.hudSettings[11] == 0) ConfigHandler.hudSettings[11] = 1; + else ConfigHandler.hudSettings[11] = 0; + } - ConfigHandler.config.get("Gui Stuff", "HUD Settings", new int[]{7, 874, 100, 100, 100, 100, 0, 0, 0, 0, 1, 1}, "Used to store the position of the armor ant tool HUD's. This should not be modified", Integer.MIN_VALUE, Integer.MAX_VALUE, true, 12).set(ConfigHandler.hudSettings); - ConfigHandler.config.save(); - } + ConfigHandler.config.get("Gui Stuff", "HUD Settings", new int[]{7, 874, 100, 100, 100, 100, 0, 0, 0, 0, 1, 1}, "Used to store the position of the armor ant tool HUD's. This should not be modified", Integer.MIN_VALUE, Integer.MAX_VALUE, true, 12).set(ConfigHandler.hudSettings); + ConfigHandler.config.save(); + } - @Override - public void drawScreen(int x, int y, float partial) { - int[] pos = ConfigHandler.hudSettings; - int hudX = (int)((pos[0] / 1000D) * width); - int hudY = (int)((pos[1] / 1000D) * height); - int armorX = (int)((pos[2] / 1000D) * width); - int armorY = (int)((pos[3] / 1000D) * height); + @Override + public void drawScreen(int x, int y, float partial) { + int[] pos = ConfigHandler.hudSettings; + int hudX = (int) ((pos[0] / 1000D) * width); + int hudY = (int) ((pos[1] / 1000D) * height); + int armorX = (int) ((pos[2] / 1000D) * width); + int armorY = (int) ((pos[3] / 1000D) * height); - drawCenteredString(fontRendererObj, StatCollector.translateToLocal("gui.de.configureGuiElements.txt"), width/2, height/2-90, 0x00FFFF); - drawCenteredString(fontRendererObj, StatCollector.translateToLocal("gui.de.hudDisplaySettings.txt"), width/2, height/2-77, 0xFFFFFF); - drawCenteredString(fontRendererObj, StatCollector.translateToLocal("gui.de.shieldDisplaySettings.txt"), width/2, height/2-15, 0xFFFFFF); - drawCenteredString(fontRendererObj, StatCollector.translateToLocal("gui.de.clickAndDragPurpleBoxes.txt"), width/2, height/2+85, 0xFFFFFF); + drawCenteredString(fontRendererObj, StatCollector.translateToLocal("gui.de.configureGuiElements.txt"), width / 2, height / 2 - 90, 0x00FFFF); + drawCenteredString(fontRendererObj, StatCollector.translateToLocal("gui.de.hudDisplaySettings.txt"), width / 2, height / 2 - 77, 0xFFFFFF); + drawCenteredString(fontRendererObj, StatCollector.translateToLocal("gui.de.shieldDisplaySettings.txt"), width / 2, height / 2 - 15, 0xFFFFFF); + drawCenteredString(fontRendererObj, StatCollector.translateToLocal("gui.de.clickAndDragPurpleBoxes.txt"), width / 2, height / 2 + 85, 0xFFFFFF); - drawCenteredString(fontRendererObj, ConfigHandler.hudSettings[4]+"%", width/2 + 97, height/2-63, 0xFFFFFF); - drawCenteredString(fontRendererObj, ConfigHandler.hudSettings[5]+"%", width/2 + 97, height/2-1, 0xFFFFFF); - super.drawScreen(x, y, partial); + drawCenteredString(fontRendererObj, ConfigHandler.hudSettings[4] + "%", width / 2 + 97, height / 2 - 63, 0xFFFFFF); + drawCenteredString(fontRendererObj, ConfigHandler.hudSettings[5] + "%", width / 2 + 97, height / 2 - 1, 0xFFFFFF); + super.drawScreen(x, y, partial); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); - GuiHelper.drawGradientRect(hudX-19, hudY-19, hudX+20, hudY+20, 0x20FF00FF, 0x20FF00FF, 1F, 1D); - GuiHelper.drawGradientRect(hudX-4, hudY, hudX+5, hudY+1, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); - GuiHelper.drawGradientRect(hudX, hudY-4, hudX+1, hudY+5, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); - GuiHelper.drawGradientRect(hudX-19, hudY-19, hudX+20, hudY-18, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); - GuiHelper.drawGradientRect(hudX-19, hudY+19, hudX+20, hudY+20, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); - GuiHelper.drawGradientRect(hudX-19, hudY-19, hudX-18, hudY+20, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); - GuiHelper.drawGradientRect(hudX+19, hudY-19, hudX+20, hudY+20, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); + GuiHelper.drawGradientRect(hudX - 19, hudY - 19, hudX + 20, hudY + 20, 0x20FF00FF, 0x20FF00FF, 1F, 1D); + GuiHelper.drawGradientRect(hudX - 4, hudY, hudX + 5, hudY + 1, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); + GuiHelper.drawGradientRect(hudX, hudY - 4, hudX + 1, hudY + 5, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); + GuiHelper.drawGradientRect(hudX - 19, hudY - 19, hudX + 20, hudY - 18, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); + GuiHelper.drawGradientRect(hudX - 19, hudY + 19, hudX + 20, hudY + 20, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); + GuiHelper.drawGradientRect(hudX - 19, hudY - 19, hudX - 18, hudY + 20, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); + GuiHelper.drawGradientRect(hudX + 19, hudY - 19, hudX + 20, hudY + 20, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); - GuiHelper.drawGradientRect(armorX-19, armorY-19, armorX+20, armorY+20, 0x20FF00FF, 0x20FF00FF, 1F, 1D); - GuiHelper.drawGradientRect(armorX-4, armorY, armorX+5, armorY+1, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); - GuiHelper.drawGradientRect(armorX, armorY-4, armorX+1, armorY+5, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); - GuiHelper.drawGradientRect(armorX-19, armorY-19, armorX+20, armorY-18, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); - GuiHelper.drawGradientRect(armorX-19, armorY+19, armorX+20, armorY+20, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); - GuiHelper.drawGradientRect(armorX-19, armorY-19, armorX-18, armorY+20, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); - GuiHelper.drawGradientRect(armorX+19, armorY-19, armorX+20, armorY+20, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); + GuiHelper.drawGradientRect(armorX - 19, armorY - 19, armorX + 20, armorY + 20, 0x20FF00FF, 0x20FF00FF, 1F, 1D); + GuiHelper.drawGradientRect(armorX - 4, armorY, armorX + 5, armorY + 1, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); + GuiHelper.drawGradientRect(armorX, armorY - 4, armorX + 1, armorY + 5, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); + GuiHelper.drawGradientRect(armorX - 19, armorY - 19, armorX + 20, armorY - 18, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); + GuiHelper.drawGradientRect(armorX - 19, armorY + 19, armorX + 20, armorY + 20, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); + GuiHelper.drawGradientRect(armorX - 19, armorY - 19, armorX - 18, armorY + 20, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); + GuiHelper.drawGradientRect(armorX + 19, armorY - 19, armorX + 20, armorY + 20, 0xFFFFFFFF, 0xFFFFFFFF, 1F, 1D); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - RenderHelper.enableStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderHelper.enableStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); - if (GuiHelper.isInRect(armorX-19, armorY-19, 39, 39, x, y) || GuiHelper.isInRect(hudX-19, hudY-19, 39, 39, x, y)){ - drawHoveringText(new ArrayList(){{add(StatCollector.translateToLocal("info.de.hudDisplayConfigTxt2.txt"));}}, x, y, fontRendererObj); - } + if (GuiHelper.isInRect(armorX - 19, armorY - 19, 39, 39, x, y) || GuiHelper.isInRect(hudX - 19, hudY - 19, 39, 39, x, y)) { + drawHoveringText(new ArrayList() {{ + add(StatCollector.translateToLocal("info.de.hudDisplayConfigTxt2.txt")); + }}, x, y, fontRendererObj); + } - } + } - @Override - protected void mouseClicked(int x, int y, int button) { - int[] pos = ConfigHandler.hudSettings; - int hudX = (int)((pos[0] / 1000D) * width); - int hudY = (int)((pos[1] / 1000D) * height); - int armorX = (int)((pos[2] / 1000D) * width); - int armorY = (int)((pos[3] / 1000D) * height); + @Override + protected void mouseClicked(int x, int y, int button) { + int[] pos = ConfigHandler.hudSettings; + int hudX = (int) ((pos[0] / 1000D) * width); + int hudY = (int) ((pos[1] / 1000D) * height); + int armorX = (int) ((pos[2] / 1000D) * width); + int armorY = (int) ((pos[3] / 1000D) * height); - if (GuiHelper.isInRect(hudX-19, hudY-19, 39, 39, x, y)){ - draggingHud = true; - dragOffsetX = hudX-x; - dragOffsetY = hudY-y; - return; - } - else if (GuiHelper.isInRect(armorX-19, armorY-19, 39, 39, x, y)){ - draggingArmor = true; - dragOffsetX = armorX-x; - dragOffsetY = armorY-y; - return; - } + if (GuiHelper.isInRect(hudX - 19, hudY - 19, 39, 39, x, y)) { + draggingHud = true; + dragOffsetX = hudX - x; + dragOffsetY = hudY - y; + return; + } else if (GuiHelper.isInRect(armorX - 19, armorY - 19, 39, 39, x, y)) { + draggingArmor = true; + dragOffsetX = armorX - x; + dragOffsetY = armorY - y; + return; + } - super.mouseClicked(x, y, button); - } + super.mouseClicked(x, y, button); + } - @Override - protected void mouseMovedOrUp(int x, int y, int action) { - super.mouseMovedOrUp(x, y, action); - draggingHud = draggingArmor = false; - ConfigHandler.config.get("Gui Stuff", "HUD Settings", new int[] {7, 874, 100, 100, 100, 100, 0, 0, 0, 0, 1, 1}, "Used to store the position of the armor ant tool HUD's. This should not be modified", Integer.MIN_VALUE, Integer.MAX_VALUE, true, 12).set(ConfigHandler.hudSettings); - ConfigHandler.config.save(); - } + @Override + protected void mouseMovedOrUp(int x, int y, int action) { + super.mouseMovedOrUp(x, y, action); + draggingHud = draggingArmor = false; + ConfigHandler.config.get("Gui Stuff", "HUD Settings", new int[]{7, 874, 100, 100, 100, 100, 0, 0, 0, 0, 1, 1}, "Used to store the position of the armor ant tool HUD's. This should not be modified", Integer.MIN_VALUE, Integer.MAX_VALUE, true, 12).set(ConfigHandler.hudSettings); + ConfigHandler.config.save(); + } - @Override - protected void mouseClickMove(int x, int y, int action, long time) { - super.mouseClickMove(x, y, action, time); - int x1 = (int) (((float) (x+dragOffsetX) / (float) width) * 1000f); - int y1 = (int) (((float) (y+dragOffsetY) / (float) height) * 1000f); + @Override + protected void mouseClickMove(int x, int y, int action, long time) { + super.mouseClickMove(x, y, action, time); + int x1 = (int) (((float) (x + dragOffsetX) / (float) width) * 1000f); + int y1 = (int) (((float) (y + dragOffsetY) / (float) height) * 1000f); - if (draggingHud){ - ConfigHandler.hudSettings[0] = x1; - ConfigHandler.hudSettings[1] = y1; - } - else if (draggingArmor){ - ConfigHandler.hudSettings[2] = x1; - ConfigHandler.hudSettings[3] = y1; - } - } + if (draggingHud) { + ConfigHandler.hudSettings[0] = x1; + ConfigHandler.hudSettings[1] = y1; + } else if (draggingArmor) { + ConfigHandler.hudSettings[2] = x1; + ConfigHandler.hudSettings[3] = y1; + } + } - @Override - public boolean doesGuiPauseGame() { - return false; - } + @Override + public boolean doesGuiPauseGame() { + return false; + } - @Override - protected void keyTyped(char keyChar, int keyInt) { - if (keyInt == 1) { - Minecraft.getMinecraft().displayGuiScreen(parent); - return; - } - } + @Override + protected void keyTyped(char keyChar, int keyInt) { + if (keyInt == 1) { + Minecraft.getMinecraft().displayGuiScreen(parent); + return; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiTextureButton.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiTextureButton.java index 93efe5c7..d08aefee 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiTextureButton.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/GuiTextureButton.java @@ -10,48 +10,41 @@ import org.lwjgl.opengl.GL11; * Created by Brandon on 30/6/2015. */ public class GuiTextureButton extends GuiButton { - public int textureXPos; - public int textureYPos; + public int textureXPos; + public int textureYPos; - public GuiTextureButton(int id, int xPos, int yPos, int textureXPos, int textureYPos, int xSise, int ySise, String text) { - super(id, xPos, yPos, xSise, ySise, text); - this.textureXPos = textureXPos; - this.textureYPos = textureYPos; - } + public GuiTextureButton(int id, int xPos, int yPos, int textureXPos, int textureYPos, int xSise, int ySise, String text) { + super(id, xPos, yPos, xSise, ySise, text); + this.textureXPos = textureXPos; + this.textureYPos = textureYPos; + } - @Override - public void drawButton(Minecraft mc, int x, int y) - { - if (this.visible) - { - FontRenderer fontrenderer = mc.fontRenderer; - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.field_146123_n = x >= this.xPosition && y >= this.yPosition && x < this.xPosition + this.width && y < this.yPosition + this.height; - int k = this.getHoverState(this.field_146123_n); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - this.drawTexturedModalRect(this.xPosition, this.yPosition, textureXPos, textureYPos + k * height, this.width, this.height); + @Override + public void drawButton(Minecraft mc, int x, int y) { + if (this.visible) { + FontRenderer fontrenderer = mc.fontRenderer; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.field_146123_n = x >= this.xPosition && y >= this.yPosition && x < this.xPosition + this.width && y < this.yPosition + this.height; + int k = this.getHoverState(this.field_146123_n); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + this.drawTexturedModalRect(this.xPosition, this.yPosition, textureXPos, textureYPos + k * height, this.width, this.height); - this.mouseDragged(mc, x, y); - int l = 14737632; + this.mouseDragged(mc, x, y); + int l = 14737632; - if (packedFGColour != 0) - { - l = packedFGColour; - } - else if (!this.enabled) - { - l = 10526880; - } - else if (this.field_146123_n) - { - l = 16777120; - } + if (packedFGColour != 0) { + l = packedFGColour; + } else if (!this.enabled) { + l = 10526880; + } else if (this.field_146123_n) { + l = 16777120; + } - this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l); - } - } + this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/GUIManual.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/GUIManual.java index 2a1c9887..d79c8a33 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/GUIManual.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/GUIManual.java @@ -35,438 +35,407 @@ import java.util.List; */ public class GUIManual extends GUIScrollingBase implements GuiYesNoCallback { - private static List pageList = new ArrayList(); - public static List imageURLs = new ArrayList(); - private static ManualPage currentPage = null; - private int previousScale = -1; - private int worldUpdateIn = -1; - private static String lang; + private static List pageList = new ArrayList(); + public static List imageURLs = new ArrayList(); + private static ManualPage currentPage = null; + private int previousScale = -1; + private int worldUpdateIn = -1; + private static String lang; - public GUIManual() { - super(new DummyContainer(), 255, 325); - if (currentPage != null) - { - collection.addComponent(new ComponentManualPage(0, 0, this, currentPage)).setGroup(GR_PAGE); - collection.addComponent(new ComponentButton(102, 314, 50, 12, 1, this, StatCollector.translateToLocal("button.de.back.txt"))).setGroup(GR_PAGE); - collection.setOnlyGroupEnabled(GR_BACKGROUND); - collection.setGroupEnabled(GR_PAGE, true); - } + public GUIManual() { + super(new DummyContainer(), 255, 325); + if (currentPage != null) { + collection.addComponent(new ComponentManualPage(0, 0, this, currentPage)).setGroup(GR_PAGE); + collection.addComponent(new ComponentButton(102, 314, 50, 12, 1, this, StatCollector.translateToLocal("button.de.back.txt"))).setGroup(GR_PAGE); + collection.setOnlyGroupEnabled(GR_BACKGROUND); + collection.setGroupEnabled(GR_PAGE, true); + } - //mc.gameSettings.guiScale - } + //mc.gameSettings.guiScale + } - @Override - public void initGui() { - super.initGui(); - loadPages(); - if (previousScale == -1) adjustGuiScale(); + @Override + public void initGui() { + super.initGui(); + loadPages(); + if (previousScale == -1) adjustGuiScale(); - if (!Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode().equals(lang)) loadPages(); + if (!Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode().equals(lang)) + loadPages(); LogHelper.info(ContributorHandler.contributors); - } - - private void adjustGuiScale(){ - previousScale = mc.gameSettings.guiScale; - - if (height < ySize){ - int x = width; - int y = height; - - if (mc.gameSettings.guiScale == 0){ - mc.gameSettings.guiScale = 3; - ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - x = scaledresolution.getScaledWidth(); - y = scaledresolution.getScaledHeight(); - } - - if (y < ySize && mc.gameSettings.guiScale == 3){ - mc.gameSettings.guiScale = 2; - ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - x = scaledresolution.getScaledWidth(); - y = scaledresolution.getScaledHeight(); - } - - if (y < ySize && mc.gameSettings.guiScale == 2){ - mc.gameSettings.guiScale = 1; - ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - x = scaledresolution.getScaledWidth(); - y = scaledresolution.getScaledHeight(); - } - - height = y; - width = x; - this.guiLeft = (this.width - this.xSize) / 2; - this.guiTop = (this.height - this.ySize) / 2; - worldUpdateIn = 5; - } - } - - @Override - public void onGuiClosed() { - super.onGuiClosed(); - mc.gameSettings.guiScale = previousScale; - } - - public static final String GR_BACKGROUND = "BACKGROUND"; - public static final String GR_INTRO = "INTRO"; - public static final String GR_CONTRIBUTORS = "CONTRIBUTORS"; - public static final String GR_INDEX = "INDEX"; - public static final String GR_PAGE = "PAGE"; - - @Override - protected ComponentCollection assembleComponents() { - collection = new ComponentCollection(0, 0, xSize, ySize, this); - - collection.addComponent(new ComponentTexturedRect(0, 0, 255, 255, ResourceHandler.getResource("textures/gui/manualTop.png"))).setGroup(GR_BACKGROUND); - collection.addComponent(new ComponentTexturedRect(0, 255, 255, 69, ResourceHandler.getResource("textures/gui/manualBottom.png"))).setGroup(GR_BACKGROUND); - - collection.addComponent(new ComponentTexturedRect(7, 100, 0, 0, 255, 255, ResourceHandler.getResource("textures/gui/images/debanner.png"), true)).setGroup(GR_INTRO).setName("BANNER"); - - collection.addComponent(new ComponentButton(75, 260, 100, 20, 0, this, StatCollector.translateToLocal("info.de.manual.indexButton.txt"), StatCollector.translateToLocal("info.de.manual.indexButtonTip.txt"))).setGroup(GR_INTRO); - collection.addComponent(new ComponentButton(75, 285, 100, 20, 2, this, StatCollector.translateToLocal("info.de.manual.contributorsButton.txt"), StatCollector.translateToLocal("info.de.manual.contributorsButtonInfo.txt"))).setGroup(GR_INTRO); - collection.addComponent(new ComponentContributorsPage(0, 0, this)).setGroup(GR_CONTRIBUTORS).setName("CONTRIBUTORS"); - - collection.addComponent(new ComponentTextureButton(140, 290, 0, 0, 100, 30, 10, this, "", "", ResourceHandler.getResource("textures/gui/patreon.png")).forceFullRender()).setGroup(GR_CONTRIBUTORS); - - for (int i = 0; i < pageList.size(); i++) - { - collection.addComponent(new ComponentIndexButton(20, 20 + i * 20, this, pageList.get(i))).setGroup(GR_INDEX).setName("INDEX_BUTTON_"+i); - pageLength += 20; - } - - scrollLimit = pageLength - 285; - - collection.setOnlyGroupEnabled(GR_BACKGROUND); - collection.setGroupEnabled(GR_INTRO, true); - return collection; - } - - @Override - public void handleScrollInput(int direction) { - if (collection.getComponent("INDEX_BUTTON_0") != null && collection.getComponent("INDEX_BUTTON_0").isEnabled()) { - - if (currentPage != null) return; - scrollOffset += direction * (InfoHelper.isShiftKeyDown() ? 30 : 10); - if (scrollOffset < 0) scrollOffset = 0; - if (scrollOffset > pageLength - ySize + 40) scrollOffset = pageLength - ySize + 40; - if (pageLength + 40 <= ySize) scrollOffset = 0; - - barPosition = (int)(((double)scrollOffset/scrollLimit) * 247D); - } - else if (collection.getComponent("CONTRIBUTORS") != null && collection.getComponent("CONTRIBUTORS").isEnabled()) { - ComponentContributorsPage page = (ComponentContributorsPage)collection.getComponent("CONTRIBUTORS"); - barPosition = (int)(((double)page.scrollOffset/page.scrollLimit) * 247D); - } - else if (collection.getComponent("OPEN_PAGE") != null && collection.getComponent("OPEN_PAGE").isEnabled()) { - ComponentManualPage page = (ComponentManualPage)collection.getComponent("OPEN_PAGE"); - barPosition = (int)(((double)page.scrollOffset/page.scrollLimit) * 247D); - } - - - - } - - @Override - public void drawScreen(int mouseX, int mouseY, float par3) { - super.drawScreen(mouseX, mouseY, par3); - int posX = (this.width - xSize) / 2; - int posY = (this.height - ySize) / 2; - if (collection.getComponent("BANNER") != null && collection.getComponent("BANNER").isEnabled()) fontRendererObj.drawSplitString(StatCollector.translateToLocal("info.de.manual.introTxt.txt"), posX + 20, posY + 190, 150, 0x000000); - - if (collection.getComponent("BANNER") != null && collection.getComponent("BANNER").isEnabled()) return; - ResourceHandler.bindResource("textures/gui/Widgets.png"); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(guiLeft, guiTop, 118, 20, 17, 17); - - if (mouseX-posX >= 0 && mouseX-posX <= 17 && mouseY-posY >= 0 && mouseY-posY <= 17){ - List list = new ArrayList(); - list.add(EnumChatFormatting.GREEN+StatCollector.translateToLocal("info.de.manual.nav1.txt")); - list.add(""); - list.add("-"+StatCollector.translateToLocal("info.de.manual.nav2.txt")); - list.add("-"+StatCollector.translateToLocal("info.de.manual.nav3.txt")); - drawHoveringText(list, posX+8, posY+32, fontRendererObj); - } - } - - @Override - public void updateScreen() { - super.updateScreen(); - - disableScrollBar = collection.getComponent("BANNER") != null && collection.getComponent("BANNER").isEnabled(); - - if (!scrollPressed && collection.getComponent("INDEX_BUTTON_0") != null && collection.getComponent("INDEX_BUTTON_0").isEnabled()) { - barPosition = (int)(((double)scrollOffset/scrollLimit) * 247D); - } - else if (!scrollPressed && collection.getComponent("CONTRIBUTORS") != null && collection.getComponent("CONTRIBUTORS").isEnabled()) { - ComponentContributorsPage page = (ComponentContributorsPage)collection.getComponent("CONTRIBUTORS"); - barPosition = (int)(((double)page.scrollOffset/page.scrollLimit) * 247D); - } - else if (!scrollPressed && collection.getComponent("OPEN_PAGE") != null && collection.getComponent("OPEN_PAGE").isEnabled()) { - ComponentManualPage page = (ComponentManualPage)collection.getComponent("OPEN_PAGE"); - barPosition = (int)(((double)page.scrollOffset/page.scrollLimit) * 247D); - } - - if (worldUpdateIn > -1) worldUpdateIn--; - if (worldUpdateIn == 0) collection.setWorldAndResolution(mc, width, height); - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - - ResourceHandler.bindResource("textures/gui/manualBottom.png"); - GL11.glColor4f(1f, 1f, 1f, 1f); - drawTexturedModalRect(0, ySize - 34, 0, 69, 256, 34); - drawTexturedModalRect(0, 0, 0, 103, 256, 34); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); - if (disableScrollBar) return; - - - - ResourceHandler.bindResource("textures/gui/manualBottom.png"); - GL11.glColor4f(1F, 1F, 1F, 1F); - drawTexturedModalRect(guiLeft - 16, guiTop + 10, 0, 146, 15, 100); - drawTexturedModalRect(guiLeft - 16, guiTop + ySize - 110, 0, 156, 15, 100); - drawTexturedModalRect(guiLeft - 16, guiTop + 110, 0, 156, 15, 90); - drawTexturedModalRect(guiLeft - 16, guiTop + 140, 0, 156, 15, 90); - - drawTexturedModalRect(guiLeft-15, guiTop+20 + barPosition, 15, 218, 13, 38); - } - - @Override - public void buttonClicked(int id, int button) { - super.buttonClicked(id, button); - if (id == 0) - { - collection.setOnlyGroupEnabled(GR_BACKGROUND); - collection.setGroupEnabled(GR_INDEX, true); - } - else if (id == 1) - { - currentPage = null; - collection.setOnlyGroupEnabled(GR_BACKGROUND); - collection.setGroupEnabled(GR_INDEX, true); - collection.schedulRemoval(GR_PAGE); - } - else if (id == 2) - { - currentPage = null; - collection.setOnlyGroupEnabled(GR_BACKGROUND); - collection.setGroupEnabled(GR_CONTRIBUTORS, true); - collection.schedulRemoval(GR_PAGE); - } - else if (id == 10){ - mc.displayGuiScreen(new GuiConfirmOpenLink(this, "https://www.patreon.com/brandon3055", 0, true)); - } - } - - @Override - protected void keyTyped(char par1, int par2) { - super.keyTyped(par1, par2); - if (Keyboard.KEY_BACK == par2) - { - if (currentPage != null) - { - currentPage = null; - collection.setOnlyGroupEnabled(GR_BACKGROUND); - collection.setGroupEnabled(GR_INDEX, true); - collection.schedulRemoval(GR_PAGE); - } - else - { - collection.setOnlyGroupEnabled(GR_BACKGROUND); - collection.setGroupEnabled(GR_INTRO, true); - } - } - } - - public static void loadPages() - { - lang = Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode(); - - ResourceLocation rsLocation = new ResourceLocation(References.RESOURCESPREFIX + "manual/manual-"+lang+".json"); - IResource resource = null; - - try { - resource = Minecraft.getMinecraft().getResourceManager().getResource(rsLocation); - } - catch (IOException e) { - LogHelper.warn("##################################################################################"); - LogHelper.warn(""); - LogHelper.warn("Info Tablet language localisation is not available for the selected language: "+lang); - LogHelper.warn("The default language (en_US) will be loaded instead"); - LogHelper.warn(""); - LogHelper.warn("##################################################################################"); - - rsLocation = new ResourceLocation(References.RESOURCESPREFIX + "manual/manual-en_US.json"); - try { - resource = Minecraft.getMinecraft().getResourceManager().getResource(rsLocation); - } - catch (IOException e1) { - LogHelper.error("Well that didn't work... "); - e1.printStackTrace(); - } - } - - if (resource == null){ - LogHelper.error("Something went wrong while loading the Info Tablet json file"); - return; - } - - - try - { - File manualJSON = new File(ResourceHandler.getConfigFolder(), "manual.json"); - - InputStream is = resource.getInputStream(); - OutputStream os = new FileOutputStream(manualJSON); - IOUtils.copy(is, os); - is.close(); - os.close(); - - - - JsonReader reader = new JsonReader(new FileReader(manualJSON)); - List images; - List content; - - reader.beginArray(); - - //Read next page - while (reader.hasNext()) - { - String name; - String nameL = null; - int meta = 0; - images = new ArrayList(); - content = new ArrayList(); - - reader.beginObject(); - - //Read page name - String s = reader.nextName(); - if (s.equals("name")) - { - name = reader.nextString(); - } - else throw new IOException("Error reading manual.json (invalid name in place of \"name\" [Found:\"" + s + "\"])"); - - //Read page images - s = reader.nextName(); - if (s.equals("nameL")) - { - nameL = reader.nextString(); - s = reader.nextName(); - } - if (s.equals("meta")) - { - meta = reader.nextInt(); - s = reader.nextName(); - } - - if (s.equals("images")) - { - reader.beginArray(); - while (reader.hasNext()) - { - String url = reader.nextString(); - images.add(url); - if (!imageURLs.contains(url)) imageURLs.add(url); - } - reader.endArray(); - } - else throw new IOException("Error reading manual.json (invalid name in place of \"images\" [Found:\"" + s + "\"])"); - - //Read page content - s = reader.nextName(); - if (s.equals("content")) - { - reader.beginArray(); - while (reader.hasNext()) - { - content.add(reader.nextString()); - } - reader.endArray(); - } - else throw new IOException("Error reading manual.json (invalid name in place of \"content\" [Found:\"" + s + "\"])"); - - reader.endObject(); - - if (isValidPage(name))pageList.add(new ManualPage(name, images.toArray(new String[images.size()]), content.toArray(new String[content.size()]), nameL, meta)); - } - - reader.endArray(); - - } - catch (FileNotFoundException e) - { - e.printStackTrace(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - - @Override - protected void mouseClicked(int x, int y, int button) { - super.mouseClicked(x, y, button); - if (buttonPressed) return; - - for (ComponentBase c : collection.getComponents()) - { - if (c instanceof ComponentIndexButton && c.isEnabled() && ((ComponentIndexButton) c).isOnScreen() && c.isMouseOver(x - guiLeft, y - guiTop)) - { - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); - currentPage = ((ComponentIndexButton) c).getPage(); - collection.addComponent(new ComponentManualPage(0, 0, this, currentPage)).setGroup(GR_PAGE).setName("OPEN_PAGE"); - collection.addComponent(new ComponentButton(102, 314, 50, 12, 1, this, StatCollector.translateToLocal("button.de.back.txt"))).setGroup(GR_PAGE); - collection.setOnlyGroupEnabled(GR_BACKGROUND); - collection.setGroupEnabled(GR_PAGE, true); - break; - } - } - } - - @Override - public void barMoved(double position) { - if (collection.getComponent("INDEX_BUTTON_0") != null &&collection.getComponent("INDEX_BUTTON_0").isEnabled()) scrollOffset = (int)(position * scrollLimit); - else if (collection.getComponent("CONTRIBUTORS") != null && collection.getComponent("CONTRIBUTORS").isEnabled()) { - ComponentContributorsPage page = (ComponentContributorsPage)collection.getComponent("CONTRIBUTORS"); - if (page.scrollLimit < 0) return; - page.scrollOffset = (int) (position * page.scrollLimit); - } - else if (collection.getComponent("OPEN_PAGE") != null && collection.getComponent("OPEN_PAGE").isEnabled()) { - ComponentManualPage page = (ComponentManualPage)collection.getComponent("OPEN_PAGE"); - if (page.scrollLimit < 0) return; - page.scrollOffset = (int) (position * page.scrollLimit); - } - } - - private static boolean isValidPage(String name) - { - if (name.contains("info.")) return true; - else if (!ConfigHandler.disabledNamesList.contains(name)) return true; - return false; - } - - @Override - public void confirmClicked(boolean confirmed, int id) { - if (confirmed) ClientUtills.openLink("https://www.patreon.com/brandon3055"); - mc.displayGuiScreen(this); - } + } + + private void adjustGuiScale() { + previousScale = mc.gameSettings.guiScale; + + if (height < ySize) { + int x = width; + int y = height; + + if (mc.gameSettings.guiScale == 0) { + mc.gameSettings.guiScale = 3; + ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + x = scaledresolution.getScaledWidth(); + y = scaledresolution.getScaledHeight(); + } + + if (y < ySize && mc.gameSettings.guiScale == 3) { + mc.gameSettings.guiScale = 2; + ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + x = scaledresolution.getScaledWidth(); + y = scaledresolution.getScaledHeight(); + } + + if (y < ySize && mc.gameSettings.guiScale == 2) { + mc.gameSettings.guiScale = 1; + ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + x = scaledresolution.getScaledWidth(); + y = scaledresolution.getScaledHeight(); + } + + height = y; + width = x; + this.guiLeft = (this.width - this.xSize) / 2; + this.guiTop = (this.height - this.ySize) / 2; + worldUpdateIn = 5; + } + } + + @Override + public void onGuiClosed() { + super.onGuiClosed(); + mc.gameSettings.guiScale = previousScale; + } + + public static final String GR_BACKGROUND = "BACKGROUND"; + public static final String GR_INTRO = "INTRO"; + public static final String GR_CONTRIBUTORS = "CONTRIBUTORS"; + public static final String GR_INDEX = "INDEX"; + public static final String GR_PAGE = "PAGE"; + + @Override + protected ComponentCollection assembleComponents() { + collection = new ComponentCollection(0, 0, xSize, ySize, this); + + collection.addComponent(new ComponentTexturedRect(0, 0, 255, 255, ResourceHandler.getResource("textures/gui/manualTop.png"))).setGroup(GR_BACKGROUND); + collection.addComponent(new ComponentTexturedRect(0, 255, 255, 69, ResourceHandler.getResource("textures/gui/manualBottom.png"))).setGroup(GR_BACKGROUND); + + collection.addComponent(new ComponentTexturedRect(7, 100, 0, 0, 255, 255, ResourceHandler.getResource("textures/gui/images/debanner.png"), true)).setGroup(GR_INTRO).setName("BANNER"); + + collection.addComponent(new ComponentButton(75, 260, 100, 20, 0, this, StatCollector.translateToLocal("info.de.manual.indexButton.txt"), StatCollector.translateToLocal("info.de.manual.indexButtonTip.txt"))).setGroup(GR_INTRO); + collection.addComponent(new ComponentButton(75, 285, 100, 20, 2, this, StatCollector.translateToLocal("info.de.manual.contributorsButton.txt"), StatCollector.translateToLocal("info.de.manual.contributorsButtonInfo.txt"))).setGroup(GR_INTRO); + collection.addComponent(new ComponentContributorsPage(0, 0, this)).setGroup(GR_CONTRIBUTORS).setName("CONTRIBUTORS"); + + collection.addComponent(new ComponentTextureButton(140, 290, 0, 0, 100, 30, 10, this, "", "", ResourceHandler.getResource("textures/gui/patreon.png")).forceFullRender()).setGroup(GR_CONTRIBUTORS); + + for (int i = 0; i < pageList.size(); i++) { + collection.addComponent(new ComponentIndexButton(20, 20 + i * 20, this, pageList.get(i))).setGroup(GR_INDEX).setName("INDEX_BUTTON_" + i); + pageLength += 20; + } + + scrollLimit = pageLength - 285; + + collection.setOnlyGroupEnabled(GR_BACKGROUND); + collection.setGroupEnabled(GR_INTRO, true); + return collection; + } + + @Override + public void handleScrollInput(int direction) { + if (collection.getComponent("INDEX_BUTTON_0") != null && collection.getComponent("INDEX_BUTTON_0").isEnabled()) { + + if (currentPage != null) return; + scrollOffset += direction * (InfoHelper.isShiftKeyDown() ? 30 : 10); + if (scrollOffset < 0) scrollOffset = 0; + if (scrollOffset > pageLength - ySize + 40) scrollOffset = pageLength - ySize + 40; + if (pageLength + 40 <= ySize) scrollOffset = 0; + + barPosition = (int) (((double) scrollOffset / scrollLimit) * 247D); + } else if (collection.getComponent("CONTRIBUTORS") != null && collection.getComponent("CONTRIBUTORS").isEnabled()) { + ComponentContributorsPage page = (ComponentContributorsPage) collection.getComponent("CONTRIBUTORS"); + barPosition = (int) (((double) page.scrollOffset / page.scrollLimit) * 247D); + } else if (collection.getComponent("OPEN_PAGE") != null && collection.getComponent("OPEN_PAGE").isEnabled()) { + ComponentManualPage page = (ComponentManualPage) collection.getComponent("OPEN_PAGE"); + barPosition = (int) (((double) page.scrollOffset / page.scrollLimit) * 247D); + } + + + } + + @Override + public void drawScreen(int mouseX, int mouseY, float par3) { + super.drawScreen(mouseX, mouseY, par3); + int posX = (this.width - xSize) / 2; + int posY = (this.height - ySize) / 2; + if (collection.getComponent("BANNER") != null && collection.getComponent("BANNER").isEnabled()) + fontRendererObj.drawSplitString(StatCollector.translateToLocal("info.de.manual.introTxt.txt"), posX + 20, posY + 190, 150, 0x000000); + + if (collection.getComponent("BANNER") != null && collection.getComponent("BANNER").isEnabled()) return; + ResourceHandler.bindResource("textures/gui/Widgets.png"); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(guiLeft, guiTop, 118, 20, 17, 17); + + if (mouseX - posX >= 0 && mouseX - posX <= 17 && mouseY - posY >= 0 && mouseY - posY <= 17) { + List list = new ArrayList(); + list.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("info.de.manual.nav1.txt")); + list.add(""); + list.add("-" + StatCollector.translateToLocal("info.de.manual.nav2.txt")); + list.add("-" + StatCollector.translateToLocal("info.de.manual.nav3.txt")); + drawHoveringText(list, posX + 8, posY + 32, fontRendererObj); + } + } + + @Override + public void updateScreen() { + super.updateScreen(); + + disableScrollBar = collection.getComponent("BANNER") != null && collection.getComponent("BANNER").isEnabled(); + + if (!scrollPressed && collection.getComponent("INDEX_BUTTON_0") != null && collection.getComponent("INDEX_BUTTON_0").isEnabled()) { + barPosition = (int) (((double) scrollOffset / scrollLimit) * 247D); + } else if (!scrollPressed && collection.getComponent("CONTRIBUTORS") != null && collection.getComponent("CONTRIBUTORS").isEnabled()) { + ComponentContributorsPage page = (ComponentContributorsPage) collection.getComponent("CONTRIBUTORS"); + barPosition = (int) (((double) page.scrollOffset / page.scrollLimit) * 247D); + } else if (!scrollPressed && collection.getComponent("OPEN_PAGE") != null && collection.getComponent("OPEN_PAGE").isEnabled()) { + ComponentManualPage page = (ComponentManualPage) collection.getComponent("OPEN_PAGE"); + barPosition = (int) (((double) page.scrollOffset / page.scrollLimit) * 247D); + } + + if (worldUpdateIn > -1) worldUpdateIn--; + if (worldUpdateIn == 0) collection.setWorldAndResolution(mc, width, height); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + + ResourceHandler.bindResource("textures/gui/manualBottom.png"); + GL11.glColor4f(1f, 1f, 1f, 1f); + drawTexturedModalRect(0, ySize - 34, 0, 69, 256, 34); + drawTexturedModalRect(0, 0, 0, 103, 256, 34); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + if (disableScrollBar) return; + + + ResourceHandler.bindResource("textures/gui/manualBottom.png"); + GL11.glColor4f(1F, 1F, 1F, 1F); + drawTexturedModalRect(guiLeft - 16, guiTop + 10, 0, 146, 15, 100); + drawTexturedModalRect(guiLeft - 16, guiTop + ySize - 110, 0, 156, 15, 100); + drawTexturedModalRect(guiLeft - 16, guiTop + 110, 0, 156, 15, 90); + drawTexturedModalRect(guiLeft - 16, guiTop + 140, 0, 156, 15, 90); + + drawTexturedModalRect(guiLeft - 15, guiTop + 20 + barPosition, 15, 218, 13, 38); + } + + @Override + public void buttonClicked(int id, int button) { + super.buttonClicked(id, button); + if (id == 0) { + collection.setOnlyGroupEnabled(GR_BACKGROUND); + collection.setGroupEnabled(GR_INDEX, true); + } else if (id == 1) { + currentPage = null; + collection.setOnlyGroupEnabled(GR_BACKGROUND); + collection.setGroupEnabled(GR_INDEX, true); + collection.schedulRemoval(GR_PAGE); + } else if (id == 2) { + currentPage = null; + collection.setOnlyGroupEnabled(GR_BACKGROUND); + collection.setGroupEnabled(GR_CONTRIBUTORS, true); + collection.schedulRemoval(GR_PAGE); + } else if (id == 10) { + mc.displayGuiScreen(new GuiConfirmOpenLink(this, "https://www.patreon.com/brandon3055", 0, true)); + } + } + + @Override + protected void keyTyped(char par1, int par2) { + super.keyTyped(par1, par2); + if (Keyboard.KEY_BACK == par2) { + if (currentPage != null) { + currentPage = null; + collection.setOnlyGroupEnabled(GR_BACKGROUND); + collection.setGroupEnabled(GR_INDEX, true); + collection.schedulRemoval(GR_PAGE); + } else { + collection.setOnlyGroupEnabled(GR_BACKGROUND); + collection.setGroupEnabled(GR_INTRO, true); + } + } + } + + public static void loadPages() { + lang = Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode(); + + ResourceLocation rsLocation = new ResourceLocation(References.RESOURCESPREFIX + "manual/manual-" + lang + ".json"); + IResource resource = null; + + try { + resource = Minecraft.getMinecraft().getResourceManager().getResource(rsLocation); + } + catch (IOException e) { + LogHelper.warn("##################################################################################"); + LogHelper.warn(""); + LogHelper.warn("Info Tablet language localisation is not available for the selected language: " + lang); + LogHelper.warn("The default language (en_US) will be loaded instead"); + LogHelper.warn(""); + LogHelper.warn("##################################################################################"); + + rsLocation = new ResourceLocation(References.RESOURCESPREFIX + "manual/manual-en_US.json"); + try { + resource = Minecraft.getMinecraft().getResourceManager().getResource(rsLocation); + } + catch (IOException e1) { + LogHelper.error("Well that didn't work... "); + e1.printStackTrace(); + } + } + + if (resource == null) { + LogHelper.error("Something went wrong while loading the Info Tablet json file"); + return; + } + + + try { + File manualJSON = new File(ResourceHandler.getConfigFolder(), "manual.json"); + + InputStream is = resource.getInputStream(); + OutputStream os = new FileOutputStream(manualJSON); + IOUtils.copy(is, os); + is.close(); + os.close(); + + + JsonReader reader = new JsonReader(new FileReader(manualJSON)); + List images; + List content; + + reader.beginArray(); + + //Read next page + while (reader.hasNext()) { + String name; + String nameL = null; + int meta = 0; + images = new ArrayList(); + content = new ArrayList(); + + reader.beginObject(); + + //Read page name + String s = reader.nextName(); + if (s.equals("name")) { + name = reader.nextString(); + } else + throw new IOException("Error reading manual.json (invalid name in place of \"name\" [Found:\"" + s + "\"])"); + + //Read page images + s = reader.nextName(); + if (s.equals("nameL")) { + nameL = reader.nextString(); + s = reader.nextName(); + } + if (s.equals("meta")) { + meta = reader.nextInt(); + s = reader.nextName(); + } + + if (s.equals("images")) { + reader.beginArray(); + while (reader.hasNext()) { + String url = reader.nextString(); + images.add(url); + if (!imageURLs.contains(url)) imageURLs.add(url); + } + reader.endArray(); + } else + throw new IOException("Error reading manual.json (invalid name in place of \"images\" [Found:\"" + s + "\"])"); + + //Read page content + s = reader.nextName(); + if (s.equals("content")) { + reader.beginArray(); + while (reader.hasNext()) { + content.add(reader.nextString()); + } + reader.endArray(); + } else + throw new IOException("Error reading manual.json (invalid name in place of \"content\" [Found:\"" + s + "\"])"); + + reader.endObject(); + + if (isValidPage(name)) + pageList.add(new ManualPage(name, images.toArray(new String[images.size()]), content.toArray(new String[content.size()]), nameL, meta)); + } + + reader.endArray(); + + } + catch (FileNotFoundException e) { + e.printStackTrace(); + } + catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + protected void mouseClicked(int x, int y, int button) { + super.mouseClicked(x, y, button); + if (buttonPressed) return; + + for (ComponentBase c : collection.getComponents()) { + if (c instanceof ComponentIndexButton && c.isEnabled() && ((ComponentIndexButton) c).isOnScreen() && c.isMouseOver(x - guiLeft, y - guiTop)) { + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + currentPage = ((ComponentIndexButton) c).getPage(); + collection.addComponent(new ComponentManualPage(0, 0, this, currentPage)).setGroup(GR_PAGE).setName("OPEN_PAGE"); + collection.addComponent(new ComponentButton(102, 314, 50, 12, 1, this, StatCollector.translateToLocal("button.de.back.txt"))).setGroup(GR_PAGE); + collection.setOnlyGroupEnabled(GR_BACKGROUND); + collection.setGroupEnabled(GR_PAGE, true); + break; + } + } + } + + @Override + public void barMoved(double position) { + if (collection.getComponent("INDEX_BUTTON_0") != null && collection.getComponent("INDEX_BUTTON_0").isEnabled()) + scrollOffset = (int) (position * scrollLimit); + else if (collection.getComponent("CONTRIBUTORS") != null && collection.getComponent("CONTRIBUTORS").isEnabled()) { + ComponentContributorsPage page = (ComponentContributorsPage) collection.getComponent("CONTRIBUTORS"); + if (page.scrollLimit < 0) return; + page.scrollOffset = (int) (position * page.scrollLimit); + } else if (collection.getComponent("OPEN_PAGE") != null && collection.getComponent("OPEN_PAGE").isEnabled()) { + ComponentManualPage page = (ComponentManualPage) collection.getComponent("OPEN_PAGE"); + if (page.scrollLimit < 0) return; + page.scrollOffset = (int) (position * page.scrollLimit); + } + } + + private static boolean isValidPage(String name) { + if (name.contains("info.")) return true; + else if (!ConfigHandler.disabledNamesList.contains(name)) return true; + return false; + } + + @Override + public void confirmClicked(boolean confirmed, int id) { + if (confirmed) ClientUtills.openLink("https://www.patreon.com/brandon3055"); + mc.displayGuiScreen(this); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/GUIReactor.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/GUIReactor.java index 556467bd..9bfc31f8 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/GUIReactor.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/GUIReactor.java @@ -20,178 +20,181 @@ import java.util.List; * Created by brandon3055 on 30/7/2015. */ public class GUIReactor extends GUIBase { - private TileReactorCore reactor; - private ContainerReactor container; - private static boolean showStats = false; + private TileReactorCore reactor; + private ContainerReactor container; + private static boolean showStats = false; - public GUIReactor(EntityPlayer player, TileReactorCore reactor, ContainerReactor container) { - super(container, 248, 222); - this.reactor = reactor; - this.container = container; - } + public GUIReactor(EntityPlayer player, TileReactorCore reactor, ContainerReactor container) { + super(container, 248, 222); + this.reactor = reactor; + this.container = container; + } - @Override - protected ComponentCollection assembleComponents() { - collection = new ComponentCollection(0, 0, 248, 222, this); - collection.addComponent(new ComponentTexturedRect(0, 0, xSize, ySize, ResourceHandler.getResource("textures/gui/Reactor.png"))); - collection.addComponent(new ComponentTextureButton(14, 190, 18, 162, 18, 18, 0, this, "", StatCollector.translateToLocal("button.de.reactorCharge.txt"), ResourceHandler.getResource("textures/gui/Widgets.png"))).setName("CHARGE"); - collection.addComponent(new ComponentTextureButton(14, 190, 18, 54, 18, 18, 1, this, "", StatCollector.translateToLocal("button.de.reactorStart.txt"), ResourceHandler.getResource("textures/gui/Widgets.png"))).setName("ACTIVATE"); - collection.addComponent(new ComponentTextureButton(216, 190, 18, 108, 18, 18, 2, this, "", StatCollector.translateToLocal("button.de.reactorStop.txt"), ResourceHandler.getResource("textures/gui/Widgets.png"))).setName("DEACTIVATE"); - collection.addComponent(new ComponentButton(9, 120, 43, 15, 3, this, StatCollector.translateToLocal("button.de.stats.txt"), StatCollector.translateToLocal("button.de.statsShow.txt"))).setName("STATS"); - return collection; - } + @Override + protected ComponentCollection assembleComponents() { + collection = new ComponentCollection(0, 0, 248, 222, this); + collection.addComponent(new ComponentTexturedRect(0, 0, xSize, ySize, ResourceHandler.getResource("textures/gui/Reactor.png"))); + collection.addComponent(new ComponentTextureButton(14, 190, 18, 162, 18, 18, 0, this, "", StatCollector.translateToLocal("button.de.reactorCharge.txt"), ResourceHandler.getResource("textures/gui/Widgets.png"))).setName("CHARGE"); + collection.addComponent(new ComponentTextureButton(14, 190, 18, 54, 18, 18, 1, this, "", StatCollector.translateToLocal("button.de.reactorStart.txt"), ResourceHandler.getResource("textures/gui/Widgets.png"))).setName("ACTIVATE"); + collection.addComponent(new ComponentTextureButton(216, 190, 18, 108, 18, 18, 2, this, "", StatCollector.translateToLocal("button.de.reactorStop.txt"), ResourceHandler.getResource("textures/gui/Widgets.png"))).setName("DEACTIVATE"); + collection.addComponent(new ComponentButton(9, 120, 43, 15, 3, this, StatCollector.translateToLocal("button.de.stats.txt"), StatCollector.translateToLocal("button.de.statsShow.txt"))).setName("STATS"); + return collection; + } - @Override - protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); - //Draw I/O Slots - if (reactor.reactorState == TileReactorCore.STATE_OFFLINE){ - RenderHelper.enableGUIStandardItemLighting(); - drawTexturedModalRect(guiLeft + 14, guiTop + 139, 14, ySize, 18, 18); - drawTexturedModalRect(guiLeft + 216, guiTop + 139, 32, ySize, 18, 18); + @Override + protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + //Draw I/O Slots + if (reactor.reactorState == TileReactorCore.STATE_OFFLINE) { + RenderHelper.enableGUIStandardItemLighting(); + drawTexturedModalRect(guiLeft + 14, guiTop + 139, 14, ySize, 18, 18); + drawTexturedModalRect(guiLeft + 216, guiTop + 139, 32, ySize, 18, 18); - fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.insert.txt"), guiLeft + 8, guiTop + 159, 0); - fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.fuel.txt"), guiLeft + 13, guiTop + 168, 0); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.insert.txt"), guiLeft + 8, guiTop + 159, 0); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.fuel.txt"), guiLeft + 13, guiTop + 168, 0); - fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.extract.txt"), guiLeft + 206, guiTop + 159, 0); - fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.fuel.txt"), guiLeft + 215, guiTop + 168, 0); - } - drawCenteredString(fontRendererObj, "Draconic Reactor", guiLeft + xSize / 2, guiTop + 4, 0x00FFFF); - } + fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.extract.txt"), guiLeft + 206, guiTop + 159, 0); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.fuel.txt"), guiLeft + 215, guiTop + 168, 0); + } + drawCenteredString(fontRendererObj, "Draconic Reactor", guiLeft + xSize / 2, guiTop + 4, 0x00FFFF); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - ResourceHandler.bindResource("textures/gui/Reactor.png"); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + ResourceHandler.bindResource("textures/gui/Reactor.png"); - GL11.glColor4f(1f, 1f, 1f, 1f); - //Draw Indicators - double value = Math.min(reactor.reactionTemperature, reactor.maxReactTemperature) / reactor.maxReactTemperature; - int pixOffset = (int)(value * 108); - drawTexturedModalRect(11, 112 - pixOffset, 0, 222, 14, 5); + GL11.glColor4f(1f, 1f, 1f, 1f); + //Draw Indicators + double value = Math.min(reactor.reactionTemperature, reactor.maxReactTemperature) / reactor.maxReactTemperature; + int pixOffset = (int) (value * 108); + drawTexturedModalRect(11, 112 - pixOffset, 0, 222, 14, 5); - value = reactor.fieldCharge / reactor.maxFieldCharge; - pixOffset = (int)(value * 108); - drawTexturedModalRect(35, 112 - pixOffset, 0, 222, 14, 5); + value = reactor.fieldCharge / reactor.maxFieldCharge; + pixOffset = (int) (value * 108); + drawTexturedModalRect(35, 112 - pixOffset, 0, 222, 14, 5); - value = (double)reactor.energySaturation / (double)reactor.maxEnergySaturation; - pixOffset = (int)(value * 108); - drawTexturedModalRect(199, 112 - pixOffset, 0, 222, 14, 5); + value = (double) reactor.energySaturation / (double) reactor.maxEnergySaturation; + pixOffset = (int) (value * 108); + drawTexturedModalRect(199, 112 - pixOffset, 0, 222, 14, 5); - value = ((double)reactor.convertedFuel) / ((double)reactor.reactorFuel + (double)reactor.convertedFuel); - pixOffset = (int)(value * 108); - drawTexturedModalRect(223, 112 - pixOffset, 0, 222, 14, 5); + value = ((double) reactor.convertedFuel) / ((double) reactor.reactorFuel + (double) reactor.convertedFuel); + pixOffset = (int) (value * 108); + drawTexturedModalRect(223, 112 - pixOffset, 0, 222, 14, 5); - GL11.glColor4f(1F, 1F, 1F, 1F); - if (!showStats) - { + GL11.glColor4f(1F, 1F, 1F, 1F); + if (!showStats) { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); - GL11.glTranslated(124, 71, 100); - double scale = 100 / (reactor.getCoreDiameter()); - GL11.glScaled(scale, scale, scale); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + GL11.glTranslated(124, 71, 100); + double scale = 100 / (reactor.getCoreDiameter()); + GL11.glScaled(scale, scale, scale); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glDisable(GL11.GL_CULL_FACE); - TileEntityRendererDispatcher.instance.renderTileEntityAt(reactor, -0.5D, -0.5D, -0.5D, 0.0F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(reactor, -0.5D, -0.5D, -0.5D, 0.0F); - GL11.glPopAttrib(); - GL11.glPopMatrix(); - }else { - ResourceHandler.bindResource("textures/gui/Reactor.png"); - for (int i = 1; i <= 10; i++) drawTexturedModalRect(63, i * 12, 0, 240, 122, 16); - drawStats(); - } + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } else { + ResourceHandler.bindResource("textures/gui/Reactor.png"); + for (int i = 1; i <= 10; i++) drawTexturedModalRect(63, i * 12, 0, 240, 122, 16); + drawStats(); + } - String status = StatCollector.translateToLocal("gui.de.status.txt")+": " + (reactor.reactorState == 0 ? EnumChatFormatting.DARK_GRAY : reactor.reactorState == 1 ? EnumChatFormatting.RED : reactor.reactorState == 2 ? EnumChatFormatting.DARK_GREEN : EnumChatFormatting.RED) + StatCollector.translateToLocal("gui.de.status"+reactor.reactorState+".txt"); - if (reactor.reactorState == 1 && reactor.canStart()) status = StatCollector.translateToLocal("gui.de.status.txt")+": " + EnumChatFormatting.DARK_GREEN + StatCollector.translateToLocal("gui.de.status1_5.txt"); - if (!showStats) fontRendererObj.drawString(status, xSize - 5 - fontRendererObj.getStringWidth(status), 125, 0); - } + String status = StatCollector.translateToLocal("gui.de.status.txt") + ": " + (reactor.reactorState == 0 ? EnumChatFormatting.DARK_GRAY : reactor.reactorState == 1 ? EnumChatFormatting.RED : reactor.reactorState == 2 ? EnumChatFormatting.DARK_GREEN : EnumChatFormatting.RED) + StatCollector.translateToLocal("gui.de.status" + reactor.reactorState + ".txt"); + if (reactor.reactorState == 1 && reactor.canStart()) + status = StatCollector.translateToLocal("gui.de.status.txt") + ": " + EnumChatFormatting.DARK_GREEN + StatCollector.translateToLocal("gui.de.status1_5.txt"); + if (!showStats) fontRendererObj.drawString(status, xSize - 5 - fontRendererObj.getStringWidth(status), 125, 0); + } - @Override - public void drawScreen(int mouseX, int mouseY, float par3) { - super.drawScreen(mouseX, mouseY, par3); - List text = new ArrayList(); - if (GuiHelper.isInRect(9, 4, 18, 114, mouseX - guiLeft, mouseY - guiTop)){ - text.add(StatCollector.translateToLocal("gui.de.reactionTemp.txt")); - text.add((int)reactor.reactionTemperature + "C"); - drawHoveringText(text, mouseX, mouseY, fontRendererObj); - } - else if (GuiHelper.isInRect(33, 4, 18, 114, mouseX-guiLeft, mouseY-guiTop)){ - text.add(StatCollector.translateToLocal("gui.de.fieldStrength.txt")); - if (reactor.maxFieldCharge > 0) text.add(Utills.round(reactor.fieldCharge / reactor.maxFieldCharge * 100D, 100D) + "%"); - text.add(Utills.addCommas((int)reactor.fieldCharge) + " / " + Utills.addCommas((int)reactor.maxFieldCharge)); //todo refine or remove - drawHoveringText(text, mouseX, mouseY, fontRendererObj); - } - else if (GuiHelper.isInRect(197, 4, 18, 114, mouseX-guiLeft, mouseY-guiTop)){ - text.add(StatCollector.translateToLocal("gui.de.energySaturation.txt")); - if (reactor.maxEnergySaturation > 0) text.add(Utills.round((double)reactor.energySaturation / (double)reactor.maxEnergySaturation * 100D, 100D) + "%"); - text.add(Utills.addCommas(reactor.energySaturation) + " / " + Utills.addCommas(reactor.maxEnergySaturation)); //todo refine or remove - drawHoveringText(text, mouseX, mouseY, fontRendererObj); - } - else if (GuiHelper.isInRect(221, 4, 18, 114, mouseX-guiLeft, mouseY-guiTop)){ - text.add(StatCollector.translateToLocal("gui.de.fuelConversion.txt")); - if (reactor.reactorFuel + reactor.convertedFuel > 0) text.add(Utills.round(((double)reactor.convertedFuel + reactor.conversionUnit) / ((double)reactor.convertedFuel + (double)reactor.reactorFuel) * 100D, 100D) + "%"); - text.add(reactor.convertedFuel + " / " + (reactor.convertedFuel + reactor.reactorFuel)); //todo refine or remove - drawHoveringText(text, mouseX, mouseY, fontRendererObj); - } + @Override + public void drawScreen(int mouseX, int mouseY, float par3) { + super.drawScreen(mouseX, mouseY, par3); + List text = new ArrayList(); + if (GuiHelper.isInRect(9, 4, 18, 114, mouseX - guiLeft, mouseY - guiTop)) { + text.add(StatCollector.translateToLocal("gui.de.reactionTemp.txt")); + text.add((int) reactor.reactionTemperature + "C"); + drawHoveringText(text, mouseX, mouseY, fontRendererObj); + } else if (GuiHelper.isInRect(33, 4, 18, 114, mouseX - guiLeft, mouseY - guiTop)) { + text.add(StatCollector.translateToLocal("gui.de.fieldStrength.txt")); + if (reactor.maxFieldCharge > 0) + text.add(Utills.round(reactor.fieldCharge / reactor.maxFieldCharge * 100D, 100D) + "%"); + text.add(Utills.addCommas((int) reactor.fieldCharge) + " / " + Utills.addCommas((int) reactor.maxFieldCharge)); //todo refine or remove + drawHoveringText(text, mouseX, mouseY, fontRendererObj); + } else if (GuiHelper.isInRect(197, 4, 18, 114, mouseX - guiLeft, mouseY - guiTop)) { + text.add(StatCollector.translateToLocal("gui.de.energySaturation.txt")); + if (reactor.maxEnergySaturation > 0) + text.add(Utills.round((double) reactor.energySaturation / (double) reactor.maxEnergySaturation * 100D, 100D) + "%"); + text.add(Utills.addCommas(reactor.energySaturation) + " / " + Utills.addCommas(reactor.maxEnergySaturation)); //todo refine or remove + drawHoveringText(text, mouseX, mouseY, fontRendererObj); + } else if (GuiHelper.isInRect(221, 4, 18, 114, mouseX - guiLeft, mouseY - guiTop)) { + text.add(StatCollector.translateToLocal("gui.de.fuelConversion.txt")); + if (reactor.reactorFuel + reactor.convertedFuel > 0) + text.add(Utills.round(((double) reactor.convertedFuel + reactor.conversionUnit) / ((double) reactor.convertedFuel + (double) reactor.reactorFuel) * 100D, 100D) + "%"); + text.add(reactor.convertedFuel + " / " + (reactor.convertedFuel + reactor.reactorFuel)); //todo refine or remove + drawHoveringText(text, mouseX, mouseY, fontRendererObj); + } - if (showStats) { - if (GuiHelper.isInRect(53, 15, 140, 18, mouseX - guiLeft, mouseY - guiTop)) { - text.addAll(fontRendererObj.listFormattedStringToWidth(StatCollector.translateToLocal("gui.de.reacTempLoadFactor.txt"), 200)); - drawHoveringText(text, mouseX, mouseY, fontRendererObj); - } else if (GuiHelper.isInRect(53, 40, 140, 18, mouseX - guiLeft, mouseY - guiTop)) { - text.addAll(fontRendererObj.listFormattedStringToWidth(StatCollector.translateToLocal("gui.de.reacCoreMass.txt"), 200)); - drawHoveringText(text, mouseX, mouseY, fontRendererObj); - } else if (GuiHelper.isInRect(53, 65, 140, 18, mouseX - guiLeft, mouseY - guiTop)) { - text.addAll(fontRendererObj.listFormattedStringToWidth(StatCollector.translateToLocal("gui.de.reacGenRate.txt"), 200)); - drawHoveringText(text, mouseX, mouseY, fontRendererObj); - } else if (GuiHelper.isInRect(53, 88, 140, 18, mouseX - guiLeft, mouseY - guiTop)) { - text.addAll(fontRendererObj.listFormattedStringToWidth(StatCollector.translateToLocal("gui.de.reacInputRate.txt"), 200)); - drawHoveringText(text, mouseX, mouseY, fontRendererObj); - } else if (GuiHelper.isInRect(53, 113, 140, 18, mouseX - guiLeft, mouseY - guiTop)) { - text.addAll(fontRendererObj.listFormattedStringToWidth(StatCollector.translateToLocal("gui.de.reacConversionRate.txt"), 200)); - drawHoveringText(text, mouseX, mouseY, fontRendererObj); - } - } - } + if (showStats) { + if (GuiHelper.isInRect(53, 15, 140, 18, mouseX - guiLeft, mouseY - guiTop)) { + text.addAll(fontRendererObj.listFormattedStringToWidth(StatCollector.translateToLocal("gui.de.reacTempLoadFactor.txt"), 200)); + drawHoveringText(text, mouseX, mouseY, fontRendererObj); + } else if (GuiHelper.isInRect(53, 40, 140, 18, mouseX - guiLeft, mouseY - guiTop)) { + text.addAll(fontRendererObj.listFormattedStringToWidth(StatCollector.translateToLocal("gui.de.reacCoreMass.txt"), 200)); + drawHoveringText(text, mouseX, mouseY, fontRendererObj); + } else if (GuiHelper.isInRect(53, 65, 140, 18, mouseX - guiLeft, mouseY - guiTop)) { + text.addAll(fontRendererObj.listFormattedStringToWidth(StatCollector.translateToLocal("gui.de.reacGenRate.txt"), 200)); + drawHoveringText(text, mouseX, mouseY, fontRendererObj); + } else if (GuiHelper.isInRect(53, 88, 140, 18, mouseX - guiLeft, mouseY - guiTop)) { + text.addAll(fontRendererObj.listFormattedStringToWidth(StatCollector.translateToLocal("gui.de.reacInputRate.txt"), 200)); + drawHoveringText(text, mouseX, mouseY, fontRendererObj); + } else if (GuiHelper.isInRect(53, 113, 140, 18, mouseX - guiLeft, mouseY - guiTop)) { + text.addAll(fontRendererObj.listFormattedStringToWidth(StatCollector.translateToLocal("gui.de.reacConversionRate.txt"), 200)); + drawHoveringText(text, mouseX, mouseY, fontRendererObj); + } + } + } - private void drawStats(){ + private void drawStats() { - double inputRate = reactor.fieldDrain / (1D - (reactor.fieldCharge / reactor.maxFieldCharge)); - fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.tempLoad.name"), 55, 16, 0x0000FF); - fontRendererObj.drawString(Utills.round(reactor.tempDrainFactor * 100D, 1D) + "%", 60, 2 + 24, 0); - fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.mass.name"), 55, 16 + 24, 0x0000FF); - fontRendererObj.drawString(Utills.round((reactor.reactorFuel + reactor.convertedFuel)/1296D, 100)+"m^3", 60, 2 + 2 * 24, 0); - fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.genRate.name"), 55, 16 + 2 * 24, 0x0000FF); - fontRendererObj.drawString(Utills.addCommas((int)reactor.generationRate)+"RF/t", 60, 2 + 3 * 24, 0); - fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.fieldInputRate.name"), 55, 16 + 3 * 24, 0x0000FF); - fontRendererObj.drawString(Utills.addCommas((int)Math.min(inputRate, Integer.MAX_VALUE))+"RF/t", 60, 2 + 4 * 24, 0); - fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.fuelConversion.name"), 55, 16 + 4 * 24, 0x0000FF); - fontRendererObj.drawString(Utills.addCommas((int)Math.round(reactor.fuelUseRate * 1000000D)) + "nb/t", 60, 2 + 5 * 24, 0); - } + double inputRate = reactor.fieldDrain / (1D - (reactor.fieldCharge / reactor.maxFieldCharge)); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.tempLoad.name"), 55, 16, 0x0000FF); + fontRendererObj.drawString(Utills.round(reactor.tempDrainFactor * 100D, 1D) + "%", 60, 2 + 24, 0); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.mass.name"), 55, 16 + 24, 0x0000FF); + fontRendererObj.drawString(Utills.round((reactor.reactorFuel + reactor.convertedFuel) / 1296D, 100) + "m^3", 60, 2 + 2 * 24, 0); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.genRate.name"), 55, 16 + 2 * 24, 0x0000FF); + fontRendererObj.drawString(Utills.addCommas((int) reactor.generationRate) + "RF/t", 60, 2 + 3 * 24, 0); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.fieldInputRate.name"), 55, 16 + 3 * 24, 0x0000FF); + fontRendererObj.drawString(Utills.addCommas((int) Math.min(inputRate, Integer.MAX_VALUE)) + "RF/t", 60, 2 + 4 * 24, 0); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.fuelConversion.name"), 55, 16 + 4 * 24, 0x0000FF); + fontRendererObj.drawString(Utills.addCommas((int) Math.round(reactor.fuelUseRate * 1000000D)) + "nb/t", 60, 2 + 5 * 24, 0); + } - @Override - public void updateScreen() { + @Override + public void updateScreen() { - if (reactor.reactorState == TileReactorCore.STATE_INVALID || reactor.reactorState == TileReactorCore.STATE_OFFLINE || reactor.reactorState == TileReactorCore.STATE_STOP) collection.getComponent("DEACTIVATE").setEnabled(false); - else collection.getComponent("DEACTIVATE").setEnabled(true); - if ((reactor.reactorState == TileReactorCore.STATE_OFFLINE || (reactor.reactorState == TileReactorCore.STATE_STOP && !reactor.canStart())) && reactor.canCharge()) collection.getComponent("CHARGE").setEnabled(true); - else collection.getComponent("CHARGE").setEnabled(false); - if ((reactor.reactorState == TileReactorCore.STATE_START || reactor.reactorState == TileReactorCore.STATE_STOP) && reactor.canStart()) collection.getComponent("ACTIVATE").setEnabled(true); - else collection.getComponent("ACTIVATE").setEnabled(false); - super.updateScreen(); - } + if (reactor.reactorState == TileReactorCore.STATE_INVALID || reactor.reactorState == TileReactorCore.STATE_OFFLINE || reactor.reactorState == TileReactorCore.STATE_STOP) + collection.getComponent("DEACTIVATE").setEnabled(false); + else collection.getComponent("DEACTIVATE").setEnabled(true); + if ((reactor.reactorState == TileReactorCore.STATE_OFFLINE || (reactor.reactorState == TileReactorCore.STATE_STOP && !reactor.canStart())) && reactor.canCharge()) + collection.getComponent("CHARGE").setEnabled(true); + else collection.getComponent("CHARGE").setEnabled(false); + if ((reactor.reactorState == TileReactorCore.STATE_START || reactor.reactorState == TileReactorCore.STATE_STOP) && reactor.canStart()) + collection.getComponent("ACTIVATE").setEnabled(true); + else collection.getComponent("ACTIVATE").setEnabled(false); + super.updateScreen(); + } - @Override - public void buttonClicked(int id, int button) { - super.buttonClicked(id, button); - if (id < 3) container.sendObjectToServer(null, 20, id); - else if (id == 3){ - showStats = !showStats; - ((ComponentButton)collection.getComponent("STATS")).hoverText = showStats ? StatCollector.translateToLocal("button.de.statsHide.txt") : StatCollector.translateToLocal("button.de.statsShow.txt"); - } + @Override + public void buttonClicked(int id, int button) { + super.buttonClicked(id, button); + if (id < 3) container.sendObjectToServer(null, 20, id); + else if (id == 3) { + showStats = !showStats; + ((ComponentButton) collection.getComponent("STATS")).hoverText = showStats ? StatCollector.translateToLocal("button.de.statsHide.txt") : StatCollector.translateToLocal("button.de.statsShow.txt"); + } - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/GUIToolConfig.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/GUIToolConfig.java index 6b8d68b3..6123af23 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/GUIToolConfig.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/GUIToolConfig.java @@ -33,239 +33,236 @@ import java.util.List; */ public class GUIToolConfig extends GUIBase { - public EntityPlayer player; - private static final ResourceLocation inventoryTexture = new ResourceLocation(References.RESOURCESPREFIX + "textures/gui/ToolConfig.png"); - private int screenLevel = 0; - private ItemStack editingItem; - private ContainerAdvTool container; - private int slot; + public EntityPlayer player; + private static final ResourceLocation inventoryTexture = new ResourceLocation(References.RESOURCESPREFIX + "textures/gui/ToolConfig.png"); + private int screenLevel = 0; + private ItemStack editingItem; + private ContainerAdvTool container; + private int slot; - public GUIToolConfig(EntityPlayer player, ContainerAdvTool container) { - super(container, 198, 89); - this.container = container; - this.player = player; - container.setSlotsActive(false); - addDependentComponents(); - } + public GUIToolConfig(EntityPlayer player, ContainerAdvTool container) { + super(container, 198, 89); + this.container = container; + this.player = player; + container.setSlotsActive(false); + addDependentComponents(); + } - @SuppressWarnings("unchecked") - @Override - public void initGui() { - super.initGui(); - if (ContributorHandler.contributors.containsKey(player.getCommandSenderName())){ - ContributorHandler.Contributor contributor = ContributorHandler.contributors.get(player.getCommandSenderName()); - if (!contributor.isUserValid(player)) return; + @SuppressWarnings("unchecked") + @Override + public void initGui() { + super.initGui(); + if (ContributorHandler.contributors.containsKey(player.getCommandSenderName())) { + ContributorHandler.Contributor contributor = ContributorHandler.contributors.get(player.getCommandSenderName()); + if (!contributor.isUserValid(player)) return; - buttonList.clear(); + buttonList.clear(); - if (contributor.contributionLevel >= 1) buttonList.add(new GuiButton(0, guiLeft - 150, guiTop, 150, 20, "Contributor Wings: " + (contributor.contributorWingsEnabled ? "Enabled" : "Disabled"))); - if (contributor.contribution.toLowerCase().contains("patreon")) buttonList.add(new GuiButton(1, guiLeft - 150, guiTop + 22, 150, 20, "Patreon Badge: " + (contributor.patreonBadgeEnabled ? "Enabled" : "Disabled"))); - } - } + if (contributor.contributionLevel >= 1) + buttonList.add(new GuiButton(0, guiLeft - 150, guiTop, 150, 20, "Contributor Wings: " + (contributor.contributorWingsEnabled ? "Enabled" : "Disabled"))); + if (contributor.contribution.toLowerCase().contains("patreon")) + buttonList.add(new GuiButton(1, guiLeft - 150, guiTop + 22, 150, 20, "Patreon Badge: " + (contributor.patreonBadgeEnabled ? "Enabled" : "Disabled"))); + } + } - @Override - protected void actionPerformed(GuiButton button) { - super.actionPerformed(button); - if (ContributorHandler.contributors.containsKey(player.getCommandSenderName())) { - ContributorHandler.Contributor contributor = ContributorHandler.contributors.get(player.getCommandSenderName()); - if (!contributor.isUserValid(player)) return; + @Override + protected void actionPerformed(GuiButton button) { + super.actionPerformed(button); + if (ContributorHandler.contributors.containsKey(player.getCommandSenderName())) { + ContributorHandler.Contributor contributor = ContributorHandler.contributors.get(player.getCommandSenderName()); + if (!contributor.isUserValid(player)) return; - if (button.id == 0) { - contributor.contributorWingsEnabled = !contributor.contributorWingsEnabled; - button.displayString = "Contributor Wings: " + (contributor.contributorWingsEnabled ? "Enabled" : "Disabled"); - } else if (button.id == 1) { - contributor.patreonBadgeEnabled = !contributor.patreonBadgeEnabled; - button.displayString = "Patreon Badge: " + (contributor.patreonBadgeEnabled ? "Enabled" : "Disabled"); - } + if (button.id == 0) { + contributor.contributorWingsEnabled = !contributor.contributorWingsEnabled; + button.displayString = "Contributor Wings: " + (contributor.contributorWingsEnabled ? "Enabled" : "Disabled"); + } else if (button.id == 1) { + contributor.patreonBadgeEnabled = !contributor.patreonBadgeEnabled; + button.displayString = "Patreon Badge: " + (contributor.patreonBadgeEnabled ? "Enabled" : "Disabled"); + } - DraconicEvolution.network.sendToServer(new ContributorPacket(player.getCommandSenderName(), contributor.contributorWingsEnabled, contributor.patreonBadgeEnabled)); - } + DraconicEvolution.network.sendToServer(new ContributorPacket(player.getCommandSenderName(), contributor.contributorWingsEnabled, contributor.patreonBadgeEnabled)); + } - } + } - @Override - protected ComponentCollection assembleComponents() { - ComponentCollection c = new ComponentCollection(0, 0, xSize, ySize, this).setOpenBoarders(); - c.addComponent(new ComponentTexturedRect(0, -15, 198, 20, inventoryTexture)).setGroup("TEXT_TAB"); - c.addComponent(new ComponentTexturedRect(0, 0, 198, 89, inventoryTexture)).setGroup("BACKGROUND"); - c.addComponent(new ComponentTexturedRect(0, 13, 0, 9, 198, 80, inventoryTexture, false)).setGroup("BACKGROUND_EXTENSION"); - c.addComponent(new ComponentButton(3, 26, 20, 12, 0, this, "<=", StatCollector.translateToLocal("gui.back"))).setGroup("BUTTONS").setName("BACK_BUTTON"); - c.addComponent(new ComponentButton(3, 39, 20, 12, 1, this, "Inv", StatCollector.translateToLocal("gui.de.itemInventory.txt"))).setGroup("BUTTONS").setName("INVENTORY_BUTTON"); - c.addComponent(new ComponentFieldAdjuster(4, 34, null, this)).setGroup("FIELD_BUTTONS").setName("FIELD_CONFIG_BUTTON_ARRAY"); - c.addComponent(new ComponentButton(0, ySize, xSize, 14, 2, this, StatCollector.translateToLocal("gui.de.configureGuiElements.txt")).setGroup("INV_SCREEN")); + @Override + protected ComponentCollection assembleComponents() { + ComponentCollection c = new ComponentCollection(0, 0, xSize, ySize, this).setOpenBoarders(); + c.addComponent(new ComponentTexturedRect(0, -15, 198, 20, inventoryTexture)).setGroup("TEXT_TAB"); + c.addComponent(new ComponentTexturedRect(0, 0, 198, 89, inventoryTexture)).setGroup("BACKGROUND"); + c.addComponent(new ComponentTexturedRect(0, 13, 0, 9, 198, 80, inventoryTexture, false)).setGroup("BACKGROUND_EXTENSION"); + c.addComponent(new ComponentButton(3, 26, 20, 12, 0, this, "<=", StatCollector.translateToLocal("gui.back"))).setGroup("BUTTONS").setName("BACK_BUTTON"); + c.addComponent(new ComponentButton(3, 39, 20, 12, 1, this, "Inv", StatCollector.translateToLocal("gui.de.itemInventory.txt"))).setGroup("BUTTONS").setName("INVENTORY_BUTTON"); + c.addComponent(new ComponentFieldAdjuster(4, 34, null, this)).setGroup("FIELD_BUTTONS").setName("FIELD_CONFIG_BUTTON_ARRAY"); + c.addComponent(new ComponentButton(0, ySize, xSize, 14, 2, this, StatCollector.translateToLocal("gui.de.configureGuiElements.txt")).setGroup("INV_SCREEN")); - ComponentTextField textField = (ComponentTextField) new ComponentTextField(this, 3, -12, 191, 12).setLabel(StatCollector.translateToLocal("gui.de.profile.txt")+":", 0xE0E0E0).setGroup("TEXT_TAB").setName("PROFILE_TEXT_FIELD"); - c.addComponent(textField); - return c; - } + ComponentTextField textField = (ComponentTextField) new ComponentTextField(this, 3, -12, 191, 12).setLabel(StatCollector.translateToLocal("gui.de.profile.txt") + ":", 0xE0E0E0).setGroup("TEXT_TAB").setName("PROFILE_TEXT_FIELD"); + c.addComponent(textField); + return c; + } - protected void addDependentComponents(){ - for (int x = 0; x < 9; x++) { - collection.addComponent(new ComponentConfigItemButton(29 + 18 * x, 64, x, player)).setGroup("INV_SCREEN"); - } + protected void addDependentComponents() { + for (int x = 0; x < 9; x++) { + collection.addComponent(new ComponentConfigItemButton(29 + 18 * x, 64, x, player)).setGroup("INV_SCREEN"); + } - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 9; x++) { - collection.addComponent(new ComponentConfigItemButton(29 + 18 * x, 7 + y * 18, x + y * 9 + 9, player)).setGroup("INV_SCREEN"); - } - } + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + collection.addComponent(new ComponentConfigItemButton(29 + 18 * x, 7 + y * 18, x + y * 9 + 9, player)).setGroup("INV_SCREEN"); + } + } - for (int y = 0; y < 4; y++){ - collection.addComponent(new ComponentConfigItemButton(6, 7 + y * 19, 39 - y, player)).setGroup("INV_SCREEN"); - } + for (int y = 0; y < 4; y++) { + collection.addComponent(new ComponentConfigItemButton(6, 7 + y * 19, 39 - y, player)).setGroup("INV_SCREEN"); + } - setLevel(0); - } + setLevel(0); + } - public void updateItemButtons() { - for (ComponentBase component : collection.getComponents()) - { - if (component instanceof ComponentConfigItemButton) - { - ((ComponentConfigItemButton) component).refreshState(); - } - } - } + public void updateItemButtons() { + for (ComponentBase component : collection.getComponents()) { + if (component instanceof ComponentConfigItemButton) { + ((ComponentConfigItemButton) component).refreshState(); + } + } + } - @Override - protected void mouseClicked(int x, int y, int button) { - super.mouseClicked(x, y, button); + @Override + protected void mouseClicked(int x, int y, int button) { + super.mouseClicked(x, y, button); - if (buttonPressed) return; + if (buttonPressed) return; - int fieldOffsetX = 24; - int fieldOffsetY = 5; + int fieldOffsetX = 24; + int fieldOffsetY = 5; - for (ComponentBase component : collection.getComponents()){ - if (component.isEnabled() && component instanceof ComponentConfigItemButton && component.isMouseOver(x - this.guiLeft, y - this.guiTop) && ((ComponentConfigItemButton) component).hasValidItem){ - ItemStack stack = player.inventory.getStackInSlot(((ComponentConfigItemButton) component).slot); - if (stack == null || !(stack.getItem() instanceof IConfigurableItem)) return; - buttonPressed = true; - IConfigurableItem item = (IConfigurableItem)stack.getItem(); + for (ComponentBase component : collection.getComponents()) { + if (component.isEnabled() && component instanceof ComponentConfigItemButton && component.isMouseOver(x - this.guiLeft, y - this.guiTop) && ((ComponentConfigItemButton) component).hasValidItem) { + ItemStack stack = player.inventory.getStackInSlot(((ComponentConfigItemButton) component).slot); + if (stack == null || !(stack.getItem() instanceof IConfigurableItem)) return; + buttonPressed = true; + IConfigurableItem item = (IConfigurableItem) stack.getItem(); - setEditingItem(stack, ((ComponentConfigItemButton) component).slot); - setLevel(1); - for (ItemConfigField field : item.getFields(stack, ((ComponentConfigItemButton) component).slot)){ - collection.addComponent(new ComponentFieldButton(fieldOffsetX, fieldOffsetY, player, field, this)).setGroup("LIST_SCREEN"); - fieldOffsetY += 12; - } + setEditingItem(stack, ((ComponentConfigItemButton) component).slot); + setLevel(1); + for (ItemConfigField field : item.getFields(stack, ((ComponentConfigItemButton) component).slot)) { + collection.addComponent(new ComponentFieldButton(fieldOffsetX, fieldOffsetY, player, field, this)).setGroup("LIST_SCREEN"); + fieldOffsetY += 12; + } - if (collection.getComponent("PROFILE_TEXT_FIELD") instanceof ComponentTextField) { - int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); - String presetName = ItemNBTHelper.getString(stack, "ProfileName" + preset, "Profile " + preset); - ((ComponentTextField)collection.getComponent("PROFILE_TEXT_FIELD")).textField.setText(presetName); - } + if (collection.getComponent("PROFILE_TEXT_FIELD") instanceof ComponentTextField) { + int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); + String presetName = ItemNBTHelper.getString(stack, "ProfileName" + preset, "Profile " + preset); + ((ComponentTextField) collection.getComponent("PROFILE_TEXT_FIELD")).textField.setText(presetName); + } - collection.addComponent(new ComponentItemRenderer(3, 5, stack)).setGroup("LIST_SCREEN"); - break; - } - } + collection.addComponent(new ComponentItemRenderer(3, 5, stack)).setGroup("LIST_SCREEN"); + break; + } + } - if (collection.getComponent("PROFILE_TEXT_FIELD") instanceof ComponentTextField && !collection.getComponent("PROFILE_TEXT_FIELD").isMouseOver(x- guiLeft, y - guiTop)){ - ((ComponentTextField)collection.getComponent("PROFILE_TEXT_FIELD")).textField.setFocused(false); - } - } + if (collection.getComponent("PROFILE_TEXT_FIELD") instanceof ComponentTextField && !collection.getComponent("PROFILE_TEXT_FIELD").isMouseOver(x - guiLeft, y - guiTop)) { + ((ComponentTextField) collection.getComponent("PROFILE_TEXT_FIELD")).textField.setFocused(false); + } + } - @Override - public void buttonClicked(int id, int button) { - super.buttonClicked(id, button); + @Override + public void buttonClicked(int id, int button) { + super.buttonClicked(id, button); - if (id == 0 && screenLevel > 0){//button back - setLevel(screenLevel - 1); - } - else if (id == 1 && editingItem != null){//inventory button - setLevel(3); - Minecraft.getMinecraft().displayGuiScreen(new GUIToolInventory(player, container, this)); + if (id == 0 && screenLevel > 0) {//button back + setLevel(screenLevel - 1); + } else if (id == 1 && editingItem != null) {//inventory button + setLevel(3); + Minecraft.getMinecraft().displayGuiScreen(new GUIToolInventory(player, container, this)); // LogHelper.info("Pre send container " + Minecraft.getMinecraft().thePlayer.openContainer); // DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_TOOLINVENTORY, false)); - } - else if (id == 2) { - Minecraft.getMinecraft().displayGuiScreen(new GuiHudConfig(this)); - } - } + } else if (id == 2) { + Minecraft.getMinecraft().displayGuiScreen(new GuiHudConfig(this)); + } + } - public void setLevel(int level){ - this.screenLevel = level; + public void setLevel(int level) { + this.screenLevel = level; - if (level == 0){//inv screen - collection.schedulRemoval("LIST_SCREEN"); - collection.setOnlyGroupEnabled("INV_SCREEN"); - collection.setGroupEnabled("BACKGROUND", true); - collection.setComponentEnabled("BACK_BUTTON", false); - slot = -1; - } - else if (level == 1){//list screen - collection.setOnlyGroupEnabled("LIST_SCREEN"); - collection.setGroupEnabled("BACKGROUND", true); - collection.setGroupEnabled("BACKGROUND_EXTENSION", true); - if (editingItem != null && editingItem.getItem() instanceof IConfigurableItem && ((IConfigurableItem)editingItem.getItem()).hasProfiles()) collection.setGroupEnabled("TEXT_TAB", true); - collection.setComponentEnabled("BACK_BUTTON", true); - if (editingItem != null && editingItem.getItem() instanceof IInventoryTool) collection.setComponentEnabled("INVENTORY_BUTTON", true); - if (collection.getComponent("BACK_BUTTON") != null) collection.getComponent("BACK_BUTTON").setY(26); - } - else if (level == 2){//field screen - collection.setOnlyGroupEnabled("FIELD_BUTTONS"); - collection.setGroupEnabled("BACKGROUND", true); - collection.setComponentEnabled("BACK_BUTTON", true); - if (collection.getComponent("BACK_BUTTON") != null) collection.getComponent("BACK_BUTTON").setY(3); + if (level == 0) {//inv screen + collection.schedulRemoval("LIST_SCREEN"); + collection.setOnlyGroupEnabled("INV_SCREEN"); + collection.setGroupEnabled("BACKGROUND", true); + collection.setComponentEnabled("BACK_BUTTON", false); + slot = -1; + } else if (level == 1) {//list screen + collection.setOnlyGroupEnabled("LIST_SCREEN"); + collection.setGroupEnabled("BACKGROUND", true); + collection.setGroupEnabled("BACKGROUND_EXTENSION", true); + if (editingItem != null && editingItem.getItem() instanceof IConfigurableItem && ((IConfigurableItem) editingItem.getItem()).hasProfiles()) + collection.setGroupEnabled("TEXT_TAB", true); + collection.setComponentEnabled("BACK_BUTTON", true); + if (editingItem != null && editingItem.getItem() instanceof IInventoryTool) + collection.setComponentEnabled("INVENTORY_BUTTON", true); + if (collection.getComponent("BACK_BUTTON") != null) collection.getComponent("BACK_BUTTON").setY(26); + } else if (level == 2) {//field screen + collection.setOnlyGroupEnabled("FIELD_BUTTONS"); + collection.setGroupEnabled("BACKGROUND", true); + collection.setComponentEnabled("BACK_BUTTON", true); + if (collection.getComponent("BACK_BUTTON") != null) collection.getComponent("BACK_BUTTON").setY(3); // slot = -1; - } - else if (level == 3){//inventory screen + } else if (level == 3) {//inventory screen - } - } + } + } - public void setFieldBeingEdited(ItemConfigField field){ - ((ComponentFieldAdjuster) collection.getComponent("FIELD_CONFIG_BUTTON_ARRAY")).field = field; - setLevel(2); - } + public void setFieldBeingEdited(ItemConfigField field) { + ((ComponentFieldAdjuster) collection.getComponent("FIELD_CONFIG_BUTTON_ARRAY")).field = field; + setLevel(2); + } - public void setEditingItem(ItemStack stack, int slot) { - this.editingItem = stack; - container.updateInventoryStack(slot); - this.slot = slot; - } + public void setEditingItem(ItemStack stack, int slot) { + this.editingItem = stack; + container.updateInventoryStack(slot); + this.slot = slot; + } - @Override - protected boolean checkHotbarKeys(int p_146983_1_) { - return false; - } + @Override + protected boolean checkHotbarKeys(int p_146983_1_) { + return false; + } - @Override - protected void keyTyped(char par1, int par2) { - if (collection.getComponent("PROFILE_TEXT_FIELD") instanceof ComponentTextField && ((ComponentTextField)collection.getComponent("PROFILE_TEXT_FIELD")).isFocused() && par2 != 1) { - collection.keyTyped(par1, par2); - return; - } - super.keyTyped(par1, par2); - } + @Override + protected void keyTyped(char par1, int par2) { + if (collection.getComponent("PROFILE_TEXT_FIELD") instanceof ComponentTextField && ((ComponentTextField) collection.getComponent("PROFILE_TEXT_FIELD")).isFocused() && par2 != 1) { + collection.keyTyped(par1, par2); + return; + } + super.keyTyped(par1, par2); + } - @Override - public void componentCallBack(ComponentBase component) { - if (component instanceof ComponentTextField && editingItem != null && slot != -1){ - ComponentTextField textField = (ComponentTextField) component; - if (!StringUtils.isNullOrEmpty(textField.textField.getText())){ - DraconicEvolution.network.sendToServer(new ItemConfigPacket(slot, textField.textField.getText())); - } - } - } + @Override + public void componentCallBack(ComponentBase component) { + if (component instanceof ComponentTextField && editingItem != null && slot != -1) { + ComponentTextField textField = (ComponentTextField) component; + if (!StringUtils.isNullOrEmpty(textField.textField.getText())) { + DraconicEvolution.network.sendToServer(new ItemConfigPacket(slot, textField.textField.getText())); + } + } + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - if (slot > -1) editingItem = player.inventory.getStackInSlot(slot); - if (slot > -1 && editingItem != null && editingItem.getUnlocalizedName().toLowerCase().contains("bow")){ - BowHandler.BowProperties properties = new BowHandler.BowProperties(editingItem, player); + if (slot > -1) editingItem = player.inventory.getStackInSlot(slot); + if (slot > -1 && editingItem != null && editingItem.getUnlocalizedName().toLowerCase().contains("bow")) { + BowHandler.BowProperties properties = new BowHandler.BowProperties(editingItem, player); - if (!properties.canFire() && properties.cantFireMessage != null && !properties.cantFireMessage.equals("msg.de.outOfArrows.name")) { - fontRendererObj.drawSplitString(StatCollector.translateToLocal(properties.cantFireMessage), 0, ySize+5, xSize, 0xFF0000); - } + if (!properties.canFire() && properties.cantFireMessage != null && !properties.cantFireMessage.equals("msg.de.outOfArrows.name")) { + fontRendererObj.drawSplitString(StatCollector.translateToLocal(properties.cantFireMessage), 0, ySize + 5, xSize, 0xFF0000); + } - List list = new ArrayList(); - list.add(StatCollector.translateToLocal("gui.de.rfPerShot.txt")+": "+ Utills.addCommas(properties.calculateEnergyCost())); - list.add(StatCollector.translateToLocal("gui.de.maxDamage.txt")+": "+properties.arrowDamage * (properties.arrowSpeed * 3)); - drawHoveringText(list, xSize - 8, 0, fontRendererObj); - } - } + List list = new ArrayList(); + list.add(StatCollector.translateToLocal("gui.de.rfPerShot.txt") + ": " + Utills.addCommas(properties.calculateEnergyCost())); + list.add(StatCollector.translateToLocal("gui.de.maxDamage.txt") + ": " + properties.arrowDamage * (properties.arrowSpeed * 3)); + drawHoveringText(list, xSize - 8, 0, fontRendererObj); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/GUIToolInventory.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/GUIToolInventory.java index f34fc059..af7f6002 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/GUIToolInventory.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/GUIToolInventory.java @@ -13,68 +13,69 @@ import org.lwjgl.opengl.GL11; */ public class GUIToolInventory extends GUIBase { - private static final ResourceLocation inventoryTexture = new ResourceLocation(References.RESOURCESPREFIX + "textures/gui/ToolConfig.png"); + private static final ResourceLocation inventoryTexture = new ResourceLocation(References.RESOURCESPREFIX + "textures/gui/ToolConfig.png"); - private ContainerAdvTool container; - private String inventoryName; - private EntityPlayer player; - private GUIToolConfig guiToolConfig; + private ContainerAdvTool container; + private String inventoryName; + private EntityPlayer player; + private GUIToolConfig guiToolConfig; - public GUIToolInventory(EntityPlayer player, ContainerAdvTool container) { - super(container, 198, 130); - this.container = container; - this.container.setSlotsActive(true); - this.inventoryName = container.inventoryTool.getInventoryName(); - this.player = player; - addDependentComponents(); - } + public GUIToolInventory(EntityPlayer player, ContainerAdvTool container) { + super(container, 198, 130); + this.container = container; + this.container.setSlotsActive(true); + this.inventoryName = container.inventoryTool.getInventoryName(); + this.player = player; + addDependentComponents(); + } - public GUIToolInventory(EntityPlayer player, ContainerAdvTool container, GUIToolConfig guiToolConfig) { - this(player, container); - this.guiToolConfig = guiToolConfig; - } + public GUIToolInventory(EntityPlayer player, ContainerAdvTool container, GUIToolConfig guiToolConfig) { + this(player, container); + this.guiToolConfig = guiToolConfig; + } - @Override - protected ComponentCollection assembleComponents() { - ComponentCollection c = new ComponentCollection(0, 0, xSize, ySize, this); - c.addComponent(new ComponentTexturedRect(0, 130 - 89, 198, 89, inventoryTexture)).setGroup("BACKGROUND"); - c.addComponent(new ComponentTexturedRect(0, 0, 198, 80, inventoryTexture)).setGroup("BACKGROUND"); - c.addComponent(new ComponentButton(172, 3, 18, 12, 0, this, "<=", "Back")); + @Override + protected ComponentCollection assembleComponents() { + ComponentCollection c = new ComponentCollection(0, 0, xSize, ySize, this); + c.addComponent(new ComponentTexturedRect(0, 130 - 89, 198, 89, inventoryTexture)).setGroup("BACKGROUND"); + c.addComponent(new ComponentTexturedRect(0, 0, 198, 80, inventoryTexture)).setGroup("BACKGROUND"); + c.addComponent(new ComponentButton(172, 3, 18, 12, 0, this, "<=", "Back")); - for (int i = 0; i < 5; i++) - { - c.addComponent(new ComponentSlotBackground(172, 18 + i * 21)).setGroup("INVENTORY"); - c.addComponent(new ComponentTexturedRect(173, 20 + i * 21, 0, 89, 16, 14, inventoryTexture, true)).setGroup("INVENTORY"); - } - return c; - } + for (int i = 0; i < 5; i++) { + c.addComponent(new ComponentSlotBackground(172, 18 + i * 21)).setGroup("INVENTORY"); + c.addComponent(new ComponentTexturedRect(173, 20 + i * 21, 0, 89, 16, 14, inventoryTexture, true)).setGroup("INVENTORY"); + } + return c; + } - @Override - public void buttonClicked(int id, int button) { - super.buttonClicked(id, button); - if (guiToolConfig == null) guiToolConfig = new GUIToolConfig(player, container); - guiToolConfig.updateItemButtons(); - Minecraft.getMinecraft().displayGuiScreen(guiToolConfig); - guiToolConfig.setLevel(1); - container.setSlotsActive(false); - } + @Override + public void buttonClicked(int id, int button) { + super.buttonClicked(id, button); + if (guiToolConfig == null) guiToolConfig = new GUIToolConfig(player, container); + guiToolConfig.updateItemButtons(); + Minecraft.getMinecraft().displayGuiScreen(guiToolConfig); + guiToolConfig.setLevel(1); + container.setSlotsActive(false); + } - @Override - protected void addDependentComponents() { - for (int x = 0; x < container.inventoryTool.size; x++) collection.addComponent(new ComponentSlotBackground(7 + x * 18, 18)).setGroup("INVENTORY"); - ComponentSlotBackground.addInventorySlots(collection, 7, 44, container.inventoryItemSlot); - if (container.inventoryItemSlot > 35) collection.addComponent(new ComponentItemRenderer(6, 18, container.inventoryTool.inventoryItem)).setGroup("INVENTORY"); - } + @Override + protected void addDependentComponents() { + for (int x = 0; x < container.inventoryTool.size; x++) + collection.addComponent(new ComponentSlotBackground(7 + x * 18, 18)).setGroup("INVENTORY"); + ComponentSlotBackground.addInventorySlots(collection, 7, 44, container.inventoryItemSlot); + if (container.inventoryItemSlot > 35) + collection.addComponent(new ComponentItemRenderer(6, 18, container.inventoryTool.inventoryItem)).setGroup("INVENTORY"); + } - @Override - protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); - GL11.glColor3f(1f, 1f, 1f); - fontRendererObj.drawString(inventoryName, guiLeft + 5, guiTop + 5, 0x555555); - } + @Override + protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + GL11.glColor3f(1f, 1f, 1f); + fontRendererObj.drawString(inventoryName, guiLeft + 5, guiTop + 5, 0x555555); + } - @Override - protected boolean checkHotbarKeys(int p_146983_1_) { - return false; - } + @Override + protected boolean checkHotbarKeys(int p_146983_1_) { + return false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/ManualPage.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/ManualPage.java index 5ab40485..92a01a47 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/ManualPage.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/componentguis/ManualPage.java @@ -9,48 +9,44 @@ import org.apache.commons.io.FilenameUtils; */ public class ManualPage { - public String name; - public String nameL; - public int meta; - public String[] imageURLs; - public String[] content; - public int scrollOffset = 0; + public String name; + public String nameL; + public int meta; + public String[] imageURLs; + public String[] content; + public int scrollOffset = 0; - public ManualPage(String name, String[] imageURLs, String[] content) - { - this.name = name; - this.imageURLs = imageURLs; - this.content = content; - } + public ManualPage(String name, String[] imageURLs, String[] content) { + this.name = name; + this.imageURLs = imageURLs; + this.content = content; + } - public ManualPage(String name, String[] imageURLs, String[] content, String nameL, int meta) - { - this(name, imageURLs, content); - this.nameL = nameL; - this.meta = meta; - } + public ManualPage(String name, String[] imageURLs, String[] content, String nameL, int meta) { + this(name, imageURLs, content); + this.nameL = nameL; + this.meta = meta; + } - public String getImageResourceName(String url) - { + public String getImageResourceName(String url) { // try // { - LogHelper.info(url); - return FilenameUtils.getName(url); - //String fileName = new URL(url).getFile(); - //return fileName.substring(fileName.indexOf("/") + 1); + LogHelper.info(url); + return FilenameUtils.getName(url); + //String fileName = new URL(url).getFile(); + //return fileName.substring(fileName.indexOf("/") + 1); // } // catch (MalformedURLException e) // { // e.printStackTrace(); // return ""; // } - } + } - public String getLocalizedName() - { - if (nameL != null) return nameL; - return (name.contains("item.") || name.contains("tile.")) ? StatCollector.translateToLocal(name + ".name") : name.contains("info.") ? name.substring(name.indexOf("info.") + 5) : "Invalid Name Data"; - } + public String getLocalizedName() { + if (nameL != null) return nameL; + return (name.contains("item.") || name.contains("tile.")) ? StatCollector.translateToLocal(name + ".name") : name.contains("info.") ? name.substring(name.indexOf("info.") + 5) : "Invalid Name Data"; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentConfigItemButton.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentConfigItemButton.java index 9f6f04d8..bdf46f39 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentConfigItemButton.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentConfigItemButton.java @@ -19,67 +19,66 @@ import java.util.List; */ public class ComponentConfigItemButton extends ComponentBase { - private static final ResourceLocation texture = new ResourceLocation(References.RESOURCESPREFIX + "textures/gui/Widgets.png"); - public int slot; - private InventoryPlayer inventory; - public boolean hasValidItem = false; + private static final ResourceLocation texture = new ResourceLocation(References.RESOURCESPREFIX + "textures/gui/Widgets.png"); + public int slot; + private InventoryPlayer inventory; + public boolean hasValidItem = false; - public ComponentConfigItemButton(int x, int y, int slot, EntityPlayer player) { - super(x, y); - this.slot = slot; - this.inventory = player.inventory; - refreshState(); - } + public ComponentConfigItemButton(int x, int y, int slot, EntityPlayer player) { + super(x, y); + this.slot = slot; + this.inventory = player.inventory; + refreshState(); + } - public void refreshState() - { - hasValidItem = (inventory.getStackInSlot(slot) != null && ((inventory.getStackInSlot(slot).getItem() instanceof IConfigurableItem && !((IConfigurableItem) inventory.getStackInSlot(slot).getItem()).getFields(inventory.getStackInSlot(slot), slot).isEmpty()) || inventory.getStackInSlot(slot).getItem() instanceof IInventoryTool)); - } + public void refreshState() { + hasValidItem = (inventory.getStackInSlot(slot) != null && ((inventory.getStackInSlot(slot).getItem() instanceof IConfigurableItem && !((IConfigurableItem) inventory.getStackInSlot(slot).getItem()).getFields(inventory.getStackInSlot(slot), slot).isEmpty()) || inventory.getStackInSlot(slot).getItem() instanceof IInventoryTool)); + } - @Override - public int getWidth() { - return 18; - } + @Override + public int getWidth() { + return 18; + } - @Override - public int getHeight() { - return 18; - } + @Override + public int getHeight() { + return 18; + } - @Override - public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - int heightOffset = isMouseOver(mouseX, mouseY) ? 36 : 18; - if (!hasValidItem)drawTexturedModalRect(x, y, 0, 0, getWidth(), getHeight()); - else drawTexturedModalRect(x, y, 0, heightOffset, getWidth(), getHeight()); + @Override + public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + int heightOffset = isMouseOver(mouseX, mouseY) ? 36 : 18; + if (!hasValidItem) drawTexturedModalRect(x, y, 0, 0, getWidth(), getHeight()); + else drawTexturedModalRect(x, y, 0, heightOffset, getWidth(), getHeight()); - if (inventory.getStackInSlot(slot) != null){ - drawItemStack(inventory.getStackInSlot(slot), x+1, y+1, "null"); - } - } + if (inventory.getStackInSlot(slot) != null) { + drawItemStack(inventory.getStackInSlot(slot), x + 1, y + 1, "null"); + } + } - @Override - public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + @Override + public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - } + } - @Override - public void renderFinal(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - if (isMouseOver(mouseX, mouseY) && hasValidItem){ - List list = new ArrayList(); - List fields = ((IConfigurableItem)inventory.getStackInSlot(slot).getItem()).getFields(inventory.getStackInSlot(slot), slot); - for (ItemConfigField field : fields) { - list.add(field.getLocalizedName() + ": " + field.getFormattedValue()); + @Override + public void renderFinal(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + if (isMouseOver(mouseX, mouseY) && hasValidItem) { + List list = new ArrayList(); + List fields = ((IConfigurableItem) inventory.getStackInSlot(slot).getItem()).getFields(inventory.getStackInSlot(slot), slot); + for (ItemConfigField field : fields) { + list.add(field.getLocalizedName() + ": " + field.getFormattedValue()); - } - drawHoveringText(list, mouseX + offsetX, mouseY + offsetY + 10, fontRendererObj); - } - } + } + drawHoveringText(list, mouseX + offsetX, mouseY + offsetY + 10, fontRendererObj); + } + } - @Override - public void mouseClicked(int x, int y, int button) { - if (hasValidItem){ - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); - } - } + @Override + public void mouseClicked(int x, int y, int button) { + if (hasValidItem) { + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentContributorsPage.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentContributorsPage.java index 2b38e530..1043235f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentContributorsPage.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentContributorsPage.java @@ -28,176 +28,177 @@ import java.util.Map; */ public class ComponentContributorsPage extends ComponentScrollingBase implements GuiYesNoCallback { - public int scrollOffset = 0; - public int pageLength = 0; - public int scrollLimit = 0; + public int scrollOffset = 0; + public int pageLength = 0; + public int scrollLimit = 0; - public ComponentContributorsPage(int x, int y, GUIScrollingBase gui) { - super(x, y, gui); - pageLength = 55; - pageLength += ContributorHandler.contributors.size() * 30; - scrollLimit = pageLength - 325; - } + public ComponentContributorsPage(int x, int y, GUIScrollingBase gui) { + super(x, y, gui); + pageLength = 55; + pageLength += ContributorHandler.contributors.size() * 30; + scrollLimit = pageLength - 325; + } - @Override - public void handleScrollInput(int direction) { - // page.scrollOffset += direction * 10; - scrollOffset += direction * (InfoHelper.isShiftKeyDown() ? 30 : 10); - if (scrollOffset < 0) scrollOffset = 0; - if (scrollOffset > pageLength - getHeight()) scrollOffset = pageLength - getHeight(); - if (pageLength <= getHeight()) scrollOffset = 0; + @Override + public void handleScrollInput(int direction) { + // page.scrollOffset += direction * 10; + scrollOffset += direction * (InfoHelper.isShiftKeyDown() ? 30 : 10); + if (scrollOffset < 0) scrollOffset = 0; + if (scrollOffset > pageLength - getHeight()) scrollOffset = pageLength - getHeight(); + if (pageLength <= getHeight()) scrollOffset = 0; - } + } - @Override - public int getWidth() { - return gui.getXSize(); - } + @Override + public int getWidth() { + return gui.getXSize(); + } - @Override - public int getHeight() { - return gui.getYSize(); - } + @Override + public int getHeight() { + return gui.getYSize(); + } - @Override - public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - int yOffset = -scrollOffset; + @Override + public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + int yOffset = -scrollOffset; - yOffset += 20; + yOffset += 20; - if (yOffset > 0) { - drawCenteredString(fontRendererObj, StatCollector.translateToLocal("info.de.manual.contributors.txt"), getWidth()/2, yOffset, 0x00FFFF); - } + if (yOffset > 0) { + drawCenteredString(fontRendererObj, StatCollector.translateToLocal("info.de.manual.contributors.txt"), getWidth() / 2, yOffset, 0x00FFFF); + } - yOffset += 10; + yOffset += 10; - boolean patreonButtonHighlighted = mouseX >= 140 && mouseY >= 290; + boolean patreonButtonHighlighted = mouseX >= 140 && mouseY >= 290; - for (Contributor contributor : ContributorHandler.contributors.values()){ - if (!StringUtils.isNullOrEmpty(contributor.details) && contributor.details.contains("[UNLISTED]")) continue; - yOffset += 30; + for (Contributor contributor : ContributorHandler.contributors.values()) { + if (!StringUtils.isNullOrEmpty(contributor.details) && contributor.details.contains("[UNLISTED]")) continue; + yOffset += 30; - if (!(yOffset > 25 && yOffset < 324)) continue; + if (!(yOffset > 25 && yOffset < 324)) continue; - if (mouseX > 15 && mouseX < 245 && mouseY < yOffset+5 && mouseY > yOffset - 25 && !patreonButtonHighlighted){ - ResourceHandler.bindResource("textures/gui/manualTop.png"); - GL11.glEnable(GL11.GL_BLEND); - GL11.glColor4f(0F, 0F, 0F, 0.4F); - drawTexturedModalRect(15, yOffset - 26, 20, 20, 226, 30); - GL11.glDisable(GL11.GL_BLEND); - } + if (mouseX > 15 && mouseX < 245 && mouseY < yOffset + 5 && mouseY > yOffset - 25 && !patreonButtonHighlighted) { + ResourceHandler.bindResource("textures/gui/manualTop.png"); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(0F, 0F, 0F, 0.4F); + drawTexturedModalRect(15, yOffset - 26, 20, 20, 226, 30); + GL11.glDisable(GL11.GL_BLEND); + } - GL11.glPushMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glTranslated(30, yOffset, 0); - GL11.glScaled(100, 100, 100); - renderPlayer(contributor.ign); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glTranslated(30, yOffset, 0); + GL11.glScaled(100, 100, 100); + renderPlayer(contributor.ign); + GL11.glPopMatrix(); - fontRendererObj.drawStringWithShadow(EnumChatFormatting.GOLD + contributor.name, 50, yOffset-20, 0x000000); - fontRendererObj.drawString(EnumChatFormatting.DARK_BLUE + contributor.contribution, 50, yOffset-10, 0x000000); - } - } + fontRendererObj.drawStringWithShadow(EnumChatFormatting.GOLD + contributor.name, 50, yOffset - 20, 0x000000); + fontRendererObj.drawString(EnumChatFormatting.DARK_BLUE + contributor.contribution, 50, yOffset - 10, 0x000000); + } + } - @Override - public void renderFinal(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - int yOffset = -scrollOffset + 30; + @Override + public void renderFinal(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + int yOffset = -scrollOffset + 30; - boolean patreonButtonHighlighted = mouseX >= 140 && mouseY >= 290; + boolean patreonButtonHighlighted = mouseX >= 140 && mouseY >= 290; - for (Contributor contributor : ContributorHandler.contributors.values()){ - if (!StringUtils.isNullOrEmpty(contributor.details) && contributor.details.contains("[UNLISTED]")) continue; - yOffset += 30; + for (Contributor contributor : ContributorHandler.contributors.values()) { + if (!StringUtils.isNullOrEmpty(contributor.details) && contributor.details.contains("[UNLISTED]")) continue; + yOffset += 30; - if (!(yOffset > 20 && yOffset < 330)) continue; + if (!(yOffset > 20 && yOffset < 330)) continue; - if (mouseX > 15 && mouseX < 245 && mouseY < yOffset+5 && mouseY > yOffset - 25 && !patreonButtonHighlighted){ - List list = new ArrayList(); - list.add(EnumChatFormatting.GOLD+contributor.contribution); + if (mouseX > 15 && mouseX < 245 && mouseY < yOffset + 5 && mouseY > yOffset - 25 && !patreonButtonHighlighted) { + List list = new ArrayList(); + list.add(EnumChatFormatting.GOLD + contributor.contribution); - if (!StringUtils.isNullOrEmpty(contributor.details)) - { - list.add(""); - List l = fontRendererObj.listFormattedStringToWidth(contributor.details, 247); - for (Object o : l) list.add(EnumChatFormatting.DARK_PURPLE + (String) o); - } + if (!StringUtils.isNullOrEmpty(contributor.details)) { + list.add(""); + List l = fontRendererObj.listFormattedStringToWidth(contributor.details, 247); + for (Object o : l) list.add(EnumChatFormatting.DARK_PURPLE + (String) o); + } - if (!contributor.name.equals(contributor.ign)){ - list.add(""); - list.add(EnumChatFormatting.BLUE+"IGN: "+EnumChatFormatting.GOLD+contributor.ign); - } + if (!contributor.name.equals(contributor.ign)) { + list.add(""); + list.add(EnumChatFormatting.BLUE + "IGN: " + EnumChatFormatting.GOLD + contributor.ign); + } - if (!StringUtils.isNullOrEmpty(contributor.website)) - { - list.add(""); - list.add("Website: "+EnumChatFormatting.BLUE+contributor.website); - list.add(EnumChatFormatting.GRAY+StatCollector.translateToLocal("info.de.manual.clickToGoToSite.txt")); - } + if (!StringUtils.isNullOrEmpty(contributor.website)) { + list.add(""); + list.add("Website: " + EnumChatFormatting.BLUE + contributor.website); + list.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("info.de.manual.clickToGoToSite.txt")); + } - drawHoveringText(list, offsetX - 7, offsetY + yOffset + 20, fontRendererObj); - } - } + drawHoveringText(list, offsetX - 7, offsetY + yOffset + 20, fontRendererObj); + } + } - if (!ContributorHandler.successfulLoad) fontRendererObj.drawString("[Error] Failed to download contributors list", offsetX+20, offsetY+40, 0xFF0000); - } + if (!ContributorHandler.successfulLoad) + fontRendererObj.drawString("[Error] Failed to download contributors list", offsetX + 20, offsetY + 40, 0xFF0000); + } - @Override - public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + @Override + public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - } + } - private String lastClickURL = ""; - @Override - public void mouseClicked(int x, int y, int button) { - super.mouseClicked(x, y, button); + private String lastClickURL = ""; - int yOffset = -scrollOffset + 30; + @Override + public void mouseClicked(int x, int y, int button) { + super.mouseClicked(x, y, button); - boolean patreonButtonHighlighted = x >= 140 && y >= 290; + int yOffset = -scrollOffset + 30; - for (Contributor contributor : ContributorHandler.contributors.values()){ - if (!StringUtils.isNullOrEmpty(contributor.details) && contributor.details.contains("[UNLISTED]")) continue; - yOffset += 30; + boolean patreonButtonHighlighted = x >= 140 && y >= 290; - if (!(yOffset > 20 && yOffset < 330) || patreonButtonHighlighted) continue; + for (Contributor contributor : ContributorHandler.contributors.values()) { + if (!StringUtils.isNullOrEmpty(contributor.details) && contributor.details.contains("[UNLISTED]")) continue; + yOffset += 30; - if (x > 15 && x < 245 && y < yOffset+5 && y > yOffset - 25 && !StringUtils.isNullOrEmpty(contributor.website)){ - lastClickURL = contributor.website; - mc.displayGuiScreen(new GuiConfirmOpenLink(this, contributor.website, 0, true)); - } - } - } + if (!(yOffset > 20 && yOffset < 330) || patreonButtonHighlighted) continue; - @Override - public void confirmClicked(boolean confirmed, int button) { - mc.displayGuiScreen(this.gui); - if (confirmed) ClientUtills.openLink(lastClickURL); - } + if (x > 15 && x < 245 && y < yOffset + 5 && y > yOffset - 25 && !StringUtils.isNullOrEmpty(contributor.website)) { + lastClickURL = contributor.website; + mc.displayGuiScreen(new GuiConfirmOpenLink(this, contributor.website, 0, true)); + } + } + } - private static ModelBiped modelBiped = new ModelBiped(0.0265F); - private static void renderPlayer(String username){ - ResourceHandler.bindTexture(getSkin(username)); - modelBiped.bipedHead.render(0.0265F); - modelBiped.bipedHeadwear.render(0.0265F); - } + @Override + public void confirmClicked(boolean confirmed, int button) { + mc.displayGuiScreen(this.gui); + if (confirmed) ClientUtills.openLink(lastClickURL); + } - private static Map skinCache = new HashMap(); - private static boolean skinCashInitialized = false; + private static ModelBiped modelBiped = new ModelBiped(0.0265F); - private static ResourceLocation getSkin(String username){ - if (!skinCashInitialized){ - for (Contributor contributor : ContributorHandler.contributors.values()) - { - if (!StringUtils.isNullOrEmpty(contributor.details) && contributor.details.contains("[UNLISTED]")) continue; - ResourceLocation skin = AbstractClientPlayer.getLocationSkin(contributor.ign); - AbstractClientPlayer.getDownloadImageSkin(skin, contributor.ign); - skinCache.put(contributor.ign, skin); - } - skinCashInitialized = true; - } + private static void renderPlayer(String username) { + ResourceHandler.bindTexture(getSkin(username)); + modelBiped.bipedHead.render(0.0265F); + modelBiped.bipedHeadwear.render(0.0265F); + } - if (!skinCache.containsKey(username)) return AbstractClientPlayer.locationStevePng; - return skinCache.get(username); - } + private static Map skinCache = new HashMap(); + private static boolean skinCashInitialized = false; + + private static ResourceLocation getSkin(String username) { + if (!skinCashInitialized) { + for (Contributor contributor : ContributorHandler.contributors.values()) { + if (!StringUtils.isNullOrEmpty(contributor.details) && contributor.details.contains("[UNLISTED]")) + continue; + ResourceLocation skin = AbstractClientPlayer.getLocationSkin(contributor.ign); + AbstractClientPlayer.getDownloadImageSkin(skin, contributor.ign); + skinCache.put(contributor.ign, skin); + } + skinCashInitialized = true; + } + + if (!skinCache.containsKey(username)) return AbstractClientPlayer.locationStevePng; + return skinCache.get(username); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentFieldAdjuster.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentFieldAdjuster.java index 7fdcb29f..d4d49220 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentFieldAdjuster.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentFieldAdjuster.java @@ -17,191 +17,187 @@ import net.minecraft.util.StatCollector; * Created by Brandon on 1/01/2015. */ public class ComponentFieldAdjuster extends ComponentBase { - private static final ResourceLocation widgets = new ResourceLocation(References.RESOURCESPREFIX + "textures/gui/Widgets.png"); - protected static final ResourceLocation buttonTextures = new ResourceLocation("textures/gui/widgets.png"); + private static final ResourceLocation widgets = new ResourceLocation(References.RESOURCESPREFIX + "textures/gui/Widgets.png"); + protected static final ResourceLocation buttonTextures = new ResourceLocation("textures/gui/widgets.png"); - public ItemConfigField field; - public GUIToolConfig gui; + public ItemConfigField field; + public GUIToolConfig gui; - public ComponentFieldAdjuster(int x, int y, ItemConfigField field, GUIToolConfig gui) { - super(x, y); - this.field = field; - this.gui = gui; - } + public ComponentFieldAdjuster(int x, int y, ItemConfigField field, GUIToolConfig gui) { + super(x, y); + this.field = field; + this.gui = gui; + } - @Override - public int getWidth() { - return 190; - } + @Override + public int getWidth() { + return 190; + } - @Override - public int getHeight() { - return 20; - } + @Override + public int getHeight() { + return 20; + } - @Override - public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - if (field == null) return; - minecraft.getTextureManager().bindTexture(buttonTextures); + @Override + public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + if (field == null) return; + minecraft.getTextureManager().bindTexture(buttonTextures); - if (isBoolean()) - { - renderButton((getWidth() / 2) - 30, 0, 60, 20, GuiHelper.isInRect(x + (getWidth() / 2) - 30, y, 60, 20, mouseX - offsetX, mouseY - offsetY)); - }else if (isDecimal() || isNonDecimal()) - { - renderButton((getWidth() / 2) - 43, 3, 24, 14, GuiHelper.isInRect(x + (getWidth() / 2) - 43, y + 3, 24, 14, mouseX - offsetX, mouseY - offsetY)); - renderButton((getWidth() / 2) - 69, 3, 24, 14, GuiHelper.isInRect(x + (getWidth() / 2) - 69, y + 3, 24, 14, mouseX - offsetX, mouseY - offsetY)); - renderButton((getWidth() / 2) - 95, 3, 24, 14, GuiHelper.isInRect(x + (getWidth() / 2) - 95, y + 3, 24, 14, mouseX - offsetX, mouseY - offsetY)); + if (isBoolean()) { + renderButton((getWidth() / 2) - 30, 0, 60, 20, GuiHelper.isInRect(x + (getWidth() / 2) - 30, y, 60, 20, mouseX - offsetX, mouseY - offsetY)); + } else if (isDecimal() || isNonDecimal()) { + renderButton((getWidth() / 2) - 43, 3, 24, 14, GuiHelper.isInRect(x + (getWidth() / 2) - 43, y + 3, 24, 14, mouseX - offsetX, mouseY - offsetY)); + renderButton((getWidth() / 2) - 69, 3, 24, 14, GuiHelper.isInRect(x + (getWidth() / 2) - 69, y + 3, 24, 14, mouseX - offsetX, mouseY - offsetY)); + renderButton((getWidth() / 2) - 95, 3, 24, 14, GuiHelper.isInRect(x + (getWidth() / 2) - 95, y + 3, 24, 14, mouseX - offsetX, mouseY - offsetY)); - renderButton((getWidth() / 2) + 19, 3, 24, 14, GuiHelper.isInRect(x + (getWidth() / 2) + 19, y + 3, 24, 14, mouseX - offsetX, mouseY - offsetY)); - renderButton((getWidth() / 2) + 45, 3, 24, 14, GuiHelper.isInRect(x + (getWidth() / 2) + 45, y + 3, 24, 14, mouseX - offsetX, mouseY - offsetY)); - renderButton((getWidth() / 2) + 71, 3, 24, 14, GuiHelper.isInRect(x + (getWidth() / 2) + 71, y + 3, 24, 14, mouseX - offsetX, mouseY - offsetY)); - } - } + renderButton((getWidth() / 2) + 19, 3, 24, 14, GuiHelper.isInRect(x + (getWidth() / 2) + 19, y + 3, 24, 14, mouseX - offsetX, mouseY - offsetY)); + renderButton((getWidth() / 2) + 45, 3, 24, 14, GuiHelper.isInRect(x + (getWidth() / 2) + 45, y + 3, 24, 14, mouseX - offsetX, mouseY - offsetY)); + renderButton((getWidth() / 2) + 71, 3, 24, 14, GuiHelper.isInRect(x + (getWidth() / 2) + 71, y + 3, 24, 14, mouseX - offsetX, mouseY - offsetY)); + } + } - @Override - public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - if (field == null) return; - String fieldName = field.getLocalizedName(); - String fieldValue = field.getFormattedValue(); - if (field.datatype == References.DOUBLE_ID) { - double d = (Double)field.value; - fieldValue = String.valueOf((double)Math.round(d*100f) / 100D); - } - //if (field.datatype == References.FLOAT_ID) { - // float d = (Float)field.value; - // fieldValue = String.valueOf((double)Math.round((double)(d*100f)) / 100D); - //} + @Override + public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + if (field == null) return; + String fieldName = field.getLocalizedName(); + String fieldValue = field.getFormattedValue(); + if (field.datatype == References.DOUBLE_ID) { + double d = (Double) field.value; + fieldValue = String.valueOf((double) Math.round(d * 100f) / 100D); + } + //if (field.datatype == References.FLOAT_ID) { + // float d = (Float)field.value; + // fieldValue = String.valueOf((double)Math.round((double)(d*100f)) / 100D); + //} - int centre = fontRendererObj.getStringWidth(fieldName) / 2; - fontRendererObj.drawString(fieldName, x + getWidth() / 2 - centre, y - 12, 0x00000); - drawCenteredString(fontRendererObj, fieldValue, x + getWidth() / 2, y + 6, 0xffffff); - if (field.modifier == null || field.modifier.equals("AOE"))drawCenteredString(fontRendererObj, StatCollector.translateToLocal("gui.de.max.txt") + " " + field.getMaxFormattedValue(), x + getWidth() / 2, y + 20, 0xFFFFFF); + int centre = fontRendererObj.getStringWidth(fieldName) / 2; + fontRendererObj.drawString(fieldName, x + getWidth() / 2 - centre, y - 12, 0x00000); + drawCenteredString(fontRendererObj, fieldValue, x + getWidth() / 2, y + 6, 0xffffff); + if (field.modifier == null || field.modifier.equals("AOE")) + drawCenteredString(fontRendererObj, StatCollector.translateToLocal("gui.de.max.txt") + " " + field.getMaxFormattedValue(), x + getWidth() / 2, y + 20, 0xFFFFFF); - if (isDecimal() || isNonDecimal()) - { - fontRendererObj.drawString("---", 7, y + 6, 0x000000); - fontRendererObj.drawString("--", 37, y + 6, 0x000000); - fontRendererObj.drawString("-", 66, y + 6, 0x000000); - fontRendererObj.drawString("+", 127, y + 6, 0x000000); - fontRendererObj.drawString("++", 151, y + 6, 0x000000); - fontRendererObj.drawString("+++", 174, y + 6, 0x000000); + if (isDecimal() || isNonDecimal()) { + fontRendererObj.drawString("---", 7, y + 6, 0x000000); + fontRendererObj.drawString("--", 37, y + 6, 0x000000); + fontRendererObj.drawString("-", 66, y + 6, 0x000000); + fontRendererObj.drawString("+", 127, y + 6, 0x000000); + fontRendererObj.drawString("++", 151, y + 6, 0x000000); + fontRendererObj.drawString("+++", 174, y + 6, 0x000000); - } - } + } + } - @Override - public void renderFinal(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - if (field == null) return; - } + @Override + public void renderFinal(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + if (field == null) return; + } - @Override - public void mouseClicked(int x, int y, int button) { - if (field == null) return; + @Override + public void mouseClicked(int x, int y, int button) { + if (field == null) return; - if (!isBoolean()) - { - if (GuiHelper.isInRect(this.x + (getWidth() / 2) - 43, this.y + 3, 26, 14, x, y)) - {//- - incroment(-1); - } else if (GuiHelper.isInRect(this.x + (getWidth() / 2) - 69, this.y + 3, 26, 14, x, y)) - {//-- - incroment(-10); - } else if (GuiHelper.isInRect(this.x + (getWidth() / 2) - 95, this.y + 3, 26, 14, x, y)) - {//--- - incroment(-100); - } else if (GuiHelper.isInRect(this.x + (getWidth() / 2) + 19, this.y + 3, 26, 14, x, y)) - {//+ - incroment(1); - } else if (GuiHelper.isInRect(this.x + (getWidth() / 2) + 45, this.y + 3, 26, 14, x, y)) - {//++ - incroment(10); - } else if (GuiHelper.isInRect(this.x + (getWidth() / 2) + 71, this.y + 3, 26, 14, x, y)) - {//+++ - incroment(100); - } - } - else if (GuiHelper.isInRect(this.x + (getWidth() / 2) - 30, this.y, 60, 20, x, y)){ - incroment(1); - } - } + if (!isBoolean()) { + if (GuiHelper.isInRect(this.x + (getWidth() / 2) - 43, this.y + 3, 26, 14, x, y)) {//- + incroment(-1); + } else if (GuiHelper.isInRect(this.x + (getWidth() / 2) - 69, this.y + 3, 26, 14, x, y)) {//-- + incroment(-10); + } else if (GuiHelper.isInRect(this.x + (getWidth() / 2) - 95, this.y + 3, 26, 14, x, y)) {//--- + incroment(-100); + } else if (GuiHelper.isInRect(this.x + (getWidth() / 2) + 19, this.y + 3, 26, 14, x, y)) {//+ + incroment(1); + } else if (GuiHelper.isInRect(this.x + (getWidth() / 2) + 45, this.y + 3, 26, 14, x, y)) {//++ + incroment(10); + } else if (GuiHelper.isInRect(this.x + (getWidth() / 2) + 71, this.y + 3, 26, 14, x, y)) {//+++ + incroment(100); + } + } else if (GuiHelper.isInRect(this.x + (getWidth() / 2) - 30, this.y, 60, 20, x, y)) { + incroment(1); + } + } - private void incroment(int multiplyer){ - switch (field.datatype){ - case References.BYTE_ID: - byte b = (Byte)field.value; - b += (Byte)field.incroment * (byte)multiplyer; - if (b > (Byte)field.max) b = (Byte) field.max; - if (b < (Byte)field.min) b = (Byte) field.min; - field.value = b; - break; - case References.SHORT_ID: - short s = (Short)field.value; - s += (Short)field.incroment * (short)multiplyer; - if (s > (Short)field.max) s = (Short) field.max; - if (s < (Short)field.min) s = (Short) field.min; - field.value = s; - break; - case References.INT_ID: - int i = (Integer)field.value; - i += (Integer)field.incroment * multiplyer; - if (i > (Integer)field.max) i = (Integer) field.max; - if (i < (Integer)field.min) i = (Integer) field.min; - field.value = i; - break; - case References.LONG_ID: - long l = (Long)field.value; - l += (Long)field.incroment * (long)multiplyer; - if (l > (Long)field.max) l = (Long) field.max; - if (l < (Long)field.min) l = (Long) field.min; - field.value = l; - break; - case References.FLOAT_ID: - float f = (Float)field.value; - f += (Float)field.incroment * (float)multiplyer; - f *= 100F; - f = Math.round(f); - f /= 100F; - if (f > (Float)field.max) f = (Float) field.max; - if (f < (Float)field.min) f = (Float) field.min; - field.value = f; - break; - case References.DOUBLE_ID: - double d = (Double)field.value; - d += (Double)field.incroment * (double)multiplyer; - if (d > (Double)field.max) d = (Double) field.max; - if (d < (Double)field.min) d = (Double) field.min; - field.value = d; - break; - case References.BOOLEAN_ID: - field.value = !(Boolean)field.value; - break; - } - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); - ItemStack stack = gui.player.inventory.getStackInSlot(field.slot); - if (stack != null && stack.getItem() instanceof IConfigurableItem){ - DataUtills.writeObjectToCompound(IConfigurableItem.ProfileHelper.getProfileCompound(stack), field.value, field.datatype, field.name); - } - field.sendChanges(); - } + private void incroment(int multiplyer) { + switch (field.datatype) { + case References.BYTE_ID: + byte b = (Byte) field.value; + b += (Byte) field.incroment * (byte) multiplyer; + if (b > (Byte) field.max) b = (Byte) field.max; + if (b < (Byte) field.min) b = (Byte) field.min; + field.value = b; + break; + case References.SHORT_ID: + short s = (Short) field.value; + s += (Short) field.incroment * (short) multiplyer; + if (s > (Short) field.max) s = (Short) field.max; + if (s < (Short) field.min) s = (Short) field.min; + field.value = s; + break; + case References.INT_ID: + int i = (Integer) field.value; + i += (Integer) field.incroment * multiplyer; + if (i > (Integer) field.max) i = (Integer) field.max; + if (i < (Integer) field.min) i = (Integer) field.min; + field.value = i; + break; + case References.LONG_ID: + long l = (Long) field.value; + l += (Long) field.incroment * (long) multiplyer; + if (l > (Long) field.max) l = (Long) field.max; + if (l < (Long) field.min) l = (Long) field.min; + field.value = l; + break; + case References.FLOAT_ID: + float f = (Float) field.value; + f += (Float) field.incroment * (float) multiplyer; + f *= 100F; + f = Math.round(f); + f /= 100F; + if (f > (Float) field.max) f = (Float) field.max; + if (f < (Float) field.min) f = (Float) field.min; + field.value = f; + break; + case References.DOUBLE_ID: + double d = (Double) field.value; + d += (Double) field.incroment * (double) multiplyer; + if (d > (Double) field.max) d = (Double) field.max; + if (d < (Double) field.min) d = (Double) field.min; + field.value = d; + break; + case References.BOOLEAN_ID: + field.value = !(Boolean) field.value; + break; + } + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + ItemStack stack = gui.player.inventory.getStackInSlot(field.slot); + if (stack != null && stack.getItem() instanceof IConfigurableItem) { + DataUtills.writeObjectToCompound(IConfigurableItem.ProfileHelper.getProfileCompound(stack), field.value, field.datatype, field.name); + } + field.sendChanges(); + } - public void renderButton(int offsetX, int offsetY, int xSize, int ySize, boolean highlighted){ - int k = highlighted ? 2 : 1; - int x = this.x + offsetX; - int y = this.y + offsetY; + public void renderButton(int offsetX, int offsetY, int xSize, int ySize, boolean highlighted) { + int k = highlighted ? 2 : 1; + int x = this.x + offsetX; + int y = this.y + offsetY; - this.drawTexturedModalRect(x, y, 0, 46 + k * 20, xSize /2, 20 - Math.max(0, 20 - ySize)); - this.drawTexturedModalRect(x + xSize / 2, y, 200 - xSize / 2, 46 + k * 20, xSize / 2, 20 - Math.max(0, 20-ySize)); + this.drawTexturedModalRect(x, y, 0, 46 + k * 20, xSize / 2, 20 - Math.max(0, 20 - ySize)); + this.drawTexturedModalRect(x + xSize / 2, y, 200 - xSize / 2, 46 + k * 20, xSize / 2, 20 - Math.max(0, 20 - ySize)); - if (ySize < 20){ - this.drawTexturedModalRect(x, y+3, 0, (46 + k * 20)+20-ySize+3, xSize -1, ySize-3); - this.drawTexturedModalRect(x + xSize / 2, y+3, 200 - xSize / 2, (46 + k * 20)+20-ySize+3, xSize / 2, ySize-3); - } - } + if (ySize < 20) { + this.drawTexturedModalRect(x, y + 3, 0, (46 + k * 20) + 20 - ySize + 3, xSize - 1, ySize - 3); + this.drawTexturedModalRect(x + xSize / 2, y + 3, 200 - xSize / 2, (46 + k * 20) + 20 - ySize + 3, xSize / 2, ySize - 3); + } + } - private boolean isBoolean(){ return field.datatype == References.BOOLEAN_ID; } + private boolean isBoolean() { + return field.datatype == References.BOOLEAN_ID; + } - private boolean isNonDecimal(){ return field.datatype == References.INT_ID || field.datatype == References.SHORT_ID || field.datatype == References.BYTE_ID; } + private boolean isNonDecimal() { + return field.datatype == References.INT_ID || field.datatype == References.SHORT_ID || field.datatype == References.BYTE_ID; + } - private boolean isDecimal(){ return field.datatype == References.FLOAT_ID || field.datatype == References.DOUBLE_ID; } + private boolean isDecimal() { + return field.datatype == References.FLOAT_ID || field.datatype == References.DOUBLE_ID; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentFieldButton.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentFieldButton.java index a36fb916..3fd2486e 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentFieldButton.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentFieldButton.java @@ -20,82 +20,79 @@ import java.util.List; */ public class ComponentFieldButton extends ComponentBase { - private static final ResourceLocation widgets = new ResourceLocation(References.RESOURCESPREFIX + "textures/gui/Widgets.png"); + private static final ResourceLocation widgets = new ResourceLocation(References.RESOURCESPREFIX + "textures/gui/Widgets.png"); - public EntityPlayer player; - public int slot; - public ItemStack stack; - public ItemConfigField field; - public GUIToolConfig gui; + public EntityPlayer player; + public int slot; + public ItemStack stack; + public ItemConfigField field; + public GUIToolConfig gui; - public ComponentFieldButton(int x, int y, EntityPlayer player, ItemConfigField field, GUIToolConfig gui) { - super(x, y); - this.player = player; - this.slot = field.slot; - this.stack = player.inventory.getStackInSlot(slot); - this.field = field; - this.gui = gui; - } + public ComponentFieldButton(int x, int y, EntityPlayer player, ItemConfigField field, GUIToolConfig gui) { + super(x, y); + this.player = player; + this.slot = field.slot; + this.stack = player.inventory.getStackInSlot(slot); + this.field = field; + this.gui = gui; + } - @Override - public int getWidth() { - return 150; - } + @Override + public int getWidth() { + return 150; + } - @Override - public int getHeight() { - return 12; - } + @Override + public int getHeight() { + return 12; + } - @Override - public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - Minecraft.getMinecraft().renderEngine.bindTexture(widgets); + @Override + public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + Minecraft.getMinecraft().renderEngine.bindTexture(widgets); - if (!isMouseOver(mouseX - offsetX, mouseY - offsetY)) - { - drawTexturedModalRect(x, y, 18, 0, getWidth() - 50, getHeight()); - drawTexturedModalRect(x, y+getHeight()-1, 18, 19, getWidth() - 50, 1); + if (!isMouseOver(mouseX - offsetX, mouseY - offsetY)) { + drawTexturedModalRect(x, y, 18, 0, getWidth() - 50, getHeight()); + drawTexturedModalRect(x, y + getHeight() - 1, 18, 19, getWidth() - 50, 1); - drawTexturedModalRect(x + 50, y, 19, 0, getWidth() - 50 - 1, getHeight()); - drawTexturedModalRect(x + 50, y+getHeight()-1, 19, 19, getWidth() - 50 - 1, 1); - } - else - { - drawTexturedModalRect(x, y, 18, 20, getWidth() - 50, getHeight()); - drawTexturedModalRect(x, y + getHeight() - 1, 18, 39, getWidth() - 50, 1); + drawTexturedModalRect(x + 50, y, 19, 0, getWidth() - 50 - 1, getHeight()); + drawTexturedModalRect(x + 50, y + getHeight() - 1, 19, 19, getWidth() - 50 - 1, 1); + } else { + drawTexturedModalRect(x, y, 18, 20, getWidth() - 50, getHeight()); + drawTexturedModalRect(x, y + getHeight() - 1, 18, 39, getWidth() - 50, 1); - drawTexturedModalRect(x + 50, y, 19, 20, getWidth() - 50 - 1, getHeight()); - drawTexturedModalRect(x + 50, y+getHeight()-1, 19, 39, getWidth() - 50 - 1, 1); - } - } + drawTexturedModalRect(x + 50, y, 19, 20, getWidth() - 50 - 1, getHeight()); + drawTexturedModalRect(x + 50, y + getHeight() - 1, 19, 39, getWidth() - 50 - 1, 1); + } + } - @Override - public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - drawString(fontRendererObj, field.getLocalizedName(), x + offsetX + 2, y + offsetY + (getHeight() / 2) - (fontRendererObj.FONT_HEIGHT / 2), 0xffffff); - } + @Override + public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + drawString(fontRendererObj, field.getLocalizedName(), x + offsetX + 2, y + offsetY + (getHeight() / 2) - (fontRendererObj.FONT_HEIGHT / 2), 0xffffff); + } - @SuppressWarnings("unchecked") - @Override - public void renderFinal(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - if (isMouseOver(mouseX, mouseY)) { - List list = new ArrayList(); - list.add(field.getFormattedValue()); - drawHoveringText(list, mouseX + offsetX, mouseY + offsetY + 10, fontRendererObj); - } - } + @SuppressWarnings("unchecked") + @Override + public void renderFinal(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + if (isMouseOver(mouseX, mouseY)) { + List list = new ArrayList(); + list.add(field.getFormattedValue()); + drawHoveringText(list, mouseX + offsetX, mouseY + offsetY + 10, fontRendererObj); + } + } - @Override - public void mouseClicked(int x, int y, int button) { - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); - if (field.datatype == References.BOOLEAN_ID){ - field.value = !(Boolean) field.value; - field.sendChanges(); - ItemStack stack = gui.player.inventory.getStackInSlot(field.slot); - if (stack != null && stack.getItem() instanceof IConfigurableItem){ - DataUtills.writeObjectToCompound(IConfigurableItem.ProfileHelper.getProfileCompound(stack), field.value, field.datatype, field.name); - } - return; - } - gui.setFieldBeingEdited(field); - } + @Override + public void mouseClicked(int x, int y, int button) { + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + if (field.datatype == References.BOOLEAN_ID) { + field.value = !(Boolean) field.value; + field.sendChanges(); + ItemStack stack = gui.player.inventory.getStackInSlot(field.slot); + if (stack != null && stack.getItem() instanceof IConfigurableItem) { + DataUtills.writeObjectToCompound(IConfigurableItem.ProfileHelper.getProfileCompound(stack), field.value, field.datatype, field.name); + } + return; + } + gui.setFieldBeingEdited(field); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentIndexButton.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentIndexButton.java index 8c852563..a37598c3 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentIndexButton.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentIndexButton.java @@ -15,66 +15,62 @@ import org.lwjgl.opengl.GL11; */ public class ComponentIndexButton extends ComponentScrollingBase { - private ManualPage page; - private ItemStack stack; + private ManualPage page; + private ItemStack stack; - public ComponentIndexButton(int x, int y, GUIScrollingBase gui, ManualPage page) { - super(x, y, gui); - this.page = page; - stack = Utills.getStackFromName(page.name, page.meta); - } + public ComponentIndexButton(int x, int y, GUIScrollingBase gui, ManualPage page) { + super(x, y, gui); + this.page = page; + stack = Utills.getStackFromName(page.name, page.meta); + } - @Override - public void handleScrollInput(int direction) { - //this.y += direction * 10; - } + @Override + public void handleScrollInput(int direction) { + //this.y += direction * 10; + } - @Override - public int getWidth() { - return 200; - } + @Override + public int getWidth() { + return 200; + } - @Override - public int getHeight() { - return 20; - } + @Override + public int getHeight() { + return 20; + } - @Override - public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - if (isOnScreen()) - { - int sy = y - gui.scrollOffset; - boolean mouseOver = isMouseOver(mouseX, mouseY); + @Override + public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + if (isOnScreen()) { + int sy = y - gui.scrollOffset; + boolean mouseOver = isMouseOver(mouseX, mouseY); - fontRendererObj.drawString(page.getLocalizedName(), x + 19, sy, mouseOver ? 0xdd00ff : 0x000000); - ResourceHandler.bindResource("textures/gui/Widgets.png"); + fontRendererObj.drawString(page.getLocalizedName(), x + 19, sy, mouseOver ? 0xdd00ff : 0x000000); + ResourceHandler.bindResource("textures/gui/Widgets.png"); + GL11.glColor4f(1f, 1f, 1f, 1f); + if (mouseOver) { + GL11.glColor4f(0f, 1f, 1f, 1f); + drawTexturedModalRect(x - 2, sy - 2, 118, 0, 20, 20); + } else drawTexturedModalRect(x - 1, sy - 1, 138, 0, 18, 18); - GL11.glColor4f(1f, 1f, 1f, 1f); - if (mouseOver) { - GL11.glColor4f(0f, 1f, 1f, 1f); - drawTexturedModalRect(x - 2, sy - 2, 118, 0, 20, 20); - } - else drawTexturedModalRect(x-1, sy-1, 138, 0, 18, 18); + if (stack != null && stack.getItem() != null) drawItemStack(stack, x, sy, ""); + else drawItemStack(new ItemStack(Items.writable_book), x, sy, ""); - if (stack != null && stack.getItem() != null) drawItemStack(stack, x, sy, ""); - else drawItemStack(new ItemStack(Items.writable_book), x, sy, ""); + } + } - } - } + public boolean isOnScreen() { + int sy = y - gui.scrollOffset; + return sy > 1 && sy + getHeight() < gui.getYSize(); + } - public boolean isOnScreen() - { - int sy = y - gui.scrollOffset; - return sy > 1 && sy + getHeight() < gui.getYSize(); - } + @Override + public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + } - @Override - public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - } - - public ManualPage getPage() { - return page; - } + public ManualPage getPage() { + return page; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentManualPage.java b/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentManualPage.java index d4e7cfcd..7bc0d5d6 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentManualPage.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/gui/guicomponents/ComponentManualPage.java @@ -28,426 +28,393 @@ import java.util.Map; * Created by Brandon on 19/03/2015. */ public class ComponentManualPage extends ComponentScrollingBase { - public ManualPage page; - public List contentList = new ArrayList(); - private int pageLength = 0; - ItemStack stack = null; - private int slideTick = 0; + public ManualPage page; + public List contentList = new ArrayList(); + private int pageLength = 0; + ItemStack stack = null; + private int slideTick = 0; - public int scrollOffset = 0; - public int scrollLimit = 0; + public int scrollOffset = 0; + public int scrollLimit = 0; - public ComponentManualPage(int x, int y, GUIScrollingBase gui, ManualPage page) { - super(x, y, gui); - this.page = page; - pageLength = 25; - stack = Utills.getStackFromName(page.name, page.meta); - ContentComponent title = new ContentComponent("title." + page.getLocalizedName(), pageLength, this); - pageLength += title.getHeight(); - contentList.add(title); - for (String s : page.content) - { - ContentComponent c = new ContentComponent(s, pageLength, this); - pageLength += c.getHeight(); - contentList.add(c); - } - pageLength += 25; + public ComponentManualPage(int x, int y, GUIScrollingBase gui, ManualPage page) { + super(x, y, gui); + this.page = page; + pageLength = 25; + stack = Utills.getStackFromName(page.name, page.meta); + ContentComponent title = new ContentComponent("title." + page.getLocalizedName(), pageLength, this); + pageLength += title.getHeight(); + contentList.add(title); + for (String s : page.content) { + ContentComponent c = new ContentComponent(s, pageLength, this); + pageLength += c.getHeight(); + contentList.add(c); + } + pageLength += 25; - scrollLimit = pageLength - 325; - } + scrollLimit = pageLength - 325; + } - @Override - public void handleScrollInput(int direction) { - // scrollOffset += direction * 10; - scrollOffset += direction * (InfoHelper.isShiftKeyDown() ? 30 : 10); - if (scrollOffset < 0) scrollOffset = 0; - if (scrollOffset > pageLength - getHeight()) scrollOffset = pageLength - getHeight(); - if (pageLength <= getHeight()) scrollOffset = 0; - } + @Override + public void handleScrollInput(int direction) { + // scrollOffset += direction * 10; + scrollOffset += direction * (InfoHelper.isShiftKeyDown() ? 30 : 10); + if (scrollOffset < 0) scrollOffset = 0; + if (scrollOffset > pageLength - getHeight()) scrollOffset = pageLength - getHeight(); + if (pageLength <= getHeight()) scrollOffset = 0; + } - @Override - public int getWidth() { - return gui.getXSize(); - } + @Override + public int getWidth() { + return gui.getXSize(); + } - @Override - public int getHeight() { - return gui.getYSize(); - } + @Override + public int getHeight() { + return gui.getYSize(); + } - @Override - public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + @Override + public void renderBackground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - for (ContentComponent c : contentList) - { - c.render(mouseX, mouseY); - } - } + for (ContentComponent c : contentList) { + c.render(mouseX, mouseY); + } + } - @Override - public void renderFinal(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - } + @Override + public void renderFinal(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + } - @Override - public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + @Override + public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { - } + } - @Override - public void updateScreen() { - super.updateScreen(); - if (!InfoHelper.isShiftKeyDown()) slideTick++; - } + @Override + public void updateScreen() { + super.updateScreen(); + if (!InfoHelper.isShiftKeyDown()) slideTick++; + } - private static class ContentComponent { + private static class ContentComponent { - private String content; - /**0 = text, 1 = image, 2 = crafting*/ - private int type; - public int yPos; - private ComponentManualPage page; - private String[] textLines; - private List recipes = new ArrayList(); - private List smeltingRecipes = new ArrayList(); - private ItemStack result; - private boolean isTitle = false; - private boolean slide = false; - private List slides = new ArrayList(); + private String content; + /** + * 0 = text, 1 = image, 2 = crafting + */ + private int type; + public int yPos; + private ComponentManualPage page; + private String[] textLines; + private List recipes = new ArrayList(); + private List smeltingRecipes = new ArrayList(); + private ItemStack result; + private boolean isTitle = false; + private boolean slide = false; + private List slides = new ArrayList(); - public ContentComponent(String content, int y, ComponentManualPage page) - { - this.content = content; - this.yPos = y; - this.page = page; - init(); - } + public ContentComponent(String content, int y, ComponentManualPage page) { + this.content = content; + this.yPos = y; + this.page = page; + init(); + } - public void init() - { - isTitle = content != null && content.contains("title."); + public void init() { + isTitle = content != null && content.contains("title."); - type = content.contains(".png") ? 1 : content.contains("[c]") ? 2 : 0; + type = content.contains(".png") ? 1 : content.contains("[c]") ? 2 : 0; - slide = (type == 1) && content.contains("[>]"); - if (slide) - { - String s = content; - while (s.contains("[>]")) - { - slides.add(s.substring(0, s.indexOf("[>]"))); - s = s.substring(s.indexOf("[>]") + 3); - } - slides.add(s); - } + slide = (type == 1) && content.contains("[>]"); + if (slide) { + String s = content; + while (s.contains("[>]")) { + slides.add(s.substring(0, s.indexOf("[>]"))); + s = s.substring(s.indexOf("[>]") + 3); + } + slides.add(s); + } - if (type == 0) { - List l = page.fontRendererObj.listFormattedStringToWidth(content, 220); - List sl = new ArrayList(); - for (String st : l) - { - String s = st; - while (s.contains("\\n")) - { - String s2 = s.substring(0, s.indexOf("\\n")); - s = s.substring(s.indexOf("\\n") + 2); - sl.add(s2); - } - sl.add(s); - } - textLines = sl.toArray(new String[sl.size()]); - } - else if (type == 2) - { - String s = content.substring(content.indexOf("[c]") + 3); - String name = s.substring(0, s.lastIndexOf(":")); - ItemStack stack = Utills.getStackFromName(name, Integer.parseInt(s.substring(s.lastIndexOf(":") + 1))); - result = stack; + if (type == 0) { + List l = page.fontRendererObj.listFormattedStringToWidth(content, 220); + List sl = new ArrayList(); + for (String st : l) { + String s = st; + while (s.contains("\\n")) { + String s2 = s.substring(0, s.indexOf("\\n")); + s = s.substring(s.indexOf("\\n") + 2); + sl.add(s2); + } + sl.add(s); + } + textLines = sl.toArray(new String[sl.size()]); + } else if (type == 2) { + String s = content.substring(content.indexOf("[c]") + 3); + String name = s.substring(0, s.lastIndexOf(":")); + ItemStack stack = Utills.getStackFromName(name, Integer.parseInt(s.substring(s.lastIndexOf(":") + 1))); + result = stack; - if (stack != null) - { + if (stack != null) { - for (IRecipe recipe : (List) CraftingManager.getInstance().getRecipeList()) - { - if (recipe == null) continue; + for (IRecipe recipe : (List) CraftingManager.getInstance().getRecipeList()) { + if (recipe == null) continue; - ItemStack result = recipe.getRecipeOutput(); - if (result == null || !result.isItemEqual(stack)) continue; + ItemStack result = recipe.getRecipeOutput(); + if (result == null || !result.isItemEqual(stack)) continue; - Object[] input = getRecipeInput(recipe); - if (input == null) continue; + Object[] input = getRecipeInput(recipe); + if (input == null) continue; - recipes.add(recipe); - } + recipes.add(recipe); + } - Iterator iterator = FurnaceRecipes.smelting().getSmeltingList().entrySet().iterator(); - Map.Entry entry; + Iterator iterator = FurnaceRecipes.smelting().getSmeltingList().entrySet().iterator(); + Map.Entry entry; - while (iterator.hasNext()) - { - entry = (Map.Entry) iterator.next(); - if (entry.getKey() instanceof ItemStack && ((ItemStack) entry.getValue()).isItemEqual(stack)) - { - smeltingRecipes.add((ItemStack) entry.getKey()); - } - } - } - } - else textLines = null; - } + while (iterator.hasNext()) { + entry = (Map.Entry) iterator.next(); + if (entry.getKey() instanceof ItemStack && ((ItemStack) entry.getValue()).isItemEqual(stack)) { + smeltingRecipes.add((ItemStack) entry.getKey()); + } + } + } + } else textLines = null; + } - public int getHeight() - { - if (type == 1 && (ResourceHandler.downloadedImages.containsKey(FilenameUtils.getName(content)) || (slide && ResourceHandler.downloadedImages.containsKey(FilenameUtils.getName(content))))) - { - CustomResourceLocation texture = slide ? ResourceHandler.downloadedImages.get(FilenameUtils.getName(content)) : ResourceHandler.downloadedImages.get(FilenameUtils.getName(content)); - return (int)((double)texture.getHeight() / (double)texture.getWidth() * 220D) + 5; - } - else if (type == 2) - { - return (recipes.size() + smeltingRecipes.size()) * 57; - } + public int getHeight() { + if (type == 1 && (ResourceHandler.downloadedImages.containsKey(FilenameUtils.getName(content)) || (slide && ResourceHandler.downloadedImages.containsKey(FilenameUtils.getName(content))))) { + CustomResourceLocation texture = slide ? ResourceHandler.downloadedImages.get(FilenameUtils.getName(content)) : ResourceHandler.downloadedImages.get(FilenameUtils.getName(content)); + return (int) ((double) texture.getHeight() / (double) texture.getWidth() * 220D) + 5; + } else if (type == 2) { + return (recipes.size() + smeltingRecipes.size()) * 57; + } - return ((textLines != null ? textLines.length * 10 : 10) + 5) + ((isTitle && (page.page.name.contains("tile.") || page.page.name.contains("item."))) ? 18 : 0); - } + return ((textLines != null ? textLines.length * 10 : 10) + 5) + ((isTitle && (page.page.name.contains("tile.") || page.page.name.contains("item."))) ? 18 : 0); + } - public void render(int mouseX, int mouseY) - { - if (type == 1) { - renderImage(); - return; - } - else if (type == 2) - { - renderCrafting(mouseX, mouseY); - return; - } - else if (isTitle) - { - int y = yPos - page.scrollOffset; - if (y > 310 || y < 5) return; - page.drawCenteredString(page.fontRendererObj, content.substring(content.indexOf("title.") + 6), 128, y, 0x00ffff); + public void render(int mouseX, int mouseY) { + if (type == 1) { + renderImage(); + return; + } else if (type == 2) { + renderCrafting(mouseX, mouseY); + return; + } else if (isTitle) { + int y = yPos - page.scrollOffset; + if (y > 310 || y < 5) return; + page.drawCenteredString(page.fontRendererObj, content.substring(content.indexOf("title.") + 6), 128, y, 0x00ffff); - if ((page.page.name.contains("tile.") || page.page.name.contains("item.")) && page.stack != null) - { - ResourceHandler.bindResource("textures/gui/Widgets.png"); - GL11.glColor4f(0.5F, 0.5F, 0.5F, 1F); - page.drawTexturedModalRect(119, y + 11, 138, 0, 18, 18); - page.drawItemStack(page.stack, 120, 12 + y, ""); - } - } - else if (textLines != null) - { - for (int i = 0; i < textLines.length; i++) - { - int y = (yPos + i * 10) - page.scrollOffset; - if (y > 310 || y < 5) continue; - page.fontRendererObj.drawString(textLines[i], 20, y, 0x000000); - } - } - } + if ((page.page.name.contains("tile.") || page.page.name.contains("item.")) && page.stack != null) { + ResourceHandler.bindResource("textures/gui/Widgets.png"); + GL11.glColor4f(0.5F, 0.5F, 0.5F, 1F); + page.drawTexturedModalRect(119, y + 11, 138, 0, 18, 18); + page.drawItemStack(page.stack, 120, 12 + y, ""); + } + } else if (textLines != null) { + for (int i = 0; i < textLines.length; i++) { + int y = (yPos + i * 10) - page.scrollOffset; + if (y > 310 || y < 5) continue; + page.fontRendererObj.drawString(textLines[i], 20, y, 0x000000); + } + } + } - private void renderImage() - { - CustomResourceLocation image = null;//slide ? ResourceHandler.downloadedImages.get(slides.get(page.slideTick % slides.size() - 1)) : ResourceHandler.downloadedImages.get(content); - if (slide) - { - int index = (page.slideTick / 20) % (slides.size()); - image = (slides.size() > index) ? ResourceHandler.downloadedImages.get(FilenameUtils.getName(slides.get(index))) : null; - } - else if (ResourceHandler.downloadedImages.containsKey(FilenameUtils.getName(content))) { - image = ResourceHandler.downloadedImages.get(FilenameUtils.getName(content)); - } + private void renderImage() { + CustomResourceLocation image = null;//slide ? ResourceHandler.downloadedImages.get(slides.get(page.slideTick % slides.size() - 1)) : ResourceHandler.downloadedImages.get(content); + if (slide) { + int index = (page.slideTick / 20) % (slides.size()); + image = (slides.size() > index) ? ResourceHandler.downloadedImages.get(FilenameUtils.getName(slides.get(index))) : null; + } else if (ResourceHandler.downloadedImages.containsKey(FilenameUtils.getName(content))) { + image = ResourceHandler.downloadedImages.get(FilenameUtils.getName(content)); + } - if (image != null) - { - //CustomResourceLocation image = ResourceHandler.downloadedImages.get(content); - image.bind(); - Tessellator tess = Tessellator.instance; + if (image != null) { + //CustomResourceLocation image = ResourceHandler.downloadedImages.get(content); + image.bind(); + Tessellator tess = Tessellator.instance; - double ySize = (double)image.getHeight() / (double)image.getWidth() * 220D; + double ySize = (double) image.getHeight() / (double) image.getWidth() * 220D; - double topS = 0; - if ((yPos - page.scrollOffset) < 0) { - topS = (yPos - 5 - page.scrollOffset); - } - double btmS = 0; - if ((yPos - page.scrollOffset) + ySize > 310) { - btmS = (yPos - 5 - page.scrollOffset) - 310 + ySize; - } + double topS = 0; + if ((yPos - page.scrollOffset) < 0) { + topS = (yPos - 5 - page.scrollOffset); + } + double btmS = 0; + if ((yPos - page.scrollOffset) + ySize > 310) { + btmS = (yPos - 5 - page.scrollOffset) - 310 + ySize; + } - double xmin = 17.5D ; - double xmax = 17.5D + 220D ; - double ymin = yPos - page.scrollOffset - topS; - double ymax = yPos + ySize - page.scrollOffset - btmS; + double xmin = 17.5D; + double xmax = 17.5D + 220D; + double ymin = yPos - page.scrollOffset - topS; + double ymax = yPos + ySize - page.scrollOffset - btmS; - double vmin = Math.max(0D, topS / -ySize); - double vmax = Math.min(1D, 1D - btmS / ySize); + double vmin = Math.max(0D, topS / -ySize); + double vmax = Math.min(1D, 1D - btmS / ySize); - tess.startDrawingQuads(); - tess.setColorRGBA_F(1f, 1f, 1f, 1f); + tess.startDrawingQuads(); + tess.setColorRGBA_F(1f, 1f, 1f, 1f); - tess.addVertexWithUV(xmin, ymin, 0, 0, vmin); - tess.addVertexWithUV(xmin, ymax, 0, 0, vmax); - tess.addVertexWithUV(xmax, ymax, 0, 1, vmax); - tess.addVertexWithUV(xmax, ymin, 0, 1, vmin); + tess.addVertexWithUV(xmin, ymin, 0, 0, vmin); + tess.addVertexWithUV(xmin, ymax, 0, 0, vmax); + tess.addVertexWithUV(xmax, ymax, 0, 1, vmax); + tess.addVertexWithUV(xmax, ymin, 0, 1, vmin); - tess.draw(); + tess.draw(); - if (slide && (int)ymax - 10 < 305 && (int)ymax - 10 > 0 && !InfoHelper.isShiftKeyDown()) page.fontRendererObj.drawString(page.ttl("info.de.shiftToPause.txt"), 20, (int)ymax - 8, 0xff0000); - } - } + if (slide && (int) ymax - 10 < 305 && (int) ymax - 10 > 0 && !InfoHelper.isShiftKeyDown()) + page.fontRendererObj.drawString(page.ttl("info.de.shiftToPause.txt"), 20, (int) ymax - 8, 0xff0000); + } + } - private void renderCrafting(int mouseX, int mouseY) - { - if (result == null) return; - ResourceHandler.bindResource("textures/gui/Widgets.png"); - GL11.glColor4f(1f, 1f, 1f, 1f); - int posX = 70; - int posY = yPos - page.scrollOffset; + private void renderCrafting(int mouseX, int mouseY) { + if (result == null) return; + ResourceHandler.bindResource("textures/gui/Widgets.png"); + GL11.glColor4f(1f, 1f, 1f, 1f); + int posX = 70; + int posY = yPos - page.scrollOffset; - for (IRecipe recipe : recipes) - { - int index = recipes.indexOf(recipe); + for (IRecipe recipe : recipes) { + int index = recipes.indexOf(recipe); - int yDown = index * 57; - for (int i = 0; i < 9; i++) - { - int x = i % 3 * 18; - int y = i / 3 * 18; + int yDown = index * 57; + for (int i = 0; i < 9; i++) { + int x = i % 3 * 18; + int y = i / 3 * 18; - if (y + yDown + posY < 0 || y + yDown + posY > 305) continue; - page.drawTexturedModalRect(x + posX, y + yDown + posY, 138, 0, 18, 18); - ItemStack stack = (ItemStack)(getRecipeInput(recipe).length > i && getRecipeInput(recipe)[i] instanceof ItemStack ? getRecipeInput(recipe)[i] : getRecipeInput(recipe).length > i && getRecipeInput(recipe)[i] instanceof ArrayList ? ((ArrayList) getRecipeInput(recipe)[i]).get(0) : null); + if (y + yDown + posY < 0 || y + yDown + posY > 305) continue; + page.drawTexturedModalRect(x + posX, y + yDown + posY, 138, 0, 18, 18); + ItemStack stack = (ItemStack) (getRecipeInput(recipe).length > i && getRecipeInput(recipe)[i] instanceof ItemStack ? getRecipeInput(recipe)[i] : getRecipeInput(recipe).length > i && getRecipeInput(recipe)[i] instanceof ArrayList ? ((ArrayList) getRecipeInput(recipe)[i]).get(0) : null); - if (stack != null) - { - if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) stack.setItemDamage(0); - page.drawItemStack(stack, 1 + x + posX, 1 + y + yDown + posY, ""); - } - } + if (stack != null) { + if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) stack.setItemDamage(0); + page.drawItemStack(stack, 1 + x + posX, 1 + y + yDown + posY, ""); + } + } - if (14 + yDown + posY > 0 && 14 + yDown + posY < 300) page.drawTexturedModalRect(90 + posX, 14 + yDown + posY, 156, 0, 26, 26); - if (19 + yDown + posY > 0 && 19 + yDown + posY < 305) { - page.drawTexturedModalRect(61 + posX, 19 + yDown + posY, 204, 0, 22, 15); - if (recipe.getRecipeOutput() != null) page.drawItemStack(recipe.getRecipeOutput(), 5 + 90 + posX, 5 + 14 + yDown + posY, ""); - } + if (14 + yDown + posY > 0 && 14 + yDown + posY < 300) + page.drawTexturedModalRect(90 + posX, 14 + yDown + posY, 156, 0, 26, 26); + if (19 + yDown + posY > 0 && 19 + yDown + posY < 305) { + page.drawTexturedModalRect(61 + posX, 19 + yDown + posY, 204, 0, 22, 15); + if (recipe.getRecipeOutput() != null) + page.drawItemStack(recipe.getRecipeOutput(), 5 + 90 + posX, 5 + 14 + yDown + posY, ""); + } - } + } - for (IRecipe recipe : recipes) - { - int index = recipes.indexOf(recipe); + for (IRecipe recipe : recipes) { + int index = recipes.indexOf(recipe); - int yDown = index * 57; + int yDown = index * 57; - if (19 + yDown + posY > 0 && 19 + yDown + posY < 305) { - if (GuiHelper.isInRect(5 + 90 + posX, 5 + 14 + yDown + posY, 18, 18, mouseX, mouseY)) - { - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); - if (recipe.getRecipeOutput() != null) page.renderToolTip(recipe.getRecipeOutput(), mouseX, mouseY); - ResourceHandler.bindResource("textures/gui/Widgets.png"); - GL11.glColor4f(1f, 1f, 1f, 1f); - GL11.glPopAttrib(); - } - } + if (19 + yDown + posY > 0 && 19 + yDown + posY < 305) { + if (GuiHelper.isInRect(5 + 90 + posX, 5 + 14 + yDown + posY, 18, 18, mouseX, mouseY)) { + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + if (recipe.getRecipeOutput() != null) + page.renderToolTip(recipe.getRecipeOutput(), mouseX, mouseY); + ResourceHandler.bindResource("textures/gui/Widgets.png"); + GL11.glColor4f(1f, 1f, 1f, 1f); + GL11.glPopAttrib(); + } + } - for (int i = 0; i < 9; i++) - { - int x = i % 3 * 18; - int y = i / 3 * 18; + for (int i = 0; i < 9; i++) { + int x = i % 3 * 18; + int y = i / 3 * 18; - if (y + yDown + posY < 0 || y + yDown + posY > 305) continue; - ItemStack stack = (ItemStack)(getRecipeInput(recipe).length > i && getRecipeInput(recipe)[i] instanceof ItemStack ? getRecipeInput(recipe)[i] : getRecipeInput(recipe).length > i && getRecipeInput(recipe)[i] instanceof ArrayList ? ((ArrayList) getRecipeInput(recipe)[i]).get(0) : null); + if (y + yDown + posY < 0 || y + yDown + posY > 305) continue; + ItemStack stack = (ItemStack) (getRecipeInput(recipe).length > i && getRecipeInput(recipe)[i] instanceof ItemStack ? getRecipeInput(recipe)[i] : getRecipeInput(recipe).length > i && getRecipeInput(recipe)[i] instanceof ArrayList ? ((ArrayList) getRecipeInput(recipe)[i]).get(0) : null); - if (stack != null) - { - if (GuiHelper.isInRect(1 + x + posX, 1 + y + yDown + posY, 18, 18, mouseX, mouseY)) - { - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); - page.renderToolTip(stack, mouseX, mouseY); - ResourceHandler.bindResource("textures/gui/Widgets.png"); - GL11.glColor4f(1f, 1f, 1f, 1f); - GL11.glPopAttrib(); - } - } - } - } + if (stack != null) { + if (GuiHelper.isInRect(1 + x + posX, 1 + y + yDown + posY, 18, 18, mouseX, mouseY)) { + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + page.renderToolTip(stack, mouseX, mouseY); + ResourceHandler.bindResource("textures/gui/Widgets.png"); + GL11.glColor4f(1f, 1f, 1f, 1f); + GL11.glPopAttrib(); + } + } + } + } - for (ItemStack recipe : smeltingRecipes) - { - int index = smeltingRecipes.indexOf(recipe); - int yDown = (recipes.size() + index) * 57; + for (ItemStack recipe : smeltingRecipes) { + int index = smeltingRecipes.indexOf(recipe); + int yDown = (recipes.size() + index) * 57; - if (yDown + posY > 0 && yDown + posY < 305) { - page.drawTexturedModalRect(posX + 18, yDown + posY, 138, 0, 18, 18); - page.drawItemStack(recipe, posX + 19, yDown + posY + 1, ""); - } - if (21 + yDown + posY > 0 && 21 + yDown + posY < 305) page.drawTexturedModalRect(posX + 18, yDown + posY + 21, 238, 0, 18, 15); - if (36 + yDown + posY > 0 && 36 + yDown + posY < 305) page.drawTexturedModalRect(posX + 18, yDown + posY + 36, 238, 15, 18, 33); - if (14 + yDown + posY > 0 && 14 + yDown + posY < 300) { - page.drawTexturedModalRect(90 + posX, 14 + yDown + posY, 156, 0, 26, 26); - page.drawItemStack(result, 95 + posX, 19 + yDown + posY, ""); - } - if (19 + yDown + posY > 0 && 19 + yDown + posY < 305) page.drawTexturedModalRect(50 + posX, 19 + yDown + posY, 204, 0, 22, 15); + if (yDown + posY > 0 && yDown + posY < 305) { + page.drawTexturedModalRect(posX + 18, yDown + posY, 138, 0, 18, 18); + page.drawItemStack(recipe, posX + 19, yDown + posY + 1, ""); + } + if (21 + yDown + posY > 0 && 21 + yDown + posY < 305) + page.drawTexturedModalRect(posX + 18, yDown + posY + 21, 238, 0, 18, 15); + if (36 + yDown + posY > 0 && 36 + yDown + posY < 305) + page.drawTexturedModalRect(posX + 18, yDown + posY + 36, 238, 15, 18, 33); + if (14 + yDown + posY > 0 && 14 + yDown + posY < 300) { + page.drawTexturedModalRect(90 + posX, 14 + yDown + posY, 156, 0, 26, 26); + page.drawItemStack(result, 95 + posX, 19 + yDown + posY, ""); + } + if (19 + yDown + posY > 0 && 19 + yDown + posY < 305) + page.drawTexturedModalRect(50 + posX, 19 + yDown + posY, 204, 0, 22, 15); - if (yDown + posY > 0 && yDown + posY < 305) { - if (GuiHelper.isInRect(posX + 19, yDown + posY + 1, 18, 18, mouseX, mouseY)) - { - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); - page.renderToolTip(recipe, mouseX, mouseY); - ResourceHandler.bindResource("textures/gui/Widgets.png"); - GL11.glColor4f(1f, 1f, 1f, 1f); - GL11.glPopAttrib(); - } - } + if (yDown + posY > 0 && yDown + posY < 305) { + if (GuiHelper.isInRect(posX + 19, yDown + posY + 1, 18, 18, mouseX, mouseY)) { + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + page.renderToolTip(recipe, mouseX, mouseY); + ResourceHandler.bindResource("textures/gui/Widgets.png"); + GL11.glColor4f(1f, 1f, 1f, 1f); + GL11.glPopAttrib(); + } + } - if (14 + yDown + posY > 0 && 14 + yDown + posY < 305) { - if (GuiHelper.isInRect(95 + posX, 19 + yDown + posY, 18, 18, mouseX, mouseY)) - { - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); - page.renderToolTip(result, mouseX, mouseY); - ResourceHandler.bindResource("textures/gui/Widgets.png"); - GL11.glColor4f(1f, 1f, 1f, 1f); - GL11.glPopAttrib(); - } - } - } - } + if (14 + yDown + posY > 0 && 14 + yDown + posY < 305) { + if (GuiHelper.isInRect(95 + posX, 19 + yDown + posY, 18, 18, mouseX, mouseY)) { + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + page.renderToolTip(result, mouseX, mouseY); + ResourceHandler.bindResource("textures/gui/Widgets.png"); + GL11.glColor4f(1f, 1f, 1f, 1f); + GL11.glPopAttrib(); + } + } + } + } - @SuppressWarnings("unchecked") - private Object[] getRecipeInput(IRecipe recipe) { - if (recipe instanceof ShapelessOreRecipe) return ((ShapelessOreRecipe)recipe).getInput().toArray(); - else if (recipe instanceof ShapedOreRecipe) return getShapedOreRecipe((ShapedOreRecipe)recipe); - else if (recipe instanceof ShapedRecipes) return ((ShapedRecipes)recipe).recipeItems; - else if (recipe instanceof ShapelessRecipes) return ((ShapelessRecipes)recipe).recipeItems.toArray(new ItemStack[0]); - return null; - } + @SuppressWarnings("unchecked") + private Object[] getRecipeInput(IRecipe recipe) { + if (recipe instanceof ShapelessOreRecipe) return ((ShapelessOreRecipe) recipe).getInput().toArray(); + else if (recipe instanceof ShapedOreRecipe) return getShapedOreRecipe((ShapedOreRecipe) recipe); + else if (recipe instanceof ShapedRecipes) return ((ShapedRecipes) recipe).recipeItems; + else if (recipe instanceof ShapelessRecipes) + return ((ShapelessRecipes) recipe).recipeItems.toArray(new ItemStack[0]); + return null; + } - private Object[] getShapedOreRecipe(ShapedOreRecipe recipe) { - try { - Field field = ShapedOreRecipe.class.getDeclaredField("width"); - if (field != null) { - field.setAccessible(true); - int width = field.getInt(recipe); - Object[] input = recipe.getInput(); - Object[] grid = new Object[9]; - for (int i = 0, offset = 0, y = 0; y < 3; y++) { - for (int x = 0; x < 3; x++, i++) { - if (x < width && offset < input.length) { - grid[i] = input[offset]; - offset++; - } else { - grid[i] = null; - } - } - } - return grid; - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - } + private Object[] getShapedOreRecipe(ShapedOreRecipe recipe) { + try { + Field field = ShapedOreRecipe.class.getDeclaredField("width"); + if (field != null) { + field.setAccessible(true); + int width = field.getInt(recipe); + Object[] input = recipe.getInput(); + Object[] grid = new Object[9]; + for (int i = 0, offset = 0, y = 0; y < 3; y++) { + for (int x = 0; x < 3; x++, i++) { + if (x < width && offset < input.length) { + grid[i] = input[offset]; + offset++; + } else { + grid[i] = null; + } + } + } + return grid; + } + } + catch (Exception e) { + e.printStackTrace(); + } + return null; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/handler/ClientEventHandler.java b/src/main/java/com/brandon3055/draconicevolution/client/handler/ClientEventHandler.java index d2a9a952..4f7ca964 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/handler/ClientEventHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/handler/ClientEventHandler.java @@ -39,75 +39,74 @@ import java.util.Random; * Created by Brandon on 28/10/2014. */ public class ClientEventHandler { - public static Map> playerShieldStatus = new HashMap>(); + public static Map> playerShieldStatus = new HashMap>(); - public static int elapsedTicks; - private static float previousFOB = 0f; - public static float previousSensitivity = 0; - public static boolean bowZoom = false; - public static boolean lastTickBowZoom = false; - public static int tickSet = 0; - private static int remountTicksRemaining = 0; - private static int remountEntityID = 0; - public static float energyCrystalAlphaValue = 0f; - public static float energyCrystalAlphaTarget = 0f; - public static boolean playerHoldingWrench = false; - public static Minecraft mc; - private static Random rand = new Random(); - private static IModelCustom shieldSphere; + public static int elapsedTicks; + private static float previousFOB = 0f; + public static float previousSensitivity = 0; + public static boolean bowZoom = false; + public static boolean lastTickBowZoom = false; + public static int tickSet = 0; + private static int remountTicksRemaining = 0; + private static int remountEntityID = 0; + public static float energyCrystalAlphaValue = 0f; + public static float energyCrystalAlphaTarget = 0f; + public static boolean playerHoldingWrench = false; + public static Minecraft mc; + private static Random rand = new Random(); + private static IModelCustom shieldSphere; - public ClientEventHandler(){ - shieldSphere = AdvancedModelLoader.loadModel(ResourceHandler.getResource("models/shieldSphere.obj")); - } + public ClientEventHandler() { + shieldSphere = AdvancedModelLoader.loadModel(ResourceHandler.getResource("models/shieldSphere.obj")); + } - @SubscribeEvent - public void tickEnd(TickEvent.ClientTickEvent event) { - if (event.phase != TickEvent.Phase.START || event.type != TickEvent.Type.CLIENT || event.side != Side.CLIENT) return; + @SubscribeEvent + public void tickEnd(TickEvent.ClientTickEvent event) { + if (event.phase != TickEvent.Phase.START || event.type != TickEvent.Type.CLIENT || event.side != Side.CLIENT) + return; - for (Iterator>> i = playerShieldStatus.entrySet().iterator(); i.hasNext(); ){ - Map.Entry> entry = i.next(); - if (elapsedTicks - entry.getValue().getValue() > 5) i.remove(); - } + for (Iterator>> i = playerShieldStatus.entrySet().iterator(); i.hasNext(); ) { + Map.Entry> entry = i.next(); + if (elapsedTicks - entry.getValue().getValue() > 5) i.remove(); + } - if (mc == null) mc = Minecraft.getMinecraft(); - else if (mc.theWorld != null) - { - elapsedTicks++; - HudHandler.clientTick(); + if (mc == null) mc = Minecraft.getMinecraft(); + else if (mc.theWorld != null) { + elapsedTicks++; + HudHandler.clientTick(); - if (bowZoom && !lastTickBowZoom) - { - previousSensitivity = Minecraft.getMinecraft().gameSettings.mouseSensitivity; - Minecraft.getMinecraft().gameSettings.mouseSensitivity = previousSensitivity / 3; - } else if (!bowZoom && lastTickBowZoom) - { - Minecraft.getMinecraft().gameSettings.mouseSensitivity = previousSensitivity; - } + if (bowZoom && !lastTickBowZoom) { + previousSensitivity = Minecraft.getMinecraft().gameSettings.mouseSensitivity; + Minecraft.getMinecraft().gameSettings.mouseSensitivity = previousSensitivity / 3; + } else if (!bowZoom && lastTickBowZoom) { + Minecraft.getMinecraft().gameSettings.mouseSensitivity = previousSensitivity; + } - lastTickBowZoom = bowZoom; - if (elapsedTicks - tickSet > 10) bowZoom = false; + lastTickBowZoom = bowZoom; + if (elapsedTicks - tickSet > 10) bowZoom = false; - if (energyCrystalAlphaValue < energyCrystalAlphaTarget) energyCrystalAlphaValue += 0.01f; - if (energyCrystalAlphaValue > energyCrystalAlphaTarget) energyCrystalAlphaValue -= 0.01f; + if (energyCrystalAlphaValue < energyCrystalAlphaTarget) energyCrystalAlphaValue += 0.01f; + if (energyCrystalAlphaValue > energyCrystalAlphaTarget) energyCrystalAlphaValue -= 0.01f; - if (Math.abs(energyCrystalAlphaTarget - energyCrystalAlphaValue) <= 0.02f) energyCrystalAlphaTarget = rand.nextFloat(); + if (Math.abs(energyCrystalAlphaTarget - energyCrystalAlphaValue) <= 0.02f) + energyCrystalAlphaTarget = rand.nextFloat(); - playerHoldingWrench = mc.thePlayer.getHeldItem() != null && mc.thePlayer.getHeldItem().getItem() == ModItems.wrench; + playerHoldingWrench = mc.thePlayer.getHeldItem() != null && mc.thePlayer.getHeldItem().getItem() == ModItems.wrench; - searchForPlayerMount(); - } - } + searchForPlayerMount(); + } + } - @SubscribeEvent(priority = EventPriority.LOW) - public void fovUpdate(FOVUpdateEvent event){ + @SubscribeEvent(priority = EventPriority.LOW) + public void fovUpdate(FOVUpdateEvent event) { - //region Bow FOV Update - if (event.entity.getHeldItem()!= null && (event.entity.getHeldItem().getItem() instanceof WyvernBow || event.entity.getHeldItem().getItem() instanceof DraconicBow) && Minecraft.getMinecraft().gameSettings.keyBindUseItem.getIsKeyPressed()){ + //region Bow FOV Update + if (event.entity.getHeldItem() != null && (event.entity.getHeldItem().getItem() instanceof WyvernBow || event.entity.getHeldItem().getItem() instanceof DraconicBow) && Minecraft.getMinecraft().gameSettings.keyBindUseItem.getIsKeyPressed()) { - BowHandler.BowProperties properties = new BowHandler.BowProperties(event.entity.getHeldItem(), event.entity); + BowHandler.BowProperties properties = new BowHandler.BowProperties(event.entity.getHeldItem(), event.entity); - event.newfov = ((6 - properties.zoomModifier) / 6) * event.fov; + event.newfov = ((6 - properties.zoomModifier) / 6) * event.fov; // if (ItemNBTHelper.getString(event.entity.getItemInUse(), "mode", "").equals("sharpshooter")){ // if (event.entity.getItemInUse().getItem() instanceof WyvernBow) zMax = 1.35f; @@ -116,110 +115,108 @@ public class ClientEventHandler { // tickSet = elapsedTicks; // } - } - //endregion + } + //endregion - //region Armor move speed FOV effect cancellation - CustomArmorHandler.ArmorSummery summery = new CustomArmorHandler.ArmorSummery().getSummery(event.entity); + //region Armor move speed FOV effect cancellation + CustomArmorHandler.ArmorSummery summery = new CustomArmorHandler.ArmorSummery().getSummery(event.entity); - if (summery != null && summery.speedModifier > 0){ - IAttributeInstance iattributeinstance = event.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed); - float f = (float)((iattributeinstance.getAttributeValue() / (double)event.entity.capabilities.getWalkSpeed() + 1.0D) / 2.0D); - event.newfov /= f; - } + if (summery != null && summery.speedModifier > 0) { + IAttributeInstance iattributeinstance = event.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed); + float f = (float) ((iattributeinstance.getAttributeValue() / (double) event.entity.capabilities.getWalkSpeed() + 1.0D) / 2.0D); + event.newfov /= f; + } - //endregion - } + //endregion + } - private void searchForPlayerMount(){ - if (remountTicksRemaining > 0){ - Entity e = Minecraft.getMinecraft().theWorld.getEntityByID(remountEntityID); - if (e != null){ - Minecraft.getMinecraft().thePlayer.mountEntity(e); - LogHelper.info("Successfully placed player on mount after "+(500 - remountTicksRemaining)+" ticks"); - remountTicksRemaining = 0; - return; - } - remountTicksRemaining--; - if (remountTicksRemaining == 0){ - LogHelper.error("Unable to locate player mount after 500 ticks! Aborting"); - DraconicEvolution.network.sendToServer(new MountUpdatePacket(-1)); - } - } - } + private void searchForPlayerMount() { + if (remountTicksRemaining > 0) { + Entity e = Minecraft.getMinecraft().theWorld.getEntityByID(remountEntityID); + if (e != null) { + Minecraft.getMinecraft().thePlayer.mountEntity(e); + LogHelper.info("Successfully placed player on mount after " + (500 - remountTicksRemaining) + " ticks"); + remountTicksRemaining = 0; + return; + } + remountTicksRemaining--; + if (remountTicksRemaining == 0) { + LogHelper.error("Unable to locate player mount after 500 ticks! Aborting"); + DraconicEvolution.network.sendToServer(new MountUpdatePacket(-1)); + } + } + } - public static void tryRepositionPlayerOnMount(int id){ - if (remountTicksRemaining == 500) return; - remountTicksRemaining = 500; - remountEntityID = id; - LogHelper.info("Started checking for player mount"); - } + public static void tryRepositionPlayerOnMount(int id) { + if (remountTicksRemaining == 500) return; + remountTicksRemaining = 500; + remountEntityID = id; + LogHelper.info("Started checking for player mount"); + } - @SubscribeEvent - public void renderPlayerEvent(RenderPlayerEvent.Specials.Post event) { - ContributorHandler.render(event); - } + @SubscribeEvent + public void renderPlayerEvent(RenderPlayerEvent.Specials.Post event) { + ContributorHandler.render(event); + } - @SubscribeEvent - public void renderArmorEvent(RenderPlayerEvent.SetArmorModel event) { - if (ConfigHandler.useOriginal3DArmorModel || ConfigHandler.useOldArmorModel || event.isCanceled()) return; - if (event.stack != null && (event.stack.getItem() instanceof DraconicArmor || event.stack.getItem() instanceof WyvernArmor)) - { - ItemArmor itemarmor = (ItemArmor)event.stack.getItem(); - ModelBiped modelbiped = itemarmor.getArmorModel(event.entityPlayer, event.stack, event.slot); - event.renderer.setRenderPassModel(modelbiped); - modelbiped.onGround = event.renderer.modelBipedMain.onGround; - modelbiped.isRiding = event.renderer.modelBipedMain.isRiding; - modelbiped.isChild = event.renderer.modelBipedMain.isChild; - event.result = 1; - } - } + @SubscribeEvent + public void renderArmorEvent(RenderPlayerEvent.SetArmorModel event) { + if (ConfigHandler.useOriginal3DArmorModel || ConfigHandler.useOldArmorModel || event.isCanceled()) return; + if (event.stack != null && (event.stack.getItem() instanceof DraconicArmor || event.stack.getItem() instanceof WyvernArmor)) { + ItemArmor itemarmor = (ItemArmor) event.stack.getItem(); + ModelBiped modelbiped = itemarmor.getArmorModel(event.entityPlayer, event.stack, event.slot); + event.renderer.setRenderPassModel(modelbiped); + modelbiped.onGround = event.renderer.modelBipedMain.onGround; + modelbiped.isRiding = event.renderer.modelBipedMain.isRiding; + modelbiped.isChild = event.renderer.modelBipedMain.isChild; + event.result = 1; + } + } - @SubscribeEvent - public void renderPlayerEvent(RenderPlayerEvent.Post event) { - if (playerShieldStatus.containsKey(event.entityPlayer)) { - GL11.glPushMatrix(); - GL11.glDepthMask(false); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_LIGHTING); - ResourceHandler.bindResource("textures/models/shieldSphere.png"); + @SubscribeEvent + public void renderPlayerEvent(RenderPlayerEvent.Post event) { + if (playerShieldStatus.containsKey(event.entityPlayer)) { + GL11.glPushMatrix(); + GL11.glDepthMask(false); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_LIGHTING); + ResourceHandler.bindResource("textures/models/shieldSphere.png"); - float p = playerShieldStatus.get(event.entityPlayer).getKey(); + float p = playerShieldStatus.get(event.entityPlayer).getKey(); - EntityPlayer viewingPlayer = Minecraft.getMinecraft().thePlayer; + EntityPlayer viewingPlayer = Minecraft.getMinecraft().thePlayer; - int i = 5 - (elapsedTicks - playerShieldStatus.get(event.entityPlayer).getValue()); + int i = 5 - (elapsedTicks - playerShieldStatus.get(event.entityPlayer).getValue()); - GL11.glColor4f(1F - p, 0F, p, i / 5F); + GL11.glColor4f(1F - p, 0F, p, i / 5F); - if (viewingPlayer != event.entityPlayer){ - double translationXLT = event.entityPlayer.prevPosX - viewingPlayer.prevPosX; - double translationYLT = event.entityPlayer.prevPosY - viewingPlayer.prevPosY; - double translationZLT = event.entityPlayer.prevPosZ - viewingPlayer.prevPosZ; + if (viewingPlayer != event.entityPlayer) { + double translationXLT = event.entityPlayer.prevPosX - viewingPlayer.prevPosX; + double translationYLT = event.entityPlayer.prevPosY - viewingPlayer.prevPosY; + double translationZLT = event.entityPlayer.prevPosZ - viewingPlayer.prevPosZ; - double translationX = translationXLT + (((event.entityPlayer.posX - viewingPlayer.posX) - translationXLT) * event.partialRenderTick); - double translationY = translationYLT + (((event.entityPlayer.posY - viewingPlayer.posY) - translationYLT) * event.partialRenderTick); - double translationZ = translationZLT + (((event.entityPlayer.posZ - viewingPlayer.posZ) - translationZLT) * event.partialRenderTick); + double translationX = translationXLT + (((event.entityPlayer.posX - viewingPlayer.posX) - translationXLT) * event.partialRenderTick); + double translationY = translationYLT + (((event.entityPlayer.posY - viewingPlayer.posY) - translationYLT) * event.partialRenderTick); + double translationZ = translationZLT + (((event.entityPlayer.posZ - viewingPlayer.posZ) - translationZLT) * event.partialRenderTick); - GL11.glTranslated(translationX, translationY + 1.1, translationZ); - } - else{ - GL11.glTranslated(0, -0.5, 0); - } + GL11.glTranslated(translationX, translationY + 1.1, translationZ); + } else { + GL11.glTranslated(0, -0.5, 0); + } - GL11.glScaled(1, 1.5, 1); + GL11.glScaled(1, 1.5, 1); - shieldSphere.renderAll(); + shieldSphere.renderAll(); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDepthMask(true); - GL11.glPopMatrix(); - } - } + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthMask(true); + GL11.glPopMatrix(); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/handler/HudHandler.java b/src/main/java/com/brandon3055/draconicevolution/client/handler/HudHandler.java index 99a0d898..cb1c73c6 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/handler/HudHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/handler/HudHandler.java @@ -28,164 +28,162 @@ import org.lwjgl.opengl.GL11; */ public class HudHandler { - private static List hudList = null; - private static List ltHudList = null; - private static float toolTipFadeOut = 0F; - private static float armorStatsFadeOut = 0F; - private static boolean showShieldHud = false; - private static int shieldPercentCharge = 0; - private static float shieldPoints = 0F; - private static float maxShieldPoints = 0F; - private static float shieldEntropy = 0F; - private static int rfCharge = 0; - private static long rfTotal = 0; + private static List hudList = null; + private static List ltHudList = null; + private static float toolTipFadeOut = 0F; + private static float armorStatsFadeOut = 0F; + private static boolean showShieldHud = false; + private static int shieldPercentCharge = 0; + private static float shieldPoints = 0F; + private static float maxShieldPoints = 0F; + private static float shieldEntropy = 0F; + private static int rfCharge = 0; + private static long rfTotal = 0; - int width; - int height; + int width; + int height; - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void drawHUD(RenderGameOverlayEvent.Post event) { - Minecraft mc = Minecraft.getMinecraft(); - if (event.type != RenderGameOverlayEvent.ElementType.ALL || mc.gameSettings.showDebugInfo || mc.currentScreen instanceof GuiChat) return; + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void drawHUD(RenderGameOverlayEvent.Post event) { + Minecraft mc = Minecraft.getMinecraft(); + if (event.type != RenderGameOverlayEvent.ElementType.ALL || mc.gameSettings.showDebugInfo || mc.currentScreen instanceof GuiChat) + return; - ScaledResolution resolution = event.resolution; - width = resolution.getScaledWidth(); - height = resolution.getScaledHeight(); - FontRenderer fontRenderer = mc.fontRenderer; + ScaledResolution resolution = event.resolution; + width = resolution.getScaledWidth(); + height = resolution.getScaledHeight(); + FontRenderer fontRenderer = mc.fontRenderer; - if (ConfigHandler.hudSettings[10] == 1 && hudList != null && toolTipFadeOut > 0) { - int x = (int) (((float)ConfigHandler.hudSettings[0] / 1000F) * (float) width); - int y = (int) (((float)ConfigHandler.hudSettings[1] / 1000F) * (float) height); + if (ConfigHandler.hudSettings[10] == 1 && hudList != null && toolTipFadeOut > 0) { + int x = (int) (((float) ConfigHandler.hudSettings[0] / 1000F) * (float) width); + int y = (int) (((float) ConfigHandler.hudSettings[1] / 1000F) * (float) height); - GL11.glPushMatrix(); - GuiHelper.drawHoveringText(hudList, x, y, fontRenderer, toolTipFadeOut > 1 ? 1 : toolTipFadeOut, ConfigHandler.hudSettings[4] / 100D, width, height); + GL11.glPushMatrix(); + GuiHelper.drawHoveringText(hudList, x, y, fontRenderer, toolTipFadeOut > 1 ? 1 : toolTipFadeOut, ConfigHandler.hudSettings[4] / 100D, width, height); GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - if (ConfigHandler.hudSettings[11] == 1 && showShieldHud) { - int x = (int) (((float)ConfigHandler.hudSettings[2] / 1000F) * (float) width); - int y = (int) (((float)ConfigHandler.hudSettings[3] / 1000F) * (float) height); + if (ConfigHandler.hudSettings[11] == 1 && showShieldHud) { + int x = (int) (((float) ConfigHandler.hudSettings[2] / 1000F) * (float) width); + int y = (int) (((float) ConfigHandler.hudSettings[3] / 1000F) * (float) height); - drawArmorHUD(x, y, ConfigHandler.hudSettings[8] == 1, ConfigHandler.hudSettings[5] / 100D); - } - } - //x, y, x, y, scale, scale, fademode, fademode, rotateArmor, armorText - @SideOnly(Side.CLIENT) - public static void clientTick() { - if (ConfigHandler.hudSettings[6] > 0 && toolTipFadeOut > 1F - ((float)ConfigHandler.hudSettings[6] * 0.25F)) { - toolTipFadeOut-=0.1F; - } - if (hudList != null && (ltHudList == null || !hudList.equals(ltHudList))) toolTipFadeOut = 5F; - if (ConfigHandler.hudSettings[7] > 0 && armorStatsFadeOut > 1F - ((float)ConfigHandler.hudSettings[7] * 0.25F)) { - armorStatsFadeOut-=0.1F; - if (armorStatsFadeOut < 0) armorStatsFadeOut = 0; - } + drawArmorHUD(x, y, ConfigHandler.hudSettings[8] == 1, ConfigHandler.hudSettings[5] / 100D); + } + } - ltHudList = hudList; + //x, y, x, y, scale, scale, fademode, fademode, rotateArmor, armorText + @SideOnly(Side.CLIENT) + public static void clientTick() { + if (ConfigHandler.hudSettings[6] > 0 && toolTipFadeOut > 1F - ((float) ConfigHandler.hudSettings[6] * 0.25F)) { + toolTipFadeOut -= 0.1F; + } + if (hudList != null && (ltHudList == null || !hudList.equals(ltHudList))) toolTipFadeOut = 5F; + if (ConfigHandler.hudSettings[7] > 0 && armorStatsFadeOut > 1F - ((float) ConfigHandler.hudSettings[7] * 0.25F)) { + armorStatsFadeOut -= 0.1F; + if (armorStatsFadeOut < 0) armorStatsFadeOut = 0; + } - Minecraft mc = Minecraft.getMinecraft(); - if (mc == null || mc.thePlayer == null) return; + ltHudList = hudList; - hudList = null; + Minecraft mc = Minecraft.getMinecraft(); + if (mc == null || mc.thePlayer == null) return; - if (mc.currentScreen != null) - { - if (mc.currentScreen instanceof GuiHudConfig) - { - hudList = new ArrayList(); - hudList.add(StatCollector.translateToLocal("info.de.hudDisplayConfigTxt1.txt")); - hudList.add(""); - hudList.add(""); - hudList.add(""); - hudList.add(StatCollector.translateToLocal("info.de.hudDisplayConfigTxt3.txt")); - toolTipFadeOut = 1F; - armorStatsFadeOut = 1F; - } - } - else if (mc.thePlayer.getHeldItem() != null && mc.thePlayer.getHeldItem().getItem() instanceof IHudDisplayItem) { - hudList = ((IHudDisplayItem) mc.thePlayer.getHeldItem().getItem()).getDisplayData( mc.thePlayer.getHeldItem()); - } + hudList = null; - MovingObjectPosition mop = mc.thePlayer.rayTrace(5, 0); - if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && mc.theWorld.getBlock(mop.blockX, mop.blockY, mop.blockZ) instanceof IHudDisplayBlock) - { - hudList = ((IHudDisplayBlock)mc.theWorld.getBlock(mop.blockX, mop.blockY, mop.blockZ)).getDisplayData(mc.theWorld, mop.blockX, mop.blockY, mop.blockZ); - } + if (mc.currentScreen != null) { + if (mc.currentScreen instanceof GuiHudConfig) { + hudList = new ArrayList(); + hudList.add(StatCollector.translateToLocal("info.de.hudDisplayConfigTxt1.txt")); + hudList.add(""); + hudList.add(""); + hudList.add(""); + hudList.add(StatCollector.translateToLocal("info.de.hudDisplayConfigTxt3.txt")); + toolTipFadeOut = 1F; + armorStatsFadeOut = 1F; + } + } else if (mc.thePlayer.getHeldItem() != null && mc.thePlayer.getHeldItem().getItem() instanceof IHudDisplayItem) { + hudList = ((IHudDisplayItem) mc.thePlayer.getHeldItem().getItem()).getDisplayData(mc.thePlayer.getHeldItem()); + } - CustomArmorHandler.ArmorSummery summery = new CustomArmorHandler.ArmorSummery().getSummery(mc.thePlayer); + MovingObjectPosition mop = mc.thePlayer.rayTrace(5, 0); + if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && mc.theWorld.getBlock(mop.blockX, mop.blockY, mop.blockZ) instanceof IHudDisplayBlock) { + hudList = ((IHudDisplayBlock) mc.theWorld.getBlock(mop.blockX, mop.blockY, mop.blockZ)).getDisplayData(mc.theWorld, mop.blockX, mop.blockY, mop.blockZ); + } - if (summery == null){ - showShieldHud = false; - return; - } - showShieldHud = armorStatsFadeOut > 0F; + CustomArmorHandler.ArmorSummery summery = new CustomArmorHandler.ArmorSummery().getSummery(mc.thePlayer); - if (maxShieldPoints != summery.maxProtectionPoints || shieldPoints != summery.protectionPoints || shieldEntropy != summery.entropy || rfTotal != summery.totalEnergyStored) armorStatsFadeOut = 5F; + if (summery == null) { + showShieldHud = false; + return; + } + showShieldHud = armorStatsFadeOut > 0F; - maxShieldPoints = summery.maxProtectionPoints; - shieldPoints = summery.protectionPoints; - shieldPercentCharge = (int) (summery.protectionPoints / summery.maxProtectionPoints * 100D); - shieldEntropy = summery.entropy; - rfCharge = (int) ((double) summery.totalEnergyStored / Math.max((double) summery.maxTotalEnergyStorage, 1D) * 100D); - rfTotal = summery.totalEnergyStored; - } + if (maxShieldPoints != summery.maxProtectionPoints || shieldPoints != summery.protectionPoints || shieldEntropy != summery.entropy || rfTotal != summery.totalEnergyStored) + armorStatsFadeOut = 5F; + + maxShieldPoints = summery.maxProtectionPoints; + shieldPoints = summery.protectionPoints; + shieldPercentCharge = (int) (summery.protectionPoints / summery.maxProtectionPoints * 100D); + shieldEntropy = summery.entropy; + rfCharge = (int) ((double) summery.totalEnergyStored / Math.max((double) summery.maxTotalEnergyStorage, 1D) * 100D); + rfTotal = summery.totalEnergyStored; + } - private void drawArmorHUD(int x, int y, boolean rotated, double scale){ - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - ResourceHandler.bindResource("textures/gui/HUD.png"); + private void drawArmorHUD(int x, int y, boolean rotated, double scale) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + ResourceHandler.bindResource("textures/gui/HUD.png"); - GL11.glTranslated(x, y, 0); - GL11.glScaled(scale, scale, 1); - GL11.glTranslated(-x, -y, 0); - GL11.glColor4f(1F, 1F, 1F, Math.min(armorStatsFadeOut, 1F)); + GL11.glTranslated(x, y, 0); + GL11.glScaled(scale, scale, 1); + GL11.glTranslated(-x, -y, 0); + GL11.glColor4f(1F, 1F, 1F, Math.min(armorStatsFadeOut, 1F)); - if (rotated){ - GuiHelper.drawTexturedRect(x-15, y+1, 14, 16, 2, 0, 13, 15, 0, GuiHelper.PXL128); - x+=104; - GL11.glTranslated(x, y, 0); - GL11.glRotated(-90, 0, 0, -1); - GL11.glTranslated(-x, -y, 0); - } - else GuiHelper.drawTexturedRect(x+1, y+105, 15, 17, 2, 0, 13, 15, 0, GuiHelper.PXL128); + if (rotated) { + GuiHelper.drawTexturedRect(x - 15, y + 1, 14, 16, 2, 0, 13, 15, 0, GuiHelper.PXL128); + x += 104; + GL11.glTranslated(x, y, 0); + GL11.glRotated(-90, 0, 0, -1); + GL11.glTranslated(-x, -y, 0); + } else GuiHelper.drawTexturedRect(x + 1, y + 105, 15, 17, 2, 0, 13, 15, 0, GuiHelper.PXL128); - GuiHelper.drawTexturedRect(x, y, 17, 104, 0, 15, 17, 104, 0, GuiHelper.PXL128); - GuiHelper.drawTexturedRect(x+2, y+2+(100-shieldPercentCharge), 7, shieldPercentCharge, 17, 100-shieldPercentCharge, 7, shieldPercentCharge, 0, GuiHelper.PXL128); - GuiHelper.drawTexturedRect(x+10, y+2+100-(int)shieldEntropy, 2, (int)shieldEntropy, 25, 100-(int)shieldEntropy, 2, (int)shieldEntropy, 0, GuiHelper.PXL128); - GuiHelper.drawTexturedRect(x+13, y+2+100-rfCharge, 2, rfCharge, 28, 100-rfCharge, 2, rfCharge, 0, GuiHelper.PXL128); + GuiHelper.drawTexturedRect(x, y, 17, 104, 0, 15, 17, 104, 0, GuiHelper.PXL128); + GuiHelper.drawTexturedRect(x + 2, y + 2 + (100 - shieldPercentCharge), 7, shieldPercentCharge, 17, 100 - shieldPercentCharge, 7, shieldPercentCharge, 0, GuiHelper.PXL128); + GuiHelper.drawTexturedRect(x + 10, y + 2 + 100 - (int) shieldEntropy, 2, (int) shieldEntropy, 25, 100 - (int) shieldEntropy, 2, (int) shieldEntropy, 0, GuiHelper.PXL128); + GuiHelper.drawTexturedRect(x + 13, y + 2 + 100 - rfCharge, 2, rfCharge, 28, 100 - rfCharge, 2, rfCharge, 0, GuiHelper.PXL128); - if (ConfigHandler.hudSettings[9] == 1) { - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; - GL11.glTranslated(x, y, 0); - if (rotated) GL11.glRotated(90, 0, 0, -1); - GL11.glTranslated(-x, -y, 0); - String shield = Math.round(shieldPoints) + "/" + (int)maxShieldPoints; - String entropy = "EN: "+(int)shieldEntropy + "%"; - String energy = "RF: "+ Utills.formatNumber(rfTotal); - float fade = Math.min(armorStatsFadeOut, 1F); - if (!rotated) { - fontRenderer.drawStringWithShadow(shield, x + 18, y + 74, ((int)(fade*240F)+0x10 << 24) | 0x00FFFFFF); - fontRenderer.drawStringWithShadow(energy, x + 18, y + 84, ((int)(fade*240F)+0x10 << 24) | 0x00FFFFFF); - fontRenderer.drawStringWithShadow(entropy, x + 18, y + 94, ((int)(fade*240F)+0x10 << 24) | 0x00FFFFFF); - }else { - fontRenderer.drawString(shield, x - 52 - fontRenderer.getStringWidth(shield)/2, y + 2, ((int)(fade*240F)+0x10 << 24) | 0x000000FF); - fontRenderer.drawStringWithShadow(entropy, x - fontRenderer.getStringWidth(entropy), y + 18, ((int)(fade*240F)+0x10 << 24) | 0x00FFFFFF); - fontRenderer.drawStringWithShadow(energy, x - 102, y + 18, ((int)(fade*240F)+0x10 << 24) | 0x00FFFFFF); - } - } + if (ConfigHandler.hudSettings[9] == 1) { + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + GL11.glTranslated(x, y, 0); + if (rotated) GL11.glRotated(90, 0, 0, -1); + GL11.glTranslated(-x, -y, 0); + String shield = Math.round(shieldPoints) + "/" + (int) maxShieldPoints; + String entropy = "EN: " + (int) shieldEntropy + "%"; + String energy = "RF: " + Utills.formatNumber(rfTotal); + float fade = Math.min(armorStatsFadeOut, 1F); + if (!rotated) { + fontRenderer.drawStringWithShadow(shield, x + 18, y + 74, ((int) (fade * 240F) + 0x10 << 24) | 0x00FFFFFF); + fontRenderer.drawStringWithShadow(energy, x + 18, y + 84, ((int) (fade * 240F) + 0x10 << 24) | 0x00FFFFFF); + fontRenderer.drawStringWithShadow(entropy, x + 18, y + 94, ((int) (fade * 240F) + 0x10 << 24) | 0x00FFFFFF); + } else { + fontRenderer.drawString(shield, x - 52 - fontRenderer.getStringWidth(shield) / 2, y + 2, ((int) (fade * 240F) + 0x10 << 24) | 0x000000FF); + fontRenderer.drawStringWithShadow(entropy, x - fontRenderer.getStringWidth(entropy), y + 18, ((int) (fade * 240F) + 0x10 << 24) | 0x00FFFFFF); + fontRenderer.drawStringWithShadow(energy, x - 102, y + 18, ((int) (fade * 240F) + 0x10 << 24) | 0x00FFFFFF); + } + } - ResourceHandler.bindTexture(ResourceHandler.getResourceWOP("minecraft:textures/gui/icons.png")); + ResourceHandler.bindTexture(ResourceHandler.getResourceWOP("minecraft:textures/gui/icons.png")); GL11.glColor4f(1F, 1F, 1F, 1F); GL11.glDisable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glPopMatrix(); - } + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/handler/ParticleHandler.java b/src/main/java/com/brandon3055/draconicevolution/client/handler/ParticleHandler.java index e34667fc..a3dcaf53 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/handler/ParticleHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/handler/ParticleHandler.java @@ -8,84 +8,68 @@ import net.minecraft.client.particle.EntityFX; import net.minecraft.world.World; @SideOnly(Side.CLIENT) -public class ParticleHandler -{ - private static Minecraft mc = Minecraft.getMinecraft(); - private static World theWorld = mc.theWorld; +public class ParticleHandler { + private static Minecraft mc = Minecraft.getMinecraft(); + private static World theWorld = mc.theWorld; - public static EntityFX spawnParticle(String particleName, double x, double y, double z, double motionX, double motionY, double motionZ, float scale) - { - if (mc != null && mc.renderViewEntity != null && mc.effectRenderer != null) - { - int var14 = mc.gameSettings.particleSetting; - if (var14 == 1 && theWorld.rand.nextInt(3) == 0) - { - var14 = 2; - } - double var15 = mc.renderViewEntity.posX - x; - double var17 = mc.renderViewEntity.posY - y; - double var19 = mc.renderViewEntity.posZ - z; - EntityFX var21 = null; - double var22 = 16.0D; - if (var15 * var15 + var17 * var17 + var19 * var19 > var22 * var22) - { - return null; - } else if (var14 > 1) - { - return null; - } else - { - if (particleName.equals("distortionParticle")) - { - var21 = new ParticleDistortion(theWorld, x, y, z, (float) motionX, (float) motionY, (float) motionZ, scale); - } - - mc.effectRenderer.addEffect(var21); - return var21; - } - } - return null; - } + public static EntityFX spawnParticle(String particleName, double x, double y, double z, double motionX, double motionY, double motionZ, float scale) { + if (mc != null && mc.renderViewEntity != null && mc.effectRenderer != null) { + int var14 = mc.gameSettings.particleSetting; + if (var14 == 1 && theWorld.rand.nextInt(3) == 0) { + var14 = 2; + } + double var15 = mc.renderViewEntity.posX - x; + double var17 = mc.renderViewEntity.posY - y; + double var19 = mc.renderViewEntity.posZ - z; + EntityFX var21 = null; + double var22 = 16.0D; + if (var15 * var15 + var17 * var17 + var19 * var19 > var22 * var22) { + return null; + } else if (var14 > 1) { + return null; + } else { + if (particleName.equals("distortionParticle")) { + var21 = new ParticleDistortion(theWorld, x, y, z, (float) motionX, (float) motionY, (float) motionZ, scale); + } - public static EntityFX spawnCustomParticle(EntityFX particle){ - return spawnCustomParticle(particle, 64); - } + mc.effectRenderer.addEffect(var21); + return var21; + } + } + return null; + } - public static EntityFX spawnCustomParticle(EntityFX particle, double vewRange) - { - if (mc != null && mc.renderViewEntity != null && mc.effectRenderer != null) - { - int var14 = mc.gameSettings.particleSetting; - if (var14 == 1 && theWorld.rand.nextInt(3) == 0) - { - var14 = 2; - } - if (!isInRange(particle.posX, particle.posY, particle.posZ, vewRange)) - { - return null; - } else if (var14 > 1) - { - return null; - } else - { - mc.effectRenderer.addEffect(particle); - return particle; - } - } - return null; - } + public static EntityFX spawnCustomParticle(EntityFX particle) { + return spawnCustomParticle(particle, 64); + } - public static boolean isInRange(double x, double y, double z, double vewRange) - { - if (mc == null || mc.renderViewEntity == null || mc.effectRenderer == null) return false; + public static EntityFX spawnCustomParticle(EntityFX particle, double vewRange) { + if (mc != null && mc.renderViewEntity != null && mc.effectRenderer != null) { + int var14 = mc.gameSettings.particleSetting; + if (var14 == 1 && theWorld.rand.nextInt(3) == 0) { + var14 = 2; + } + if (!isInRange(particle.posX, particle.posY, particle.posZ, vewRange)) { + return null; + } else if (var14 > 1) { + return null; + } else { + mc.effectRenderer.addEffect(particle); + return particle; + } + } + return null; + } - double var15 = mc.renderViewEntity.posX - x; - double var17 = mc.renderViewEntity.posY - y; - double var19 = mc.renderViewEntity.posZ - z; - if (var15 * var15 + var17 * var17 + var19 * var19 > vewRange * vewRange) - { - return false; - } - return true; - } + public static boolean isInRange(double x, double y, double z, double vewRange) { + if (mc == null || mc.renderViewEntity == null || mc.effectRenderer == null) return false; + + double var15 = mc.renderViewEntity.posX - x; + double var17 = mc.renderViewEntity.posY - y; + double var19 = mc.renderViewEntity.posZ - z; + if (var15 * var15 + var17 * var17 + var19 * var19 > vewRange * vewRange) { + return false; + } + return true; + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/client/handler/ResourceHandler.java b/src/main/java/com/brandon3055/draconicevolution/client/handler/ResourceHandler.java index a4685d6e..5a5c82f8 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/handler/ResourceHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/handler/ResourceHandler.java @@ -29,254 +29,229 @@ import java.util.*; * Created by Brandon on 8/02/2015. */ public class ResourceHandler { - public static ResourceHandler instance = new ResourceHandler(); - private static ResourceLocation defaultParticles; - private static ResourceLocation particles = new ResourceLocation(References.RESOURCESPREFIX + "textures/particle/particles.png"); - private static Map cachedResources = new HashMap(); - public static Map downloadedImages = new HashMap(); + public static ResourceHandler instance = new ResourceHandler(); + private static ResourceLocation defaultParticles; + private static ResourceLocation particles = new ResourceLocation(References.RESOURCESPREFIX + "textures/particle/particles.png"); + private static Map cachedResources = new HashMap(); + public static Map downloadedImages = new HashMap(); - private static String savePath; - private static File saveFolder; - private static File imagesFolder; - private static DownloadThread downloadThread; - public static int downloadStatus = 0; + private static String savePath; + private static File saveFolder; + private static File imagesFolder; + private static DownloadThread downloadThread; + public static int downloadStatus = 0; - //-------------------- File Handling -----------------------// + //-------------------- File Handling -----------------------// - @SubscribeEvent - public void tick(TickEvent.ClientTickEvent event) - { - if (downloadThread != null && downloadThread.isFinished) - { - if (downloadThread.isReloadRequired()) LogHelper.info("Image Download Finished"); - downloadStatus = downloadThread.wasSuccessful ? 1 : 2; - FMLCommonHandler.instance().bus().unregister(this); - addRSPack(event != null); - downloadThread = null; - } - } + @SubscribeEvent + public void tick(TickEvent.ClientTickEvent event) { + if (downloadThread != null && downloadThread.isFinished) { + if (downloadThread.isReloadRequired()) LogHelper.info("Image Download Finished"); + downloadStatus = downloadThread.wasSuccessful ? 1 : 2; + FMLCommonHandler.instance().bus().unregister(this); + addRSPack(event != null); + downloadThread = null; + } + } - public static void init(FMLPreInitializationEvent event) - { - FMLCommonHandler.instance().bus().register(instance); + public static void init(FMLPreInitializationEvent event) { + FMLCommonHandler.instance().bus().register(instance); - if (event != null) savePath = event.getModConfigurationDirectory().getParentFile().getAbsolutePath() + "/config/draconicevolution"; - GUIManual.loadPages(); + if (event != null) + savePath = event.getModConfigurationDirectory().getParentFile().getAbsolutePath() + "/config/draconicevolution"; + GUIManual.loadPages(); - downloadThread = new DownloadThread(GUIManual.imageURLs); - downloadThread.start(); - } + downloadThread = new DownloadThread(GUIManual.imageURLs); + downloadThread.start(); + } - public static class DownloadThread extends Thread - { - private List imageURLs; - private boolean isFinished = false; - private boolean wasSuccessful = true; - private boolean reloadRequired = false; + public static class DownloadThread extends Thread { + private List imageURLs; + private boolean isFinished = false; + private boolean wasSuccessful = true; + private boolean reloadRequired = false; - public DownloadThread(List imageURLs) - { - this.imageURLs = new ArrayList(imageURLs); - } + public DownloadThread(List imageURLs) { + this.imageURLs = new ArrayList(imageURLs); + } - @Override - public void run() { + @Override + public void run() { - for (String s : imageURLs) - { - if (!checkExistence(s)) if (downloadImage(s)) reloadRequired = true; - if (checkExistence(s)) - { - try - { - URL url = new URL(s); - String fileName = url.getFile(); + for (String s : imageURLs) { + if (!checkExistence(s)) if (downloadImage(s)) reloadRequired = true; + if (checkExistence(s)) { + try { + URL url = new URL(s); + String fileName = url.getFile(); - BufferedImage bi = ImageIO.read(new File(getImagesFolder(), FilenameUtils.getName(fileName))); - downloadedImages.put(FilenameUtils.getName(fileName), new CustomResourceLocation(FilenameUtils.getName(fileName), bi.getWidth(), bi.getHeight())); - } - catch (MalformedURLException e) - { - LogHelper.error("Image Read Failed"); - e.printStackTrace(); - } - catch (IOException e) - { - LogHelper.error("Image Read Failed"); - e.printStackTrace(); - } - } - } + BufferedImage bi = ImageIO.read(new File(getImagesFolder(), FilenameUtils.getName(fileName))); + downloadedImages.put(FilenameUtils.getName(fileName), new CustomResourceLocation(FilenameUtils.getName(fileName), bi.getWidth(), bi.getHeight())); + } + catch (MalformedURLException e) { + LogHelper.error("Image Read Failed"); + e.printStackTrace(); + } + catch (IOException e) { + LogHelper.error("Image Read Failed"); + e.printStackTrace(); + } + } + } - isFinished = true; - } + isFinished = true; + } - private static boolean downloadImage(String urlString) - { - try { - URL url = new URL(urlString); - String fileName = url.getFile(); + private static boolean downloadImage(String urlString) { + try { + URL url = new URL(urlString); + String fileName = url.getFile(); - LogHelper.info("Downloading Image " + FilenameUtils.getName(fileName)); + LogHelper.info("Downloading Image " + FilenameUtils.getName(fileName)); - File dll = new File(getImagesFolder(), FilenameUtils.getName(fileName)); + File dll = new File(getImagesFolder(), FilenameUtils.getName(fileName)); - InputStream is = url.openStream(); - OutputStream os = new FileOutputStream(dll); + InputStream is = url.openStream(); + OutputStream os = new FileOutputStream(dll); - ByteStreams.copy(is, os); + ByteStreams.copy(is, os); - is.close(); - os.close(); + is.close(); + os.close(); - }catch (IOException e){ - LogHelper.error("Download Failed"); - e.printStackTrace(); - return false; - } - return true; - } + } + catch (IOException e) { + LogHelper.error("Download Failed"); + e.printStackTrace(); + return false; + } + return true; + } - private static boolean checkExistence(String urlS) - { - try - { - URL url = new URL(urlS); - String fileName = url.getFile(); - return Arrays.asList(getImagesFolder().list()).contains(FilenameUtils.getName(fileName)); - } - catch (MalformedURLException e) - { - LogHelper.error("Unable to check files existence. Invalid URL: " + urlS); - e.printStackTrace(); - return false; - } - } + private static boolean checkExistence(String urlS) { + try { + URL url = new URL(urlS); + String fileName = url.getFile(); + return Arrays.asList(getImagesFolder().list()).contains(FilenameUtils.getName(fileName)); + } + catch (MalformedURLException e) { + LogHelper.error("Unable to check files existence. Invalid URL: " + urlS); + e.printStackTrace(); + return false; + } + } - public boolean isFinished() { - return isFinished; - } + public boolean isFinished() { + return isFinished; + } - public boolean wasSuccessful() { - return wasSuccessful; - } + public boolean wasSuccessful() { + return wasSuccessful; + } - public boolean isReloadRequired() { - return reloadRequired; - } - } + public boolean isReloadRequired() { + return reloadRequired; + } + } - private static void addRSPack(boolean refreash) - { - File rspack = new File(getConfigFolder(), "/resources"); - if (!rspack.exists()) return; + private static void addRSPack(boolean refreash) { + File rspack = new File(getConfigFolder(), "/resources"); + if (!rspack.exists()) return; - if (!Arrays.asList(rspack.list()).contains("pack.mcmeta")) - { - try - { - JsonWriter writer = new JsonWriter(new FileWriter(new File(rspack, "pack.mcmeta"))); - writer.beginObject(); - writer.name("pack"); - writer.beginObject(); - writer.name("pack_format").value(1); - writer.name("description").value("Draconic Evolution GUI Images"); - writer.endObject(); - writer.endObject(); - writer.close(); - } - catch (IOException e) - { - LogHelper.error("Error creating pack.mcmeta"); - e.printStackTrace(); - } - } + if (!Arrays.asList(rspack.list()).contains("pack.mcmeta")) { + try { + JsonWriter writer = new JsonWriter(new FileWriter(new File(rspack, "pack.mcmeta"))); + writer.beginObject(); + writer.name("pack"); + writer.beginObject(); + writer.name("pack_format").value(1); + writer.name("description").value("Draconic Evolution GUI Images"); + writer.endObject(); + writer.endObject(); + writer.close(); + } + catch (IOException e) { + LogHelper.error("Error creating pack.mcmeta"); + e.printStackTrace(); + } + } - Field f = ReflectionHelper.findField(Minecraft.class, "defaultResourcePacks", "field_110449_ao"); - f.setAccessible(true); - try { - List defaultResourcePacks = (List)f.get(Minecraft.getMinecraft()); - defaultResourcePacks.add(new FolderResourcePack(rspack)); + Field f = ReflectionHelper.findField(Minecraft.class, "defaultResourcePacks", "field_110449_ao"); + f.setAccessible(true); + try { + List defaultResourcePacks = (List) f.get(Minecraft.getMinecraft()); + defaultResourcePacks.add(new FolderResourcePack(rspack)); - f.set(Minecraft.getMinecraft(), defaultResourcePacks); - LogHelper.info("RS Added"); - if (refreash) Minecraft.getMinecraft().refreshResources(); - } - catch (IllegalAccessException e) { - e.printStackTrace(); - } - } + f.set(Minecraft.getMinecraft(), defaultResourcePacks); + LogHelper.info("RS Added"); + if (refreash) Minecraft.getMinecraft().refreshResources(); + } + catch (IllegalAccessException e) { + e.printStackTrace(); + } + } - public static File getConfigFolder() - { - if (saveFolder == null) { saveFolder = new File(savePath); } - if (!saveFolder.exists()) saveFolder.mkdir(); + public static File getConfigFolder() { + if (saveFolder == null) { + saveFolder = new File(savePath); + } + if (!saveFolder.exists()) saveFolder.mkdir(); - return saveFolder; - } + return saveFolder; + } - public static File getImagesFolder() - { - if (imagesFolder == null) { imagesFolder = new File(getConfigFolder(), "/resources/assets/draconicevolution/textures/gui/manualimages"); } - if (!imagesFolder.exists()) imagesFolder.mkdirs(); + public static File getImagesFolder() { + if (imagesFolder == null) { + imagesFolder = new File(getConfigFolder(), "/resources/assets/draconicevolution/textures/gui/manualimages"); + } + if (!imagesFolder.exists()) imagesFolder.mkdirs(); - return imagesFolder; - } + return imagesFolder; + } - //----------------------------------------------------------// + //----------------------------------------------------------// + public static void bindTexture(ResourceLocation texture) { + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + } + /** + * Binds the vanilla particle sheet + */ + public static void bindDefaultParticles() { + if (defaultParticles == null) { + try { + defaultParticles = (ResourceLocation) ReflectionHelper.getPrivateValue(EffectRenderer.class, null, "particleTextures", "field_110737_b"); + } + catch (Exception e) { + } + } + if (defaultParticles != null) bindTexture(defaultParticles); + } + public static void bindParticles() { + bindTexture(particles); + } + public static ResourceLocation getResource(String rs) { + if (!cachedResources.containsKey(rs)) + cachedResources.put(rs, new ResourceLocation(References.RESOURCESPREFIX + rs)); + return cachedResources.get(rs); + } + public static ResourceLocation getResourceWOP(String rs) { + if (!cachedResources.containsKey(rs)) cachedResources.put(rs, new ResourceLocation(rs)); + return cachedResources.get(rs); + } - - - public static void bindTexture(ResourceLocation texture) - { - Minecraft.getMinecraft().renderEngine.bindTexture(texture); - } - - /**Binds the vanilla particle sheet*/ - public static void bindDefaultParticles() - { - if (defaultParticles == null) - { - try - { - defaultParticles = (ResourceLocation) ReflectionHelper.getPrivateValue(EffectRenderer.class, null, "particleTextures", "field_110737_b"); - } - catch (Exception e) {} - } - if (defaultParticles != null) bindTexture(defaultParticles); - } - - public static void bindParticles() - { - bindTexture(particles); - } - - public static ResourceLocation getResource(String rs) - { - if (!cachedResources.containsKey(rs)) cachedResources.put(rs, new ResourceLocation(References.RESOURCESPREFIX + rs)); - return cachedResources.get(rs); - } - - public static ResourceLocation getResourceWOP(String rs) - { - if (!cachedResources.containsKey(rs)) cachedResources.put(rs, new ResourceLocation(rs)); - return cachedResources.get(rs); - } - - public static void bindResource(String rs) - { - bindTexture(ResourceHandler.getResource(rs)); - } + public static void bindResource(String rs) { + bindTexture(ResourceHandler.getResource(rs)); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/keybinding/KeyBindings.java b/src/main/java/com/brandon3055/draconicevolution/client/keybinding/KeyBindings.java index 92741ca6..dc4e38fc 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/keybinding/KeyBindings.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/keybinding/KeyBindings.java @@ -12,19 +12,19 @@ import org.lwjgl.input.Keyboard; */ @SideOnly(Side.CLIENT) public class KeyBindings { - public static KeyBinding placeItem; - public static KeyBinding toolConfig; - public static KeyBinding toolProfileChange; - public static KeyBinding toggleFlight; + public static KeyBinding placeItem; + public static KeyBinding toolConfig; + public static KeyBinding toolProfileChange; + public static KeyBinding toggleFlight; - public static void init() { - placeItem = new KeyBinding("key.placeItem", Keyboard.KEY_P, References.MODNAME); - toolConfig = new KeyBinding("key.toolConfig", Keyboard.KEY_C, References.MODNAME); - toolProfileChange = new KeyBinding("key.toolProfileChange", Keyboard.KEY_BACKSLASH, References.MODNAME); - toggleFlight = new KeyBinding("key.toggleFlight", Keyboard.KEY_NONE, References.MODNAME); - ClientRegistry.registerKeyBinding(placeItem); - ClientRegistry.registerKeyBinding(toolConfig); - ClientRegistry.registerKeyBinding(toolProfileChange); - ClientRegistry.registerKeyBinding(toggleFlight); - } + public static void init() { + placeItem = new KeyBinding("key.placeItem", Keyboard.KEY_P, References.MODNAME); + toolConfig = new KeyBinding("key.toolConfig", Keyboard.KEY_C, References.MODNAME); + toolProfileChange = new KeyBinding("key.toolProfileChange", Keyboard.KEY_BACKSLASH, References.MODNAME); + toggleFlight = new KeyBinding("key.toggleFlight", Keyboard.KEY_NONE, References.MODNAME); + ClientRegistry.registerKeyBinding(placeItem); + ClientRegistry.registerKeyBinding(toolConfig); + ClientRegistry.registerKeyBinding(toolProfileChange); + ClientRegistry.registerKeyBinding(toggleFlight); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/keybinding/KeyInputHandler.java b/src/main/java/com/brandon3055/draconicevolution/client/keybinding/KeyInputHandler.java index 31d5e81d..cbb5095f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/keybinding/KeyInputHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/keybinding/KeyInputHandler.java @@ -25,90 +25,88 @@ import org.lwjgl.input.Mouse; */ public class KeyInputHandler { - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onKeyInput(InputEvent.KeyInputEvent event) { - if(KeyBindings.placeItem.isPressed()) handlePlaceItemKey(); - else if(KeyBindings.toolConfig.isPressed()) { - DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_TOOLCONFIG, false)); - } - else if (KeyBindings.toolProfileChange.isPressed() && Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().thePlayer.getItemInUse() == null){ - DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_TOOL_PROFILE_CHANGE, false)); + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onKeyInput(InputEvent.KeyInputEvent event) { + if (KeyBindings.placeItem.isPressed()) handlePlaceItemKey(); + else if (KeyBindings.toolConfig.isPressed()) { + DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_TOOLCONFIG, false)); + } else if (KeyBindings.toolProfileChange.isPressed() && Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().thePlayer.getItemInUse() == null) { + DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_TOOL_PROFILE_CHANGE, false)); - ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem(); - if (stack != null && stack.getItem() instanceof IConfigurableItem && ((IConfigurableItem)stack.getItem()).hasProfiles()){ - int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); - if (++preset >= 5) preset = 0; - ItemNBTHelper.setInteger(stack, "ConfigProfile", preset); - } - } - else if (KeyBindings.toggleFlight.isPressed()){ - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - if (player.capabilities.allowFlying){ - if (player.capabilities.isFlying){ - player.capabilities.isFlying = false; - player.sendPlayerAbilities(); - }else { - player.capabilities.isFlying = true; - if (player.onGround) { - player.setPosition(player.posX, player.posY+0.05D, player.posZ); - player.motionY = 0; - } - player.sendPlayerAbilities(); - } - } - } - } + ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem(); + if (stack != null && stack.getItem() instanceof IConfigurableItem && ((IConfigurableItem) stack.getItem()).hasProfiles()) { + int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); + if (++preset >= 5) preset = 0; + ItemNBTHelper.setInteger(stack, "ConfigProfile", preset); + } + } else if (KeyBindings.toggleFlight.isPressed()) { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + if (player.capabilities.allowFlying) { + if (player.capabilities.isFlying) { + player.capabilities.isFlying = false; + player.sendPlayerAbilities(); + } else { + player.capabilities.isFlying = true; + if (player.onGround) { + player.setPosition(player.posX, player.posY + 0.05D, player.posZ); + player.motionY = 0; + } + player.sendPlayerAbilities(); + } + } + } + } - private void handlePlaceItemKey(){ - EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; - WorldClient world = Minecraft.getMinecraft().theWorld; - MovingObjectPosition mop = ToolHandler.raytraceFromEntity(world, player, 4.5D); - if (mop != null) DraconicEvolution.network.sendToServer(new PlacedItemPacket((byte) mop.sideHit, mop.blockX, mop.blockY, mop.blockZ)); - } + private void handlePlaceItemKey() { + EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; + WorldClient world = Minecraft.getMinecraft().theWorld; + MovingObjectPosition mop = ToolHandler.raytraceFromEntity(world, player, 4.5D); + if (mop != null) + DraconicEvolution.network.sendToServer(new PlacedItemPacket((byte) mop.sideHit, mop.blockX, mop.blockY, mop.blockZ)); + } - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onMouseInput(InputEvent.MouseInputEvent event) { - if(KeyBindings.placeItem.isPressed()) handlePlaceItemKey(); - else if(KeyBindings.toolConfig.isPressed()) { - DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_TOOLCONFIG, false)); - } - else if (KeyBindings.toolProfileChange.isPressed() && Minecraft.getMinecraft().thePlayer != null){ - DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_TOOL_PROFILE_CHANGE, false)); + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onMouseInput(InputEvent.MouseInputEvent event) { + if (KeyBindings.placeItem.isPressed()) handlePlaceItemKey(); + else if (KeyBindings.toolConfig.isPressed()) { + DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_TOOLCONFIG, false)); + } else if (KeyBindings.toolProfileChange.isPressed() && Minecraft.getMinecraft().thePlayer != null) { + DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_TOOL_PROFILE_CHANGE, false)); - ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem(); - if (stack != null && stack.getItem() instanceof IConfigurableItem && ((IConfigurableItem)stack.getItem()).hasProfiles()){ - int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); - if (++preset >= 5) preset = 0; - ItemNBTHelper.setInteger(stack, "ConfigProfile", preset); - } - } + ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem(); + if (stack != null && stack.getItem() instanceof IConfigurableItem && ((IConfigurableItem) stack.getItem()).hasProfiles()) { + int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); + if (++preset >= 5) preset = 0; + ItemNBTHelper.setInteger(stack, "ConfigProfile", preset); + } + } - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - int change = Mouse.getEventDWheel(); - if (change == 0 || !player.isSneaking()) return; + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + int change = Mouse.getEventDWheel(); + if (change == 0 || !player.isSneaking()) return; - if (change > 0){ - ItemStack item = player.inventory.getStackInSlot(previouseSlot(1, player.inventory.currentItem)); - if (item != null && item.getItem().equals(ModItems.teleporterMKII)){ - player.inventory.currentItem = previouseSlot(1, player.inventory.currentItem); - DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.SCROLL, -1, false)); - } - }else if (change < 0){ - ItemStack item = player.inventory.getStackInSlot(previouseSlot(-1, player.inventory.currentItem)); - if (item != null && item.getItem().equals(ModItems.teleporterMKII)){ - player.inventory.currentItem = previouseSlot(-1, player.inventory.currentItem); - DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.SCROLL, 1, false)); - } - } - } + if (change > 0) { + ItemStack item = player.inventory.getStackInSlot(previouseSlot(1, player.inventory.currentItem)); + if (item != null && item.getItem().equals(ModItems.teleporterMKII)) { + player.inventory.currentItem = previouseSlot(1, player.inventory.currentItem); + DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.SCROLL, -1, false)); + } + } else if (change < 0) { + ItemStack item = player.inventory.getStackInSlot(previouseSlot(-1, player.inventory.currentItem)); + if (item != null && item.getItem().equals(ModItems.teleporterMKII)) { + player.inventory.currentItem = previouseSlot(-1, player.inventory.currentItem); + DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.SCROLL, 1, false)); + } + } + } - private int previouseSlot(int i, int c){ - if (c > 0 && c < 8) return c+i; - if (c == 0 && i < 0) return 8; - if (c == 8 && i > 0) return 0; - return c+i; - } + private int previouseSlot(int i, int c) { + if (c > 0 && c < 8) return c + i; + if (c == 0 && i < 0) return 8; + if (c == 8 && i > 0) return 0; + return c + i; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelChaosCrystal.java b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelChaosCrystal.java index 5ca89cbd..a2ad23a9 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelChaosCrystal.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelChaosCrystal.java @@ -82,39 +82,38 @@ public class ModelChaosCrystal extends ModelBase { this.ringBase2.addChild(this.RingSegment1_1); } - public void render(Entity entity, float f1, float f2, float f3, float deathAnimation, float health, float scale) { - GL11.glPushMatrix(); - GL11.glScalef(2.0F, 2.0F, 2.0F); - GL11.glTranslatef(0.0F, -0.5F, 0.0F); + public void render(Entity entity, float f1, float f2, float f3, float deathAnimation, float health, float scale) { + GL11.glPushMatrix(); + GL11.glScalef(2.0F, 2.0F, 2.0F); + GL11.glTranslatef(0.0F, -0.5F, 0.0F); - if (this.base != null) - { - this.base.render(scale); - } + if (this.base != null) { + this.base.render(scale); + } - GL11.glPushMatrix(); - float s = 1.1F + (float) Math.sin(f2 / 20) * 0.1F; - GL11.glTranslatef(0.0F, 0.1F + deathAnimation * 0.9F, 0.0F); - GL11.glRotatef(f2 * 2, 0.0F, 1.0F, 0.1F); - GL11.glScalef(s, s, s); - this.ringBase1.render(scale); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + float s = 1.1F + (float) Math.sin(f2 / 20) * 0.1F; + GL11.glTranslatef(0.0F, 0.1F + deathAnimation * 0.9F, 0.0F); + GL11.glRotatef(f2 * 2, 0.0F, 1.0F, 0.1F); + GL11.glScalef(s, s, s); + this.ringBase1.render(scale); + GL11.glPopMatrix(); - GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.7F + deathAnimation * (0.1F + f3), 0.0F); - GL11.glRotatef(60.0F, 0.7071F, 0.0F, 0.7071F); - this.glass.render(scale); - float f6 = 0.875F; - GL11.glScalef(f6, f6, f6); - GL11.glRotatef(60.0F, 0.7071F, 0.0F, 0.7071F); - GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F); - this.glass.render(scale); - GL11.glScalef(f6, f6, f6); - GL11.glRotatef(60.0F, 0.7071F, 0.0F, 0.7071F); - GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F); - this.cube.render(scale); - GL11.glPopMatrix(); - } + GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.7F + deathAnimation * (0.1F + f3), 0.0F); + GL11.glRotatef(60.0F, 0.7071F, 0.0F, 0.7071F); + this.glass.render(scale); + float f6 = 0.875F; + GL11.glScalef(f6, f6, f6); + GL11.glRotatef(60.0F, 0.7071F, 0.0F, 0.7071F); + GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F); + this.glass.render(scale); + GL11.glScalef(f6, f6, f6); + GL11.glRotatef(60.0F, 0.7071F, 0.0F, 0.7071F); + GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F); + this.cube.render(scale); + GL11.glPopMatrix(); + } /** * This is a helper function from Tabula to set the rotation of model parts diff --git a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelDraconicArmor.java b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelDraconicArmor.java index e4a6e497..ac9bf520 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelDraconicArmor.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelDraconicArmor.java @@ -8,177 +8,175 @@ import net.minecraft.entity.Entity; public class ModelDraconicArmor extends ModelBiped { - public ModelRenderOBJ head; - public ModelRenderOBJ body; - public ModelRenderOBJ rightArm; - public ModelRenderOBJ leftArm; - public ModelRenderOBJ belt; - public ModelRenderOBJ rightLeg; - public ModelRenderOBJ leftLeg; - public ModelRenderOBJ rightBoot; - public ModelRenderOBJ leftBoot; + public ModelRenderOBJ head; + public ModelRenderOBJ body; + public ModelRenderOBJ rightArm; + public ModelRenderOBJ leftArm; + public ModelRenderOBJ belt; + public ModelRenderOBJ rightLeg; + public ModelRenderOBJ leftLeg; + public ModelRenderOBJ rightBoot; + public ModelRenderOBJ leftBoot; public ModelDraconicArmor(float f, boolean isHelmet, boolean isChestPiece, boolean isLeggings, boolean isdBoots) { - super(f, 0.0f, 128, 128); + super(f, 0.0f, 128, 128); - this.bipedHead = new ModelRenderer(this, 0, 0); - this.bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.0F); + this.bipedHead = new ModelRenderer(this, 0, 0); + this.bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.0F); - this.bipedBody = new ModelRenderer(this, 16, 16); - this.bipedBody.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, 0.0F); + this.bipedBody = new ModelRenderer(this, 16, 16); + this.bipedBody.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, 0.0F); - this.bipedLeftArm = new ModelRenderer(this, 40, 16); - this.bipedLeftArm.setRotationPoint(5.0F, 2.0F, 0.0F); - this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, 0.0F); + this.bipedLeftArm = new ModelRenderer(this, 40, 16); + this.bipedLeftArm.setRotationPoint(5.0F, 2.0F, 0.0F); + this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, 0.0F); - this.bipedRightArm = new ModelRenderer(this, 40, 16); - this.bipedRightArm.setRotationPoint(-5.0F, 2.0F, 0.0F); - this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, 0.0F); + this.bipedRightArm = new ModelRenderer(this, 40, 16); + this.bipedRightArm.setRotationPoint(-5.0F, 2.0F, 0.0F); + this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, 0.0F); - this.bipedLeftLeg = new ModelRenderer(this, 0, 16); - this.bipedLeftLeg.setRotationPoint(2.0F, 12.0F, 0.0F); - this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0.0F); + this.bipedLeftLeg = new ModelRenderer(this, 0, 16); + this.bipedLeftLeg.setRotationPoint(2.0F, 12.0F, 0.0F); + this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0.0F); - this.bipedRightLeg = new ModelRenderer(this, 0, 16); - this.bipedRightLeg.setRotationPoint(-2.0F, 12.0F, 0.0F); - this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0.0F); + this.bipedRightLeg = new ModelRenderer(this, 0, 16); + this.bipedRightLeg.setRotationPoint(-2.0F, 12.0F, 0.0F); + this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0.0F); - this.head = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicHelmet.obj"), ResourceHandler.getResource("textures/models/armor/DraconicHelmet.png")); - this.body = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicBody.obj"), ResourceHandler.getResource("textures/models/armor/DraconicBody.png")); - this.rightArm = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicRightArm.obj"), ResourceHandler.getResource("textures/models/armor/DraconicRightArm.png")); - this.leftArm = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicLeftArm.obj"), ResourceHandler.getResource("textures/models/armor/DraconicLeftArm.png")); - this.belt = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicBelt.obj"), ResourceHandler.getResource("textures/models/armor/DraconicBelt.png")); - this.rightLeg = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicRightLeg.obj"), ResourceHandler.getResource("textures/models/armor/DraconicRightLeg.png")); - this.leftLeg = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicLeftLeg.obj"), ResourceHandler.getResource("textures/models/armor/DraconicLeftLeg.png")); - this.rightBoot = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicRightBoot.obj"), ResourceHandler.getResource("textures/models/armor/DraconicRightBoot.png")); - this.leftBoot = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicLeftBoot.obj"), ResourceHandler.getResource("textures/models/armor/DraconicLeftBoot.png")); + this.head = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicHelmet.obj"), ResourceHandler.getResource("textures/models/armor/DraconicHelmet.png")); + this.body = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicBody.obj"), ResourceHandler.getResource("textures/models/armor/DraconicBody.png")); + this.rightArm = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicRightArm.obj"), ResourceHandler.getResource("textures/models/armor/DraconicRightArm.png")); + this.leftArm = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicLeftArm.obj"), ResourceHandler.getResource("textures/models/armor/DraconicLeftArm.png")); + this.belt = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicBelt.obj"), ResourceHandler.getResource("textures/models/armor/DraconicBelt.png")); + this.rightLeg = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicRightLeg.obj"), ResourceHandler.getResource("textures/models/armor/DraconicRightLeg.png")); + this.leftLeg = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicLeftLeg.obj"), ResourceHandler.getResource("textures/models/armor/DraconicLeftLeg.png")); + this.rightBoot = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicRightBoot.obj"), ResourceHandler.getResource("textures/models/armor/DraconicRightBoot.png")); + this.leftBoot = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/DraconicLeftBoot.obj"), ResourceHandler.getResource("textures/models/armor/DraconicLeftBoot.png")); - this.bipedHead.cubeList.clear(); - this.bipedHeadwear.cubeList.clear(); - this.bipedBody.cubeList.clear(); - this.bipedRightArm.cubeList.clear(); - this.bipedLeftArm.cubeList.clear(); - this.bipedLeftLeg.cubeList.clear(); - this.bipedRightLeg.cubeList.clear(); + this.bipedHead.cubeList.clear(); + this.bipedHeadwear.cubeList.clear(); + this.bipedBody.cubeList.clear(); + this.bipedRightArm.cubeList.clear(); + this.bipedLeftArm.cubeList.clear(); + this.bipedLeftLeg.cubeList.clear(); + this.bipedRightLeg.cubeList.clear(); - body.offsetY = 0.755F; - rightArm.offsetY = 0.755F; - leftArm.offsetY = 0.755F; + body.offsetY = 0.755F; + rightArm.offsetY = 0.755F; + leftArm.offsetY = 0.755F; - head.offsetY = -0.1F; - head.offsetX = -0.033F; - head.offsetZ = 0.1F; + head.offsetY = -0.1F; + head.offsetX = -0.033F; + head.offsetZ = 0.1F; - body.offsetY = 0.755F; - body.offsetZ = -0.03F; - rightArm.offsetY = 0.72F; - rightArm.offsetX = -0.18F; - rightArm.offsetZ = -0.05F; - leftArm.offsetY = 0.72F; - leftArm.offsetX = 0.18F; - leftArm.offsetZ = -0.06F; - belt.offsetY = 0.756F; - belt.offsetZ = -0.04F; - rightLeg.offsetY = 0.6F; - rightLeg.offsetX = -0.05F; - leftLeg.offsetY = 0.6F; - leftLeg.offsetX = 0.06F; - rightBoot.offsetY = 0.76F; - rightBoot.offsetX = -0.03F; - leftBoot.offsetY = 0.76F; - leftBoot.offsetX = 0.03F; + body.offsetY = 0.755F; + body.offsetZ = -0.03F; + rightArm.offsetY = 0.72F; + rightArm.offsetX = -0.18F; + rightArm.offsetZ = -0.05F; + leftArm.offsetY = 0.72F; + leftArm.offsetX = 0.18F; + leftArm.offsetZ = -0.06F; + belt.offsetY = 0.756F; + belt.offsetZ = -0.04F; + rightLeg.offsetY = 0.6F; + rightLeg.offsetX = -0.05F; + leftLeg.offsetY = 0.6F; + leftLeg.offsetX = 0.06F; + rightBoot.offsetY = 0.76F; + rightBoot.offsetX = -0.03F; + leftBoot.offsetY = 0.76F; + leftBoot.offsetX = 0.03F; - leftLeg.scale = 1F / 15F; - rightLeg.scale = 1F / 15F; - leftBoot.scale = 1F / 15F; - rightBoot.scale = 1F / 15F; + leftLeg.scale = 1F / 15F; + rightLeg.scale = 1F / 15F; + leftBoot.scale = 1F / 15F; + rightBoot.scale = 1F / 15F; - if (isHelmet) { - this.bipedHead.addChild(head); - } - if (isChestPiece) { - this.bipedBody.addChild(body); - this.bipedLeftArm.addChild(leftArm); - this.bipedRightArm.addChild(rightArm); - } - if (isLeggings) { - this.bipedLeftLeg.addChild(leftLeg); - this.bipedRightLeg.addChild(rightLeg); - this.bipedBody.addChild(belt); - } - if (isdBoots) { - this.bipedLeftLeg.addChild(leftBoot); - this.bipedRightLeg.addChild(rightBoot); - } + if (isHelmet) { + this.bipedHead.addChild(head); + } + if (isChestPiece) { + this.bipedBody.addChild(body); + this.bipedLeftArm.addChild(leftArm); + this.bipedRightArm.addChild(rightArm); + } + if (isLeggings) { + this.bipedLeftLeg.addChild(leftLeg); + this.bipedRightLeg.addChild(rightLeg); + this.bipedBody.addChild(belt); + } + if (isdBoots) { + this.bipedLeftLeg.addChild(leftBoot); + this.bipedRightLeg.addChild(rightBoot); + } } @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - if (entity == null){ - isSneak = false; - isRiding = false; - isChild = false; - aimedBow = false; + if (entity == null) { + isSneak = false; + isRiding = false; + isChild = false; + aimedBow = false; - this.bipedRightArm.rotateAngleX = 0F; - this.bipedRightArm.rotateAngleY = 0F; - this.bipedRightArm.rotateAngleZ = 0F; - this.bipedLeftArm.rotateAngleX = 0F; - this.bipedLeftArm.rotateAngleY = 0F; - this.bipedLeftArm.rotateAngleZ = 0F; + this.bipedRightArm.rotateAngleX = 0F; + this.bipedRightArm.rotateAngleY = 0F; + this.bipedRightArm.rotateAngleZ = 0F; + this.bipedLeftArm.rotateAngleX = 0F; + this.bipedLeftArm.rotateAngleY = 0F; + this.bipedLeftArm.rotateAngleZ = 0F; - bipedBody.rotateAngleX = 0F; - bipedBody.rotateAngleY = 0F; - bipedBody.rotateAngleZ = 0F; + bipedBody.rotateAngleX = 0F; + bipedBody.rotateAngleY = 0F; + bipedBody.rotateAngleZ = 0F; - bipedHead.rotateAngleX = 0F; - bipedHead.rotateAngleY = 0F; - bipedHead.rotateAngleZ = 0F; + bipedHead.rotateAngleX = 0F; + bipedHead.rotateAngleY = 0F; + bipedHead.rotateAngleZ = 0F; - bipedLeftLeg.rotateAngleX = 0F; - bipedLeftLeg.rotateAngleY = 0F; - bipedLeftLeg.rotateAngleZ = 0F; + bipedLeftLeg.rotateAngleX = 0F; + bipedLeftLeg.rotateAngleY = 0F; + bipedLeftLeg.rotateAngleZ = 0F; - bipedRightLeg.rotateAngleX = 0F; - bipedRightLeg.rotateAngleY = 0F; - bipedRightLeg.rotateAngleZ = 0F; + bipedRightLeg.rotateAngleX = 0F; + bipedRightLeg.rotateAngleY = 0F; + bipedRightLeg.rotateAngleZ = 0F; - setRotationAngles(0, 0, 0, 0, 0, 0, null); - } - else super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + setRotationAngles(0, 0, 0, 0, 0, 0, null); + } else super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); - this.bipedHead.render(1F/13F); - this.bipedRightArm.render(1F/15F); - this.bipedLeftArm.render(1F/15F); - this.bipedBody.render(1F/15F); - this.bipedRightLeg.render(1F/16F); - this.bipedLeftLeg.render(1F/16F); - } + this.bipedHead.render(1F / 13F); + this.bipedRightArm.render(1F / 15F); + this.bipedLeftArm.render(1F / 15F); + this.bipedBody.render(1F / 15F); + this.bipedRightLeg.render(1F / 16F); + this.bipedLeftLeg.render(1F / 16F); + } - 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.bipedRightArm.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleZ = 0.0F; - this.bipedRightArm.rotationPointZ = 0.0F; - this.bipedLeftArm.rotationPointZ = 0.0F; - this.bipedRightLeg.rotateAngleY = 0.0F; - this.bipedLeftLeg.rotateAngleY = 0.0F; - this.bipedRightArm.rotateAngleY = 0.0F; - this.bipedLeftArm.rotateAngleY = 0.0F; - this.bipedBody.rotateAngleX = 0.0F; - this.bipedRightLeg.rotationPointZ = 0.1F; - this.bipedLeftLeg.rotationPointZ = 0.1F; - this.bipedRightLeg.rotationPointY = 12.0F; - this.bipedLeftLeg.rotationPointY = 12.0F; - this.bipedHead.rotationPointY = 0.0F; - this.bipedHeadwear.rotationPointY = 0.0F; - this.leftLeg.rotationPointZ = 0F; - this.rightLeg.rotationPointZ = 0F; - this.bipedRightArm.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleZ = 0.0F; - } + 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.bipedRightArm.rotateAngleZ = 0.0F; + this.bipedLeftArm.rotateAngleZ = 0.0F; + this.bipedRightArm.rotationPointZ = 0.0F; + this.bipedLeftArm.rotationPointZ = 0.0F; + this.bipedRightLeg.rotateAngleY = 0.0F; + this.bipedLeftLeg.rotateAngleY = 0.0F; + this.bipedRightArm.rotateAngleY = 0.0F; + this.bipedLeftArm.rotateAngleY = 0.0F; + this.bipedBody.rotateAngleX = 0.0F; + this.bipedRightLeg.rotationPointZ = 0.1F; + this.bipedLeftLeg.rotationPointZ = 0.1F; + this.bipedRightLeg.rotationPointY = 12.0F; + this.bipedLeftLeg.rotationPointY = 12.0F; + this.bipedHead.rotationPointY = 0.0F; + this.bipedHeadwear.rotationPointY = 0.0F; + this.leftLeg.rotationPointZ = 0F; + this.rightLeg.rotationPointZ = 0F; + this.bipedRightArm.rotateAngleZ = 0.0F; + this.bipedLeftArm.rotateAngleZ = 0.0F; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelDraconicArmorOld.java b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelDraconicArmorOld.java index f581e90d..21de2bf3 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelDraconicArmorOld.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelDraconicArmorOld.java @@ -9,7 +9,7 @@ import net.minecraft.entity.Entity; * Created using Tabula 5.0.0 */ public class ModelDraconicArmorOld extends ModelBiped {// -// public ModelRenderer bipedHead; + // public ModelRenderer bipedHead; // public ModelRenderer bipedBody; // public ModelRenderer bipedRightArm; // public ModelRenderer bipedLeftArm; @@ -78,617 +78,613 @@ public class ModelDraconicArmorOld extends ModelBiped {// public ModelRenderer BootPieceLeft2; public ModelRenderer MainKneePadLeft; public ModelRenderer KneePieceLeft1; - public ModelRenderer BootPieceLeft3; - public ModelRenderer BootPieceLeft4; - public ModelRenderer BootPieceRight3; - public ModelRenderer BootPieceRight4; - public ModelRenderer LeggsTop; + public ModelRenderer BootPieceLeft3; + public ModelRenderer BootPieceLeft4; + public ModelRenderer BootPieceRight3; + public ModelRenderer BootPieceRight4; + public ModelRenderer LeggsTop; - //Draconic Specific - public ModelRenderer DrMainChestPieceTop; - public ModelRenderer DrMainChestPieceMid; - public ModelRenderer DrChestDecorationPiece1; - public ModelRenderer DrChestDecorationPiece3; - public ModelRenderer BeltFront; - public ModelRenderer BeltBack; - public ModelRenderer BeltLeft; - public ModelRenderer BeltRight; - public ModelRenderer BeltBuckle; - //Wyvern Specific - public ModelRenderer WyHelmPieceTop1; - public ModelRenderer WyHelmPieceTop2; - public ModelRenderer WyHelmPieceTop3; - public ModelRenderer WyHelmPieceTop4; - public ModelRenderer WyMainChestPieceMid; - public ModelRenderer WyMainChestPieceTop; - public ModelRenderer WyChestPieceTop1; - public ModelRenderer WyChestPieceTop2; - public ModelRenderer WyChestDecorationPiece3; - public ModelRenderer WyChestPieceTop3; + //Draconic Specific + public ModelRenderer DrMainChestPieceTop; + public ModelRenderer DrMainChestPieceMid; + public ModelRenderer DrChestDecorationPiece1; + public ModelRenderer DrChestDecorationPiece3; + public ModelRenderer BeltFront; + public ModelRenderer BeltBack; + public ModelRenderer BeltLeft; + public ModelRenderer BeltRight; + public ModelRenderer BeltBuckle; + //Wyvern Specific + public ModelRenderer WyHelmPieceTop1; + public ModelRenderer WyHelmPieceTop2; + public ModelRenderer WyHelmPieceTop3; + public ModelRenderer WyHelmPieceTop4; + public ModelRenderer WyMainChestPieceMid; + public ModelRenderer WyMainChestPieceTop; + public ModelRenderer WyChestPieceTop1; + public ModelRenderer WyChestPieceTop2; + public ModelRenderer WyChestDecorationPiece3; + public ModelRenderer WyChestPieceTop3; - private boolean isDraconic; + private boolean isDraconic; public ModelDraconicArmorOld(float f, boolean isHelmet, boolean isChestPiece, boolean isLeggings, boolean isdBoots, boolean isDraconic) { - super(f, 0.0f, 128, 128); + super(f, 0.0f, 128, 128); this.textureWidth = 256; this.textureHeight = 128; - this.isDraconic = isDraconic; + this.isDraconic = isDraconic; /* Helm */ - { - this.bipedHead = new ModelRenderer(this, 0, 0); - this.bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.0F); + { + this.bipedHead = new ModelRenderer(this, 0, 0); + this.bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.0F); - this.MainHelmPieceLeft1 = new ModelRenderer(this, 191, 0); - this.MainHelmPieceLeft1.setRotationPoint(3.5F, -3.0F, -4.5F); - this.MainHelmPieceLeft1.addBox(0.0F, 0.0F, 0.0F, 1, 3, 9, 0.0F); + this.MainHelmPieceLeft1 = new ModelRenderer(this, 191, 0); + this.MainHelmPieceLeft1.setRotationPoint(3.5F, -3.0F, -4.5F); + this.MainHelmPieceLeft1.addBox(0.0F, 0.0F, 0.0F, 1, 3, 9, 0.0F); - this.HelmPieceFront2 = new ModelRenderer(this, 177, 43); - this.HelmPieceFront2.setRotationPoint(-0.5F, -5.5F, -4.5F); - this.HelmPieceFront2.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1, 0.0F); + this.HelmPieceFront2 = new ModelRenderer(this, 177, 43); + this.HelmPieceFront2.setRotationPoint(-0.5F, -5.5F, -4.5F); + this.HelmPieceFront2.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1, 0.0F); - this.MainHelmPieceRight2 = new ModelRenderer(this, 170, 0); - this.MainHelmPieceRight2.setRotationPoint(-4.5F, -8.0F, -4.5F); - this.MainHelmPieceRight2.addBox(0.0F, 0.0F, 0.0F, 1, 2, 9, 0.0F); + this.MainHelmPieceRight2 = new ModelRenderer(this, 170, 0); + this.MainHelmPieceRight2.setRotationPoint(-4.5F, -8.0F, -4.5F); + this.MainHelmPieceRight2.addBox(0.0F, 0.0F, 0.0F, 1, 2, 9, 0.0F); - this.MainHelmPieceTop = new ModelRenderer(this, 177, 24); - this.MainHelmPieceTop.mirror = true; - this.MainHelmPieceTop.setRotationPoint(-4.0F, -8.300000190734863F, -4.5F); - this.MainHelmPieceTop.addBox(0.0F, 0.0F, 0.0F, 8, 1, 9, 0.0F); - this.setRotateAngle(MainHelmPieceTop, 0.05235987901687623F, -0.0F, 0.0F); + this.MainHelmPieceTop = new ModelRenderer(this, 177, 24); + this.MainHelmPieceTop.mirror = true; + this.MainHelmPieceTop.setRotationPoint(-4.0F, -8.300000190734863F, -4.5F); + this.MainHelmPieceTop.addBox(0.0F, 0.0F, 0.0F, 8, 1, 9, 0.0F); + this.setRotateAngle(MainHelmPieceTop, 0.05235987901687623F, -0.0F, 0.0F); - this.MainHelmPieceFrontBottom = new ModelRenderer(this, 174, 35); - this.MainHelmPieceFrontBottom.setRotationPoint(-4.0F, -3.0F, -5.0F); - this.MainHelmPieceFrontBottom.addBox(0.0F, 0.0F, 0.0F, 8, 3, 1, 0.0F); + this.MainHelmPieceFrontBottom = new ModelRenderer(this, 174, 35); + this.MainHelmPieceFrontBottom.setRotationPoint(-4.0F, -3.0F, -5.0F); + this.MainHelmPieceFrontBottom.addBox(0.0F, 0.0F, 0.0F, 8, 3, 1, 0.0F); - this.MainHelmPieceLeft2 = new ModelRenderer(this, 170, 0); - this.MainHelmPieceLeft2.setRotationPoint(3.5F, -8.0F, -4.5F); - this.MainHelmPieceLeft2.addBox(0.0F, 0.0F, 0.0F, 1, 2, 9, 0.0F); + this.MainHelmPieceLeft2 = new ModelRenderer(this, 170, 0); + this.MainHelmPieceLeft2.setRotationPoint(3.5F, -8.0F, -4.5F); + this.MainHelmPieceLeft2.addBox(0.0F, 0.0F, 0.0F, 1, 2, 9, 0.0F); - this.HelmPieceBack1 = new ModelRenderer(this, 193, 39); - this.HelmPieceBack1.setRotationPoint(-4.0F, -8.0F, 4.0F); - this.HelmPieceBack1.addBox(0.0F, 0.0F, 0.0F, 8, 8, 1, 0.0F); + this.HelmPieceBack1 = new ModelRenderer(this, 193, 39); + this.HelmPieceBack1.setRotationPoint(-4.0F, -8.0F, 4.0F); + this.HelmPieceBack1.addBox(0.0F, 0.0F, 0.0F, 8, 8, 1, 0.0F); - this.MainHelmPieceLeft3 = new ModelRenderer(this, 195, 13); - this.MainHelmPieceLeft3.setRotationPoint(3.5F, -6.0F, -2.5F); - this.MainHelmPieceLeft3.addBox(0.0F, 0.0F, 0.0F, 1, 3, 7, 0.0F); + this.MainHelmPieceLeft3 = new ModelRenderer(this, 195, 13); + this.MainHelmPieceLeft3.setRotationPoint(3.5F, -6.0F, -2.5F); + this.MainHelmPieceLeft3.addBox(0.0F, 0.0F, 0.0F, 1, 3, 7, 0.0F); - this.MainHelmPieceRight1 = new ModelRenderer(this, 191, 0); - this.MainHelmPieceRight1.setRotationPoint(-4.5F, -3.0F, -4.5F); - this.MainHelmPieceRight1.addBox(0.0F, 0.0F, 0.0F, 1, 3, 9, 0.0F); + this.MainHelmPieceRight1 = new ModelRenderer(this, 191, 0); + this.MainHelmPieceRight1.setRotationPoint(-4.5F, -3.0F, -4.5F); + this.MainHelmPieceRight1.addBox(0.0F, 0.0F, 0.0F, 1, 3, 9, 0.0F); - this.MainHelmPieceBack = new ModelRenderer(this, 178, 13); - this.MainHelmPieceBack.setRotationPoint(-3.5F, -8.0F, 3.5F); - this.MainHelmPieceBack.addBox(0.0F, 0.0F, 0.0F, 7, 8, 1, 0.0F); + this.MainHelmPieceBack = new ModelRenderer(this, 178, 13); + this.MainHelmPieceBack.setRotationPoint(-3.5F, -8.0F, 3.5F); + this.MainHelmPieceBack.addBox(0.0F, 0.0F, 0.0F, 7, 8, 1, 0.0F); - this.MainHelmPieceRight3 = new ModelRenderer(this, 195, 13); - this.MainHelmPieceRight3.setRotationPoint(-4.5F, -6.0F, -2.5F); - this.MainHelmPieceRight3.addBox(0.0F, 0.0F, 0.0F, 1, 3, 7, 0.0F); + this.MainHelmPieceRight3 = new ModelRenderer(this, 195, 13); + this.MainHelmPieceRight3.setRotationPoint(-4.5F, -6.0F, -2.5F); + this.MainHelmPieceRight3.addBox(0.0F, 0.0F, 0.0F, 1, 3, 7, 0.0F); - this.HelmPieceFront1 = new ModelRenderer(this, 175, 40); - this.HelmPieceFront1.setRotationPoint(-1.0F, -6.0F, -5.0F); - this.HelmPieceFront1.addBox(0.0F, 0.0F, 0.0F, 2, 1, 1, 0.0F); + this.HelmPieceFront1 = new ModelRenderer(this, 175, 40); + this.HelmPieceFront1.setRotationPoint(-1.0F, -6.0F, -5.0F); + this.HelmPieceFront1.addBox(0.0F, 0.0F, 0.0F, 2, 1, 1, 0.0F); - this.MainHelmPieceBottom = new ModelRenderer(this, 177, 24); - this.MainHelmPieceBottom.setRotationPoint(-4.0F, -0.5F, -4.5F); - this.MainHelmPieceBottom.addBox(0.0F, 0.0F, 0.0F, 8, 1, 9, 0.0F); + this.MainHelmPieceBottom = new ModelRenderer(this, 177, 24); + this.MainHelmPieceBottom.setRotationPoint(-4.0F, -0.5F, -4.5F); + this.MainHelmPieceBottom.addBox(0.0F, 0.0F, 0.0F, 8, 1, 9, 0.0F); - this.MainHelmPieceFrontTop = new ModelRenderer(this, 193, 35); - this.MainHelmPieceFrontTop.setRotationPoint(-4.0F, -8.0F, -5.0F); - this.MainHelmPieceFrontTop.addBox(0.0F, 0.0F, 0.0F, 8, 2, 1, 0.0F); + this.MainHelmPieceFrontTop = new ModelRenderer(this, 193, 35); + this.MainHelmPieceFrontTop.setRotationPoint(-4.0F, -8.0F, -5.0F); + this.MainHelmPieceFrontTop.addBox(0.0F, 0.0F, 0.0F, 8, 2, 1, 0.0F); - this.HornPieceLeft1 = new ModelRenderer(this, 182, 40); - this.HornPieceLeft1.setRotationPoint(4.0F, -7.5F, -1.0F); - this.HornPieceLeft1.addBox(0.0F, 0.0F, 0.0F, 1, 4, 4, 0.0F); + this.HornPieceLeft1 = new ModelRenderer(this, 182, 40); + this.HornPieceLeft1.setRotationPoint(4.0F, -7.5F, -1.0F); + this.HornPieceLeft1.addBox(0.0F, 0.0F, 0.0F, 1, 4, 4, 0.0F); - this.HornPieceLeft2 = new ModelRenderer(this, 201, 49); - this.HornPieceLeft2.setRotationPoint(4.6F, -5.5F, 1.03F); - this.HornPieceLeft2.addBox(0.0F, -1.5F, -1.5F, 2, 3, 3, 0.0F); - this.setRotateAngle(HornPieceLeft2, 0.0F, -0.0F, -0.13962634015954636F); + this.HornPieceLeft2 = new ModelRenderer(this, 201, 49); + this.HornPieceLeft2.setRotationPoint(4.6F, -5.5F, 1.03F); + this.HornPieceLeft2.addBox(0.0F, -1.5F, -1.5F, 2, 3, 3, 0.0F); + this.setRotateAngle(HornPieceLeft2, 0.0F, -0.0F, -0.13962634015954636F); - this.HornPieceLeft3 = new ModelRenderer(this, 190, 49); - this.HornPieceLeft3.setRotationPoint(6.1F, -5.6F, 1.0F); - this.HornPieceLeft3.addBox(0.0F, -1.0F, -1.0F, 3, 2, 2, 0.0F); - this.setRotateAngle(HornPieceLeft3, 0.0F, -0.0F, -0.5235987755982988F); + this.HornPieceLeft3 = new ModelRenderer(this, 190, 49); + this.HornPieceLeft3.setRotationPoint(6.1F, -5.6F, 1.0F); + this.HornPieceLeft3.addBox(0.0F, -1.0F, -1.0F, 3, 2, 2, 0.0F); + this.setRotateAngle(HornPieceLeft3, 0.0F, -0.0F, -0.5235987755982988F); - this.HornPieceRight1 = new ModelRenderer(this, 182, 40); - this.HornPieceRight1.setRotationPoint(-5.0F, -7.5F, -1.0F); - this.HornPieceRight1.addBox(0.0F, 0.0F, 0.0F, 1, 4, 4, 0.0F); + this.HornPieceRight1 = new ModelRenderer(this, 182, 40); + this.HornPieceRight1.setRotationPoint(-5.0F, -7.5F, -1.0F); + this.HornPieceRight1.addBox(0.0F, 0.0F, 0.0F, 1, 4, 4, 0.0F); - this.HornPieceRight2 = new ModelRenderer(this, 201, 49); - this.HornPieceRight2.setRotationPoint(-4.6F, -5.5F, 1.03F); - this.HornPieceRight2.addBox(0.0F, -1.5F, -1.5F, 2, 3, 3, 0.0F); - this.setRotateAngle(HornPieceRight2, 0.0F, -0.0F, -3.001966313430247F); + this.HornPieceRight2 = new ModelRenderer(this, 201, 49); + this.HornPieceRight2.setRotationPoint(-4.6F, -5.5F, 1.03F); + this.HornPieceRight2.addBox(0.0F, -1.5F, -1.5F, 2, 3, 3, 0.0F); + this.setRotateAngle(HornPieceRight2, 0.0F, -0.0F, -3.001966313430247F); - this.HornPieceRight3 = new ModelRenderer(this, 190, 49); - this.HornPieceRight3.setRotationPoint(-6.1F, -5.6F, 1.0F); - this.HornPieceRight3.addBox(0.0F, -1.0F, -1.0F, 3, 2, 2, 0.0F); - this.setRotateAngle(HornPieceRight3, 0.0F, -0.0F, -2.6179938779914944F); + this.HornPieceRight3 = new ModelRenderer(this, 190, 49); + this.HornPieceRight3.setRotationPoint(-6.1F, -5.6F, 1.0F); + this.HornPieceRight3.addBox(0.0F, -1.0F, -1.0F, 3, 2, 2, 0.0F); + this.setRotateAngle(HornPieceRight3, 0.0F, -0.0F, -2.6179938779914944F); - this.HornPieceLeft4 = new ModelRenderer(this, 181, 49); - this.HornPieceLeft4.setRotationPoint(8.2F, -6.7F, 1.0F); - this.HornPieceLeft4.addBox(0.0F, -0.5F, -0.5F, 3, 1, 1, 0.0F); - this.setRotateAngle(HornPieceLeft4, 0.0F, -0.0F, -0.8726646259971648F); + this.HornPieceLeft4 = new ModelRenderer(this, 181, 49); + this.HornPieceLeft4.setRotationPoint(8.2F, -6.7F, 1.0F); + this.HornPieceLeft4.addBox(0.0F, -0.5F, -0.5F, 3, 1, 1, 0.0F); + this.setRotateAngle(HornPieceLeft4, 0.0F, -0.0F, -0.8726646259971648F); - this.HornPieceRight4 = new ModelRenderer(this, 181, 49); - this.HornPieceRight4.setRotationPoint(-8.2F, -6.7F, 1.0F); - this.HornPieceRight4.addBox(0.0F, -0.5F, -0.5F, 3, 1, 1, 0.0F); - this.setRotateAngle(HornPieceRight4, 0.0F, -0.0F, -2.2689280275926285F); + this.HornPieceRight4 = new ModelRenderer(this, 181, 49); + this.HornPieceRight4.setRotationPoint(-8.2F, -6.7F, 1.0F); + this.HornPieceRight4.addBox(0.0F, -0.5F, -0.5F, 3, 1, 1, 0.0F); + this.setRotateAngle(HornPieceRight4, 0.0F, -0.0F, -2.2689280275926285F); - this.WyHelmPieceTop1 = new ModelRenderer(this, 181, 49); - this.WyHelmPieceTop1.setRotationPoint(-0.5F, -8.5F, -4.5F); - this.WyHelmPieceTop1.addBox(0.0F, 0.0F, 0.0F, 1, 1, 3, 0.0F); - this.setRotateAngle(WyHelmPieceTop1, 0.2792526803190927F, -0.0F, 0.0F); + this.WyHelmPieceTop1 = new ModelRenderer(this, 181, 49); + this.WyHelmPieceTop1.setRotationPoint(-0.5F, -8.5F, -4.5F); + this.WyHelmPieceTop1.addBox(0.0F, 0.0F, 0.0F, 1, 1, 3, 0.0F); + this.setRotateAngle(WyHelmPieceTop1, 0.2792526803190927F, -0.0F, 0.0F); - this.WyHelmPieceTop2 = new ModelRenderer(this, 201, 56); - this.WyHelmPieceTop2.setRotationPoint(-1.0F, -10.0F, -2.0F); - this.WyHelmPieceTop2.addBox(0.0F, 0.0F, 0.0F, 2, 2, 3, 0.0F); - this.setRotateAngle(WyHelmPieceTop2, 0.08726646259971647F, -0.0F, 0.0F); + this.WyHelmPieceTop2 = new ModelRenderer(this, 201, 56); + this.WyHelmPieceTop2.setRotationPoint(-1.0F, -10.0F, -2.0F); + this.WyHelmPieceTop2.addBox(0.0F, 0.0F, 0.0F, 2, 2, 3, 0.0F); + this.setRotateAngle(WyHelmPieceTop2, 0.08726646259971647F, -0.0F, 0.0F); - this.WyHelmPieceTop3 = new ModelRenderer(this, 188, 54); - this.WyHelmPieceTop3.setRotationPoint(-1.5F, -11.0F, 1.0F); - this.WyHelmPieceTop3.addBox(0.0F, 0.0F, 0.0F, 3, 3, 3, 0.0F); - this.setRotateAngle(WyHelmPieceTop3, -0.2792526803190927F, -0.0F, 0.0F); + this.WyHelmPieceTop3 = new ModelRenderer(this, 188, 54); + this.WyHelmPieceTop3.setRotationPoint(-1.5F, -11.0F, 1.0F); + this.WyHelmPieceTop3.addBox(0.0F, 0.0F, 0.0F, 3, 3, 3, 0.0F); + this.setRotateAngle(WyHelmPieceTop3, -0.2792526803190927F, -0.0F, 0.0F); - this.WyHelmPieceTop4 = new ModelRenderer(this, 179, 54); - this.WyHelmPieceTop4.setRotationPoint(-0.5F, -10.0F, 1.5F); - this.WyHelmPieceTop4.addBox(0.0F, 0.0F, 0.0F, 1, 1, 3, 0.0F); - this.setRotateAngle(WyHelmPieceTop4, -0.20943951023931953F, -0.0F, 0.0F); - } + this.WyHelmPieceTop4 = new ModelRenderer(this, 179, 54); + this.WyHelmPieceTop4.setRotationPoint(-0.5F, -10.0F, 1.5F); + this.WyHelmPieceTop4.addBox(0.0F, 0.0F, 0.0F, 1, 1, 3, 0.0F); + this.setRotateAngle(WyHelmPieceTop4, -0.20943951023931953F, -0.0F, 0.0F); + } /* Chest */ - { - this.bipedBody = new ModelRenderer(this, 16, 16); - this.bipedBody.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, 0.0F); + { + this.bipedBody = new ModelRenderer(this, 16, 16); + this.bipedBody.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, 0.0F); - this.DrMainChestPieceTop = new ModelRenderer(this, 214, 0); - this.DrMainChestPieceTop.setRotationPoint(-5.5F, -0.5F, -5.0F); - this.DrMainChestPieceTop.addBox(0.0F, 0.0F, 0.0F, 11, 4, 10, 0.0F); - this.setRotateAngle(DrMainChestPieceTop, 0.15707963705062866F, -0.0F, 0.0F); + this.DrMainChestPieceTop = new ModelRenderer(this, 214, 0); + this.DrMainChestPieceTop.setRotationPoint(-5.5F, -0.5F, -5.0F); + this.DrMainChestPieceTop.addBox(0.0F, 0.0F, 0.0F, 11, 4, 10, 0.0F); + this.setRotateAngle(DrMainChestPieceTop, 0.15707963705062866F, -0.0F, 0.0F); - this.DrMainChestPieceMid = new ModelRenderer(this, 224, 15); - this.DrMainChestPieceMid.setRotationPoint(-5.0F, 2.0F, -3.0F); - this.DrMainChestPieceMid.addBox(0.0F, 0.0F, 0.0F, 10, 5, 6, 0.0F); + this.DrMainChestPieceMid = new ModelRenderer(this, 224, 15); + this.DrMainChestPieceMid.setRotationPoint(-5.0F, 2.0F, -3.0F); + this.DrMainChestPieceMid.addBox(0.0F, 0.0F, 0.0F, 10, 5, 6, 0.0F); - this.WyChestPieceTop3 = new ModelRenderer(this, 239, 0); - this.WyChestPieceTop3.setRotationPoint(-3.5F, 4.5F, -3.5F); - this.WyChestPieceTop3.addBox(1.0F, 0.0F, 0.0F, 4, 4, 1, 0.0F); - this.setRotateAngle(WyChestPieceTop3, 0.0879645943005142F, 0.08621926504851989F, -0.7890633548266364F); + this.WyChestPieceTop3 = new ModelRenderer(this, 239, 0); + this.WyChestPieceTop3.setRotationPoint(-3.5F, 4.5F, -3.5F); + this.WyChestPieceTop3.addBox(1.0F, 0.0F, 0.0F, 4, 4, 1, 0.0F); + this.setRotateAngle(WyChestPieceTop3, 0.0879645943005142F, 0.08621926504851989F, -0.7890633548266364F); - this.WyMainChestPieceTop = new ModelRenderer(this, 250, 0); - this.WyMainChestPieceTop.setRotationPoint(-5.7F, 0.0F, -2.6F); - this.WyMainChestPieceTop.addBox(1.0F, 0.0F, 0.0F, 2, 4, 1, 0.0F); - this.setRotateAngle(WyMainChestPieceTop, 0.0F, 0.47123889803846897F, 0.0F); + this.WyMainChestPieceTop = new ModelRenderer(this, 250, 0); + this.WyMainChestPieceTop.setRotationPoint(-5.7F, 0.0F, -2.6F); + this.WyMainChestPieceTop.addBox(1.0F, 0.0F, 0.0F, 2, 4, 1, 0.0F); + this.setRotateAngle(WyMainChestPieceTop, 0.0F, 0.47123889803846897F, 0.0F); - this.MainChestPieceBottom = new ModelRenderer(this, 228, 27); - this.MainChestPieceBottom.setRotationPoint(-4.5F, 7.0F, -2.5F); - this.MainChestPieceBottom.addBox(0.0F, 0.0F, 0.0F, 9, 5, 5, 0.0F); + this.MainChestPieceBottom = new ModelRenderer(this, 228, 27); + this.MainChestPieceBottom.setRotationPoint(-4.5F, 7.0F, -2.5F); + this.MainChestPieceBottom.addBox(0.0F, 0.0F, 0.0F, 9, 5, 5, 0.0F); - this.DrChestDecorationPiece1 = new ModelRenderer(this, 244, 38); - this.DrChestDecorationPiece1.setRotationPoint(0.0F, -0.5F, -4.0F); - this.DrChestDecorationPiece1.addBox(0.0F, 0.0F, -0.5F, 5, 5, 1, 0.0F); - this.setRotateAngle(DrChestDecorationPiece1, 0.1426609064282019F, -0.13533507716461618F, 0.7946695004338321F); + this.DrChestDecorationPiece1 = new ModelRenderer(this, 244, 38); + this.DrChestDecorationPiece1.setRotationPoint(0.0F, -0.5F, -4.0F); + this.DrChestDecorationPiece1.addBox(0.0F, 0.0F, -0.5F, 5, 5, 1, 0.0F); + this.setRotateAngle(DrChestDecorationPiece1, 0.1426609064282019F, -0.13533507716461618F, 0.7946695004338321F); - this.ChestDecorationPiece2 = new ModelRenderer(this, 229, 38); - this.ChestDecorationPiece2.setRotationPoint(-3.0F, 7.0F, -3.0F); - this.ChestDecorationPiece2.addBox(0.0F, 0.0F, 0.0F, 6, 3, 1, 0.0F); - this.setRotateAngle(ChestDecorationPiece2, 0.12217304855585097F, -0.0F, 0.0F); + this.ChestDecorationPiece2 = new ModelRenderer(this, 229, 38); + this.ChestDecorationPiece2.setRotationPoint(-3.0F, 7.0F, -3.0F); + this.ChestDecorationPiece2.addBox(0.0F, 0.0F, 0.0F, 6, 3, 1, 0.0F); + this.setRotateAngle(ChestDecorationPiece2, 0.12217304855585097F, -0.0F, 0.0F); - this.DrChestDecorationPiece3 = new ModelRenderer(this, 236, 45); - this.DrChestDecorationPiece3.setRotationPoint(-4.0F, 1.0F, 3.0F); - this.DrChestDecorationPiece3.addBox(0.0F, 0.0F, 0.0F, 8, 5, 2, 0.0F); - this.setRotateAngle(DrChestDecorationPiece3, -0.39211732149124146F, -0.0F, 0.0F); + this.DrChestDecorationPiece3 = new ModelRenderer(this, 236, 45); + this.DrChestDecorationPiece3.setRotationPoint(-4.0F, 1.0F, 3.0F); + this.DrChestDecorationPiece3.addBox(0.0F, 0.0F, 0.0F, 8, 5, 2, 0.0F); + this.setRotateAngle(DrChestDecorationPiece3, -0.39211732149124146F, -0.0F, 0.0F); - this.ChestDecorationPiece4 = new ModelRenderer(this, 229, 38); - this.ChestDecorationPiece4.setRotationPoint(-3.0F, 6.800000190734863F, 2.0F); - this.ChestDecorationPiece4.addBox(0.0F, 0.0F, 0.0F, 6, 3, 1, 0.0F); - this.setRotateAngle(ChestDecorationPiece4, -0.12217304855585097F, -0.0F, 0.0F); + this.ChestDecorationPiece4 = new ModelRenderer(this, 229, 38); + this.ChestDecorationPiece4.setRotationPoint(-3.0F, 6.800000190734863F, 2.0F); + this.ChestDecorationPiece4.addBox(0.0F, 0.0F, 0.0F, 6, 3, 1, 0.0F); + this.setRotateAngle(ChestDecorationPiece4, -0.12217304855585097F, -0.0F, 0.0F); - this.WyMainChestPieceMid = new ModelRenderer(this, 224, 13); - this.WyMainChestPieceMid.setRotationPoint(-5.0F, -0.1F, -3.0F); - this.WyMainChestPieceMid.addBox(0.0F, 0.0F, 0.0F, 10, 7, 6, 0.0F); + this.WyMainChestPieceMid = new ModelRenderer(this, 224, 13); + this.WyMainChestPieceMid.setRotationPoint(-5.0F, -0.1F, -3.0F); + this.WyMainChestPieceMid.addBox(0.0F, 0.0F, 0.0F, 10, 7, 6, 0.0F); - this.WyChestPieceTop2 = new ModelRenderer(this, 250, 0); - this.WyChestPieceTop2.setRotationPoint(2.1F, 0.0F, -4.4F); - this.WyChestPieceTop2.addBox(1.0F, 0.0F, 0.0F, 2, 4, 1, 0.0F); - this.setRotateAngle(WyChestPieceTop2, 0.0F, -0.47123889803846897F, 0.0F); + this.WyChestPieceTop2 = new ModelRenderer(this, 250, 0); + this.WyChestPieceTop2.setRotationPoint(2.1F, 0.0F, -4.4F); + this.WyChestPieceTop2.addBox(1.0F, 0.0F, 0.0F, 2, 4, 1, 0.0F); + this.setRotateAngle(WyChestPieceTop2, 0.0F, -0.47123889803846897F, 0.0F); - this.WyChestPieceTop1 = new ModelRenderer(this, 240, 6); - this.WyChestPieceTop1.setRotationPoint(-4.0F, 0.0F, -4.0F); - this.WyChestPieceTop1.addBox(1.0F, 0.0F, 0.0F, 6, 4, 2, 0.0F); + this.WyChestPieceTop1 = new ModelRenderer(this, 240, 6); + this.WyChestPieceTop1.setRotationPoint(-4.0F, 0.0F, -4.0F); + this.WyChestPieceTop1.addBox(1.0F, 0.0F, 0.0F, 6, 4, 2, 0.0F); - this.WyChestDecorationPiece3 = new ModelRenderer(this, 236, 45); - this.WyChestDecorationPiece3.setRotationPoint(-3.5F, 0.0F, 2.5F); - this.WyChestDecorationPiece3.addBox(0.0F, 0.0F, 0.0F, 7, 5, 2, 0.0F); - this.setRotateAngle(WyChestDecorationPiece3, -0.2617993877991494F, -0.0F, 0.0F); + this.WyChestDecorationPiece3 = new ModelRenderer(this, 236, 45); + this.WyChestDecorationPiece3.setRotationPoint(-3.5F, 0.0F, 2.5F); + this.WyChestDecorationPiece3.addBox(0.0F, 0.0F, 0.0F, 7, 5, 2, 0.0F); + this.setRotateAngle(WyChestDecorationPiece3, -0.2617993877991494F, -0.0F, 0.0F); - this.BeltFront = new ModelRenderer(this, 121, 25); - this.BeltFront.setRotationPoint(0.5F, 10.01F, -2.0F); - this.BeltFront.addBox(-5.0F, 0.0F, -0.7F, 9, 2, 1, 0.0F); + this.BeltFront = new ModelRenderer(this, 121, 25); + this.BeltFront.setRotationPoint(0.5F, 10.01F, -2.0F); + this.BeltFront.addBox(-5.0F, 0.0F, -0.7F, 9, 2, 1, 0.0F); - this.BeltBuckle = new ModelRenderer(this, 121, 29); - this.BeltBuckle.setRotationPoint(3.5F, 10.0F, -2.2F); - this.BeltBuckle.addBox(-5.0F, 0.0F, -0.7F, 3, 2, 1, 0.0F); + this.BeltBuckle = new ModelRenderer(this, 121, 29); + this.BeltBuckle.setRotationPoint(3.5F, 10.0F, -2.2F); + this.BeltBuckle.addBox(-5.0F, 0.0F, -0.7F, 3, 2, 1, 0.0F); - this.BeltBack = new ModelRenderer(this, 121, 25); - this.BeltBack.setRotationPoint(0.5F, 10.01F, 2.0F); - this.BeltBack.addBox(-5.0F, 0.0F, -0.3F, 9, 2, 1, 0.0F); + this.BeltBack = new ModelRenderer(this, 121, 25); + this.BeltBack.setRotationPoint(0.5F, 10.01F, 2.0F); + this.BeltBack.addBox(-5.0F, 0.0F, -0.3F, 9, 2, 1, 0.0F); - this.BeltRight = new ModelRenderer(this, 142, 25); - this.BeltRight.setRotationPoint(-4.7F, 10.01F, -2.2F); - this.BeltRight.addBox(0.0F, 0.0F, -0.3F, 1, 2, 5, 0.0F); + this.BeltRight = new ModelRenderer(this, 142, 25); + this.BeltRight.setRotationPoint(-4.7F, 10.01F, -2.2F); + this.BeltRight.addBox(0.0F, 0.0F, -0.3F, 1, 2, 5, 0.0F); - this.BeltLeft = new ModelRenderer(this, 142, 25); - this.BeltLeft.setRotationPoint(3.7F, 10.01F, -2.2F); - this.BeltLeft.addBox(0.0F, 0.0F, -0.3F, 1, 2, 5, 0.0F); + this.BeltLeft = new ModelRenderer(this, 142, 25); + this.BeltLeft.setRotationPoint(3.7F, 10.01F, -2.2F); + this.BeltLeft.addBox(0.0F, 0.0F, -0.3F, 1, 2, 5, 0.0F); - //Left - this.bipedLeftArm = new ModelRenderer(this, 40, 16); - this.bipedLeftArm.setRotationPoint(5.0F, 2.0F, 0.0F); - this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, 0.0F); + //Left + this.bipedLeftArm = new ModelRenderer(this, 40, 16); + this.bipedLeftArm.setRotationPoint(5.0F, 2.0F, 0.0F); + this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, 0.0F); - this.ShoulderPadLeft1 = new ModelRenderer(this, 236, 53); - this.ShoulderPadLeft1.setRotationPoint(-1.5F, -2.0F, -2.5F); - this.ShoulderPadLeft1.addBox(0.0F, 0.0F, 0.0F, 5, 4, 5, 0.0F); + this.ShoulderPadLeft1 = new ModelRenderer(this, 236, 53); + this.ShoulderPadLeft1.setRotationPoint(-1.5F, -2.0F, -2.5F); + this.ShoulderPadLeft1.addBox(0.0F, 0.0F, 0.0F, 5, 4, 5, 0.0F); - this.ShoulderPadLeft2 = new ModelRenderer(this, 232, 63); - this.ShoulderPadLeft2.setRotationPoint(-1.0F, -2.5F, -3.0F); - this.ShoulderPadLeft2.addBox(-0.3F, 0.0F, 0.0F, 6, 2, 6, 0.0F); - this.setRotateAngle(ShoulderPadLeft2, 0.0F, -0.0F, 0.3665191429188092F); + this.ShoulderPadLeft2 = new ModelRenderer(this, 232, 63); + this.ShoulderPadLeft2.setRotationPoint(-1.0F, -2.5F, -3.0F); + this.ShoulderPadLeft2.addBox(-0.3F, 0.0F, 0.0F, 6, 2, 6, 0.0F); + this.setRotateAngle(ShoulderPadLeft2, 0.0F, -0.0F, 0.3665191429188092F); - this.ShoulderPadLeft3 = new ModelRenderer(this, 215, 53); - this.ShoulderPadLeft3.mirror = true; - this.ShoulderPadLeft3.setRotationPoint(-1.0F, -3.0F, -2.5F); - this.ShoulderPadLeft3.addBox(0.3F, -0.5F, 0.0F, 5, 2, 5, 0.0F); - this.setRotateAngle(ShoulderPadLeft3, 0.0F, -0.0F, 0.20943951023931953F); + this.ShoulderPadLeft3 = new ModelRenderer(this, 215, 53); + this.ShoulderPadLeft3.mirror = true; + this.ShoulderPadLeft3.setRotationPoint(-1.0F, -3.0F, -2.5F); + this.ShoulderPadLeft3.addBox(0.3F, -0.5F, 0.0F, 5, 2, 5, 0.0F); + this.setRotateAngle(ShoulderPadLeft3, 0.0F, -0.0F, 0.20943951023931953F); - this.ShoulderPadLeft4 = new ModelRenderer(this, 219, 61); - this.ShoulderPadLeft4.setRotationPoint(-0.5F, -2.5F, -2.0F); - this.ShoulderPadLeft4.addBox(0.7F, -2.0F, 0.5F, 3, 2, 3, 0.0F); - this.setRotateAngle(ShoulderPadLeft4, 0.0F, -0.0F, 0.12217304763960307F); + this.ShoulderPadLeft4 = new ModelRenderer(this, 219, 61); + this.ShoulderPadLeft4.setRotationPoint(-0.5F, -2.5F, -2.0F); + this.ShoulderPadLeft4.addBox(0.7F, -2.0F, 0.5F, 3, 2, 3, 0.0F); + this.setRotateAngle(ShoulderPadLeft4, 0.0F, -0.0F, 0.12217304763960307F); - this.MainArmGuardLeft = new ModelRenderer(this, 240, 72); - this.MainArmGuardLeft.setRotationPoint(0.5F, 3.0F, -2.5F); - this.MainArmGuardLeft.addBox(0.0F, 0.0F, 0.0F, 3, 5, 5, 0.0F); + this.MainArmGuardLeft = new ModelRenderer(this, 240, 72); + this.MainArmGuardLeft.setRotationPoint(0.5F, 3.0F, -2.5F); + this.MainArmGuardLeft.addBox(0.0F, 0.0F, 0.0F, 3, 5, 5, 0.0F); - this.ArmGuardPieceLeft1 = new ModelRenderer(this, 223, 67); - this.ArmGuardPieceLeft1.setRotationPoint(2.5F, 6.0F, -1.5F); - this.ArmGuardPieceLeft1.addBox(0.2F, -0.3F, 0.0F, 1, 2, 3, 0.0F); - this.setRotateAngle(ArmGuardPieceLeft1, 0.0F, -0.0F, -0.17453292519943295F); + this.ArmGuardPieceLeft1 = new ModelRenderer(this, 223, 67); + this.ArmGuardPieceLeft1.setRotationPoint(2.5F, 6.0F, -1.5F); + this.ArmGuardPieceLeft1.addBox(0.2F, -0.3F, 0.0F, 1, 2, 3, 0.0F); + this.setRotateAngle(ArmGuardPieceLeft1, 0.0F, -0.0F, -0.17453292519943295F); - this.ArmGuardPieceLeft2 = new ModelRenderer(this, 223, 67); - this.ArmGuardPieceLeft2.setRotationPoint(2.5F, 5.0F, -1.5F); - this.ArmGuardPieceLeft2.addBox(0.2F, -0.3F, 0.0F, 1, 2, 3, 0.0F); - this.setRotateAngle(ArmGuardPieceLeft2, 0.0F, -0.0F, -0.17453292519943295F); + this.ArmGuardPieceLeft2 = new ModelRenderer(this, 223, 67); + this.ArmGuardPieceLeft2.setRotationPoint(2.5F, 5.0F, -1.5F); + this.ArmGuardPieceLeft2.addBox(0.2F, -0.3F, 0.0F, 1, 2, 3, 0.0F); + this.setRotateAngle(ArmGuardPieceLeft2, 0.0F, -0.0F, -0.17453292519943295F); - this.ArmGuardPieceLeft3 = new ModelRenderer(this, 223, 67); - this.ArmGuardPieceLeft3.setRotationPoint(2.5F, 4.0F, -1.5F); - this.ArmGuardPieceLeft3.addBox(0.2F, -0.3F, 0.0F, 1, 2, 3, 0.0F); - this.setRotateAngle(ArmGuardPieceLeft3, 0.0F, -0.0F, -0.17453292519943295F); + this.ArmGuardPieceLeft3 = new ModelRenderer(this, 223, 67); + this.ArmGuardPieceLeft3.setRotationPoint(2.5F, 4.0F, -1.5F); + this.ArmGuardPieceLeft3.addBox(0.2F, -0.3F, 0.0F, 1, 2, 3, 0.0F); + this.setRotateAngle(ArmGuardPieceLeft3, 0.0F, -0.0F, -0.17453292519943295F); - this.ArmGuardPieceLeft4 = new ModelRenderer(this, 231, 72); - this.ArmGuardPieceLeft4.setRotationPoint(2.5F, 3.0F, -1.5F); - this.ArmGuardPieceLeft4.addBox(0.2F, 0.6F, 0.0F, 1, 1, 3, 0.0F); - this.setRotateAngle(ArmGuardPieceLeft4, 0.0F, -0.0F, -0.17453292519943295F); + this.ArmGuardPieceLeft4 = new ModelRenderer(this, 231, 72); + this.ArmGuardPieceLeft4.setRotationPoint(2.5F, 3.0F, -1.5F); + this.ArmGuardPieceLeft4.addBox(0.2F, 0.6F, 0.0F, 1, 1, 3, 0.0F); + this.setRotateAngle(ArmGuardPieceLeft4, 0.0F, -0.0F, -0.17453292519943295F); - this.ArmStrapLeftTop = new ModelRenderer(this, 225, 77); - this.ArmStrapLeftTop.setRotationPoint(-1.43F, 3.0F, -2.5F); - this.ArmStrapLeftTop.addBox(0.0F, 0.0F, 0.0F, 2, 1, 5, 0.0F); + this.ArmStrapLeftTop = new ModelRenderer(this, 225, 77); + this.ArmStrapLeftTop.setRotationPoint(-1.43F, 3.0F, -2.5F); + this.ArmStrapLeftTop.addBox(0.0F, 0.0F, 0.0F, 2, 1, 5, 0.0F); - this.ArmStrapLeftBottom = new ModelRenderer(this, 225, 77); - this.ArmStrapLeftBottom.setRotationPoint(-1.5F, 7.0F, -2.5F); - this.ArmStrapLeftBottom.addBox(0.0F, 0.0F, 0.0F, 2, 1, 5, 0.0F); + this.ArmStrapLeftBottom = new ModelRenderer(this, 225, 77); + this.ArmStrapLeftBottom.setRotationPoint(-1.5F, 7.0F, -2.5F); + this.ArmStrapLeftBottom.addBox(0.0F, 0.0F, 0.0F, 2, 1, 5, 0.0F); - //Right - this.MainArmGuardRight = new ModelRenderer(this, 240, 72); - this.MainArmGuardRight.setRotationPoint(-3.5F, 3.0F, -2.5F); - this.MainArmGuardRight.addBox(0.0F, 0.0F, 0.0F, 3, 5, 5, 0.0F); + //Right + this.MainArmGuardRight = new ModelRenderer(this, 240, 72); + this.MainArmGuardRight.setRotationPoint(-3.5F, 3.0F, -2.5F); + this.MainArmGuardRight.addBox(0.0F, 0.0F, 0.0F, 3, 5, 5, 0.0F); - this.ArmGuardPieceRight1 = new ModelRenderer(this, 231, 72); - this.ArmGuardPieceRight1.setRotationPoint(-3.9F, 2.8F, -1.5F); - this.ArmGuardPieceRight1.addBox(0.2F, 0.6F, 0.0F, 1, 1, 3, 0.0F); - this.setRotateAngle(ArmGuardPieceRight1, 0.0F, -0.0F, 0.17453292519943295F); + this.ArmGuardPieceRight1 = new ModelRenderer(this, 231, 72); + this.ArmGuardPieceRight1.setRotationPoint(-3.9F, 2.8F, -1.5F); + this.ArmGuardPieceRight1.addBox(0.2F, 0.6F, 0.0F, 1, 1, 3, 0.0F); + this.setRotateAngle(ArmGuardPieceRight1, 0.0F, -0.0F, 0.17453292519943295F); - this.ArmGuardPieceRight2 = new ModelRenderer(this, 223, 67); - this.ArmGuardPieceRight2.setRotationPoint(-4.6F, 4.1F, -1.5F); - this.ArmGuardPieceRight2.addBox(0.8F, -0.7F, 0.0F, 1, 2, 3, 0.0F); - this.setRotateAngle(ArmGuardPieceRight2, 0.0F, -0.0F, 0.17453292519943295F); + this.ArmGuardPieceRight2 = new ModelRenderer(this, 223, 67); + this.ArmGuardPieceRight2.setRotationPoint(-4.6F, 4.1F, -1.5F); + this.ArmGuardPieceRight2.addBox(0.8F, -0.7F, 0.0F, 1, 2, 3, 0.0F); + this.setRotateAngle(ArmGuardPieceRight2, 0.0F, -0.0F, 0.17453292519943295F); - this.ArmGuardPieceRight3 = new ModelRenderer(this, 223, 67); - this.ArmGuardPieceRight3.setRotationPoint(-4.03F, 5.3F, -1.5F); - this.ArmGuardPieceRight3.addBox(0.2F, -0.8F, 0.0F, 1, 2, 3, 0.0F); - this.setRotateAngle(ArmGuardPieceRight3, 0.0F, -0.0F, 0.17453292519943295F); + this.ArmGuardPieceRight3 = new ModelRenderer(this, 223, 67); + this.ArmGuardPieceRight3.setRotationPoint(-4.03F, 5.3F, -1.5F); + this.ArmGuardPieceRight3.addBox(0.2F, -0.8F, 0.0F, 1, 2, 3, 0.0F); + this.setRotateAngle(ArmGuardPieceRight3, 0.0F, -0.0F, 0.17453292519943295F); - this.ArmGuardPieceRight4 = new ModelRenderer(this, 223, 67); - this.ArmGuardPieceRight4.setRotationPoint(-4.0F, 6.8F, -1.5F); - this.ArmGuardPieceRight4.addBox(0.1F, -1.3F, 0.0F, 1, 2, 3, 0.0F); - this.setRotateAngle(ArmGuardPieceRight4, 0.0F, -0.0F, 0.17453292519943295F); + this.ArmGuardPieceRight4 = new ModelRenderer(this, 223, 67); + this.ArmGuardPieceRight4.setRotationPoint(-4.0F, 6.8F, -1.5F); + this.ArmGuardPieceRight4.addBox(0.1F, -1.3F, 0.0F, 1, 2, 3, 0.0F); + this.setRotateAngle(ArmGuardPieceRight4, 0.0F, -0.0F, 0.17453292519943295F); - this.ShoulderPadRight1 = new ModelRenderer(this, 236, 53); - this.ShoulderPadRight1.setRotationPoint(-3.5F, -2.0F, -2.5F); - this.ShoulderPadRight1.addBox(0.0F, 0.0F, 0.0F, 5, 4, 5, 0.0F); + this.ShoulderPadRight1 = new ModelRenderer(this, 236, 53); + this.ShoulderPadRight1.setRotationPoint(-3.5F, -2.0F, -2.5F); + this.ShoulderPadRight1.addBox(0.0F, 0.0F, 0.0F, 5, 4, 5, 0.0F); - this.ShoulderPadRight2 = new ModelRenderer(this, 232, 63); - this.ShoulderPadRight2.setRotationPoint(-5.0F, -2.5F, -3.0F); - this.ShoulderPadRight2.addBox(-0.1F, 2.1F, 0.0F, 6, 2, 6, 0.0F); - this.setRotateAngle(ShoulderPadRight2, 0.0F, -0.0F, -0.3665191429188092F); + this.ShoulderPadRight2 = new ModelRenderer(this, 232, 63); + this.ShoulderPadRight2.setRotationPoint(-5.0F, -2.5F, -3.0F); + this.ShoulderPadRight2.addBox(-0.1F, 2.1F, 0.0F, 6, 2, 6, 0.0F); + this.setRotateAngle(ShoulderPadRight2, 0.0F, -0.0F, -0.3665191429188092F); - this.ShoulderPadRight3 = new ModelRenderer(this, 215, 53); - this.ShoulderPadRight3.setRotationPoint(-5.0F, -3.0F, -2.5F); - this.ShoulderPadRight3.addBox(0.6F, 0.7F, 0.0F, 5, 2, 5, 0.0F); - this.setRotateAngle(ShoulderPadRight3, 0.0F, -0.0F, -0.20943951023931953F); + this.ShoulderPadRight3 = new ModelRenderer(this, 215, 53); + this.ShoulderPadRight3.setRotationPoint(-5.0F, -3.0F, -2.5F); + this.ShoulderPadRight3.addBox(0.6F, 0.7F, 0.0F, 5, 2, 5, 0.0F); + this.setRotateAngle(ShoulderPadRight3, 0.0F, -0.0F, -0.20943951023931953F); - this.ShoulderPadRight4 = new ModelRenderer(this, 219, 61); - this.ShoulderPadRight4.setRotationPoint(-4.5F, -2.5F, -2.0F); - this.ShoulderPadRight4.addBox(1.3F, -1.5F, 0.5F, 3, 2, 3, 0.0F); - this.setRotateAngle(ShoulderPadRight4, 0.0F, -0.0F, -0.12217304763960307F); + this.ShoulderPadRight4 = new ModelRenderer(this, 219, 61); + this.ShoulderPadRight4.setRotationPoint(-4.5F, -2.5F, -2.0F); + this.ShoulderPadRight4.addBox(1.3F, -1.5F, 0.5F, 3, 2, 3, 0.0F); + this.setRotateAngle(ShoulderPadRight4, 0.0F, -0.0F, -0.12217304763960307F); - this.bipedRightArm = new ModelRenderer(this, 40, 16); - this.bipedRightArm.setRotationPoint(-5.0F, 2.0F, 0.0F); - this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, 0.0F); + this.bipedRightArm = new ModelRenderer(this, 40, 16); + this.bipedRightArm.setRotationPoint(-5.0F, 2.0F, 0.0F); + this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, 0.0F); - this.ArmStrapRightTop = new ModelRenderer(this, 225, 77); - this.ArmStrapRightTop.setRotationPoint(-0.5F, 3.0F, -2.5F); - this.ArmStrapRightTop.addBox(0.0F, 0.0F, 0.0F, 2, 1, 5, 0.0F); + this.ArmStrapRightTop = new ModelRenderer(this, 225, 77); + this.ArmStrapRightTop.setRotationPoint(-0.5F, 3.0F, -2.5F); + this.ArmStrapRightTop.addBox(0.0F, 0.0F, 0.0F, 2, 1, 5, 0.0F); - this.ArmStrapRightBottom = new ModelRenderer(this, 225, 77); - this.ArmStrapRightBottom.setRotationPoint(-0.5F, 7.0F, -2.5F); - this.ArmStrapRightBottom.addBox(0.0F, 0.0F, 0.0F, 2, 1, 5, 0.0F); - } + this.ArmStrapRightBottom = new ModelRenderer(this, 225, 77); + this.ArmStrapRightBottom.setRotationPoint(-0.5F, 7.0F, -2.5F); + this.ArmStrapRightBottom.addBox(0.0F, 0.0F, 0.0F, 2, 1, 5, 0.0F); + } /* Leggs */ - { - this.LeggsTop = new ModelRenderer(this, 121, 15); - this.LeggsTop.setRotationPoint(0.5F, 8.0F, -2.4F); - this.LeggsTop.addBox(-5.0F, 0.0F, 0.0F, 9, 4, 5, 0.0F); - //Left - this.bipedLeftLeg = new ModelRenderer(this, 0, 16); - this.bipedLeftLeg.setRotationPoint(2.0F, 12.0F, 0.0F); - this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0.0F); + { + this.LeggsTop = new ModelRenderer(this, 121, 15); + this.LeggsTop.setRotationPoint(0.5F, 8.0F, -2.4F); + this.LeggsTop.addBox(-5.0F, 0.0F, 0.0F, 9, 4, 5, 0.0F); + //Left + this.bipedLeftLeg = new ModelRenderer(this, 0, 16); + this.bipedLeftLeg.setRotationPoint(2.0F, 12.0F, 0.0F); + this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0.0F); - this.MainLegPieceLeft = new ModelRenderer(this, 149, 0); - this.MainLegPieceLeft.setRotationPoint(-2.0F, -1F, -2.5F); - this.MainLegPieceLeft.addBox(0.0F, 0.0F, 0.0F, 4, 10, 5, 0.0F); + this.MainLegPieceLeft = new ModelRenderer(this, 149, 0); + this.MainLegPieceLeft.setRotationPoint(-2.0F, -1F, -2.5F); + this.MainLegPieceLeft.addBox(0.0F, 0.0F, 0.0F, 4, 10, 5, 0.0F); - this.LegPieceLeft1 = new ModelRenderer(this, 138, 0); - this.LegPieceLeft1.setRotationPoint(1.5F, -1F, -2.0F); - this.LegPieceLeft1.addBox(0.0F, 0.0F, 0.0F, 1, 10, 4, 0.0F); + this.LegPieceLeft1 = new ModelRenderer(this, 138, 0); + this.LegPieceLeft1.setRotationPoint(1.5F, -1F, -2.0F); + this.LegPieceLeft1.addBox(0.0F, 0.0F, 0.0F, 1, 10, 4, 0.0F); - this.LegPieceLeft2 = new ModelRenderer(this, 138, 0); - this.LegPieceLeft2.setRotationPoint(-2.5F, -1F, -2.0F); - this.LegPieceLeft2.addBox(0.0F, 0.0F, 0.0F, 1, 10, 4, 0.0F); + this.LegPieceLeft2 = new ModelRenderer(this, 138, 0); + this.LegPieceLeft2.setRotationPoint(-2.5F, -1F, -2.0F); + this.LegPieceLeft2.addBox(0.0F, 0.0F, 0.0F, 1, 10, 4, 0.0F); - this.MainKneePadLeft = new ModelRenderer(this, 149, 15); - this.MainKneePadLeft.setRotationPoint(0.0F, 2.5F, -3.0F); - this.MainKneePadLeft.addBox(0.0F, 0.0F, 0.0F, 2, 2, 1, 0.0F); - this.setRotateAngle(MainKneePadLeft, 0.0F, -0.0F, 0.7853981633974483F); + this.MainKneePadLeft = new ModelRenderer(this, 149, 15); + this.MainKneePadLeft.setRotationPoint(0.0F, 2.5F, -3.0F); + this.MainKneePadLeft.addBox(0.0F, 0.0F, 0.0F, 2, 2, 1, 0.0F); + this.setRotateAngle(MainKneePadLeft, 0.0F, -0.0F, 0.7853981633974483F); - this.KneePieceLeft1 = new ModelRenderer(this, 156, 15); - this.KneePieceLeft1.setRotationPoint(-0.5F, 2.0F, -2.7F); - this.KneePieceLeft1.addBox(0.0F, 0.0F, 0.0F, 1, 4, 1, 0.0F); + this.KneePieceLeft1 = new ModelRenderer(this, 156, 15); + this.KneePieceLeft1.setRotationPoint(-0.5F, 2.0F, -2.7F); + this.KneePieceLeft1.addBox(0.0F, 0.0F, 0.0F, 1, 4, 1, 0.0F); - //Right - this.bipedRightLeg = new ModelRenderer(this, 0, 16); - this.bipedRightLeg.setRotationPoint(-2.0F, 12.0F, 0.0F); - this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0.0F); + //Right + this.bipedRightLeg = new ModelRenderer(this, 0, 16); + this.bipedRightLeg.setRotationPoint(-2.0F, 12.0F, 0.0F); + this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0.0F); - this.MainLegPieceRight = new ModelRenderer(this, 149, 0); - this.MainLegPieceRight.setRotationPoint(-2.0F, -1F, -2.5F); - this.MainLegPieceRight.addBox(0.0F, 0.0F, 0.0F, 4, 10, 5, 0.0F); + this.MainLegPieceRight = new ModelRenderer(this, 149, 0); + this.MainLegPieceRight.setRotationPoint(-2.0F, -1F, -2.5F); + this.MainLegPieceRight.addBox(0.0F, 0.0F, 0.0F, 4, 10, 5, 0.0F); - this.LegPieceRight1 = new ModelRenderer(this, 138, 0); - this.LegPieceRight1.setRotationPoint(-2.5F, -1F, -2.0F); - this.LegPieceRight1.addBox(0.0F, 0.0F, 0.0F, 1, 10, 4, 0.0F); + this.LegPieceRight1 = new ModelRenderer(this, 138, 0); + this.LegPieceRight1.setRotationPoint(-2.5F, -1F, -2.0F); + this.LegPieceRight1.addBox(0.0F, 0.0F, 0.0F, 1, 10, 4, 0.0F); - this.LegPieceRight2 = new ModelRenderer(this, 138, 0); - this.LegPieceRight2.setRotationPoint(1.5F, -1F, -2.0F); - this.LegPieceRight2.addBox(0.0F, 0.0F, 0.0F, 1, 10, 4, 0.0F); + this.LegPieceRight2 = new ModelRenderer(this, 138, 0); + this.LegPieceRight2.setRotationPoint(1.5F, -1F, -2.0F); + this.LegPieceRight2.addBox(0.0F, 0.0F, 0.0F, 1, 10, 4, 0.0F); - this.MainKneePadRight = new ModelRenderer(this, 149, 15); - this.MainKneePadRight.setRotationPoint(0.0F, 2.5F, -3.0F); - this.MainKneePadRight.addBox(0.0F, 0.0F, 0.0F, 2, 2, 1, 0.0F); + this.MainKneePadRight = new ModelRenderer(this, 149, 15); + this.MainKneePadRight.setRotationPoint(0.0F, 2.5F, -3.0F); + this.MainKneePadRight.addBox(0.0F, 0.0F, 0.0F, 2, 2, 1, 0.0F); - this.setRotateAngle(MainKneePadRight, 0.0F, -0.0F, 0.7853981633974483F); - this.KneePieceRight1 = new ModelRenderer(this, 156, 15); - this.KneePieceRight1.setRotationPoint(-0.5F, 2.0F, -2.7F); - this.KneePieceRight1.addBox(0.0F, 0.0F, 0.0F, 1, 4, 1, 0.0F); + this.setRotateAngle(MainKneePadRight, 0.0F, -0.0F, 0.7853981633974483F); + this.KneePieceRight1 = new ModelRenderer(this, 156, 15); + this.KneePieceRight1.setRotationPoint(-0.5F, 2.0F, -2.7F); + this.KneePieceRight1.addBox(0.0F, 0.0F, 0.0F, 1, 4, 1, 0.0F); - } + } /* Boots */ - { - //Left - this.MainBootPieceLeft = new ModelRenderer(this, 119, 0); - this.MainBootPieceLeft.setRotationPoint(-2.0F, 9.1F, -2.5F); - this.MainBootPieceLeft.addBox(0.0F, 0.0F, 0.0F, 4, 3, 5, 0.0F); + { + //Left + this.MainBootPieceLeft = new ModelRenderer(this, 119, 0); + this.MainBootPieceLeft.setRotationPoint(-2.0F, 9.1F, -2.5F); + this.MainBootPieceLeft.addBox(0.0F, 0.0F, 0.0F, 4, 3, 5, 0.0F); - this.BootPieceLeft1 = new ModelRenderer(this, 129, 9); - this.BootPieceLeft1.setRotationPoint(-1.5F, 9.0F, -3.5F); - this.BootPieceLeft1.addBox(0.0F, 0.0F, 0.0F, 3, 3, 1, 0.0F); + this.BootPieceLeft1 = new ModelRenderer(this, 129, 9); + this.BootPieceLeft1.setRotationPoint(-1.5F, 9.0F, -3.5F); + this.BootPieceLeft1.addBox(0.0F, 0.0F, 0.0F, 3, 3, 1, 0.0F); - this.BootPieceLeft2 = new ModelRenderer(this, 122, 9); - this.BootPieceLeft2.setRotationPoint(-1.0F, 9.0F, -2.5F); - this.BootPieceLeft2.addBox(0.0F, 0.0F, 0.0F, 2, 2, 1, 0.0F); - this.setRotateAngle(BootPieceLeft2, -0.40142572795869574F, -0.0F, 0.0F); + this.BootPieceLeft2 = new ModelRenderer(this, 122, 9); + this.BootPieceLeft2.setRotationPoint(-1.0F, 9.0F, -2.5F); + this.BootPieceLeft2.addBox(0.0F, 0.0F, 0.0F, 2, 2, 1, 0.0F); + this.setRotateAngle(BootPieceLeft2, -0.40142572795869574F, -0.0F, 0.0F); - this.BootPieceLeft3 = new ModelRenderer(this, 138, 0); - this.BootPieceLeft3.setRotationPoint(1.5F, 9.05F, -2.0F); - this.BootPieceLeft3.addBox(0.0F, 0.0F, 0.0F, 1, 3, 4, 0.0F); + this.BootPieceLeft3 = new ModelRenderer(this, 138, 0); + this.BootPieceLeft3.setRotationPoint(1.5F, 9.05F, -2.0F); + this.BootPieceLeft3.addBox(0.0F, 0.0F, 0.0F, 1, 3, 4, 0.0F); - this.BootPieceLeft4 = new ModelRenderer(this, 138, 0); - this.BootPieceLeft4.setRotationPoint(-2.5F, 9.05F, -2.0F); - this.BootPieceLeft4.addBox(0.0F, 0.0F, 0.0F, 1, 3, 4, 0.0F); + this.BootPieceLeft4 = new ModelRenderer(this, 138, 0); + this.BootPieceLeft4.setRotationPoint(-2.5F, 9.05F, -2.0F); + this.BootPieceLeft4.addBox(0.0F, 0.0F, 0.0F, 1, 3, 4, 0.0F); - //Right - this.MainBootPieceRight = new ModelRenderer(this, 119, 0); - this.MainBootPieceRight.setRotationPoint(-2.0F, 9.1F, -2.5F); - this.MainBootPieceRight.addBox(0.0F, 0.0F, 0.0F, 4, 3, 5, 0.0F); + //Right + this.MainBootPieceRight = new ModelRenderer(this, 119, 0); + this.MainBootPieceRight.setRotationPoint(-2.0F, 9.1F, -2.5F); + this.MainBootPieceRight.addBox(0.0F, 0.0F, 0.0F, 4, 3, 5, 0.0F); - this.BootPieceRight1 = new ModelRenderer(this, 129, 9); - this.BootPieceRight1.setRotationPoint(-1.5F, 9.0F, -3.5F); - this.BootPieceRight1.addBox(0.0F, 0.0F, 0.0F, 3, 3, 1, 0.0F); + this.BootPieceRight1 = new ModelRenderer(this, 129, 9); + this.BootPieceRight1.setRotationPoint(-1.5F, 9.0F, -3.5F); + this.BootPieceRight1.addBox(0.0F, 0.0F, 0.0F, 3, 3, 1, 0.0F); - this.BootPieceRight2 = new ModelRenderer(this, 122, 9); - this.BootPieceRight2.setRotationPoint(-1.0F, 9.0F, -2.5F); - this.BootPieceRight2.addBox(0.0F, 0.0F, 0.0F, 2, 2, 1, 0.0F); - this.setRotateAngle(BootPieceRight2, -0.40142572795869574F, -0.0F, 0.0F); + this.BootPieceRight2 = new ModelRenderer(this, 122, 9); + this.BootPieceRight2.setRotationPoint(-1.0F, 9.0F, -2.5F); + this.BootPieceRight2.addBox(0.0F, 0.0F, 0.0F, 2, 2, 1, 0.0F); + this.setRotateAngle(BootPieceRight2, -0.40142572795869574F, -0.0F, 0.0F); - this.BootPieceRight3 = new ModelRenderer(this, 138, 0); - this.BootPieceRight3.setRotationPoint(-2.5F, 9.05F, -2.0F); - this.BootPieceRight3.addBox(0.0F, 0.0F, 0.0F, 1, 3, 4, 0.0F); + this.BootPieceRight3 = new ModelRenderer(this, 138, 0); + this.BootPieceRight3.setRotationPoint(-2.5F, 9.05F, -2.0F); + this.BootPieceRight3.addBox(0.0F, 0.0F, 0.0F, 1, 3, 4, 0.0F); - this.BootPieceRight4 = new ModelRenderer(this, 138, 0); - this.BootPieceRight4.setRotationPoint(1.5F, 9.05F, -2.0F); - this.BootPieceRight4.addBox(0.0F, 0.0F, 0.0F, 1, 3, 4, 0.0F); - } + this.BootPieceRight4 = new ModelRenderer(this, 138, 0); + this.BootPieceRight4.setRotationPoint(1.5F, 9.05F, -2.0F); + this.BootPieceRight4.addBox(0.0F, 0.0F, 0.0F, 1, 3, 4, 0.0F); + } - this.bipedHead.cubeList.clear(); - this.bipedHeadwear.cubeList.clear(); - if (isHelmet){ - this.bipedHead.addChild(this.MainHelmPieceLeft1); - this.bipedHead.addChild(this.HelmPieceFront2); - this.bipedHead.addChild(this.MainHelmPieceRight2); - this.bipedHead.addChild(this.MainHelmPieceTop); - this.bipedHead.addChild(this.MainHelmPieceFrontBottom); - this.bipedHead.addChild(this.HornPieceRight1); - this.bipedHead.addChild(this.HornPieceLeft1); + this.bipedHead.cubeList.clear(); + this.bipedHeadwear.cubeList.clear(); + if (isHelmet) { + this.bipedHead.addChild(this.MainHelmPieceLeft1); + this.bipedHead.addChild(this.HelmPieceFront2); + this.bipedHead.addChild(this.MainHelmPieceRight2); + this.bipedHead.addChild(this.MainHelmPieceTop); + this.bipedHead.addChild(this.MainHelmPieceFrontBottom); + this.bipedHead.addChild(this.HornPieceRight1); + this.bipedHead.addChild(this.HornPieceLeft1); - this.bipedHead.addChild(this.MainHelmPieceLeft2); - this.bipedHead.addChild(this.HornPieceRight3); - this.bipedHead.addChild(this.HornPieceLeft3); - this.bipedHead.addChild(this.HelmPieceBack1); + this.bipedHead.addChild(this.MainHelmPieceLeft2); + this.bipedHead.addChild(this.HornPieceRight3); + this.bipedHead.addChild(this.HornPieceLeft3); + this.bipedHead.addChild(this.HelmPieceBack1); - this.bipedHead.addChild(this.MainHelmPieceLeft3); - this.bipedHead.addChild(this.MainHelmPieceRight1); - this.bipedHead.addChild(this.HornPieceRight2); - this.bipedHead.addChild(this.MainHelmPieceBack); - this.bipedHead.addChild(this.MainHelmPieceRight3); - this.bipedHead.addChild(this.HelmPieceFront1); - this.bipedHead.addChild(this.MainHelmPieceBottom); - this.bipedHead.addChild(this.MainHelmPieceFrontTop); - this.bipedHead.addChild(this.HornPieceLeft2); + this.bipedHead.addChild(this.MainHelmPieceLeft3); + this.bipedHead.addChild(this.MainHelmPieceRight1); + this.bipedHead.addChild(this.HornPieceRight2); + this.bipedHead.addChild(this.MainHelmPieceBack); + this.bipedHead.addChild(this.MainHelmPieceRight3); + this.bipedHead.addChild(this.HelmPieceFront1); + this.bipedHead.addChild(this.MainHelmPieceBottom); + this.bipedHead.addChild(this.MainHelmPieceFrontTop); + this.bipedHead.addChild(this.HornPieceLeft2); - if (isDraconic){ - this.bipedHead.addChild(this.HornPieceLeft4); - this.bipedHead.addChild(this.HornPieceRight4); - } - else - { - this.bipedHead.addChild(this.WyHelmPieceTop1); - this.bipedHead.addChild(this.WyHelmPieceTop2); - this.bipedHead.addChild(this.WyHelmPieceTop3); - this.bipedHead.addChild(this.WyHelmPieceTop4); - } - } + if (isDraconic) { + this.bipedHead.addChild(this.HornPieceLeft4); + this.bipedHead.addChild(this.HornPieceRight4); + } else { + this.bipedHead.addChild(this.WyHelmPieceTop1); + this.bipedHead.addChild(this.WyHelmPieceTop2); + this.bipedHead.addChild(this.WyHelmPieceTop3); + this.bipedHead.addChild(this.WyHelmPieceTop4); + } + } - this.bipedBody.cubeList.clear(); - this.bipedRightArm.cubeList.clear(); - this.bipedLeftArm.cubeList.clear(); - if (isChestPiece){ - this.bipedBody.addChild(this.MainChestPieceBottom); - this.bipedBody.addChild(this.ChestDecorationPiece2); - this.bipedBody.addChild(this.ChestDecorationPiece4); + this.bipedBody.cubeList.clear(); + this.bipedRightArm.cubeList.clear(); + this.bipedLeftArm.cubeList.clear(); + if (isChestPiece) { + this.bipedBody.addChild(this.MainChestPieceBottom); + this.bipedBody.addChild(this.ChestDecorationPiece2); + this.bipedBody.addChild(this.ChestDecorationPiece4); - if (isDraconic){ - this.bipedBody.addChild(this.DrMainChestPieceTop); - this.bipedBody.addChild(this.DrMainChestPieceMid); - this.bipedBody.addChild(this.DrChestDecorationPiece1); - this.bipedBody.addChild(this.DrChestDecorationPiece3); + if (isDraconic) { + this.bipedBody.addChild(this.DrMainChestPieceTop); + this.bipedBody.addChild(this.DrMainChestPieceMid); + this.bipedBody.addChild(this.DrChestDecorationPiece1); + this.bipedBody.addChild(this.DrChestDecorationPiece3); - this.bipedLeftArm.addChild(this.ArmGuardPieceLeft1); - this.bipedLeftArm.addChild(this.ArmGuardPieceLeft2); - this.bipedLeftArm.addChild(this.ArmGuardPieceLeft3); - this.bipedLeftArm.addChild(this.ArmGuardPieceLeft4); - this.bipedLeftArm.addChild(this.MainArmGuardLeft); - this.bipedLeftArm.addChild(this.ArmStrapLeftTop); - this.bipedLeftArm.addChild(this.ArmStrapLeftBottom); + this.bipedLeftArm.addChild(this.ArmGuardPieceLeft1); + this.bipedLeftArm.addChild(this.ArmGuardPieceLeft2); + this.bipedLeftArm.addChild(this.ArmGuardPieceLeft3); + this.bipedLeftArm.addChild(this.ArmGuardPieceLeft4); + this.bipedLeftArm.addChild(this.MainArmGuardLeft); + this.bipedLeftArm.addChild(this.ArmStrapLeftTop); + this.bipedLeftArm.addChild(this.ArmStrapLeftBottom); - this.bipedRightArm.addChild(this.ArmGuardPieceRight1); - this.bipedRightArm.addChild(this.ArmGuardPieceRight2); - this.bipedRightArm.addChild(this.ArmGuardPieceRight3); - this.bipedRightArm.addChild(this.ArmGuardPieceRight4); - this.bipedRightArm.addChild(this.MainArmGuardRight); - this.bipedRightArm.addChild(this.ArmStrapRightTop); - this.bipedRightArm.addChild(this.ArmStrapRightBottom); - } - else - { - this.bipedBody.addChild(this.WyMainChestPieceMid); - this.bipedBody.addChild(this.WyChestPieceTop2); - this.bipedBody.addChild(this.WyChestPieceTop1); - this.bipedBody.addChild(this.WyChestPieceTop3); - this.bipedBody.addChild(this.WyChestDecorationPiece3); - this.bipedBody.addChild(this.WyMainChestPieceTop); - } + this.bipedRightArm.addChild(this.ArmGuardPieceRight1); + this.bipedRightArm.addChild(this.ArmGuardPieceRight2); + this.bipedRightArm.addChild(this.ArmGuardPieceRight3); + this.bipedRightArm.addChild(this.ArmGuardPieceRight4); + this.bipedRightArm.addChild(this.MainArmGuardRight); + this.bipedRightArm.addChild(this.ArmStrapRightTop); + this.bipedRightArm.addChild(this.ArmStrapRightBottom); + } else { + this.bipedBody.addChild(this.WyMainChestPieceMid); + this.bipedBody.addChild(this.WyChestPieceTop2); + this.bipedBody.addChild(this.WyChestPieceTop1); + this.bipedBody.addChild(this.WyChestPieceTop3); + this.bipedBody.addChild(this.WyChestDecorationPiece3); + this.bipedBody.addChild(this.WyMainChestPieceTop); + } - this.bipedLeftArm.addChild(this.ShoulderPadLeft1); - this.bipedLeftArm.addChild(this.ShoulderPadLeft2); - this.bipedLeftArm.addChild(this.ShoulderPadLeft3); - this.bipedLeftArm.addChild(this.ShoulderPadLeft4); + this.bipedLeftArm.addChild(this.ShoulderPadLeft1); + this.bipedLeftArm.addChild(this.ShoulderPadLeft2); + this.bipedLeftArm.addChild(this.ShoulderPadLeft3); + this.bipedLeftArm.addChild(this.ShoulderPadLeft4); - this.bipedRightArm.addChild(this.ShoulderPadRight1); - this.bipedRightArm.addChild(this.ShoulderPadRight2); - this.bipedRightArm.addChild(this.ShoulderPadRight3); - this.bipedRightArm.addChild(this.ShoulderPadRight4); - } + this.bipedRightArm.addChild(this.ShoulderPadRight1); + this.bipedRightArm.addChild(this.ShoulderPadRight2); + this.bipedRightArm.addChild(this.ShoulderPadRight3); + this.bipedRightArm.addChild(this.ShoulderPadRight4); + } - this.bipedLeftLeg.cubeList.clear(); - this.bipedRightLeg.cubeList.clear(); - if (isLeggings){ - this.bipedBody.addChild(this.LeggsTop); + this.bipedLeftLeg.cubeList.clear(); + this.bipedRightLeg.cubeList.clear(); + if (isLeggings) { + this.bipedBody.addChild(this.LeggsTop); - this.bipedLeftLeg.addChild(this.LegPieceLeft1); - this.bipedLeftLeg.addChild(this.MainKneePadLeft); - this.bipedLeftLeg.addChild(this.MainLegPieceLeft); - this.bipedLeftLeg.addChild(this.KneePieceLeft1); - this.bipedLeftLeg.addChild(this.LegPieceLeft2); + this.bipedLeftLeg.addChild(this.LegPieceLeft1); + this.bipedLeftLeg.addChild(this.MainKneePadLeft); + this.bipedLeftLeg.addChild(this.MainLegPieceLeft); + this.bipedLeftLeg.addChild(this.KneePieceLeft1); + this.bipedLeftLeg.addChild(this.LegPieceLeft2); - this.bipedRightLeg.addChild(this.LegPieceRight2); - this.bipedRightLeg.addChild(this.LegPieceRight1); - this.bipedRightLeg.addChild(this.MainKneePadRight); - this.bipedRightLeg.addChild(this.KneePieceRight1); - this.bipedRightLeg.addChild(this.MainLegPieceRight); + this.bipedRightLeg.addChild(this.LegPieceRight2); + this.bipedRightLeg.addChild(this.LegPieceRight1); + this.bipedRightLeg.addChild(this.MainKneePadRight); + this.bipedRightLeg.addChild(this.KneePieceRight1); + this.bipedRightLeg.addChild(this.MainLegPieceRight); - if (isDraconic){ - this.bipedBody.addChild(this.BeltFront); - this.bipedBody.addChild(this.BeltBack); - this.bipedBody.addChild(this.BeltLeft); - this.bipedBody.addChild(this.BeltRight); - this.bipedBody.addChild(this.BeltBuckle); - } - } + if (isDraconic) { + this.bipedBody.addChild(this.BeltFront); + this.bipedBody.addChild(this.BeltBack); + this.bipedBody.addChild(this.BeltLeft); + this.bipedBody.addChild(this.BeltRight); + this.bipedBody.addChild(this.BeltBuckle); + } + } - if (isdBoots){ - this.bipedLeftLeg.addChild(this.MainBootPieceLeft); - this.bipedLeftLeg.addChild(this.BootPieceLeft2); - this.bipedLeftLeg.addChild(this.BootPieceLeft1); - this.bipedLeftLeg.addChild(this.BootPieceLeft3); - this.bipedLeftLeg.addChild(this.BootPieceLeft4); + if (isdBoots) { + this.bipedLeftLeg.addChild(this.MainBootPieceLeft); + this.bipedLeftLeg.addChild(this.BootPieceLeft2); + this.bipedLeftLeg.addChild(this.BootPieceLeft1); + this.bipedLeftLeg.addChild(this.BootPieceLeft3); + this.bipedLeftLeg.addChild(this.BootPieceLeft4); - this.bipedRightLeg.addChild(this.MainBootPieceRight); - this.bipedRightLeg.addChild(this.BootPieceRight1); - this.bipedRightLeg.addChild(this.BootPieceRight2); - this.bipedRightLeg.addChild(this.BootPieceRight3); - this.bipedRightLeg.addChild(this.BootPieceRight4); - } + this.bipedRightLeg.addChild(this.MainBootPieceRight); + this.bipedRightLeg.addChild(this.BootPieceRight1); + this.bipedRightLeg.addChild(this.BootPieceRight2); + this.bipedRightLeg.addChild(this.BootPieceRight3); + this.bipedRightLeg.addChild(this.BootPieceRight4); + } } @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - setRotationAngles(f, f1, f2, f3, f4, f5, entity); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.bipedRightLeg.render(f5); - this.bipedBody.render(f5*1.05F);// * 1.1F); + this.bipedBody.render(f5 * 1.05F);// * 1.1F); this.bipedLeftArm.render(f5); - this.bipedRightArm.render(f5); + this.bipedRightArm.render(f5); this.bipedLeftLeg.render(f5); - this.bipedHead.render(f5*1.05F); + this.bipedHead.render(f5 * 1.05F); } /** diff --git a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelReactorEnergyInjector.java b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelReactorEnergyInjector.java index 799e1ae7..eadfb416 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelReactorEnergyInjector.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelReactorEnergyInjector.java @@ -156,23 +156,23 @@ public class ModelReactorEnergyInjector extends ModelBase { @Override public void render(Entity entity, float brightness, float f1, float f2, float f3, float f4, float f5) { - this.support1.render(f5); - this.BasePlate.render(f5); - //this.coreSupports.render(f5); + this.support1.render(f5); + this.BasePlate.render(f5); + //this.coreSupports.render(f5); - float lastBrightnessX = OpenGlHelper.lastBrightnessX; - float lastBrightnessY = OpenGlHelper.lastBrightnessY; + float lastBrightnessX = OpenGlHelper.lastBrightnessX; + float lastBrightnessY = OpenGlHelper.lastBrightnessY; - float b = brightness * 200F; - float colour = Math.min(2F, (brightness*2F) + 0.5F); - if (brightness > 0F) GL11.glDisable(GL11.GL_LIGHTING); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, Math.min(200F, lastBrightnessX + b), Math.min(200F, lastBrightnessY + b)); - GL11.glColor4f(colour, colour, colour, 1F); - this.element1.render(f5); - GL11.glColor4f(1F, 1F, 1F, 1F); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastBrightnessX, lastBrightnessY); - if (brightness > 0F) GL11.glEnable(GL11.GL_LIGHTING); - } + float b = brightness * 200F; + float colour = Math.min(2F, (brightness * 2F) + 0.5F); + if (brightness > 0F) GL11.glDisable(GL11.GL_LIGHTING); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, Math.min(200F, lastBrightnessX + b), Math.min(200F, lastBrightnessY + b)); + GL11.glColor4f(colour, colour, colour, 1F); + this.element1.render(f5); + GL11.glColor4f(1F, 1F, 1F, 1F); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastBrightnessX, lastBrightnessY); + if (brightness > 0F) GL11.glEnable(GL11.GL_LIGHTING); + } /** * This is a helper function from Tabula to set the rotation of model parts diff --git a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelReactorStabilizerCore.java b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelReactorStabilizerCore.java index 3f45fe1f..004b7326 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelReactorStabilizerCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelReactorStabilizerCore.java @@ -253,34 +253,34 @@ public class ModelReactorStabilizerCore extends ModelBase { @Override public void render(Entity entity, float rotation, float brightness, float f2, float f3, float f4, float f5) { - GL11.glPushMatrix(); + GL11.glPushMatrix(); - this.basePlate.render(f5); + this.basePlate.render(f5); - GL11.glRotatef(rotation, 0F, 0F, 1F); - this.hub1.render(f5); - GL11.glRotatef(rotation * 2F, 0F, 0F, -1F); - this.hub2.render(f5); + GL11.glRotatef(rotation, 0F, 0F, 1F); + this.hub1.render(f5); + GL11.glRotatef(rotation * 2F, 0F, 0F, -1F); + this.hub2.render(f5); - float lastBrightnessX = OpenGlHelper.lastBrightnessX; - float lastBrightnessY = OpenGlHelper.lastBrightnessY; + float lastBrightnessX = OpenGlHelper.lastBrightnessX; + float lastBrightnessY = OpenGlHelper.lastBrightnessY; - float b = brightness * 200F; - float colour = Math.min(2F, (brightness*2F) + 0.1F); - if (brightness > 0F) GL11.glDisable(GL11.GL_LIGHTING); + float b = brightness * 200F; + float colour = Math.min(2F, (brightness * 2F) + 0.1F); + if (brightness > 0F) GL11.glDisable(GL11.GL_LIGHTING); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, Math.min(200F, lastBrightnessX + b), Math.min(200F, lastBrightnessY + b)); - GL11.glColor4f(colour, colour, colour, 1F); - this.rotor2R.render(f5); - GL11.glRotatef(rotation * 2F, 0F, 0F, 1F); - this.rotor1R.render(f5); - GL11.glColor4f(1F, 1F, 1F, 1F); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastBrightnessX, lastBrightnessY); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, Math.min(200F, lastBrightnessX + b), Math.min(200F, lastBrightnessY + b)); + GL11.glColor4f(colour, colour, colour, 1F); + this.rotor2R.render(f5); + GL11.glRotatef(rotation * 2F, 0F, 0F, 1F); + this.rotor1R.render(f5); + GL11.glColor4f(1F, 1F, 1F, 1F); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastBrightnessX, lastBrightnessY); - if (brightness > 0F) GL11.glEnable(GL11.GL_LIGHTING); + if (brightness > 0F) GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } /** * This is a helper function from Tabula to set the rotation of model parts diff --git a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelReactorStabilizerRing.java b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelReactorStabilizerRing.java index 5d606bbb..064e979e 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelReactorStabilizerRing.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelReactorStabilizerRing.java @@ -33,190 +33,190 @@ public class ModelReactorStabilizerRing extends ModelBase { public ModelRenderer emitter4; public ModelReactorStabilizerRing() { - this.textureWidth = 32; - this.textureHeight = 16; - this.ringElement9 = new ModelRenderer(this, 0, 0); - this.ringElement9.setRotationPoint(6.7F, 0.01F, -1.55F); - this.ringElement9.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); - this.setRotateAngle(ringElement9, 0.0F, 2.0943951023931953F, 0.0F); - this.ringElement10 = new ModelRenderer(this, 0, 0); - this.ringElement10.setRotationPoint(1.55F, 0.02F, -6.7F); - this.ringElement10.addBox(-4.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); - this.setRotateAngle(ringElement10, 0.0F, 2.6179938779914944F, 0.0F); - this.ringElement1 = new ModelRenderer(this, 0, 0); - this.ringElement1.setRotationPoint(-2.0F, 0.01F, 6.6F); - this.ringElement1.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); - this.ringElement7 = new ModelRenderer(this, 0, 0); - this.ringElement7.setRotationPoint(-1.55F, 0.02F, -6.7F); - this.ringElement7.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); - this.setRotateAngle(ringElement7, 0.0F, -2.6179938779914944F, 0.0F); - this.hing4 = new ModelRenderer(this, 15, 0); - this.hing4.setRotationPoint(1.75F, -0.5F, 6.95F); - this.hing4.addBox(0.0F, 0.0F, 0.0F, 1, 1, 7, 0.0F); - this.setRotateAngle(hing4, 0.0F, -1.5716689914208934F, 0.0F); - this.ringElement8 = new ModelRenderer(this, 0, 0); - this.ringElement8.setRotationPoint(-6.7F, 0.01F, -1.55F); - this.ringElement8.addBox(-4.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); - this.setRotateAngle(ringElement8, 0.0F, -2.0943951023931953F, 0.0F); - this.emitter4 = new ModelRenderer(this, 0, 2); - this.emitter4.setRotationPoint(2.25F, -0.3F, 7.1F); - this.emitter4.addBox(-0.5F, -0.8F, 0.0F, 3, 1, 9, 0.0F); - this.setRotateAngle(emitter4, 0.0F, -1.5707963267948966F, 0.0F); - this.emitter2 = new ModelRenderer(this, 0, 2); - this.emitter2.setRotationPoint(-7.1F, -0.3F, 2.25F); - this.emitter2.addBox(-0.5F, -0.8F, 0.0F, 3, 1, 9, 0.0F); - this.setRotateAngle(emitter2, 0.0F, 3.141592653589793F, 0.0F); - this.emitter1 = new ModelRenderer(this, 0, 2); - this.emitter1.setRotationPoint(7.1F, -0.3F, -2.25F); - this.emitter1.addBox(-0.5F, -0.8F, 0.0F, 3, 1, 9, 0.0F); - this.hing2 = new ModelRenderer(this, 15, 0); - this.hing2.setRotationPoint(6.95F, -0.5F, -1.75F); - this.hing2.addBox(0.0F, 0.0F, 0.0F, 1, 1, 7, 0.0F); - this.ringElement2 = new ModelRenderer(this, 0, 0); - this.ringElement2.setRotationPoint(2.0F, 0.01F, -6.6F); - this.ringElement2.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); - this.setRotateAngle(ringElement2, 0.0F, 3.141592653589793F, 0.0F); - this.ringElement5 = new ModelRenderer(this, 0, 0); - this.ringElement5.setRotationPoint(-6.7F, 0.01F, 1.55F); - this.ringElement5.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); - this.setRotateAngle(ringElement5, 0.0F, -1.0471975511965976F, 0.0F); - this.ringElement12 = new ModelRenderer(this, 0, 0); - this.ringElement12.setRotationPoint(1.55F, 0.02F, 6.7F); - this.ringElement12.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); - this.setRotateAngle(ringElement12, 0.0F, 0.5235987755982988F, 0.0F); - this.hing1 = new ModelRenderer(this, 15, 0); - this.hing1.setRotationPoint(-7.45F, -0.5F, -1.75F); - this.hing1.addBox(0.0F, 0.0F, 0.0F, 1, 1, 7, 0.0F); - this.ringElement6 = new ModelRenderer(this, 0, 0); - this.ringElement6.setRotationPoint(-1.55F, 0.02F, 6.7F); - this.ringElement6.addBox(-4.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); - this.setRotateAngle(ringElement6, 0.0F, -0.5235987755982988F, 0.0F); - this.ringElement11 = new ModelRenderer(this, 0, 0); - this.ringElement11.setRotationPoint(6.7F, 0.01F, 1.55F); - this.ringElement11.addBox(-4.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); - this.setRotateAngle(ringElement11, 0.0F, 1.0471975511965976F, 0.0F); - this.emitter3 = new ModelRenderer(this, 0, 2); - this.emitter3.setRotationPoint(-2.25F, -0.3F, -7.1F); - this.emitter3.addBox(-0.5F, -0.8F, 0.0F, 3, 1, 9, 0.0F); - this.setRotateAngle(emitter3, 0.0F, 1.5707963267948966F, 0.0F); - this.ringElement4 = new ModelRenderer(this, 0, 0); - this.ringElement4.setRotationPoint(-6.6F, 0.0F, -2.0F); - this.ringElement4.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); - this.setRotateAngle(ringElement4, 0.0F, -1.5707963267948966F, 0.0F); - this.hing3 = new ModelRenderer(this, 15, 0); - this.hing3.setRotationPoint(1.75F, -0.5F, -7.45F); - this.hing3.addBox(0.0F, 0.0F, 0.0F, 1, 1, 7, 0.0F); - this.setRotateAngle(hing3, 0.0F, -1.5716689914208934F, 0.0F); - this.ringElement3 = new ModelRenderer(this, 0, 0); - this.ringElement3.setRotationPoint(6.6F, 0.0F, 2.0F); - this.ringElement3.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); - this.setRotateAngle(ringElement3, 0.0F, 1.5707963267948966F, 0.0F); + this.textureWidth = 32; + this.textureHeight = 16; + this.ringElement9 = new ModelRenderer(this, 0, 0); + this.ringElement9.setRotationPoint(6.7F, 0.01F, -1.55F); + this.ringElement9.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); + this.setRotateAngle(ringElement9, 0.0F, 2.0943951023931953F, 0.0F); + this.ringElement10 = new ModelRenderer(this, 0, 0); + this.ringElement10.setRotationPoint(1.55F, 0.02F, -6.7F); + this.ringElement10.addBox(-4.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); + this.setRotateAngle(ringElement10, 0.0F, 2.6179938779914944F, 0.0F); + this.ringElement1 = new ModelRenderer(this, 0, 0); + this.ringElement1.setRotationPoint(-2.0F, 0.01F, 6.6F); + this.ringElement1.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); + this.ringElement7 = new ModelRenderer(this, 0, 0); + this.ringElement7.setRotationPoint(-1.55F, 0.02F, -6.7F); + this.ringElement7.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); + this.setRotateAngle(ringElement7, 0.0F, -2.6179938779914944F, 0.0F); + this.hing4 = new ModelRenderer(this, 15, 0); + this.hing4.setRotationPoint(1.75F, -0.5F, 6.95F); + this.hing4.addBox(0.0F, 0.0F, 0.0F, 1, 1, 7, 0.0F); + this.setRotateAngle(hing4, 0.0F, -1.5716689914208934F, 0.0F); + this.ringElement8 = new ModelRenderer(this, 0, 0); + this.ringElement8.setRotationPoint(-6.7F, 0.01F, -1.55F); + this.ringElement8.addBox(-4.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); + this.setRotateAngle(ringElement8, 0.0F, -2.0943951023931953F, 0.0F); + this.emitter4 = new ModelRenderer(this, 0, 2); + this.emitter4.setRotationPoint(2.25F, -0.3F, 7.1F); + this.emitter4.addBox(-0.5F, -0.8F, 0.0F, 3, 1, 9, 0.0F); + this.setRotateAngle(emitter4, 0.0F, -1.5707963267948966F, 0.0F); + this.emitter2 = new ModelRenderer(this, 0, 2); + this.emitter2.setRotationPoint(-7.1F, -0.3F, 2.25F); + this.emitter2.addBox(-0.5F, -0.8F, 0.0F, 3, 1, 9, 0.0F); + this.setRotateAngle(emitter2, 0.0F, 3.141592653589793F, 0.0F); + this.emitter1 = new ModelRenderer(this, 0, 2); + this.emitter1.setRotationPoint(7.1F, -0.3F, -2.25F); + this.emitter1.addBox(-0.5F, -0.8F, 0.0F, 3, 1, 9, 0.0F); + this.hing2 = new ModelRenderer(this, 15, 0); + this.hing2.setRotationPoint(6.95F, -0.5F, -1.75F); + this.hing2.addBox(0.0F, 0.0F, 0.0F, 1, 1, 7, 0.0F); + this.ringElement2 = new ModelRenderer(this, 0, 0); + this.ringElement2.setRotationPoint(2.0F, 0.01F, -6.6F); + this.ringElement2.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); + this.setRotateAngle(ringElement2, 0.0F, 3.141592653589793F, 0.0F); + this.ringElement5 = new ModelRenderer(this, 0, 0); + this.ringElement5.setRotationPoint(-6.7F, 0.01F, 1.55F); + this.ringElement5.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); + this.setRotateAngle(ringElement5, 0.0F, -1.0471975511965976F, 0.0F); + this.ringElement12 = new ModelRenderer(this, 0, 0); + this.ringElement12.setRotationPoint(1.55F, 0.02F, 6.7F); + this.ringElement12.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); + this.setRotateAngle(ringElement12, 0.0F, 0.5235987755982988F, 0.0F); + this.hing1 = new ModelRenderer(this, 15, 0); + this.hing1.setRotationPoint(-7.45F, -0.5F, -1.75F); + this.hing1.addBox(0.0F, 0.0F, 0.0F, 1, 1, 7, 0.0F); + this.ringElement6 = new ModelRenderer(this, 0, 0); + this.ringElement6.setRotationPoint(-1.55F, 0.02F, 6.7F); + this.ringElement6.addBox(-4.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); + this.setRotateAngle(ringElement6, 0.0F, -0.5235987755982988F, 0.0F); + this.ringElement11 = new ModelRenderer(this, 0, 0); + this.ringElement11.setRotationPoint(6.7F, 0.01F, 1.55F); + this.ringElement11.addBox(-4.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); + this.setRotateAngle(ringElement11, 0.0F, 1.0471975511965976F, 0.0F); + this.emitter3 = new ModelRenderer(this, 0, 2); + this.emitter3.setRotationPoint(-2.25F, -0.3F, -7.1F); + this.emitter3.addBox(-0.5F, -0.8F, 0.0F, 3, 1, 9, 0.0F); + this.setRotateAngle(emitter3, 0.0F, 1.5707963267948966F, 0.0F); + this.ringElement4 = new ModelRenderer(this, 0, 0); + this.ringElement4.setRotationPoint(-6.6F, 0.0F, -2.0F); + this.ringElement4.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); + this.setRotateAngle(ringElement4, 0.0F, -1.5707963267948966F, 0.0F); + this.hing3 = new ModelRenderer(this, 15, 0); + this.hing3.setRotationPoint(1.75F, -0.5F, -7.45F); + this.hing3.addBox(0.0F, 0.0F, 0.0F, 1, 1, 7, 0.0F); + this.setRotateAngle(hing3, 0.0F, -1.5716689914208934F, 0.0F); + this.ringElement3 = new ModelRenderer(this, 0, 0); + this.ringElement3.setRotationPoint(6.6F, 0.0F, 2.0F); + this.ringElement3.addBox(0.0F, 0.0F, 0.0F, 4, 1, 1, 0.0F); + this.setRotateAngle(ringElement3, 0.0F, 1.5707963267948966F, 0.0F); } @Override public void render(Entity entity, float embitterRotation, float brightness, float f2, float f3, float f4, float scale) { - this.ringElement1.render(scale); - this.ringElement2.render(scale); - this.ringElement3.render(scale); - this.ringElement4.render(scale); - this.ringElement5.render(scale); - this.ringElement6.render(scale); - this.ringElement7.render(scale); - this.ringElement8.render(scale); - this.ringElement9.render(scale); - this.ringElement10.render(scale); - this.ringElement11.render(scale); - this.ringElement12.render(scale); + this.ringElement1.render(scale); + this.ringElement2.render(scale); + this.ringElement3.render(scale); + this.ringElement4.render(scale); + this.ringElement5.render(scale); + this.ringElement6.render(scale); + this.ringElement7.render(scale); + this.ringElement8.render(scale); + this.ringElement9.render(scale); + this.ringElement10.render(scale); + this.ringElement11.render(scale); + this.ringElement12.render(scale); - GL11.glPushMatrix(); - GL11.glTranslated(this.hing1.offsetX, this.hing1.offsetY, this.hing1.offsetZ); - GL11.glTranslated(this.hing1.rotationPointX * scale, this.hing1.rotationPointY * scale, this.hing1.rotationPointZ * scale); - GL11.glScaled(0.5D, 0.5D, 0.5D); - GL11.glTranslated(-this.hing1.offsetX, -this.hing1.offsetY, -this.hing1.offsetZ); - GL11.glTranslated(-this.hing1.rotationPointX * scale, -this.hing1.rotationPointY * scale, -this.hing1.rotationPointZ * scale); - this.hing1.render(scale); - GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glTranslated(this.hing2.offsetX, this.hing2.offsetY, this.hing2.offsetZ); - GL11.glTranslated(this.hing2.rotationPointX * scale, this.hing2.rotationPointY * scale, this.hing2.rotationPointZ * scale); - GL11.glScaled(0.5D, 0.5D, 0.5D); - GL11.glTranslated(-this.hing2.offsetX, -this.hing2.offsetY, -this.hing2.offsetZ); - GL11.glTranslated(-this.hing2.rotationPointX * scale, -this.hing2.rotationPointY * scale, -this.hing2.rotationPointZ * scale); - this.hing2.render(scale); - GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glTranslated(this.hing3.offsetX, this.hing3.offsetY, this.hing3.offsetZ); - GL11.glTranslated(this.hing3.rotationPointX * scale, this.hing3.rotationPointY * scale, this.hing3.rotationPointZ * scale); - GL11.glScaled(0.5D, 0.5D, 0.5D); - GL11.glTranslated(-this.hing3.offsetX, -this.hing3.offsetY, -this.hing3.offsetZ); - GL11.glTranslated(-this.hing3.rotationPointX * scale, -this.hing3.rotationPointY * scale, -this.hing3.rotationPointZ * scale); - this.hing3.render(scale); - GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glTranslated(this.hing4.offsetX, this.hing4.offsetY, this.hing4.offsetZ); - GL11.glTranslated(this.hing4.rotationPointX * scale, this.hing4.rotationPointY * scale, this.hing4.rotationPointZ * scale); - GL11.glScaled(0.5D, 0.5D, 0.5D); - GL11.glTranslated(-this.hing4.offsetX, -this.hing4.offsetY, -this.hing4.offsetZ); - GL11.glTranslated(-this.hing4.rotationPointX * scale, -this.hing4.rotationPointY * scale, -this.hing4.rotationPointZ * scale); - this.hing4.render(scale); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslated(this.hing1.offsetX, this.hing1.offsetY, this.hing1.offsetZ); + GL11.glTranslated(this.hing1.rotationPointX * scale, this.hing1.rotationPointY * scale, this.hing1.rotationPointZ * scale); + GL11.glScaled(0.5D, 0.5D, 0.5D); + GL11.glTranslated(-this.hing1.offsetX, -this.hing1.offsetY, -this.hing1.offsetZ); + GL11.glTranslated(-this.hing1.rotationPointX * scale, -this.hing1.rotationPointY * scale, -this.hing1.rotationPointZ * scale); + this.hing1.render(scale); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslated(this.hing2.offsetX, this.hing2.offsetY, this.hing2.offsetZ); + GL11.glTranslated(this.hing2.rotationPointX * scale, this.hing2.rotationPointY * scale, this.hing2.rotationPointZ * scale); + GL11.glScaled(0.5D, 0.5D, 0.5D); + GL11.glTranslated(-this.hing2.offsetX, -this.hing2.offsetY, -this.hing2.offsetZ); + GL11.glTranslated(-this.hing2.rotationPointX * scale, -this.hing2.rotationPointY * scale, -this.hing2.rotationPointZ * scale); + this.hing2.render(scale); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslated(this.hing3.offsetX, this.hing3.offsetY, this.hing3.offsetZ); + GL11.glTranslated(this.hing3.rotationPointX * scale, this.hing3.rotationPointY * scale, this.hing3.rotationPointZ * scale); + GL11.glScaled(0.5D, 0.5D, 0.5D); + GL11.glTranslated(-this.hing3.offsetX, -this.hing3.offsetY, -this.hing3.offsetZ); + GL11.glTranslated(-this.hing3.rotationPointX * scale, -this.hing3.rotationPointY * scale, -this.hing3.rotationPointZ * scale); + this.hing3.render(scale); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslated(this.hing4.offsetX, this.hing4.offsetY, this.hing4.offsetZ); + GL11.glTranslated(this.hing4.rotationPointX * scale, this.hing4.rotationPointY * scale, this.hing4.rotationPointZ * scale); + GL11.glScaled(0.5D, 0.5D, 0.5D); + GL11.glTranslated(-this.hing4.offsetX, -this.hing4.offsetY, -this.hing4.offsetZ); + GL11.glTranslated(-this.hing4.rotationPointX * scale, -this.hing4.rotationPointY * scale, -this.hing4.rotationPointZ * scale); + this.hing4.render(scale); + GL11.glPopMatrix(); // float lastBrightnessX = OpenGlHelper.lastBrightnessX; // float lastBrightnessY = OpenGlHelper.lastBrightnessY; // OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); - float lastBrightnessX = OpenGlHelper.lastBrightnessX; - float lastBrightnessY = OpenGlHelper.lastBrightnessY; + float lastBrightnessX = OpenGlHelper.lastBrightnessX; + float lastBrightnessY = OpenGlHelper.lastBrightnessY; - float b = brightness * 200F; - float colour = Math.min(2F, (brightness*2F) + 0.1F); + float b = brightness * 200F; + float colour = Math.min(2F, (brightness * 2F) + 0.1F); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, Math.min(200F, lastBrightnessX + b), Math.min(200F, lastBrightnessY + b)); - GL11.glColor4f(colour, colour, colour, 1F); - if (brightness > 0F) GL11.glDisable(GL11.GL_LIGHTING); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, Math.min(200F, lastBrightnessX + b), Math.min(200F, lastBrightnessY + b)); + GL11.glColor4f(colour, colour, colour, 1F); + if (brightness > 0F) GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPushMatrix(); - GL11.glTranslated(this.emitter1.offsetX, this.emitter1.offsetY, this.emitter1.offsetZ); - GL11.glTranslated(this.emitter1.rotationPointX * scale, this.emitter1.rotationPointY * scale, this.emitter1.rotationPointZ * scale); - GL11.glRotatef(embitterRotation, 0, 0, 1); - GL11.glScaled(0.5D, 0.5D, 0.5D); - GL11.glTranslated(-this.emitter1.offsetX, -this.emitter1.offsetY, -this.emitter1.offsetZ); - GL11.glTranslated(-this.emitter1.rotationPointX * scale, -this.emitter1.rotationPointY * scale, -this.emitter1.rotationPointZ * scale); - this.emitter1.render(scale); - GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glTranslated(this.emitter2.offsetX, this.emitter2.offsetY, this.emitter2.offsetZ); - GL11.glTranslated(this.emitter2.rotationPointX * scale, this.emitter2.rotationPointY * scale, this.emitter2.rotationPointZ * scale); - GL11.glRotatef(embitterRotation, 0, 0, -1); - GL11.glScaled(0.5D, 0.5D, 0.5D); - GL11.glTranslated(-this.emitter2.offsetX, -this.emitter2.offsetY, -this.emitter2.offsetZ); - GL11.glTranslated(-this.emitter2.rotationPointX * scale, -this.emitter2.rotationPointY * scale, -this.emitter2.rotationPointZ * scale); - this.emitter2.render(scale); - GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glTranslated(this.emitter3.offsetX, this.emitter3.offsetY, this.emitter3.offsetZ); - GL11.glTranslated(this.emitter3.rotationPointX * scale, this.emitter3.rotationPointY * scale, this.emitter3.rotationPointZ * scale); - GL11.glRotatef(embitterRotation, 1, 0, 0); - GL11.glScaled(0.5D, 0.5D, 0.5D); - GL11.glTranslated(-this.emitter3.offsetX, -this.emitter3.offsetY, -this.emitter3.offsetZ); - GL11.glTranslated(-this.emitter3.rotationPointX * scale, -this.emitter3.rotationPointY * scale, -this.emitter3.rotationPointZ * scale); - this.emitter3.render(scale); - GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glTranslated(this.emitter4.offsetX, this.emitter4.offsetY, this.emitter4.offsetZ); - GL11.glTranslated(this.emitter4.rotationPointX * scale, this.emitter4.rotationPointY * scale, this.emitter4.rotationPointZ * scale); - GL11.glRotatef(embitterRotation, -1, 0, 0); - GL11.glScaled(0.5D, 0.5D, 0.5D); - GL11.glTranslated(-this.emitter4.offsetX, -this.emitter4.offsetY, -this.emitter4.offsetZ); - GL11.glTranslated(-this.emitter4.rotationPointX * scale, -this.emitter4.rotationPointY * scale, -this.emitter4.rotationPointZ * scale); - this.emitter4.render(scale); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslated(this.emitter1.offsetX, this.emitter1.offsetY, this.emitter1.offsetZ); + GL11.glTranslated(this.emitter1.rotationPointX * scale, this.emitter1.rotationPointY * scale, this.emitter1.rotationPointZ * scale); + GL11.glRotatef(embitterRotation, 0, 0, 1); + GL11.glScaled(0.5D, 0.5D, 0.5D); + GL11.glTranslated(-this.emitter1.offsetX, -this.emitter1.offsetY, -this.emitter1.offsetZ); + GL11.glTranslated(-this.emitter1.rotationPointX * scale, -this.emitter1.rotationPointY * scale, -this.emitter1.rotationPointZ * scale); + this.emitter1.render(scale); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslated(this.emitter2.offsetX, this.emitter2.offsetY, this.emitter2.offsetZ); + GL11.glTranslated(this.emitter2.rotationPointX * scale, this.emitter2.rotationPointY * scale, this.emitter2.rotationPointZ * scale); + GL11.glRotatef(embitterRotation, 0, 0, -1); + GL11.glScaled(0.5D, 0.5D, 0.5D); + GL11.glTranslated(-this.emitter2.offsetX, -this.emitter2.offsetY, -this.emitter2.offsetZ); + GL11.glTranslated(-this.emitter2.rotationPointX * scale, -this.emitter2.rotationPointY * scale, -this.emitter2.rotationPointZ * scale); + this.emitter2.render(scale); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslated(this.emitter3.offsetX, this.emitter3.offsetY, this.emitter3.offsetZ); + GL11.glTranslated(this.emitter3.rotationPointX * scale, this.emitter3.rotationPointY * scale, this.emitter3.rotationPointZ * scale); + GL11.glRotatef(embitterRotation, 1, 0, 0); + GL11.glScaled(0.5D, 0.5D, 0.5D); + GL11.glTranslated(-this.emitter3.offsetX, -this.emitter3.offsetY, -this.emitter3.offsetZ); + GL11.glTranslated(-this.emitter3.rotationPointX * scale, -this.emitter3.rotationPointY * scale, -this.emitter3.rotationPointZ * scale); + this.emitter3.render(scale); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslated(this.emitter4.offsetX, this.emitter4.offsetY, this.emitter4.offsetZ); + GL11.glTranslated(this.emitter4.rotationPointX * scale, this.emitter4.rotationPointY * scale, this.emitter4.rotationPointZ * scale); + GL11.glRotatef(embitterRotation, -1, 0, 0); + GL11.glScaled(0.5D, 0.5D, 0.5D); + GL11.glTranslated(-this.emitter4.offsetX, -this.emitter4.offsetY, -this.emitter4.offsetZ); + GL11.glTranslated(-this.emitter4.rotationPointX * scale, -this.emitter4.rotationPointY * scale, -this.emitter4.rotationPointZ * scale); + this.emitter4.render(scale); + GL11.glPopMatrix(); - if (brightness > 0F) GL11.glEnable(GL11.GL_LIGHTING); - GL11.glColor4f(1F, 1F, 1F, 1F); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastBrightnessX, lastBrightnessY); - GL11.glEnable(GL11.GL_LIGHTING); - } + if (brightness > 0F) GL11.glEnable(GL11.GL_LIGHTING); + GL11.glColor4f(1F, 1F, 1F, 1F); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastBrightnessX, lastBrightnessY); + GL11.glEnable(GL11.GL_LIGHTING); + } /** * This is a helper function from Tabula to set the rotation of model parts diff --git a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelRenderOBJ.java b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelRenderOBJ.java index 091112e0..c0989149 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelRenderOBJ.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelRenderOBJ.java @@ -13,131 +13,130 @@ import org.lwjgl.opengl.GL11; * Created by brandon3055 on 16/9/2015. */ public class ModelRenderOBJ extends ModelRenderer { - private IModelCustom model; - private ResourceLocation texture; - private int displayList; - private boolean compiled = false; - public float scale = 0; + private IModelCustom model; + private ResourceLocation texture; + private int displayList; + private boolean compiled = false; + public float scale = 0; - public ModelRenderOBJ(ModelBase baseModel, ResourceLocation customModel, ResourceLocation texture) { - super(baseModel); - this.model = AdvancedModelLoader.loadModel(customModel); - this.texture = texture; - } + public ModelRenderOBJ(ModelBase baseModel, ResourceLocation customModel, ResourceLocation texture) { + super(baseModel); + this.model = AdvancedModelLoader.loadModel(customModel); + this.texture = texture; + } - @Override - public void render(float scale) { - if(!this.isHidden && this.showModel) { - if(!this.compiled) { - this.compileDisplayList(scale); - } + @Override + public void render(float scale) { + if (!this.isHidden && this.showModel) { + if (!this.compiled) { + this.compileDisplayList(scale); + } - GL11.glTranslatef(this.offsetX, this.offsetY, this.offsetZ); + GL11.glTranslatef(this.offsetX, this.offsetY, this.offsetZ); - if(this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) { - if(this.rotationPointX == 0.0F && this.rotationPointY == 0.0F && this.rotationPointZ == 0.0F) { - GL11.glCallList(this.displayList); - } else { - GL11.glTranslatef(this.rotationPointX * scale, this.rotationPointY * scale, this.rotationPointZ * scale); - GL11.glCallList(this.displayList); - GL11.glTranslatef(-this.rotationPointX * scale, -this.rotationPointY * scale, -this.rotationPointZ * scale); - } - } else { - GL11.glPushMatrix(); - GL11.glTranslatef(this.rotationPointX * scale, this.rotationPointY * scale, this.rotationPointZ * scale); - if(this.rotateAngleZ != 0.0F) { - GL11.glRotatef(this.rotateAngleZ * 57.295776F, 0.0F, 0.0F, 1.0F); - } + if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) { + if (this.rotationPointX == 0.0F && this.rotationPointY == 0.0F && this.rotationPointZ == 0.0F) { + GL11.glCallList(this.displayList); + } else { + GL11.glTranslatef(this.rotationPointX * scale, this.rotationPointY * scale, this.rotationPointZ * scale); + GL11.glCallList(this.displayList); + GL11.glTranslatef(-this.rotationPointX * scale, -this.rotationPointY * scale, -this.rotationPointZ * scale); + } + } else { + GL11.glPushMatrix(); + GL11.glTranslatef(this.rotationPointX * scale, this.rotationPointY * scale, this.rotationPointZ * scale); + if (this.rotateAngleZ != 0.0F) { + GL11.glRotatef(this.rotateAngleZ * 57.295776F, 0.0F, 0.0F, 1.0F); + } - if(this.rotateAngleY != 0.0F) { - GL11.glRotatef(this.rotateAngleY * 57.295776F, 0.0F, 1.0F, 0.0F); - } + if (this.rotateAngleY != 0.0F) { + GL11.glRotatef(this.rotateAngleY * 57.295776F, 0.0F, 1.0F, 0.0F); + } - if(this.rotateAngleX != 0.0F) { - GL11.glRotatef(this.rotateAngleX * 57.295776F, 1.0F, 0.0F, 0.0F); - } + if (this.rotateAngleX != 0.0F) { + GL11.glRotatef(this.rotateAngleX * 57.295776F, 1.0F, 0.0F, 0.0F); + } - GL11.glCallList(this.displayList); - GL11.glPopMatrix(); - } + GL11.glCallList(this.displayList); + GL11.glPopMatrix(); + } - GL11.glTranslatef(-this.offsetX, -this.offsetY, -this.offsetZ); - } + GL11.glTranslatef(-this.offsetX, -this.offsetY, -this.offsetZ); + } - } + } - private void compileDisplayList(float scale) - { - if (this.scale == 0) this.scale = scale; - scale = this.scale; - this.displayList = GLAllocation.generateDisplayLists(1); - GL11.glNewList(this.displayList, GL11.GL_COMPILE); + private void compileDisplayList(float scale) { + if (this.scale == 0) this.scale = scale; + scale = this.scale; + this.displayList = GLAllocation.generateDisplayLists(1); + GL11.glNewList(this.displayList, GL11.GL_COMPILE); - GL11.glPushMatrix(); - ResourceHandler.bindTexture(texture); - //scale = 1F/15F; - GL11.glScalef(scale, scale, scale); - GL11.glRotatef(180, -1, 0, 1); - model.renderAll(); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + ResourceHandler.bindTexture(texture); + //scale = 1F/15F; + GL11.glScalef(scale, scale, scale); + GL11.glRotatef(180, -1, 0, 1); + model.renderAll(); + GL11.glPopMatrix(); - GL11.glEndList(); - this.compiled = true; - } + GL11.glEndList(); + this.compiled = true; + } - @Override - public void renderWithRotation(float scale) { - if(!this.isHidden && this.showModel) { - if(!this.compiled) { - this.compileDisplayList(scale); - } + @Override + public void renderWithRotation(float scale) { + if (!this.isHidden && this.showModel) { + if (!this.compiled) { + this.compileDisplayList(scale); + } - GL11.glPushMatrix(); - GL11.glTranslatef(this.rotationPointX * scale, this.rotationPointY * scale, this.rotationPointZ * scale); - if(this.rotateAngleY != 0.0F) { - GL11.glRotatef(this.rotateAngleY * 57.295776F, 0.0F, 1.0F, 0.0F); - } + GL11.glPushMatrix(); + GL11.glTranslatef(this.rotationPointX * scale, this.rotationPointY * scale, this.rotationPointZ * scale); + if (this.rotateAngleY != 0.0F) { + GL11.glRotatef(this.rotateAngleY * 57.295776F, 0.0F, 1.0F, 0.0F); + } - if(this.rotateAngleX != 0.0F) { - GL11.glRotatef(this.rotateAngleX * 57.295776F, 1.0F, 0.0F, 0.0F); - } + if (this.rotateAngleX != 0.0F) { + GL11.glRotatef(this.rotateAngleX * 57.295776F, 1.0F, 0.0F, 0.0F); + } - if(this.rotateAngleZ != 0.0F) { - GL11.glRotatef(this.rotateAngleZ * 57.295776F, 0.0F, 0.0F, 1.0F); - } + if (this.rotateAngleZ != 0.0F) { + GL11.glRotatef(this.rotateAngleZ * 57.295776F, 0.0F, 0.0F, 1.0F); + } - GL11.glCallList(this.displayList); - GL11.glPopMatrix(); - } + GL11.glCallList(this.displayList); + GL11.glPopMatrix(); + } - } + } - @Override - public void postRender(float scale) { - if(!this.isHidden && this.showModel) { + @Override + public void postRender(float scale) { + if (!this.isHidden && this.showModel) { // if(!this.compiled) { // this.compileDisplayList(scale); // } - if(this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) { - if(this.rotationPointX != 0.0F || this.rotationPointY != 0.0F || this.rotationPointZ != 0.0F) { - GL11.glTranslatef(this.rotationPointX * scale, this.rotationPointY * scale, this.rotationPointZ * scale); - } - } else { - GL11.glTranslatef(this.rotationPointX * scale, this.rotationPointY * scale, this.rotationPointZ * scale); - if(this.rotateAngleZ != 0.0F) { - GL11.glRotatef(this.rotateAngleZ * 57.295776F, 0.0F, 0.0F, 1.0F); - } + if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) { + if (this.rotationPointX != 0.0F || this.rotationPointY != 0.0F || this.rotationPointZ != 0.0F) { + GL11.glTranslatef(this.rotationPointX * scale, this.rotationPointY * scale, this.rotationPointZ * scale); + } + } else { + GL11.glTranslatef(this.rotationPointX * scale, this.rotationPointY * scale, this.rotationPointZ * scale); + if (this.rotateAngleZ != 0.0F) { + GL11.glRotatef(this.rotateAngleZ * 57.295776F, 0.0F, 0.0F, 1.0F); + } - if(this.rotateAngleY != 0.0F) { - GL11.glRotatef(this.rotateAngleY * 57.295776F, 0.0F, 1.0F, 0.0F); - } + if (this.rotateAngleY != 0.0F) { + GL11.glRotatef(this.rotateAngleY * 57.295776F, 0.0F, 1.0F, 0.0F); + } - if(this.rotateAngleX != 0.0F) { - GL11.glRotatef(this.rotateAngleX * 57.295776F, 1.0F, 0.0F, 0.0F); - } - } - } + if (this.rotateAngleX != 0.0F) { + GL11.glRotatef(this.rotateAngleX * 57.295776F, 1.0F, 0.0F, 0.0F); + } + } + } - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelTeleporterStand.java b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelTeleporterStand.java index bdaf3002..6d51c6ea 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelTeleporterStand.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelTeleporterStand.java @@ -8,76 +8,79 @@ import net.minecraft.client.model.ModelRenderer; */ public class ModelTeleporterStand extends ModelBase { - ModelRenderer plate; - ModelRenderer holders; - ModelRenderer support; - ModelRenderer collum; - ModelRenderer baseTop; - ModelRenderer baseBottom; + ModelRenderer plate; + ModelRenderer holders; + ModelRenderer support; + ModelRenderer collum; + ModelRenderer baseTop; + ModelRenderer baseBottom; - public ModelTeleporterStand() { - textureWidth = 64; - textureHeight = 64; + public ModelTeleporterStand() { + textureWidth = 64; + textureHeight = 64; - plate = new ModelRenderer(this, 0, 0); - plate.addBox(0f, 1f, 0f, 7, 1, 7); - plate.setRotationPoint(-3.5F, -7.8F, -2F); - plate.setTextureSize(64, 64); - setRotationDegree(plate, -30, 0, 0); + plate = new ModelRenderer(this, 0, 0); + plate.addBox(0f, 1f, 0f, 7, 1, 7); + plate.setRotationPoint(-3.5F, -7.8F, -2F); + plate.setTextureSize(64, 64); + setRotationDegree(plate, -30, 0, 0); - holders = new ModelRenderer(this, 0, 0); - holders.addBox(0f, 0f, 0f, 1, 1, 1); - holders.addBox(5.55f, 0f, 0f, 1, 1, 1); - holders.setRotationPoint(-3.3F, -4.7F, 2.86F); - holders.setTextureSize(64, 64); - setRotationDegree(holders, -30, 0, 0); + holders = new ModelRenderer(this, 0, 0); + holders.addBox(0f, 0f, 0f, 1, 1, 1); + holders.addBox(5.55f, 0f, 0f, 1, 1, 1); + holders.setRotationPoint(-3.3F, -4.7F, 2.86F); + holders.setTextureSize(64, 64); + setRotationDegree(holders, -30, 0, 0); - support = new ModelRenderer(this, 0, 8); - support.addBox(0f, 0f, 0.1f, 4, 1, 1); - support.setRotationPoint(-2F, -5F, -2F); - support.setTextureSize(64, 64); - setRotation(support, 0F, 0F, 0F); + support = new ModelRenderer(this, 0, 8); + support.addBox(0f, 0f, 0.1f, 4, 1, 1); + support.setRotationPoint(-2F, -5F, -2F); + support.setTextureSize(64, 64); + setRotation(support, 0F, 0F, 0F); - collum = new ModelRenderer(this, 28, 0); - collum.addBox(0f, 0f, 0f, 4, 12, 4); - collum.setRotationPoint(-2F, -4F, -2F); - collum.setTextureSize(64, 64); - setRotation(collum, 0F, 0F, 0F); + collum = new ModelRenderer(this, 28, 0); + collum.addBox(0f, 0f, 0f, 4, 12, 4); + collum.setRotationPoint(-2F, -4F, -2F); + collum.setTextureSize(64, 64); + setRotation(collum, 0F, 0F, 0F); - baseTop = new ModelRenderer(this, 0, 27); - baseTop.addBox(0f, 0f, 0f, 6, 1, 6); - baseTop.setRotationPoint(-3F, 6F, -3F); - baseTop.setTextureSize(64, 64); - setRotation(baseTop, 0F, 0F, 0F); + baseTop = new ModelRenderer(this, 0, 27); + baseTop.addBox(0f, 0f, 0f, 6, 1, 6); + baseTop.setRotationPoint(-3F, 6F, -3F); + baseTop.setTextureSize(64, 64); + setRotation(baseTop, 0F, 0F, 0F); - baseBottom = new ModelRenderer(this, 0, 16); - baseBottom.addBox(0f, 0f, 0f, 10, 1, 10); - baseBottom.setRotationPoint(-5F, 7F, -5F); - baseBottom.setTextureSize(64, 64); - setRotationDegree(baseBottom, 0, 0, 0); + baseBottom = new ModelRenderer(this, 0, 16); + baseBottom.addBox(0f, 0f, 0f, 10, 1, 10); + baseBottom.setRotationPoint(-5F, 7F, -5F); + baseBottom.setTextureSize(64, 64); + setRotationDegree(baseBottom, 0, 0, 0); - } + } - public void render() { - final float scale = 1F / 16; + public void render() { + final float scale = 1F / 16; - plate.render(scale); - holders.render(scale); - support.render(scale); - collum.render(scale); - baseTop.render(scale); - baseBottom.render(scale); - } + plate.render(scale); + holders.render(scale); + support.render(scale); + collum.render(scale); + baseTop.render(scale); + baseBottom.render(scale); + } - private void setRotation(ModelRenderer model, float x, float y, float z) { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } - /**Sets rotation in degrees (0-360)*/ - private void setRotationDegree(ModelRenderer model, int x, int y, int z) { - model.rotateAngleX = x / (180F / (float)Math.PI); - model.rotateAngleY = y / (180F / (float)Math.PI); - model.rotateAngleZ = z / (180F / (float)Math.PI); - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + /** + * Sets rotation in degrees (0-360) + */ + private void setRotationDegree(ModelRenderer model, int x, int y, int z) { + model.rotateAngleX = x / (180F / (float) Math.PI); + model.rotateAngleY = y / (180F / (float) Math.PI); + model.rotateAngleZ = z / (180F / (float) Math.PI); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelWyvernArmor.java b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelWyvernArmor.java index aab9f97d..19cacd8c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/model/ModelWyvernArmor.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/model/ModelWyvernArmor.java @@ -8,174 +8,172 @@ import net.minecraft.entity.Entity; public class ModelWyvernArmor extends ModelBiped { - public ModelRenderOBJ head; - public ModelRenderOBJ body; - public ModelRenderOBJ rightArm; - public ModelRenderOBJ leftArm; - public ModelRenderOBJ belt; - public ModelRenderOBJ rightLeg; - public ModelRenderOBJ leftLeg; - public ModelRenderOBJ rightBoot; - public ModelRenderOBJ leftBoot; + public ModelRenderOBJ head; + public ModelRenderOBJ body; + public ModelRenderOBJ rightArm; + public ModelRenderOBJ leftArm; + public ModelRenderOBJ belt; + public ModelRenderOBJ rightLeg; + public ModelRenderOBJ leftLeg; + public ModelRenderOBJ rightBoot; + public ModelRenderOBJ leftBoot; public ModelWyvernArmor(float f, boolean isHelmet, boolean isChestPiece, boolean isLeggings, boolean isdBoots) { - super(f, 0.0f, 128, 128); + super(f, 0.0f, 128, 128); - this.bipedHead = new ModelRenderer(this, 0, 0); - this.bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.0F); + this.bipedHead = new ModelRenderer(this, 0, 0); + this.bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.0F); - this.bipedBody = new ModelRenderer(this, 16, 16); - this.bipedBody.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, 0.0F); + this.bipedBody = new ModelRenderer(this, 16, 16); + this.bipedBody.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, 0.0F); - this.bipedLeftArm = new ModelRenderer(this, 40, 16); - this.bipedLeftArm.setRotationPoint(5.0F, 2.0F, 0.0F); - this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, 0.0F); + this.bipedLeftArm = new ModelRenderer(this, 40, 16); + this.bipedLeftArm.setRotationPoint(5.0F, 2.0F, 0.0F); + this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, 0.0F); - this.bipedRightArm = new ModelRenderer(this, 40, 16); - this.bipedRightArm.setRotationPoint(-5.0F, 2.0F, 0.0F); - this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, 0.0F); + this.bipedRightArm = new ModelRenderer(this, 40, 16); + this.bipedRightArm.setRotationPoint(-5.0F, 2.0F, 0.0F); + this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, 0.0F); - this.bipedLeftLeg = new ModelRenderer(this, 0, 16); - this.bipedLeftLeg.setRotationPoint(2.0F, 12.0F, 0.0F); - this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0.0F); + this.bipedLeftLeg = new ModelRenderer(this, 0, 16); + this.bipedLeftLeg.setRotationPoint(2.0F, 12.0F, 0.0F); + this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0.0F); - this.bipedRightLeg = new ModelRenderer(this, 0, 16); - this.bipedRightLeg.setRotationPoint(-2.0F, 12.0F, 0.0F); - this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0.0F); + this.bipedRightLeg = new ModelRenderer(this, 0, 16); + this.bipedRightLeg.setRotationPoint(-2.0F, 12.0F, 0.0F); + this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, 0.0F); - this.head = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernHelmet.obj"), ResourceHandler.getResource("textures/models/armor/WyvernHelmet.png")); - this.body = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernBody.obj"), ResourceHandler.getResource("textures/models/armor/WyvernBody.png")); - this.rightArm = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernRightArm.obj"), ResourceHandler.getResource("textures/models/armor/WyvernRightArm.png")); - this.leftArm = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernLeftArm.obj"), ResourceHandler.getResource("textures/models/armor/WyvernLeftArm.png")); - this.belt = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernBelt.obj"), ResourceHandler.getResource("textures/models/armor/WyvernBelt.png")); - this.rightLeg = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernRightLeg.obj"), ResourceHandler.getResource("textures/models/armor/WyvernRightLeg.png")); - this.leftLeg = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernLeftLeg.obj"), ResourceHandler.getResource("textures/models/armor/WyvernLeftLeg.png")); - this.rightBoot = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernRightBoot.obj"), ResourceHandler.getResource("textures/models/armor/WyvernRightBoot.png")); - this.leftBoot = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernLeftBoot.obj"), ResourceHandler.getResource("textures/models/armor/WyvernLeftBoot.png")); + this.head = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernHelmet.obj"), ResourceHandler.getResource("textures/models/armor/WyvernHelmet.png")); + this.body = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernBody.obj"), ResourceHandler.getResource("textures/models/armor/WyvernBody.png")); + this.rightArm = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernRightArm.obj"), ResourceHandler.getResource("textures/models/armor/WyvernRightArm.png")); + this.leftArm = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernLeftArm.obj"), ResourceHandler.getResource("textures/models/armor/WyvernLeftArm.png")); + this.belt = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernBelt.obj"), ResourceHandler.getResource("textures/models/armor/WyvernBelt.png")); + this.rightLeg = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernRightLeg.obj"), ResourceHandler.getResource("textures/models/armor/WyvernRightLeg.png")); + this.leftLeg = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernLeftLeg.obj"), ResourceHandler.getResource("textures/models/armor/WyvernLeftLeg.png")); + this.rightBoot = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernRightBoot.obj"), ResourceHandler.getResource("textures/models/armor/WyvernRightBoot.png")); + this.leftBoot = new ModelRenderOBJ(this, ResourceHandler.getResource("models/armor/WyvernLeftBoot.obj"), ResourceHandler.getResource("textures/models/armor/WyvernLeftBoot.png")); - this.bipedHead.cubeList.clear(); - this.bipedHeadwear.cubeList.clear(); - this.bipedBody.cubeList.clear(); - this.bipedRightArm.cubeList.clear(); - this.bipedLeftArm.cubeList.clear(); - this.bipedLeftLeg.cubeList.clear(); - this.bipedRightLeg.cubeList.clear(); + this.bipedHead.cubeList.clear(); + this.bipedHeadwear.cubeList.clear(); + this.bipedBody.cubeList.clear(); + this.bipedRightArm.cubeList.clear(); + this.bipedLeftArm.cubeList.clear(); + this.bipedLeftLeg.cubeList.clear(); + this.bipedRightLeg.cubeList.clear(); - body.offsetY = 0.755F; - rightArm.offsetY = 0.755F; - leftArm.offsetY = 0.755F; + body.offsetY = 0.755F; + rightArm.offsetY = 0.755F; + leftArm.offsetY = 0.755F; - head.offsetY = -0.07F; - body.offsetY = 0.755F; - body.offsetZ = -0.03F; - rightArm.offsetY = 0.72F; - rightArm.offsetX = -0.18F; - rightArm.offsetZ = 0.F; - leftArm.offsetY = 0.72F; - leftArm.offsetX = 0.18F; - leftArm.offsetZ = 0F; - belt.offsetY = 0.756F; - belt.offsetZ = -0.04F; - rightLeg.offsetY = 0.6F; - rightLeg.offsetX = -0.06F; - leftLeg.offsetY = 0.6F; - leftLeg.offsetX = 0.06F; - rightBoot.offsetY = 0.76F; - rightBoot.offsetX = -0.03F; - leftBoot.offsetY = 0.76F; - leftBoot.offsetX = 0.03F; + head.offsetY = -0.07F; + body.offsetY = 0.755F; + body.offsetZ = -0.03F; + rightArm.offsetY = 0.72F; + rightArm.offsetX = -0.18F; + rightArm.offsetZ = 0.F; + leftArm.offsetY = 0.72F; + leftArm.offsetX = 0.18F; + leftArm.offsetZ = 0F; + belt.offsetY = 0.756F; + belt.offsetZ = -0.04F; + rightLeg.offsetY = 0.6F; + rightLeg.offsetX = -0.06F; + leftLeg.offsetY = 0.6F; + leftLeg.offsetX = 0.06F; + rightBoot.offsetY = 0.76F; + rightBoot.offsetX = -0.03F; + leftBoot.offsetY = 0.76F; + leftBoot.offsetX = 0.03F; - leftLeg.scale = 1F / 15F; - rightLeg.scale = 1F / 15F; - leftBoot.scale = 1F / 15F; - rightBoot.scale = 1F / 15F; + leftLeg.scale = 1F / 15F; + rightLeg.scale = 1F / 15F; + leftBoot.scale = 1F / 15F; + rightBoot.scale = 1F / 15F; - if (isHelmet) { - this.bipedHead.addChild(head); - } - if (isChestPiece) { - this.bipedBody.addChild(body); - this.bipedLeftArm.addChild(leftArm); - this.bipedRightArm.addChild(rightArm); - } - if (isLeggings) { - this.bipedLeftLeg.addChild(leftLeg); - this.bipedRightLeg.addChild(rightLeg); - this.bipedBody.addChild(belt); - } - if (isdBoots) { - this.bipedLeftLeg.addChild(leftBoot); - this.bipedRightLeg.addChild(rightBoot); - } + if (isHelmet) { + this.bipedHead.addChild(head); + } + if (isChestPiece) { + this.bipedBody.addChild(body); + this.bipedLeftArm.addChild(leftArm); + this.bipedRightArm.addChild(rightArm); + } + if (isLeggings) { + this.bipedLeftLeg.addChild(leftLeg); + this.bipedRightLeg.addChild(rightLeg); + this.bipedBody.addChild(belt); + } + if (isdBoots) { + this.bipedLeftLeg.addChild(leftBoot); + this.bipedRightLeg.addChild(rightBoot); + } } @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - if (entity == null){ - isSneak = false; - isRiding = false; - isChild = false; - aimedBow = false; + if (entity == null) { + isSneak = false; + isRiding = false; + isChild = false; + aimedBow = false; - this.bipedRightArm.rotateAngleX = 0F; - this.bipedRightArm.rotateAngleY = 0F; - this.bipedRightArm.rotateAngleZ = 0F; - this.bipedLeftArm.rotateAngleX = 0F; - this.bipedLeftArm.rotateAngleY = 0F; - this.bipedLeftArm.rotateAngleZ = 0F; + this.bipedRightArm.rotateAngleX = 0F; + this.bipedRightArm.rotateAngleY = 0F; + this.bipedRightArm.rotateAngleZ = 0F; + this.bipedLeftArm.rotateAngleX = 0F; + this.bipedLeftArm.rotateAngleY = 0F; + this.bipedLeftArm.rotateAngleZ = 0F; - bipedBody.rotateAngleX = 0F; - bipedBody.rotateAngleY = 0F; - bipedBody.rotateAngleZ = 0F; + bipedBody.rotateAngleX = 0F; + bipedBody.rotateAngleY = 0F; + bipedBody.rotateAngleZ = 0F; - bipedHead.rotateAngleX = 0F; - bipedHead.rotateAngleY = 0F; - bipedHead.rotateAngleZ = 0F; + bipedHead.rotateAngleX = 0F; + bipedHead.rotateAngleY = 0F; + bipedHead.rotateAngleZ = 0F; - bipedLeftLeg.rotateAngleX = 0F; - bipedLeftLeg.rotateAngleY = 0F; - bipedLeftLeg.rotateAngleZ = 0F; + bipedLeftLeg.rotateAngleX = 0F; + bipedLeftLeg.rotateAngleY = 0F; + bipedLeftLeg.rotateAngleZ = 0F; - bipedRightLeg.rotateAngleX = 0F; - bipedRightLeg.rotateAngleY = 0F; - bipedRightLeg.rotateAngleZ = 0F; + bipedRightLeg.rotateAngleX = 0F; + bipedRightLeg.rotateAngleY = 0F; + bipedRightLeg.rotateAngleZ = 0F; - setRotationAngles(0, 0, 0, 0, 0, 0, null); - } - else super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + setRotationAngles(0, 0, 0, 0, 0, 0, null); + } else super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); - this.bipedHead.render(1F/13F); - this.bipedRightArm.render(1F/15F); - this.bipedLeftArm.render(1F/15F); - this.bipedBody.render(1F/15F); - this.bipedRightLeg.render(1F/16F); - this.bipedLeftLeg.render(1F/16F); - } + this.bipedHead.render(1F / 13F); + this.bipedRightArm.render(1F / 15F); + this.bipedLeftArm.render(1F / 15F); + this.bipedBody.render(1F / 15F); + this.bipedRightLeg.render(1F / 16F); + this.bipedLeftLeg.render(1F / 16F); + } - public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float scale, Entity p_78087_7_) - { - this.bipedRightArm.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleZ = 0.0F; - this.bipedRightArm.rotationPointZ = 0.0F; - this.bipedLeftArm.rotationPointZ = 0.0F; - this.bipedRightLeg.rotateAngleY = 0.0F; - this.bipedLeftLeg.rotateAngleY = 0.0F; - this.bipedRightArm.rotateAngleY = 0.0F; - this.bipedLeftArm.rotateAngleY = 0.0F; - this.bipedBody.rotateAngleX = 0.0F; - this.bipedRightLeg.rotationPointZ = 0.1F; - this.bipedLeftLeg.rotationPointZ = 0.1F; - this.bipedRightLeg.rotationPointY = 12.0F; - this.bipedLeftLeg.rotationPointY = 12.0F; - this.bipedHead.rotationPointY = 0.0F; - this.bipedHeadwear.rotationPointY = 0.0F; - this.leftLeg.rotationPointZ = 0F; - this.rightLeg.rotationPointZ = 0F; - this.bipedRightArm.rotateAngleZ = 0.0F; - this.bipedLeftArm.rotateAngleZ = 0.0F; - } + public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float scale, Entity p_78087_7_) { + this.bipedRightArm.rotateAngleZ = 0.0F; + this.bipedLeftArm.rotateAngleZ = 0.0F; + this.bipedRightArm.rotationPointZ = 0.0F; + this.bipedLeftArm.rotationPointZ = 0.0F; + this.bipedRightLeg.rotateAngleY = 0.0F; + this.bipedLeftLeg.rotateAngleY = 0.0F; + this.bipedRightArm.rotateAngleY = 0.0F; + this.bipedLeftArm.rotateAngleY = 0.0F; + this.bipedBody.rotateAngleX = 0.0F; + this.bipedRightLeg.rotationPointZ = 0.1F; + this.bipedLeftLeg.rotationPointZ = 0.1F; + this.bipedRightLeg.rotationPointY = 12.0F; + this.bipedLeftLeg.rotationPointY = 12.0F; + this.bipedHead.rotationPointY = 0.0F; + this.bipedHeadwear.rotationPointY = 0.0F; + this.leftLeg.rotationPointZ = 0F; + this.rightLeg.rotationPointZ = 0F; + this.bipedRightArm.rotateAngleZ = 0.0F; + this.bipedLeftArm.rotateAngleZ = 0.0F; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/model/special/ModelContributorWings.java b/src/main/java/com/brandon3055/draconicevolution/client/model/special/ModelContributorWings.java index fb015f43..32dbdebe 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/model/special/ModelContributorWings.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/model/special/ModelContributorWings.java @@ -63,32 +63,31 @@ public class ModelContributorWings extends ModelBase { @Override public void render(Entity entity, float f, float f1, float f2, float f3, float partialTick, float scale) { - GL11.glPushMatrix(); + GL11.glPushMatrix(); - float baseRot = 0.45906584F; - float outerRot = 0.61086524F; + float baseRot = 0.45906584F; + float outerRot = 0.61086524F; - float animation = (float)Math.sin(((float)ClientEventHandler.elapsedTicks + partialTick) / 20); + float animation = (float) Math.sin(((float) ClientEventHandler.elapsedTicks + partialTick) / 20); - if (entity.isSneaking()){ - this.leftBaseStem.rotateAngleX = 0.5F; - this.rightBaseStem.rotateAngleX = 0.5F; - } - else { - this.leftBaseStem.rotateAngleX = 0F; - this.rightBaseStem.rotateAngleX = 0F; - } + if (entity.isSneaking()) { + this.leftBaseStem.rotateAngleX = 0.5F; + this.rightBaseStem.rotateAngleX = 0.5F; + } else { + this.leftBaseStem.rotateAngleX = 0F; + this.rightBaseStem.rotateAngleX = 0F; + } - this.leftBaseStem.rotateAngleY = -baseRot + (animation * 0.15F); - this.leftOuterStem.rotateAngleY = outerRot + (animation * 0.3F); - this.rightBaseStem.rotateAngleY = baseRot - (animation * 0.15F); - this.rightOuterStem.rotateAngleY = -outerRot - (animation * 0.3F); + this.leftBaseStem.rotateAngleY = -baseRot + (animation * 0.15F); + this.leftOuterStem.rotateAngleY = outerRot + (animation * 0.3F); + this.rightBaseStem.rotateAngleY = baseRot - (animation * 0.15F); + this.rightOuterStem.rotateAngleY = -outerRot - (animation * 0.3F); this.leftBaseStem.render(scale); this.rightBaseStem.render(scale); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } /** * This is a helper function from Tabula to set the rotation of model parts diff --git a/src/main/java/com/brandon3055/draconicevolution/client/model/special/ModelStaffOfTheGreatOne.java b/src/main/java/com/brandon3055/draconicevolution/client/model/special/ModelStaffOfTheGreatOne.java index 6b44af21..28c05446 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/model/special/ModelStaffOfTheGreatOne.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/model/special/ModelStaffOfTheGreatOne.java @@ -10,7 +10,7 @@ import org.lwjgl.opengl.GL11; * Created using Tabula 5.0.0 */ public class ModelStaffOfTheGreatOne extends ModelBase { - public double[] modelScale = new double[] { 2.0D, 2.0D, 2.0D }; + public double[] modelScale = new double[]{2.0D, 2.0D, 2.0D}; public ModelRenderer staff; public ModelRenderer edge1; public ModelRenderer edge1_1; @@ -332,9 +332,9 @@ public class ModelStaffOfTheGreatOne extends ModelBase { @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glScaled(1D / modelScale[0], 1D / modelScale[1], 1D / modelScale[2]); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge1.offsetX, this.edge1.offsetY, this.edge1.offsetZ); GL11.glTranslated(this.edge1.rotationPointX * f5, this.edge1.rotationPointY * f5, this.edge1.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -342,7 +342,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge1.rotationPointX * f5, -this.edge1.rotationPointY * f5, -this.edge1.rotationPointZ * f5); this.edge1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.staffTopM_3.offsetX, this.staffTopM_3.offsetY, this.staffTopM_3.offsetZ); GL11.glTranslated(this.staffTopM_3.rotationPointX * f5, this.staffTopM_3.rotationPointY * f5, this.staffTopM_3.rotationPointZ * f5); GL11.glScaled(0.6D, 1.06D, 0.6D); @@ -350,7 +350,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.staffTopM_3.rotationPointX * f5, -this.staffTopM_3.rotationPointY * f5, -this.staffTopM_3.rotationPointZ * f5); this.staffTopM_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge2_1.offsetX, this.edge2_1.offsetY, this.edge2_1.offsetZ); GL11.glTranslated(this.edge2_1.rotationPointX * f5, this.edge2_1.rotationPointY * f5, this.edge2_1.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -358,7 +358,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge2_1.rotationPointX * f5, -this.edge2_1.rotationPointY * f5, -this.edge2_1.rotationPointZ * f5); this.edge2_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape5_1.offsetX, this.shape5_1.offsetY, this.shape5_1.offsetZ); GL11.glTranslated(this.shape5_1.rotationPointX * f5, this.shape5_1.rotationPointY * f5, this.shape5_1.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -366,7 +366,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape5_1.rotationPointX * f5, -this.shape5_1.rotationPointY * f5, -this.shape5_1.rotationPointZ * f5); this.shape5_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape4_2.offsetX, this.shape4_2.offsetY, this.shape4_2.offsetZ); GL11.glTranslated(this.shape4_2.rotationPointX * f5, this.shape4_2.rotationPointY * f5, this.shape4_2.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -374,7 +374,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape4_2.rotationPointX * f5, -this.shape4_2.rotationPointY * f5, -this.shape4_2.rotationPointZ * f5); this.shape4_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.tope2.offsetX, this.tope2.offsetY, this.tope2.offsetZ); GL11.glTranslated(this.tope2.rotationPointX * f5, this.tope2.rotationPointY * f5, this.tope2.rotationPointZ * f5); GL11.glScaled(0.9D, 0.5D, 0.9D); @@ -382,7 +382,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.tope2.rotationPointX * f5, -this.tope2.rotationPointY * f5, -this.tope2.rotationPointZ * f5); this.tope2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.tope1.offsetX, this.tope1.offsetY, this.tope1.offsetZ); GL11.glTranslated(this.tope1.rotationPointX * f5, this.tope1.rotationPointY * f5, this.tope1.rotationPointZ * f5); GL11.glScaled(1.2D, 0.5D, 1.2D); @@ -390,7 +390,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.tope1.rotationPointX * f5, -this.tope1.rotationPointY * f5, -this.tope1.rotationPointZ * f5); this.tope1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape7_2.offsetX, this.shape7_2.offsetY, this.shape7_2.offsetZ); GL11.glTranslated(this.shape7_2.rotationPointX * f5, this.shape7_2.rotationPointY * f5, this.shape7_2.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -398,7 +398,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape7_2.rotationPointX * f5, -this.shape7_2.rotationPointY * f5, -this.shape7_2.rotationPointZ * f5); this.shape7_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape4.offsetX, this.shape4.offsetY, this.shape4.offsetZ); GL11.glTranslated(this.shape4.rotationPointX * f5, this.shape4.rotationPointY * f5, this.shape4.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -406,7 +406,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape4.rotationPointX * f5, -this.shape4.rotationPointY * f5, -this.shape4.rotationPointZ * f5); this.shape4.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape2_2.offsetX, this.shape2_2.offsetY, this.shape2_2.offsetZ); GL11.glTranslated(this.shape2_2.rotationPointX * f5, this.shape2_2.rotationPointY * f5, this.shape2_2.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -414,7 +414,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape2_2.rotationPointX * f5, -this.shape2_2.rotationPointY * f5, -this.shape2_2.rotationPointZ * f5); this.shape2_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge2_2.offsetX, this.topedge2_2.offsetY, this.topedge2_2.offsetZ); GL11.glTranslated(this.topedge2_2.rotationPointX * f5, this.topedge2_2.rotationPointY * f5, this.topedge2_2.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -422,7 +422,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge2_2.rotationPointX * f5, -this.topedge2_2.rotationPointY * f5, -this.topedge2_2.rotationPointZ * f5); this.topedge2_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge4_1.offsetX, this.topedge4_1.offsetY, this.topedge4_1.offsetZ); GL11.glTranslated(this.topedge4_1.rotationPointX * f5, this.topedge4_1.rotationPointY * f5, this.topedge4_1.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -430,7 +430,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge4_1.rotationPointX * f5, -this.topedge4_1.rotationPointY * f5, -this.topedge4_1.rotationPointZ * f5); this.topedge4_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge5.offsetX, this.topedge5.offsetY, this.topedge5.offsetZ); GL11.glTranslated(this.topedge5.rotationPointX * f5, this.topedge5.rotationPointY * f5, this.topedge5.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -438,7 +438,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge5.rotationPointX * f5, -this.topedge5.rotationPointY * f5, -this.topedge5.rotationPointZ * f5); this.topedge5.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge4_2.offsetX, this.topedge4_2.offsetY, this.topedge4_2.offsetZ); GL11.glTranslated(this.topedge4_2.rotationPointX * f5, this.topedge4_2.rotationPointY * f5, this.topedge4_2.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -446,7 +446,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge4_2.rotationPointX * f5, -this.topedge4_2.rotationPointY * f5, -this.topedge4_2.rotationPointZ * f5); this.topedge4_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape6_2.offsetX, this.shape6_2.offsetY, this.shape6_2.offsetZ); GL11.glTranslated(this.shape6_2.rotationPointX * f5, this.shape6_2.rotationPointY * f5, this.shape6_2.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -454,7 +454,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape6_2.rotationPointX * f5, -this.shape6_2.rotationPointY * f5, -this.shape6_2.rotationPointZ * f5); this.shape6_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge3.offsetX, this.edge3.offsetY, this.edge3.offsetZ); GL11.glTranslated(this.edge3.rotationPointX * f5, this.edge3.rotationPointY * f5, this.edge3.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -462,7 +462,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge3.rotationPointX * f5, -this.edge3.rotationPointY * f5, -this.edge3.rotationPointZ * f5); this.edge3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge4_3.offsetX, this.topedge4_3.offsetY, this.topedge4_3.offsetZ); GL11.glTranslated(this.topedge4_3.rotationPointX * f5, this.topedge4_3.rotationPointY * f5, this.topedge4_3.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -470,7 +470,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge4_3.rotationPointX * f5, -this.topedge4_3.rotationPointY * f5, -this.topedge4_3.rotationPointZ * f5); this.topedge4_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape5_3.offsetX, this.shape5_3.offsetY, this.shape5_3.offsetZ); GL11.glTranslated(this.shape5_3.rotationPointX * f5, this.shape5_3.rotationPointY * f5, this.shape5_3.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -478,7 +478,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape5_3.rotationPointX * f5, -this.shape5_3.rotationPointY * f5, -this.shape5_3.rotationPointZ * f5); this.shape5_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape4_3.offsetX, this.shape4_3.offsetY, this.shape4_3.offsetZ); GL11.glTranslated(this.shape4_3.rotationPointX * f5, this.shape4_3.rotationPointY * f5, this.shape4_3.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -486,7 +486,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape4_3.rotationPointX * f5, -this.shape4_3.rotationPointY * f5, -this.shape4_3.rotationPointZ * f5); this.shape4_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge3.offsetX, this.topedge3.offsetY, this.topedge3.offsetZ); GL11.glTranslated(this.topedge3.rotationPointX * f5, this.topedge3.rotationPointY * f5, this.topedge3.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -494,7 +494,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge3.rotationPointX * f5, -this.topedge3.rotationPointY * f5, -this.topedge3.rotationPointZ * f5); this.topedge3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge4.offsetX, this.topedge4.offsetY, this.topedge4.offsetZ); GL11.glTranslated(this.topedge4.rotationPointX * f5, this.topedge4.rotationPointY * f5, this.topedge4.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -502,7 +502,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge4.rotationPointX * f5, -this.topedge4.rotationPointY * f5, -this.topedge4.rotationPointZ * f5); this.topedge4.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge5_2.offsetX, this.edge5_2.offsetY, this.edge5_2.offsetZ); GL11.glTranslated(this.edge5_2.rotationPointX * f5, this.edge5_2.rotationPointY * f5, this.edge5_2.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -510,7 +510,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge5_2.rotationPointX * f5, -this.edge5_2.rotationPointY * f5, -this.edge5_2.rotationPointZ * f5); this.edge5_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge5.offsetX, this.edge5.offsetY, this.edge5.offsetZ); GL11.glTranslated(this.edge5.rotationPointX * f5, this.edge5.rotationPointY * f5, this.edge5.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -518,7 +518,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge5.rotationPointX * f5, -this.edge5.rotationPointY * f5, -this.edge5.rotationPointZ * f5); this.edge5.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge2_3.offsetX, this.topedge2_3.offsetY, this.topedge2_3.offsetZ); GL11.glTranslated(this.topedge2_3.rotationPointX * f5, this.topedge2_3.rotationPointY * f5, this.topedge2_3.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -526,7 +526,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge2_3.rotationPointX * f5, -this.topedge2_3.rotationPointY * f5, -this.topedge2_3.rotationPointZ * f5); this.topedge2_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape6_3.offsetX, this.shape6_3.offsetY, this.shape6_3.offsetZ); GL11.glTranslated(this.shape6_3.rotationPointX * f5, this.shape6_3.rotationPointY * f5, this.shape6_3.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -534,7 +534,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape6_3.rotationPointX * f5, -this.shape6_3.rotationPointY * f5, -this.shape6_3.rotationPointZ * f5); this.shape6_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge1_1.offsetX, this.edge1_1.offsetY, this.edge1_1.offsetZ); GL11.glTranslated(this.edge1_1.rotationPointX * f5, this.edge1_1.rotationPointY * f5, this.edge1_1.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -542,7 +542,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge1_1.rotationPointX * f5, -this.edge1_1.rotationPointY * f5, -this.edge1_1.rotationPointZ * f5); this.edge1_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape5_2.offsetX, this.shape5_2.offsetY, this.shape5_2.offsetZ); GL11.glTranslated(this.shape5_2.rotationPointX * f5, this.shape5_2.rotationPointY * f5, this.shape5_2.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -550,7 +550,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape5_2.rotationPointX * f5, -this.shape5_2.rotationPointY * f5, -this.shape5_2.rotationPointZ * f5); this.shape5_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge5_2.offsetX, this.topedge5_2.offsetY, this.topedge5_2.offsetZ); GL11.glTranslated(this.topedge5_2.rotationPointX * f5, this.topedge5_2.rotationPointY * f5, this.topedge5_2.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -558,7 +558,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge5_2.rotationPointX * f5, -this.topedge5_2.rotationPointY * f5, -this.topedge5_2.rotationPointZ * f5); this.topedge5_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge2.offsetX, this.topedge2.offsetY, this.topedge2.offsetZ); GL11.glTranslated(this.topedge2.rotationPointX * f5, this.topedge2.rotationPointY * f5, this.topedge2.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -566,7 +566,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge2.rotationPointX * f5, -this.topedge2.rotationPointY * f5, -this.topedge2.rotationPointZ * f5); this.topedge2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.staffTopQ_3.offsetX, this.staffTopQ_3.offsetY, this.staffTopQ_3.offsetZ); GL11.glTranslated(this.staffTopQ_3.rotationPointX * f5, this.staffTopQ_3.rotationPointY * f5, this.staffTopQ_3.rotationPointZ * f5); GL11.glScaled(0.7D, 1.0D, 0.7D); @@ -574,7 +574,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.staffTopQ_3.rotationPointX * f5, -this.staffTopQ_3.rotationPointY * f5, -this.staffTopQ_3.rotationPointZ * f5); this.staffTopQ_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge4_2.offsetX, this.edge4_2.offsetY, this.edge4_2.offsetZ); GL11.glTranslated(this.edge4_2.rotationPointX * f5, this.edge4_2.rotationPointY * f5, this.edge4_2.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -582,7 +582,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge4_2.rotationPointX * f5, -this.edge4_2.rotationPointY * f5, -this.edge4_2.rotationPointZ * f5); this.edge4_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.staffTopQ_1.offsetX, this.staffTopQ_1.offsetY, this.staffTopQ_1.offsetZ); GL11.glTranslated(this.staffTopQ_1.rotationPointX * f5, this.staffTopQ_1.rotationPointY * f5, this.staffTopQ_1.rotationPointZ * f5); GL11.glScaled(0.7D, 1.0D, 0.7D); @@ -590,7 +590,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.staffTopQ_1.rotationPointX * f5, -this.staffTopQ_1.rotationPointY * f5, -this.staffTopQ_1.rotationPointZ * f5); this.staffTopQ_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge3_3.offsetX, this.edge3_3.offsetY, this.edge3_3.offsetZ); GL11.glTranslated(this.edge3_3.rotationPointX * f5, this.edge3_3.rotationPointY * f5, this.edge3_3.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -598,7 +598,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge3_3.rotationPointX * f5, -this.edge3_3.rotationPointY * f5, -this.edge3_3.rotationPointZ * f5); this.edge3_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape3.offsetX, this.shape3.offsetY, this.shape3.offsetZ); GL11.glTranslated(this.shape3.rotationPointX * f5, this.shape3.rotationPointY * f5, this.shape3.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -606,7 +606,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape3.rotationPointX * f5, -this.shape3.rotationPointY * f5, -this.shape3.rotationPointZ * f5); this.shape3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape2_3.offsetX, this.shape2_3.offsetY, this.shape2_3.offsetZ); GL11.glTranslated(this.shape2_3.rotationPointX * f5, this.shape2_3.rotationPointY * f5, this.shape2_3.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -614,7 +614,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape2_3.rotationPointX * f5, -this.shape2_3.rotationPointY * f5, -this.shape2_3.rotationPointZ * f5); this.shape2_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge1.offsetX, this.topedge1.offsetY, this.topedge1.offsetZ); GL11.glTranslated(this.topedge1.rotationPointX * f5, this.topedge1.rotationPointY * f5, this.topedge1.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -622,7 +622,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge1.rotationPointX * f5, -this.topedge1.rotationPointY * f5, -this.topedge1.rotationPointZ * f5); this.topedge1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge5_1.offsetX, this.topedge5_1.offsetY, this.topedge5_1.offsetZ); GL11.glTranslated(this.topedge5_1.rotationPointX * f5, this.topedge5_1.rotationPointY * f5, this.topedge5_1.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -630,7 +630,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge5_1.rotationPointX * f5, -this.topedge5_1.rotationPointY * f5, -this.topedge5_1.rotationPointZ * f5); this.topedge5_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape7_3.offsetX, this.shape7_3.offsetY, this.shape7_3.offsetZ); GL11.glTranslated(this.shape7_3.rotationPointX * f5, this.shape7_3.rotationPointY * f5, this.shape7_3.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -638,7 +638,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape7_3.rotationPointX * f5, -this.shape7_3.rotationPointY * f5, -this.shape7_3.rotationPointZ * f5); this.shape7_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.staffTopM_2.offsetX, this.staffTopM_2.offsetY, this.staffTopM_2.offsetZ); GL11.glTranslated(this.staffTopM_2.rotationPointX * f5, this.staffTopM_2.rotationPointY * f5, this.staffTopM_2.rotationPointZ * f5); GL11.glScaled(0.6D, 1.06D, 0.6D); @@ -646,7 +646,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.staffTopM_2.rotationPointX * f5, -this.staffTopM_2.rotationPointY * f5, -this.staffTopM_2.rotationPointZ * f5); this.staffTopM_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape3_3.offsetX, this.shape3_3.offsetY, this.shape3_3.offsetZ); GL11.glTranslated(this.shape3_3.rotationPointX * f5, this.shape3_3.rotationPointY * f5, this.shape3_3.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -654,7 +654,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape3_3.rotationPointX * f5, -this.shape3_3.rotationPointY * f5, -this.shape3_3.rotationPointZ * f5); this.shape3_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape3_1.offsetX, this.shape3_1.offsetY, this.shape3_1.offsetZ); GL11.glTranslated(this.shape3_1.rotationPointX * f5, this.shape3_1.rotationPointY * f5, this.shape3_1.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -662,7 +662,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape3_1.rotationPointX * f5, -this.shape3_1.rotationPointY * f5, -this.shape3_1.rotationPointZ * f5); this.shape3_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape6_1.offsetX, this.shape6_1.offsetY, this.shape6_1.offsetZ); GL11.glTranslated(this.shape6_1.rotationPointX * f5, this.shape6_1.rotationPointY * f5, this.shape6_1.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -670,7 +670,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape6_1.rotationPointX * f5, -this.shape6_1.rotationPointY * f5, -this.shape6_1.rotationPointZ * f5); this.shape6_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape7_1.offsetX, this.shape7_1.offsetY, this.shape7_1.offsetZ); GL11.glTranslated(this.shape7_1.rotationPointX * f5, this.shape7_1.rotationPointY * f5, this.shape7_1.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -678,7 +678,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape7_1.rotationPointX * f5, -this.shape7_1.rotationPointY * f5, -this.shape7_1.rotationPointZ * f5); this.shape7_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge1_3.offsetX, this.topedge1_3.offsetY, this.topedge1_3.offsetZ); GL11.glTranslated(this.topedge1_3.rotationPointX * f5, this.topedge1_3.rotationPointY * f5, this.topedge1_3.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -686,7 +686,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge1_3.rotationPointX * f5, -this.topedge1_3.rotationPointY * f5, -this.topedge1_3.rotationPointZ * f5); this.topedge1_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.tope3.offsetX, this.tope3.offsetY, this.tope3.offsetZ); GL11.glTranslated(this.tope3.rotationPointX * f5, this.tope3.rotationPointY * f5, this.tope3.rotationPointZ * f5); GL11.glScaled(0.6D, 0.6D, 0.6D); @@ -694,7 +694,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.tope3.rotationPointX * f5, -this.tope3.rotationPointY * f5, -this.tope3.rotationPointZ * f5); this.tope3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape5.offsetX, this.shape5.offsetY, this.shape5.offsetZ); GL11.glTranslated(this.shape5.rotationPointX * f5, this.shape5.rotationPointY * f5, this.shape5.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -702,7 +702,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape5.rotationPointX * f5, -this.shape5.rotationPointY * f5, -this.shape5.rotationPointZ * f5); this.shape5.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge3_1.offsetX, this.topedge3_1.offsetY, this.topedge3_1.offsetZ); GL11.glTranslated(this.topedge3_1.rotationPointX * f5, this.topedge3_1.rotationPointY * f5, this.topedge3_1.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -710,7 +710,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge3_1.rotationPointX * f5, -this.topedge3_1.rotationPointY * f5, -this.topedge3_1.rotationPointZ * f5); this.topedge3_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge5_3.offsetX, this.topedge5_3.offsetY, this.topedge5_3.offsetZ); GL11.glTranslated(this.topedge5_3.rotationPointX * f5, this.topedge5_3.rotationPointY * f5, this.topedge5_3.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -718,7 +718,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge5_3.rotationPointX * f5, -this.topedge5_3.rotationPointY * f5, -this.topedge5_3.rotationPointZ * f5); this.topedge5_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge5_3.offsetX, this.edge5_3.offsetY, this.edge5_3.offsetZ); GL11.glTranslated(this.edge5_3.rotationPointX * f5, this.edge5_3.rotationPointY * f5, this.edge5_3.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -726,7 +726,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge5_3.rotationPointX * f5, -this.edge5_3.rotationPointY * f5, -this.edge5_3.rotationPointZ * f5); this.edge5_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge3_1.offsetX, this.edge3_1.offsetY, this.edge3_1.offsetZ); GL11.glTranslated(this.edge3_1.rotationPointX * f5, this.edge3_1.rotationPointY * f5, this.edge3_1.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -734,7 +734,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge3_1.rotationPointX * f5, -this.edge3_1.rotationPointY * f5, -this.edge3_1.rotationPointZ * f5); this.edge3_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape7.offsetX, this.shape7.offsetY, this.shape7.offsetZ); GL11.glTranslated(this.shape7.rotationPointX * f5, this.shape7.rotationPointY * f5, this.shape7.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -742,7 +742,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape7.rotationPointX * f5, -this.shape7.rotationPointY * f5, -this.shape7.rotationPointZ * f5); this.shape7.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge1_1.offsetX, this.topedge1_1.offsetY, this.topedge1_1.offsetZ); GL11.glTranslated(this.topedge1_1.rotationPointX * f5, this.topedge1_1.rotationPointY * f5, this.topedge1_1.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -750,7 +750,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge1_1.rotationPointX * f5, -this.topedge1_1.rotationPointY * f5, -this.topedge1_1.rotationPointZ * f5); this.topedge1_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape2_1.offsetX, this.shape2_1.offsetY, this.shape2_1.offsetZ); GL11.glTranslated(this.shape2_1.rotationPointX * f5, this.shape2_1.rotationPointY * f5, this.shape2_1.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -758,7 +758,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape2_1.rotationPointX * f5, -this.shape2_1.rotationPointY * f5, -this.shape2_1.rotationPointZ * f5); this.shape2_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge2_3.offsetX, this.edge2_3.offsetY, this.edge2_3.offsetZ); GL11.glTranslated(this.edge2_3.rotationPointX * f5, this.edge2_3.rotationPointY * f5, this.edge2_3.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -766,7 +766,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge2_3.rotationPointX * f5, -this.edge2_3.rotationPointY * f5, -this.edge2_3.rotationPointZ * f5); this.edge2_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge3_2.offsetX, this.topedge3_2.offsetY, this.topedge3_2.offsetZ); GL11.glTranslated(this.topedge3_2.rotationPointX * f5, this.topedge3_2.rotationPointY * f5, this.topedge3_2.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -774,7 +774,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge3_2.rotationPointX * f5, -this.topedge3_2.rotationPointY * f5, -this.topedge3_2.rotationPointZ * f5); this.topedge3_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge1_2.offsetX, this.edge1_2.offsetY, this.edge1_2.offsetZ); GL11.glTranslated(this.edge1_2.rotationPointX * f5, this.edge1_2.rotationPointY * f5, this.edge1_2.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -782,7 +782,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge1_2.rotationPointX * f5, -this.edge1_2.rotationPointY * f5, -this.edge1_2.rotationPointZ * f5); this.edge1_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge2_2.offsetX, this.edge2_2.offsetY, this.edge2_2.offsetZ); GL11.glTranslated(this.edge2_2.rotationPointX * f5, this.edge2_2.rotationPointY * f5, this.edge2_2.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -790,7 +790,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge2_2.rotationPointX * f5, -this.edge2_2.rotationPointY * f5, -this.edge2_2.rotationPointZ * f5); this.edge2_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge2.offsetX, this.edge2.offsetY, this.edge2.offsetZ); GL11.glTranslated(this.edge2.rotationPointX * f5, this.edge2.rotationPointY * f5, this.edge2.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -798,7 +798,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge2.rotationPointX * f5, -this.edge2.rotationPointY * f5, -this.edge2.rotationPointZ * f5); this.edge2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.staffTopM.offsetX, this.staffTopM.offsetY, this.staffTopM.offsetZ); GL11.glTranslated(this.staffTopM.rotationPointX * f5, this.staffTopM.rotationPointY * f5, this.staffTopM.rotationPointZ * f5); GL11.glScaled(0.6D, 1.06D, 0.6D); @@ -806,7 +806,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.staffTopM.rotationPointX * f5, -this.staffTopM.rotationPointY * f5, -this.staffTopM.rotationPointZ * f5); this.staffTopM.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge5_1.offsetX, this.edge5_1.offsetY, this.edge5_1.offsetZ); GL11.glTranslated(this.edge5_1.rotationPointX * f5, this.edge5_1.rotationPointY * f5, this.edge5_1.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -814,7 +814,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge5_1.rotationPointX * f5, -this.edge5_1.rotationPointY * f5, -this.edge5_1.rotationPointZ * f5); this.edge5_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.staffTopQ.offsetX, this.staffTopQ.offsetY, this.staffTopQ.offsetZ); GL11.glTranslated(this.staffTopQ.rotationPointX * f5, this.staffTopQ.rotationPointY * f5, this.staffTopQ.rotationPointZ * f5); GL11.glScaled(0.7D, 1.0D, 0.7D); @@ -822,7 +822,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.staffTopQ.rotationPointX * f5, -this.staffTopQ.rotationPointY * f5, -this.staffTopQ.rotationPointZ * f5); this.staffTopQ.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge4_1.offsetX, this.edge4_1.offsetY, this.edge4_1.offsetZ); GL11.glTranslated(this.edge4_1.rotationPointX * f5, this.edge4_1.rotationPointY * f5, this.edge4_1.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -830,7 +830,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge4_1.rotationPointX * f5, -this.edge4_1.rotationPointY * f5, -this.edge4_1.rotationPointZ * f5); this.edge4_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.staffTopM_1.offsetX, this.staffTopM_1.offsetY, this.staffTopM_1.offsetZ); GL11.glTranslated(this.staffTopM_1.rotationPointX * f5, this.staffTopM_1.rotationPointY * f5, this.staffTopM_1.rotationPointZ * f5); GL11.glScaled(0.6D, 1.0D, 0.6D); @@ -838,7 +838,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.staffTopM_1.rotationPointX * f5, -this.staffTopM_1.rotationPointY * f5, -this.staffTopM_1.rotationPointZ * f5); this.staffTopM_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge3_2.offsetX, this.edge3_2.offsetY, this.edge3_2.offsetZ); GL11.glTranslated(this.edge3_2.rotationPointX * f5, this.edge3_2.rotationPointY * f5, this.edge3_2.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -846,7 +846,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge3_2.rotationPointX * f5, -this.edge3_2.rotationPointY * f5, -this.edge3_2.rotationPointZ * f5); this.edge3_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.staffTopQ_2.offsetX, this.staffTopQ_2.offsetY, this.staffTopQ_2.offsetZ); GL11.glTranslated(this.staffTopQ_2.rotationPointX * f5, this.staffTopQ_2.rotationPointY * f5, this.staffTopQ_2.rotationPointZ * f5); GL11.glScaled(0.7D, 1.0D, 0.7D); @@ -854,7 +854,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.staffTopQ_2.rotationPointX * f5, -this.staffTopQ_2.rotationPointY * f5, -this.staffTopQ_2.rotationPointZ * f5); this.staffTopQ_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.staffTopM_4.offsetX, this.staffTopM_4.offsetY, this.staffTopM_4.offsetZ); GL11.glTranslated(this.staffTopM_4.rotationPointX * f5, this.staffTopM_4.rotationPointY * f5, this.staffTopM_4.rotationPointZ * f5); GL11.glScaled(0.6D, 1.06D, 0.6D); @@ -862,7 +862,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.staffTopM_4.rotationPointX * f5, -this.staffTopM_4.rotationPointY * f5, -this.staffTopM_4.rotationPointZ * f5); this.staffTopM_4.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge3_3.offsetX, this.topedge3_3.offsetY, this.topedge3_3.offsetZ); GL11.glTranslated(this.topedge3_3.rotationPointX * f5, this.topedge3_3.rotationPointY * f5, this.topedge3_3.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -870,7 +870,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge3_3.rotationPointX * f5, -this.topedge3_3.rotationPointY * f5, -this.topedge3_3.rotationPointZ * f5); this.topedge3_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape3_2.offsetX, this.shape3_2.offsetY, this.shape3_2.offsetZ); GL11.glTranslated(this.shape3_2.rotationPointX * f5, this.shape3_2.rotationPointY * f5, this.shape3_2.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -878,7 +878,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape3_2.rotationPointX * f5, -this.shape3_2.rotationPointY * f5, -this.shape3_2.rotationPointZ * f5); this.shape3_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge1_3.offsetX, this.edge1_3.offsetY, this.edge1_3.offsetZ); GL11.glTranslated(this.edge1_3.rotationPointX * f5, this.edge1_3.rotationPointY * f5, this.edge1_3.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -886,7 +886,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge1_3.rotationPointX * f5, -this.edge1_3.rotationPointY * f5, -this.edge1_3.rotationPointZ * f5); this.edge1_3.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge2_1.offsetX, this.topedge2_1.offsetY, this.topedge2_1.offsetZ); GL11.glTranslated(this.topedge2_1.rotationPointX * f5, this.topedge2_1.rotationPointY * f5, this.topedge2_1.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -894,7 +894,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge2_1.rotationPointX * f5, -this.topedge2_1.rotationPointY * f5, -this.topedge2_1.rotationPointZ * f5); this.topedge2_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape2.offsetX, this.shape2.offsetY, this.shape2.offsetZ); GL11.glTranslated(this.shape2.rotationPointX * f5, this.shape2.rotationPointY * f5, this.shape2.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -903,7 +903,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { this.shape2.render(f5); GL11.glPopMatrix(); this.staff.render(f5); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape6.offsetX, this.shape6.offsetY, this.shape6.offsetZ); GL11.glTranslated(this.shape6.rotationPointX * f5, this.shape6.rotationPointY * f5, this.shape6.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -911,7 +911,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape6.rotationPointX * f5, -this.shape6.rotationPointY * f5, -this.shape6.rotationPointZ * f5); this.shape6.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge4.offsetX, this.edge4.offsetY, this.edge4.offsetZ); GL11.glTranslated(this.edge4.rotationPointX * f5, this.edge4.rotationPointY * f5, this.edge4.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -919,7 +919,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.edge4.rotationPointX * f5, -this.edge4.rotationPointY * f5, -this.edge4.rotationPointZ * f5); this.edge4.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.topedge1_2.offsetX, this.topedge1_2.offsetY, this.topedge1_2.offsetZ); GL11.glTranslated(this.topedge1_2.rotationPointX * f5, this.topedge1_2.rotationPointY * f5, this.topedge1_2.rotationPointZ * f5); GL11.glScaled(0.6D, 0.5D, 0.6D); @@ -927,7 +927,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.topedge1_2.rotationPointX * f5, -this.topedge1_2.rotationPointY * f5, -this.topedge1_2.rotationPointZ * f5); this.topedge1_2.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.shape4_1.offsetX, this.shape4_1.offsetY, this.shape4_1.offsetZ); GL11.glTranslated(this.shape4_1.rotationPointX * f5, this.shape4_1.rotationPointY * f5, this.shape4_1.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); @@ -935,7 +935,7 @@ public class ModelStaffOfTheGreatOne extends ModelBase { GL11.glTranslated(-this.shape4_1.rotationPointX * f5, -this.shape4_1.rotationPointY * f5, -this.shape4_1.rotationPointZ * f5); this.shape4_1.render(f5); GL11.glPopMatrix(); - GL11.glPushMatrix(); + GL11.glPushMatrix(); GL11.glTranslated(this.edge5_4.offsetX, this.edge5_4.offsetY, this.edge5_4.offsetZ); GL11.glTranslated(this.edge5_4.rotationPointX * f5, this.edge5_4.rotationPointY * f5, this.edge5_4.rotationPointZ * f5); GL11.glScaled(0.7D, 0.7D, 0.7D); diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/IRenderTweak.java b/src/main/java/com/brandon3055/draconicevolution/client/render/IRenderTweak.java index e7e0d469..4aac4bf0 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/IRenderTweak.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/IRenderTweak.java @@ -7,5 +7,5 @@ import net.minecraftforge.client.IItemRenderer.ItemRenderType; */ public interface IRenderTweak { - public void tweakRender(ItemRenderType type); + public void tweakRender(ItemRenderType type); } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderCrystal.java b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderCrystal.java index 9bc5367a..153f2f04 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderCrystal.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderCrystal.java @@ -14,56 +14,49 @@ import org.lwjgl.opengl.GL11; */ public class RenderCrystal implements IItemRenderer { - private TileEnergyRelay relay1; - private TileEnergyRelay relay2; - private TileEnergyTransceiver transceiver1; - private TileEnergyTransceiver transceiver2; - private TileWirelessEnergyTransceiver wirelessTransceiver1; - private TileWirelessEnergyTransceiver wirelessTransceiver2; + private TileEnergyRelay relay1; + private TileEnergyRelay relay2; + private TileEnergyTransceiver transceiver1; + private TileEnergyTransceiver transceiver2; + private TileWirelessEnergyTransceiver wirelessTransceiver1; + private TileWirelessEnergyTransceiver wirelessTransceiver2; - public RenderCrystal() { - relay1 = new TileEnergyRelay(0); - relay2 = new TileEnergyRelay(1); - transceiver1 = new TileEnergyTransceiver(0); - transceiver2 = new TileEnergyTransceiver(1); - wirelessTransceiver1 = new TileWirelessEnergyTransceiver(0); - wirelessTransceiver2 = new TileWirelessEnergyTransceiver(1); - transceiver1.facing = 1; - transceiver2.facing = 1; - } + public RenderCrystal() { + relay1 = new TileEnergyRelay(0); + relay2 = new TileEnergyRelay(1); + transceiver1 = new TileEnergyTransceiver(0); + transceiver2 = new TileEnergyTransceiver(1); + wirelessTransceiver1 = new TileWirelessEnergyTransceiver(0); + wirelessTransceiver2 = new TileWirelessEnergyTransceiver(1); + transceiver1.facing = 1; + transceiver2.facing = 1; + } + @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) - { - GL11.glPushMatrix(); - GL11.glScalef(1.8F, 1.8F, 1.8F); - if (type == ItemRenderType.ENTITY) - { - GL11.glTranslatef(-0.5F, 0.0F, -0.5F); - } - else if (type == ItemRenderType.EQUIPPED) - { - GL11.glRotated(45, -1, 0, 1); - if (item.getItemDamage() < 2) GL11.glTranslatef(0.0F, -0.3F, 0.0F); - else GL11.glTranslatef(0.0F, -0.6F, 0.0F); - } - int meta = item.getItemDamage(); - TileEntityRendererDispatcher.instance.renderTileEntityAt(meta == 0 ? relay1 : meta == 1 ? relay2 : meta == 2 ? transceiver1 : meta == 3 ? transceiver2 : meta == 4 ? wirelessTransceiver1 : wirelessTransceiver2, 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - RenderHelper.enableStandardItemLighting(); - } + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); + GL11.glScalef(1.8F, 1.8F, 1.8F); + if (type == ItemRenderType.ENTITY) { + GL11.glTranslatef(-0.5F, 0.0F, -0.5F); + } else if (type == ItemRenderType.EQUIPPED) { + GL11.glRotated(45, -1, 0, 1); + if (item.getItemDamage() < 2) GL11.glTranslatef(0.0F, -0.3F, 0.0F); + else GL11.glTranslatef(0.0F, -0.6F, 0.0F); + } + int meta = item.getItemDamage(); + TileEntityRendererDispatcher.instance.renderTileEntityAt(meta == 0 ? relay1 : meta == 1 ? relay2 : meta == 2 ? transceiver1 : meta == 3 ? transceiver2 : meta == 4 ? wirelessTransceiver1 : wirelessTransceiver2, 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + RenderHelper.enableStandardItemLighting(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderDraconiumChest.java b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderDraconiumChest.java index 36a3ce4f..744fdd1a 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderDraconiumChest.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderDraconiumChest.java @@ -13,36 +13,36 @@ import org.lwjgl.opengl.GL11; */ public class RenderDraconiumChest implements IItemRenderer { - ModelChest chest; + ModelChest chest; - public RenderDraconiumChest() { - chest = new ModelChest(); - } + public RenderDraconiumChest() { + chest = new ModelChest(); + } - @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) { - GL11.glPushMatrix(); + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); - TileDraconiumChest tile = new TileDraconiumChest(); - if (item.hasTagCompound() && item.getTagCompound().hasKey(ICustomItemData.tagName)) tile.readDataFromItem(item.getTagCompound().getCompoundTag(ICustomItemData.tagName), item); + TileDraconiumChest tile = new TileDraconiumChest(); + if (item.hasTagCompound() && item.getTagCompound().hasKey(ICustomItemData.tagName)) + tile.readDataFromItem(item.getTagCompound().getCompoundTag(ICustomItemData.tagName), item); - if (type == ItemRenderType.ENTITY) - { - GL11.glTranslated(-0.5D, 0, -0.5D); - } + if (type == ItemRenderType.ENTITY) { + GL11.glTranslated(-0.5D, 0, -0.5D); + } - TileEntityRendererDispatcher.instance.renderTileEntityAt(tile, 0.0D, 0.0D, 0.0D, 0.0F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(tile, 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderEnergyInfuser.java b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderEnergyInfuser.java index fae33153..e6f176ad 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderEnergyInfuser.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderEnergyInfuser.java @@ -6,33 +6,28 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; -public class RenderEnergyInfuser implements IItemRenderer -{ - private TileEnergyInfuser tile; +public class RenderEnergyInfuser implements IItemRenderer { + private TileEnergyInfuser tile; - public RenderEnergyInfuser() { - this.tile = new TileEnergyInfuser(); - this.tile.rotation = 0f; - this.tile.running = false; - } + public RenderEnergyInfuser() { + this.tile = new TileEnergyInfuser(); + this.tile.rotation = 0f; + this.tile.running = false; + } - @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) - { - if (type == ItemRenderType.ENTITY) - GL11.glTranslatef(-0.5F, 0.0F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(tile, 0.0D, 0.0D, 0.0D, 0.0F); - } + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + if (type == ItemRenderType.ENTITY) GL11.glTranslatef(-0.5F, 0.0F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(tile, 0.0D, 0.0D, 0.0D, 0.0F); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderParticleGen.java b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderParticleGen.java index 55c113a6..60a52022 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderParticleGen.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderParticleGen.java @@ -8,39 +8,33 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; -public class RenderParticleGen implements IItemRenderer -{ - private TileEntity tile; - - public RenderParticleGen() { - this.tile = new TileParticleGenerator(); - } +public class RenderParticleGen implements IItemRenderer { + private TileEntity tile; - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) - { - return true; - } + public RenderParticleGen() { + this.tile = new TileParticleGenerator(); + } - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) - { - return true; - } + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return true; + } - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) - { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - if (type == IItemRenderer.ItemRenderType.ENTITY) - GL11.glTranslatef(-0.5F, 0.0F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(tile, 0.0D, 0.0D, 0.0D, 0.0F); - RenderHelper.disableStandardItemLighting(); - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + if (type == IItemRenderer.ItemRenderType.ENTITY) GL11.glTranslatef(-0.5F, 0.0F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(tile, 0.0D, 0.0D, 0.0D, 0.0F); + RenderHelper.disableStandardItemLighting(); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } - } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderPortal.java b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderPortal.java index 1d4f26da..03192d15 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderPortal.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderPortal.java @@ -14,151 +14,151 @@ import net.minecraft.world.IBlockAccess; * Created by Brandon on 25/5/2015. */ public class RenderPortal implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { - } + } - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - Tessellator tess = Tessellator.instance; + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + Tessellator tess = Tessellator.instance; - int meta = world.getBlockMetadata(x, y, z); + int meta = world.getBlockMetadata(x, y, z); - IIcon c = Blocks.obsidian.getIcon(0, 0); - float u = c.getMinU(); - float v = c.getMinV(); - float U = c.getMaxU(); - float V = c.getMaxV(); + IIcon c = Blocks.obsidian.getIcon(0, 0); + float u = c.getMinU(); + float v = c.getMinV(); + float U = c.getMaxU(); + float V = c.getMaxV(); - tess.setColorRGBA(0, 0, 0, 256); - switch (meta){ - case 1: - tess.addVertexWithUV(x - 0.01, y - 0.01, z + 0.75, u, v); - tess.addVertexWithUV(x - 0.01, y + 1.01, z + 0.75, u, V); - tess.addVertexWithUV(x + 1.01, y + 1.01, z + 0.75, U, V); - tess.addVertexWithUV(x + 1.01, y - 0.01, z + 0.75, U, v); + tess.setColorRGBA(0, 0, 0, 256); + switch (meta) { + case 1: + tess.addVertexWithUV(x - 0.01, y - 0.01, z + 0.75, u, v); + tess.addVertexWithUV(x - 0.01, y + 1.01, z + 0.75, u, V); + tess.addVertexWithUV(x + 1.01, y + 1.01, z + 0.75, U, V); + tess.addVertexWithUV(x + 1.01, y - 0.01, z + 0.75, U, v); - tess.addVertexWithUV(x + 1.01, y - 0.01, z + 0.25, U, v); - tess.addVertexWithUV(x + 1.01, y + 1.01, z + 0.25, U, V); - tess.addVertexWithUV(x - 0.01, y + 1.01, z + 0.25, u, V); - tess.addVertexWithUV(x - 0.01, y - 0.01, z + 0.25, u, v); + tess.addVertexWithUV(x + 1.01, y - 0.01, z + 0.25, U, v); + tess.addVertexWithUV(x + 1.01, y + 1.01, z + 0.25, U, V); + tess.addVertexWithUV(x - 0.01, y + 1.01, z + 0.25, u, V); + tess.addVertexWithUV(x - 0.01, y - 0.01, z + 0.25, u, v); - if (isFrame(world, x+1, y, z)){ - tess.addVertexWithUV(x + 0.99, y - 0.01, z + 0.25, u, v); - tess.addVertexWithUV(x + 0.99, y - 0.01, z + 0.75, u, V); - tess.addVertexWithUV(x + 0.99, y + 1.01, z + 0.75, U, V); - tess.addVertexWithUV(x + 0.99, y + 1.01, z + 0.25, U, v); - } - if (isFrame(world, x-1, y, z)){ - tess.addVertexWithUV(x + 0.01, y + 1.01, z + 0.25, U, v); - tess.addVertexWithUV(x + 0.01, y + 1.01, z + 0.75, U, V); - tess.addVertexWithUV(x + 0.01, y - 0.01, z + 0.75, u, V); - tess.addVertexWithUV(x + 0.01, y - 0.01, z + 0.25, u, v); - } - if (isFrame(world, x, y-1, z)){ - tess.addVertexWithUV(x - 0.01, y + 0.01, z + 0.25, u, v); - tess.addVertexWithUV(x - 0.01, y + 0.01, z + 0.75, u, V); - tess.addVertexWithUV(x + 1.01, y + 0.01, z + 0.75, U, V); - tess.addVertexWithUV(x + 1.01, y + 0.01, z + 0.25, U, v); - } - if (isFrame(world, x, y+1, z)){ - tess.addVertexWithUV(x + 1.01, y + 0.99, z + 0.25, U, v); - tess.addVertexWithUV(x + 1.01, y + 0.99, z + 0.75, U, V); - tess.addVertexWithUV(x - 0.01, y + 0.99, z + 0.75, u, V); - tess.addVertexWithUV(x - 0.01, y + 0.99, z + 0.25, u, v); - } + if (isFrame(world, x + 1, y, z)) { + tess.addVertexWithUV(x + 0.99, y - 0.01, z + 0.25, u, v); + tess.addVertexWithUV(x + 0.99, y - 0.01, z + 0.75, u, V); + tess.addVertexWithUV(x + 0.99, y + 1.01, z + 0.75, U, V); + tess.addVertexWithUV(x + 0.99, y + 1.01, z + 0.25, U, v); + } + if (isFrame(world, x - 1, y, z)) { + tess.addVertexWithUV(x + 0.01, y + 1.01, z + 0.25, U, v); + tess.addVertexWithUV(x + 0.01, y + 1.01, z + 0.75, U, V); + tess.addVertexWithUV(x + 0.01, y - 0.01, z + 0.75, u, V); + tess.addVertexWithUV(x + 0.01, y - 0.01, z + 0.25, u, v); + } + if (isFrame(world, x, y - 1, z)) { + tess.addVertexWithUV(x - 0.01, y + 0.01, z + 0.25, u, v); + tess.addVertexWithUV(x - 0.01, y + 0.01, z + 0.75, u, V); + tess.addVertexWithUV(x + 1.01, y + 0.01, z + 0.75, U, V); + tess.addVertexWithUV(x + 1.01, y + 0.01, z + 0.25, U, v); + } + if (isFrame(world, x, y + 1, z)) { + tess.addVertexWithUV(x + 1.01, y + 0.99, z + 0.25, U, v); + tess.addVertexWithUV(x + 1.01, y + 0.99, z + 0.75, U, V); + tess.addVertexWithUV(x - 0.01, y + 0.99, z + 0.75, u, V); + tess.addVertexWithUV(x - 0.01, y + 0.99, z + 0.25, u, v); + } - break; - case 2: - tess.addVertexWithUV(x + 0.75, y - 0.01, z - 0.01, u, v); - tess.addVertexWithUV(x + 0.75, y - 0.01, z + 1.01, u, V); - tess.addVertexWithUV(x + 0.75, y + 1.01, z + 1.01, U, V); - tess.addVertexWithUV(x + 0.75, y + 1.01, z - 0.01, U, v); + break; + case 2: + tess.addVertexWithUV(x + 0.75, y - 0.01, z - 0.01, u, v); + tess.addVertexWithUV(x + 0.75, y - 0.01, z + 1.01, u, V); + tess.addVertexWithUV(x + 0.75, y + 1.01, z + 1.01, U, V); + tess.addVertexWithUV(x + 0.75, y + 1.01, z - 0.01, U, v); - tess.addVertexWithUV(x + 0.25, y + 1.01, z - 0.01, U, v); - tess.addVertexWithUV(x + 0.25, y + 1.01, z + 1.01, U, V); - tess.addVertexWithUV(x + 0.25, y - 0.01, z + 1.01, u, V); - tess.addVertexWithUV(x + 0.25, y - 0.01, z - 0.01, u, v); + tess.addVertexWithUV(x + 0.25, y + 1.01, z - 0.01, U, v); + tess.addVertexWithUV(x + 0.25, y + 1.01, z + 1.01, U, V); + tess.addVertexWithUV(x + 0.25, y - 0.01, z + 1.01, u, V); + tess.addVertexWithUV(x + 0.25, y - 0.01, z - 0.01, u, v); - if (isFrame(world, x, y, z+1)){ - tess.addVertexWithUV(x + 0.25, y - 0.01, z + 0.99, u, v); - tess.addVertexWithUV(x + 0.25, y + 1.01, z + 0.99, U, V); - tess.addVertexWithUV(x + 0.75, y + 1.01, z + 0.99, U, V); - tess.addVertexWithUV(x + 0.75, y - 0.01, z + 0.99, u, v); - } - if (isFrame(world, x, y, z-1)){ - tess.addVertexWithUV(x + 0.75, y - 0.01, z + 0.01, u, v); - tess.addVertexWithUV(x + 0.75, y + 1.01, z + 0.01, U, V); - tess.addVertexWithUV(x + 0.25, y + 1.01, z + 0.01, U, V); - tess.addVertexWithUV(x + 0.25, y - 0.01, z + 0.01, u, v); - } - if (isFrame(world, x, y-1, z)){ - tess.addVertexWithUV(x + 0.25, y + 0.01, z - 0.01, u, v); - tess.addVertexWithUV(x + 0.25, y + 0.01, z + 1.01, u, V); - tess.addVertexWithUV(x + 0.75, y + 0.01, z + 1.01, U, V); - tess.addVertexWithUV(x + 0.75, y + 0.01, z - 0.01, U, v); - } - if (isFrame(world, x, y+1, z)){ - tess.addVertexWithUV(x + 0.75, y + 0.99, z - 0.01, U, v); - tess.addVertexWithUV(x + 0.75, y + 0.99, z + 1.01, U, V); - tess.addVertexWithUV(x + 0.25, y + 0.99, z + 1.01, u, V); - tess.addVertexWithUV(x + 0.25, y + 0.99, z - 0.01, u, v); - } + if (isFrame(world, x, y, z + 1)) { + tess.addVertexWithUV(x + 0.25, y - 0.01, z + 0.99, u, v); + tess.addVertexWithUV(x + 0.25, y + 1.01, z + 0.99, U, V); + tess.addVertexWithUV(x + 0.75, y + 1.01, z + 0.99, U, V); + tess.addVertexWithUV(x + 0.75, y - 0.01, z + 0.99, u, v); + } + if (isFrame(world, x, y, z - 1)) { + tess.addVertexWithUV(x + 0.75, y - 0.01, z + 0.01, u, v); + tess.addVertexWithUV(x + 0.75, y + 1.01, z + 0.01, U, V); + tess.addVertexWithUV(x + 0.25, y + 1.01, z + 0.01, U, V); + tess.addVertexWithUV(x + 0.25, y - 0.01, z + 0.01, u, v); + } + if (isFrame(world, x, y - 1, z)) { + tess.addVertexWithUV(x + 0.25, y + 0.01, z - 0.01, u, v); + tess.addVertexWithUV(x + 0.25, y + 0.01, z + 1.01, u, V); + tess.addVertexWithUV(x + 0.75, y + 0.01, z + 1.01, U, V); + tess.addVertexWithUV(x + 0.75, y + 0.01, z - 0.01, U, v); + } + if (isFrame(world, x, y + 1, z)) { + tess.addVertexWithUV(x + 0.75, y + 0.99, z - 0.01, U, v); + tess.addVertexWithUV(x + 0.75, y + 0.99, z + 1.01, U, V); + tess.addVertexWithUV(x + 0.25, y + 0.99, z + 1.01, u, V); + tess.addVertexWithUV(x + 0.25, y + 0.99, z - 0.01, u, v); + } - break; - case 3: - tess.addVertexWithUV(x - 0.01, y + 0.25, z - 0.01, u, v); - tess.addVertexWithUV(x - 0.01, y + 0.25, z + 1.01, u, V); - tess.addVertexWithUV(x + 1.01, y + 0.25, z + 1.01, U, V); - tess.addVertexWithUV(x + 1.01, y + 0.25, z - 0.01, U, v); + break; + case 3: + tess.addVertexWithUV(x - 0.01, y + 0.25, z - 0.01, u, v); + tess.addVertexWithUV(x - 0.01, y + 0.25, z + 1.01, u, V); + tess.addVertexWithUV(x + 1.01, y + 0.25, z + 1.01, U, V); + tess.addVertexWithUV(x + 1.01, y + 0.25, z - 0.01, U, v); - tess.addVertexWithUV(x + 1.01, y + 0.75, z - 0.01, U, v); - tess.addVertexWithUV(x + 1.01, y + 0.75, z + 1.01, U, V); - tess.addVertexWithUV(x - 0.01, y + 0.75, z + 1.01, u, V); - tess.addVertexWithUV(x - 0.01, y + 0.75, z - 0.01, u, v); + tess.addVertexWithUV(x + 1.01, y + 0.75, z - 0.01, U, v); + tess.addVertexWithUV(x + 1.01, y + 0.75, z + 1.01, U, V); + tess.addVertexWithUV(x - 0.01, y + 0.75, z + 1.01, u, V); + tess.addVertexWithUV(x - 0.01, y + 0.75, z - 0.01, u, v); - if (isFrame(world, x, y, z+1)){ - tess.addVertexWithUV(x - 0.01, y + 0.25, z + 0.99, u, v); - tess.addVertexWithUV(x - 0.01, y + 0.75, z + 0.99, u, V); - tess.addVertexWithUV(x + 1.01, y + 0.75, z + 0.99, U, V); - tess.addVertexWithUV(x + 1.01, y + 0.25, z + 0.99, U, v); - } - if (isFrame(world, x, y, z-1)){ - tess.addVertexWithUV(x + 1.01, y + 0.25, z + 0.01, U, v); - tess.addVertexWithUV(x + 1.01, y + 0.75, z + 0.01, U, V); - tess.addVertexWithUV(x - 0.01, y + 0.75, z + 0.01, u, V); - tess.addVertexWithUV(x - 0.01, y + 0.25, z + 0.01, u, v); - } - if (isFrame(world, x+1, y, z)){ - tess.addVertexWithUV(x + 0.99, y + 0.25, z - 0.01, u, v); - tess.addVertexWithUV(x + 0.99, y + 0.25, z + 1.01, u, V); - tess.addVertexWithUV(x + 0.99, y + 0.75, z + 1.01, U, V); - tess.addVertexWithUV(x + 0.99, y + 0.75, z - 0.01, U, v); - } - if (isFrame(world, x-1, y, z)){ - tess.addVertexWithUV(x + 0.01, y + 0.75, z - 0.01, U, v); - tess.addVertexWithUV(x + 0.01, y + 0.75, z + 1.01, U, V); - tess.addVertexWithUV(x + 0.01, y + 0.25, z + 1.01, u, V); - tess.addVertexWithUV(x + 0.01, y + 0.25, z - 0.01, u, v); - } - } + if (isFrame(world, x, y, z + 1)) { + tess.addVertexWithUV(x - 0.01, y + 0.25, z + 0.99, u, v); + tess.addVertexWithUV(x - 0.01, y + 0.75, z + 0.99, u, V); + tess.addVertexWithUV(x + 1.01, y + 0.75, z + 0.99, U, V); + tess.addVertexWithUV(x + 1.01, y + 0.25, z + 0.99, U, v); + } + if (isFrame(world, x, y, z - 1)) { + tess.addVertexWithUV(x + 1.01, y + 0.25, z + 0.01, U, v); + tess.addVertexWithUV(x + 1.01, y + 0.75, z + 0.01, U, V); + tess.addVertexWithUV(x - 0.01, y + 0.75, z + 0.01, u, V); + tess.addVertexWithUV(x - 0.01, y + 0.25, z + 0.01, u, v); + } + if (isFrame(world, x + 1, y, z)) { + tess.addVertexWithUV(x + 0.99, y + 0.25, z - 0.01, u, v); + tess.addVertexWithUV(x + 0.99, y + 0.25, z + 1.01, u, V); + tess.addVertexWithUV(x + 0.99, y + 0.75, z + 1.01, U, V); + tess.addVertexWithUV(x + 0.99, y + 0.75, z - 0.01, U, v); + } + if (isFrame(world, x - 1, y, z)) { + tess.addVertexWithUV(x + 0.01, y + 0.75, z - 0.01, U, v); + tess.addVertexWithUV(x + 0.01, y + 0.75, z + 1.01, U, V); + tess.addVertexWithUV(x + 0.01, y + 0.25, z + 1.01, u, V); + tess.addVertexWithUV(x + 0.01, y + 0.25, z - 0.01, u, v); + } + } - return true; - } + return true; + } - @Override - public boolean shouldRender3DInInventory(int modelId) { - return false; - } + @Override + public boolean shouldRender3DInInventory(int modelId) { + return false; + } - @Override - public int getRenderId() { - return References.idPortal; - } + @Override + public int getRenderId() { + return References.idPortal; + } - private boolean isFrame(IBlockAccess access, int x, int y, int z){ - Block block = access.getBlock(x, y, z); - return block == ModBlocks.infusedObsidian || block == ModBlocks.dislocatorReceptacle; - } + private boolean isFrame(IBlockAccess access, int x, int y, int z) { + Block block = access.getBlock(x, y, z); + return block == ModBlocks.infusedObsidian || block == ModBlocks.dislocatorReceptacle; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderReactorCore.java b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderReactorCore.java index 7c3d679a..bca6a12c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderReactorCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderReactorCore.java @@ -11,30 +11,30 @@ import org.lwjgl.opengl.GL11; */ public class RenderReactorCore implements IItemRenderer { - @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) { - GL11.glPushMatrix(); + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); - if (type == ItemRenderType.INVENTORY) GL11.glRotated(180, 0, 1, 0); - else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { - GL11.glTranslated(0.5, 0.5, 0.5); - if (type == ItemRenderType.EQUIPPED)GL11.glRotated(90, 0, 1, 0); - } + if (type == ItemRenderType.INVENTORY) GL11.glRotated(180, 0, 1, 0); + else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glTranslated(0.5, 0.5, 0.5); + if (type == ItemRenderType.EQUIPPED) GL11.glRotated(90, 0, 1, 0); + } - ResourceHandler.bindResource("textures/blocks/draconic_block_blank.png"); - GL11.glScaled(0.5, 0.5, 0.5); - RenderTileReactorCore.reactorModel.renderAll(); + ResourceHandler.bindResource("textures/blocks/draconic_block_blank.png"); + GL11.glScaled(0.5, 0.5, 0.5); + RenderTileReactorCore.reactorModel.renderAll(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderReactorEnergyInjector.java b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderReactorEnergyInjector.java index efd728e5..32cfe345 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderReactorEnergyInjector.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderReactorEnergyInjector.java @@ -11,30 +11,30 @@ import org.lwjgl.opengl.GL11; */ public class RenderReactorEnergyInjector implements IItemRenderer { - @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) { - GL11.glPushMatrix(); - float scale = (1F / 16F); + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); + float scale = (1F / 16F); - if (type == ItemRenderType.INVENTORY) GL11.glRotated(180, 0, 1, 0); - else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { - GL11.glTranslated(0.5, 0.5, 0.5); - GL11.glRotated(90, 0, 1, 0); - } - GL11.glRotated(180, 0, 0, 1); + if (type == ItemRenderType.INVENTORY) GL11.glRotated(180, 0, 1, 0); + else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glTranslated(0.5, 0.5, 0.5); + GL11.glRotated(90, 0, 1, 0); + } + GL11.glRotated(180, 0, 0, 1); - ResourceHandler.bindResource("textures/models/ModelReactorPowerInjector.png"); - RenderTileReactorEnergyInjector.modelReactorEnergyInjector.render(null, 1F, 0F, 0F, 0F, 0F, scale); - GL11.glPopMatrix(); - } + ResourceHandler.bindResource("textures/models/ModelReactorPowerInjector.png"); + RenderTileReactorEnergyInjector.modelReactorEnergyInjector.render(null, 1F, 0F, 0F, 0F, 0F, scale); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderReactorStabilizer.java b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderReactorStabilizer.java index 328ac2ce..5373cae2 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderReactorStabilizer.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderReactorStabilizer.java @@ -11,35 +11,35 @@ import org.lwjgl.opengl.GL11; */ public class RenderReactorStabilizer implements IItemRenderer { - @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) { - GL11.glPushMatrix(); - float scale = (1F / 16F); + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); + float scale = (1F / 16F); - if (type == ItemRenderType.INVENTORY) GL11.glRotated(180, 0, 1, 0); - else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { - GL11.glTranslated(0.5, 0.5, 0.5); - if (type == ItemRenderType.EQUIPPED)GL11.glRotated(90, 0, 1, 0); - } + if (type == ItemRenderType.INVENTORY) GL11.glRotated(180, 0, 1, 0); + else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glTranslated(0.5, 0.5, 0.5); + if (type == ItemRenderType.EQUIPPED) GL11.glRotated(90, 0, 1, 0); + } - ResourceHandler.bindResource("textures/models/reactorStabilizerCore.png"); - RenderTileReactorStabilizer.modelStabilizerCore.render(null, 0F, 1F, 0F, 0F, 0F, scale); + ResourceHandler.bindResource("textures/models/reactorStabilizerCore.png"); + RenderTileReactorStabilizer.modelStabilizerCore.render(null, 0F, 1F, 0F, 0F, 0F, scale); - ResourceHandler.bindResource("textures/models/reactorStabilizerRing.png"); - GL11.glRotated(90, 1, 0, 0); - GL11.glTranslated(0, -0.58, 0); - GL11.glScaled(0.95, 0.95, 0.95); - RenderTileReactorStabilizer.modelStabilizerRing.render(null, -70F, 1F, 0F, 0F, 0F, scale); - GL11.glPopMatrix(); - } + ResourceHandler.bindResource("textures/models/reactorStabilizerRing.png"); + GL11.glRotated(90, 1, 0, 0); + GL11.glTranslated(0, -0.58, 0); + GL11.glScaled(0.95, 0.95, 0.95); + RenderTileReactorStabilizer.modelStabilizerRing.render(null, -70F, 1F, 0F, 0F, 0F, scale); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderTeleporterStand.java b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderTeleporterStand.java index b6945eaf..31859777 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderTeleporterStand.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderTeleporterStand.java @@ -14,27 +14,27 @@ import org.lwjgl.opengl.GL11; */ public class RenderTeleporterStand implements ISimpleBlockRenderingHandler { - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileTeleporterStand(), 0.0D, 0.0D, 0.0D, 0.0F); - GL11.glPopMatrix(); - } + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileTeleporterStand(), 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopMatrix(); + } - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return false; - } + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + return false; + } - @Override - public boolean shouldRender3DInInventory(int modelId) { - return true; - } + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } - @Override - public int getRenderId() { - return References.idTeleporterStand; - } + @Override + public int getRenderId() { + return References.idTeleporterStand; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderUpgradeModifier.java b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderUpgradeModifier.java index 3d574b77..1f0c3feb 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderUpgradeModifier.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderUpgradeModifier.java @@ -6,32 +6,27 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; -public class RenderUpgradeModifier implements IItemRenderer -{ - private TileUpgradeModifier tile; +public class RenderUpgradeModifier implements IItemRenderer { + private TileUpgradeModifier tile; - public RenderUpgradeModifier() { - this.tile = new TileUpgradeModifier(); - this.tile.rotation = 0f; - } + public RenderUpgradeModifier() { + this.tile = new TileUpgradeModifier(); + this.tile.rotation = 0f; + } - @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) - { - if (type == ItemRenderType.ENTITY) - GL11.glTranslatef(-0.5F, 0.0F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(tile, 0.0D, 0.0D, 0.0D, 0.0F); - } + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + if (type == ItemRenderType.ENTITY) GL11.glTranslatef(-0.5F, 0.0F, -0.5F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(tile, 0.0D, 0.0D, 0.0D, 0.0F); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/entity/RenderChaosCrystal.java b/src/main/java/com/brandon3055/draconicevolution/client/render/entity/RenderChaosCrystal.java index 26c2c0ef..89846cbd 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/entity/RenderChaosCrystal.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/entity/RenderChaosCrystal.java @@ -17,93 +17,91 @@ import org.lwjgl.opengl.GL11; * Created by brandon3055 on 30/8/2015. */ public class RenderChaosCrystal extends Render { - private ModelBase model; + private ModelBase model; - public RenderChaosCrystal() { - this.shadowSize = 0.5F; - this.model = new ModelChaosCrystal(true); - } + public RenderChaosCrystal() { + this.shadowSize = 0.5F; + this.model = new ModelChaosCrystal(true); + } - public void doRender(EntityChaosCrystal crystal, double x, double y, double z, float f, float partialTick) { - float rotation = (float)crystal.innerRotation + (crystal.health > 0 ? partialTick : 0); - GL11.glPushMatrix(); - GL11.glTranslated(x, y, z); - ResourceHandler.bindResource("textures/entity/chaosCrystal.png"); - float r2 = MathHelper.sin(rotation * 0.2F) / 2.0F + 0.5F; - r2 += r2 * r2; - this.model.render(crystal, 0.0F, rotation * 3.0F, r2 * 0.2F, crystal.deathAnimation, crystal.health, 0.0625F); + public void doRender(EntityChaosCrystal crystal, double x, double y, double z, float f, float partialTick) { + float rotation = (float) crystal.innerRotation + (crystal.health > 0 ? partialTick : 0); + GL11.glPushMatrix(); + GL11.glTranslated(x, y, z); + ResourceHandler.bindResource("textures/entity/chaosCrystal.png"); + float r2 = MathHelper.sin(rotation * 0.2F) / 2.0F + 0.5F; + r2 += r2 * r2; + this.model.render(crystal, 0.0F, rotation * 3.0F, r2 * 0.2F, crystal.deathAnimation, crystal.health, 0.0625F); - GL11.glPopMatrix(); + GL11.glPopMatrix(); - if (crystal.shieldTime > 0) - { - GL11.glPushMatrix(); - GL11.glTranslated(-0.5, -1.5, -0.5); - Tessellator tessellator = Tessellator.instance; - ResourceHandler.bindTexture(ResourceHandler.getResourceWOP("textures/entity/beacon_beam.png")); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDepthMask(true); - OpenGlHelper.glBlendFunc(770, 1, 1, 0); - float f2 = (float) crystal.ticksExisted + partialTick; - float f3 = -f2 * 0.2F - (float) MathHelper.floor_float(-f2 * 0.1F); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glDepthMask(false); - tessellator.startDrawingQuads(); - tessellator.setColorRGBA(200, 0, 0, 32); - double size = 0.39F; - double d30 = 0.2D - size; - double d4 = 0.2D - size; - double d6 = 0.8D + size; - double d8 = 0.2D - size; - double d10 = 0.2D - size; - double d12 = 0.8D + size; - double d14 = 0.8D + size; - double d16 = 0.8D + size; - double d18 = (double) (256.0F); - double d20 = 0.0D; - double d22 = 1.0D; - double d24 = (double) (-1.0F + f3); - double d26 = (double) (256.0F) + d24; - tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d22, d26); - tessellator.addVertexWithUV(x + d30, y, z + d4, d22, d24); - tessellator.addVertexWithUV(x + d6, y, z + d8, d20, d24); - tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d20, d26); - tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d22, d26); - tessellator.addVertexWithUV(x + d14, y, z + d16, d22, d24); - tessellator.addVertexWithUV(x + d10, y, z + d12, d20, d24); - tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d20, d26); - tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d22, d26); - tessellator.addVertexWithUV(x + d6, y, z + d8, d22, d24); - tessellator.addVertexWithUV(x + d14, y, z + d16, d20, d24); - tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d20, d26); - tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d22, d26); - tessellator.addVertexWithUV(x + d10, y, z + d12, d22, d24); - tessellator.addVertexWithUV(x + d30, y, z + d4, d20, d24); - tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d20, d26); - tessellator.draw(); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDepthMask(true); - GL11.glPopMatrix(); - } - } + if (crystal.shieldTime > 0) { + GL11.glPushMatrix(); + GL11.glTranslated(-0.5, -1.5, -0.5); + Tessellator tessellator = Tessellator.instance; + ResourceHandler.bindTexture(ResourceHandler.getResourceWOP("textures/entity/beacon_beam.png")); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + OpenGlHelper.glBlendFunc(770, 1, 1, 0); + float f2 = (float) crystal.ticksExisted + partialTick; + float f3 = -f2 * 0.2F - (float) MathHelper.floor_float(-f2 * 0.1F); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glDepthMask(false); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA(200, 0, 0, 32); + double size = 0.39F; + double d30 = 0.2D - size; + double d4 = 0.2D - size; + double d6 = 0.8D + size; + double d8 = 0.2D - size; + double d10 = 0.2D - size; + double d12 = 0.8D + size; + double d14 = 0.8D + size; + double d16 = 0.8D + size; + double d18 = (double) (256.0F); + double d20 = 0.0D; + double d22 = 1.0D; + double d24 = (double) (-1.0F + f3); + double d26 = (double) (256.0F) + d24; + tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d22, d26); + tessellator.addVertexWithUV(x + d30, y, z + d4, d22, d24); + tessellator.addVertexWithUV(x + d6, y, z + d8, d20, d24); + tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d20, d26); + tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d22, d26); + tessellator.addVertexWithUV(x + d14, y, z + d16, d22, d24); + tessellator.addVertexWithUV(x + d10, y, z + d12, d20, d24); + tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d20, d26); + tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d22, d26); + tessellator.addVertexWithUV(x + d6, y, z + d8, d22, d24); + tessellator.addVertexWithUV(x + d14, y, z + d16, d20, d24); + tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d20, d26); + tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d22, d26); + tessellator.addVertexWithUV(x + d10, y, z + d12, d22, d24); + tessellator.addVertexWithUV(x + d30, y, z + d4, d20, d24); + tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d20, d26); + tessellator.draw(); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + GL11.glPopMatrix(); + } + } - protected ResourceLocation getEntityTexture(EntityEnderCrystal p_110775_1_) - { - return ResourceHandler.getResource("textures/entity/chaosCrystal.png"); - } + protected ResourceLocation getEntityTexture(EntityEnderCrystal p_110775_1_) { + return ResourceHandler.getResource("textures/entity/chaosCrystal.png"); + } - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return this.getEntityTexture((EntityChaosCrystal)p_110775_1_); - } + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return this.getEntityTexture((EntityChaosCrystal) p_110775_1_); + } - public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { - this.doRender((EntityChaosCrystal)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); - } + public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { + this.doRender((EntityChaosCrystal) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/entity/RenderChaosDrill.java b/src/main/java/com/brandon3055/draconicevolution/client/render/entity/RenderChaosDrill.java index 2094ec59..0cb0e532 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/entity/RenderChaosDrill.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/entity/RenderChaosDrill.java @@ -12,13 +12,13 @@ import net.minecraft.util.ResourceLocation; @SideOnly(Side.CLIENT) public class RenderChaosDrill extends Render { - @Override - public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) { + @Override + public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) { - } + } - @Override - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return null; - } + @Override + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return null; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/entity/RenderDragon.java b/src/main/java/com/brandon3055/draconicevolution/client/render/entity/RenderDragon.java index df6c97c6..544f9423 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/entity/RenderDragon.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/entity/RenderDragon.java @@ -24,172 +24,161 @@ import java.util.Random; * Created by Brandon on 11/08/2014. */ @SideOnly(Side.CLIENT) -public class RenderDragon extends RenderLiving -{ - private static final ResourceLocation enderDragonExplodingTextures = new ResourceLocation("textures/entity/enderdragon/dragon_exploding.png"); - private static final ResourceLocation enderDragonCrystalBeamTextures = new ResourceLocation("textures/entity/endercrystal/endercrystal_beam.png"); - private static final ResourceLocation enderDragonEyesTextures = new ResourceLocation("textures/entity/enderdragon/dragon_eyes.png"); - private static final ResourceLocation enderDragonTextures = new ResourceLocation(References.RESOURCESPREFIX + "textures/entity/de_dragon.png"); - private static final ResourceLocation enderDragonTextures2 = new ResourceLocation(References.RESOURCESPREFIX + "textures/entity/de_chaos_dragon.png"); - /** An instance of the dragon model in RenderDragon */ - protected ModelDragon modelDragon; +public class RenderDragon extends RenderLiving { + private static final ResourceLocation enderDragonExplodingTextures = new ResourceLocation("textures/entity/enderdragon/dragon_exploding.png"); + private static final ResourceLocation enderDragonCrystalBeamTextures = new ResourceLocation("textures/entity/endercrystal/endercrystal_beam.png"); + private static final ResourceLocation enderDragonEyesTextures = new ResourceLocation("textures/entity/enderdragon/dragon_eyes.png"); + private static final ResourceLocation enderDragonTextures = new ResourceLocation(References.RESOURCESPREFIX + "textures/entity/de_dragon.png"); + private static final ResourceLocation enderDragonTextures2 = new ResourceLocation(References.RESOURCESPREFIX + "textures/entity/de_chaos_dragon.png"); + /** + * An instance of the dragon model in RenderDragon + */ + protected ModelDragon modelDragon; - public RenderDragon() - { - super(new ModelDragon(0.0F), 0.5F); - this.modelDragon = (ModelDragon)this.mainModel; - this.setRenderPassModel(this.mainModel); - } + public RenderDragon() { + super(new ModelDragon(0.0F), 0.5F); + this.modelDragon = (ModelDragon) this.mainModel; + this.setRenderPassModel(this.mainModel); + } - protected void rotateCorpse(EntityDragon p_77043_1_, float p_77043_2_, float p_77043_3_, float p_77043_4_) - { - float f3 = (float)p_77043_1_.getMovementOffsets(7, p_77043_4_)[0]; - float f4 = (float)(p_77043_1_.getMovementOffsets(5, p_77043_4_)[1] - p_77043_1_.getMovementOffsets(10, p_77043_4_)[1]); - GL11.glRotatef(-f3, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(f4 * 10.0F, 1.0F, 0.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.0F, 1.0F); + protected void rotateCorpse(EntityDragon p_77043_1_, float p_77043_2_, float p_77043_3_, float p_77043_4_) { + float f3 = (float) p_77043_1_.getMovementOffsets(7, p_77043_4_)[0]; + float f4 = (float) (p_77043_1_.getMovementOffsets(5, p_77043_4_)[1] - p_77043_1_.getMovementOffsets(10, p_77043_4_)[1]); + GL11.glRotatef(-f3, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(f4 * 10.0F, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.0F, 1.0F); - if (p_77043_1_.deathTime > 0) - { - float f5 = ((float)p_77043_1_.deathTime + p_77043_4_ - 1.0F) / 20.0F * 1.6F; - f5 = MathHelper.sqrt_float(f5); + if (p_77043_1_.deathTime > 0) { + float f5 = ((float) p_77043_1_.deathTime + p_77043_4_ - 1.0F) / 20.0F * 1.6F; + f5 = MathHelper.sqrt_float(f5); - if (f5 > 1.0F) - { - f5 = 1.0F; - } + if (f5 > 1.0F) { + f5 = 1.0F; + } - GL11.glRotatef(f5 * this.getDeathMaxRotation(p_77043_1_), 0.0F, 0.0F, 1.0F); - } - } + GL11.glRotatef(f5 * this.getDeathMaxRotation(p_77043_1_), 0.0F, 0.0F, 1.0F); + } + } - /** - * Renders the model in RenderLiving - */ - protected void renderModel(EntityDragon p_77036_1_, float p_77036_2_, float p_77036_3_, float p_77036_4_, float p_77036_5_, float p_77036_6_, float p_77036_7_) - { - if (p_77036_1_.deathTicks > 0) - { - float f6 = (float)p_77036_1_.deathTicks / 200.0F; - GL11.glDepthFunc(GL11.GL_LEQUAL); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glAlphaFunc(GL11.GL_GREATER, f6); - this.bindTexture(enderDragonExplodingTextures); - this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); - GL11.glDepthFunc(GL11.GL_EQUAL); - } + /** + * Renders the model in RenderLiving + */ + protected void renderModel(EntityDragon p_77036_1_, float p_77036_2_, float p_77036_3_, float p_77036_4_, float p_77036_5_, float p_77036_6_, float p_77036_7_) { + if (p_77036_1_.deathTicks > 0) { + float f6 = (float) p_77036_1_.deathTicks / 200.0F; + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glAlphaFunc(GL11.GL_GREATER, f6); + this.bindTexture(enderDragonExplodingTextures); + this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glDepthFunc(GL11.GL_EQUAL); + } - this.bindEntityTexture(p_77036_1_); - this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); + this.bindEntityTexture(p_77036_1_); + this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); - if (p_77036_1_.hurtTime > 0) - { - GL11.glDepthFunc(GL11.GL_EQUAL); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1.0F, 0.0F, 0.0F, 0.5F); - this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDepthFunc(GL11.GL_LEQUAL); - } - } + if (p_77036_1_.hurtTime > 0) { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1.0F, 0.0F, 0.0F, 0.5F); + this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + } - /** - * 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){ + tessellator.draw(); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glShadeModel(GL11.GL_FLAT); + RenderHelper.enableStandardItemLighting(); + GL11.glPopMatrix(); + } else if (dragon instanceof EntityChaosGuardian && ((EntityChaosGuardian) dragon).crystalY > 0) { - float f2 = ((EntityChaosGuardian) dragon).healingChaosCrystal != null ? (float)((EntityChaosGuardian) dragon).healingChaosCrystal.innerRotation + p_76986_9_ : 0; - float f3 = MathHelper.sin(f2 * 0.2F) / 2.0F + 0.5F; - f3 = (f3 * f3 + f3) * 0.2F; - float f4 = (float)(((EntityChaosGuardian) dragon).crystalX+0.5 - dragon.posX - (dragon.prevPosX - dragon.posX) * (double)(1.0F - p_76986_9_)); - float f5 = (float)((double)f3 + ((EntityChaosGuardian) dragon).crystalY+0.5 - 1.0D - dragon.posY - (dragon.prevPosY - dragon.posY) * (double)(1.0F - p_76986_9_)); - float f6 = (float)(((EntityChaosGuardian) dragon).crystalZ+0.5 - dragon.posZ - (dragon.prevPosZ - dragon.posZ) * (double)(1.0F - p_76986_9_)); - float f7 = MathHelper.sqrt_float(f4 * f4 + f6 * f6); - float f8 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6); - GL11.glPushMatrix(); - GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_ + 2.0F, (float)p_76986_6_); - GL11.glRotatef((float)(-Math.atan2((double)f6, (double)f4)) * 180.0F / (float)Math.PI - 90.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef((float)(-Math.atan2((double)f7, (double)f5)) * 180.0F / (float)Math.PI - 90.0F, 1.0F, 0.0F, 0.0F); - Tessellator tessellator = Tessellator.instance; - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL11.GL_CULL_FACE); - this.bindTexture(enderDragonCrystalBeamTextures); - GL11.glShadeModel(GL11.GL_SMOOTH); - float f9 = 0.0F - ((float)dragon.ticksExisted + p_76986_9_) * 0.01F; - float f10 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6) / 32.0F - ((float)dragon.ticksExisted + p_76986_9_) * 0.01F; - tessellator.startDrawing(5); - byte b0 = 8; + float f2 = ((EntityChaosGuardian) dragon).healingChaosCrystal != null ? (float) ((EntityChaosGuardian) dragon).healingChaosCrystal.innerRotation + p_76986_9_ : 0; + float f3 = MathHelper.sin(f2 * 0.2F) / 2.0F + 0.5F; + f3 = (f3 * f3 + f3) * 0.2F; + float f4 = (float) (((EntityChaosGuardian) dragon).crystalX + 0.5 - dragon.posX - (dragon.prevPosX - dragon.posX) * (double) (1.0F - p_76986_9_)); + float f5 = (float) ((double) f3 + ((EntityChaosGuardian) dragon).crystalY + 0.5 - 1.0D - dragon.posY - (dragon.prevPosY - dragon.posY) * (double) (1.0F - p_76986_9_)); + float f6 = (float) (((EntityChaosGuardian) dragon).crystalZ + 0.5 - dragon.posZ - (dragon.prevPosZ - dragon.posZ) * (double) (1.0F - p_76986_9_)); + float f7 = MathHelper.sqrt_float(f4 * f4 + f6 * f6); + float f8 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6); + GL11.glPushMatrix(); + GL11.glTranslatef((float) p_76986_2_, (float) p_76986_4_ + 2.0F, (float) p_76986_6_); + GL11.glRotatef((float) (-Math.atan2((double) f6, (double) f4)) * 180.0F / (float) Math.PI - 90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef((float) (-Math.atan2((double) f7, (double) f5)) * 180.0F / (float) Math.PI - 90.0F, 1.0F, 0.0F, 0.0F); + Tessellator tessellator = Tessellator.instance; + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_CULL_FACE); + this.bindTexture(enderDragonCrystalBeamTextures); + GL11.glShadeModel(GL11.GL_SMOOTH); + float f9 = 0.0F - ((float) dragon.ticksExisted + p_76986_9_) * 0.01F; + float f10 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6) / 32.0F - ((float) dragon.ticksExisted + p_76986_9_) * 0.01F; + tessellator.startDrawing(5); + byte b0 = 8; - for (int i = 0; i <= b0; ++i) - { - float f11 = MathHelper.sin((float)(i % b0) * (float)Math.PI * 2.0F / (float)b0) * 0.75F; - float f12 = MathHelper.cos((float)(i % b0) * (float)Math.PI * 2.0F / (float)b0) * 0.75F; - float f13 = (float)(i % b0) * 1.0F / (float)b0; - tessellator.setColorOpaque_I(0); - tessellator.addVertexWithUV((double)(f11 * 0.2F), (double)(f12 * 0.2F), 0.0D, (double)f13, (double)f10); - tessellator.setColorOpaque_I(0xFF0000); - tessellator.addVertexWithUV((double)f11, (double)f12, (double)f8, (double)f13, (double)f9); - } + for (int i = 0; i <= b0; ++i) { + float f11 = MathHelper.sin((float) (i % b0) * (float) Math.PI * 2.0F / (float) b0) * 0.75F; + float f12 = MathHelper.cos((float) (i % b0) * (float) Math.PI * 2.0F / (float) b0) * 0.75F; + float f13 = (float) (i % b0) * 1.0F / (float) b0; + tessellator.setColorOpaque_I(0); + tessellator.addVertexWithUV((double) (f11 * 0.2F), (double) (f12 * 0.2F), 0.0D, (double) f13, (double) f10); + tessellator.setColorOpaque_I(0xFF0000); + tessellator.addVertexWithUV((double) f11, (double) f12, (double) f8, (double) f13, (double) f9); + } - tessellator.draw(); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glShadeModel(GL11.GL_FLAT); - RenderHelper.enableStandardItemLighting(); - GL11.glPopMatrix(); - } + tessellator.draw(); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glShadeModel(GL11.GL_FLAT); + RenderHelper.enableStandardItemLighting(); + GL11.glPopMatrix(); + } // } else if (dragon instanceof EntityChaosGuardian && ((EntityChaosGuardian) dragon).healingChaosCrystal != null){ // // @@ -232,175 +221,157 @@ public class RenderDragon extends RenderLiving // RenderHelper.enableStandardItemLighting(); // GL11.glPopMatrix(); // } - } + } - /** - * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. - */ - protected ResourceLocation getEntityTexture(EntityDragon dragon) - { - return dragon instanceof EntityChaosGuardian ? enderDragonTextures2 : enderDragonTextures; - } + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(EntityDragon dragon) { + return dragon instanceof EntityChaosGuardian ? enderDragonTextures2 : enderDragonTextures; + } - protected void renderEquippedItems(EntityDragon dragon, float p_77029_2_) - { - super.renderEquippedItems(dragon, p_77029_2_); - Tessellator tessellator = Tessellator.instance; + protected void renderEquippedItems(EntityDragon dragon, float p_77029_2_) { + super.renderEquippedItems(dragon, p_77029_2_); + Tessellator tessellator = Tessellator.instance; - if (dragon.deathTicks > 0) - { - RenderHelper.disableStandardItemLighting(); - float f1 = ((float)dragon.deathTicks + p_77029_2_) / 200.0F; - float f2 = 0.0F; + if (dragon.deathTicks > 0) { + RenderHelper.disableStandardItemLighting(); + float f1 = ((float) dragon.deathTicks + p_77029_2_) / 200.0F; + float f2 = 0.0F; - if (f1 > 0.8F) - { - f2 = (f1 - 0.8F) / 0.2F; - } + if (f1 > 0.8F) { + f2 = (f1 - 0.8F) / 0.2F; + } - if (dragon instanceof EntityChaosGuardian) f2 = 0; + if (dragon instanceof EntityChaosGuardian) f2 = 0; - Random random = new Random(1L); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glShadeModel(GL11.GL_SMOOTH); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glDepthMask(false); - GL11.glPushMatrix(); - GL11.glTranslatef(0.0F, -1.0F, -2.0F); + Random random = new Random(1L); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDepthMask(false); + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, -1.0F, -2.0F); - for (int i = 0; (float)i < (f1 + f1 * f1) / 2.0F * 60.0F; ++i) - { - GL11.glRotatef(random.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(random.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(random.nextFloat() * 360.0F + f1 * 90.0F, 0.0F, 0.0F, 1.0F); - tessellator.startDrawing(6); - float f3 = random.nextFloat() * 20.0F + 5.0F + f2 * 10.0F; - float f4 = random.nextFloat() * 2.0F + 1.0F + f2 * 2.0F; - tessellator.setColorRGBA_I(16777215, (int)(255.0F * (1.0F - f2))); - tessellator.addVertex(0.0D, 0.0D, 0.0D); - tessellator.setColorRGBA_I(16711935, 0); - tessellator.addVertex(-0.866D * (double)f4, (double)f3, (double)(-0.5F * f4)); - tessellator.addVertex(0.866D * (double)f4, (double)f3, (double)(-0.5F * f4)); - tessellator.addVertex(0.0D, (double)f3, (double)(1.0F * f4)); - tessellator.addVertex(-0.866D * (double)f4, (double)f3, (double)(-0.5F * f4)); - tessellator.draw(); - } + for (int i = 0; (float) i < (f1 + f1 * f1) / 2.0F * 60.0F; ++i) { + GL11.glRotatef(random.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(random.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(random.nextFloat() * 360.0F + f1 * 90.0F, 0.0F, 0.0F, 1.0F); + tessellator.startDrawing(6); + float f3 = random.nextFloat() * 20.0F + 5.0F + f2 * 10.0F; + float f4 = random.nextFloat() * 2.0F + 1.0F + f2 * 2.0F; + tessellator.setColorRGBA_I(16777215, (int) (255.0F * (1.0F - f2))); + tessellator.addVertex(0.0D, 0.0D, 0.0D); + tessellator.setColorRGBA_I(16711935, 0); + tessellator.addVertex(-0.866D * (double) f4, (double) f3, (double) (-0.5F * f4)); + tessellator.addVertex(0.866D * (double) f4, (double) f3, (double) (-0.5F * f4)); + tessellator.addVertex(0.0D, (double) f3, (double) (1.0F * f4)); + tessellator.addVertex(-0.866D * (double) f4, (double) f3, (double) (-0.5F * f4)); + tessellator.draw(); + } - GL11.glPopMatrix(); - GL11.glDepthMask(true); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_BLEND); - GL11.glShadeModel(GL11.GL_FLAT); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_ALPHA_TEST); - RenderHelper.enableStandardItemLighting(); - } - } + GL11.glPopMatrix(); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_ALPHA_TEST); + RenderHelper.enableStandardItemLighting(); + } + } - /** - * Queries whether should renderBackground the specified pass or not. - */ - protected int shouldRenderPass(EntityDragon p_77032_1_, int p_77032_2_, float p_77032_3_) - { - if (p_77032_2_ == 1) - { - GL11.glDepthFunc(GL11.GL_LEQUAL); - } + /** + * Queries whether should renderBackground the specified pass or not. + */ + protected int shouldRenderPass(EntityDragon p_77032_1_, int p_77032_2_, float p_77032_3_) { + if (p_77032_2_ == 1) { + GL11.glDepthFunc(GL11.GL_LEQUAL); + } - if (p_77032_2_ != 0) - { - return -1; - } - else - { - this.bindTexture(enderDragonEyesTextures); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDepthFunc(GL11.GL_EQUAL); - char c0 = 61680; - int j = c0 % 65536; - int k = c0 / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - return 1; - } - } + if (p_77032_2_ != 0) { + return -1; + } else { + this.bindTexture(enderDragonEyesTextures); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_EQUAL); + char c0 = 61680; + int j = c0 % 65536; + int k = c0 / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + return 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.5F) scale = 0.5F; + float scale = ((float) entity.ticksExisted - 100F) + tick; + scale /= 500F; + if (scale > 0.5F) scale = 0.5F; - GL11.glScaled(scale, scale, scale); - uvSphere.renderAll(); + GL11.glScaled(scale, scale, scale); + uvSphere.renderAll(); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - @Override - public void doRender(Entity entity, double x, double y, double z, float f1, float f2) { - doRender((EntityChaosVortex)entity, x, y, z, f1, f2); - } + @Override + public void doRender(Entity entity, double x, double y, double z, float f1, float f2) { + doRender((EntityChaosVortex) entity, x, y, z, f1, f2); + } - @Override - protected ResourceLocation getEntityTexture(Entity entity) { - return null; - } + @Override + protected ResourceLocation getEntityTexture(Entity entity) { + return null; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/entity/RenderEntityCustomArrow.java b/src/main/java/com/brandon3055/draconicevolution/client/render/entity/RenderEntityCustomArrow.java index d0afa629..d841f05d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/entity/RenderEntityCustomArrow.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/entity/RenderEntityCustomArrow.java @@ -14,85 +14,74 @@ import org.lwjgl.opengl.GL12; /** * Created by brandon3055 on 3/3/2016. */ -public class RenderEntityCustomArrow extends Render -{ - private IModelCustom arrow = AdvancedModelLoader.loadModel(ResourceHandler.getResource("models/tools/ArrowCommon.obj")); +public class RenderEntityCustomArrow extends Render { + private IModelCustom arrow = AdvancedModelLoader.loadModel(ResourceHandler.getResource("models/tools/ArrowCommon.obj")); - public void doRender(EntityCustomArrow entityArrow, double x, double y, double z, float f1, float f2) - { - this.bindEntityTexture(entityArrow); - GL11.glPushMatrix(); - GL11.glTranslatef((float)x, (float)y, (float)z); - GL11.glRotatef(entityArrow.prevRotationYaw + (entityArrow.rotationYaw - entityArrow.prevRotationYaw) * f2 - 90.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(entityArrow.prevRotationPitch + (entityArrow.rotationPitch - entityArrow.prevRotationPitch) * f2, 0.0F, 0.0F, 1.0F); + public void doRender(EntityCustomArrow entityArrow, double x, double y, double z, float f1, float f2) { + this.bindEntityTexture(entityArrow); + GL11.glPushMatrix(); + GL11.glTranslatef((float) x, (float) y, (float) z); + GL11.glRotatef(entityArrow.prevRotationYaw + (entityArrow.rotationYaw - entityArrow.prevRotationYaw) * f2 - 90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(entityArrow.prevRotationPitch + (entityArrow.rotationPitch - entityArrow.prevRotationPitch) * f2, 0.0F, 0.0F, 1.0F); - float f10 = 0.3F; - float f11 = (float)entityArrow.arrowShake - f2; + float f10 = 0.3F; + float f11 = (float) entityArrow.arrowShake - f2; - if (f11 > 0.0F) - { - float f12 = -MathHelper.sin(f11 * 3.0F) * f11; - GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F); - } + if (f11 > 0.0F) { + float f12 = -MathHelper.sin(f11 * 3.0F) * f11; + GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F); + } - GL11.glRotatef(90.0F, 0.0F, -1.0F, 0.0F); - GL11.glScalef(f10, f10, f10); - GL11.glEnable(GL11.GL_BLEND); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glRotatef(90.0F, 0.0F, -1.0F, 0.0F); + GL11.glScalef(f10, f10, f10); + GL11.glEnable(GL11.GL_BLEND); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + //arrow.renderAll(); + if (entityArrow.bowProperties != null && entityArrow.bowProperties.energyBolt) { + arrow.renderAll(); - //arrow.renderAll(); - if (entityArrow.bowProperties != null && entityArrow.bowProperties.energyBolt) - { - arrow.renderAll(); + GL11.glTranslated(0, -0.025, 0); + GL11.glColor4f(1F, 1F, 1F, 0.6F); + GL11.glScaled(1.05, 1.05, 1.05); - GL11.glTranslated(0, -0.025, 0); - GL11.glColor4f(1F, 1F, 1F, 0.6F); - GL11.glScaled(1.05, 1.05, 1.05); + GL11.glColor4f(1F, 1F, 1F, 0.4F); + GL11.glScaled(1.05, 1.05, 1.05); + arrow.renderAll(); + } else { + arrow.renderAll(); + } - GL11.glColor4f(1F, 1F, 1F, 0.4F); - GL11.glScaled(1.05, 1.05, 1.05); - arrow.renderAll(); - } - else - { - arrow.renderAll(); - } + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - - } + } + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(EntityCustomArrow arrow) { + return arrow.bowProperties.energyBolt ? ResourceHandler.getResource("textures/models/reactorCore.png") : ResourceHandler.getResource("textures/models/tools/ArrowCommon.png"); + } - /** - * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. - */ - protected ResourceLocation getEntityTexture(EntityCustomArrow arrow) - { - return arrow.bowProperties.energyBolt ? ResourceHandler.getResource("textures/models/reactorCore.png") : ResourceHandler.getResource("textures/models/tools/ArrowCommon.png"); - } + /** + * 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_) { + return this.getEntityTexture((EntityCustomArrow) p_110775_1_); + } - /** - * 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_) - { - return this.getEntityTexture((EntityCustomArrow)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= 2 && (data[1] instanceof EntityPlayer)) { - EntityPlayer player = (EntityPlayer) data[1]; - j = (float)player.getItemInUseDuration(); - if (j > 0) { - properties = new BowHandler.BowProperties(item, player); - if (j > properties.getDrawTicks()) j = properties.getDrawTicks(); - j /= (float) properties.getDrawTicks(); - int j2 = (int) (j * 3F); + if (data.length >= 2 && (data[1] instanceof EntityPlayer)) { + EntityPlayer player = (EntityPlayer) data[1]; + j = (float) player.getItemInUseDuration(); + if (j > 0) { + properties = new BowHandler.BowProperties(item, player); + if (j > properties.getDrawTicks()) j = properties.getDrawTicks(); + j /= (float) properties.getDrawTicks(); + int j2 = (int) (j * 3F); - if (j2 < 0) j2 = 0; - else if (j2 > 3) j2 = 3; + if (j2 < 0) j2 = 0; + else if (j2 > 3) j2 = 3; - selection = j2; - } - } + selection = j2; + } + } - IModelCustom activeModel; + IModelCustom activeModel; - if (draconic) - { - activeModel = draconicModels[selection]; - ResourceHandler.bindResource("textures/models/tools/DraconicBow0" + selection + ".png"); - }else - { - activeModel = draconicModels[selection]; - ResourceHandler.bindResource("textures/models/tools/WyvernBow0"+selection+".png"); - } + if (draconic) { + activeModel = draconicModels[selection]; + ResourceHandler.bindResource("textures/models/tools/DraconicBow0" + selection + ".png"); + } else { + activeModel = draconicModels[selection]; + ResourceHandler.bindResource("textures/models/tools/WyvernBow0" + selection + ".png"); + } - if (activeModel != null) doRender(activeModel, type, j > 0 ? selection : -1, properties); + if (activeModel != null) doRender(activeModel, type, j > 0 ? selection : -1, properties); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - private void doRender(IModelCustom modelCustom, ItemRenderType type, int drawState, BowHandler.BowProperties properties){ + private void doRender(IModelCustom modelCustom, ItemRenderType type, int drawState, BowHandler.BowProperties properties) { - if (type == ItemRenderType.EQUIPPED) - { - GL11.glScaled(0.8, 0.8, 0.8); - GL11.glTranslated(0.7, 0, 0.2); - GL11.glRotatef(87, 0, 0, 1); - GL11.glRotatef(190, 1, 0, 0); - } - else if (type == ItemRenderType.EQUIPPED_FIRST_PERSON){ - GL11.glScaled(0.8, 0.8, 0.8); - GL11.glTranslated(0.7, 0.7, 0.2); - GL11.glRotatef(130, 0, 0, 1); - GL11.glRotatef(-90, 1, 0, 0); - } - else if (type == IItemRenderer.ItemRenderType.INVENTORY){ - GL11.glScalef(6F, 6F, 6F); - GL11.glRotatef(90, 1, 0, 0); - GL11.glRotatef(135, 0, 1, 0); - GL11.glTranslated(0, 0, 1.5); - } - else if (type == IItemRenderer.ItemRenderType.ENTITY){ - GL11.glScaled(0.8, 0.8, 0.8); - GL11.glTranslated(0.25, 0.7, 0.2); - GL11.glRotatef(130, 0, 0, 1); - GL11.glRotatef(-90, 1, 0, 0); - } + if (type == ItemRenderType.EQUIPPED) { + GL11.glScaled(0.8, 0.8, 0.8); + GL11.glTranslated(0.7, 0, 0.2); + GL11.glRotatef(87, 0, 0, 1); + GL11.glRotatef(190, 1, 0, 0); + } else if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glScaled(0.8, 0.8, 0.8); + GL11.glTranslated(0.7, 0.7, 0.2); + GL11.glRotatef(130, 0, 0, 1); + GL11.glRotatef(-90, 1, 0, 0); + } else if (type == IItemRenderer.ItemRenderType.INVENTORY) { + GL11.glScalef(6F, 6F, 6F); + GL11.glRotatef(90, 1, 0, 0); + GL11.glRotatef(135, 0, 1, 0); + GL11.glTranslated(0, 0, 1.5); + } else if (type == IItemRenderer.ItemRenderType.ENTITY) { + GL11.glScaled(0.8, 0.8, 0.8); + GL11.glTranslated(0.25, 0.7, 0.2); + GL11.glRotatef(130, 0, 0, 1); + GL11.glRotatef(-90, 1, 0, 0); + } - modelCustom.renderAll(); + modelCustom.renderAll(); - if (drawState != -1) - { - GL11.glTranslated(0.3, 0.151, -0.2 + (drawState == 1 ? 0 : drawState == 2 ? 0.55 : drawState == 3 ? 1 : -0.7)); - GL11.glRotatef(90, 0, 0, 1); + if (drawState != -1) { + GL11.glTranslated(0.3, 0.151, -0.2 + (drawState == 1 ? 0 : drawState == 2 ? 0.55 : drawState == 3 ? 1 : -0.7)); + GL11.glRotatef(90, 0, 0, 1); - if (properties != null && properties.energyBolt) - { - ResourceHandler.bindResource("textures/models/reactorCore.png"); - arrow.renderAll(); + if (properties != null && properties.energyBolt) { + ResourceHandler.bindResource("textures/models/reactorCore.png"); + arrow.renderAll(); - GL11.glTranslated(0, -0.025, 0); - GL11.glEnable(GL11.GL_BLEND); - GL11.glColor4f(1F, 1F, 1F, 0.6F); - GL11.glScaled(1.05, 1.05, 1.05); + GL11.glTranslated(0, -0.025, 0); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(1F, 1F, 1F, 0.6F); + GL11.glScaled(1.05, 1.05, 1.05); - GL11.glColor4f(1F, 1F, 1F, 0.4F); - GL11.glScaled(1.05, 1.05, 1.05); - arrow.renderAll(); - } - else - { - ResourceHandler.bindResource("textures/models/tools/ArrowCommon.png"); - arrow.renderAll(); - } - } - } + GL11.glColor4f(1F, 1F, 1F, 0.4F); + GL11.glScaled(1.05, 1.05, 1.05); + arrow.renderAll(); + } else { + ResourceHandler.bindResource("textures/models/tools/ArrowCommon.png"); + arrow.renderAll(); + } + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderChaosFragment.java b/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderChaosFragment.java index aedb7790..99c42709 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderChaosFragment.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderChaosFragment.java @@ -12,35 +12,36 @@ import org.lwjgl.opengl.GL11; * Created by brandon3055 on 1/10/2015. */ public class RenderChaosFragment implements IItemRenderer { - private static IModelCustom model = AdvancedModelLoader.loadModel(ResourceHandler.getResource("models/chaosCrystalShard.obj")); + private static IModelCustom model = AdvancedModelLoader.loadModel(ResourceHandler.getResource("models/chaosCrystalShard.obj")); - private static ModelStaffOfTheGreatOne staff = new ModelStaffOfTheGreatOne(); + private static ModelStaffOfTheGreatOne staff = new ModelStaffOfTheGreatOne(); - @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) { - GL11.glPushMatrix(); + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); - if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) GL11.glTranslated(0.5, 0.5, 0.5); - if (type != ItemRenderType.ENTITY) GL11.glRotatef(45, -1, 0, -1); - else GL11.glRotatef(45, -1, 0, 0); + if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) + GL11.glTranslated(0.5, 0.5, 0.5); + if (type != ItemRenderType.ENTITY) GL11.glRotatef(45, -1, 0, -1); + else GL11.glRotatef(45, -1, 0, 0); - GL11.glScalef(0.4F, 0.4F, 0.4F); - float size = 1f / (4 - item.getItemDamage()); - GL11.glScalef(size, size, size); + GL11.glScalef(0.4F, 0.4F, 0.4F); + float size = 1f / (4 - item.getItemDamage()); + GL11.glScalef(size, size, size); - ResourceHandler.bindResource("textures/models/chaosCrystal.png"); - model.renderAll(); + ResourceHandler.bindResource("textures/models/chaosCrystal.png"); + model.renderAll(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderChaosShard.java b/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderChaosShard.java index 2e7bb87e..0a69bdbb 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderChaosShard.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderChaosShard.java @@ -11,31 +11,32 @@ import org.lwjgl.opengl.GL11; * Created by brandon3055 on 1/10/2015. */ public class RenderChaosShard implements IItemRenderer { - private static IModelCustom model = AdvancedModelLoader.loadModel(ResourceHandler.getResource("models/chaosCrystalShard.obj")); + private static IModelCustom model = AdvancedModelLoader.loadModel(ResourceHandler.getResource("models/chaosCrystalShard.obj")); - @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) { - GL11.glPushMatrix(); + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); - if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) GL11.glTranslated(0.5, 0.5, 0.5); - if (type != ItemRenderType.ENTITY) GL11.glRotatef(45, -1, 0, -1); - else GL11.glRotatef(45, -1, 0, 0); + if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) + GL11.glTranslated(0.5, 0.5, 0.5); + if (type != ItemRenderType.ENTITY) GL11.glRotatef(45, -1, 0, -1); + else GL11.glRotatef(45, -1, 0, 0); - GL11.glScalef(0.4F, 0.4F, 0.4F); + GL11.glScalef(0.4F, 0.4F, 0.4F); - ResourceHandler.bindResource("textures/models/chaosCrystal.png"); - model.renderAll(); + ResourceHandler.bindResource("textures/models/chaosCrystal.png"); + model.renderAll(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderMobSoul.java b/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderMobSoul.java index e89c05d3..a31d5eab 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderMobSoul.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderMobSoul.java @@ -12,88 +12,82 @@ import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; public class RenderMobSoul implements IItemRenderer { - private Minecraft mc; - private Entity randomEntity = null; - private String[] randomEntitys = new String[] {"Pig", "Sheep", "Enderman", "Zombie", "Creeper", "Cow", "Chicken", "Ozelot", "Witch", "Wolf", "MushroomCow", "Squid", "EntityHorse", "Spider", "Skeleton", "Blaze", "Bat", "Villager", "Silverfish"}; + private Minecraft mc; + private Entity randomEntity = null; + private String[] randomEntitys = new String[]{"Pig", "Sheep", "Enderman", "Zombie", "Creeper", "Cow", "Chicken", "Ozelot", "Witch", "Wolf", "MushroomCow", "Squid", "EntityHorse", "Spider", "Skeleton", "Blaze", "Bat", "Villager", "Silverfish"}; - public RenderMobSoul() { - this.mc = Minecraft.getMinecraft(); - } + public RenderMobSoul() { + this.mc = Minecraft.getMinecraft(); + } - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) { - return type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON || type == ItemRenderType.INVENTORY || type == ItemRenderType.ENTITY; - } + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON || type == ItemRenderType.INVENTORY || type == ItemRenderType.ENTITY; + } - @Override + @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return false; - } + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return false; + } - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - Entity mob = EntityList.createEntityByName(ItemNBTHelper.getString(item, "Name", "Pig"), mc.theWorld); - randomEntity = EntityList.createEntityByName(randomEntitys[(int)((Minecraft.getSystemTime() / 1000) % 18)], mc.theWorld); - if (ItemNBTHelper.getString(item, "Name", "Pig").equals("Any")) mob = randomEntity; - if (mob instanceof EntitySkeleton) ((EntitySkeleton)mob).setSkeletonType(ItemNBTHelper.getInteger(item, "SkeletonType", 0)); + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + Entity mob = EntityList.createEntityByName(ItemNBTHelper.getString(item, "Name", "Pig"), mc.theWorld); + randomEntity = EntityList.createEntityByName(randomEntitys[(int) ((Minecraft.getSystemTime() / 1000) % 18)], mc.theWorld); + if (ItemNBTHelper.getString(item, "Name", "Pig").equals("Any")) mob = randomEntity; + if (mob instanceof EntitySkeleton) + ((EntitySkeleton) mob).setSkeletonType(ItemNBTHelper.getInteger(item, "SkeletonType", 0)); - if (mob == null) { - LogHelper.error("Invalid Mob Name:" + ItemNBTHelper.getString(item, "Name", "Pig")); - mob = EntityList.createEntityByName("Pig", mc.theWorld); - } - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glScalef(0.5F, 0.5F, 0.5F); + if (mob == null) { + LogHelper.error("Invalid Mob Name:" + ItemNBTHelper.getString(item, "Name", "Pig")); + mob = EntityList.createEntityByName("Pig", mc.theWorld); + } + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glScalef(0.5F, 0.5F, 0.5F); - if (type == ItemRenderType.INVENTORY) - { - GL11.glPushMatrix(); - GL11.glScalef(13F, 13F, 13F); - GL11.glTranslated(1.2, 2.2, 0); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F); - GL11.glRotatef(-20F, 1F, 0F, 0F); - RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F); - GL11.glPopMatrix(); - } - else if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) - { - GL11.glPushMatrix(); - GL11.glScalef(0.8F, 0.8F, 0.8F); - GL11.glTranslated(2, 0.5, 0); - GL11.glRotatef(20F, 0F, 0F, 1F); - GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F); - GL11.glRotatef(-20F, 1F, 0F, 0F); - RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F); - GL11.glPopMatrix(); - } - else if (type == ItemRenderType.EQUIPPED) - { - GL11.glPushMatrix(); - GL11.glScalef(0.8F, 0.8F, 0.8F); - GL11.glTranslated(1, 0.5, 0); - GL11.glRotatef(20F, 0F, 0F, 1F); - GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F); - GL11.glRotatef(-20F, 1F, 0F, 0F); - RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F); - GL11.glPopMatrix(); - } - else - { - GL11.glPushMatrix(); - GL11.glScalef(1.5F, 1.5F, 1.5F); - GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F); - GL11.glRotatef(-20F, 1F, 0F, 0F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } + if (type == ItemRenderType.INVENTORY) { + GL11.glPushMatrix(); + GL11.glScalef(13F, 13F, 13F); + GL11.glTranslated(1.2, 2.2, 0); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F); + GL11.glRotatef(-20F, 1F, 0F, 0F); + RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F); + GL11.glPopMatrix(); + } else if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glPushMatrix(); + GL11.glScalef(0.8F, 0.8F, 0.8F); + GL11.glTranslated(2, 0.5, 0); + GL11.glRotatef(20F, 0F, 0F, 1F); + GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F); + GL11.glRotatef(-20F, 1F, 0F, 0F); + RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F); + GL11.glPopMatrix(); + } else if (type == ItemRenderType.EQUIPPED) { + GL11.glPushMatrix(); + GL11.glScalef(0.8F, 0.8F, 0.8F); + GL11.glTranslated(1, 0.5, 0); + GL11.glRotatef(20F, 0F, 0F, 1F); + GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F); + GL11.glRotatef(-20F, 1F, 0F, 0F); + RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F); + GL11.glPopMatrix(); + } else { + GL11.glPushMatrix(); + GL11.glScalef(1.5F, 1.5F, 1.5F); + GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F); + GL11.glRotatef(-20F, 1F, 0F, 0F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } - GL11.glPopAttrib(); - GL11.glPopMatrix(); + GL11.glPopAttrib(); + GL11.glPopMatrix(); - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderStabilizerPart.java b/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderStabilizerPart.java index 653f2aa5..b971abd9 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderStabilizerPart.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderStabilizerPart.java @@ -12,70 +12,71 @@ import org.lwjgl.opengl.GL11; */ public class RenderStabilizerPart implements IItemRenderer { - public static ModelReactorStabilizerCore modelBase = new ModelReactorStabilizerCore(); - public static ModelReactorStabilizerCore modelBaseRotors = new ModelReactorStabilizerCore(); - public static ModelReactorStabilizerRing modelRing = new ModelReactorStabilizerRing(); + public static ModelReactorStabilizerCore modelBase = new ModelReactorStabilizerCore(); + public static ModelReactorStabilizerCore modelBaseRotors = new ModelReactorStabilizerCore(); + public static ModelReactorStabilizerRing modelRing = new ModelReactorStabilizerRing(); - @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) { - GL11.glPushMatrix(); - if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) GL11.glTranslated(0.5, 0.5, 0.5); + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); + if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) + GL11.glTranslated(0.5, 0.5, 0.5); - switch (item.getItemDamage()){ - case 0://frame - ResourceHandler.bindResource("textures/models/reactorStabilizerCore.png"); - modelBase.basePlate.render(0.0625F); - break; - case 1://rotor inner - ResourceHandler.bindResource("textures/models/reactorStabilizerCore.png"); + switch (item.getItemDamage()) { + case 0://frame + ResourceHandler.bindResource("textures/models/reactorStabilizerCore.png"); + modelBase.basePlate.render(0.0625F); + break; + case 1://rotor inner + ResourceHandler.bindResource("textures/models/reactorStabilizerCore.png"); // GL11.glScaled(2, 2, 2); // GL11.glTranslated(-0.2, 0, 0); - modelBaseRotors.rotor1R.childModels.clear(); - modelBaseRotors.rotor1R.render(0.0625F); - modelBaseRotors.rotor1R_1.render(0.0625F); - modelBaseRotors.rotor1R_2.render(0.0625F); - modelBaseRotors.rotor1R_3.render(0.0625F); - modelBaseRotors.rotor1R_4.render(0.0625F); - break; - case 2://rotor outer - ResourceHandler.bindResource("textures/models/reactorStabilizerCore.png"); + modelBaseRotors.rotor1R.childModels.clear(); + modelBaseRotors.rotor1R.render(0.0625F); + modelBaseRotors.rotor1R_1.render(0.0625F); + modelBaseRotors.rotor1R_2.render(0.0625F); + modelBaseRotors.rotor1R_3.render(0.0625F); + modelBaseRotors.rotor1R_4.render(0.0625F); + break; + case 2://rotor outer + ResourceHandler.bindResource("textures/models/reactorStabilizerCore.png"); // GL11.glScaled(2, 2, 2); // GL11.glTranslated(-0.3, 0, 0); - modelBaseRotors.rotor2R.childModels.clear(); - modelBaseRotors.rotor2R.render(0.0625F); - modelBaseRotors.rotor2R_1.render(0.0625F); - modelBaseRotors.rotor2R_2.render(0.0625F); - modelBaseRotors.rotor2R_3.render(0.0625F); - modelBaseRotors.rotor2R_4.render(0.0625F); - break; - case 3://rotor assembly - ResourceHandler.bindResource("textures/models/reactorStabilizerCore.png"); + modelBaseRotors.rotor2R.childModels.clear(); + modelBaseRotors.rotor2R.render(0.0625F); + modelBaseRotors.rotor2R_1.render(0.0625F); + modelBaseRotors.rotor2R_2.render(0.0625F); + modelBaseRotors.rotor2R_3.render(0.0625F); + modelBaseRotors.rotor2R_4.render(0.0625F); + break; + case 3://rotor assembly + ResourceHandler.bindResource("textures/models/reactorStabilizerCore.png"); // GL11.glScaled(1.5, 1.5, 1.5); // GL11.glTranslated(-0.05, 0, 0); - GL11.glRotatef(30F, 0F, 0F, 1F); - modelBase.rotor1R.render(0.0625F); - modelBase.hub1.render(0.0625F); - GL11.glRotatef(60F, 0F, 0F, -1F); - modelBase.hub2.render(0.0625F); - modelBase.rotor2R.render(0.0625F); - break; - case 4://stabilizer ring - ResourceHandler.bindResource("textures/models/reactorStabilizerRing.png"); - GL11.glRotatef(90F, 0F, 0F, 1F); - modelRing.render(null, -30, 1, 0, 0, 0, 1F / 16F); - break; - } + GL11.glRotatef(30F, 0F, 0F, 1F); + modelBase.rotor1R.render(0.0625F); + modelBase.hub1.render(0.0625F); + GL11.glRotatef(60F, 0F, 0F, -1F); + modelBase.hub2.render(0.0625F); + modelBase.rotor2R.render(0.0625F); + break; + case 4://stabilizer ring + ResourceHandler.bindResource("textures/models/reactorStabilizerRing.png"); + GL11.glRotatef(90F, 0F, 0F, 1F); + modelRing.render(null, -30, 1, 0, 0, 0, 1F / 16F); + break; + } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderTool.java b/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderTool.java index 19aa18cd..95553a9e 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderTool.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderTool.java @@ -11,37 +11,37 @@ import org.lwjgl.opengl.GL11; /** * Created by brandon3055 on 29/10/2015. */ -public class RenderTool implements IItemRenderer{ - private IModelCustom toolModel; - private String toolTexture; - private IRenderTweak tool; +public class RenderTool implements IItemRenderer { + private IModelCustom toolModel; + private String toolTexture; + private IRenderTweak tool; - //Draconic Sword + //Draconic Sword - public RenderTool(String model, String texture, IRenderTweak tool){ - this.tool = tool; - this.toolModel = AdvancedModelLoader.loadModel(ResourceHandler.getResource(model)); - this.toolTexture = texture; - } + public RenderTool(String model, String texture, IRenderTweak tool) { + this.tool = tool; + this.toolModel = AdvancedModelLoader.loadModel(ResourceHandler.getResource(model)); + this.toolTexture = texture; + } - @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 type == ItemRenderType.ENTITY && helper == ItemRendererHelper.ENTITY_ROTATION; - } + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return type == ItemRenderType.ENTITY && helper == ItemRendererHelper.ENTITY_ROTATION; + } - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - GL11.glPushMatrix(); - ResourceHandler.bindResource(toolTexture); + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); + ResourceHandler.bindResource(toolTexture); - tool.tweakRender(type); - toolModel.renderAll(); + tool.tweakRender(type); + toolModel.renderAll(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleCustom.java b/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleCustom.java index 5b841acb..6a1ebe9c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleCustom.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleCustom.java @@ -7,93 +7,87 @@ import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.World; -public class ParticleCustom extends EntityFX -{ - public int red = 0; - public int green = 0; - public int blue = 0; - public int maxAge = 0; - public int fadeTime = 0; - public int fadeLength = 0; - public float gravity = 0F; - - - public ParticleCustom(World world, double spawnX, double spawnY, double spawnZ, float spawnMotionX, float spawnMotionY, float spawnMotionZ, float scale, boolean canCollide, int index) { - super(world, spawnX, spawnY, spawnZ, 0.0D, 0.0D, 0.0D); - this.motionX = spawnMotionX;//initial motion value X - this.motionY = spawnMotionY;//initial motion value Y - this.motionZ = spawnMotionZ;//initial motion value Z - this.particleTextureIndexX = index - 1; // - this.particleTextureIndexY = 0; - - this.particleScale = scale; +public class ParticleCustom extends EntityFX { + public int red = 0; + public int green = 0; + public int blue = 0; + public int maxAge = 0; + public int fadeTime = 0; + public int fadeLength = 0; + public float gravity = 0F; - this.noClip = !canCollide; - } - - - @Override - public void onUpdate() - { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - if (this.particleAge++ >= this.maxAge) - { - this.particleAlpha = (float) ((float) fadeTime) / ((float) fadeLength); - if (fadeTime <= 0) - this.setDead(); - fadeTime--; - } - - this.moveEntity(this.motionX, this.motionY, this.motionZ);// also important if you want your particle to move - //this.motionX = motionX * (1 - (worldObj.rand.nextFloat() / 10F)); - this.motionY = motionY - (gravity / 100F); - //this.motionZ = motionZ * (1 - (worldObj.rand.nextFloat() / 10F)); - - - } + public ParticleCustom(World world, double spawnX, double spawnY, double spawnZ, float spawnMotionX, float spawnMotionY, float spawnMotionZ, float scale, boolean canCollide, int index) { + super(world, spawnX, spawnY, spawnZ, 0.0D, 0.0D, 0.0D); + this.motionX = spawnMotionX;//initial motion value X + this.motionY = spawnMotionY;//initial motion value Y + this.motionZ = spawnMotionZ;//initial motion value Z + this.particleTextureIndexX = index - 1; // + this.particleTextureIndexY = 0; - @Override - @SideOnly(Side.CLIENT) - public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) - {//Note U=X V=Y - - tesselator.draw(); - ResourceHandler.bindParticles(); - tesselator.startDrawingQuads(); - tesselator.setBrightness(200);//make sure you have this!! - - - float minU = (float)this.particleTextureIndexX / 8.0F; + this.particleScale = scale; + + this.noClip = !canCollide; + } + + + @Override + public void onUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.maxAge) { + this.particleAlpha = (float) ((float) fadeTime) / ((float) fadeLength); + if (fadeTime <= 0) this.setDead(); + fadeTime--; + } + + this.moveEntity(this.motionX, this.motionY, this.motionZ);// also important if you want your particle to move + //this.motionX = motionX * (1 - (worldObj.rand.nextFloat() / 10F)); + this.motionY = motionY - (gravity / 100F); + //this.motionZ = motionZ * (1 - (worldObj.rand.nextFloat() / 10F)); + + + } + + @Override + @SideOnly(Side.CLIENT) + public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + + tesselator.draw(); + ResourceHandler.bindParticles(); + tesselator.startDrawingQuads(); + tesselator.setBrightness(200);//make sure you have this!! + + + float minU = (float) this.particleTextureIndexX / 8.0F; float maxU = minU + 0.124F; - float minV = (float)this.particleTextureIndexY / 8.0F; + float minV = (float) this.particleTextureIndexY / 8.0F; float maxV = minV + 0.124F; float drawScale = 0.1F * this.particleScale; - if (this.particleIcon != null) - { + if (this.particleIcon != null) { minU = this.particleIcon.getMinU(); maxU = this.particleIcon.getMaxU(); minV = this.particleIcon.getMinV(); maxV = this.particleIcon.getMaxV(); } - float drawX = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX); - float drawY = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY); - float drawZ = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ); - - tesselator.setColorRGBA(red, green, blue, (int)(this.particleAlpha * 255F)); - - tesselator.addVertexWithUV((double)(drawX - par3 * drawScale - par6 * drawScale), (double)(drawY - par4 * drawScale), (double)(drawZ - par5 * drawScale - par7 * drawScale), (double)maxU, (double)maxV); - tesselator.addVertexWithUV((double)(drawX - par3 * drawScale + par6 * drawScale), (double)(drawY + par4 * drawScale), (double)(drawZ - par5 * drawScale + par7 * drawScale), (double)maxU, (double)minV); - tesselator.addVertexWithUV((double)(drawX + par3 * drawScale + par6 * drawScale), (double)(drawY + par4 * drawScale), (double)(drawZ + par5 * drawScale + par7 * drawScale), (double)minU, (double)minV); - tesselator.addVertexWithUV((double)(drawX + par3 * drawScale - par6 * drawScale), (double)(drawY - par4 * drawScale), (double)(drawZ + par5 * drawScale - par7 * drawScale), (double)minU, (double)maxV); - + float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); + float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); + float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); + + tesselator.setColorRGBA(red, green, blue, (int) (this.particleAlpha * 255F)); + + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); + tesselator.draw(); - ResourceHandler.bindDefaultParticles(); - tesselator.startDrawingQuads(); - - } + ResourceHandler.bindDefaultParticles(); + tesselator.startDrawingQuads(); + + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleDistortion.java b/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleDistortion.java index 8f539c17..eda89584 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleDistortion.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleDistortion.java @@ -8,94 +8,94 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.World; public class ParticleDistortion extends EntityFX { - double originalX; - double originalZ; + double originalX; + double originalZ; - public ParticleDistortion(World par1World, double par2, double par4, double par6, float par8, float par9, float par10, float scale) { - this(par1World, par2, par4, par6, 1.0F, par8, par9, par10, scale); - } + public ParticleDistortion(World par1World, double par2, double par4, double par6, float par8, float par9, float par10, float scale) { + this(par1World, par2, par4, par6, 1.0F, par8, par9, par10, scale); + } - public ParticleDistortion(World world, double par2, double par4, double par6, float par8, float par9, float par10, float par11, float scale) { - super(world, par2, par4, par6, 0.0D, 0.0D, 0.0D); - this.motionX = par9;//initial motion value X - this.motionY = par10;//initial motion value Y - this.motionZ = par11;//initial motion value Z - this.originalX = par9; - this.originalZ = par11; - if (par9 == 0.0F) { - par9 = 1.0F; - } - //float var12 = (float) Math.random() * 0.4F + 0.6F; - this.particleTextureIndexX = 0; // - this.particleTextureIndexY = 0; + public ParticleDistortion(World world, double par2, double par4, double par6, float par8, float par9, float par10, float par11, float scale) { + super(world, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.motionX = par9;//initial motion value X + this.motionY = par10;//initial motion value Y + this.motionZ = par11;//initial motion value Z + this.originalX = par9; + this.originalZ = par11; + if (par9 == 0.0F) { + par9 = 1.0F; + } + //float var12 = (float) Math.random() * 0.4F + 0.6F; + this.particleTextureIndexX = 0; // + this.particleTextureIndexY = 0; - this.particleRed = 0.7F;//RGB of your particle - this.particleGreen = 0.8F; - this.particleBlue = 1.0F; - //this.particleScale *= 0.05f + world.rand.nextFloat()*0.005; - //this.particleScale *= par8; - this.particleScale = scale; + this.particleRed = 0.7F;//RGB of your particle + this.particleGreen = 0.8F; + this.particleBlue = 1.0F; + //this.particleScale *= 0.05f + world.rand.nextFloat()*0.005; + //this.particleScale *= par8; + this.particleScale = scale; - this.particleMaxAge = 40 + world.rand.nextInt(40);//how soon the particle dies. You can use randomizer for this - this.noClip = true;//does your particle collide with blocks? - } + this.particleMaxAge = 40 + world.rand.nextInt(40);//how soon the particle dies. You can use randomizer for this + this.noClip = true;//does your particle collide with blocks? + } - @Override - public void onUpdate() { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + @Override + public void onUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; - if (this.particleAge++ >= this.particleMaxAge) { - this.setDead();//make sure to have this - } - this.moveEntity(this.motionX, this.motionY, this.motionZ);// also important if you want your particle to move - this.motionX = motionX * (1 - (worldObj.rand.nextFloat() / 10F)); - this.motionY = motionY * (1 - (worldObj.rand.nextFloat() / 10F)); - this.motionZ = motionZ * (1 - (worldObj.rand.nextFloat() / 10F)); - this.particleAlpha = (1F - ((float) this.particleAge / (float) this.particleMaxAge)) * 0.5F; + if (this.particleAge++ >= this.particleMaxAge) { + this.setDead();//make sure to have this + } + this.moveEntity(this.motionX, this.motionY, this.motionZ);// also important if you want your particle to move + this.motionX = motionX * (1 - (worldObj.rand.nextFloat() / 10F)); + this.motionY = motionY * (1 - (worldObj.rand.nextFloat() / 10F)); + this.motionZ = motionZ * (1 - (worldObj.rand.nextFloat() / 10F)); + this.particleAlpha = (1F - ((float) this.particleAge / (float) this.particleMaxAge)) * 0.5F; - } + } - @Override - @SideOnly(Side.CLIENT) - public void renderParticle(Tessellator tessellator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + @Override + @SideOnly(Side.CLIENT) + public void renderParticle(Tessellator tessellator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y - tessellator.draw(); - ResourceHandler.bindParticles(); - tessellator.startDrawingQuads(); - tessellator.setBrightness(200);//make sure you have this!! + tessellator.draw(); + ResourceHandler.bindParticles(); + tessellator.startDrawingQuads(); + tessellator.setBrightness(200);//make sure you have this!! - float minU = 0.0F + 0F;//(float)this.particleTextureIndexX / 32.0F; - float maxU = 0.0F + 0.1245F;//minU + 0.124F; - float minV = 0F;//(float)this.particleTextureIndexY / 32.0F; - float maxV = 0.1245F;//minV + 0.124F; - float drawScale = 0.1F * this.particleScale; + float minU = 0.0F + 0F;//(float)this.particleTextureIndexX / 32.0F; + float maxU = 0.0F + 0.1245F;//minU + 0.124F; + float minV = 0F;//(float)this.particleTextureIndexY / 32.0F; + float maxV = 0.1245F;//minV + 0.124F; + float drawScale = 0.1F * this.particleScale; - if (this.particleIcon != null) { - minU = this.particleIcon.getMinU(); - maxU = this.particleIcon.getMaxU(); - minV = this.particleIcon.getMinV(); - maxV = this.particleIcon.getMaxV(); - } + if (this.particleIcon != null) { + minU = this.particleIcon.getMinU(); + maxU = this.particleIcon.getMaxU(); + minV = this.particleIcon.getMinV(); + maxV = this.particleIcon.getMaxV(); + } - float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); - float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); - float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); + float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); + float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); + float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); - tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); - tessellator.setColorRGBA(0, 255, 255, (int) (this.particleAlpha * 255F)); + tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); + tessellator.setColorRGBA(0, 255, 255, (int) (this.particleAlpha * 255F)); - tessellator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); - tessellator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); - tessellator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); - tessellator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); + tessellator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); + tessellator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); + tessellator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); + tessellator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); - tessellator.draw(); - ResourceHandler.bindDefaultParticles(); - tessellator.startDrawingQuads(); + tessellator.draw(); + ResourceHandler.bindDefaultParticles(); + tessellator.startDrawingQuads(); - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleEnergy.java b/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleEnergy.java index b035a8ff..d171d13f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleEnergy.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleEnergy.java @@ -6,130 +6,129 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.World; public class ParticleEnergy extends EntityFX { - public double originalX; - public double originalY; - public double originalZ; - public double targetX; - public double targetY; - public double targetZ; - public int particle; - public boolean expand = true; + public double originalX; + public double originalY; + public double originalZ; + public double targetX; + public double targetY; + public double targetZ; + public int particle; + public boolean expand = true; - public ParticleEnergy(World world, double x, double y, double z, double tX, double tY, double tZ, int particle, boolean expand) { - this(world, x, y, z, tX, tY, tZ, particle); - this.expand = expand; - this.particleRed = 185F / 255F; - this.particleGreen = 0.0F; - this.particleBlue = 197F / 255F; - this.particleScale = 0F; - } + public ParticleEnergy(World world, double x, double y, double z, double tX, double tY, double tZ, int particle, boolean expand) { + this(world, x, y, z, tX, tY, tZ, particle); + this.expand = expand; + this.particleRed = 185F / 255F; + this.particleGreen = 0.0F; + this.particleBlue = 197F / 255F; + this.particleScale = 0F; + } - public ParticleEnergy(World world, double x, double y, double z, double tX, double tY, double tZ, int particle) { - super(world, x, y, z, 0.0D, 0.0D, 0.0D); - this.motionX = 0; - this.motionY = 0; - this.motionZ = 0; - this.originalX = x; - this.originalY = y; - this.originalZ = z; - this.targetX = tX; - this.targetY = tY; - this.targetZ = tZ; - this.particle = particle; + public ParticleEnergy(World world, double x, double y, double z, double tX, double tY, double tZ, int particle) { + super(world, x, y, z, 0.0D, 0.0D, 0.0D); + this.motionX = 0; + this.motionY = 0; + this.motionZ = 0; + this.originalX = x; + this.originalY = y; + this.originalZ = z; + this.targetX = tX; + this.targetY = tY; + this.targetZ = tZ; + this.particle = particle; - this.particleTextureIndexX = 0; - this.particleTextureIndexY = 0; + this.particleTextureIndexX = 0; + this.particleTextureIndexY = 0; - this.particleRed = particle == 1 ? 0F : 1.0F; - this.particleGreen = particle == 1 ? 1F : 0.2F; - this.particleBlue = particle == 1 ? 1F : 0.0F; - //this.particleScale *= 0.05f + world.rand.nextFloat()*0.005; - //this.particleScale *= par8; - this.particleScale = 0.5F; - this.particleMaxAge = 80; - this.noClip = true; - } + this.particleRed = particle == 1 ? 0F : 1.0F; + this.particleGreen = particle == 1 ? 1F : 0.2F; + this.particleBlue = particle == 1 ? 1F : 0.0F; + //this.particleScale *= 0.05f + world.rand.nextFloat()*0.005; + //this.particleScale *= par8; + this.particleScale = 0.5F; + this.particleMaxAge = 80; + this.noClip = true; + } - @Override - public void onUpdate() { - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; + @Override + public void onUpdate() { + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; - if (!expand && particleScale < 0.7){ - particleScale += 0.05; - } + if (!expand && particleScale < 0.7) { + particleScale += 0.05; + } - particleAlpha = (1F - ((float) particleAge / (float) particleMaxAge)) * 0.5F; + particleAlpha = (1F - ((float) particleAge / (float) particleMaxAge)) * 0.5F; - if (particleAge++ >= particleMaxAge) { - setDead(); - } - moveEntity(motionX, motionY, motionZ);// also important if you want your particle to move - float speedMultiplyer = 0.000501F; - float ySpeedMultiplyer = 0.1006F; - if (expand) { - motionX = motionX + (targetX - posX) * speedMultiplyer; - motionY = motionY + (targetY - posY) * speedMultiplyer; - motionZ = motionZ + (targetZ - posZ) * speedMultiplyer; - }else - { - motionX = (targetX - posX) * speedMultiplyer; - motionY = (targetY - posY) * ySpeedMultiplyer; - motionZ = (targetZ - posZ) * speedMultiplyer; - } - if (expand && Math.abs(targetX - posX) < 0.01 && Math.abs(targetY - posY) < 0.01 && Math.abs(targetZ - posZ) < 0.01){ - motionX = 0; - motionY = 0; - motionZ = 0; - particleRed = 0F; - particleGreen = 1F; - particleBlue = 1F; - particleScale = 2; - particleAlpha = (1F - ((float) particleAge / (float) particleMaxAge)) * 1F; - } + if (particleAge++ >= particleMaxAge) { + setDead(); + } + moveEntity(motionX, motionY, motionZ);// also important if you want your particle to move + float speedMultiplyer = 0.000501F; + float ySpeedMultiplyer = 0.1006F; + if (expand) { + motionX = motionX + (targetX - posX) * speedMultiplyer; + motionY = motionY + (targetY - posY) * speedMultiplyer; + motionZ = motionZ + (targetZ - posZ) * speedMultiplyer; + } else { + motionX = (targetX - posX) * speedMultiplyer; + motionY = (targetY - posY) * ySpeedMultiplyer; + motionZ = (targetZ - posZ) * speedMultiplyer; + } + if (expand && Math.abs(targetX - posX) < 0.01 && Math.abs(targetY - posY) < 0.01 && Math.abs(targetZ - posZ) < 0.01) { + motionX = 0; + motionY = 0; + motionZ = 0; + particleRed = 0F; + particleGreen = 1F; + particleBlue = 1F; + particleScale = 2; + particleAlpha = (1F - ((float) particleAge / (float) particleMaxAge)) * 1F; + } - } + } - @Override - //@SideOnly(Side.CLIENT) - public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + @Override + //@SideOnly(Side.CLIENT) + public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y - tesselator.draw(); - ResourceHandler.bindParticles(); - tesselator.startDrawingQuads(); - tesselator.setBrightness(200);//make sure you have this!! + tesselator.draw(); + ResourceHandler.bindParticles(); + tesselator.startDrawingQuads(); + tesselator.setBrightness(200);//make sure you have this!! - float minU = 0.0F + 0F;//(float)this.particleTextureIndexX / 32.0F; - float maxU = 0.0F + 0.1245F;//minU + 0.124F; - float minV = 0F;//(float)this.particleTextureIndexY / 32.0F; - float maxV = 0.1245F;//minV + 0.124F; - float drawScale = 0.1F * this.particleScale; + float minU = 0.0F + 0F;//(float)this.particleTextureIndexX / 32.0F; + float maxU = 0.0F + 0.1245F;//minU + 0.124F; + float minV = 0F;//(float)this.particleTextureIndexY / 32.0F; + float maxV = 0.1245F;//minV + 0.124F; + float drawScale = 0.1F * this.particleScale; - if (this.particleIcon != null) { - minU = this.particleIcon.getMinU(); - maxU = this.particleIcon.getMaxU(); - minV = this.particleIcon.getMinV(); - maxV = this.particleIcon.getMaxV(); - } + if (this.particleIcon != null) { + minU = this.particleIcon.getMinU(); + maxU = this.particleIcon.getMaxU(); + minV = this.particleIcon.getMinV(); + maxV = this.particleIcon.getMaxV(); + } - float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); - float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); - float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); + float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); + float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); + float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); - tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); - //tesselator.setColorRGBA(0, 255, 255, (int) (this.particleAlpha * 255F)); + tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); + //tesselator.setColorRGBA(0, 255, 255, (int) (this.particleAlpha * 255F)); - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); - tesselator.draw(); - ResourceHandler.bindDefaultParticles(); - tesselator.startDrawingQuads(); + tesselator.draw(); + ResourceHandler.bindDefaultParticles(); + tesselator.startDrawingQuads(); - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleEnergyBeam.java b/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleEnergyBeam.java index c14c98b4..e1279566 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleEnergyBeam.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleEnergyBeam.java @@ -17,216 +17,218 @@ import org.lwjgl.opengl.GL11; * Created by Brandon on 8/02/2015. */ public class ParticleEnergyBeam extends EntityFX { - /**Power flow integer Ranges from 0 to 100*/ - private int flow; + /** + * Power flow integer Ranges from 0 to 100 + */ + private int flow; - /**Beam Target X*/ - private double tX = 0.0D; - /**Beam Target Y*/ - private double tY = 0.0D; - /**Beam Target Z*/ - private double tZ = 0.0D; - /**Modified Target X*/ - private boolean advanced; - private boolean renderParticle = true; - private float length = 0.0F; - private float rotYaw = 0.0F; - private float rotPitch = 0.0F; - private float prevYaw = 0.0F; - private float prevPitch = 0.0F; - private EntityPlayer player; + /** + * Beam Target X + */ + private double tX = 0.0D; + /** + * Beam Target Y + */ + private double tY = 0.0D; + /** + * Beam Target Z + */ + private double tZ = 0.0D; + /** + * Modified Target X + */ + private boolean advanced; + private boolean renderParticle = true; + private float length = 0.0F; + private float rotYaw = 0.0F; + private float rotPitch = 0.0F; + private float prevYaw = 0.0F; + private float prevPitch = 0.0F; + private EntityPlayer player; - //todo make sure not dyrectly up or down on y axis, Set dead when player goes out of range, PaRTICLE eNGINE + //todo make sure not dyrectly up or down on y axis, Set dead when player goes out of range, PaRTICLE eNGINE - private static ResourceLocation beamTextureBasic = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/EnergyBeamBlue.png"); - private static ResourceLocation beamTextureAdvanced = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/EnergyBeamRed.png"); + private static ResourceLocation beamTextureBasic = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/EnergyBeamBlue.png"); + private static ResourceLocation beamTextureAdvanced = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/EnergyBeamRed.png"); - /** - * @param offsetMode 0 = no offset, 1 = offset target end, 2 = offset start end, 3 offset both ends - * */ - public ParticleEnergyBeam(World world, double x, double y, double z, double tX, double tY, double tZ, int maxAge, int flow, boolean advanced, int offsetMode) { - super(world, x, y, z, 0.0D, 0.0D, 0.0D); - this.particleRed = 1F; - this.particleGreen = 1F; - this.particleBlue = 1F; - this.noClip = true; - this.motionX = 0.0D; - this.motionY = 0.0D; - this.motionZ = 0.0D; - this.particleMaxAge = maxAge; - this.flow = flow; - this.prevYaw = rotationYaw; - this.prevPitch = rotPitch; - this.setSize(0.2F, 0.2F); - this.advanced = advanced; - this.tX = tX; - this.tY = tY; - this.tZ = tZ; + /** + * @param offsetMode 0 = no offset, 1 = offset target end, 2 = offset start end, 3 offset both ends + */ + public ParticleEnergyBeam(World world, double x, double y, double z, double tX, double tY, double tZ, int maxAge, int flow, boolean advanced, int offsetMode) { + super(world, x, y, z, 0.0D, 0.0D, 0.0D); + this.particleRed = 1F; + this.particleGreen = 1F; + this.particleBlue = 1F; + this.noClip = true; + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; + this.particleMaxAge = maxAge; + this.flow = flow; + this.prevYaw = rotationYaw; + this.prevPitch = rotPitch; + this.setSize(0.2F, 0.2F); + this.advanced = advanced; + this.tX = tX; + this.tY = tY; + this.tZ = tZ; - if (offsetMode > 0) - { - double dist = Utills.getDistanceAtoB(x, z, tX, tZ); - if (dist == 0) dist = 0.1; - double xDist = x - tX; - double zDist = z - tZ; - double xOff = xDist / dist; - double zOff = zDist / dist; - if (xOff == 0 && zOff == 0) xOff = 1; - //LogHelper.info(xOff + " " + zOff); - double offM = 0.4D; + if (offsetMode > 0) { + double dist = Utills.getDistanceAtoB(x, z, tX, tZ); + if (dist == 0) dist = 0.1; + double xDist = x - tX; + double zDist = z - tZ; + double xOff = xDist / dist; + double zOff = zDist / dist; + if (xOff == 0 && zOff == 0) xOff = 1; + //LogHelper.info(xOff + " " + zOff); + double offM = 0.4D; - if (offsetMode == 2 || offsetMode == 3) setPosition(posX - xOff * offM, posY, posZ - zOff * offM); + if (offsetMode == 2 || offsetMode == 3) setPosition(posX - xOff * offM, posY, posZ - zOff * offM); - if (offsetMode == 1 || offsetMode == 3) - { - this.tX = tX + xOff * offM; - this.tY = tY; - this.tZ = tZ + zOff * offM; - } - } + if (offsetMode == 1 || offsetMode == 3) { + this.tX = tX + xOff * offM; + this.tY = tY; + this.tZ = tZ + zOff * offM; + } + } - } + } - public void update(int flow, boolean render) - { - this.renderParticle = render; - for(this.flow = flow; this.particleMaxAge - this.particleAge < 4; ++this.particleMaxAge) {} - } + public void update(int flow, boolean render) { + this.renderParticle = render; + for (this.flow = flow; this.particleMaxAge - this.particleAge < 4; ++this.particleMaxAge) { + } + } - @Override - public void onUpdate() - { - //1.570797f + @Override + public void onUpdate() { + //1.570797f // double sin = Math.sin(-1f + (float)(particleAge % 360) / 180f * 1.570797f); // LogHelper.info(sin + " " + particleAge % 360); - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; - this.prevYaw = this.rotYaw; - this.prevPitch = this.rotPitch; + this.prevYaw = this.rotYaw; + this.prevPitch = this.rotPitch; - float xd = (float)(this.posX - this.tX); - float yd = (float)(this.posY - this.tY); - float zd = (float)(this.posZ - this.tZ); - this.length = MathHelper.sqrt_float(xd * xd + yd * yd + zd * zd); - double var7 = (double)MathHelper.sqrt_double((double) (xd * xd + zd * zd)); - this.rotYaw = (float)(Math.atan2((double)xd, (double)zd) * 180.0D / 3.141592653589793D); - this.rotPitch = (float)(Math.atan2((double)yd, var7) * 180.0D / 3.141592653589793D); - this.prevYaw = this.rotYaw; - this.prevPitch = this.rotPitch; + float xd = (float) (this.posX - this.tX); + float yd = (float) (this.posY - this.tY); + float zd = (float) (this.posZ - this.tZ); + this.length = MathHelper.sqrt_float(xd * xd + yd * yd + zd * zd); + double var7 = (double) MathHelper.sqrt_double((double) (xd * xd + zd * zd)); + this.rotYaw = (float) (Math.atan2((double) xd, (double) zd) * 180.0D / 3.141592653589793D); + this.rotPitch = (float) (Math.atan2((double) yd, var7) * 180.0D / 3.141592653589793D); + this.prevYaw = this.rotYaw; + this.prevPitch = this.rotPitch; - if (this.particleAge++ >= this.particleMaxAge) - { - this.setDead(); - } - } + if (this.particleAge++ >= this.particleMaxAge) { + this.setDead(); + } + } - private EntityPlayer getPlayer() - { - if (player == null) - { - player = Minecraft.getMinecraft().thePlayer; - } - return player; - } + private EntityPlayer getPlayer() { + if (player == null) { + player = Minecraft.getMinecraft().thePlayer; + } + return player; + } - @Override - public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) - { - if (!renderParticle) return; - tessellator.draw(); - GL11.glPushMatrix(); - //GL11.glPushAttrib(GL11.GL_ATTRIB_STACK_DEPTH); - float var9 = 1.0F; - float slide = (float) getPlayer().ticksExisted; - float size = (float) flow / 100f * 2f; //0.7F; - if (advanced) Minecraft.getMinecraft().renderEngine.bindTexture(beamTextureAdvanced); - else Minecraft.getMinecraft().renderEngine.bindTexture(beamTextureBasic); - GL11.glTexParameterf(3553, 10242, 10497.0F); - GL11.glTexParameterf(3553, 10243, 10497.0F); - GL11.glDisable(GL11.GL_CULL_FACE); - float var11 = slide + partialTick; - float var12 = -var11 * 0.2F - (float) MathHelper.floor_float(-var11 * 0.1F); - GL11.glBlendFunc(770, 1); - GL11.glDepthMask(false); - float xx = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTick - interpPosX); - float yy = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTick - interpPosY); - float zz = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTick - interpPosZ); - GL11.glTranslated((double)xx, (double)yy, (double)zz); - float ry = (float)((double)this.prevYaw + (double)(this.rotYaw - this.prevYaw) * (double)partialTick); - float rp = (float)((double)this.prevPitch + (double)(this.rotPitch - this.prevPitch) * (double)partialTick); - GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(180.0F + ry, 0.0F, 0.0F, -1.0F); - GL11.glRotatef(rp, 1.0F, 0.0F, 0.0F); - double var44 = -0.15D * (double)size; - double var17 = 0.15D * (double)size; + @Override + public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) { + if (!renderParticle) return; + tessellator.draw(); + GL11.glPushMatrix(); + //GL11.glPushAttrib(GL11.GL_ATTRIB_STACK_DEPTH); + float var9 = 1.0F; + float slide = (float) getPlayer().ticksExisted; + float size = (float) flow / 100f * 2f; //0.7F; + if (advanced) Minecraft.getMinecraft().renderEngine.bindTexture(beamTextureAdvanced); + else Minecraft.getMinecraft().renderEngine.bindTexture(beamTextureBasic); + GL11.glTexParameterf(3553, 10242, 10497.0F); + GL11.glTexParameterf(3553, 10243, 10497.0F); + GL11.glDisable(GL11.GL_CULL_FACE); + float var11 = slide + partialTick; + float var12 = -var11 * 0.2F - (float) MathHelper.floor_float(-var11 * 0.1F); + GL11.glBlendFunc(770, 1); + GL11.glDepthMask(false); + float xx = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTick - interpPosX); + float yy = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTick - interpPosY); + float zz = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTick - interpPosZ); + GL11.glTranslated((double) xx, (double) yy, (double) zz); + float ry = (float) ((double) this.prevYaw + (double) (this.rotYaw - this.prevYaw) * (double) partialTick); + float rp = (float) ((double) this.prevPitch + (double) (this.rotPitch - this.prevPitch) * (double) partialTick); + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(180.0F + ry, 0.0F, 0.0F, -1.0F); + GL11.glRotatef(rp, 1.0F, 0.0F, 0.0F); + double var44 = -0.15D * (double) size; + double var17 = 0.15D * (double) size; - GL11.glTranslated(0.03, 0, 0); - for(int t = 0; t < 2; ++t) { - double var29 = (double)(this.length * var9); - double var31 = 0D; - double var33 = 1D; - double var35 = (double)(-1.0F + var12 + (float)t / 3.0F); - double var37 = (double)(this.length * var9) + var35; - GL11.glRotatef(t * 90.0F, 0.0F, 1.0F, 0.0F); - tessellator.startDrawingQuads(); - tessellator.setBrightness(200); - tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, 1f); - tessellator.addVertexWithUV(var44, var29, 0.0D, var33, var37); - tessellator.addVertexWithUV(var44, 0.0D, 0.0D, var33, var35); - tessellator.addVertexWithUV(var17, 0.0D, 0.0D, var31, var35); - tessellator.addVertexWithUV(var17, var29, 0.0D, var31, var37); - tessellator.draw(); - GL11.glRotatef(t * 90.0F, 0.0F, -1.0F, 0.0F); - } + GL11.glTranslated(0.03, 0, 0); + for (int t = 0; t < 2; ++t) { + double var29 = (double) (this.length * var9); + double var31 = 0D; + double var33 = 1D; + double var35 = (double) (-1.0F + var12 + (float) t / 3.0F); + double var37 = (double) (this.length * var9) + var35; + GL11.glRotatef(t * 90.0F, 0.0F, 1.0F, 0.0F); + tessellator.startDrawingQuads(); + tessellator.setBrightness(200); + tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, 1f); + tessellator.addVertexWithUV(var44, var29, 0.0D, var33, var37); + tessellator.addVertexWithUV(var44, 0.0D, 0.0D, var33, var35); + tessellator.addVertexWithUV(var17, 0.0D, 0.0D, var31, var35); + tessellator.addVertexWithUV(var17, var29, 0.0D, var31, var37); + tessellator.draw(); + GL11.glRotatef(t * 90.0F, 0.0F, -1.0F, 0.0F); + } - if (ClientEventHandler.playerHoldingWrench) - { - var44 = -0.15D * (double)1; - var17 = 0.15D * (double)1; + if (ClientEventHandler.playerHoldingWrench) { + var44 = -0.15D * (double) 1; + var17 = 0.15D * (double) 1; - //GL11.glColor4f(1f, 1f, 1f, 1f); - //GL11.glTranslated(0.1, 0, 0); - for(int t = 0; t < 2; ++t) { - double var29 = (double)(this.length * var9); - double var31 = 0D; - double var33 = 1D; - double var35 = (double)(-1.0F + var12 + (float)t / 3.0F); - double var37 = (double)(this.length * var9) + var35; - GL11.glRotatef(t * 90.0F, 0.0F, 1.0F, 0.0F); - tessellator.startDrawingQuads(); - tessellator.setBrightness(200); - tessellator.setColorRGBA_F(0f, 1f, 0f, 1f); - tessellator.addVertexWithUV(var44, var29, 0.0D, var33, var37); - tessellator.addVertexWithUV(var44, 0.0D, 0.0D, var33, var35); - tessellator.addVertexWithUV(var17, 0.0D, 0.0D, var31, var35); - tessellator.addVertexWithUV(var17, var29, 0.0D, var31, var37); - tessellator.draw(); - GL11.glRotatef(t * 90.0F, 0.0F, -1.0F, 0.0F); - } - } + //GL11.glColor4f(1f, 1f, 1f, 1f); + //GL11.glTranslated(0.1, 0, 0); + for (int t = 0; t < 2; ++t) { + double var29 = (double) (this.length * var9); + double var31 = 0D; + double var33 = 1D; + double var35 = (double) (-1.0F + var12 + (float) t / 3.0F); + double var37 = (double) (this.length * var9) + var35; + GL11.glRotatef(t * 90.0F, 0.0F, 1.0F, 0.0F); + tessellator.startDrawingQuads(); + tessellator.setBrightness(200); + tessellator.setColorRGBA_F(0f, 1f, 0f, 1f); + tessellator.addVertexWithUV(var44, var29, 0.0D, var33, var37); + tessellator.addVertexWithUV(var44, 0.0D, 0.0D, var33, var35); + tessellator.addVertexWithUV(var17, 0.0D, 0.0D, var31, var35); + tessellator.addVertexWithUV(var17, var29, 0.0D, var31, var37); + tessellator.draw(); + GL11.glRotatef(t * 90.0F, 0.0F, -1.0F, 0.0F); + } + } - //GL11.glDepthMask(true); - GL11.glBlendFunc(770, 771); - GL11.glEnable(GL11.GL_CULL_FACE); - // GL11.glPopAttrib(); - GL11.glPopMatrix(); + //GL11.glDepthMask(true); + GL11.glBlendFunc(770, 771); + GL11.glEnable(GL11.GL_CULL_FACE); + // GL11.glPopAttrib(); + GL11.glPopMatrix(); - ResourceHandler.bindDefaultParticles(); - tessellator.startDrawingQuads(); - } + ResourceHandler.bindDefaultParticles(); + tessellator.startDrawingQuads(); + } - public int getFlow() { - return flow; - } + public int getFlow() { + return flow; + } - public void setFlow(int flow) { - this.flow = flow; - } + public void setFlow(int flow) { + this.flow = flow; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleEnergyField.java b/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleEnergyField.java index cb2a4349..e979e6c5 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleEnergyField.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleEnergyField.java @@ -11,127 +11,120 @@ import org.lwjgl.opengl.GL11; * Created by Brandon on 9/02/2015. */ public class ParticleEnergyField extends EntityFX { - /** - * Particle Type 0 = Energy Ring, 1 = single particle - */ - private int type; - private boolean advanced; - private boolean renderParticle = true; + /** + * Particle Type 0 = Energy Ring, 1 = single particle + */ + private int type; + private boolean advanced; + private boolean renderParticle = true; - public ParticleEnergyField(World world, double x, double y, double z, int maxAge, int type, boolean advanced) { - super(world, x, y, z, 0.0D, 0.0D, 0.0D); - this.particleRed = 1F; - this.particleGreen = 1F; - this.particleBlue = 1F; - this.noClip = true; - this.motionX = 0.0D; - this.motionY = 0.0D; - this.motionZ = 0.0D; - this.particleMaxAge = maxAge; - this.type = type; - this.advanced = advanced; - this.setSize(1F, 1F); - } + public ParticleEnergyField(World world, double x, double y, double z, int maxAge, int type, boolean advanced) { + super(world, x, y, z, 0.0D, 0.0D, 0.0D); + this.particleRed = 1F; + this.particleGreen = 1F; + this.particleBlue = 1F; + this.noClip = true; + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; + this.particleMaxAge = maxAge; + this.type = type; + this.advanced = advanced; + this.setSize(1F, 1F); + } - public void update(boolean render) - { - for (this.renderParticle = render; this.particleMaxAge - this.particleAge < 4; ++this.particleMaxAge) {} - } + public void update(boolean render) { + for (this.renderParticle = render; this.particleMaxAge - this.particleAge < 4; ++this.particleMaxAge) { + } + } - @Override - public void onUpdate() { + @Override + public void onUpdate() { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; - if (this.particleAge++ >= this.particleMaxAge) - { - this.setDead(); - } - } + if (this.particleAge++ >= this.particleMaxAge) { + this.setDead(); + } + } - @Override - public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) { - if (!renderParticle) return; - tessellator.draw(); - GL11.glPushMatrix(); - //GL11.glPushAttrib(GL11.GL_ATTRIB_STACK_DEPTH); - GL11.glDepthMask(false); - ResourceHandler.bindParticles(); + @Override + public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) { + if (!renderParticle) return; + tessellator.draw(); + GL11.glPushMatrix(); + //GL11.glPushAttrib(GL11.GL_ATTRIB_STACK_DEPTH); + GL11.glDepthMask(false); + ResourceHandler.bindParticles(); - float minU = 0.0F + 0.125F * (advanced ? 4 : 3); - float maxU = 0.0F + 0.125F * (advanced ? 5 : 4);//minU + 0.124F; - if (type == 2) - { - minU = 0.0F + 0.125F * 5; - maxU = 0.0F + 0.125F * 6; - } - float minV = 0F;//(float)this.particleTextureIndexY / 32.0F; - float maxV = 0.123F;//minV + 0.124F; - float drawScale = 0.2f; + float minU = 0.0F + 0.125F * (advanced ? 4 : 3); + float maxU = 0.0F + 0.125F * (advanced ? 5 : 4);//minU + 0.124F; + if (type == 2) { + minU = 0.0F + 0.125F * 5; + maxU = 0.0F + 0.125F * 6; + } + float minV = 0F;//(float)this.particleTextureIndexY / 32.0F; + float maxV = 0.123F;//minV + 0.124F; + float drawScale = 0.2f; - if (this.particleIcon != null) - { - minU = this.particleIcon.getMinU(); - maxU = this.particleIcon.getMaxU(); - minV = this.particleIcon.getMinV(); - maxV = this.particleIcon.getMaxV(); - } + if (this.particleIcon != null) { + minU = this.particleIcon.getMinU(); + maxU = this.particleIcon.getMaxU(); + minV = this.particleIcon.getMinV(); + maxV = this.particleIcon.getMaxV(); + } - float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTick - interpPosX); - float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTick - interpPosY); - float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTick - interpPosZ); + float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTick - interpPosX); + float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTick - interpPosY); + float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTick - interpPosZ); - if (type == 0 || type == 2) - { - tessellator.startDrawingQuads(); - tessellator.setBrightness(200); - tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, 1f); + if (type == 0 || type == 2) { + tessellator.startDrawingQuads(); + tessellator.setBrightness(200); + tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, 1f); - double pCount = Minecraft.getMinecraft().gameSettings.fancyGraphics ? 35 : 15; - for (int i = 0; i < pCount; i++) - { - double rot = i / pCount * (3.141 * 2D) + particleAge / 3D;//1D;//i / 10D; - double offset = 0.4; - double ox = Math.sin(rot) * offset; - double oz = Math.cos(rot) * offset; + double pCount = Minecraft.getMinecraft().gameSettings.fancyGraphics ? 35 : 15; + for (int i = 0; i < pCount; i++) { + double rot = i / pCount * (3.141 * 2D) + particleAge / 3D;//1D;//i / 10D; + double offset = 0.4; + double ox = Math.sin(rot) * offset; + double oz = Math.cos(rot) * offset; - float drawXX = drawX + (float) ox; - float drawZZ = drawZ + (float) oz; + float drawXX = drawX + (float) ox; + float drawZZ = drawZ + (float) oz; - tessellator.addVertexWithUV((double) (drawXX - rotX * drawScale - rotYZ * drawScale), (double) (drawY - rotXZ * drawScale), (double) (drawZZ - rotZ * drawScale - rotXY * drawScale), (double) maxU, (double) maxV); - tessellator.addVertexWithUV((double) (drawXX - rotX * drawScale + rotYZ * drawScale), (double) (drawY + rotXZ * drawScale), (double) (drawZZ - rotZ * drawScale + rotXY * drawScale), (double) maxU, (double) minV); - tessellator.addVertexWithUV((double) (drawXX + rotX * drawScale + rotYZ * drawScale), (double) (drawY + rotXZ * drawScale), (double) (drawZZ + rotZ * drawScale + rotXY * drawScale), (double) minU, (double) minV); - tessellator.addVertexWithUV((double) (drawXX + rotX * drawScale - rotYZ * drawScale), (double) (drawY - rotXZ * drawScale), (double) (drawZZ + rotZ * drawScale - rotXY * drawScale), (double) minU, (double) maxV); - } + tessellator.addVertexWithUV((double) (drawXX - rotX * drawScale - rotYZ * drawScale), (double) (drawY - rotXZ * drawScale), (double) (drawZZ - rotZ * drawScale - rotXY * drawScale), (double) maxU, (double) maxV); + tessellator.addVertexWithUV((double) (drawXX - rotX * drawScale + rotYZ * drawScale), (double) (drawY + rotXZ * drawScale), (double) (drawZZ - rotZ * drawScale + rotXY * drawScale), (double) maxU, (double) minV); + tessellator.addVertexWithUV((double) (drawXX + rotX * drawScale + rotYZ * drawScale), (double) (drawY + rotXZ * drawScale), (double) (drawZZ + rotZ * drawScale + rotXY * drawScale), (double) minU, (double) minV); + tessellator.addVertexWithUV((double) (drawXX + rotX * drawScale - rotYZ * drawScale), (double) (drawY - rotXZ * drawScale), (double) (drawZZ + rotZ * drawScale - rotXY * drawScale), (double) minU, (double) maxV); + } - tessellator.draw(); - } - else if (type == 1) - { + tessellator.draw(); + } else if (type == 1) { - tessellator.startDrawingQuads(); - tessellator.setBrightness(200); - tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, 1f); + tessellator.startDrawingQuads(); + tessellator.setBrightness(200); + tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, 1f); - tessellator.addVertexWithUV((double) (drawX - rotX * drawScale - rotYZ * drawScale), (double) (drawY - rotXZ * drawScale), (double) (drawZ - rotZ * drawScale - rotXY * drawScale), (double) maxU, (double) maxV); - tessellator.addVertexWithUV((double) (drawX - rotX * drawScale + rotYZ * drawScale), (double) (drawY + rotXZ * drawScale), (double) (drawZ - rotZ * drawScale + rotXY * drawScale), (double) maxU, (double) minV); - tessellator.addVertexWithUV((double) (drawX + rotX * drawScale + rotYZ * drawScale), (double) (drawY + rotXZ * drawScale), (double) (drawZ + rotZ * drawScale + rotXY * drawScale), (double) minU, (double) minV); - tessellator.addVertexWithUV((double) (drawX + rotX * drawScale - rotYZ * drawScale), (double) (drawY - rotXZ * drawScale), (double) (drawZ + rotZ * drawScale - rotXY * drawScale), (double) minU, (double) maxV); + tessellator.addVertexWithUV((double) (drawX - rotX * drawScale - rotYZ * drawScale), (double) (drawY - rotXZ * drawScale), (double) (drawZ - rotZ * drawScale - rotXY * drawScale), (double) maxU, (double) maxV); + tessellator.addVertexWithUV((double) (drawX - rotX * drawScale + rotYZ * drawScale), (double) (drawY + rotXZ * drawScale), (double) (drawZ - rotZ * drawScale + rotXY * drawScale), (double) maxU, (double) minV); + tessellator.addVertexWithUV((double) (drawX + rotX * drawScale + rotYZ * drawScale), (double) (drawY + rotXZ * drawScale), (double) (drawZ + rotZ * drawScale + rotXY * drawScale), (double) minU, (double) minV); + tessellator.addVertexWithUV((double) (drawX + rotX * drawScale - rotYZ * drawScale), (double) (drawY - rotXZ * drawScale), (double) (drawZ + rotZ * drawScale - rotXY * drawScale), (double) minU, (double) maxV); - tessellator.draw(); - } + tessellator.draw(); + } // GL11.glDepthMask(true); - //GL11.glPopAttrib(); - GL11.glPopMatrix(); + //GL11.glPopAttrib(); + GL11.glPopMatrix(); - ResourceHandler.bindDefaultParticles(); - tessellator.startDrawingQuads(); - } + ResourceHandler.bindDefaultParticles(); + tessellator.startDrawingQuads(); + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleReactorBeam.java b/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleReactorBeam.java index e716ab11..7eea2dc6 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleReactorBeam.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/particle/ParticleReactorBeam.java @@ -19,223 +19,221 @@ import org.lwjgl.opengl.GL11; */ @SideOnly(Side.CLIENT) public class ParticleReactorBeam extends EntityFX { - /** - * Particle Type 0 = Energy Ring, 1 = single particle - */ - private boolean renderParticle = true; - private TileEntity tile; - private boolean isInjectorBeam = false; + /** + * Particle Type 0 = Energy Ring, 1 = single particle + */ + private boolean renderParticle = true; + private TileEntity tile; + private boolean isInjectorBeam = false; - public ParticleReactorBeam(TileEntity tile) { - super(tile.getWorldObj(), tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5, 0.0D, 0.0D, 0.0D); - this.tile = tile; - this.particleRed = 1F; - this.particleGreen = 1F; - this.particleBlue = 1F; - this.noClip = true; - this.motionX = 0.0D; - this.motionY = 0.0D; - this.motionZ = 0.0D; - this.particleMaxAge = 4; - this.setSize(1F, 1F); - isInjectorBeam = tile instanceof TileReactorEnergyInjector; - } + public ParticleReactorBeam(TileEntity tile) { + super(tile.getWorldObj(), tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5, 0.0D, 0.0D, 0.0D); + this.tile = tile; + this.particleRed = 1F; + this.particleGreen = 1F; + this.particleBlue = 1F; + this.noClip = true; + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; + this.particleMaxAge = 4; + this.setSize(1F, 1F); + isInjectorBeam = tile instanceof TileReactorEnergyInjector; + } - public void update(boolean render) - { - for (this.renderParticle = render; this.particleMaxAge - this.particleAge < 4; ++this.particleMaxAge) {} - } + public void update(boolean render) { + for (this.renderParticle = render; this.particleMaxAge - this.particleAge < 4; ++this.particleMaxAge) { + } + } - @Override - public void onUpdate() { + @Override + public void onUpdate() { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; - if (this.particleAge++ >= this.particleMaxAge) - { - this.setDead(); - } - } + if (this.particleAge++ >= this.particleMaxAge) { + this.setDead(); + } + } - @Override - public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) { - if (!((IReactorPart)tile).isActive()) return; - tessellator.draw(); - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F); + @Override + public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) { + if (!((IReactorPart) tile).isActive()) return; + tessellator.draw(); + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F); - float xx = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTick - interpPosX); - float yy = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTick - interpPosY); - float zz = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTick - interpPosZ); - GL11.glTranslated((double)xx, (double)yy, (double)zz); + float xx = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTick - interpPosX); + float yy = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTick - interpPosY); + float zz = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTick - interpPosZ); + GL11.glTranslated((double) xx, (double) yy, (double) zz); - //Common Fields - MultiblockHelper.TileLocation master = ((IReactorPart)tile).getMaster(); - float offsetX = (float)(master.posX - tile.xCoord); - float offsetY = (float)((double)master.posY - tile.yCoord); - float offsetZ = (float)(master.posZ - tile.zCoord); - float length = MathHelper.sqrt_float(offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ); + //Common Fields + MultiblockHelper.TileLocation master = ((IReactorPart) tile).getMaster(); + float offsetX = (float) (master.posX - tile.xCoord); + float offsetY = (float) ((double) master.posY - tile.yCoord); + float offsetZ = (float) (master.posZ - tile.zCoord); + float length = MathHelper.sqrt_float(offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ); - //Rotate beam to face target - float f7 = MathHelper.sqrt_float(offsetX * offsetX + offsetZ * offsetZ); - GL11.glRotatef((float) (-Math.atan2((double) offsetZ, (double) offsetX)) * 180.0F / (float) Math.PI - 90.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef((float)(-Math.atan2((double)f7, (double)offsetY)) * 180.0F / (float)Math.PI - 90.0F, 1.0F, 0.0F, 0.0F); + //Rotate beam to face target + float f7 = MathHelper.sqrt_float(offsetX * offsetX + offsetZ * offsetZ); + GL11.glRotatef((float) (-Math.atan2((double) offsetZ, (double) offsetX)) * 180.0F / (float) Math.PI - 90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef((float) (-Math.atan2((double) f7, (double) offsetY)) * 180.0F / (float) Math.PI - 90.0F, 1.0F, 0.0F, 0.0F); - TileReactorCore reactor = ((IReactorPart)tile).getMaster().getTileEntity(worldObj) instanceof TileReactorCore ? (TileReactorCore) ((IReactorPart)tile).getMaster().getTileEntity(worldObj) : null; + TileReactorCore reactor = ((IReactorPart) tile).getMaster().getTileEntity(worldObj) instanceof TileReactorCore ? (TileReactorCore) ((IReactorPart) tile).getMaster().getTileEntity(worldObj) : null; - if (tile instanceof TileReactorStabilizer && reactor != null) renderStabilizerEffect(tessellator, reactor, offsetX, offsetY, offsetZ, length, partialTick); - else if (reactor != null){ + if (tile instanceof TileReactorStabilizer && reactor != null) + renderStabilizerEffect(tessellator, reactor, offsetX, offsetY, offsetZ, length, partialTick); + else if (reactor != null) { - GL11.glShadeModel(GL11.GL_SMOOTH); - GL11.glTranslated(0, 0, 0.3); - //GL11.glPushMatrix(); - GL11.glRotatef(((float)particleAge + partialTick)*20F, 0, 0, 1); - ResourceHandler.bindResource("textures/particle/reactorEnergyBeam.png"); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glTranslated(0, 0, 0.3); + //GL11.glPushMatrix(); + GL11.glRotatef(((float) particleAge + partialTick) * 20F, 0, 0, 1); + ResourceHandler.bindResource("textures/particle/reactorEnergyBeam.png"); // float sizeOrigin = 0.5F; // float sizeTarget = 0.2F; - float sizeOrigin = 0.5F; + float sizeOrigin = 0.5F; - int color = 0xFF2200; - int alpha = (int)(200D * reactor.renderSpeed); + int color = 0xFF2200; + int alpha = (int) (200D * reactor.renderSpeed); - float speed = 20F; - float texV2 = 0.0F + ((float)particleAge + partialTick) * 0.01F * speed; - float texV1 = MathHelper.sqrt_float(offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ) + ((float)particleAge + partialTick) * 0.01F * speed; + float speed = 20F; + float texV2 = 0.0F + ((float) particleAge + partialTick) * 0.01F * speed; + float texV1 = MathHelper.sqrt_float(offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ) + ((float) particleAge + partialTick) * 0.01F * speed; - tessellator.startDrawing(5); - tessellator.setBrightness(200); + tessellator.startDrawing(5); + tessellator.setBrightness(200); - float sizeTarget = 0.1F; + float sizeTarget = 0.1F; - byte b0 = 16; - length = 0F; - for (int i = 0; i <= b0; ++i) - { - float verX = MathHelper.sin((float)(i % b0) * (float)Math.PI * 2.3F / (float)b0) * sizeTarget; - float verY = MathHelper.cos((float)(i % b0) * (float)Math.PI * 2.3F / (float)b0) * sizeTarget; - float texU = (float)(i % b0) * 1.0F / (float)b0; - tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), 0); + byte b0 = 16; + length = 0F; + for (int i = 0; i <= b0; ++i) { + float verX = MathHelper.sin((float) (i % b0) * (float) Math.PI * 2.3F / (float) b0) * sizeTarget; + float verY = MathHelper.cos((float) (i % b0) * (float) Math.PI * 2.3F / (float) b0) * sizeTarget; + float texU = (float) (i % b0) * 1.0F / (float) b0; + tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), 0); - tessellator.addVertexWithUV((double)(verX * sizeOrigin), (double)(verY * sizeOrigin), -0.55D, (double)texU, (double)texV1); - tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), alpha); - tessellator.addVertexWithUV((double)verX, (double)verY, (double)length, (double)texU, (double)texV2); - } + tessellator.addVertexWithUV((double) (verX * sizeOrigin), (double) (verY * sizeOrigin), -0.55D, (double) texU, (double) texV1); + tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), alpha); + tessellator.addVertexWithUV((double) verX, (double) verY, (double) length, (double) texU, (double) texV2); + } - length = MathHelper.sqrt_float(offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ) - (float)(reactor.getCoreDiameter()/2D) - 0.3F; - sizeTarget = (float)(reactor.getCoreDiameter()/2 * 0.2D); - sizeOrigin = 0.1F / sizeTarget; + length = MathHelper.sqrt_float(offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ) - (float) (reactor.getCoreDiameter() / 2D) - 0.3F; + sizeTarget = (float) (reactor.getCoreDiameter() / 2 * 0.2D); + sizeOrigin = 0.1F / sizeTarget; - for (int i = 0; i <= b0; ++i) - { - float verX = MathHelper.sin((float)(i % b0) * (float)Math.PI * 2.13F / (float)b0) * sizeTarget; - float verY = MathHelper.cos((float)(i % b0) * (float)Math.PI * 2.13F / (float)b0) * sizeTarget; - float texU = (float)(i % b0) * 1.0F / (float)b0; - tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), alpha); + for (int i = 0; i <= b0; ++i) { + float verX = MathHelper.sin((float) (i % b0) * (float) Math.PI * 2.13F / (float) b0) * sizeTarget; + float verY = MathHelper.cos((float) (i % b0) * (float) Math.PI * 2.13F / (float) b0) * sizeTarget; + float texU = (float) (i % b0) * 1.0F / (float) b0; + tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), alpha); - tessellator.addVertexWithUV((double)(verX * sizeOrigin), (double)(verY * sizeOrigin), 0.0D, (double)texU, (double)texV1); - tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), 0); - tessellator.addVertexWithUV((double)verX, (double)verY, (double)length, (double)texU, (double)texV2); - } + tessellator.addVertexWithUV((double) (verX * sizeOrigin), (double) (verY * sizeOrigin), 0.0D, (double) texU, (double) texV1); + tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), 0); + tessellator.addVertexWithUV((double) verX, (double) verY, (double) length, (double) texU, (double) texV2); + } - tessellator.draw(); - //GL11.glPopMatrix(); - GL11.glRotatef(((float)particleAge + partialTick)*-30F, 0, 0, 1); + tessellator.draw(); + //GL11.glPopMatrix(); + GL11.glRotatef(((float) particleAge + partialTick) * -30F, 0, 0, 1); - tessellator.startDrawing(5); - tessellator.setBrightness(200); - color = 0xFF4400; + tessellator.startDrawing(5); + tessellator.setBrightness(200); + color = 0xFF4400; - sizeTarget = (float)(reactor.getCoreDiameter()/2 * 0.6D); - sizeOrigin = 0.1F / sizeTarget; - length += 0.4F; - GL11.glTranslated(0, 0, -0.1); + sizeTarget = (float) (reactor.getCoreDiameter() / 2 * 0.6D); + sizeOrigin = 0.1F / sizeTarget; + length += 0.4F; + GL11.glTranslated(0, 0, -0.1); - for (int i = 0; i <= b0; ++i) - { - float verX = MathHelper.sin((float)(i % b0) * (float)Math.PI * 2.13F / (float)b0) * sizeTarget; - float verY = MathHelper.cos((float)(i % b0) * (float)Math.PI * 2.13F / (float)b0) * sizeTarget; - float texU = (float)(i % b0) * 1.0F / (float)b0; - tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), alpha/2); + for (int i = 0; i <= b0; ++i) { + float verX = MathHelper.sin((float) (i % b0) * (float) Math.PI * 2.13F / (float) b0) * sizeTarget; + float verY = MathHelper.cos((float) (i % b0) * (float) Math.PI * 2.13F / (float) b0) * sizeTarget; + float texU = (float) (i % b0) * 1.0F / (float) b0; + tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), alpha / 2); - tessellator.addVertexWithUV((double)(verX * sizeOrigin), (double)(verY * sizeOrigin), 0.0D, (double)texU, (double)texV1); - tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), 0); - tessellator.addVertexWithUV((double)verX, (double)verY, (double)length, (double)texU, (double)texV2); - } + tessellator.addVertexWithUV((double) (verX * sizeOrigin), (double) (verY * sizeOrigin), 0.0D, (double) texU, (double) texV1); + tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), 0); + tessellator.addVertexWithUV((double) verX, (double) verY, (double) length, (double) texU, (double) texV2); + } - tessellator.draw(); - GL11.glShadeModel(GL11.GL_FLAT); - } + tessellator.draw(); + GL11.glShadeModel(GL11.GL_FLAT); + } - GL11.glPopMatrix(); - GL11.glEnable(GL11.GL_CULL_FACE); - ResourceHandler.bindDefaultParticles(); - tessellator.startDrawingQuads(); - } + GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_CULL_FACE); + ResourceHandler.bindDefaultParticles(); + tessellator.startDrawingQuads(); + } - private void renderStabilizerEffect(Tessellator tessellator, TileReactorCore reactor, float offsetX, float offsetY, float offsetZ, float length, float partialTick){ - GL11.glShadeModel(GL11.GL_SMOOTH); + private void renderStabilizerEffect(Tessellator tessellator, TileReactorCore reactor, float offsetX, float offsetY, float offsetZ, float length, float partialTick) { + GL11.glShadeModel(GL11.GL_SMOOTH); - //Draw Beams - GL11.glPushMatrix(); - GL11.glTranslated(0, 0, -0.35); - ResourceHandler.bindResource("textures/particle/reactorBeam.png"); - drawBeam(tessellator, reactor, 1F, 0.355F, 0.8F, offsetX, offsetY, offsetZ, particleAge, partialTick, true, false, 0x00ffff); - GL11.glPopMatrix(); + //Draw Beams + GL11.glPushMatrix(); + GL11.glTranslated(0, 0, -0.35); + ResourceHandler.bindResource("textures/particle/reactorBeam.png"); + drawBeam(tessellator, reactor, 1F, 0.355F, 0.8F, offsetX, offsetY, offsetZ, particleAge, partialTick, true, false, 0x00ffff); + GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glTranslated(0, 0, 0.45); - float coreSize = (float)(reactor.getCoreDiameter()/2) * 0.9F; - float s = 0.355F; - drawBeam(tessellator, reactor, s / coreSize, coreSize, length - (float)(reactor.getCoreDiameter()/2.5D), offsetX, offsetY, offsetZ, particleAge, partialTick, false, false, 0x00ffff); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslated(0, 0, 0.45); + float coreSize = (float) (reactor.getCoreDiameter() / 2) * 0.9F; + float s = 0.355F; + drawBeam(tessellator, reactor, s / coreSize, coreSize, length - (float) (reactor.getCoreDiameter() / 2.5D), offsetX, offsetY, offsetZ, particleAge, partialTick, false, false, 0x00ffff); + GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glTranslated(0, 0, -0.35); - drawBeam(tessellator, reactor, 1F, 0.263F, 0.8F, offsetX, offsetY, offsetZ, particleAge, partialTick, true, true, 0xff6600); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslated(0, 0, -0.35); + drawBeam(tessellator, reactor, 1F, 0.263F, 0.8F, offsetX, offsetY, offsetZ, particleAge, partialTick, true, true, 0xff6600); + GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glTranslated(0, 0, 0.45); - coreSize = (float)(reactor.getCoreDiameter()/2) * 0.4F; - s = 0.263F; - drawBeam(tessellator, reactor, s / coreSize, coreSize, length - 0.5F, offsetX, offsetY, offsetZ, particleAge, partialTick, false, true, 0xff6600); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslated(0, 0, 0.45); + coreSize = (float) (reactor.getCoreDiameter() / 2) * 0.4F; + s = 0.263F; + drawBeam(tessellator, reactor, s / coreSize, coreSize, length - 0.5F, offsetX, offsetY, offsetZ, particleAge, partialTick, false, true, 0xff6600); + GL11.glPopMatrix(); - GL11.glShadeModel(GL11.GL_FLAT); - } + GL11.glShadeModel(GL11.GL_FLAT); + } - /**Size Origin is the fraction of size start Target - * So if size target is 10 and size origin is 0.5 origin will actually be 5*/ - private void drawBeam(Tessellator tessellator, TileReactorCore reactor, float sizeOrigin, float sizeTarget, float length, float offsetX, float offsetY, float offsetZ, int tick, float partialTick, boolean reverseTransparency, boolean reverseDirection, int color) { - float speed = 3F; - float texV2 = -0.1F + ((float)tick + partialTick) * (reverseDirection ? -0.01F : 0.01F) * speed; - float texV1 = MathHelper.sqrt_float(offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ) / 32.0F + ((float)tick + partialTick) * (reverseDirection ? -0.01F : 0.01F) * speed; + /** + * Size Origin is the fraction of size start Target + * So if size target is 10 and size origin is 0.5 origin will actually be 5 + */ + private void drawBeam(Tessellator tessellator, TileReactorCore reactor, float sizeOrigin, float sizeTarget, float length, float offsetX, float offsetY, float offsetZ, int tick, float partialTick, boolean reverseTransparency, boolean reverseDirection, int color) { + float speed = 3F; + float texV2 = -0.1F + ((float) tick + partialTick) * (reverseDirection ? -0.01F : 0.01F) * speed; + float texV1 = MathHelper.sqrt_float(offsetX * offsetX + offsetY * offsetY + offsetZ * offsetZ) / 32.0F + ((float) tick + partialTick) * (reverseDirection ? -0.01F : 0.01F) * speed; - tessellator.startDrawing(5); - tessellator.setBrightness(200); + tessellator.startDrawing(5); + tessellator.setBrightness(200); - byte b0 = 16; - for (int i = 0; i <= b0; ++i) - { - float verX = MathHelper.sin((float)(i % b0) * (float)Math.PI * 2.13325F / (float)b0) * sizeTarget; - float verY = MathHelper.cos((float)(i % b0) * (float)Math.PI * 2.13325F / (float)b0) * sizeTarget; - float texU = (float)(i % b0) * 1.0F / (float)b0; - tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), reverseTransparency ? 0 : (int)(255D * reactor.renderSpeed)); - tessellator.addVertexWithUV((double)(verX * sizeOrigin), (double)(verY * sizeOrigin), 0.0D, (double)texU, (double)texV1); - tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), reverseTransparency ? (int)(255D * reactor.renderSpeed) : 0); - tessellator.addVertexWithUV((double)verX, (double)verY, (double)length, (double)texU, (double)texV2); - } + byte b0 = 16; + for (int i = 0; i <= b0; ++i) { + float verX = MathHelper.sin((float) (i % b0) * (float) Math.PI * 2.13325F / (float) b0) * sizeTarget; + float verY = MathHelper.cos((float) (i % b0) * (float) Math.PI * 2.13325F / (float) b0) * sizeTarget; + float texU = (float) (i % b0) * 1.0F / (float) b0; + tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), reverseTransparency ? 0 : (int) (255D * reactor.renderSpeed)); + tessellator.addVertexWithUV((double) (verX * sizeOrigin), (double) (verY * sizeOrigin), 0.0D, (double) texU, (double) texV1); + tessellator.setColorRGBA((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, (color & 0xFF), reverseTransparency ? (int) (255D * reactor.renderSpeed) : 0); + tessellator.addVertexWithUV((double) verX, (double) verY, (double) length, (double) texU, (double) texV2); + } - tessellator.draw(); - } + tessellator.draw(); + } } // @Override diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/particle/Particles.java b/src/main/java/com/brandon3055/draconicevolution/client/render/particle/Particles.java index 95940505..955f1f58 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/particle/Particles.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/particle/Particles.java @@ -21,822 +21,822 @@ import org.lwjgl.opengl.GL11; */ public class Particles { - public static class EnergyBeamParticle extends EntityFX { + public static class EnergyBeamParticle extends EntityFX { - private int direction = 0; - private double masterX = 0; - private double masterZ = 0; - private float rotation = 0; - private boolean mirror = false; - private double[] trailX = new double[15]; - private double[] trailY = new double[15]; - private double[] trailZ = new double[15]; + private int direction = 0; + private double masterX = 0; + private double masterZ = 0; + private float rotation = 0; + private boolean mirror = false; + private double[] trailX = new double[15]; + private double[] trailY = new double[15]; + private double[] trailZ = new double[15]; - public EnergyBeamParticle(World world, double x, double y, double z, double x1, double z1, int direction, boolean mirror) { - super(world, x, y, z, 0.0D, 0.0D, 0.0D); - float speed = 0.04F; - this.motionX = 0; - this.motionY = 0; - this.motionZ = 0; - this.masterX = x1; - this.masterZ = z1; - this.direction = direction; - this.mirror = mirror; + public EnergyBeamParticle(World world, double x, double y, double z, double x1, double z1, int direction, boolean mirror) { + super(world, x, y, z, 0.0D, 0.0D, 0.0D); + float speed = 0.04F; + this.motionX = 0; + this.motionY = 0; + this.motionZ = 0; + this.masterX = x1; + this.masterZ = z1; + this.direction = direction; + this.mirror = mirror; - switch (direction){ - case 0: - this.motionX = speed; - break; - case 1: - this.motionX = -speed; - break; - case 2: - this.motionZ = speed; - break; - case 3: - this.motionZ = -speed; - break; - } + switch (direction) { + case 0: + this.motionX = speed; + break; + case 1: + this.motionX = -speed; + break; + case 2: + this.motionZ = speed; + break; + case 3: + this.motionZ = -speed; + break; + } - this.particleTextureIndexX = 0; - this.particleTextureIndexY = 0; - this.particleScale = 1F; - this.noClip = true; - this.particleMaxAge = 300; - } + this.particleTextureIndexX = 0; + this.particleTextureIndexY = 0; + this.particleScale = 1F; + this.noClip = true; + this.particleMaxAge = 300; + } - @Override - public void onUpdate() { - if (particleAge > particleMaxAge || this.getDistanceSq(masterX, posY, masterZ) < 0.02) setDead(); - if (this.getDistanceSq(masterX, posY, masterZ) < 0.1) { - motionX = (masterX - posX) * 0.1F; - motionY = (Math.floor(posY) + 0.5 - posY) * 0.1F; - motionZ = (masterZ - posZ) * 0.1F; - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - moveEntity(motionX, motionY, motionZ); - return; - }else { - trailX[0] = posX; - trailY[0] = posY; - trailZ[0] = posZ; - for (int i = 14; i >= 0; i--){ - if (i > 0) { - trailX[i] = trailX[i-1]; - trailY[i] = trailY[i-1]; - trailZ[i] = trailZ[i-1]; - } - } + @Override + public void onUpdate() { + if (particleAge > particleMaxAge || this.getDistanceSq(masterX, posY, masterZ) < 0.02) setDead(); + if (this.getDistanceSq(masterX, posY, masterZ) < 0.1) { + motionX = (masterX - posX) * 0.1F; + motionY = (Math.floor(posY) + 0.5 - posY) * 0.1F; + motionZ = (masterZ - posZ) * 0.1F; + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + moveEntity(motionX, motionY, motionZ); + return; + } else { + trailX[0] = posX; + trailY[0] = posY; + trailZ[0] = posZ; + for (int i = 14; i >= 0; i--) { + if (i > 0) { + trailX[i] = trailX[i - 1]; + trailY[i] = trailY[i - 1]; + trailZ[i] = trailZ[i - 1]; + } + } - float multiplier = 0.27F; - double masterY = Math.floor(posY) + 0.5; - if (direction == 0 || direction == 1) { - posZ = masterZ + Math.sin(rotation) * multiplier; - posY = masterY + Math.cos(rotation) * multiplier; - }else{ - posX = masterX + Math.sin(rotation) * multiplier; - posY = masterY + Math.cos(rotation) * multiplier; - } - if (mirror){ - float modifier = 3F; - if (direction == 0 || direction == 1) { - posZ = masterZ + Math.sin(rotation + modifier) * multiplier; - posY = masterY + Math.cos(rotation + modifier) * multiplier; - }else{ - posX = masterX + Math.sin(rotation + modifier) * multiplier; - posY = masterY + Math.cos(rotation + modifier) * multiplier; - } - } - setPosition(posX, posY, posZ); - } - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - if (direction == 0 || direction == 1) - moveEntity(motionX, 0, 0); - else - moveEntity(0, 0, motionZ); - particleAge ++; - if (direction == 0 || direction == 3) - rotation -= 0.15; - else - rotation += 0.15; - } - @Override - @SideOnly(Side.CLIENT) - public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + float multiplier = 0.27F; + double masterY = Math.floor(posY) + 0.5; + if (direction == 0 || direction == 1) { + posZ = masterZ + Math.sin(rotation) * multiplier; + posY = masterY + Math.cos(rotation) * multiplier; + } else { + posX = masterX + Math.sin(rotation) * multiplier; + posY = masterY + Math.cos(rotation) * multiplier; + } + if (mirror) { + float modifier = 3F; + if (direction == 0 || direction == 1) { + posZ = masterZ + Math.sin(rotation + modifier) * multiplier; + posY = masterY + Math.cos(rotation + modifier) * multiplier; + } else { + posX = masterX + Math.sin(rotation + modifier) * multiplier; + posY = masterY + Math.cos(rotation + modifier) * multiplier; + } + } + setPosition(posX, posY, posZ); + } + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + if (direction == 0 || direction == 1) moveEntity(motionX, 0, 0); + else moveEntity(0, 0, motionZ); + particleAge++; + if (direction == 0 || direction == 3) rotation -= 0.15; + else rotation += 0.15; + } - tesselator.draw(); - ResourceHandler.bindParticles(); - tesselator.startDrawingQuads(); - tesselator.setBrightness(200);//make sure you have this!! + @Override + @SideOnly(Side.CLIENT) + public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + + tesselator.draw(); + ResourceHandler.bindParticles(); + tesselator.startDrawingQuads(); + tesselator.setBrightness(200);//make sure you have this!! - float minU = 0.0F + 0F;//(float)this.particleTextureIndexX / 32.0F; - float maxU = 0.0F + 0.1245F;//minU + 0.124F; - float minV = 0F;//(float)this.particleTextureIndexY / 32.0F; - float maxV = 0.1245F;//minV + 0.124F; - float drawScale = 0.1F * particleScale; + float minU = 0.0F + 0F;//(float)this.particleTextureIndexX / 32.0F; + float maxU = 0.0F + 0.1245F;//minU + 0.124F; + float minV = 0F;//(float)this.particleTextureIndexY / 32.0F; + float maxV = 0.1245F;//minV + 0.124F; + float drawScale = 0.1F * particleScale; - if (this.particleIcon != null) { - minU = particleIcon.getMinU(); - maxU = particleIcon.getMaxU(); - minV = particleIcon.getMinV(); - maxV = particleIcon.getMaxV(); - } + if (this.particleIcon != null) { + minU = particleIcon.getMinU(); + maxU = particleIcon.getMaxU(); + minV = particleIcon.getMinV(); + maxV = particleIcon.getMaxV(); + } - float drawX = (float) (prevPosX + (posX - prevPosX) * (double) par2 - interpPosX); - float drawY = (float) (prevPosY + (posY - prevPosY) * (double) par2 - interpPosY); - float drawZ = (float) (prevPosZ + (posZ - prevPosZ) * (double) par2 - interpPosZ); + float drawX = (float) (prevPosX + (posX - prevPosX) * (double) par2 - interpPosX); + float drawY = (float) (prevPosY + (posY - prevPosY) * (double) par2 - interpPosY); + float drawZ = (float) (prevPosZ + (posZ - prevPosZ) * (double) par2 - interpPosZ); - tesselator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha); + tesselator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha); - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); - for (int i = 0; i <= 14; i++){ - GL11.glPushMatrix(); - drawX = (float) (trailX[i] + (trailX[i] - trailX[i]) * (double) par2 - interpPosX); - drawY = (float) (trailY[i] + (trailY[i] - trailY[i]) * (double) par2 - interpPosY); - drawZ = (float) (trailZ[i] + (trailZ[i] - trailZ[i]) * (double) par2 - interpPosZ); - float scale = 0.1F * (1F - ((float)i / 14F)); - float scale2 = (1F - ((float)i / 14F)); + for (int i = 0; i <= 14; i++) { + GL11.glPushMatrix(); + drawX = (float) (trailX[i] + (trailX[i] - trailX[i]) * (double) par2 - interpPosX); + drawY = (float) (trailY[i] + (trailY[i] - trailY[i]) * (double) par2 - interpPosY); + drawZ = (float) (trailZ[i] + (trailZ[i] - trailZ[i]) * (double) par2 - interpPosZ); + float scale = 0.1F * (1F - ((float) i / 14F)); + float scale2 = (1F - ((float) i / 14F)); - if (!mirror) { - tesselator.setColorRGBA_F(1F, scale2, scale2, scale2); - }else{ - tesselator.setColorRGBA_F(scale2, 1F, scale2, scale2); - } + if (!mirror) { + tesselator.setColorRGBA_F(1F, scale2, scale2, scale2); + } else { + tesselator.setColorRGBA_F(scale2, 1F, scale2, scale2); + } - tesselator.addVertexWithUV((double) (drawX - par3 * scale - par6 * scale), (double) (drawY - par4 * scale), (double) (drawZ - par5 * scale - par7 * scale), (double) maxU, (double) maxV); - tesselator.addVertexWithUV((double) (drawX - par3 * scale + par6 * scale), (double) (drawY + par4 * scale), (double) (drawZ - par5 * scale + par7 * scale), (double) maxU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * scale + par6 * scale), (double) (drawY + par4 * scale), (double) (drawZ + par5 * scale + par7 * scale), (double) minU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * scale - par6 * scale), (double) (drawY - par4 * scale), (double) (drawZ + par5 * scale - par7 * scale), (double) minU, (double) maxV); - GL11.glPopMatrix(); - } + tesselator.addVertexWithUV((double) (drawX - par3 * scale - par6 * scale), (double) (drawY - par4 * scale), (double) (drawZ - par5 * scale - par7 * scale), (double) maxU, (double) maxV); + tesselator.addVertexWithUV((double) (drawX - par3 * scale + par6 * scale), (double) (drawY + par4 * scale), (double) (drawZ - par5 * scale + par7 * scale), (double) maxU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * scale + par6 * scale), (double) (drawY + par4 * scale), (double) (drawZ + par5 * scale + par7 * scale), (double) minU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * scale - par6 * scale), (double) (drawY - par4 * scale), (double) (drawZ + par5 * scale - par7 * scale), (double) minU, (double) maxV); + GL11.glPopMatrix(); + } - tesselator.draw(); - ResourceHandler.bindDefaultParticles(); - tesselator.startDrawingQuads(); + tesselator.draw(); + ResourceHandler.bindDefaultParticles(); + tesselator.startDrawingQuads(); - } - } + } + } - public static class EnergyTransferParticle extends EntityFX { + public static class EnergyTransferParticle extends EntityFX { - private double targetX; - private double targetY; - private double targetZ; - private boolean passive; + private double targetX; + private double targetY; + private double targetZ; + private boolean passive; - public EnergyTransferParticle(World world, double x, double y, double z, double tX, double tY, double tZ, boolean passive) { - super(world, x, y, z, 0.0D, 0.0D, 0.0D); - this.passive = passive; - this.targetX = tX; - this.targetY = tY; - this.targetZ = tZ; - this.motionX = 0; - this.motionY = 0; - this.motionZ = 0; - this.particleTextureIndexX = 0; - this.particleTextureIndexY = 0; - this.particleScale = world.rand.nextFloat() + 0.5F; - this.particleMaxAge = 100; - this.noClip = true; - if (!passive){ - this.particleRed = 0F; - this.particleGreen = 94F/255F; - this.particleBlue = 250F/255F; - } - } + public EnergyTransferParticle(World world, double x, double y, double z, double tX, double tY, double tZ, boolean passive) { + super(world, x, y, z, 0.0D, 0.0D, 0.0D); + this.passive = passive; + this.targetX = tX; + this.targetY = tY; + this.targetZ = tZ; + this.motionX = 0; + this.motionY = 0; + this.motionZ = 0; + this.particleTextureIndexX = 0; + this.particleTextureIndexY = 0; + this.particleScale = world.rand.nextFloat() + 0.5F; + this.particleMaxAge = 100; + this.noClip = true; + if (!passive) { + this.particleRed = 0F; + this.particleGreen = 94F / 255F; + this.particleBlue = 250F / 255F; + } + } - @Override - public void onUpdate() { - if (particleAge > particleMaxAge) setDead(); - if (particleAge > particleMaxAge || this.getDistanceSq(targetX, targetY, targetZ) < 0.05) setDead(); - particleAge ++; - motionX += (targetX - posX) * 0.001F; - motionY += (targetY - posY) * 0.001F; - motionZ += (targetZ - posZ) * 0.001F; - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - moveEntity(motionX, motionY, motionZ); - } + @Override + public void onUpdate() { + if (particleAge > particleMaxAge) setDead(); + if (particleAge > particleMaxAge || this.getDistanceSq(targetX, targetY, targetZ) < 0.05) setDead(); + particleAge++; + motionX += (targetX - posX) * 0.001F; + motionY += (targetY - posY) * 0.001F; + motionZ += (targetZ - posZ) * 0.001F; + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + moveEntity(motionX, motionY, motionZ); + } - @Override - @SideOnly(Side.CLIENT) - public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + @Override + @SideOnly(Side.CLIENT) + public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y - tesselator.draw(); - ResourceHandler.bindParticles(); - tesselator.startDrawingQuads(); - tesselator.setBrightness(200);//make sure you have this!! + tesselator.draw(); + ResourceHandler.bindParticles(); + tesselator.startDrawingQuads(); + tesselator.setBrightness(200);//make sure you have this!! - float minU = 0.0F + 0F;//(float)this.particleTextureIndexX / 32.0F; - float maxU = 0.0F + 0.1245F;//minU + 0.124F; - float minV = 0F;//(float)this.particleTextureIndexY / 32.0F; - float maxV = 0.1245F;//minV + 0.124F; - float drawScale = 0.1F * this.particleScale; + float minU = 0.0F + 0F;//(float)this.particleTextureIndexX / 32.0F; + float maxU = 0.0F + 0.1245F;//minU + 0.124F; + float minV = 0F;//(float)this.particleTextureIndexY / 32.0F; + float maxV = 0.1245F;//minV + 0.124F; + float drawScale = 0.1F * this.particleScale; - if (this.particleIcon != null) { - minU = this.particleIcon.getMinU(); - maxU = this.particleIcon.getMaxU(); - minV = this.particleIcon.getMinV(); - maxV = this.particleIcon.getMaxV(); - } + if (this.particleIcon != null) { + minU = this.particleIcon.getMinU(); + maxU = this.particleIcon.getMaxU(); + minV = this.particleIcon.getMinV(); + maxV = this.particleIcon.getMaxV(); + } - float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); - float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); - float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); + float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); + float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); + float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); - if (passive) - tesselator.setColorRGBA_F((float)this.getDistanceSq(targetX, targetY, targetZ)*5F*this.particleRed, (float)this.getDistanceSq(targetX, targetY, targetZ)*5F*this.particleGreen, this.particleBlue, this.particleAlpha); - else - tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, (float)this.getDistanceSq(targetX, targetY, targetZ)*5F); + if (passive) + tesselator.setColorRGBA_F((float) this.getDistanceSq(targetX, targetY, targetZ) * 5F * this.particleRed, (float) this.getDistanceSq(targetX, targetY, targetZ) * 5F * this.particleGreen, this.particleBlue, this.particleAlpha); + else + tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, (float) this.getDistanceSq(targetX, targetY, targetZ) * 5F); - //tesselator.setColorRGBA(0, 255, 255, (int) (this.particleAlpha * 255F)); + //tesselator.setColorRGBA(0, 255, 255, (int) (this.particleAlpha * 255F)); - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); - tesselator.draw(); - ResourceHandler.bindDefaultParticles(); - tesselator.startDrawingQuads(); + tesselator.draw(); + ResourceHandler.bindDefaultParticles(); + tesselator.startDrawingQuads(); - } - } + } + } - public static class AdvancedSeekerParticle extends EntityFX { + public static class AdvancedSeekerParticle extends EntityFX { - public double targetX; - public double targetY; - public double targetZ; - public double startDist = 0; - public int behaviour; - public int timer = 0; + public double targetX; + public double targetY; + public double targetZ; + public double startDist = 0; + public int behaviour; + public int timer = 0; - public AdvancedSeekerParticle(World world, double x, double y, double z, double tX, double tY, double tZ, int type, int maxAge) { - super(world, x, y, z, 0.0D, 0.0D, 0.0D); - this.targetX = tX; - this.targetY = tY; - this.targetZ = tZ; - this.motionX = 0; - this.motionY = 0; - this.motionZ = 0; - this.particleTextureIndexX = 0; - this.particleTextureIndexY = 0; - this.particleScale = world.rand.nextFloat() + 0.5F; - this.particleMaxAge = 100; - this.noClip = true; - this.behaviour = type; - this.startDist = getDistance(targetX, targetY, targetZ); - this.particleMaxAge = maxAge; - } + public AdvancedSeekerParticle(World world, double x, double y, double z, double tX, double tY, double tZ, int type, int maxAge) { + super(world, x, y, z, 0.0D, 0.0D, 0.0D); + this.targetX = tX; + this.targetY = tY; + this.targetZ = tZ; + this.motionX = 0; + this.motionY = 0; + this.motionZ = 0; + this.particleTextureIndexX = 0; + this.particleTextureIndexY = 0; + this.particleScale = world.rand.nextFloat() + 0.5F; + this.particleMaxAge = 100; + this.noClip = true; + this.behaviour = type; + this.startDist = getDistance(targetX, targetY, targetZ); + this.particleMaxAge = maxAge; + } - public AdvancedSeekerParticle(World world, double x, double y, double z, double tX, double tY, double tZ, int type, float red, float green, float blue, int maxAge) { - this(world, x, y, z, tX, tY, tZ, type, maxAge); - this.particleRed = red; - this.particleGreen = green; - this.particleBlue = blue; - } + public AdvancedSeekerParticle(World world, double x, double y, double z, double tX, double tY, double tZ, int type, float red, float green, float blue, int maxAge) { + this(world, x, y, z, tX, tY, tZ, type, maxAge); + this.particleRed = red; + this.particleGreen = green; + this.particleBlue = blue; + } - public AdvancedSeekerParticle(World world, double x, double y, double z, double tX, double tY, double tZ, int type, float red, float green, float blue, int maxAge, int timer) { - this(world, x, y, z, tX, tY, tZ, type, maxAge); - this.particleRed = red; - this.particleGreen = green; - this.particleBlue = blue; - this.timer = timer; - } + public AdvancedSeekerParticle(World world, double x, double y, double z, double tX, double tY, double tZ, int type, float red, float green, float blue, int maxAge, int timer) { + this(world, x, y, z, tX, tY, tZ, type, maxAge); + this.particleRed = red; + this.particleGreen = green; + this.particleBlue = blue; + this.timer = timer; + } - @Override - public void onUpdate() { - switch (behaviour){ - case 1: - behaviour1(); - break; - case 2: - behaviour2(); - break; - case 3: - behaviour3(); - break; - case 4: - behaviour4(); - break; - } + @Override + public void onUpdate() { + switch (behaviour) { + case 1: + behaviour1(); + break; + case 2: + behaviour2(); + break; + case 3: + behaviour3(); + break; + case 4: + behaviour4(); + break; + } - } + } - /**Fade Out*/ - private void behaviour1(){ - if (particleAge > particleMaxAge) setDead(); - if (particleAge + 10 >= particleMaxAge) particleAlpha = ((float)particleMaxAge - (float)particleAge) / 10F; - particleAge ++; - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - moveEntity(motionX, motionY, motionZ); - timer++; - } + /** + * Fade Out + */ + private void behaviour1() { + if (particleAge > particleMaxAge) setDead(); + if (particleAge + 10 >= particleMaxAge) + particleAlpha = ((float) particleMaxAge - (float) particleAge) / 10F; + particleAge++; + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + moveEntity(motionX, motionY, motionZ); + timer++; + } - /**Goes to target and Expand*/ - private void behaviour2(){ - if (particleAge > particleMaxAge) setDead(); - particleAge ++; + /** + * Goes to target and Expand + */ + private void behaviour2() { + if (particleAge > particleMaxAge) setDead(); + particleAge++; - if (particleScale > 0) particleScale -= 0.02F; + if (particleScale > 0) particleScale -= 0.02F; - if (particleAge > particleMaxAge - 10){ - particleScale += 1F; - particleAlpha -= 0.1F; - } + if (particleAge > particleMaxAge - 10) { + particleScale += 1F; + particleAlpha -= 0.1F; + } - float motionMod = 0.001F * Math.max(1F - (float) (particleAge / 50), 0F); - motionX += (targetX - posX) * motionMod; - motionY += (targetY - posY) * motionMod; - motionZ += (targetZ - posZ) * motionMod; + float motionMod = 0.001F * Math.max(1F - (float) (particleAge / 50), 0F); + motionX += (targetX - posX) * motionMod; + motionY += (targetY - posY) * motionMod; + motionZ += (targetZ - posZ) * motionMod; - float directMotMod = 0.05F; - float directMotT = Math.max(1F-((float)particleAge/(float)50), 0F); - directMotMod = (directMotMod * (1F - directMotT)); - motionX = (motionX * directMotT) + (targetX - posX) * directMotMod; - motionY = (motionY * directMotT) + (targetY - posY) * directMotMod; - motionZ = (motionZ * directMotT) + (targetZ - posZ) * directMotMod; + float directMotMod = 0.05F; + float directMotT = Math.max(1F - ((float) particleAge / (float) 50), 0F); + directMotMod = (directMotMod * (1F - directMotT)); + motionX = (motionX * directMotT) + (targetX - posX) * directMotMod; + motionY = (motionY * directMotT) + (targetY - posY) * directMotMod; + motionZ = (motionZ * directMotT) + (targetZ - posZ) * directMotMod; - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - moveEntity(motionX, motionY, motionZ); - timer++; - } + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + moveEntity(motionX, motionY, motionZ); + timer++; + } - /**Go to target and expand with timer*/ - private void behaviour3(){ - if (this.getDistanceSq(targetX, targetY, targetZ) < 0.1 && particleAge < particleMaxAge - 40) particleAge = particleMaxAge - 40; - if (particleAge > particleMaxAge) setDead(); - particleAge ++; + /** + * Go to target and expand with timer + */ + private void behaviour3() { + if (this.getDistanceSq(targetX, targetY, targetZ) < 0.1 && particleAge < particleMaxAge - 40) + particleAge = particleMaxAge - 40; + if (particleAge > particleMaxAge) setDead(); + particleAge++; - if (particleScale > 0) particleScale -= 0.02F; + if (particleScale > 0) particleScale -= 0.02F; - if ((particleRed == 1F || (particleGreen == 1F && particleBlue == 0F)) && particleAge > particleMaxAge - 10){ - int t = timer - 300; - if (timer > 0) particleScale = (float)t / (1F - (particleAge / (particleMaxAge - 10F)) * 100F); - }else if (particleBlue == 1F && particleAge > particleMaxAge - 15){ - int t = timer - 700; - if (timer > 0) particleScale = (float)t / (1F - (particleAge / (particleMaxAge - 10F)) * 100F); - } + if ((particleRed == 1F || (particleGreen == 1F && particleBlue == 0F)) && particleAge > particleMaxAge - 10) { + int t = timer - 300; + if (timer > 0) particleScale = (float) t / (1F - (particleAge / (particleMaxAge - 10F)) * 100F); + } else if (particleBlue == 1F && particleAge > particleMaxAge - 15) { + int t = timer - 700; + if (timer > 0) particleScale = (float) t / (1F - (particleAge / (particleMaxAge - 10F)) * 100F); + } - float motionMod = 0.001F * Math.max(1F - (float) (particleAge / 50), 0F); - motionX += (targetX - posX) * motionMod; - motionY += (targetY - posY) * motionMod; - motionZ += (targetZ - posZ) * motionMod; + float motionMod = 0.001F * Math.max(1F - (float) (particleAge / 50), 0F); + motionX += (targetX - posX) * motionMod; + motionY += (targetY - posY) * motionMod; + motionZ += (targetZ - posZ) * motionMod; - float directMotMod = 0.05F; - float directMotT = Math.max(1F-((float)particleAge/(float)50), 0F); - directMotMod = (directMotMod * (1F - directMotT)); - motionX = (motionX * directMotT) + (targetX - posX) * directMotMod; - motionY = (motionY * directMotT) + (targetY - posY) * directMotMod; - motionZ = (motionZ * directMotT) + (targetZ - posZ) * directMotMod; + float directMotMod = 0.05F; + float directMotT = Math.max(1F - ((float) particleAge / (float) 50), 0F); + directMotMod = (directMotMod * (1F - directMotT)); + motionX = (motionX * directMotT) + (targetX - posX) * directMotMod; + motionY = (motionY * directMotT) + (targetY - posY) * directMotMod; + motionZ = (motionZ * directMotT) + (targetZ - posZ) * directMotMod; - if (particleMaxAge - particleAge < 40 && timer > 2300 && (particleRed == 1F || (particleGreen == 1f && particleBlue == 1f))){ - double yChange = (double)(timer - 2300); - //setPosition(posX, targetY + yChange, posZ); - if (posY < targetY + 60)motionY = yChange * 0.05F; - } + if (particleMaxAge - particleAge < 40 && timer > 2300 && (particleRed == 1F || (particleGreen == 1f && particleBlue == 1f))) { + double yChange = (double) (timer - 2300); + //setPosition(posX, targetY + yChange, posZ); + if (posY < targetY + 60) motionY = yChange * 0.05F; + } - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - moveEntity(motionX, motionY, motionZ); - timer++; - } + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + moveEntity(motionX, motionY, motionZ); + timer++; + } - /**Go to target and shrink out of existence*/ - private void behaviour4(){ + /** + * Go to target and shrink out of existence + */ + private void behaviour4() { - } + } - @Override - @SideOnly(Side.CLIENT) - public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + @Override + @SideOnly(Side.CLIENT) + public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y - tesselator.draw(); - ResourceHandler.bindParticles(); - tesselator.startDrawingQuads(); - tesselator.setBrightness(200); + tesselator.draw(); + ResourceHandler.bindParticles(); + tesselator.startDrawingQuads(); + tesselator.setBrightness(200); - int uIndex = 0; - int vIndex = 0; + int uIndex = 0; + int vIndex = 0; - float minU = uIndex * 0.125F; - float maxU = (uIndex+1) * 0.12F; - float minV = vIndex * 0.125F; - float maxV = (vIndex+1) * 0.125F; + float minU = uIndex * 0.125F; + float maxU = (uIndex + 1) * 0.12F; + float minV = vIndex * 0.125F; + float maxV = (vIndex + 1) * 0.125F; // float minU = 0.0F + 0F;//(float)this.particleTextureIndexX / 32.0F; // float maxU = 0.0F + 0.1245F;//minU + 0.124F; // float minV = 0F;//(float)this.particleTextureIndexY / 32.0F; // float maxV = 0.1245F;//minV + 0.124F; - float drawScale = 0.1F * this.particleScale; - - if (this.particleIcon != null) { - minU = this.particleIcon.getMinU(); - maxU = this.particleIcon.getMaxU(); - minV = this.particleIcon.getMinV(); - maxV = this.particleIcon.getMaxV(); - } - - float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); - float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); - float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); - - tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); - - //tesselator.setColorRGBA(0, 255, 255, (int) (this.particleAlpha * 255F)); - - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); - - tesselator.draw(); - ResourceHandler.bindDefaultParticles(); - tesselator.startDrawingQuads(); - - } - - } - - public static class TransceiverParticle extends EntityFX - { - public double targetX; - public double targetY; - public double targetZ; - private int textureIndex = 0; - - public TransceiverParticle(World world, double x, double y, double z, double tx, double ty, double tz) { - super(world, x, y, z, 0.0D, 0.0D, 0.0D); - this.targetX = tx; - this.targetY = ty; - this.targetZ = tz; - this.motionX = 0; - this.motionY = 0; - this.motionZ = 0; - this.particleMaxAge = 1000; - this.noClip = true; - this.particleRed = this.particleGreen = this.particleBlue = 1.0f; - } - - @Override - public void onUpdate() { - //super.onUpdate(); - if (particleAge > particleMaxAge) setDead(); - if (particleAge > particleMaxAge || this.getDistanceSq(targetX, targetY, targetZ) < 0.05) setDead(); - particleAge ++; - float speed = (float)particleAge * 0.00002F; - motionX += (targetX - posX) * speed; - motionY += (targetY - posY) * speed; - motionZ += (targetZ - posZ) * speed; - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - moveEntity(motionX, motionY, motionZ); - - textureIndex = worldObj.rand.nextInt(5); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y - - tesselator.draw(); - ResourceHandler.bindParticles(); - tesselator.startDrawingQuads(); - tesselator.setBrightness(200); - - int uIndex = textureIndex; - int vIndex = 1; - - float minU = uIndex * 0.125F; - float maxU = (uIndex+1) * 0.125F; - float minV = vIndex * 0.125F; - float maxV = (vIndex+1) * 0.125F; - - float drawScale = 0.1F * this.particleScale; - - if (this.particleIcon != null) { - minU = this.particleIcon.getMinU(); - maxU = this.particleIcon.getMaxU(); - minV = this.particleIcon.getMinV(); - maxV = this.particleIcon.getMaxV(); - } - - float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); - float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); - float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); - - tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); - - //tesselator.setColorRGBA(0, 255, 255, (int) (this.particleAlpha * 255F)); - - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); - - tesselator.draw(); - ResourceHandler.bindDefaultParticles(); - tesselator.startDrawingQuads(); - - } - } - - public static class PortalParticle extends EntityFX - { - public double targetX; - public double targetY; - public double targetZ; - public double startX; - public double startY; - public double startZ; - public float baseScale; - - public PortalParticle(World world, double x, double y, double z, double tx, double ty, double tz) { - super(world, x, y, z, 0.0D, 0.0D, 0.0D); - this.startX = x; - this.startY = y; - this.startZ = z; - this.targetX = tx; - this.targetY = ty; - this.targetZ = tz; - float speed = 0.12F + (rand.nextFloat() * 0.2F); - this.motionX = (targetX - startX) * speed; - this.motionY = (targetY - startY) * speed; - this.motionZ = (targetZ - startZ) * speed; - this.particleMaxAge = 100; - this.noClip = true; - this.particleRed = this.particleGreen = this.particleBlue = 1.0f; - float baseSize = 0.05F + ((float) RenderManager.instance.livingPlayer.getDistance(x, y, z)) * 0.007F; - if (RenderManager.instance.livingPlayer != null) this.baseScale = baseSize + (rand.nextFloat() * (baseSize * 2F)); - } - - @Override - public void onUpdate() { - //super.onUpdate(); - if (particleAge >= particleMaxAge || this.getDistanceSq(targetX, targetY, targetZ) < 0.05) setDead(); - - double d1 = Utills.getDistanceAtoB(startX, startY, startZ, targetX, targetY, targetZ); - double d2 = Utills.getDistanceAtoB(posX, posY, posZ, targetX, targetY, targetZ); - particleScale = ((float) (d2 / d1)) * baseScale; - - particleAge ++; - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - moveEntity(motionX, motionY, motionZ); - - } - - @Override - @SideOnly(Side.CLIENT) - public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y - - tesselator.draw(); - ResourceHandler.bindParticles(); - tesselator.startDrawingQuads(); - tesselator.setBrightness(200); - - int uIndex = 6; - int vIndex = 0; - - float minU = uIndex * 0.125F; - float maxU = (uIndex+1) * 0.125F; - float minV = vIndex * 0.125F; - float maxV = (vIndex+1) * 0.125F; - - float drawScale = 0.1F * this.particleScale; - - if (this.particleIcon != null) { - minU = this.particleIcon.getMinU(); - maxU = this.particleIcon.getMaxU(); - minV = this.particleIcon.getMinV(); - maxV = this.particleIcon.getMaxV(); - } - - float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); - float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); - float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); - - tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); - - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); - - tesselator.draw(); - ResourceHandler.bindDefaultParticles(); - tesselator.startDrawingQuads(); - - } - } - - public static class ReactorExplosionParticle extends EntityFX - { - public static IModelCustom uvSphere; - public double size = 0; - public double maxSize; - - public ReactorExplosionParticle(World world, double x, double y, double z, double maxSize) { - super(world, x, y, z, 0D, 0D, 0D); - if (uvSphere == null) uvSphere = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/reactorCoreModel.obj")); - this.maxSize = maxSize; - } - - @Override - public void onUpdate() { - if (particleAge == 3) worldObj.playSound(posX, posY, posZ, "DraconicEvolution:fusionExplosion", 100F, 1F, false); - particleAge++; - size++; - if (size > maxSize * 1.2) setDead(); - - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - } - - @Override - @SideOnly(Side.CLIENT) - public void renderParticle(Tessellator tessellator, float partialTick, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y - - tessellator.draw(); - GL11.glPushMatrix(); - float xx = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTick - interpPosX); - float yy = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTick - interpPosY); - float zz = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTick - interpPosZ); - GL11.glTranslated((double)xx + 0.5, (double)yy + 0.5, (double)zz + 0.5); - - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); - ResourceHandler.bindResource("textures/models/white.png"); - double s = size + partialTick * 1F; - GL11.glScaled(s, s/4, s); - - - //Leading edge - GL11.glPushMatrix(); - float a = (float)Math.max(0D, 0.3D - (size / (maxSize))); - GL11.glColor4f(1F, 0.4F, 0F, a); - GL11.glScaled(5, 10, 5); - if (a > 0)uvSphere.renderAll(); - GL11.glPopMatrix(); - - //Disk - GL11.glPushMatrix(); - a = (float)Math.max(0D, 0.5D - ((size / (maxSize)) * 0.5D)); - GL11.glColor4f(1F, 0.4F, 0F, a); - GL11.glScaled(2, 0.2, 2); - if (a > 0)uvSphere.renderAll(); - GL11.glPopMatrix(); - - //Synced edge - GL11.glPushMatrix(); - a = (float)Math.max(0D, 0.5D - ((size / (maxSize)) * 0.5D)); - GL11.glColor4f(1F, 0.4F, 0F, a); - if (a > 0)uvSphere.renderAll(); - GL11.glPopMatrix(); - - GL11.glScalef(1.5F, 1.5F, 1.5F); - - //Inner edges - GL11.glPushMatrix(); - a = (float)Math.max(0D, 0.5D - ((size / (maxSize)) * 0.5D)); - GL11.glColor4f(1F, 0.4F, 0F, a); - GL11.glScaled(0.8, 0.6, 0.8); - if (a > 0)uvSphere.renderAll(); - - GL11.glColor4f(1F, 0.5F, 0.1F, a); - GL11.glScaled(0.8, 0.7, 0.8); - if (a > 0)uvSphere.renderAll(); - - GL11.glColor4f(1F, 0.6F, 0.25F, a); - GL11.glScaled(0.7, 0.9, 0.7); - if (a > 0)uvSphere.renderAll(); - - GL11.glColor4f(1F, 0.7F, 0.4F, a); - GL11.glScaled(0.6, 0.9, 0.6); - if (a > 0)uvSphere.renderAll(); - - GL11.glColor4f(1F, 0.8F, 0.55F, a); - GL11.glScaled(0.5, 0.9, 0.5); - if (a > 0)uvSphere.renderAll(); - - GL11.glPopMatrix(); - - for (int i = 0; i < 10; i++) - { - GL11.glScalef(0.95F, 0.95F, 0.95F); - GL11.glPushMatrix(); - a = (float)Math.max(0D, 0.5D - ((size / (maxSize)) * 0.5D)); - GL11.glColor4f(1F, 0.4F, 0F, a); - GL11.glScaled(0.8, 0.6, 0.8); - if (a > 0)uvSphere.renderAll(); - - GL11.glColor4f(1F, 0.5F, 0.1F, a); - GL11.glScaled(0.8, 0.7, 0.8); - if (a > 0)uvSphere.renderAll(); - - GL11.glColor4f(1F, 0.6F, 0.25F, a); - GL11.glScaled(0.7, 0.9, 0.7); - if (a > 0)uvSphere.renderAll(); - - GL11.glColor4f(1F, 0.7F, 0.4F, a); - GL11.glScaled(0.6, 0.9, 0.6); - if (a > 0)uvSphere.renderAll(); - - GL11.glColor4f(1F, 0.8F, 0.55F, a); - GL11.glScaled(0.5, 0.9, 0.5); - if (a > 0)uvSphere.renderAll(); - GL11.glPopMatrix(); - } - - - - - - - - - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glPopMatrix(); - ResourceHandler.bindDefaultParticles(); - tessellator.startDrawingQuads(); - } - } - - public static class ChaosImplosionParticle extends EntityFX - { - public static IModelCustom uvSphere; - public double size = 0; - public double maxSize; - - public ChaosImplosionParticle(World world, double x, double y, double z, double maxSize) { - super(world, x, y, z, 0D, 0D, 0D); - if (uvSphere == null) uvSphere = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/reactorCoreModel.obj")); - this.maxSize = maxSize; - } - - @Override - public void onUpdate() { - //if (particleAge == 3) worldObj.playSound(posX, posY, posZ, "DraconicEvolution:fusionExplosion", 100F, 1F, false); - particleAge++; - size++; - if (size > maxSize * 1.2) setDead(); - - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - } - - @Override - @SideOnly(Side.CLIENT) - public void renderParticle(Tessellator tessellator, float partialTick, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y - - tessellator.draw(); - GL11.glPushMatrix(); - float xx = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTick - interpPosX); - float yy = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTick - interpPosY); - float zz = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTick - interpPosZ); - GL11.glTranslated((double)xx + 0.5, (double)yy + 0.5, (double)zz + 0.5); - - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); - ResourceHandler.bindResource("textures/models/white.png"); - double s = size + partialTick * 1F; - GL11.glScaled(s, s/4, s); - - - //Leading edge - GL11.glPushMatrix(); - float a = (float)Math.max(0D, 0.3D - (size / (maxSize))); - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glScaled(5, 10, 5); - if (a > 0)uvSphere.renderAll(); - GL11.glPopMatrix(); + float drawScale = 0.1F * this.particleScale; + + if (this.particleIcon != null) { + minU = this.particleIcon.getMinU(); + maxU = this.particleIcon.getMaxU(); + minV = this.particleIcon.getMinV(); + maxV = this.particleIcon.getMaxV(); + } + + float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); + float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); + float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); + + tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); + + //tesselator.setColorRGBA(0, 255, 255, (int) (this.particleAlpha * 255F)); + + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); + + tesselator.draw(); + ResourceHandler.bindDefaultParticles(); + tesselator.startDrawingQuads(); + + } + + } + + public static class TransceiverParticle extends EntityFX { + public double targetX; + public double targetY; + public double targetZ; + private int textureIndex = 0; + + public TransceiverParticle(World world, double x, double y, double z, double tx, double ty, double tz) { + super(world, x, y, z, 0.0D, 0.0D, 0.0D); + this.targetX = tx; + this.targetY = ty; + this.targetZ = tz; + this.motionX = 0; + this.motionY = 0; + this.motionZ = 0; + this.particleMaxAge = 1000; + this.noClip = true; + this.particleRed = this.particleGreen = this.particleBlue = 1.0f; + } + + @Override + public void onUpdate() { + //super.onUpdate(); + if (particleAge > particleMaxAge) setDead(); + if (particleAge > particleMaxAge || this.getDistanceSq(targetX, targetY, targetZ) < 0.05) setDead(); + particleAge++; + float speed = (float) particleAge * 0.00002F; + motionX += (targetX - posX) * speed; + motionY += (targetY - posY) * speed; + motionZ += (targetZ - posZ) * speed; + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + moveEntity(motionX, motionY, motionZ); + + textureIndex = worldObj.rand.nextInt(5); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + + tesselator.draw(); + ResourceHandler.bindParticles(); + tesselator.startDrawingQuads(); + tesselator.setBrightness(200); + + int uIndex = textureIndex; + int vIndex = 1; + + float minU = uIndex * 0.125F; + float maxU = (uIndex + 1) * 0.125F; + float minV = vIndex * 0.125F; + float maxV = (vIndex + 1) * 0.125F; + + float drawScale = 0.1F * this.particleScale; + + if (this.particleIcon != null) { + minU = this.particleIcon.getMinU(); + maxU = this.particleIcon.getMaxU(); + minV = this.particleIcon.getMinV(); + maxV = this.particleIcon.getMaxV(); + } + + float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); + float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); + float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); + + tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); + + //tesselator.setColorRGBA(0, 255, 255, (int) (this.particleAlpha * 255F)); + + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); + + tesselator.draw(); + ResourceHandler.bindDefaultParticles(); + tesselator.startDrawingQuads(); + + } + } + + public static class PortalParticle extends EntityFX { + public double targetX; + public double targetY; + public double targetZ; + public double startX; + public double startY; + public double startZ; + public float baseScale; + + public PortalParticle(World world, double x, double y, double z, double tx, double ty, double tz) { + super(world, x, y, z, 0.0D, 0.0D, 0.0D); + this.startX = x; + this.startY = y; + this.startZ = z; + this.targetX = tx; + this.targetY = ty; + this.targetZ = tz; + float speed = 0.12F + (rand.nextFloat() * 0.2F); + this.motionX = (targetX - startX) * speed; + this.motionY = (targetY - startY) * speed; + this.motionZ = (targetZ - startZ) * speed; + this.particleMaxAge = 100; + this.noClip = true; + this.particleRed = this.particleGreen = this.particleBlue = 1.0f; + float baseSize = 0.05F + ((float) RenderManager.instance.livingPlayer.getDistance(x, y, z)) * 0.007F; + if (RenderManager.instance.livingPlayer != null) + this.baseScale = baseSize + (rand.nextFloat() * (baseSize * 2F)); + } + + @Override + public void onUpdate() { + //super.onUpdate(); + if (particleAge >= particleMaxAge || this.getDistanceSq(targetX, targetY, targetZ) < 0.05) setDead(); + + double d1 = Utills.getDistanceAtoB(startX, startY, startZ, targetX, targetY, targetZ); + double d2 = Utills.getDistanceAtoB(posX, posY, posZ, targetX, targetY, targetZ); + particleScale = ((float) (d2 / d1)) * baseScale; + + particleAge++; + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + moveEntity(motionX, motionY, motionZ); + + } + + @Override + @SideOnly(Side.CLIENT) + public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + + tesselator.draw(); + ResourceHandler.bindParticles(); + tesselator.startDrawingQuads(); + tesselator.setBrightness(200); + + int uIndex = 6; + int vIndex = 0; + + float minU = uIndex * 0.125F; + float maxU = (uIndex + 1) * 0.125F; + float minV = vIndex * 0.125F; + float maxV = (vIndex + 1) * 0.125F; + + float drawScale = 0.1F * this.particleScale; + + if (this.particleIcon != null) { + minU = this.particleIcon.getMinU(); + maxU = this.particleIcon.getMaxU(); + minV = this.particleIcon.getMinV(); + maxV = this.particleIcon.getMaxV(); + } + + float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); + float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); + float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); + + tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); + + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); + + tesselator.draw(); + ResourceHandler.bindDefaultParticles(); + tesselator.startDrawingQuads(); + + } + } + + public static class ReactorExplosionParticle extends EntityFX { + public static IModelCustom uvSphere; + public double size = 0; + public double maxSize; + + public ReactorExplosionParticle(World world, double x, double y, double z, double maxSize) { + super(world, x, y, z, 0D, 0D, 0D); + if (uvSphere == null) + uvSphere = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/reactorCoreModel.obj")); + this.maxSize = maxSize; + } + + @Override + public void onUpdate() { + if (particleAge == 3) + worldObj.playSound(posX, posY, posZ, "DraconicEvolution:fusionExplosion", 100F, 1F, false); + particleAge++; + size++; + if (size > maxSize * 1.2) setDead(); + + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + } + + @Override + @SideOnly(Side.CLIENT) + public void renderParticle(Tessellator tessellator, float partialTick, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + + tessellator.draw(); + GL11.glPushMatrix(); + float xx = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTick - interpPosX); + float yy = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTick - interpPosY); + float zz = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTick - interpPosZ); + GL11.glTranslated((double) xx + 0.5, (double) yy + 0.5, (double) zz + 0.5); + + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); + ResourceHandler.bindResource("textures/models/white.png"); + double s = size + partialTick * 1F; + GL11.glScaled(s, s / 4, s); + + + //Leading edge + GL11.glPushMatrix(); + float a = (float) Math.max(0D, 0.3D - (size / (maxSize))); + GL11.glColor4f(1F, 0.4F, 0F, a); + GL11.glScaled(5, 10, 5); + if (a > 0) uvSphere.renderAll(); + GL11.glPopMatrix(); + + //Disk + GL11.glPushMatrix(); + a = (float) Math.max(0D, 0.5D - ((size / (maxSize)) * 0.5D)); + GL11.glColor4f(1F, 0.4F, 0F, a); + GL11.glScaled(2, 0.2, 2); + if (a > 0) uvSphere.renderAll(); + GL11.glPopMatrix(); + + //Synced edge + GL11.glPushMatrix(); + a = (float) Math.max(0D, 0.5D - ((size / (maxSize)) * 0.5D)); + GL11.glColor4f(1F, 0.4F, 0F, a); + if (a > 0) uvSphere.renderAll(); + GL11.glPopMatrix(); + + GL11.glScalef(1.5F, 1.5F, 1.5F); + + //Inner edges + GL11.glPushMatrix(); + a = (float) Math.max(0D, 0.5D - ((size / (maxSize)) * 0.5D)); + GL11.glColor4f(1F, 0.4F, 0F, a); + GL11.glScaled(0.8, 0.6, 0.8); + if (a > 0) uvSphere.renderAll(); + + GL11.glColor4f(1F, 0.5F, 0.1F, a); + GL11.glScaled(0.8, 0.7, 0.8); + if (a > 0) uvSphere.renderAll(); + + GL11.glColor4f(1F, 0.6F, 0.25F, a); + GL11.glScaled(0.7, 0.9, 0.7); + if (a > 0) uvSphere.renderAll(); + + GL11.glColor4f(1F, 0.7F, 0.4F, a); + GL11.glScaled(0.6, 0.9, 0.6); + if (a > 0) uvSphere.renderAll(); + + GL11.glColor4f(1F, 0.8F, 0.55F, a); + GL11.glScaled(0.5, 0.9, 0.5); + if (a > 0) uvSphere.renderAll(); + + GL11.glPopMatrix(); + + for (int i = 0; i < 10; i++) { + GL11.glScalef(0.95F, 0.95F, 0.95F); + GL11.glPushMatrix(); + a = (float) Math.max(0D, 0.5D - ((size / (maxSize)) * 0.5D)); + GL11.glColor4f(1F, 0.4F, 0F, a); + GL11.glScaled(0.8, 0.6, 0.8); + if (a > 0) uvSphere.renderAll(); + + GL11.glColor4f(1F, 0.5F, 0.1F, a); + GL11.glScaled(0.8, 0.7, 0.8); + if (a > 0) uvSphere.renderAll(); + + GL11.glColor4f(1F, 0.6F, 0.25F, a); + GL11.glScaled(0.7, 0.9, 0.7); + if (a > 0) uvSphere.renderAll(); + + GL11.glColor4f(1F, 0.7F, 0.4F, a); + GL11.glScaled(0.6, 0.9, 0.6); + if (a > 0) uvSphere.renderAll(); + + GL11.glColor4f(1F, 0.8F, 0.55F, a); + GL11.glScaled(0.5, 0.9, 0.5); + if (a > 0) uvSphere.renderAll(); + GL11.glPopMatrix(); + } + + + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + ResourceHandler.bindDefaultParticles(); + tessellator.startDrawingQuads(); + } + } + + public static class ChaosImplosionParticle extends EntityFX { + public static IModelCustom uvSphere; + public double size = 0; + public double maxSize; + + public ChaosImplosionParticle(World world, double x, double y, double z, double maxSize) { + super(world, x, y, z, 0D, 0D, 0D); + if (uvSphere == null) + uvSphere = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/reactorCoreModel.obj")); + this.maxSize = maxSize; + } + + @Override + public void onUpdate() { + //if (particleAge == 3) worldObj.playSound(posX, posY, posZ, "DraconicEvolution:fusionExplosion", 100F, 1F, false); + particleAge++; + size++; + if (size > maxSize * 1.2) setDead(); + + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + } + + @Override + @SideOnly(Side.CLIENT) + public void renderParticle(Tessellator tessellator, float partialTick, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + + tessellator.draw(); + GL11.glPushMatrix(); + float xx = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTick - interpPosX); + float yy = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTick - interpPosY); + float zz = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTick - interpPosZ); + GL11.glTranslated((double) xx + 0.5, (double) yy + 0.5, (double) zz + 0.5); + + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); + ResourceHandler.bindResource("textures/models/white.png"); + double s = size + partialTick * 1F; + GL11.glScaled(s, s / 4, s); + + + //Leading edge + GL11.glPushMatrix(); + float a = (float) Math.max(0D, 0.3D - (size / (maxSize))); + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glScaled(5, 10, 5); + if (a > 0) uvSphere.renderAll(); + GL11.glPopMatrix(); // //Disk // GL11.glPushMatrix(); @@ -846,474 +846,464 @@ public class Particles { // if (a > 0)uvSphere.renderAll(); // GL11.glPopMatrix(); - //Synced edge - GL11.glPushMatrix(); - a = (float)Math.max(0D, 0.5D - ((size / (maxSize)) * 0.5D)); - GL11.glColor4f(1F, 1F, 1F, a); - if (a > 0)uvSphere.renderAll(); - GL11.glPopMatrix(); + //Synced edge + GL11.glPushMatrix(); + a = (float) Math.max(0D, 0.5D - ((size / (maxSize)) * 0.5D)); + GL11.glColor4f(1F, 1F, 1F, a); + if (a > 0) uvSphere.renderAll(); + GL11.glPopMatrix(); - GL11.glScalef(1.5F, 1.5F, 1.5F); + GL11.glScalef(1.5F, 1.5F, 1.5F); - //Inner edges - GL11.glPushMatrix(); - a = (float)Math.max(0D, 0.5D - ((size / (maxSize)) * 0.5D)); - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glScaled(0.8, 0.6, 0.8); - if (a > 0)uvSphere.renderAll(); + //Inner edges + GL11.glPushMatrix(); + a = (float) Math.max(0D, 0.5D - ((size / (maxSize)) * 0.5D)); + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glScaled(0.8, 0.6, 0.8); + if (a > 0) uvSphere.renderAll(); - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glScaled(0.8, 0.7, 0.8); - if (a > 0)uvSphere.renderAll(); + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glScaled(0.8, 0.7, 0.8); + if (a > 0) uvSphere.renderAll(); - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glScaled(0.7, 0.9, 0.7); - if (a > 0)uvSphere.renderAll(); + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glScaled(0.7, 0.9, 0.7); + if (a > 0) uvSphere.renderAll(); - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glScaled(0.6, 0.9, 0.6); - if (a > 0)uvSphere.renderAll(); + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glScaled(0.6, 0.9, 0.6); + if (a > 0) uvSphere.renderAll(); - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glScaled(0.5, 0.9, 0.5); - if (a > 0)uvSphere.renderAll(); + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glScaled(0.5, 0.9, 0.5); + if (a > 0) uvSphere.renderAll(); - GL11.glPopMatrix(); + GL11.glPopMatrix(); - for (int i = 0; i < 10; i++) - { - GL11.glScalef(0.95F, 0.95F, 0.95F); - GL11.glPushMatrix(); - a = (float)Math.max(0D, 0.5D - ((size / (maxSize)) * 0.5D)); - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glScaled(0.8, 0.6, 0.8); - if (a > 0)uvSphere.renderAll(); + for (int i = 0; i < 10; i++) { + GL11.glScalef(0.95F, 0.95F, 0.95F); + GL11.glPushMatrix(); + a = (float) Math.max(0D, 0.5D - ((size / (maxSize)) * 0.5D)); + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glScaled(0.8, 0.6, 0.8); + if (a > 0) uvSphere.renderAll(); - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glScaled(0.8, 0.7, 0.8); - if (a > 0)uvSphere.renderAll(); + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glScaled(0.8, 0.7, 0.8); + if (a > 0) uvSphere.renderAll(); - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glScaled(0.7, 0.9, 0.7); - if (a > 0)uvSphere.renderAll(); + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glScaled(0.7, 0.9, 0.7); + if (a > 0) uvSphere.renderAll(); - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glScaled(0.6, 0.9, 0.6); - if (a > 0)uvSphere.renderAll(); + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glScaled(0.6, 0.9, 0.6); + if (a > 0) uvSphere.renderAll(); - GL11.glColor4f(1F, 1F, 1F, a); - GL11.glScaled(0.5, 0.9, 0.5); - if (a > 0)uvSphere.renderAll(); - GL11.glPopMatrix(); - } + GL11.glColor4f(1F, 1F, 1F, a); + GL11.glScaled(0.5, 0.9, 0.5); + if (a > 0) uvSphere.renderAll(); + GL11.glPopMatrix(); + } + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + ResourceHandler.bindDefaultParticles(); + tessellator.startDrawingQuads(); + } + } + public static class DragonProjectileParticle extends EntityFX { + private EntityDragonProjectile entity; + private int particleColour; + public DragonProjectileParticle(World world, double x, double y, double z, int colour) { + super(world, x, y, z); + this.particleMaxAge = 50; + this.noClip = true; + this.particleColour = colour; + this.particleRed = this.particleGreen = this.particleBlue = 1.0f; + } + public DragonProjectileParticle(World world, double x, double y, double z, EntityDragonProjectile projectile) { + super(world, x, y, z); + this.particleMaxAge = 50; + this.noClip = true; + this.entity = projectile; + this.particleColour = projectile.getParticleColour(); + this.particleRed = this.particleGreen = this.particleBlue = 1.0f; + } - - - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glPopMatrix(); - ResourceHandler.bindDefaultParticles(); - tessellator.startDrawingQuads(); - } - } - - public static class DragonProjectileParticle extends EntityFX - { - private EntityDragonProjectile entity; - private int particleColour; - - public DragonProjectileParticle(World world, double x, double y, double z, int colour) { - super(world, x, y, z); - this.particleMaxAge = 50; - this.noClip = true; - this.particleColour = colour; - this.particleRed = this.particleGreen = this.particleBlue = 1.0f; - } - - public DragonProjectileParticle(World world, double x, double y, double z, EntityDragonProjectile projectile) { - super(world, x, y, z); - this.particleMaxAge = 50; - this.noClip = true; - this.entity = projectile; - this.particleColour = projectile.getParticleColour(); - this.particleRed = this.particleGreen = this.particleBlue = 1.0f; - } - - @Override - public void onUpdate() { - //super.onUpdate(); - if (particleAge >= particleMaxAge) setDead(); + @Override + public void onUpdate() { + //super.onUpdate(); + if (particleAge >= particleMaxAge) setDead(); // // double d1 = Utills.getDistanceAtoB(startX, startY, startZ, targetX, targetY, targetZ); // double d2 = Utills.getDistanceAtoB(posX, posY, posZ, targetX, targetY, targetZ); - //particleScale = ((float) (d2 / d1)) * baseScale; - - particleAlpha = (1F - (float)((double)particleAge / particleMaxAge)); - particleScale = 1F * (1F - (float)((double)particleAge / particleMaxAge)); - - particleAge ++; - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - moveEntity(motionX, motionY, motionZ); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y - tesselator.draw(); - ResourceHandler.bindParticles(); - tesselator.startDrawingQuads(); - tesselator.setBrightness(200); - //GL11.glDepthMask(true); - - int uIndex = 7; - int vIndex = 0; - - float minU = uIndex * 0.125F; - float maxU = (uIndex+1) * 0.125F; - float minV = vIndex * 0.125F; - float maxV = (vIndex+1) * 0.125F; - - float drawScale = 0.1F * this.particleScale; - - if (this.particleIcon != null) { - minU = this.particleIcon.getMinU(); - maxU = this.particleIcon.getMaxU(); - minV = this.particleIcon.getMinV(); - maxV = this.particleIcon.getMaxV(); - } - - float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); - float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); - float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); - - //tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); - tesselator.setColorRGBA_I(particleColour, 0xFF); - - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); - - tesselator.draw(); - ResourceHandler.bindDefaultParticles(); - tesselator.startDrawingQuads(); - - } - } - - public static class ChaosBoltParticle extends EntityFX { - - public int timer = 0; - public double focalX; - public double focalY; - public double focalZ; - public double shardX; - public double shardY; - public double shardZ; - - private int mode; - - public ChaosBoltParticle(World world, double x, double y, double z, double shardX, double shardY, double shardZ, int mode) { - super(world, x, y, z, 0.0D, 0.0D, 0.0D); - this.focalX = x; - this.focalY = y; - this.focalZ = z; - this.shardX = shardX; - this.shardY = 79 + rand.nextDouble() * 3; - this.shardZ = shardZ; - if (mode == 0){ - this.motionX = (rand.nextFloat() - 0.5F) * 0.5F; - this.motionY = (rand.nextFloat() - 0.5F) * 0.5F; - this.motionZ = (rand.nextFloat() - 0.5F) * 0.5F; - this.shardY = 80.5; - }else - { - this.motionX = 0; - this.motionY = 0; - this.motionZ = 0; - } - this.mode = mode; - this.particleMaxAge = 100; - this.noClip = true; - this.particleRed = 0; - this.particleGreen = 0; - this.particleBlue = 0; - } - - - @Override - public void onUpdate() { - if (particleAge++ > particleMaxAge) setDead(); - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - - if (mode == 0){ - if (Utills.getDistanceAtoB(posX, posY, posZ, focalX, focalY, focalZ) < 0.2 && particleAge > 5) mode = 1; - double d = Utills.getDistanceAtoB(focalX, focalY, focalZ, shardX, shardY, shardZ); - float motionMod = 0.1F; - motionX += (focalX - posX)/d * motionMod; - motionY += (focalY - posY)/d * motionMod; - motionZ += (focalZ - posZ)/d * motionMod; - } - if (mode == 1){ - if (Utills.getDistanceAtoB(posX, posY, posZ, shardX, shardY, shardZ) < 1) setDead(); - double d = Utills.getDistanceAtoB(focalX, focalY, focalZ, shardX, shardY, shardZ); - particleScale = 1F - (float)d * 0.01F; - float motionMod = 1F; - motionX = (shardX - focalX)/d * motionMod; - motionY = (shardY - focalY)/d * motionMod; - motionZ = (shardZ - focalZ)/d * motionMod; - } - - if (mode == 10){ - if (Utills.getDistanceAtoB(posX, posY, posZ, shardX, shardY, shardZ) < 0.3) setDead(); - double d = Utills.getDistanceAtoB(focalX, focalY, focalZ, shardX, shardY, shardZ); - float motionMod = 0.4F; - motionX = (shardX - focalX)/d * motionMod; - motionY = (shardY - focalY)/d * motionMod; - motionZ = (shardZ - focalZ)/d * motionMod; - } - moveEntity(motionX, motionY, motionZ); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y - - tesselator.draw(); - ResourceHandler.bindParticles(); - - int uIndex = particleAge%5; - int vIndex = 1; - - float minU = uIndex * 0.125F; - float maxU = (uIndex+1) * 0.125F; - float minV = vIndex * 0.125F; - float maxV = (vIndex+1) * 0.125F; - - float drawScale = 0.2F * this.particleScale; - - if (this.particleIcon != null) { - minU = this.particleIcon.getMinU(); - maxU = this.particleIcon.getMaxU(); - minV = this.particleIcon.getMinV(); - maxV = this.particleIcon.getMaxV(); - } - - float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); - float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); - float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); - - tesselator.startDrawingQuads(); - tesselator.setBrightness(200); - tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); - - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); - - tesselator.draw(); - - ResourceHandler.bindDefaultParticles(); - tesselator.startDrawingQuads(); - - } - - } - - public static class ChaosExpansionParticle extends EntityFX - { - public static IModelCustom uvSphere; - private final boolean shrink; - public double size = 0; - public double maxSize = 20; - - public ChaosExpansionParticle(World world, double x, double y, double z, boolean shrink) { - super(world, x, y, z, 0D, 0D, 0D); - this.shrink = shrink; - if (uvSphere == null) uvSphere = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/reactorCoreModel.obj")); - if (shrink){ - size = 20; - } - } - - @Override - public void onUpdate() { - particleAge++; - if (shrink)size--; - else size++; - if (size > maxSize * 1 || size < 0) setDead(); - - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - } - - @Override - @SideOnly(Side.CLIENT) - public void renderParticle(Tessellator tessellator, float partialTick, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y - - tessellator.draw(); - GL11.glPushMatrix(); - float xx = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTick - interpPosX); - float yy = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTick - interpPosY); - float zz = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTick - interpPosZ); - GL11.glTranslated((double)xx, (double)yy, (double)zz); - - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); - ResourceHandler.bindResource("textures/models/white.png"); - double s = (size + (partialTick * (shrink ? -1F : 1F))) * 2D; - GL11.glScaled(s, s, s); - - if (shrink) GL11.glColor4f(1F, 1F, 1F, 1F - ((float)size - partialTick) / (float)maxSize); - else GL11.glColor4f(0F, 0F, 0F, 1F - ((float) size - partialTick) / (float) maxSize); - //GL11.glScaled(5, 10, 5); - uvSphere.renderAll(); - - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glPopMatrix(); - ResourceHandler.bindDefaultParticles(); - tessellator.startDrawingQuads(); - } - } - - public static class ArrowParticle extends EntityFX - { - private int particleColour; - private float setScale; - - public ArrowParticle(World world, double x, double y, double z, int colour, float scale) { - super(world, x, y, z); - this.particleMaxAge = 30; - if (scale > 5) particleMaxAge = 10; - this.noClip = true; - this.particleColour = colour; - this.particleRed = this.particleGreen = this.particleBlue = 1.0f; - this.setScale = scale; - } - - @Override - public void onUpdate() { - if (particleAge >= particleMaxAge) setDead(); - - particleAlpha = (1F - (float)((double)particleAge / particleMaxAge)); - particleScale = setScale * (1F - (float)((double)particleAge / particleMaxAge)); - - particleAge ++; - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - moveEntity(motionX, motionY, motionZ); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y - tesselator.draw(); - ResourceHandler.bindParticles(); - tesselator.startDrawingQuads(); - tesselator.setBrightness(200); - //GL11.glDepthMask(true); - - int uIndex = 3; - int vIndex = 1; - - float minU = uIndex * 0.125F; - float maxU = (uIndex+1) * 0.125F; - float minV = vIndex * 0.125F; - float maxV = (vIndex+1) * 0.125F; - - float drawScale = 0.1F * this.particleScale; - - if (this.particleIcon != null) { - minU = this.particleIcon.getMinU(); - maxU = this.particleIcon.getMaxU(); - minV = this.particleIcon.getMinV(); - maxV = this.particleIcon.getMaxV(); - } - - float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); - float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); - float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); - - //tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); - tesselator.setColorRGBA_I(particleColour, 0xFF); - - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); - tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); - tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); - - tesselator.draw(); - ResourceHandler.bindDefaultParticles(); - tesselator.startDrawingQuads(); - - } - } - - public static class ArrowShockParticle extends EntityFX - { - public static IModelCustom uvSphere; - public double size = 0; - public double maxSize; - - public ArrowShockParticle(World world, double x, double y, double z, int maxSize) { - super(world, x, y, z, 0D, 0D, 0D); - if (uvSphere == null) uvSphere = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/reactorCoreModel.obj")); - this.maxSize = maxSize / 100D; - } - - @Override - public void onUpdate() { - //if (particleAge == 3) worldObj.playSound(posX, posY, posZ, "DraconicEvolution:fusionExplosion", 100F, 1F, false); - particleAge++; - size+=1.2; - if (size > maxSize * 1.2) setDead(); - - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - } - - @Override - @SideOnly(Side.CLIENT) - public void renderParticle(Tessellator tessellator, float partialTick, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y - - tessellator.draw(); - GL11.glPushMatrix(); - float xx = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTick - interpPosX); - float yy = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTick - interpPosY); - float zz = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTick - interpPosZ); - GL11.glTranslated((double)xx + 0.5, (double)yy + 0.5, (double)zz + 0.5); - - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); - ResourceHandler.bindResource("textures/models/white.png"); - double s = size + partialTick * 1F; - GL11.glScaled(s, s/3, s); - - - //Leading edge - GL11.glPushMatrix(); - float a = (float)Math.max(0D, 0.3D - (size / (maxSize))); - GL11.glScaled(5, 5, 5); - //if (a > 0)uvSphere.renderAll(); - GL11.glPopMatrix(); + //particleScale = ((float) (d2 / d1)) * baseScale; + + particleAlpha = (1F - (float) ((double) particleAge / particleMaxAge)); + particleScale = 1F * (1F - (float) ((double) particleAge / particleMaxAge)); + + particleAge++; + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + moveEntity(motionX, motionY, motionZ); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + tesselator.draw(); + ResourceHandler.bindParticles(); + tesselator.startDrawingQuads(); + tesselator.setBrightness(200); + //GL11.glDepthMask(true); + + int uIndex = 7; + int vIndex = 0; + + float minU = uIndex * 0.125F; + float maxU = (uIndex + 1) * 0.125F; + float minV = vIndex * 0.125F; + float maxV = (vIndex + 1) * 0.125F; + + float drawScale = 0.1F * this.particleScale; + + if (this.particleIcon != null) { + minU = this.particleIcon.getMinU(); + maxU = this.particleIcon.getMaxU(); + minV = this.particleIcon.getMinV(); + maxV = this.particleIcon.getMaxV(); + } + + float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); + float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); + float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); + + //tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); + tesselator.setColorRGBA_I(particleColour, 0xFF); + + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); + + tesselator.draw(); + ResourceHandler.bindDefaultParticles(); + tesselator.startDrawingQuads(); + + } + } + + public static class ChaosBoltParticle extends EntityFX { + + public int timer = 0; + public double focalX; + public double focalY; + public double focalZ; + public double shardX; + public double shardY; + public double shardZ; + + private int mode; + + public ChaosBoltParticle(World world, double x, double y, double z, double shardX, double shardY, double shardZ, int mode) { + super(world, x, y, z, 0.0D, 0.0D, 0.0D); + this.focalX = x; + this.focalY = y; + this.focalZ = z; + this.shardX = shardX; + this.shardY = 79 + rand.nextDouble() * 3; + this.shardZ = shardZ; + if (mode == 0) { + this.motionX = (rand.nextFloat() - 0.5F) * 0.5F; + this.motionY = (rand.nextFloat() - 0.5F) * 0.5F; + this.motionZ = (rand.nextFloat() - 0.5F) * 0.5F; + this.shardY = 80.5; + } else { + this.motionX = 0; + this.motionY = 0; + this.motionZ = 0; + } + this.mode = mode; + this.particleMaxAge = 100; + this.noClip = true; + this.particleRed = 0; + this.particleGreen = 0; + this.particleBlue = 0; + } + + + @Override + public void onUpdate() { + if (particleAge++ > particleMaxAge) setDead(); + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + if (mode == 0) { + if (Utills.getDistanceAtoB(posX, posY, posZ, focalX, focalY, focalZ) < 0.2 && particleAge > 5) mode = 1; + double d = Utills.getDistanceAtoB(focalX, focalY, focalZ, shardX, shardY, shardZ); + float motionMod = 0.1F; + motionX += (focalX - posX) / d * motionMod; + motionY += (focalY - posY) / d * motionMod; + motionZ += (focalZ - posZ) / d * motionMod; + } + if (mode == 1) { + if (Utills.getDistanceAtoB(posX, posY, posZ, shardX, shardY, shardZ) < 1) setDead(); + double d = Utills.getDistanceAtoB(focalX, focalY, focalZ, shardX, shardY, shardZ); + particleScale = 1F - (float) d * 0.01F; + float motionMod = 1F; + motionX = (shardX - focalX) / d * motionMod; + motionY = (shardY - focalY) / d * motionMod; + motionZ = (shardZ - focalZ) / d * motionMod; + } + + if (mode == 10) { + if (Utills.getDistanceAtoB(posX, posY, posZ, shardX, shardY, shardZ) < 0.3) setDead(); + double d = Utills.getDistanceAtoB(focalX, focalY, focalZ, shardX, shardY, shardZ); + float motionMod = 0.4F; + motionX = (shardX - focalX) / d * motionMod; + motionY = (shardY - focalY) / d * motionMod; + motionZ = (shardZ - focalZ) / d * motionMod; + } + moveEntity(motionX, motionY, motionZ); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + + tesselator.draw(); + ResourceHandler.bindParticles(); + + int uIndex = particleAge % 5; + int vIndex = 1; + + float minU = uIndex * 0.125F; + float maxU = (uIndex + 1) * 0.125F; + float minV = vIndex * 0.125F; + float maxV = (vIndex + 1) * 0.125F; + + float drawScale = 0.2F * this.particleScale; + + if (this.particleIcon != null) { + minU = this.particleIcon.getMinU(); + maxU = this.particleIcon.getMaxU(); + minV = this.particleIcon.getMinV(); + maxV = this.particleIcon.getMaxV(); + } + + float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); + float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); + float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); + + tesselator.startDrawingQuads(); + tesselator.setBrightness(200); + tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); + + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); + + tesselator.draw(); + + ResourceHandler.bindDefaultParticles(); + tesselator.startDrawingQuads(); + + } + + } + + public static class ChaosExpansionParticle extends EntityFX { + public static IModelCustom uvSphere; + private final boolean shrink; + public double size = 0; + public double maxSize = 20; + + public ChaosExpansionParticle(World world, double x, double y, double z, boolean shrink) { + super(world, x, y, z, 0D, 0D, 0D); + this.shrink = shrink; + if (uvSphere == null) + uvSphere = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/reactorCoreModel.obj")); + if (shrink) { + size = 20; + } + } + + @Override + public void onUpdate() { + particleAge++; + if (shrink) size--; + else size++; + if (size > maxSize * 1 || size < 0) setDead(); + + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + } + + @Override + @SideOnly(Side.CLIENT) + public void renderParticle(Tessellator tessellator, float partialTick, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + + tessellator.draw(); + GL11.glPushMatrix(); + float xx = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTick - interpPosX); + float yy = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTick - interpPosY); + float zz = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTick - interpPosZ); + GL11.glTranslated((double) xx, (double) yy, (double) zz); + + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); + ResourceHandler.bindResource("textures/models/white.png"); + double s = (size + (partialTick * (shrink ? -1F : 1F))) * 2D; + GL11.glScaled(s, s, s); + + if (shrink) GL11.glColor4f(1F, 1F, 1F, 1F - ((float) size - partialTick) / (float) maxSize); + else GL11.glColor4f(0F, 0F, 0F, 1F - ((float) size - partialTick) / (float) maxSize); + //GL11.glScaled(5, 10, 5); + uvSphere.renderAll(); + + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + ResourceHandler.bindDefaultParticles(); + tessellator.startDrawingQuads(); + } + } + + public static class ArrowParticle extends EntityFX { + private int particleColour; + private float setScale; + + public ArrowParticle(World world, double x, double y, double z, int colour, float scale) { + super(world, x, y, z); + this.particleMaxAge = 30; + if (scale > 5) particleMaxAge = 10; + this.noClip = true; + this.particleColour = colour; + this.particleRed = this.particleGreen = this.particleBlue = 1.0f; + this.setScale = scale; + } + + @Override + public void onUpdate() { + if (particleAge >= particleMaxAge) setDead(); + + particleAlpha = (1F - (float) ((double) particleAge / particleMaxAge)); + particleScale = setScale * (1F - (float) ((double) particleAge / particleMaxAge)); + + particleAge++; + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + moveEntity(motionX, motionY, motionZ); + } + + @Override + @SideOnly(Side.CLIENT) + public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + tesselator.draw(); + ResourceHandler.bindParticles(); + tesselator.startDrawingQuads(); + tesselator.setBrightness(200); + //GL11.glDepthMask(true); + + int uIndex = 3; + int vIndex = 1; + + float minU = uIndex * 0.125F; + float maxU = (uIndex + 1) * 0.125F; + float minV = vIndex * 0.125F; + float maxV = (vIndex + 1) * 0.125F; + + float drawScale = 0.1F * this.particleScale; + + if (this.particleIcon != null) { + minU = this.particleIcon.getMinU(); + maxU = this.particleIcon.getMaxU(); + minV = this.particleIcon.getMinV(); + maxV = this.particleIcon.getMaxV(); + } + + float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); + float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); + float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); + + //tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); + tesselator.setColorRGBA_I(particleColour, 0xFF); + + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); + + tesselator.draw(); + ResourceHandler.bindDefaultParticles(); + tesselator.startDrawingQuads(); + + } + } + + public static class ArrowShockParticle extends EntityFX { + public static IModelCustom uvSphere; + public double size = 0; + public double maxSize; + + public ArrowShockParticle(World world, double x, double y, double z, int maxSize) { + super(world, x, y, z, 0D, 0D, 0D); + if (uvSphere == null) + uvSphere = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/reactorCoreModel.obj")); + this.maxSize = maxSize / 100D; + } + + @Override + public void onUpdate() { + //if (particleAge == 3) worldObj.playSound(posX, posY, posZ, "DraconicEvolution:fusionExplosion", 100F, 1F, false); + particleAge++; + size += 1.2; + if (size > maxSize * 1.2) setDead(); + + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + } + + @Override + @SideOnly(Side.CLIENT) + public void renderParticle(Tessellator tessellator, float partialTick, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + + tessellator.draw(); + GL11.glPushMatrix(); + float xx = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTick - interpPosX); + float yy = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTick - interpPosY); + float zz = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTick - interpPosZ); + GL11.glTranslated((double) xx + 0.5, (double) yy + 0.5, (double) zz + 0.5); + + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); + ResourceHandler.bindResource("textures/models/white.png"); + double s = size + partialTick * 1F; + GL11.glScaled(s, s / 3, s); + + + //Leading edge + GL11.glPushMatrix(); + float a = (float) Math.max(0D, 0.3D - (size / (maxSize))); + GL11.glScaled(5, 5, 5); + //if (a > 0)uvSphere.renderAll(); + GL11.glPopMatrix(); // //Disk // GL11.glPushMatrix(); @@ -1323,12 +1313,12 @@ public class Particles { // if (a > 0)uvSphere.renderAll(); // GL11.glPopMatrix(); - //Synced edge - GL11.glPushMatrix(); - a = (float)Math.max(0D, 0.5D - ((size / (maxSize)) * 0.5D)); - GL11.glColor4f(1F, 0.1F, 0F, a); - if (a > 0)uvSphere.renderAll(); - GL11.glPopMatrix(); + //Synced edge + GL11.glPushMatrix(); + a = (float) Math.max(0D, 0.5D - ((size / (maxSize)) * 0.5D)); + GL11.glColor4f(1F, 0.1F, 0F, a); + if (a > 0) uvSphere.renderAll(); + GL11.glPopMatrix(); // GL11.glScalef(1.5F, 1.5F, 1.5F); // @@ -1385,18 +1375,12 @@ public class Particles { // } - - - - - - - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glPopMatrix(); - ResourceHandler.bindDefaultParticles(); - tessellator.startDrawingQuads(); - } - } + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + ResourceHandler.bindDefaultParticles(); + tessellator.startDrawingQuads(); + } + } } //int uIndex = 0; diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileChaosShard.java b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileChaosShard.java index 490cbac4..40236c2d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileChaosShard.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileChaosShard.java @@ -15,78 +15,77 @@ import org.lwjgl.opengl.GL11; * Created by brandon3055 on 24/9/2015. */ public class RenderTileChaosShard extends TileEntitySpecialRenderer { - public static IModelCustom model = AdvancedModelLoader.loadModel(ResourceHandler.getResource("models/chaosCrystal.obj")); + public static IModelCustom model = AdvancedModelLoader.loadModel(ResourceHandler.getResource("models/chaosCrystal.obj")); - @Override - public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float tick) { - renderTileEntityAt((TileChaosShard)tile, x, y, z, tick); - } + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float tick) { + renderTileEntityAt((TileChaosShard) tile, x, y, z, tick); + } - private void renderTileEntityAt(TileChaosShard tile, double x, double y, double z, float tick) { - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5D, y + 0.5D, z + 0.5D); + private void renderTileEntityAt(TileChaosShard tile, double x, double y, double z, float tick) { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5D, y + 0.5D, z + 0.5D); - GL11.glRotatef(((float)tile.tick + tick), 0, 1, 0); - ResourceHandler.bindResource("textures/models/chaosCrystal.png"); - model.renderAll(); + GL11.glRotatef(((float) tile.tick + tick), 0, 1, 0); + ResourceHandler.bindResource("textures/models/chaosCrystal.png"); + model.renderAll(); - GL11.glPopMatrix(); + GL11.glPopMatrix(); - if (!tile.guardianDefeated) - { - GL11.glPushMatrix(); - GL11.glTranslated(0, -4.5, 0); - Tessellator tessellator = Tessellator.instance; - ResourceHandler.bindTexture(ResourceHandler.getResourceWOP("textures/entity/beacon_beam.png")); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDepthMask(true); - OpenGlHelper.glBlendFunc(770, 1, 1, 0); - float f2 = (float) tile.tick + tick; - float f3 = -f2 * 0.2F - (float) MathHelper.floor_float(-f2 * 0.1F); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glDepthMask(false); - tessellator.startDrawingQuads(); - tessellator.setColorRGBA(200, 0, 0, 62); - double size = 0.7F; - double d30 = 0.2D - size; - double d4 = 0.2D - size; - double d6 = 0.8D + size; - double d8 = 0.2D - size; - double d10 = 0.2D - size; - double d12 = 0.8D + size; - double d14 = 0.8D + size; - double d16 = 0.8D + size; - double d18 = 10.0D; //Height - double d20 = 0.0D; - double d22 = 1.0D; - double d24 = (double) (-1.0F + f3); - double d26 = d18 + d24; - tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d22, d26); - tessellator.addVertexWithUV(x + d30, y, z + d4, d22, d24); - tessellator.addVertexWithUV(x + d6, y, z + d8, d20, d24); - tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d20, d26); - tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d22, d26); - tessellator.addVertexWithUV(x + d14, y, z + d16, d22, d24); - tessellator.addVertexWithUV(x + d10, y, z + d12, d20, d24); - tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d20, d26); - tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d22, d26); - tessellator.addVertexWithUV(x + d6, y, z + d8, d22, d24); - tessellator.addVertexWithUV(x + d14, y, z + d16, d20, d24); - tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d20, d26); - tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d22, d26); - tessellator.addVertexWithUV(x + d10, y, z + d12, d22, d24); - tessellator.addVertexWithUV(x + d30, y, z + d4, d20, d24); - tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d20, d26); - tessellator.draw(); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDepthMask(true); - GL11.glPopMatrix(); - } - } + if (!tile.guardianDefeated) { + GL11.glPushMatrix(); + GL11.glTranslated(0, -4.5, 0); + Tessellator tessellator = Tessellator.instance; + ResourceHandler.bindTexture(ResourceHandler.getResourceWOP("textures/entity/beacon_beam.png")); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + OpenGlHelper.glBlendFunc(770, 1, 1, 0); + float f2 = (float) tile.tick + tick; + float f3 = -f2 * 0.2F - (float) MathHelper.floor_float(-f2 * 0.1F); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glDepthMask(false); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA(200, 0, 0, 62); + double size = 0.7F; + double d30 = 0.2D - size; + double d4 = 0.2D - size; + double d6 = 0.8D + size; + double d8 = 0.2D - size; + double d10 = 0.2D - size; + double d12 = 0.8D + size; + double d14 = 0.8D + size; + double d16 = 0.8D + size; + double d18 = 10.0D; //Height + double d20 = 0.0D; + double d22 = 1.0D; + double d24 = (double) (-1.0F + f3); + double d26 = d18 + d24; + tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d22, d26); + tessellator.addVertexWithUV(x + d30, y, z + d4, d22, d24); + tessellator.addVertexWithUV(x + d6, y, z + d8, d20, d24); + tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d20, d26); + tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d22, d26); + tessellator.addVertexWithUV(x + d14, y, z + d16, d22, d24); + tessellator.addVertexWithUV(x + d10, y, z + d12, d20, d24); + tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d20, d26); + tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d22, d26); + tessellator.addVertexWithUV(x + d6, y, z + d8, d22, d24); + tessellator.addVertexWithUV(x + d14, y, z + d16, d20, d24); + tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d20, d26); + tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d22, d26); + tessellator.addVertexWithUV(x + d10, y, z + d12, d22, d24); + tessellator.addVertexWithUV(x + d30, y, z + d4, d20, d24); + tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d20, d26); + tessellator.draw(); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + GL11.glPopMatrix(); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileCrystal.java b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileCrystal.java index 9d3afe54..8fee56f1 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileCrystal.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileCrystal.java @@ -20,143 +20,144 @@ import org.lwjgl.opengl.GL11; */ public class RenderTileCrystal extends TileEntitySpecialRenderer { - private static ResourceLocation texrure = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalPurpleTransparent.png"); - private static ResourceLocation crystalBlue = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalBlue.png"); - private static ResourceLocation crystalBlueAlpha = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalBlueAlpha.png"); - private static ResourceLocation crystalRed = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalRed.png"); - private static ResourceLocation crystalRedAlpha = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalRedAlpha.png"); + private static ResourceLocation texrure = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalPurpleTransparent.png"); + private static ResourceLocation crystalBlue = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalBlue.png"); + private static ResourceLocation crystalBlueAlpha = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalBlueAlpha.png"); + private static ResourceLocation crystalRed = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalRed.png"); + private static ResourceLocation crystalRedAlpha = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/CrystalRedAlpha.png"); - private IModelCustom modelCrystal; - private IModelCustom modelCrystalTransceiver; + private IModelCustom modelCrystal; + private IModelCustom modelCrystalTransceiver; - public RenderTileCrystal(){ - modelCrystal = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/Crystal.obj")); - modelCrystalTransceiver = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/CrystalTransceiver.obj")); - } + public RenderTileCrystal() { + modelCrystal = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/Crystal.obj")); + modelCrystalTransceiver = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/CrystalTransceiver.obj")); + } - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { - if (tileEntity instanceof TileEnergyRelay || tileEntity instanceof TileWirelessEnergyTransceiver) renderEnergyRelay((TileRemoteEnergyBase) tileEntity, x, y, z, partialTick); - else if (tileEntity instanceof TileEnergyTransceiver) renderTransceiver((TileEnergyTransceiver) tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { + if (tileEntity instanceof TileEnergyRelay || tileEntity instanceof TileWirelessEnergyTransceiver) + renderEnergyRelay((TileRemoteEnergyBase) tileEntity, x, y, z, partialTick); + else if (tileEntity instanceof TileEnergyTransceiver) + renderTransceiver((TileEnergyTransceiver) tileEntity, x, y, z, partialTick); + } - public void renderEnergyRelay(TileRemoteEnergyBase tileEntity, double x, double y, double z, float partialTick) { - //--- Pre Render ---// - tileEntity.inView = 10; - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); - GL11.glScalef(0.5f, 0.5f, 0.5f); - RenderHelper.disableStandardItemLighting(); - GL11.glEnable(GL11.GL_BLEND); - float innerLight = 100f; - float outerLight = 140f + ClientEventHandler.energyCrystalAlphaValue * 40F; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, innerLight, innerLight); - OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + public void renderEnergyRelay(TileRemoteEnergyBase tileEntity, double x, double y, double z, float partialTick) { + //--- Pre Render ---// + tileEntity.inView = 10; + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + GL11.glScalef(0.5f, 0.5f, 0.5f); + RenderHelper.disableStandardItemLighting(); + GL11.glEnable(GL11.GL_BLEND); + float innerLight = 100f; + float outerLight = 140f + ClientEventHandler.energyCrystalAlphaValue * 40F; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, innerLight, innerLight); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - //--- Render Bottom Layer ---// - if (tileEntity.getPowerTier() == 0) bindTexture(crystalBlue); - else bindTexture(crystalRed); + //--- Render Bottom Layer ---// + if (tileEntity.getPowerTier() == 0) bindTexture(crystalBlue); + else bindTexture(crystalRed); - modelCrystal.renderAll(); + modelCrystal.renderAll(); - //--- Render Alpha Overlay ---// - if (tileEntity.getPowerTier() == 0) bindTexture(crystalBlueAlpha); - else bindTexture(crystalRedAlpha); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.5f + ClientEventHandler.energyCrystalAlphaValue * 0.5f); + //--- Render Alpha Overlay ---// + if (tileEntity.getPowerTier() == 0) bindTexture(crystalBlueAlpha); + else bindTexture(crystalRedAlpha); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.5f + ClientEventHandler.energyCrystalAlphaValue * 0.5f); - modelCrystal.renderAll(); + modelCrystal.renderAll(); - GL11.glAlphaFunc(GL11.GL_GREATER, 0f); + GL11.glAlphaFunc(GL11.GL_GREATER, 0f); // GL11.glDisable(GL11.GL_ALPHA_TEST); - //--- Render Overlay ---// - bindTexture(texrure); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, outerLight, outerLight); + //--- Render Overlay ---// + bindTexture(texrure); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, outerLight, outerLight); - modelCrystal.renderAll(); + modelCrystal.renderAll(); - //--- Post Render ---// + //--- Post Render ---// GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f); - GL11.glDisable(GL11.GL_BLEND); - RenderHelper.enableStandardItemLighting(); - GL11.glPopMatrix(); - } + GL11.glDisable(GL11.GL_BLEND); + RenderHelper.enableStandardItemLighting(); + GL11.glPopMatrix(); + } - public void renderTransceiver(TileEnergyTransceiver tileEntity, double x, double y, double z, float partialTick) { - //--- Pre Render ---// + public void renderTransceiver(TileEnergyTransceiver tileEntity, double x, double y, double z, float partialTick) { + //--- Pre Render ---// - tileEntity.inView = 10; - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); - GL11.glScalef(0.5f, 0.5f, 0.5f); + tileEntity.inView = 10; + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + GL11.glScalef(0.5f, 0.5f, 0.5f); - switch (tileEntity.facing) - { - case 0: - GL11.glRotatef(180, 0, 0, 1); - break; - case 3: - GL11.glRotatef(90, 1, 0, 0); - break; - case 2: - GL11.glRotatef(90, -1, 0, 0); - break; - case 4: - GL11.glRotatef(90, 0, 0, 1); - break; - case 5: - GL11.glRotatef(90, 0, 0, -1); - break; - } + switch (tileEntity.facing) { + case 0: + GL11.glRotatef(180, 0, 0, 1); + break; + case 3: + GL11.glRotatef(90, 1, 0, 0); + break; + case 2: + GL11.glRotatef(90, -1, 0, 0); + break; + case 4: + GL11.glRotatef(90, 0, 0, 1); + break; + case 5: + GL11.glRotatef(90, 0, 0, -1); + break; + } - GL11.glTranslated(0, -1, 0); + GL11.glTranslated(0, -1, 0); - GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_LIGHTING); // RenderHelper.disableStandardItemLighting(); - GL11.glEnable(GL11.GL_BLEND); - float innerLight = 100f; - float outerLight = 140f + ClientEventHandler.energyCrystalAlphaValue * 40F; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, innerLight, innerLight); - OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GL11.glEnable(GL11.GL_BLEND); + float innerLight = 100f; + float outerLight = 140f + ClientEventHandler.energyCrystalAlphaValue * 40F; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, innerLight, innerLight); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - //--- Render Bottom Layer ---// - if (tileEntity.getPowerTier() == 0) bindTexture(crystalBlue); - else bindTexture(crystalRed); + //--- Render Bottom Layer ---// + if (tileEntity.getPowerTier() == 0) bindTexture(crystalBlue); + else bindTexture(crystalRed); - modelCrystalTransceiver.renderAll(); + modelCrystalTransceiver.renderAll(); - //--- Render Alpha Overlay ---// - if (tileEntity.getPowerTier() == 0) bindTexture(crystalBlueAlpha); - else bindTexture(crystalRedAlpha); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.5f + ClientEventHandler.energyCrystalAlphaValue * 0.5f); - - modelCrystalTransceiver.renderAll(); - - GL11.glDisable(GL11.GL_ALPHA_TEST); - - - //--- Render Overlay ---// - bindTexture(texrure); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, outerLight, outerLight); - - modelCrystalTransceiver.renderAll(); - - - //--- Post Render ---// - GL11.glDisable(GL11.GL_BLEND); -// RenderHelper.enableStandardItemLighting(); - GL11.glEnable(GL11.GL_LIGHTING); + //--- Render Alpha Overlay ---// + if (tileEntity.getPowerTier() == 0) bindTexture(crystalBlueAlpha); + else bindTexture(crystalRedAlpha); GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f); - GL11.glPopMatrix(); - } + GL11.glAlphaFunc(GL11.GL_GREATER, 0.5f + ClientEventHandler.energyCrystalAlphaValue * 0.5f); + + modelCrystalTransceiver.renderAll(); + + GL11.glDisable(GL11.GL_ALPHA_TEST); + + + //--- Render Overlay ---// + bindTexture(texrure); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, outerLight, outerLight); + + modelCrystalTransceiver.renderAll(); + + + //--- Post Render ---// + GL11.glDisable(GL11.GL_BLEND); +// RenderHelper.enableStandardItemLighting(); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileCustomSpawner.java b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileCustomSpawner.java index ca86f7cd..54caf89e 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileCustomSpawner.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileCustomSpawner.java @@ -17,79 +17,76 @@ import net.minecraft.tileentity.TileEntity; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class RenderTileCustomSpawner extends TileEntitySpecialRenderer -{ - public void renderTileEntityAt(TileCustomSpawner tile, double x, double y, double z, float p_147518_8_) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y, (float)z + 0.5F); - renderTile(tile.getBaseLogic(), x, y, z, p_147518_8_); - GL11.glPopMatrix(); - } +public class RenderTileCustomSpawner extends TileEntitySpecialRenderer { + public void renderTileEntityAt(TileCustomSpawner tile, double x, double y, double z, float p_147518_8_) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y, (float) z + 0.5F); + renderTile(tile.getBaseLogic(), x, y, z, p_147518_8_); + GL11.glPopMatrix(); + } - public void renderTile(CustomSpawnerBaseLogic customSpawnerBaseLogic, double x, double y, double z, float partialTick) - { - Tessellator tessellator = Tessellator.instance; + public void renderTile(CustomSpawnerBaseLogic customSpawnerBaseLogic, double x, double y, double z, float partialTick) { + Tessellator tessellator = Tessellator.instance; - Entity entity = customSpawnerBaseLogic.getEntityForRenderer(); + Entity entity = customSpawnerBaseLogic.getEntityForRenderer(); - if (entity != null) - { - if (customSpawnerBaseLogic.powered) partialTick = 0f; - GL11.glPushMatrix(); - entity.setWorld(customSpawnerBaseLogic.getSpawnerWorld()); - float f1 = 0.4375F; - GL11.glTranslatef(0.0F, 0.4F, 0.0F); - GL11.glRotatef((float) (customSpawnerBaseLogic.renderRotation1 + (customSpawnerBaseLogic.renderRotation0 - customSpawnerBaseLogic.renderRotation1) * (double) partialTick) * 10.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F); - GL11.glTranslatef(0.0F, -0.4F, 0.0F); - GL11.glScalef(f1, f1, f1); - entity.setLocationAndAngles(x, y, z, 0.0F, 0.0F); - RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, partialTick); - GL11.glPopMatrix(); - } - { - GL11.glPushMatrix(); + if (entity != null) { + if (customSpawnerBaseLogic.powered) partialTick = 0f; + GL11.glPushMatrix(); + entity.setWorld(customSpawnerBaseLogic.getSpawnerWorld()); + float f1 = 0.4375F; + GL11.glTranslatef(0.0F, 0.4F, 0.0F); + GL11.glRotatef((float) (customSpawnerBaseLogic.renderRotation1 + (customSpawnerBaseLogic.renderRotation0 - customSpawnerBaseLogic.renderRotation1) * (double) partialTick) * 10.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(0.0F, -0.4F, 0.0F); + GL11.glScalef(f1, f1, f1); + entity.setLocationAndAngles(x, y, z, 0.0F, 0.0F); + RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, partialTick); + GL11.glPopMatrix(); + } + { + GL11.glPushMatrix(); - if (customSpawnerBaseLogic.spawnSpeed == 2) ResourceHandler.bindResource("textures/items/wyvernCore.png"); - else if (customSpawnerBaseLogic.spawnSpeed == 3) ResourceHandler.bindResource("textures/items/awakenedCore.png"); - else ResourceHandler.bindResource("textures/items/draconicCore.png"); + if (customSpawnerBaseLogic.spawnSpeed == 2) ResourceHandler.bindResource("textures/items/wyvernCore.png"); + else if (customSpawnerBaseLogic.spawnSpeed == 3) + ResourceHandler.bindResource("textures/items/awakenedCore.png"); + else ResourceHandler.bindResource("textures/items/draconicCore.png"); - tessellator.setColorRGBA(255, 255, 255, 255); - tessellator.setBrightness(200); + tessellator.setColorRGBA(255, 255, 255, 255); + tessellator.setBrightness(200); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, 1.0F); - GL11.glTranslatef(-0.5F, 0F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-0.5F, 0F, -0.5F); - tessellator.addVertexWithUV(0, 0.99D, 0, 0, 0); - tessellator.addVertexWithUV(1, 0.99D, 0, 1, 0); - tessellator.addVertexWithUV(1, 0.99D, 1, 1, 1); - tessellator.addVertexWithUV(0, 0.99D, 1, 0, 1); + tessellator.addVertexWithUV(0, 0.99D, 0, 0, 0); + tessellator.addVertexWithUV(1, 0.99D, 0, 1, 0); + tessellator.addVertexWithUV(1, 0.99D, 1, 1, 1); + tessellator.addVertexWithUV(0, 0.99D, 1, 0, 1); - tessellator.addVertexWithUV(0, 0.99D, 0, 0, 0); - tessellator.addVertexWithUV(0, 0.99D, 1, 1, 0); - tessellator.addVertexWithUV(1, 0.99D, 1, 1, 1); - tessellator.addVertexWithUV(1, 0.99D, 0, 0, 1); + tessellator.addVertexWithUV(0, 0.99D, 0, 0, 0); + tessellator.addVertexWithUV(0, 0.99D, 1, 1, 0); + tessellator.addVertexWithUV(1, 0.99D, 1, 1, 1); + tessellator.addVertexWithUV(1, 0.99D, 0, 0, 1); - tessellator.addVertexWithUV(0, 0.01D, 0, 0, 0); - tessellator.addVertexWithUV(1, 0.01D, 0, 1, 0); - tessellator.addVertexWithUV(1, 0.01D, 1, 1, 1); - tessellator.addVertexWithUV(0, 0.01D, 1, 0, 1); + tessellator.addVertexWithUV(0, 0.01D, 0, 0, 0); + tessellator.addVertexWithUV(1, 0.01D, 0, 1, 0); + tessellator.addVertexWithUV(1, 0.01D, 1, 1, 1); + tessellator.addVertexWithUV(0, 0.01D, 1, 0, 1); - tessellator.addVertexWithUV(0, 0.01D, 0, 0, 0); - tessellator.addVertexWithUV(0, 0.01D, 1, 1, 0); - tessellator.addVertexWithUV(1, 0.01D, 1, 1, 1); - tessellator.addVertexWithUV(1, 0.01D, 0, 0, 1); + tessellator.addVertexWithUV(0, 0.01D, 0, 0, 0); + tessellator.addVertexWithUV(0, 0.01D, 1, 1, 0); + tessellator.addVertexWithUV(1, 0.01D, 1, 1, 1); + tessellator.addVertexWithUV(1, 0.01D, 0, 0, 1); - tessellator.draw(); + tessellator.draw(); - GL11.glPopMatrix(); - } - } - @Override - public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) - { - this.renderTileEntityAt((TileCustomSpawner)p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); - } + GL11.glPopMatrix(); + } + } + + @Override + public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { + this.renderTileEntityAt((TileCustomSpawner) p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileDissEnchanter.java b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileDissEnchanter.java index 415f272d..b2eea370 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileDissEnchanter.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileDissEnchanter.java @@ -14,82 +14,78 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import org.lwjgl.opengl.GL11; -public class RenderTileDissEnchanter extends TileEntitySpecialRenderer -{ +public class RenderTileDissEnchanter extends TileEntitySpecialRenderer { - //private final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/EnergyInfuserTextureSheet.png"); + //private final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/EnergyInfuserTextureSheet.png"); - //private static float pxl = 1F / 256F; + //private static float pxl = 1F / 256F; - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) - { - GL11.glPushMatrix(); - - GL11.glTranslatef((float) x, (float) y, (float) z); - TileDissEnchanter tile = (TileDissEnchanter) tileEntity; - renderBlock(tile, tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, f); - - GL11.glPopMatrix(); - } + @Override + public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { + GL11.glPushMatrix(); - public void renderBlock(TileDissEnchanter tile, World world, int x, int y, int z, float f) - { - Tessellator tessellator = Tessellator.instance; - //bindTexture(texture); + GL11.glTranslatef((float) x, (float) y, (float) z); + TileDissEnchanter tile = (TileDissEnchanter) tileEntity; + renderBlock(tile, tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, f); - tessellator.setColorRGBA(255, 255, 255, 255); - tessellator.setBrightness(200); - int l = world.getLightBrightnessForSkyBlocks(x, y, z, 0); - int l1 = l % 65536; - int l2 = l / 65536; - tessellator.setColorOpaque_F(1f, 1f, 1f); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)l1, (float)l2); + GL11.glPopMatrix(); + } - GL11.glPushMatrix(); - GL11.glRotatef(90, 1, 0, 0); - GL11.glTranslated(0, 1.2, -0.27); - GL11.glRotatef(180, 1, 0, 0); - renderItem(tile, 1, f, false); - GL11.glPopMatrix(); - if (Minecraft.isFancyGraphicsEnabled()) { - GL11.glPushMatrix(); - GL11.glTranslated(0, 0.4, 0); - renderItem(tile, 0, f, true); - GL11.glPopMatrix(); - }else{ - GL11.glPushMatrix(); - GL11.glRotatef(90, 1, 0, 0); - GL11.glTranslated(0, 1.2, -0.37); - GL11.glRotatef(180, 1, 0, 0); - renderItem(tile, 0, f, false); - GL11.glPopMatrix(); - } - } + public void renderBlock(TileDissEnchanter tile, World world, int x, int y, int z, float f) { + Tessellator tessellator = Tessellator.instance; + //bindTexture(texture); - public void renderItem(TileDissEnchanter tile, int i, float f, boolean rotate){ - if (tile.getStackInSlot(i) != null) { - GL11.glPushMatrix(); + tessellator.setColorRGBA(255, 255, 255, 255); + tessellator.setBrightness(200); + int l = world.getLightBrightnessForSkyBlocks(x, y, z, 0); + int l1 = l % 65536; + int l2 = l / 65536; + tessellator.setColorOpaque_F(1f, 1f, 1f); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) l1, (float) l2); - ItemStack stack = tile.getStackInSlot(i).copy(); - stack.stackSize = 1; - EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, stack); - itemEntity.hoverStart = 0.0F; + GL11.glPushMatrix(); + GL11.glRotatef(90, 1, 0, 0); + GL11.glTranslated(0, 1.2, -0.27); + GL11.glRotatef(180, 1, 0, 0); + renderItem(tile, 1, f, false); + GL11.glPopMatrix(); + if (Minecraft.isFancyGraphicsEnabled()) { + GL11.glPushMatrix(); + GL11.glTranslated(0, 0.4, 0); + renderItem(tile, 0, f, true); + GL11.glPopMatrix(); + } else { + GL11.glPushMatrix(); + GL11.glRotatef(90, 1, 0, 0); + GL11.glTranslated(0, 1.2, -0.37); + GL11.glRotatef(180, 1, 0, 0); + renderItem(tile, 0, f, false); + GL11.glPopMatrix(); + } + } - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - GL11.glScalef(1F, 1F, 1F); - if (rotate) GL11.glRotatef(tile.timer+f, 0F, -1F, 0F); - if (stack.getItem() instanceof ItemBlock) - { - GL11.glScalef(1F, 1F, 1F); - GL11.glTranslatef(0F, 0.045F, 0.0f); - } + public void renderItem(TileDissEnchanter tile, int i, float f, boolean rotate) { + if (tile.getStackInSlot(i) != null) { + GL11.glPushMatrix(); - RenderItem.renderInFrame = true; - RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - RenderItem.renderInFrame = false; + ItemStack stack = tile.getStackInSlot(i).copy(); + stack.stackSize = 1; + EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, stack); + itemEntity.hoverStart = 0.0F; - GL11.glPopMatrix(); - } - } + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glScalef(1F, 1F, 1F); + if (rotate) GL11.glRotatef(tile.timer + f, 0F, -1F, 0F); + if (stack.getItem() instanceof ItemBlock) { + GL11.glScalef(1F, 1F, 1F); + GL11.glTranslatef(0F, 0.045F, 0.0f); + } + + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + + GL11.glPopMatrix(); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileDraconiumChest.java b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileDraconiumChest.java index e54204ba..a48907fb 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileDraconiumChest.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileDraconiumChest.java @@ -15,66 +15,65 @@ import static org.lwjgl.opengl.GL11.*; /** * Created by Brandon on 25/10/2014. */ -public class RenderTileDraconiumChest extends TileEntitySpecialRenderer{ +public class RenderTileDraconiumChest extends TileEntitySpecialRenderer { - ModelChest model; - private final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/DraconiumChest.png"); - private Random random; + ModelChest model; + private final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/DraconiumChest.png"); + private Random random; - public RenderTileDraconiumChest() - { - model = new ModelChest(); - random = new Random(); - } + public RenderTileDraconiumChest() { + model = new ModelChest(); + random = new Random(); + } - @Override - public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { - render((TileDraconiumChest) tileentity, x, y, z, f); - } + @Override + public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { + render((TileDraconiumChest) tileentity, x, y, z, f); + } - public void render(TileDraconiumChest tile, double x, double y, double z, float partialTick){ - if (tile == null) { - return; - } - int facing = 3; - if (tile.hasWorldObj()) { - facing = tile.getFacing(); - } - bindTexture(texture); - glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - glEnable(32826 /* GL_RESCALE_NORMAL_EXT */); - glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - float red = (float)(tile.red+50) / 255f; - float green = (float)(tile.green+50) / 255f; - float blue = (float)(tile.blue+50) / 255f; - glColor4f(red, green, blue, 1.0F); - glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F); - glScalef(1.0F, -1F, -1F); - glTranslatef(0.5F, 0.5F, 0.5F); - int k = 0; - if (facing == 2) { - k = 180; - } - if (facing == 3) { - k = 0; - } - if (facing == 4) { - k = 90; - } - if (facing == 5) { - k = -90; - } - glRotatef(k, 0.0F, 1.0F, 0.0F); - glTranslatef(-0.5F, -0.5F, -0.5F); - float lidangle = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * partialTick; - lidangle = 1.0F - lidangle; - lidangle = 1.0F - lidangle * lidangle * lidangle; - model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F); - model.renderAll(); - glDisable(32826 /* GL_RESCALE_NORMAL_EXT */); - GL11.glPopAttrib(); - glPopMatrix(); - glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - } + public void render(TileDraconiumChest tile, double x, double y, double z, float partialTick) { + if (tile == null) { + return; + } + int facing = 3; + if (tile.hasWorldObj()) { + facing = tile.getFacing(); + } + bindTexture(texture); + glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + glEnable(32826 /* GL_RESCALE_NORMAL_EXT */); + glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float red = (float) (tile.red + 50) / 255f; + float green = (float) (tile.green + 50) / 255f; + float blue = (float) (tile.blue + 50) / 255f; + glColor4f(red, green, blue, 1.0F); + glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F); + glScalef(1.0F, -1F, -1F); + glTranslatef(0.5F, 0.5F, 0.5F); + int k = 0; + if (facing == 2) { + k = 180; + } + if (facing == 3) { + k = 0; + } + if (facing == 4) { + k = 90; + } + if (facing == 5) { + k = -90; + } + glRotatef(k, 0.0F, 1.0F, 0.0F); + glTranslatef(-0.5F, -0.5F, -0.5F); + float lidangle = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * partialTick; + lidangle = 1.0F - lidangle; + lidangle = 1.0F - lidangle * lidangle * lidangle; + model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F); + model.renderAll(); + glDisable(32826 /* GL_RESCALE_NORMAL_EXT */); + GL11.glPopAttrib(); + glPopMatrix(); + glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileEnergyInfiser.java b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileEnergyInfiser.java index 49de53de..eeb80de8 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileEnergyInfiser.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileEnergyInfiser.java @@ -13,258 +13,248 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -public class RenderTileEnergyInfiser extends TileEntitySpecialRenderer -{ +public class RenderTileEnergyInfiser extends TileEntitySpecialRenderer { - private final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/EnergyInfuserTextureSheet.png"); + private final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/EnergyInfuserTextureSheet.png"); - private static float pxl = 1F / 256F; + private static float pxl = 1F / 256F; - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) - { - GL11.glPushMatrix(); + @Override + public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { + GL11.glPushMatrix(); - GL11.glTranslatef((float) x, (float) y, (float) z); - TileEnergyInfuser tile = (TileEnergyInfuser) tileEntity; - renderBlock(tile); + GL11.glTranslatef((float) x, (float) y, (float) z); + TileEnergyInfuser tile = (TileEnergyInfuser) tileEntity; + renderBlock(tile); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - public void renderBlock(TileEnergyInfuser tile) - { - Tessellator tessellator = Tessellator.instance; - bindTexture(texture); + public void renderBlock(TileEnergyInfuser tile) { + Tessellator tessellator = Tessellator.instance; + bindTexture(texture); - tessellator.setColorRGBA(255, 255, 255, 255); + tessellator.setColorRGBA(255, 255, 255, 255); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); - drawBase(tessellator); - drawWings(tessellator, tile); - renderChargingItem(tile); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + drawBase(tessellator); + drawWings(tessellator, tile); + renderChargingItem(tile); - } + } - private void drawBase(Tessellator tess){ - GL11.glPushMatrix(); - tess.startDrawingQuads(); - tess.setNormal(0F, 0F, 1.0F); + private void drawBase(Tessellator tess) { + GL11.glPushMatrix(); + tess.startDrawingQuads(); + tess.setNormal(0F, 0F, 1.0F); - double srcXMin = 0D; - double srcYMin = 0D; - double srcXMax = 64D * pxl; - double srcYMax = 64D * pxl; + double srcXMin = 0D; + double srcYMin = 0D; + double srcXMax = 64D * pxl; + double srcYMax = 64D * pxl; - tess.addVertexWithUV(0, 0.0005D, 0, srcXMin, srcYMin); - tess.addVertexWithUV(1, 0.0005D, 0, srcXMax, srcYMin); - tess.addVertexWithUV(1, 0.0005D, 1, srcXMax, srcYMax); - tess.addVertexWithUV(0, 0.0005D, 1, srcXMin, srcYMax); + tess.addVertexWithUV(0, 0.0005D, 0, srcXMin, srcYMin); + tess.addVertexWithUV(1, 0.0005D, 0, srcXMax, srcYMin); + tess.addVertexWithUV(1, 0.0005D, 1, srcXMax, srcYMax); + tess.addVertexWithUV(0, 0.0005D, 1, srcXMin, srcYMax); - srcXMin = 128D * pxl; - srcYMin = 0D; - srcXMax = 192D * pxl; - srcYMax = 64D * pxl; + srcXMin = 128D * pxl; + srcYMin = 0D; + srcXMax = 192D * pxl; + srcYMax = 64D * pxl; - tess.addVertexWithUV(0, 0.3745D, 0, srcXMin, srcYMin); - tess.addVertexWithUV(0, 0.3745D, 1, srcXMax, srcYMin); - tess.addVertexWithUV(1, 0.3745D, 1, srcXMax, srcYMax); - tess.addVertexWithUV(1, 0.3745D, 0, srcXMin, srcYMax); + tess.addVertexWithUV(0, 0.3745D, 0, srcXMin, srcYMin); + tess.addVertexWithUV(0, 0.3745D, 1, srcXMax, srcYMin); + tess.addVertexWithUV(1, 0.3745D, 1, srcXMax, srcYMax); + tess.addVertexWithUV(1, 0.3745D, 0, srcXMin, srcYMax); - srcXMin = 64D * pxl; - srcYMin = 0D; - srcXMax = 128D * pxl; - srcYMax = 24D * pxl; + srcXMin = 64D * pxl; + srcYMin = 0D; + srcXMax = 128D * pxl; + srcYMax = 24D * pxl; - tess.addVertexWithUV(1, 0, 0, srcXMin, srcYMin); - tess.addVertexWithUV(0, 0, 0, srcXMax, srcYMin); - tess.addVertexWithUV(0, 0.375D, 0, srcXMax, srcYMax); - tess.addVertexWithUV(1, 0.375D, 0, srcXMin, srcYMax); + tess.addVertexWithUV(1, 0, 0, srcXMin, srcYMin); + tess.addVertexWithUV(0, 0, 0, srcXMax, srcYMin); + tess.addVertexWithUV(0, 0.375D, 0, srcXMax, srcYMax); + tess.addVertexWithUV(1, 0.375D, 0, srcXMin, srcYMax); - tess.addVertexWithUV(1, 0, 1, srcXMin, srcYMin); - tess.addVertexWithUV(1, 0.375D, 1, srcXMin, srcYMax); - tess.addVertexWithUV(0, 0.375D, 1, srcXMax, srcYMax); - tess.addVertexWithUV(0, 0, 1, srcXMax, srcYMin); + tess.addVertexWithUV(1, 0, 1, srcXMin, srcYMin); + tess.addVertexWithUV(1, 0.375D, 1, srcXMin, srcYMax); + tess.addVertexWithUV(0, 0.375D, 1, srcXMax, srcYMax); + tess.addVertexWithUV(0, 0, 1, srcXMax, srcYMin); - tess.addVertexWithUV(0, 0.375D, 1, srcXMin, srcYMin); - tess.addVertexWithUV(0, 0.375D, 0, srcXMax, srcYMin); - tess.addVertexWithUV(0, 0, 0, srcXMax, srcYMax); - tess.addVertexWithUV(0, 0, 1, srcXMin, srcYMax); + tess.addVertexWithUV(0, 0.375D, 1, srcXMin, srcYMin); + tess.addVertexWithUV(0, 0.375D, 0, srcXMax, srcYMin); + tess.addVertexWithUV(0, 0, 0, srcXMax, srcYMax); + tess.addVertexWithUV(0, 0, 1, srcXMin, srcYMax); - tess.addVertexWithUV(1, 0.375D, 1, srcXMin, srcYMin); - tess.addVertexWithUV(1, 0, 1, srcXMin, srcYMax); - tess.addVertexWithUV(1, 0, 0, srcXMax, srcYMax); - tess.addVertexWithUV(1, 0.375D, 0, srcXMax, srcYMin); + tess.addVertexWithUV(1, 0.375D, 1, srcXMin, srcYMin); + tess.addVertexWithUV(1, 0, 1, srcXMin, srcYMax); + tess.addVertexWithUV(1, 0, 0, srcXMax, srcYMax); + tess.addVertexWithUV(1, 0.375D, 0, srcXMax, srcYMin); - tess.draw(); - GL11.glPopMatrix(); + tess.draw(); + GL11.glPopMatrix(); - } + } - private void drawWings(Tessellator tess, TileEnergyInfuser tile){ - GL11.glPushMatrix(); - float srcXMin = 0F; //iicon.getMinU(); - float srcYMin = 64F * pxl; //iicon.getMaxU(); - float srcXMax = 92F * pxl; //iicon.getMinV(); - float srcYMax = 115F * pxl; //iicon.getMaxV(); + private void drawWings(Tessellator tess, TileEnergyInfuser tile) { + GL11.glPushMatrix(); + float srcXMin = 0F; //iicon.getMinU(); + float srcYMin = 64F * pxl; //iicon.getMaxU(); + float srcXMax = 92F * pxl; //iicon.getMinV(); + float srcYMax = 115F * pxl; //iicon.getMaxV(); - GL11.glTranslatef(-0.64F, 0.365F, 0.51F); - GL11.glScalef(0.7F, 0.7F, 0.7F); - float xTrans = 0.025F; + GL11.glTranslatef(-0.64F, 0.365F, 0.51F); + GL11.glScalef(0.7F, 0.7F, 0.7F); + float xTrans = 0.025F; - { - GL11.glTranslatef(1.62F, 0F, -xTrans); - GL11.glRotatef(tile.rotation, 0F, 1F, 0F); - GL11.glTranslatef(-1.62F, 0F, xTrans); - render2DWithThicness(tess, srcXMax, srcYMin, srcXMin, srcYMax, 92, 51, 0.0625F); - } - { - GL11.glTranslatef(1.62F, 0F, -xTrans); - GL11.glRotatef(90, 0F, 1F, 0F); - GL11.glTranslatef(-1.62F, 0F, xTrans); - render2DWithThicness(tess, srcXMax, srcYMin, srcXMin, srcYMax, 92, 51, 0.0625F); - } - { - GL11.glTranslatef(1.62F, 0F, -xTrans); - GL11.glRotatef(90, 0F, 1F, 0F); - GL11.glTranslatef(-1.62F, 0F, xTrans); - render2DWithThicness(tess, srcXMax, srcYMin, srcXMin, srcYMax, 92, 51, 0.0625F); - } - { - GL11.glTranslatef(1.62F, 0F, -xTrans); - GL11.glRotatef(90, 0F, 1F, 0F); - GL11.glTranslatef(-1.62F, 0F, xTrans); - render2DWithThicness(tess, srcXMax, srcYMin, srcXMin, srcYMax, 92, 51, 0.0625F); - } - { - srcXMin = 64F * pxl; //iicon.getMinU(); - srcYMin = 24F * pxl; //iicon.getMaxU(); - srcXMax = 96F * pxl; //iicon.getMinV(); - srcYMax = 56F * pxl; //iicon.getMaxV(); - GL11.glTranslatef(1.26F, 0F, 0.31F); - GL11.glTranslatef(0F, 0F, 0F); - GL11.glRotatef(90, 0F, 1F, 0F); - GL11.glRotatef(90, 1F, 0F, 0F); - GL11.glTranslatef(-0F, 0F, 0F); - GL11.glScalef(1.4F, 1.4F, 1.4F); - render2DWithThicness(tess, srcXMax, srcYMin, srcXMin, srcYMax, 32, 32, 0.0625F); - } - GL11.glPopMatrix(); - } + { + GL11.glTranslatef(1.62F, 0F, -xTrans); + GL11.glRotatef(tile.rotation, 0F, 1F, 0F); + GL11.glTranslatef(-1.62F, 0F, xTrans); + render2DWithThicness(tess, srcXMax, srcYMin, srcXMin, srcYMax, 92, 51, 0.0625F); + } + { + GL11.glTranslatef(1.62F, 0F, -xTrans); + GL11.glRotatef(90, 0F, 1F, 0F); + GL11.glTranslatef(-1.62F, 0F, xTrans); + render2DWithThicness(tess, srcXMax, srcYMin, srcXMin, srcYMax, 92, 51, 0.0625F); + } + { + GL11.glTranslatef(1.62F, 0F, -xTrans); + GL11.glRotatef(90, 0F, 1F, 0F); + GL11.glTranslatef(-1.62F, 0F, xTrans); + render2DWithThicness(tess, srcXMax, srcYMin, srcXMin, srcYMax, 92, 51, 0.0625F); + } + { + GL11.glTranslatef(1.62F, 0F, -xTrans); + GL11.glRotatef(90, 0F, 1F, 0F); + GL11.glTranslatef(-1.62F, 0F, xTrans); + render2DWithThicness(tess, srcXMax, srcYMin, srcXMin, srcYMax, 92, 51, 0.0625F); + } + { + srcXMin = 64F * pxl; //iicon.getMinU(); + srcYMin = 24F * pxl; //iicon.getMaxU(); + srcXMax = 96F * pxl; //iicon.getMinV(); + srcYMax = 56F * pxl; //iicon.getMaxV(); + GL11.glTranslatef(1.26F, 0F, 0.31F); + GL11.glTranslatef(0F, 0F, 0F); + GL11.glRotatef(90, 0F, 1F, 0F); + GL11.glRotatef(90, 1F, 0F, 0F); + GL11.glTranslatef(-0F, 0F, 0F); + GL11.glScalef(1.4F, 1.4F, 1.4F); + render2DWithThicness(tess, srcXMax, srcYMin, srcXMin, srcYMax, 32, 32, 0.0625F); + } + GL11.glPopMatrix(); + } - public static void render2DWithThicness(Tessellator tess, float maxU, float minV, float minU, float maxV, int width, int height, float thickness) - { - double pix = 1D / 64D; - tess.startDrawingQuads(); - tess.setNormal(0.0F, 0.0F, 1.0F); - tess.addVertexWithUV(0.0D, 0.0D, 0.0D, (double)maxU, (double)maxV); - tess.addVertexWithUV(width*pix, 0.0D, 0.0D, (double)minU, (double)maxV); - tess.addVertexWithUV(width*pix, height*pix, 0.0D, (double)minU, (double)minV); - tess.addVertexWithUV(0.0D, height*pix, 0.0D, (double) maxU, (double) minV); - tess.draw(); - tess.startDrawingQuads(); - tess.setNormal(0.0F, 0.0F, -1.0F); - tess.addVertexWithUV(0.0D, height*pix, (double) (0.0F - thickness), (double) maxU, (double) minV); - tess.addVertexWithUV(width*pix, height*pix, (double) (0.0F - thickness), (double) minU, (double) minV); - tess.addVertexWithUV(width*pix, 0.0D, (double)(0.0F - thickness), (double)minU, (double)maxV); - tess.addVertexWithUV(0.0D, 0.0D, (double)(0.0F - thickness), (double)maxU, (double)maxV); - tess.draw(); - float f5 = 0.5F * (maxU - minU) / (float)width; - float f6 = 0.5F * (maxV - minV) / (float)height; - tess.startDrawingQuads(); - tess.setNormal(-1.0F, 0.0F, 0.0F); - int k; - float f7; - float f8; - double d; + public static void render2DWithThicness(Tessellator tess, float maxU, float minV, float minU, float maxV, int width, int height, float thickness) { + double pix = 1D / 64D; + tess.startDrawingQuads(); + tess.setNormal(0.0F, 0.0F, 1.0F); + tess.addVertexWithUV(0.0D, 0.0D, 0.0D, (double) maxU, (double) maxV); + tess.addVertexWithUV(width * pix, 0.0D, 0.0D, (double) minU, (double) maxV); + tess.addVertexWithUV(width * pix, height * pix, 0.0D, (double) minU, (double) minV); + tess.addVertexWithUV(0.0D, height * pix, 0.0D, (double) maxU, (double) minV); + tess.draw(); + tess.startDrawingQuads(); + tess.setNormal(0.0F, 0.0F, -1.0F); + tess.addVertexWithUV(0.0D, height * pix, (double) (0.0F - thickness), (double) maxU, (double) minV); + tess.addVertexWithUV(width * pix, height * pix, (double) (0.0F - thickness), (double) minU, (double) minV); + tess.addVertexWithUV(width * pix, 0.0D, (double) (0.0F - thickness), (double) minU, (double) maxV); + tess.addVertexWithUV(0.0D, 0.0D, (double) (0.0F - thickness), (double) maxU, (double) maxV); + tess.draw(); + float f5 = 0.5F * (maxU - minU) / (float) width; + float f6 = 0.5F * (maxV - minV) / (float) height; + tess.startDrawingQuads(); + tess.setNormal(-1.0F, 0.0F, 0.0F); + int k; + float f7; + float f8; + double d; - for (k = 0; k < width; ++k) - { - d = k*pix; - f7 = (float)k / (float)width; - f8 = maxU + (minU - maxU) * f7 - f5; - tess.addVertexWithUV(d, 0.0D, (double)(0.0F - thickness), (double)f8, (double)maxV); - tess.addVertexWithUV(d, 0.0D, 0.0D, (double)f8, (double)maxV); - tess.addVertexWithUV(d, height*pix, 0.0D, (double)f8, (double)minV); - tess.addVertexWithUV(d, height*pix, (double)(0.0F - thickness), (double)f8, (double)minV); - } + for (k = 0; k < width; ++k) { + d = k * pix; + f7 = (float) k / (float) width; + f8 = maxU + (minU - maxU) * f7 - f5; + tess.addVertexWithUV(d, 0.0D, (double) (0.0F - thickness), (double) f8, (double) maxV); + tess.addVertexWithUV(d, 0.0D, 0.0D, (double) f8, (double) maxV); + tess.addVertexWithUV(d, height * pix, 0.0D, (double) f8, (double) minV); + tess.addVertexWithUV(d, height * pix, (double) (0.0F - thickness), (double) f8, (double) minV); + } - tess.draw(); - tess.startDrawingQuads(); - tess.setNormal(1.0F, 0.0F, 0.0F); + tess.draw(); + tess.startDrawingQuads(); + tess.setNormal(1.0F, 0.0F, 0.0F); - for (k = 0; k < width; ++k) - { - d = (k+1)*pix; - f7 = (float)k / (float)width; - f8 = maxU + (minU - maxU) * f7 - f5; - tess.addVertexWithUV(d, height*pix, (double)(0.0F - thickness), (double)f8, (double)minV); - tess.addVertexWithUV(d, height*pix, 0.0D, (double)f8, (double)minV); - tess.addVertexWithUV(d, 0.0D, 0.0D, (double)f8, (double)maxV); - tess.addVertexWithUV(d, 0.0D, (double)(0.0F - thickness), (double)f8, (double)maxV); - } + for (k = 0; k < width; ++k) { + d = (k + 1) * pix; + f7 = (float) k / (float) width; + f8 = maxU + (minU - maxU) * f7 - f5; + tess.addVertexWithUV(d, height * pix, (double) (0.0F - thickness), (double) f8, (double) minV); + tess.addVertexWithUV(d, height * pix, 0.0D, (double) f8, (double) minV); + tess.addVertexWithUV(d, 0.0D, 0.0D, (double) f8, (double) maxV); + tess.addVertexWithUV(d, 0.0D, (double) (0.0F - thickness), (double) f8, (double) maxV); + } - tess.draw(); - tess.startDrawingQuads(); - tess.setNormal(0.0F, 1.0F, 0.0F); + tess.draw(); + tess.startDrawingQuads(); + tess.setNormal(0.0F, 1.0F, 0.0F); - for (k = 0; k < height; ++k) - { - d = (k+1)*pix; - f7 = (float)k / (float)height; - f8 = maxV + (minV - maxV) * f7 - f6; - tess.addVertexWithUV(0.0D, d, 0.0D, (double)maxU, (double)f8); - tess.addVertexWithUV(width*pix, d, 0.0D, (double)minU, (double)f8); - tess.addVertexWithUV(width*pix, d, (double)(0.0F - thickness), (double)minU, (double)f8); - tess.addVertexWithUV(0.0D, d, (double)(0.0F - thickness), (double)maxU, (double)f8); - } + for (k = 0; k < height; ++k) { + d = (k + 1) * pix; + f7 = (float) k / (float) height; + f8 = maxV + (minV - maxV) * f7 - f6; + tess.addVertexWithUV(0.0D, d, 0.0D, (double) maxU, (double) f8); + tess.addVertexWithUV(width * pix, d, 0.0D, (double) minU, (double) f8); + tess.addVertexWithUV(width * pix, d, (double) (0.0F - thickness), (double) minU, (double) f8); + tess.addVertexWithUV(0.0D, d, (double) (0.0F - thickness), (double) maxU, (double) f8); + } - tess.draw(); - tess.startDrawingQuads(); - tess.setNormal(0.0F, -1.0F, 0.0F); + tess.draw(); + tess.startDrawingQuads(); + tess.setNormal(0.0F, -1.0F, 0.0F); - for (k = 0; k < height; ++k) - { - d = k*pix; - f7 = (float)k / (float)height; - f8 = maxV + (minV - maxV) * f7 - f6; - tess.addVertexWithUV(width*pix, d, 0.0D, (double)minU, (double)f8); - tess.addVertexWithUV(0.0D, d, 0.0D, (double)maxU, (double)f8); - tess.addVertexWithUV(0.0D, d, (double)(0.0F - thickness), (double)maxU, (double)f8); - tess.addVertexWithUV(width*pix, d, (double)(0.0F - thickness), (double)minU, (double)f8); - } + for (k = 0; k < height; ++k) { + d = k * pix; + f7 = (float) k / (float) height; + f8 = maxV + (minV - maxV) * f7 - f6; + tess.addVertexWithUV(width * pix, d, 0.0D, (double) minU, (double) f8); + tess.addVertexWithUV(0.0D, d, 0.0D, (double) maxU, (double) f8); + tess.addVertexWithUV(0.0D, d, (double) (0.0F - thickness), (double) maxU, (double) f8); + tess.addVertexWithUV(width * pix, d, (double) (0.0F - thickness), (double) minU, (double) f8); + } - tess.draw(); - } + tess.draw(); + } - public void renderChargingItem(TileEnergyInfuser tile){ - if (tile.getStackInSlot(0) != null) { - GL11.glPushMatrix(); + public void renderChargingItem(TileEnergyInfuser tile) { + if (tile.getStackInSlot(0) != null) { + GL11.glPushMatrix(); - ItemStack stack = tile.getStackInSlot(0); - EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, tile.getStackInSlot(0)); - itemEntity.hoverStart = 0.0F; + ItemStack stack = tile.getStackInSlot(0); + EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, tile.getStackInSlot(0)); + itemEntity.hoverStart = 0.0F; - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - GL11.glScalef(1F, 1F, 1F); - if (tile.getWorldObj().getWorldInfo().getGameRulesInstance().getGameRuleBooleanValue("doDaylightCycle")) - GL11.glRotatef(tile.getWorldObj().getWorldTime(), 0F, -1F, 0F); - else - GL11.glRotatef(tile.rotation, 0F, -1F, 0F); - if (stack.getItem() instanceof ItemBlock) - { - GL11.glScalef(1F, 1F, 1F); - GL11.glTranslatef(0F, 0.045F, 0.0f); - } + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glScalef(1F, 1F, 1F); + if (tile.getWorldObj().getWorldInfo().getGameRulesInstance().getGameRuleBooleanValue("doDaylightCycle")) + GL11.glRotatef(tile.getWorldObj().getWorldTime(), 0F, -1F, 0F); + else GL11.glRotatef(tile.rotation, 0F, -1F, 0F); + if (stack.getItem() instanceof ItemBlock) { + GL11.glScalef(1F, 1F, 1F); + GL11.glTranslatef(0F, 0.045F, 0.0f); + } - RenderItem.renderInFrame = true; - RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - RenderItem.renderInFrame = false; + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; - GL11.glPopMatrix(); - } - } + GL11.glPopMatrix(); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileEnergyPylon.java b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileEnergyPylon.java index c75cecde..277f691d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileEnergyPylon.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileEnergyPylon.java @@ -15,85 +15,85 @@ import org.lwjgl.opengl.GL11; */ public class RenderTileEnergyPylon extends TileEntitySpecialRenderer { - private static final ResourceLocation model_texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/pylon_sphere_texture.png"); - private IModelCustom model; + private static final ResourceLocation model_texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/pylon_sphere_texture.png"); + private IModelCustom model; - public RenderTileEnergyPylon() - { - model = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/pylon_sphere.obj")); - } - @Override - public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) { + public RenderTileEnergyPylon() { + model = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/pylon_sphere.obj")); + } - if (tile == null || !(tile instanceof TileEnergyPylon)) return; - TileEnergyPylon pylon = (TileEnergyPylon) tile; - if (!pylon.active) return; - float scale = pylon.modelScale + (timeSinceLastTick *= !pylon.reciveEnergy ? -0.01F : 0.01F); - float rotation = pylon.modelRotation + (timeSinceLastTick / 2F); + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + if (tile == null || !(tile instanceof TileEnergyPylon)) return; + TileEnergyPylon pylon = (TileEnergyPylon) tile; + if (!pylon.active) return; + float scale = pylon.modelScale + (timeSinceLastTick *= !pylon.reciveEnergy ? -0.01F : 0.01F); + float rotation = pylon.modelRotation + (timeSinceLastTick / 2F); - GL11.glTranslated(x+0.5, y+0.5, z+0.5); - if (pylon.getWorldObj().getBlockMetadata(pylon.xCoord, pylon.yCoord, pylon.zCoord) == 1) { - GL11.glTranslated(0, 1, 0); - }else { - GL11.glTranslated(0, -1, 0); - } + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + if (pylon.getWorldObj().getBlockMetadata(pylon.xCoord, pylon.yCoord, pylon.zCoord) == 1) { + GL11.glTranslated(0, 1, 0); + } else { + GL11.glTranslated(0, -1, 0); + } - bindTexture(model_texture); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glDepthMask(false); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); + bindTexture(model_texture); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glPushMatrix(); - float scale1 = scale % 1F; - GL11.glScalef(scale1, scale1, scale1); - GL11.glRotatef(rotation * 0.5F, 0F, -1F, -0.5F); - GL11.glColor4d(1D, 1D, 1D, 1F - (scale1)); - model.renderAll(); - GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glDepthMask(false); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); - GL11.glPushMatrix(); - float scale2 = (scale+0.25F) % 1F; - GL11.glScalef(scale2, scale2, scale2); - GL11.glRotatef(rotation*0.5F, 0F, -1F, -0.5F); - GL11.glColor4f(1F, 1F, 1F, 1F-(scale2)); - model.renderAll(); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + float scale1 = scale % 1F; + GL11.glScalef(scale1, scale1, scale1); + GL11.glRotatef(rotation * 0.5F, 0F, -1F, -0.5F); + GL11.glColor4d(1D, 1D, 1D, 1F - (scale1)); + model.renderAll(); + GL11.glPopMatrix(); - GL11.glPushMatrix(); - float scale3 = (scale+0.5F) % 1F; - GL11.glScalef(scale3, scale3, scale3); - GL11.glRotatef(rotation*0.5F, 0F, -1F, -0.5F); - GL11.glColor4f(1F, 1F, 1F, 1F-(scale3)); - model.renderAll(); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + float scale2 = (scale + 0.25F) % 1F; + GL11.glScalef(scale2, scale2, scale2); + GL11.glRotatef(rotation * 0.5F, 0F, -1F, -0.5F); + GL11.glColor4f(1F, 1F, 1F, 1F - (scale2)); + model.renderAll(); + GL11.glPopMatrix(); - GL11.glPushMatrix(); - float scale4 = (scale+0.75F) % 1F; - GL11.glScalef(scale4, scale4, scale4); - GL11.glRotatef(rotation*0.5F, 0F, -1F, -0.5F); - GL11.glColor4f(1F, 1F, 1F, 1F-(scale4)); - model.renderAll(); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + float scale3 = (scale + 0.5F) % 1F; + GL11.glScalef(scale3, scale3, scale3); + GL11.glRotatef(rotation * 0.5F, 0F, -1F, -0.5F); + GL11.glColor4f(1F, 1F, 1F, 1F - (scale3)); + model.renderAll(); + GL11.glPopMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDepthMask(true); - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + GL11.glPushMatrix(); + float scale4 = (scale + 0.75F) % 1F; + GL11.glScalef(scale4, scale4, scale4); + GL11.glRotatef(rotation * 0.5F, 0F, -1F, -0.5F); + GL11.glColor4f(1F, 1F, 1F, 1F - (scale4)); + model.renderAll(); + GL11.glPopMatrix(); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } // private void renderSphere() diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileEnergyStorageCore.java b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileEnergyStorageCore.java index 76130d19..a30ed6a1 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileEnergyStorageCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileEnergyStorageCore.java @@ -17,65 +17,65 @@ import org.lwjgl.opengl.GL11; */ public class RenderTileEnergyStorageCore extends TileEntitySpecialRenderer { - private static final ResourceLocation iner_model_texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/power_sphere_layer_1.png"); - private static final ResourceLocation outer_model_texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/power_sphere_layer_2.png"); - private IModelCustom iner_model; + private static final ResourceLocation iner_model_texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/power_sphere_layer_1.png"); + private static final ResourceLocation outer_model_texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/power_sphere_layer_2.png"); + private IModelCustom iner_model; - public RenderTileEnergyStorageCore() - { - iner_model = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/power_sphere_layer_1.obj")); - } - @Override - public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) { - if (tile == null || !(tile instanceof TileEnergyStorageCore)) return; - TileEnergyStorageCore core = (TileEnergyStorageCore) tile; - if (!core.isOnline()) return; - float scale = 0; - float rotation = core.modelRotation + (timeSinceLastTick / 2F); + public RenderTileEnergyStorageCore() { + iner_model = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/power_sphere_layer_1.obj")); + } - switch (core.getTier()){ - case 0: - scale = 0.7F; - break; - case 1: - scale = 1.2F; - break; - case 2: - scale = 1.7F; - break; - case 3: - scale = 2.5F; - break; - case 4: - scale = 3.5F; - break; - case 5: - scale = 4.5F; - break; - case 6: - scale = 5.5F; - break; - } + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) { + if (tile == null || !(tile instanceof TileEnergyStorageCore)) return; + TileEnergyStorageCore core = (TileEnergyStorageCore) tile; + if (!core.isOnline()) return; + float scale = 0; + float rotation = core.modelRotation + (timeSinceLastTick / 2F); - GL11.glPushMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 150f, 150f); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glTranslated(x+0.5, y+0.5, z+0.5); - FMLClientHandler.instance().getClient().getTextureManager().bindTexture(iner_model_texture); + switch (core.getTier()) { + case 0: + scale = 0.7F; + break; + case 1: + scale = 1.2F; + break; + case 2: + scale = 1.7F; + break; + case 3: + scale = 2.5F; + break; + case 4: + scale = 3.5F; + break; + case 5: + scale = 4.5F; + break; + case 6: + scale = 5.5F; + break; + } - double colour = (double)((TileEnergyStorageCore) tile).getEnergyStored() / (double)((TileEnergyStorageCore) tile).getMaxEnergyStored(); - float brightness = (float)Math.abs(Math.sin((float) Minecraft.getSystemTime() / 3000f) * 100f); + GL11.glPushMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 150f, 150f); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + FMLClientHandler.instance().getClient().getTextureManager().bindTexture(iner_model_texture); - colour = 1f - colour; - GL11.glScalef(scale, scale, scale); - GL11.glPushMatrix(); - GL11.glRotatef(rotation, 0F, 1F, 0.5F); - GL11.glColor4d(1F, colour * 0.3f, colour * 0.7f, 1F); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 80f + brightness, 80f + brightness); - iner_model.renderAll(); - GL11.glPopMatrix(); + double colour = (double) ((TileEnergyStorageCore) tile).getEnergyStored() / (double) ((TileEnergyStorageCore) tile).getMaxEnergyStored(); + float brightness = (float) Math.abs(Math.sin((float) Minecraft.getSystemTime() / 3000f) * 100f); + + colour = 1f - colour; + GL11.glScalef(scale, scale, scale); + GL11.glPushMatrix(); + GL11.glRotatef(rotation, 0F, 1F, 0.5F); + GL11.glColor4d(1F, colour * 0.3f, colour * 0.7f, 1F); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 80f + brightness, 80f + brightness); + iner_model.renderAll(); + GL11.glPopMatrix(); // GL11.glPushMatrix(); // GL11.glScalef(0.8F, 0.8F, 0.8F); @@ -91,19 +91,19 @@ public class RenderTileEnergyStorageCore extends TileEntitySpecialRenderer { // //iner_model.renderAll(); // GL11.glPopMatrix(); - GL11.glScalef(1.1F, 1.1F, 1.1F); - GL11.glDepthMask(false); - FMLClientHandler.instance().getClient().getTextureManager().bindTexture(outer_model_texture); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glRotatef(rotation*0.5F, 0F, -1F, -0.5F); - GL11.glColor4f(0.5F, 2F, 2F, 0.7F); - iner_model.renderAll(); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDepthMask(true); - GL11.glEnable(GL11.GL_LIGHTING); + GL11.glScalef(1.1F, 1.1F, 1.1F); + GL11.glDepthMask(false); + FMLClientHandler.instance().getClient().getTextureManager().bindTexture(outer_model_texture); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glRotatef(rotation * 0.5F, 0F, -1F, -0.5F); + GL11.glColor4f(0.5F, 2F, 2F, 0.7F); + iner_model.renderAll(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileParticleGen.java b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileParticleGen.java index 6904389e..3a211ae4 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileParticleGen.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileParticleGen.java @@ -18,659 +18,651 @@ import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class RenderTileParticleGen extends TileEntitySpecialRenderer -{ - - private final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/ParticleGenTextureSheet.png"); - private final ResourceLocation beamTexture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/stabilizer_beam.png"); - private static final ResourceLocation modelTexture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/stabilizer_sphere.png"); - private IModelCustom stabilizerSphereModel; - - private float pxl = 1F / 64; - - public RenderTileParticleGen() - { - stabilizerSphereModel = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/stabilizer_sphere.obj")); - } - - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { - GL11.glPushMatrix(); - - GL11.glTranslatef((float) x, (float) y, (float) z); - TileParticleGenerator tileEntityGen = (TileParticleGenerator) tileEntity; - renderBlock(tileEntityGen, f); - - - - GL11.glPopMatrix(); - } - - public void renderBlock(TileParticleGenerator tl, float f3) { - Tessellator tessellator = Tessellator.instance; - - boolean inverted = tl.inverted; - boolean stabilizerMode = tl.stabalizerMode; - - GL11.glPushMatrix(); - - //GL11.glDisable(GL11.GL_LIGHTING); - bindTexture(texture); - - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, 1.0F); - tessellator.setColorRGBA(255, 255, 255, 255); - - {//Draw Corners - float f = 0.4F; - drawCornerCube(tessellator, f, f, f, 1F - f, inverted, stabilizerMode); - drawCornerCube(tessellator, f, -f, f, 1F - f, inverted, stabilizerMode); - drawCornerCube(tessellator, -f, f, -f, 1F - f, inverted, stabilizerMode); - drawCornerCube(tessellator, -f, -f, -f, 1F - f, inverted, stabilizerMode); - drawCornerCube(tessellator, -f, f, f, 1F - f, inverted, stabilizerMode); - drawCornerCube(tessellator, f, f, -f, 1F - f, inverted, stabilizerMode); - drawCornerCube(tessellator, f, -f, -f, 1F - f, inverted, stabilizerMode); - drawCornerCube(tessellator, -f, -f, f, 1F - f, inverted, stabilizerMode); - } - {//Draw Beams - float f = 0.45F; - float f2 = 0.4F; - drawBeamX(tessellator, 0, f2, f2, 1F - f); - drawBeamX(tessellator, 0, -f2, f2, 1F - f); - drawBeamX(tessellator, 0, f2, -f2, 1F - f); - drawBeamX(tessellator, 0, -f2, -f2, 1F - f); - - drawBeamY(tessellator, f2, 0, f2, 1F - f); - drawBeamY(tessellator, -f2, 0, f2, 1F - f); - drawBeamY(tessellator, f2, 0, -f2, 1F - f); - drawBeamY(tessellator, -f2, 0, -f2, 1F - f); - - drawBeamZ(tessellator, f2, f2, 0, 1F - f); - drawBeamZ(tessellator, -f2, f2, 0, 1F - f); - drawBeamZ(tessellator, f2, -f2, 0, 1F - f); - drawBeamZ(tessellator, -f2, -f2, 0, 1F - f); - } - - tessellator.draw(); - //GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - - if (stabilizerMode) - { - drawEnergyBeam(tessellator, tl, f3); - } - - if (tl.beam_enabled) preRenderBeam(tessellator, tl, f3); - - } - - private void drawEnergyBeam(Tessellator tess, TileParticleGenerator gen, float f){ - TileEnergyStorageCore master = gen.getMaster(); - if (master == null) return; - float length = 0; - - GL11.glPushMatrix(); - - if (master.xCoord > gen.xCoord){ - GL11.glRotatef(-90F, 0F, 0F, 1F); - GL11.glTranslated(-1, 0.5, 0); - length = master.xCoord - gen.xCoord - 0.2F; - } - else if (master.xCoord < gen.xCoord){ - GL11.glRotatef(90F, 0F, 0F, 1F); - GL11.glTranslated(0, -0.5, 0); - length = gen.xCoord - master.xCoord - 0.2F; - } - else if (master.zCoord > gen.zCoord){ - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glTranslated(0, 0.5, -1); - length = master.zCoord - gen.zCoord - 0.2F; - } - else if (master.zCoord < gen.zCoord){ - GL11.glRotatef(-90F, 1F, 0F, 0F); - GL11.glTranslated(0, -0.5, 0); - length = gen.zCoord - master.zCoord - 0.2F; - } - - renderStabilizerSphere(gen); - renderEnergyBeam(tess, gen, length, f); - - GL11.glPopMatrix(); - } - - public void renderStabilizerSphere(TileParticleGenerator tile){ - GL11.glPushMatrix(); - //GL11.glColor4f(0.5F, 0.0F, 0.0F, 1F); - GL11.glColor4f(0.0F, 2.0F, 0.0F, 1F); - GL11.glTranslated(0.5, 0, 0.5); - GL11.glScalef(0.4F, 0.4F, 0.4F); - if (!tile.stabalizerMode) { - float red = (float)tile.beam_red / 255F; - float green = (float)tile.beam_green / 255F; - float blue = (float)tile.beam_blue / 255F; - GL11.glColor4f(red, green, blue, 1F); - GL11.glScalef(tile.beam_scale, tile.beam_scale, tile.beam_scale); - } - - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200, 200); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_CULL_FACE); - - FMLClientHandler.instance().getClient().getTextureManager().bindTexture(modelTexture); - - GL11.glRotatef(tile.rotation, 0F, 1F, 0F); - stabilizerSphereModel.renderAll(); - - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200, 200); - GL11.glRotatef(tile.rotation*2, 0F, -1F, 0F); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDepthMask(false); - GL11.glColor4f(0.0F, 1.0F, 1.0F, 0.5F); - if (!tile.stabalizerMode) { - float red = (float)tile.beam_red / 255F; - float green = (float)tile.beam_green / 255F; - float blue = (float)tile.beam_blue / 255F; - GL11.glColor4f(red, green, blue, 0.5F); - } - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glScalef(1.3F, 1.3F, 1.3F); - stabilizerSphereModel.renderAll(); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDepthMask(true); - - GL11.glPopMatrix(); - } - - private void renderEnergyBeam(Tessellator tess, TileParticleGenerator tile, float length, float f){ - int x = 0; - int y = 0; - int z = 0; - - GL11.glPushMatrix(); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); - - bindTexture(beamTexture); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDepthMask(true); - OpenGlHelper.glBlendFunc(770, 1, 1, 0); - - //float time = (float)tile.getWorldObj().getTotalWorldTime() + f; - float time = tile.rotation + f; - float upMot = -time * 0.2F - (float) MathHelper.floor_float(-time * 0.1F); - byte scaleMult = 1; - double rotation = (double)time * 0.025D * (1.0D - (double)(scaleMult & 1) * 2.5D); - - - tess.startDrawingQuads(); - tess.setColorRGBA(255, 255, 255, 32); - - double scale = (double)scaleMult * 0.2D; - double d7 = 0.5D + Math.cos(rotation + 2.356194490192345D) * scale; //x point 1 - double d9 = 0.5D + Math.sin(rotation + 2.356194490192345D) * scale; //z point 1 - double d11 = 0.5D + Math.cos(rotation + (Math.PI / 4D)) * scale; //x point 2 - double d13 = 0.5D + Math.sin(rotation + (Math.PI / 4D)) * scale; //z point 2 - double d15 = 0.5D + Math.cos(rotation + 3.9269908169872414D) * scale;//Dist from x-3 - double d17 = 0.5D + Math.sin(rotation + 3.9269908169872414D) * scale; - double d19 = 0.5D + Math.cos(rotation + 5.497787143782138D) * scale; - double d21 = 0.5D + Math.sin(rotation + 5.497787143782138D) * scale; - double height = (double)(length); - double texXMin = 0.0D; - double texXMax = 1.0D; - double d28 = (double)(-1.0F + upMot); - double texHeight = (double)(length) * (0.5D / scale) + d28; - - tess.addVertexWithUV(x + d7, y + height, z + d9, texXMax, texHeight); - tess.addVertexWithUV(x + d7, y, z + d9, texXMax, d28); - tess.addVertexWithUV(x + d11, y, z + d13, texXMin, d28); - tess.addVertexWithUV(x + d11, y + height, z + d13, texXMin, texHeight); - - tess.addVertexWithUV(x + d19, y + height, z + d21, texXMax, texHeight); - tess.addVertexWithUV(x + d19, y, z + d21, texXMax, d28); - tess.addVertexWithUV(x + d15, y, z + d17, texXMin, d28); - tess.addVertexWithUV(x + d15, y + height, z + d17, texXMin, texHeight); - - tess.addVertexWithUV(x + d11, y + height, z + d13, texXMax, texHeight); - tess.addVertexWithUV(x + d11, y, z + d13, texXMax, d28); - tess.addVertexWithUV(x + d19, y, z + d21, texXMin, d28); - tess.addVertexWithUV(x + d19, y + height, z + d21, texXMin, texHeight); - - tess.addVertexWithUV(x + d15, y + height, z + d17, texXMax, texHeight); - tess.addVertexWithUV(x + d15, y, z + d17, texXMax, d28); - tess.addVertexWithUV(x + d7, y, z + d9, texXMin, d28); - tess.addVertexWithUV(x + d7, y + height, z + d9, texXMin, texHeight); - - rotation += 0.77f; - d7 = 0.5D + Math.cos(rotation + 2.356194490192345D) * scale; - d9 = 0.5D + Math.sin(rotation + 2.356194490192345D) * scale; - d11 = 0.5D + Math.cos(rotation + (Math.PI / 4D)) * scale; - d13 = 0.5D + Math.sin(rotation + (Math.PI / 4D)) * scale; - d15 = 0.5D + Math.cos(rotation + 3.9269908169872414D) * scale; - d17 = 0.5D + Math.sin(rotation + 3.9269908169872414D) * scale; - d19 = 0.5D + Math.cos(rotation + 5.497787143782138D) * scale; - d21 = 0.5D + Math.sin(rotation + 5.497787143782138D) * scale; - - d28 = (-1F + (upMot*1)); - texHeight = (double)(length) * (0.5D / scale) + d28; - - tess.setColorRGBA_F(1.0F, 1.0f, 1.0f, 1f); - - tess.addVertexWithUV(x + d7, y + height, z + d9, texXMax, texHeight); - tess.addVertexWithUV(x + d7, y, z + d9, texXMax, d28); - tess.addVertexWithUV(x + d11, y, z + d13, texXMin, d28); - tess.addVertexWithUV(x + d11, y + height, z + d13, texXMin, texHeight); - - tess.addVertexWithUV(x + d19, y + height, z + d21, texXMax, texHeight); - tess.addVertexWithUV(x + d19, y, z + d21, texXMax, d28); - tess.addVertexWithUV(x + d15, y, z + d17, texXMin, d28); - tess.addVertexWithUV(x + d15, y + height, z + d17, texXMin, texHeight); - - tess.addVertexWithUV(x + d11, y + height, z + d13, texXMax, texHeight); - tess.addVertexWithUV(x + d11, y, z + d13, texXMax, d28); - tess.addVertexWithUV(x + d19, y, z + d21, texXMin, d28); - tess.addVertexWithUV(x + d19, y + height, z + d21, texXMin, texHeight); - - tess.addVertexWithUV(x + d15, y + height, z + d17, texXMax, texHeight); - tess.addVertexWithUV(x + d15, y, z + d17, texXMax, d28); - tess.addVertexWithUV(x + d7, y, z + d9, texXMin, d28); - tess.addVertexWithUV(x + d7, y + height, z + d9, texXMin, texHeight); - - tess.draw(); - GL11.glPushMatrix(); - - GL11.glTranslated(0, 0.4, 0); - length -= 0.5F; - - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glDepthMask(false); - tess.startDrawingQuads(); - tess.setColorRGBA(255, 255, 255, 32); - double d30 = 0.2D; - double d4 = 0.2D; - double d6 = 0.8D; - double d8 = 0.2D; - double d10 = 0.2D; - double d12 = 0.8D; - double d14 = 0.8D; - double d16 = 0.8D; - double d18 = (double)(length); - double d20 = 0.0D; - double d22 = 1.0D; - double d24 = (double)(-1.0F + upMot); - double d26 = (double)(length) + d24; - tess.addVertexWithUV(x + d30, y + d18, z + d4, d22, d26); - tess.addVertexWithUV(x + d30, y, z + d4, d22, d24); - tess.addVertexWithUV(x + d6, y, z + d8, d20, d24); - tess.addVertexWithUV(x + d6, y + d18, z + d8, d20, d26); - tess.addVertexWithUV(x + d14, y + d18, z + d16, d22, d26); - tess.addVertexWithUV(x + d14, y, z + d16, d22, d24); - tess.addVertexWithUV(x + d10, y, z + d12, d20, d24); - tess.addVertexWithUV(x + d10, y + d18, z + d12, d20, d26); - tess.addVertexWithUV(x + d6, y + d18, z + d8, d22, d26); - tess.addVertexWithUV(x + d6, y, z + d8, d22, d24); - tess.addVertexWithUV(x + d14, y, z + d16, d20, d24); - tess.addVertexWithUV(x + d14, y + d18, z + d16, d20, d26); - tess.addVertexWithUV(x + d10, y + d18, z + d12, d22, d26); - tess.addVertexWithUV(x + d10, y, z + d12, d22, d24); - tess.addVertexWithUV(x + d30, y, z + d4, d20, d24); - tess.addVertexWithUV(x + d30, y + d18, z + d4, d20, d26); - tess.draw(); - GL11.glPopMatrix(); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDepthMask(true); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - - } - - private void drawCornerCube(Tessellator tess, float x, float y, float z, float FP, boolean inverted, boolean stabalizerMode) { - float srcXMin = inverted ? 38F * pxl: 32F * pxl; - float srcYMin = 0F; - float srcXMax = inverted ? 44F * pxl : 38F * pxl; - float srcYMax = 6 * pxl; - //float FP = 0.6F; //Scale - float FN = 1F - FP; - - if (stabalizerMode){ - srcXMin = 44F * pxl; - srcXMax = 50F * pxl; - } - - //X+ - tess.addVertexWithUV(FP + x, FN + y, FN + z, srcXMin, srcYMin); - tess.addVertexWithUV(FP + x, FP + y, FN + z, srcXMax, srcYMin); - tess.addVertexWithUV(FP + x, FP + y, FP + z, srcXMax, srcYMax); - tess.addVertexWithUV(FP + x, FN + y, FP + z, srcXMin, srcYMax); - - //X- - tess.addVertexWithUV(FN + x, FN + y, FP + z, srcXMin, srcYMin); - tess.addVertexWithUV(FN + x, FP + y, FP + z, srcXMax, srcYMin); - tess.addVertexWithUV(FN + x, FP + y, FN + z, srcXMax, srcYMax); - tess.addVertexWithUV(FN + x, FN + y, FN + z, srcXMin, srcYMax); - - //Y+ - tess.addVertexWithUV(FN + x, FP + y, FN + z, srcXMin, srcYMin); - tess.addVertexWithUV(FN + x, FP + y, FP + z, srcXMax, srcYMin); - tess.addVertexWithUV(FP + x, FP + y, FP + z, srcXMax, srcYMax); - tess.addVertexWithUV(FP + x, FP + y, FN + z, srcXMin, srcYMax); - - //Y- - tess.addVertexWithUV(FN + x, FN + y, FN + z, srcXMin, srcYMin); - tess.addVertexWithUV(FP + x, FN + y, FN + z, srcXMax, srcYMin); - tess.addVertexWithUV(FP + x, FN + y, FP + z, srcXMax, srcYMax); - tess.addVertexWithUV(FN + x, FN + y, FP + z, srcXMin, srcYMax); - - //Z+ - tess.addVertexWithUV(FP + x, FN + y, FP + z, srcXMin, srcYMin); - tess.addVertexWithUV(FP + x, FP + y, FP + z, srcXMax, srcYMin); - tess.addVertexWithUV(FN + x, FP + y, FP + z, srcXMax, srcYMax); - tess.addVertexWithUV(FN + x, FN + y, FP + z, srcXMin, srcYMax); - - //Z- - tess.addVertexWithUV(FN + x, FN + y, FN + z, srcXMin, srcYMin); - tess.addVertexWithUV(FN + x, FP + y, FN + z, srcXMax, srcYMin); - tess.addVertexWithUV(FP + x, FP + y, FN + z, srcXMax, srcYMax); - tess.addVertexWithUV(FP + x, FN + y, FN + z, srcXMin, srcYMax); - } - - private void drawBeamX(Tessellator tess, float x, float y, float z, float FP) { - float srcXMin = 0; - float srcYMin = 0F; - float srcXMax = 32F * pxl; - float srcYMax = 4 * pxl; - float FN = 1F - FP; - - float XX = 0.9F; - float XM = 0.1F; - - //Y+ - tess.addVertexWithUV(XM, FP + y, FN + z, srcXMin, srcYMax); - tess.addVertexWithUV(XM, FP + y, FP + z, srcXMin, srcYMin); - tess.addVertexWithUV(XX, FP + y, FP + z, srcXMax, srcYMin); - tess.addVertexWithUV(XX, FP + y, FN + z, srcXMax, srcYMax); - - //Y- - tess.addVertexWithUV(XM, FN + y, FN + z, srcXMin, srcYMin); - tess.addVertexWithUV(XX, FN + y, FN + z, srcXMax, srcYMin); - tess.addVertexWithUV(XX, FN + y, FP + z, srcXMax, srcYMax); - tess.addVertexWithUV(XM, FN + y, FP + z, srcXMin, srcYMax); - - //Z+ - tess.addVertexWithUV(XX, FN + y, FP + z, srcXMin, srcYMax); - tess.addVertexWithUV(XX, FP + y, FP + z, srcXMin, srcYMin); - tess.addVertexWithUV(XM, FP + y, FP + z, srcXMax, srcYMin); - tess.addVertexWithUV(XM, FN + y, FP + z, srcXMax, srcYMax); - - //Z- - tess.addVertexWithUV(XM, FN + y, FN + z, srcXMin, srcYMax); - tess.addVertexWithUV(XM, FP + y, FN + z, srcXMin, srcYMin); - tess.addVertexWithUV(XX, FP + y, FN + z, srcXMax, srcYMin); - tess.addVertexWithUV(XX, FN + y, FN + z, srcXMax, srcYMax); - } - - private void drawBeamY(Tessellator tess, float x, float y, float z, float FP) { - float srcXMin = 0; - float srcYMin = 0F; - float srcXMax = 32F * pxl; - float srcYMax = 4 * pxl; - float FN = 1F - FP; - - float XX = 0.9F; - float XM = 0.1F; - - //X+ - tess.addVertexWithUV(FP + x, XM, FN + z, srcXMin, srcYMin); - tess.addVertexWithUV(FP + x, XX, FN + z, srcXMax, srcYMin); - tess.addVertexWithUV(FP + x, XX, FP + z, srcXMax, srcYMax); - tess.addVertexWithUV(FP + x, XM, FP + z, srcXMin, srcYMax); - - //X- - tess.addVertexWithUV(FN + x, XM, FP + z, srcXMin, srcYMin); - tess.addVertexWithUV(FN + x, XX, FP + z, srcXMax, srcYMin); - tess.addVertexWithUV(FN + x, XX, FN + z, srcXMax, srcYMax); - tess.addVertexWithUV(FN + x, XM, FN + z, srcXMin, srcYMax); - - //Z+ - tess.addVertexWithUV(FP + x, XM, FP + z, srcXMin, srcYMin); - tess.addVertexWithUV(FP + x, XX, FP + z, srcXMax, srcYMin); - tess.addVertexWithUV(FN + x, XX, FP + z, srcXMax, srcYMax); - tess.addVertexWithUV(FN + x, XM, FP + z, srcXMin, srcYMax); - - //Z- - tess.addVertexWithUV(FN + x, XM, FN + z, srcXMin, srcYMin); - tess.addVertexWithUV(FN + x, XX, FN + z, srcXMax, srcYMin); - tess.addVertexWithUV(FP + x, XX, FN + z, srcXMax, srcYMax); - tess.addVertexWithUV(FP + x, XM, FN + z, srcXMin, srcYMax); - - } - - private void drawBeamZ(Tessellator tess, float x, float y, float z, float FP) { - float srcXMin = 0; - float srcYMin = 0F; - float srcXMax = 32F * pxl; - float srcYMax = 4 * pxl; - float FN = 1F - FP; - - float XX = 0.9F; - float XM = 0.1F; - - //X+ - tess.addVertexWithUV(FP + x, FN + y, XM, srcXMin, srcYMax); - tess.addVertexWithUV(FP + x, FP + y, XM, srcXMin, srcYMin); - tess.addVertexWithUV(FP + x, FP + y, XX, srcXMax, srcYMin); - tess.addVertexWithUV(FP + x, FN + y, XX, srcXMax, srcYMax); - - //X- - tess.addVertexWithUV(FN + x, FN + y, XX, srcXMin, srcYMax); - tess.addVertexWithUV(FN + x, FP + y, XX, srcXMin, srcYMin); - tess.addVertexWithUV(FN + x, FP + y, XM, srcXMax, srcYMin); - tess.addVertexWithUV(FN + x, FN + y, XM, srcXMax, srcYMax); - - //Y+ - tess.addVertexWithUV(FN + x, FP + y, XM, srcXMin, srcYMin); - tess.addVertexWithUV(FN + x, FP + y, XX, srcXMax, srcYMin); - tess.addVertexWithUV(FP + x, FP + y, XX, srcXMax, srcYMax); - tess.addVertexWithUV(FP + x, FP + y, XM, srcXMin, srcYMax); - - //Y- - tess.addVertexWithUV(FN + x, FN + y, XM, srcXMin, srcYMax); - tess.addVertexWithUV(FP + x, FN + y, XM, srcXMin, srcYMin); - tess.addVertexWithUV(FP + x, FN + y, XX, srcXMax, srcYMin); - tess.addVertexWithUV(FN + x, FN + y, XX, srcXMax, srcYMax); - - } - - private void preRenderBeam(Tessellator tess, TileParticleGenerator gen, float f) - { - GL11.glPushMatrix(); - - GL11.glTranslated(0, 0.5, 0.5); - GL11.glRotatef(90F + gen.beam_pitch, 1F, 0F, 0F); - GL11.glTranslated(0, 0, -0.5); - - GL11.glTranslated(0.5, 0, 0); - GL11.glRotatef(gen.beam_yaw, 0F, 0F, 1F); - GL11.glTranslated(-0.5, 0, 0); - - renderBeam(tess, gen, f); - GL11.glPopMatrix(); - - if (gen.render_core) { - GL11.glPushMatrix(); - GL11.glTranslated(0, 0.5, 0); - renderStabilizerSphere(gen); - GL11.glPopMatrix(); - } - } - - private void renderBeam(Tessellator tess, TileParticleGenerator tile, float f){ - int x = 0; - int y = 0; - int z = 0; - double length = tile.beam_length; - float red = (float)tile.beam_red / 255F; - float green = (float)tile.beam_green / 255F; - float blue = (float)tile.beam_blue / 255F; - - GL11.glPushMatrix(); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); - - bindTexture(beamTexture); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDepthMask(true); - OpenGlHelper.glBlendFunc(770, 1, 1, 0); - - //float time = (float)tile.getWorldObj().getTotalWorldTime() + f; - float time = tile.rotation + f; - float upMot = -time * 0.2F - (float) MathHelper.floor_float(-time * 0.1F); - float rotValue = tile.beam_rotation * (tile.rotation + f * 0.5F); - double rotation = rotValue ; - - - tess.startDrawingQuads(); - tess.setBrightness(200); - tess.setColorRGBA(tile.beam_red, tile.beam_green, tile.beam_blue, 32); - - double scale = (double)tile.beam_scale * 0.2D; - double d7 = 0.5D + Math.cos(rotation + 2.356194490192345D) * scale; //x point 1 - double d9 = 0.5D + Math.sin(rotation + 2.356194490192345D) * scale; //z point 1 - double d11 = 0.5D + Math.cos(rotation + (Math.PI / 4D)) * scale; //x point 2 - double d13 = 0.5D + Math.sin(rotation + (Math.PI / 4D)) * scale; //z point 2 - double d15 = 0.5D + Math.cos(rotation + 3.9269908169872414D) * scale;//Dist from x-3 - double d17 = 0.5D + Math.sin(rotation + 3.9269908169872414D) * scale; - double d19 = 0.5D + Math.cos(rotation + 5.497787143782138D) * scale; - double d21 = 0.5D + Math.sin(rotation + 5.497787143782138D) * scale; - double height = (double)(length); - double texXMin = 0.0D; - double texXMax = 1.0D; - double d28 = (double)(-1.0F + upMot); - double texHeight = (double)(length) * (0.5D / scale) + d28; - - tess.addVertexWithUV(x + d7, y + height, z + d9, texXMax, texHeight); - tess.addVertexWithUV(x + d7, y, z + d9, texXMax, d28); - tess.addVertexWithUV(x + d11, y, z + d13, texXMin, d28); - tess.addVertexWithUV(x + d11, y + height, z + d13, texXMin, texHeight); - - tess.addVertexWithUV(x + d19, y + height, z + d21, texXMax, texHeight); - tess.addVertexWithUV(x + d19, y, z + d21, texXMax, d28); - tess.addVertexWithUV(x + d15, y, z + d17, texXMin, d28); - tess.addVertexWithUV(x + d15, y + height, z + d17, texXMin, texHeight); - - tess.addVertexWithUV(x + d11, y + height, z + d13, texXMax, texHeight); - tess.addVertexWithUV(x + d11, y, z + d13, texXMax, d28); - tess.addVertexWithUV(x + d19, y, z + d21, texXMin, d28); - tess.addVertexWithUV(x + d19, y + height, z + d21, texXMin, texHeight); - - tess.addVertexWithUV(x + d15, y + height, z + d17, texXMax, texHeight); - tess.addVertexWithUV(x + d15, y, z + d17, texXMax, d28); - tess.addVertexWithUV(x + d7, y, z + d9, texXMin, d28); - tess.addVertexWithUV(x + d7, y + height, z + d9, texXMin, texHeight); - - rotation += 0.77f; - d7 = 0.5D + Math.cos(rotation + 2.356194490192345D) * scale; - d9 = 0.5D + Math.sin(rotation + 2.356194490192345D) * scale; - d11 = 0.5D + Math.cos(rotation + (Math.PI / 4D)) * scale; - d13 = 0.5D + Math.sin(rotation + (Math.PI / 4D)) * scale; - d15 = 0.5D + Math.cos(rotation + 3.9269908169872414D) * scale; - d17 = 0.5D + Math.sin(rotation + 3.9269908169872414D) * scale; - d19 = 0.5D + Math.cos(rotation + 5.497787143782138D) * scale; - d21 = 0.5D + Math.sin(rotation + 5.497787143782138D) * scale; - - d28 = (-1F + (upMot*1)); - texHeight = (double)(length) * (0.5D / scale) + d28; - - tess.setColorRGBA_F(red, green, blue, 1f); - - tess.addVertexWithUV(x + d7, y + height, z + d9, texXMax, texHeight); - tess.addVertexWithUV(x + d7, y, z + d9, texXMax, d28); - tess.addVertexWithUV(x + d11, y, z + d13, texXMin, d28); - tess.addVertexWithUV(x + d11, y + height, z + d13, texXMin, texHeight); - - tess.addVertexWithUV(x + d19, y + height, z + d21, texXMax, texHeight); - tess.addVertexWithUV(x + d19, y, z + d21, texXMax, d28); - tess.addVertexWithUV(x + d15, y, z + d17, texXMin, d28); - tess.addVertexWithUV(x + d15, y + height, z + d17, texXMin, texHeight); - - tess.addVertexWithUV(x + d11, y + height, z + d13, texXMax, texHeight); - tess.addVertexWithUV(x + d11, y, z + d13, texXMax, d28); - tess.addVertexWithUV(x + d19, y, z + d21, texXMin, d28); - tess.addVertexWithUV(x + d19, y + height, z + d21, texXMin, texHeight); - - tess.addVertexWithUV(x + d15, y + height, z + d17, texXMax, texHeight); - tess.addVertexWithUV(x + d15, y, z + d17, texXMax, d28); - tess.addVertexWithUV(x + d7, y, z + d9, texXMin, d28); - tess.addVertexWithUV(x + d7, y + height, z + d9, texXMin, texHeight); - - tess.draw(); - GL11.glPushMatrix(); - - //GL11.glTranslated(0, 0.4, 0); - //length -= 0.5F; - - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glDepthMask(false); - GL11.glTranslated(0.5, 0, 0.5); - GL11.glScalef(tile.beam_scale, 1f, tile.beam_scale); - GL11.glTranslated(-0.5, -0, -0.5); - tess.startDrawingQuads(); - tess.setColorRGBA(tile.beam_red, tile.beam_green, tile.beam_blue, 32); - double d30 = 0.2D; - double d4 = 0.2D; - double d6 = 0.8D; - double d8 = 0.2D; - double d10 = 0.2D; - double d12 = 0.8D; - double d14 = 0.8D; - double d16 = 0.8D; - double d18 = (double)(length); - double d20 = 0.0D; - double d22 = 1D; - double d24 = (double)(-1.0F + upMot); - double d26 = (double)(length) + d24; - tess.addVertexWithUV(x + d30, y + d18, z + d4, d22, d26); - tess.addVertexWithUV(x + d30, y, z + d4, d22, d24); - tess.addVertexWithUV(x + d6, y, z + d8, d20, d24); - tess.addVertexWithUV(x + d6, y + d18, z + d8, d20, d26); - tess.addVertexWithUV(x + d14, y + d18, z + d16, d22, d26); - tess.addVertexWithUV(x + d14, y, z + d16, d22, d24); - tess.addVertexWithUV(x + d10, y, z + d12, d20, d24); - tess.addVertexWithUV(x + d10, y + d18, z + d12, d20, d26); - tess.addVertexWithUV(x + d6, y + d18, z + d8, d22, d26); - tess.addVertexWithUV(x + d6, y, z + d8, d22, d24); - tess.addVertexWithUV(x + d14, y, z + d16, d20, d24); - tess.addVertexWithUV(x + d14, y + d18, z + d16, d20, d26); - tess.addVertexWithUV(x + d10, y + d18, z + d12, d22, d26); - tess.addVertexWithUV(x + d10, y, z + d12, d22, d24); - tess.addVertexWithUV(x + d30, y, z + d4, d20, d24); - tess.addVertexWithUV(x + d30, y + d18, z + d4, d20, d26); - tess.draw(); - GL11.glPopMatrix(); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDepthMask(true); +public class RenderTileParticleGen extends TileEntitySpecialRenderer { + + private final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/ParticleGenTextureSheet.png"); + private final ResourceLocation beamTexture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/stabilizer_beam.png"); + private static final ResourceLocation modelTexture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/stabilizer_sphere.png"); + private IModelCustom stabilizerSphereModel; + + private float pxl = 1F / 64; + + public RenderTileParticleGen() { + stabilizerSphereModel = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/stabilizer_sphere.obj")); + } + + @Override + public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { + GL11.glPushMatrix(); + + GL11.glTranslatef((float) x, (float) y, (float) z); + TileParticleGenerator tileEntityGen = (TileParticleGenerator) tileEntity; + renderBlock(tileEntityGen, f); + + + GL11.glPopMatrix(); + } + + public void renderBlock(TileParticleGenerator tl, float f3) { + Tessellator tessellator = Tessellator.instance; + + boolean inverted = tl.inverted; + boolean stabilizerMode = tl.stabalizerMode; + + GL11.glPushMatrix(); + + //GL11.glDisable(GL11.GL_LIGHTING); + bindTexture(texture); + + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + tessellator.setColorRGBA(255, 255, 255, 255); + + {//Draw Corners + float f = 0.4F; + drawCornerCube(tessellator, f, f, f, 1F - f, inverted, stabilizerMode); + drawCornerCube(tessellator, f, -f, f, 1F - f, inverted, stabilizerMode); + drawCornerCube(tessellator, -f, f, -f, 1F - f, inverted, stabilizerMode); + drawCornerCube(tessellator, -f, -f, -f, 1F - f, inverted, stabilizerMode); + drawCornerCube(tessellator, -f, f, f, 1F - f, inverted, stabilizerMode); + drawCornerCube(tessellator, f, f, -f, 1F - f, inverted, stabilizerMode); + drawCornerCube(tessellator, f, -f, -f, 1F - f, inverted, stabilizerMode); + drawCornerCube(tessellator, -f, -f, f, 1F - f, inverted, stabilizerMode); + } + {//Draw Beams + float f = 0.45F; + float f2 = 0.4F; + drawBeamX(tessellator, 0, f2, f2, 1F - f); + drawBeamX(tessellator, 0, -f2, f2, 1F - f); + drawBeamX(tessellator, 0, f2, -f2, 1F - f); + drawBeamX(tessellator, 0, -f2, -f2, 1F - f); + + drawBeamY(tessellator, f2, 0, f2, 1F - f); + drawBeamY(tessellator, -f2, 0, f2, 1F - f); + drawBeamY(tessellator, f2, 0, -f2, 1F - f); + drawBeamY(tessellator, -f2, 0, -f2, 1F - f); + + drawBeamZ(tessellator, f2, f2, 0, 1F - f); + drawBeamZ(tessellator, -f2, f2, 0, 1F - f); + drawBeamZ(tessellator, f2, -f2, 0, 1F - f); + drawBeamZ(tessellator, -f2, -f2, 0, 1F - f); + } + + tessellator.draw(); + //GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + + if (stabilizerMode) { + drawEnergyBeam(tessellator, tl, f3); + } + + if (tl.beam_enabled) preRenderBeam(tessellator, tl, f3); + + } + + private void drawEnergyBeam(Tessellator tess, TileParticleGenerator gen, float f) { + TileEnergyStorageCore master = gen.getMaster(); + if (master == null) return; + float length = 0; + + GL11.glPushMatrix(); + + if (master.xCoord > gen.xCoord) { + GL11.glRotatef(-90F, 0F, 0F, 1F); + GL11.glTranslated(-1, 0.5, 0); + length = master.xCoord - gen.xCoord - 0.2F; + } else if (master.xCoord < gen.xCoord) { + GL11.glRotatef(90F, 0F, 0F, 1F); + GL11.glTranslated(0, -0.5, 0); + length = gen.xCoord - master.xCoord - 0.2F; + } else if (master.zCoord > gen.zCoord) { + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glTranslated(0, 0.5, -1); + length = master.zCoord - gen.zCoord - 0.2F; + } else if (master.zCoord < gen.zCoord) { + GL11.glRotatef(-90F, 1F, 0F, 0F); + GL11.glTranslated(0, -0.5, 0); + length = gen.zCoord - master.zCoord - 0.2F; + } + + renderStabilizerSphere(gen); + renderEnergyBeam(tess, gen, length, f); + + GL11.glPopMatrix(); + } + + public void renderStabilizerSphere(TileParticleGenerator tile) { + GL11.glPushMatrix(); + //GL11.glColor4f(0.5F, 0.0F, 0.0F, 1F); + GL11.glColor4f(0.0F, 2.0F, 0.0F, 1F); + GL11.glTranslated(0.5, 0, 0.5); + GL11.glScalef(0.4F, 0.4F, 0.4F); + if (!tile.stabalizerMode) { + float red = (float) tile.beam_red / 255F; + float green = (float) tile.beam_green / 255F; + float blue = (float) tile.beam_blue / 255F; + GL11.glColor4f(red, green, blue, 1F); + GL11.glScalef(tile.beam_scale, tile.beam_scale, tile.beam_scale); + } + + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200, 200); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + + FMLClientHandler.instance().getClient().getTextureManager().bindTexture(modelTexture); + + GL11.glRotatef(tile.rotation, 0F, 1F, 0F); + stabilizerSphereModel.renderAll(); + + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200, 200); + GL11.glRotatef(tile.rotation * 2, 0F, -1F, 0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + GL11.glColor4f(0.0F, 1.0F, 1.0F, 0.5F); + if (!tile.stabalizerMode) { + float red = (float) tile.beam_red / 255F; + float green = (float) tile.beam_green / 255F; + float blue = (float) tile.beam_blue / 255F; + GL11.glColor4f(red, green, blue, 0.5F); + } + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glScalef(1.3F, 1.3F, 1.3F); + stabilizerSphereModel.renderAll(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + + GL11.glPopMatrix(); + } + + private void renderEnergyBeam(Tessellator tess, TileParticleGenerator tile, float length, float f) { + int x = 0; + int y = 0; + int z = 0; + + GL11.glPushMatrix(); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + + bindTexture(beamTexture); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + OpenGlHelper.glBlendFunc(770, 1, 1, 0); + + //float time = (float)tile.getWorldObj().getTotalWorldTime() + f; + float time = tile.rotation + f; + float upMot = -time * 0.2F - (float) MathHelper.floor_float(-time * 0.1F); + byte scaleMult = 1; + double rotation = (double) time * 0.025D * (1.0D - (double) (scaleMult & 1) * 2.5D); + + + tess.startDrawingQuads(); + tess.setColorRGBA(255, 255, 255, 32); + + double scale = (double) scaleMult * 0.2D; + double d7 = 0.5D + Math.cos(rotation + 2.356194490192345D) * scale; //x point 1 + double d9 = 0.5D + Math.sin(rotation + 2.356194490192345D) * scale; //z point 1 + double d11 = 0.5D + Math.cos(rotation + (Math.PI / 4D)) * scale; //x point 2 + double d13 = 0.5D + Math.sin(rotation + (Math.PI / 4D)) * scale; //z point 2 + double d15 = 0.5D + Math.cos(rotation + 3.9269908169872414D) * scale;//Dist from x-3 + double d17 = 0.5D + Math.sin(rotation + 3.9269908169872414D) * scale; + double d19 = 0.5D + Math.cos(rotation + 5.497787143782138D) * scale; + double d21 = 0.5D + Math.sin(rotation + 5.497787143782138D) * scale; + double height = (double) (length); + double texXMin = 0.0D; + double texXMax = 1.0D; + double d28 = (double) (-1.0F + upMot); + double texHeight = (double) (length) * (0.5D / scale) + d28; + + tess.addVertexWithUV(x + d7, y + height, z + d9, texXMax, texHeight); + tess.addVertexWithUV(x + d7, y, z + d9, texXMax, d28); + tess.addVertexWithUV(x + d11, y, z + d13, texXMin, d28); + tess.addVertexWithUV(x + d11, y + height, z + d13, texXMin, texHeight); + + tess.addVertexWithUV(x + d19, y + height, z + d21, texXMax, texHeight); + tess.addVertexWithUV(x + d19, y, z + d21, texXMax, d28); + tess.addVertexWithUV(x + d15, y, z + d17, texXMin, d28); + tess.addVertexWithUV(x + d15, y + height, z + d17, texXMin, texHeight); + + tess.addVertexWithUV(x + d11, y + height, z + d13, texXMax, texHeight); + tess.addVertexWithUV(x + d11, y, z + d13, texXMax, d28); + tess.addVertexWithUV(x + d19, y, z + d21, texXMin, d28); + tess.addVertexWithUV(x + d19, y + height, z + d21, texXMin, texHeight); + + tess.addVertexWithUV(x + d15, y + height, z + d17, texXMax, texHeight); + tess.addVertexWithUV(x + d15, y, z + d17, texXMax, d28); + tess.addVertexWithUV(x + d7, y, z + d9, texXMin, d28); + tess.addVertexWithUV(x + d7, y + height, z + d9, texXMin, texHeight); + + rotation += 0.77f; + d7 = 0.5D + Math.cos(rotation + 2.356194490192345D) * scale; + d9 = 0.5D + Math.sin(rotation + 2.356194490192345D) * scale; + d11 = 0.5D + Math.cos(rotation + (Math.PI / 4D)) * scale; + d13 = 0.5D + Math.sin(rotation + (Math.PI / 4D)) * scale; + d15 = 0.5D + Math.cos(rotation + 3.9269908169872414D) * scale; + d17 = 0.5D + Math.sin(rotation + 3.9269908169872414D) * scale; + d19 = 0.5D + Math.cos(rotation + 5.497787143782138D) * scale; + d21 = 0.5D + Math.sin(rotation + 5.497787143782138D) * scale; + + d28 = (-1F + (upMot * 1)); + texHeight = (double) (length) * (0.5D / scale) + d28; + + tess.setColorRGBA_F(1.0F, 1.0f, 1.0f, 1f); + + tess.addVertexWithUV(x + d7, y + height, z + d9, texXMax, texHeight); + tess.addVertexWithUV(x + d7, y, z + d9, texXMax, d28); + tess.addVertexWithUV(x + d11, y, z + d13, texXMin, d28); + tess.addVertexWithUV(x + d11, y + height, z + d13, texXMin, texHeight); + + tess.addVertexWithUV(x + d19, y + height, z + d21, texXMax, texHeight); + tess.addVertexWithUV(x + d19, y, z + d21, texXMax, d28); + tess.addVertexWithUV(x + d15, y, z + d17, texXMin, d28); + tess.addVertexWithUV(x + d15, y + height, z + d17, texXMin, texHeight); + + tess.addVertexWithUV(x + d11, y + height, z + d13, texXMax, texHeight); + tess.addVertexWithUV(x + d11, y, z + d13, texXMax, d28); + tess.addVertexWithUV(x + d19, y, z + d21, texXMin, d28); + tess.addVertexWithUV(x + d19, y + height, z + d21, texXMin, texHeight); + + tess.addVertexWithUV(x + d15, y + height, z + d17, texXMax, texHeight); + tess.addVertexWithUV(x + d15, y, z + d17, texXMax, d28); + tess.addVertexWithUV(x + d7, y, z + d9, texXMin, d28); + tess.addVertexWithUV(x + d7, y + height, z + d9, texXMin, texHeight); + + tess.draw(); + GL11.glPushMatrix(); + + GL11.glTranslated(0, 0.4, 0); + length -= 0.5F; + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glDepthMask(false); + tess.startDrawingQuads(); + tess.setColorRGBA(255, 255, 255, 32); + double d30 = 0.2D; + double d4 = 0.2D; + double d6 = 0.8D; + double d8 = 0.2D; + double d10 = 0.2D; + double d12 = 0.8D; + double d14 = 0.8D; + double d16 = 0.8D; + double d18 = (double) (length); + double d20 = 0.0D; + double d22 = 1.0D; + double d24 = (double) (-1.0F + upMot); + double d26 = (double) (length) + d24; + tess.addVertexWithUV(x + d30, y + d18, z + d4, d22, d26); + tess.addVertexWithUV(x + d30, y, z + d4, d22, d24); + tess.addVertexWithUV(x + d6, y, z + d8, d20, d24); + tess.addVertexWithUV(x + d6, y + d18, z + d8, d20, d26); + tess.addVertexWithUV(x + d14, y + d18, z + d16, d22, d26); + tess.addVertexWithUV(x + d14, y, z + d16, d22, d24); + tess.addVertexWithUV(x + d10, y, z + d12, d20, d24); + tess.addVertexWithUV(x + d10, y + d18, z + d12, d20, d26); + tess.addVertexWithUV(x + d6, y + d18, z + d8, d22, d26); + tess.addVertexWithUV(x + d6, y, z + d8, d22, d24); + tess.addVertexWithUV(x + d14, y, z + d16, d20, d24); + tess.addVertexWithUV(x + d14, y + d18, z + d16, d20, d26); + tess.addVertexWithUV(x + d10, y + d18, z + d12, d22, d26); + tess.addVertexWithUV(x + d10, y, z + d12, d22, d24); + tess.addVertexWithUV(x + d30, y, z + d4, d20, d24); + tess.addVertexWithUV(x + d30, y + d18, z + d4, d20, d26); + tess.draw(); + GL11.glPopMatrix(); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + + } + + private void drawCornerCube(Tessellator tess, float x, float y, float z, float FP, boolean inverted, boolean stabalizerMode) { + float srcXMin = inverted ? 38F * pxl : 32F * pxl; + float srcYMin = 0F; + float srcXMax = inverted ? 44F * pxl : 38F * pxl; + float srcYMax = 6 * pxl; + //float FP = 0.6F; //Scale + float FN = 1F - FP; + + if (stabalizerMode) { + srcXMin = 44F * pxl; + srcXMax = 50F * pxl; + } + + //X+ + tess.addVertexWithUV(FP + x, FN + y, FN + z, srcXMin, srcYMin); + tess.addVertexWithUV(FP + x, FP + y, FN + z, srcXMax, srcYMin); + tess.addVertexWithUV(FP + x, FP + y, FP + z, srcXMax, srcYMax); + tess.addVertexWithUV(FP + x, FN + y, FP + z, srcXMin, srcYMax); + + //X- + tess.addVertexWithUV(FN + x, FN + y, FP + z, srcXMin, srcYMin); + tess.addVertexWithUV(FN + x, FP + y, FP + z, srcXMax, srcYMin); + tess.addVertexWithUV(FN + x, FP + y, FN + z, srcXMax, srcYMax); + tess.addVertexWithUV(FN + x, FN + y, FN + z, srcXMin, srcYMax); + + //Y+ + tess.addVertexWithUV(FN + x, FP + y, FN + z, srcXMin, srcYMin); + tess.addVertexWithUV(FN + x, FP + y, FP + z, srcXMax, srcYMin); + tess.addVertexWithUV(FP + x, FP + y, FP + z, srcXMax, srcYMax); + tess.addVertexWithUV(FP + x, FP + y, FN + z, srcXMin, srcYMax); + + //Y- + tess.addVertexWithUV(FN + x, FN + y, FN + z, srcXMin, srcYMin); + tess.addVertexWithUV(FP + x, FN + y, FN + z, srcXMax, srcYMin); + tess.addVertexWithUV(FP + x, FN + y, FP + z, srcXMax, srcYMax); + tess.addVertexWithUV(FN + x, FN + y, FP + z, srcXMin, srcYMax); + + //Z+ + tess.addVertexWithUV(FP + x, FN + y, FP + z, srcXMin, srcYMin); + tess.addVertexWithUV(FP + x, FP + y, FP + z, srcXMax, srcYMin); + tess.addVertexWithUV(FN + x, FP + y, FP + z, srcXMax, srcYMax); + tess.addVertexWithUV(FN + x, FN + y, FP + z, srcXMin, srcYMax); + + //Z- + tess.addVertexWithUV(FN + x, FN + y, FN + z, srcXMin, srcYMin); + tess.addVertexWithUV(FN + x, FP + y, FN + z, srcXMax, srcYMin); + tess.addVertexWithUV(FP + x, FP + y, FN + z, srcXMax, srcYMax); + tess.addVertexWithUV(FP + x, FN + y, FN + z, srcXMin, srcYMax); + } + + private void drawBeamX(Tessellator tess, float x, float y, float z, float FP) { + float srcXMin = 0; + float srcYMin = 0F; + float srcXMax = 32F * pxl; + float srcYMax = 4 * pxl; + float FN = 1F - FP; + + float XX = 0.9F; + float XM = 0.1F; + + //Y+ + tess.addVertexWithUV(XM, FP + y, FN + z, srcXMin, srcYMax); + tess.addVertexWithUV(XM, FP + y, FP + z, srcXMin, srcYMin); + tess.addVertexWithUV(XX, FP + y, FP + z, srcXMax, srcYMin); + tess.addVertexWithUV(XX, FP + y, FN + z, srcXMax, srcYMax); + + //Y- + tess.addVertexWithUV(XM, FN + y, FN + z, srcXMin, srcYMin); + tess.addVertexWithUV(XX, FN + y, FN + z, srcXMax, srcYMin); + tess.addVertexWithUV(XX, FN + y, FP + z, srcXMax, srcYMax); + tess.addVertexWithUV(XM, FN + y, FP + z, srcXMin, srcYMax); + + //Z+ + tess.addVertexWithUV(XX, FN + y, FP + z, srcXMin, srcYMax); + tess.addVertexWithUV(XX, FP + y, FP + z, srcXMin, srcYMin); + tess.addVertexWithUV(XM, FP + y, FP + z, srcXMax, srcYMin); + tess.addVertexWithUV(XM, FN + y, FP + z, srcXMax, srcYMax); + + //Z- + tess.addVertexWithUV(XM, FN + y, FN + z, srcXMin, srcYMax); + tess.addVertexWithUV(XM, FP + y, FN + z, srcXMin, srcYMin); + tess.addVertexWithUV(XX, FP + y, FN + z, srcXMax, srcYMin); + tess.addVertexWithUV(XX, FN + y, FN + z, srcXMax, srcYMax); + } + + private void drawBeamY(Tessellator tess, float x, float y, float z, float FP) { + float srcXMin = 0; + float srcYMin = 0F; + float srcXMax = 32F * pxl; + float srcYMax = 4 * pxl; + float FN = 1F - FP; + + float XX = 0.9F; + float XM = 0.1F; + + //X+ + tess.addVertexWithUV(FP + x, XM, FN + z, srcXMin, srcYMin); + tess.addVertexWithUV(FP + x, XX, FN + z, srcXMax, srcYMin); + tess.addVertexWithUV(FP + x, XX, FP + z, srcXMax, srcYMax); + tess.addVertexWithUV(FP + x, XM, FP + z, srcXMin, srcYMax); + + //X- + tess.addVertexWithUV(FN + x, XM, FP + z, srcXMin, srcYMin); + tess.addVertexWithUV(FN + x, XX, FP + z, srcXMax, srcYMin); + tess.addVertexWithUV(FN + x, XX, FN + z, srcXMax, srcYMax); + tess.addVertexWithUV(FN + x, XM, FN + z, srcXMin, srcYMax); + + //Z+ + tess.addVertexWithUV(FP + x, XM, FP + z, srcXMin, srcYMin); + tess.addVertexWithUV(FP + x, XX, FP + z, srcXMax, srcYMin); + tess.addVertexWithUV(FN + x, XX, FP + z, srcXMax, srcYMax); + tess.addVertexWithUV(FN + x, XM, FP + z, srcXMin, srcYMax); + + //Z- + tess.addVertexWithUV(FN + x, XM, FN + z, srcXMin, srcYMin); + tess.addVertexWithUV(FN + x, XX, FN + z, srcXMax, srcYMin); + tess.addVertexWithUV(FP + x, XX, FN + z, srcXMax, srcYMax); + tess.addVertexWithUV(FP + x, XM, FN + z, srcXMin, srcYMax); + + } + + private void drawBeamZ(Tessellator tess, float x, float y, float z, float FP) { + float srcXMin = 0; + float srcYMin = 0F; + float srcXMax = 32F * pxl; + float srcYMax = 4 * pxl; + float FN = 1F - FP; + + float XX = 0.9F; + float XM = 0.1F; + + //X+ + tess.addVertexWithUV(FP + x, FN + y, XM, srcXMin, srcYMax); + tess.addVertexWithUV(FP + x, FP + y, XM, srcXMin, srcYMin); + tess.addVertexWithUV(FP + x, FP + y, XX, srcXMax, srcYMin); + tess.addVertexWithUV(FP + x, FN + y, XX, srcXMax, srcYMax); + + //X- + tess.addVertexWithUV(FN + x, FN + y, XX, srcXMin, srcYMax); + tess.addVertexWithUV(FN + x, FP + y, XX, srcXMin, srcYMin); + tess.addVertexWithUV(FN + x, FP + y, XM, srcXMax, srcYMin); + tess.addVertexWithUV(FN + x, FN + y, XM, srcXMax, srcYMax); + + //Y+ + tess.addVertexWithUV(FN + x, FP + y, XM, srcXMin, srcYMin); + tess.addVertexWithUV(FN + x, FP + y, XX, srcXMax, srcYMin); + tess.addVertexWithUV(FP + x, FP + y, XX, srcXMax, srcYMax); + tess.addVertexWithUV(FP + x, FP + y, XM, srcXMin, srcYMax); + + //Y- + tess.addVertexWithUV(FN + x, FN + y, XM, srcXMin, srcYMax); + tess.addVertexWithUV(FP + x, FN + y, XM, srcXMin, srcYMin); + tess.addVertexWithUV(FP + x, FN + y, XX, srcXMax, srcYMin); + tess.addVertexWithUV(FN + x, FN + y, XX, srcXMax, srcYMax); + + } + + private void preRenderBeam(Tessellator tess, TileParticleGenerator gen, float f) { + GL11.glPushMatrix(); + + GL11.glTranslated(0, 0.5, 0.5); + GL11.glRotatef(90F + gen.beam_pitch, 1F, 0F, 0F); + GL11.glTranslated(0, 0, -0.5); + + GL11.glTranslated(0.5, 0, 0); + GL11.glRotatef(gen.beam_yaw, 0F, 0F, 1F); + GL11.glTranslated(-0.5, 0, 0); + + renderBeam(tess, gen, f); + GL11.glPopMatrix(); + + if (gen.render_core) { + GL11.glPushMatrix(); + GL11.glTranslated(0, 0.5, 0); + renderStabilizerSphere(gen); + GL11.glPopMatrix(); + } + } + + private void renderBeam(Tessellator tess, TileParticleGenerator tile, float f) { + int x = 0; + int y = 0; + int z = 0; + double length = tile.beam_length; + float red = (float) tile.beam_red / 255F; + float green = (float) tile.beam_green / 255F; + float blue = (float) tile.beam_blue / 255F; + + GL11.glPushMatrix(); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + + bindTexture(beamTexture); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + OpenGlHelper.glBlendFunc(770, 1, 1, 0); + + //float time = (float)tile.getWorldObj().getTotalWorldTime() + f; + float time = tile.rotation + f; + float upMot = -time * 0.2F - (float) MathHelper.floor_float(-time * 0.1F); + float rotValue = tile.beam_rotation * (tile.rotation + f * 0.5F); + double rotation = rotValue; + + + tess.startDrawingQuads(); + tess.setBrightness(200); + tess.setColorRGBA(tile.beam_red, tile.beam_green, tile.beam_blue, 32); + + double scale = (double) tile.beam_scale * 0.2D; + double d7 = 0.5D + Math.cos(rotation + 2.356194490192345D) * scale; //x point 1 + double d9 = 0.5D + Math.sin(rotation + 2.356194490192345D) * scale; //z point 1 + double d11 = 0.5D + Math.cos(rotation + (Math.PI / 4D)) * scale; //x point 2 + double d13 = 0.5D + Math.sin(rotation + (Math.PI / 4D)) * scale; //z point 2 + double d15 = 0.5D + Math.cos(rotation + 3.9269908169872414D) * scale;//Dist from x-3 + double d17 = 0.5D + Math.sin(rotation + 3.9269908169872414D) * scale; + double d19 = 0.5D + Math.cos(rotation + 5.497787143782138D) * scale; + double d21 = 0.5D + Math.sin(rotation + 5.497787143782138D) * scale; + double height = (double) (length); + double texXMin = 0.0D; + double texXMax = 1.0D; + double d28 = (double) (-1.0F + upMot); + double texHeight = (double) (length) * (0.5D / scale) + d28; + + tess.addVertexWithUV(x + d7, y + height, z + d9, texXMax, texHeight); + tess.addVertexWithUV(x + d7, y, z + d9, texXMax, d28); + tess.addVertexWithUV(x + d11, y, z + d13, texXMin, d28); + tess.addVertexWithUV(x + d11, y + height, z + d13, texXMin, texHeight); + + tess.addVertexWithUV(x + d19, y + height, z + d21, texXMax, texHeight); + tess.addVertexWithUV(x + d19, y, z + d21, texXMax, d28); + tess.addVertexWithUV(x + d15, y, z + d17, texXMin, d28); + tess.addVertexWithUV(x + d15, y + height, z + d17, texXMin, texHeight); + + tess.addVertexWithUV(x + d11, y + height, z + d13, texXMax, texHeight); + tess.addVertexWithUV(x + d11, y, z + d13, texXMax, d28); + tess.addVertexWithUV(x + d19, y, z + d21, texXMin, d28); + tess.addVertexWithUV(x + d19, y + height, z + d21, texXMin, texHeight); + + tess.addVertexWithUV(x + d15, y + height, z + d17, texXMax, texHeight); + tess.addVertexWithUV(x + d15, y, z + d17, texXMax, d28); + tess.addVertexWithUV(x + d7, y, z + d9, texXMin, d28); + tess.addVertexWithUV(x + d7, y + height, z + d9, texXMin, texHeight); + + rotation += 0.77f; + d7 = 0.5D + Math.cos(rotation + 2.356194490192345D) * scale; + d9 = 0.5D + Math.sin(rotation + 2.356194490192345D) * scale; + d11 = 0.5D + Math.cos(rotation + (Math.PI / 4D)) * scale; + d13 = 0.5D + Math.sin(rotation + (Math.PI / 4D)) * scale; + d15 = 0.5D + Math.cos(rotation + 3.9269908169872414D) * scale; + d17 = 0.5D + Math.sin(rotation + 3.9269908169872414D) * scale; + d19 = 0.5D + Math.cos(rotation + 5.497787143782138D) * scale; + d21 = 0.5D + Math.sin(rotation + 5.497787143782138D) * scale; + + d28 = (-1F + (upMot * 1)); + texHeight = (double) (length) * (0.5D / scale) + d28; + + tess.setColorRGBA_F(red, green, blue, 1f); + + tess.addVertexWithUV(x + d7, y + height, z + d9, texXMax, texHeight); + tess.addVertexWithUV(x + d7, y, z + d9, texXMax, d28); + tess.addVertexWithUV(x + d11, y, z + d13, texXMin, d28); + tess.addVertexWithUV(x + d11, y + height, z + d13, texXMin, texHeight); + + tess.addVertexWithUV(x + d19, y + height, z + d21, texXMax, texHeight); + tess.addVertexWithUV(x + d19, y, z + d21, texXMax, d28); + tess.addVertexWithUV(x + d15, y, z + d17, texXMin, d28); + tess.addVertexWithUV(x + d15, y + height, z + d17, texXMin, texHeight); + + tess.addVertexWithUV(x + d11, y + height, z + d13, texXMax, texHeight); + tess.addVertexWithUV(x + d11, y, z + d13, texXMax, d28); + tess.addVertexWithUV(x + d19, y, z + d21, texXMin, d28); + tess.addVertexWithUV(x + d19, y + height, z + d21, texXMin, texHeight); + + tess.addVertexWithUV(x + d15, y + height, z + d17, texXMax, texHeight); + tess.addVertexWithUV(x + d15, y, z + d17, texXMax, d28); + tess.addVertexWithUV(x + d7, y, z + d9, texXMin, d28); + tess.addVertexWithUV(x + d7, y + height, z + d9, texXMin, texHeight); + + tess.draw(); + GL11.glPushMatrix(); + + //GL11.glTranslated(0, 0.4, 0); + //length -= 0.5F; + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glDepthMask(false); + GL11.glTranslated(0.5, 0, 0.5); + GL11.glScalef(tile.beam_scale, 1f, tile.beam_scale); + GL11.glTranslated(-0.5, -0, -0.5); + tess.startDrawingQuads(); + tess.setColorRGBA(tile.beam_red, tile.beam_green, tile.beam_blue, 32); + double d30 = 0.2D; + double d4 = 0.2D; + double d6 = 0.8D; + double d8 = 0.2D; + double d10 = 0.2D; + double d12 = 0.8D; + double d14 = 0.8D; + double d16 = 0.8D; + double d18 = (double) (length); + double d20 = 0.0D; + double d22 = 1D; + double d24 = (double) (-1.0F + upMot); + double d26 = (double) (length) + d24; + tess.addVertexWithUV(x + d30, y + d18, z + d4, d22, d26); + tess.addVertexWithUV(x + d30, y, z + d4, d22, d24); + tess.addVertexWithUV(x + d6, y, z + d8, d20, d24); + tess.addVertexWithUV(x + d6, y + d18, z + d8, d20, d26); + tess.addVertexWithUV(x + d14, y + d18, z + d16, d22, d26); + tess.addVertexWithUV(x + d14, y, z + d16, d22, d24); + tess.addVertexWithUV(x + d10, y, z + d12, d20, d24); + tess.addVertexWithUV(x + d10, y + d18, z + d12, d20, d26); + tess.addVertexWithUV(x + d6, y + d18, z + d8, d22, d26); + tess.addVertexWithUV(x + d6, y, z + d8, d22, d24); + tess.addVertexWithUV(x + d14, y, z + d16, d20, d24); + tess.addVertexWithUV(x + d14, y + d18, z + d16, d20, d26); + tess.addVertexWithUV(x + d10, y + d18, z + d12, d22, d26); + tess.addVertexWithUV(x + d10, y, z + d12, d22, d24); + tess.addVertexWithUV(x + d30, y, z + d4, d20, d24); + tess.addVertexWithUV(x + d30, y + d18, z + d4, d20, d26); + tess.draw(); + GL11.glPopMatrix(); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); // // GL11.glEnable(GL11.GL_LIGHTING); // GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); - } + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTilePlacedItem.java b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTilePlacedItem.java index 5882cb4d..845af836 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTilePlacedItem.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTilePlacedItem.java @@ -20,152 +20,152 @@ import org.lwjgl.opengl.GL11; */ public class RenderTilePlacedItem extends TileEntitySpecialRenderer { - public RenderTilePlacedItem() - { - } - @Override - public void renderTileEntityAt(TileEntity te, double x, double y, double z, float timeSinceLastTick) { - if (te == null || !(te instanceof TilePlacedItem)) return; - TilePlacedItem tile = (TilePlacedItem) te; - if (tile.getStack() == null) return; - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glTranslated(x, y, z); - renderItem(tile); - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + public RenderTilePlacedItem() { + } - public void renderItem(TilePlacedItem tile){ - ItemStack stack = tile.getStack(); - World world = Minecraft.getMinecraft().theWorld; - EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, stack); - int meta = world.getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord); - //itemEntity.getEntityItem().stackSize = 1; - itemEntity.hoverStart = 0.0F; - boolean is3D = stack.getItem().isFull3D(); - boolean isBlock = stack.getItem() instanceof ItemBlock; + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float timeSinceLastTick) { + if (te == null || !(te instanceof TilePlacedItem)) return; + TilePlacedItem tile = (TilePlacedItem) te; + if (tile.getStack() == null) return; + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glTranslated(x, y, z); + renderItem(tile); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } - if (isBlock){ - GL11.glTranslatef(0.5F, 0.25F, 0.5F); - GL11.glScalef(1.5F, 1.5F, 1.5F); - metaAdjustBlock(meta); - GL11.glRotatef(tile.rotation, 0F, 1F, 0F); - }else if (is3D || stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemBow){ - GL11.glScalef(2F, 2F, 2F); - GL11.glRotatef(90F, -1F, 0F, 0F); - GL11.glTranslatef(0.25F, -0.45F, 0.02F); - metaAdjustItemTool(meta); - GL11.glTranslatef(0.0F, 0.21F, 0.0F); - GL11.glRotatef(tile.rotation, 0F, 0F, 1F); - GL11.glTranslatef(0.0F, -0.21F, 0.0F); - } else if (stack.getItem() instanceof MobSoul) { + public void renderItem(TilePlacedItem tile) { + ItemStack stack = tile.getStack(); + World world = Minecraft.getMinecraft().theWorld; + EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, stack); + int meta = world.getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord); + //itemEntity.getEntityItem().stackSize = 1; + itemEntity.hoverStart = 0.0F; + boolean is3D = stack.getItem().isFull3D(); + boolean isBlock = stack.getItem() instanceof ItemBlock; - GL11.glTranslatef(0.5F, 0.3F, 0.5F); - }else { - GL11.glRotatef(90F, -1F, 0F, 0F); - GL11.glTranslatef(0.5F, -0.65F, 0.02F); - metaAdjustItem(meta); - GL11.glTranslatef(0.0F, 0.18F, 0.0F); - GL11.glRotatef(tile.rotation, 0F, 0F, 1F); - GL11.glTranslatef(0.0F, -0.18F, 0.0F); - } + if (isBlock) { + GL11.glTranslatef(0.5F, 0.25F, 0.5F); + GL11.glScalef(1.5F, 1.5F, 1.5F); + metaAdjustBlock(meta); + GL11.glRotatef(tile.rotation, 0F, 1F, 0F); + } else if (is3D || stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemBow) { + GL11.glScalef(2F, 2F, 2F); + GL11.glRotatef(90F, -1F, 0F, 0F); + GL11.glTranslatef(0.25F, -0.45F, 0.02F); + metaAdjustItemTool(meta); + GL11.glTranslatef(0.0F, 0.21F, 0.0F); + GL11.glRotatef(tile.rotation, 0F, 0F, 1F); + GL11.glTranslatef(0.0F, -0.21F, 0.0F); + } else if (stack.getItem() instanceof MobSoul) { - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - RenderItem.renderInFrame = true; - RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - RenderItem.renderInFrame = false; - GL11.glDisable(GL11.GL_BLEND); - } + GL11.glTranslatef(0.5F, 0.3F, 0.5F); + } else { + GL11.glRotatef(90F, -1F, 0F, 0F); + GL11.glTranslatef(0.5F, -0.65F, 0.02F); + metaAdjustItem(meta); + GL11.glTranslatef(0.0F, 0.18F, 0.0F); + GL11.glRotatef(tile.rotation, 0F, 0F, 1F); + GL11.glTranslatef(0.0F, -0.18F, 0.0F); + } - private void metaAdjustItemTool(int meta){ - switch (meta){ - case 0: - GL11.glRotatef(180F, 0F, 1F, 0F); - GL11.glTranslatef(0.0F, 0.0F, -0.46F); - break; - case 1: - break; - case 2: - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glRotatef(180F, 0F, 1F, 0F); - GL11.glTranslatef(0.0F, 0.02F, -0.03F); - break; - case 3: - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glTranslatef(0.0F, 0.02F, -0.43F); - break; - case 4: - GL11.glRotatef(90F, 0F, -1F, 0F); - GL11.glRotatef(90F, 0F, 0F, -1F); - GL11.glTranslatef(-0.205F, 0.02F, -0.23F); - break; - case 5: - GL11.glRotatef(90F, 0F, -1F, 0F); - GL11.glRotatef(90F, 0F, 0F, -1F); - GL11.glRotatef(180F, 0F, 1F, 0F); - GL11.glTranslatef(0.223F, 0.0F, -0.23F); - break; - } - } + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + GL11.glDisable(GL11.GL_BLEND); + } - private void metaAdjustItem(int meta){ - switch (meta){ - case 0: - GL11.glRotatef(180F, 0F, 1F, 0F); - GL11.glTranslatef(0.0F, 0.0F, -0.96F); - break; - case 1: - break; - case 2: - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glRotatef(180F, 0F, 1F, 0F); - GL11.glTranslatef(0.0F, 0.32F, -0.33F); - break; - case 3: - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glTranslatef(0.0F, 0.3F, -0.63F); - break; - case 4: - GL11.glRotatef(90F, 0F, -1F, 0F); - GL11.glRotatef(90F, 0F, 0F, -1F); - GL11.glTranslatef(-0.17F, 0.302F, -0.475F); - break; - case 5: - GL11.glRotatef(90F, 0F, -1F, 0F); - GL11.glRotatef(90F, 0F, 0F, -1F); - GL11.glRotatef(180F, 0F, 1F, 0F); - GL11.glTranslatef(0.15F, 0.3F, -0.475F); - break; - } - } + private void metaAdjustItemTool(int meta) { + switch (meta) { + case 0: + GL11.glRotatef(180F, 0F, 1F, 0F); + GL11.glTranslatef(0.0F, 0.0F, -0.46F); + break; + case 1: + break; + case 2: + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glRotatef(180F, 0F, 1F, 0F); + GL11.glTranslatef(0.0F, 0.02F, -0.03F); + break; + case 3: + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glTranslatef(0.0F, 0.02F, -0.43F); + break; + case 4: + GL11.glRotatef(90F, 0F, -1F, 0F); + GL11.glRotatef(90F, 0F, 0F, -1F); + GL11.glTranslatef(-0.205F, 0.02F, -0.23F); + break; + case 5: + GL11.glRotatef(90F, 0F, -1F, 0F); + GL11.glRotatef(90F, 0F, 0F, -1F); + GL11.glRotatef(180F, 0F, 1F, 0F); + GL11.glTranslatef(0.223F, 0.0F, -0.23F); + break; + } + } - private void metaAdjustBlock(int meta){ - switch (meta){ - case 0: - GL11.glTranslatef(0.0F, 0.51F, 0.0F); - GL11.glRotatef(180F, 0F, 0F, 1F); - break; - case 1: - GL11.glTranslatef(0.0F, -0.17F, 0.0F); - break; - case 2: - GL11.glTranslatef(-0.0F, 0.17F, 0.34F); - GL11.glRotatef(90F, -1F, 0F, 0F); - break; - case 3: - GL11.glTranslatef(0.0F, 0.17F, -0.34F); - GL11.glRotatef(90F, 1F, 0F, 0F); - break; - case 4: - GL11.glTranslatef(0.34F, 0.17F, 0.0F); - GL11.glRotatef(90F, 0F, 0F, 1F); - break; - case 5: - GL11.glTranslatef(-0.34F, 0.17F, 0.0F); - GL11.glRotatef(90F, 0F, 0F, -1F); - break; - } - } + private void metaAdjustItem(int meta) { + switch (meta) { + case 0: + GL11.glRotatef(180F, 0F, 1F, 0F); + GL11.glTranslatef(0.0F, 0.0F, -0.96F); + break; + case 1: + break; + case 2: + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glRotatef(180F, 0F, 1F, 0F); + GL11.glTranslatef(0.0F, 0.32F, -0.33F); + break; + case 3: + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glTranslatef(0.0F, 0.3F, -0.63F); + break; + case 4: + GL11.glRotatef(90F, 0F, -1F, 0F); + GL11.glRotatef(90F, 0F, 0F, -1F); + GL11.glTranslatef(-0.17F, 0.302F, -0.475F); + break; + case 5: + GL11.glRotatef(90F, 0F, -1F, 0F); + GL11.glRotatef(90F, 0F, 0F, -1F); + GL11.glRotatef(180F, 0F, 1F, 0F); + GL11.glTranslatef(0.15F, 0.3F, -0.475F); + break; + } + } + + private void metaAdjustBlock(int meta) { + switch (meta) { + case 0: + GL11.glTranslatef(0.0F, 0.51F, 0.0F); + GL11.glRotatef(180F, 0F, 0F, 1F); + break; + case 1: + GL11.glTranslatef(0.0F, -0.17F, 0.0F); + break; + case 2: + GL11.glTranslatef(-0.0F, 0.17F, 0.34F); + GL11.glRotatef(90F, -1F, 0F, 0F); + break; + case 3: + GL11.glTranslatef(0.0F, 0.17F, -0.34F); + GL11.glRotatef(90F, 1F, 0F, 0F); + break; + case 4: + GL11.glTranslatef(0.34F, 0.17F, 0.0F); + GL11.glRotatef(90F, 0F, 0F, 1F); + break; + case 5: + GL11.glTranslatef(-0.34F, 0.17F, 0.0F); + GL11.glRotatef(90F, 0F, 0F, -1F); + break; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileReactorCore.java b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileReactorCore.java index 1f064251..06f256ec 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileReactorCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileReactorCore.java @@ -15,21 +15,21 @@ import org.lwjgl.opengl.GL11; * Created by Brandon on 16/6/2015. */ public class RenderTileReactorCore extends TileEntitySpecialRenderer { - public static IModelCustom reactorModel; + public static IModelCustom reactorModel; - public RenderTileReactorCore(){ - reactorModel = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/reactorCoreModel.obj")); - } + public RenderTileReactorCore() { + reactorModel = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/reactorCoreModel.obj")); + } - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { - TileReactorCore tile = (TileReactorCore) tileEntity; + @Override + public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { + TileReactorCore tile = (TileReactorCore) tileEntity; // tile.renderList.clear(); - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); - renderReactorCore(tile, partialTick); + renderReactorCore(tile, partialTick); // for (MultiblockHelper.TileOffset offset : tile.stabilizerLocations){ // if (!(offset.getTileEntity(tileEntity) instanceof TileReactorStabilizer)) continue; // GL11.glPushMatrix(); @@ -42,69 +42,69 @@ public class RenderTileReactorCore extends TileEntitySpecialRenderer { // GL11.glPopMatrix(); // } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - public void renderReactorCore(TileReactorCore tile, float partialTick) { - float rotation = (tile.renderRotation * 0.2F) + (partialTick * (tile.renderSpeed * 0.2F)); - double ff = tile.maxFieldCharge > 0 ? tile.fieldCharge / tile.maxFieldCharge : 0; - double r = ff < 0.5 ? 1 - (ff*2) : 0; - double g = ff > 0.5 ? (ff-0.5)*2 : 0; - double b = ff * 2; - double a = ff < 0.1 ? (ff * 10) : 1; + public void renderReactorCore(TileReactorCore tile, float partialTick) { + float rotation = (tile.renderRotation * 0.2F) + (partialTick * (tile.renderSpeed * 0.2F)); + double ff = tile.maxFieldCharge > 0 ? tile.fieldCharge / tile.maxFieldCharge : 0; + double r = ff < 0.5 ? 1 - (ff * 2) : 0; + double g = ff > 0.5 ? (ff - 0.5) * 2 : 0; + double b = ff * 2; + double a = ff < 0.1 ? (ff * 10) : 1; - //Pre Render - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - float lastBrightnessX = OpenGlHelper.lastBrightnessX; - float lastBrightnessY = OpenGlHelper.lastBrightnessY; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); + //Pre Render + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + float lastBrightnessX = OpenGlHelper.lastBrightnessX; + float lastBrightnessY = OpenGlHelper.lastBrightnessY; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); - //Render inner - if (tile.reactorFuel + tile.convertedFuel < 144){ - ResourceHandler.bindResource("textures/blocks/draconic_block_blank.png"); - GL11.glPushMatrix(); - GL11.glScaled(0.1, 0.1, 0.1); - reactorModel.renderAll(); - GL11.glPopMatrix(); - } + //Render inner + if (tile.reactorFuel + tile.convertedFuel < 144) { + ResourceHandler.bindResource("textures/blocks/draconic_block_blank.png"); + GL11.glPushMatrix(); + GL11.glScaled(0.1, 0.1, 0.1); + reactorModel.renderAll(); + GL11.glPopMatrix(); + } - ResourceHandler.bindResource("textures/models/reactorCore.png"); - GL11.glColor4d(1, 1, 1, 1); - GL11.glRotatef(rotation, 0.5F, 1F, 0.5F); - GL11.glScaled(0.5, 0.5, 0.5); - double r3 = tile.getCoreDiameter(); - GL11.glScaled(r3, r3, r3); - reactorModel.renderAll(); + ResourceHandler.bindResource("textures/models/reactorCore.png"); + GL11.glColor4d(1, 1, 1, 1); + GL11.glRotatef(rotation, 0.5F, 1F, 0.5F); + GL11.glScaled(0.5, 0.5, 0.5); + double r3 = tile.getCoreDiameter(); + GL11.glScaled(r3, r3, r3); + reactorModel.renderAll(); - //Mid Render - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glAlphaFunc(GL11.GL_GREATER, 0F); + //Mid Render + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glAlphaFunc(GL11.GL_GREATER, 0F); - if (tile.reactionTemperature < 2000) - { - ResourceHandler.bindResource("textures/blocks/draconic_block_blank.png"); - if (tile.reactionTemperature > 1000) GL11.glColor4d(1F, 1F, 1F, 1D - ((tile.reactionTemperature-1000) / 1000D)); - reactorModel.renderAll(); - } + if (tile.reactionTemperature < 2000) { + ResourceHandler.bindResource("textures/blocks/draconic_block_blank.png"); + if (tile.reactionTemperature > 1000) + GL11.glColor4d(1F, 1F, 1F, 1D - ((tile.reactionTemperature - 1000) / 1000D)); + reactorModel.renderAll(); + } - //Render Outer - ResourceHandler.bindResource("textures/models/reactorShieldPlate.png"); - GL11.glColor4d(r, g, b, a); - GL11.glScaled(1.03F, 1.03F, 1.03F); - GL11.glRotatef(2343, 0.5F, 1F, 0.5F); - GL11.glRotatef(-rotation*2, 0.5F, 1F, 0.5F); - reactorModel.renderAll(); + //Render Outer + ResourceHandler.bindResource("textures/models/reactorShieldPlate.png"); + GL11.glColor4d(r, g, b, a); + GL11.glScaled(1.03F, 1.03F, 1.03F); + GL11.glRotatef(2343, 0.5F, 1F, 0.5F); + GL11.glRotatef(-rotation * 2, 0.5F, 1F, 0.5F); + reactorModel.renderAll(); - //Post Render - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - GL11.glColor4f(1f, 1f, 1f, 1f); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastBrightnessX, lastBrightnessY); - GL11.glPopMatrix(); - } + //Post Render + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1f, 1f, 1f, 1f); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastBrightnessX, lastBrightnessY); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileReactorEnergyInjector.java b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileReactorEnergyInjector.java index ef19c050..d6aed6b7 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileReactorEnergyInjector.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileReactorEnergyInjector.java @@ -12,34 +12,43 @@ import org.lwjgl.opengl.GL11; */ public class RenderTileReactorEnergyInjector extends TileEntitySpecialRenderer { - public static ModelReactorEnergyInjector modelReactorEnergyInjector = new ModelReactorEnergyInjector(); + public static ModelReactorEnergyInjector modelReactorEnergyInjector = new ModelReactorEnergyInjector(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + @Override + public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); - renderCore((TileReactorEnergyInjector) tileEntity, partialTick); + renderCore((TileReactorEnergyInjector) tileEntity, partialTick); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - public static void renderCore(TileReactorEnergyInjector tile, float partialTick) { - GL11.glPushMatrix(); - float scale = (1F / 16F); + public static void renderCore(TileReactorEnergyInjector tile, float partialTick) { + GL11.glPushMatrix(); + float scale = (1F / 16F); - switch (tile.facingDirection){ - case 1: GL11.glRotated(180, -1, 0, 0); break; - case 2: GL11.glRotated(90, 1, 0, 0); break; - case 3: GL11.glRotated(90, -1, 0, 0); break; - case 4: GL11.glRotated(90, 0, 0, -1); break; - case 5: GL11.glRotated(90, 0, 0, 1); - } + switch (tile.facingDirection) { + case 1: + GL11.glRotated(180, -1, 0, 0); + break; + case 2: + GL11.glRotated(90, 1, 0, 0); + break; + case 3: + GL11.glRotated(90, -1, 0, 0); + break; + case 4: + GL11.glRotated(90, 0, 0, -1); + break; + case 5: + GL11.glRotated(90, 0, 0, 1); + } - ResourceHandler.bindResource("textures/models/ModelReactorPowerInjector.png"); - modelReactorEnergyInjector.render(null, tile.modelIllumination, 0F, 0F, 0F, 0F, scale); + ResourceHandler.bindResource("textures/models/ModelReactorPowerInjector.png"); + modelReactorEnergyInjector.render(null, tile.modelIllumination, 0F, 0F, 0F, 0F, scale); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileReactorStabilizer.java b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileReactorStabilizer.java index b79d12b3..a060af52 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileReactorStabilizer.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileReactorStabilizer.java @@ -13,45 +13,54 @@ import org.lwjgl.opengl.GL11; */ public class RenderTileReactorStabilizer extends TileEntitySpecialRenderer { - public static ModelReactorStabilizerRing modelStabilizerRing = new ModelReactorStabilizerRing(); - public static ModelReactorStabilizerCore modelStabilizerCore = new ModelReactorStabilizerCore(); + public static ModelReactorStabilizerRing modelStabilizerRing = new ModelReactorStabilizerRing(); + public static ModelReactorStabilizerCore modelStabilizerCore = new ModelReactorStabilizerCore(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + @Override + public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); - renderCore((TileReactorStabilizer) tileEntity, partialTick); - //renderEffects((TileReactorStabilizer) tileEntity, partialTick); + renderCore((TileReactorStabilizer) tileEntity, partialTick); + //renderEffects((TileReactorStabilizer) tileEntity, partialTick); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - public static void renderCore(TileReactorStabilizer tile, float partialTick) { - GL11.glPushMatrix(); - float scale = (1F / 16F); - float coreRotation = tile.coreRotation + (partialTick * tile.coreSpeed); - float ringRotation = tile.ringRotation + (partialTick * tile.ringSpeed); + public static void renderCore(TileReactorStabilizer tile, float partialTick) { + GL11.glPushMatrix(); + float scale = (1F / 16F); + float coreRotation = tile.coreRotation + (partialTick * tile.coreSpeed); + float ringRotation = tile.ringRotation + (partialTick * tile.ringSpeed); - switch (tile.facingDirection){ - case 0: GL11.glRotated(90, -1, 0, 0); break; - case 1: GL11.glRotated(90, 1, 0, 0); break; - case 3: GL11.glRotated(180, 1, 0, 0); break; - case 4: GL11.glRotated(90, 0, 1, 0); break; - case 5: GL11.glRotated(90, 0, -1, 0); - } + switch (tile.facingDirection) { + case 0: + GL11.glRotated(90, -1, 0, 0); + break; + case 1: + GL11.glRotated(90, 1, 0, 0); + break; + case 3: + GL11.glRotated(180, 1, 0, 0); + break; + case 4: + GL11.glRotated(90, 0, 1, 0); + break; + case 5: + GL11.glRotated(90, 0, -1, 0); + } - ResourceHandler.bindResource("textures/models/reactorStabilizerCore.png"); - modelStabilizerCore.render(null, coreRotation, tile.modelIllumination, 0F, 0F, 0F, scale); + ResourceHandler.bindResource("textures/models/reactorStabilizerCore.png"); + modelStabilizerCore.render(null, coreRotation, tile.modelIllumination, 0F, 0F, 0F, scale); - ResourceHandler.bindResource("textures/models/reactorStabilizerRing.png"); - GL11.glRotated(90, 1, 0, 0); - GL11.glTranslated(0, -0.58, 0); - GL11.glScaled(0.95, 0.95, 0.95); - GL11.glRotatef(ringRotation, 0, 1, 0); - modelStabilizerRing.render(null, -70F, tile.modelIllumination, 0F, 0F, 0F, scale); - GL11.glPopMatrix(); - } + ResourceHandler.bindResource("textures/models/reactorStabilizerRing.png"); + GL11.glRotated(90, 1, 0, 0); + GL11.glTranslated(0, -0.58, 0); + GL11.glScaled(0.95, 0.95, 0.95); + GL11.glRotatef(ringRotation, 0, 1, 0); + modelStabilizerRing.render(null, -70F, tile.modelIllumination, 0F, 0F, 0F, scale); + GL11.glPopMatrix(); + } // public static void renderEffects(TileReactorStabilizer tile, float partialTick) { // if (tile.isValid) diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileTeleporterStand.java b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileTeleporterStand.java index 5c053cc0..e0384ecc 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileTeleporterStand.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileTeleporterStand.java @@ -29,140 +29,138 @@ import java.awt.*; /** * Created by Brandon on 25/10/2014. */ -public class RenderTileTeleporterStand extends TileEntitySpecialRenderer{ +public class RenderTileTeleporterStand extends TileEntitySpecialRenderer { - ModelTeleporterStand model = new ModelTeleporterStand(); + ModelTeleporterStand model = new ModelTeleporterStand(); - private final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/TeleporterStand.png"); + private final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/TeleporterStand.png"); - @Override - public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { + @Override + public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { - ItemStack item = null; - int rotation = 0; - if (tileentity instanceof TileTeleporterStand){ - item = ((TileTeleporterStand) tileentity).getStackInSlot(0); - rotation = ((TileTeleporterStand) tileentity).rotation; - } + ItemStack item = null; + int rotation = 0; + if (tileentity instanceof TileTeleporterStand) { + item = ((TileTeleporterStand) tileentity).getStackInSlot(0); + rotation = ((TileTeleporterStand) tileentity).rotation; + } - GL11.glPushMatrix(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glTranslatef((float) x, (float) y, (float) z); - GL11.glColor4f(1F, 1F, 1F, 1F); - Minecraft.getMinecraft().renderEngine.bindTexture(texture); + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glTranslatef((float) x, (float) y, (float) z); + GL11.glColor4f(1F, 1F, 1F, 1F); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - GL11.glScalef(1F, -1F, -1F); - GL11.glRotated(rotation, 0, 1, 0); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glScalef(1F, -1F, -1F); + GL11.glRotated(rotation, 0, 1, 0); - model.render(); - if (item != null) drawNameString(item, rotation, tileentity, f); + model.render(); + if (item != null) drawNameString(item, rotation, tileentity, f); - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glTranslatef(0F, 0F, -0.6F); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - if (item != null) renderItem(tileentity, item, f); - GL11.glPopMatrix(); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glTranslatef(0F, 0F, -0.6F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + if (item != null) renderItem(tileentity, item, f); + GL11.glPopMatrix(); - } + } - public void renderItem(TileEntity tile, ItemStack item, float f){ - if (item.getItem() == null) return; - GL11.glPushMatrix(); + public void renderItem(TileEntity tile, ItemStack item, float f) { + if (item.getItem() == null) return; + GL11.glPushMatrix(); - EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, item); - itemEntity.hoverStart = 0.0F; + EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, item); + itemEntity.hoverStart = 0.0F; - if (item.getItem() instanceof TeleporterMKII) { - GL11.glTranslatef(0F, 0.18F, 0.864F); - GL11.glRotated(180, 0, 0, 1); - GL11.glRotated(30, 1, 0, 0); - GL11.glScalef(1F, 1F, 1F); - }else{ - GL11.glTranslatef(0F, 0.22F, 0.84F); - GL11.glRotated(180, 0, 0, 1); - GL11.glRotated(30, 1, 0, 0); - GL11.glScalef(1F, 1F, 1F); - } + if (item.getItem() instanceof TeleporterMKII) { + GL11.glTranslatef(0F, 0.18F, 0.864F); + GL11.glRotated(180, 0, 0, 1); + GL11.glRotated(30, 1, 0, 0); + GL11.glScalef(1F, 1F, 1F); + } else { + GL11.glTranslatef(0F, 0.22F, 0.84F); + GL11.glRotated(180, 0, 0, 1); + GL11.glRotated(30, 1, 0, 0); + GL11.glScalef(1F, 1F, 1F); + } - RenderItem.renderInFrame = true; - RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - RenderItem.renderInFrame = false; + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - private void drawNameString(ItemStack item, float rotation, TileEntity tileentity, float f){ - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; - MovingObjectPosition mop = player.rayTrace(10, f); - boolean isCursorOver = mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && mop.blockX == tileentity.xCoord && mop.blockY == tileentity.yCoord && mop.blockZ == tileentity.zCoord; - boolean isSneaking = player.isSneaking(); + private void drawNameString(ItemStack item, float rotation, TileEntity tileentity, float f) { + EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + MovingObjectPosition mop = player.rayTrace(10, f); + boolean isCursorOver = mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && mop.blockX == tileentity.xCoord && mop.blockY == tileentity.yCoord && mop.blockZ == tileentity.zCoord; + boolean isSneaking = player.isSneaking(); - if (!isCursorOver && (isSneaking != ConfigHandler.invertDPDSB)) return; + if (!isCursorOver && (isSneaking != ConfigHandler.invertDPDSB)) return; - String s = item.hasDisplayName() ? item.getDisplayName() : ""; - if (item.getItem() instanceof TeleporterMKII) - { - short selected = ItemNBTHelper.getShort(item, "Selection", (short) 0); - int selrctionOffset = ItemNBTHelper.getInteger(item, "SelectionOffset", 0); - NBTTagCompound compound = item.getTagCompound(); - if(compound == null) compound = new NBTTagCompound(); - NBTTagList list = (NBTTagList)compound.getTag("Locations"); - if (list == null) list = new NBTTagList(); - s = list.getCompoundTagAt(selected+selrctionOffset).getString("Name"); - } - if (s.isEmpty()) return; + String s = item.hasDisplayName() ? item.getDisplayName() : ""; + if (item.getItem() instanceof TeleporterMKII) { + short selected = ItemNBTHelper.getShort(item, "Selection", (short) 0); + int selrctionOffset = ItemNBTHelper.getInteger(item, "SelectionOffset", 0); + NBTTagCompound compound = item.getTagCompound(); + if (compound == null) compound = new NBTTagCompound(); + NBTTagList list = (NBTTagList) compound.getTag("Locations"); + if (list == null) list = new NBTTagList(); + s = list.getCompoundTagAt(selected + selrctionOffset).getString("Name"); + } + if (s.isEmpty()) return; - FontRenderer fontRenderer = RenderManager.instance.getFontRenderer(); - Tessellator tess = Tessellator.instance; + FontRenderer fontRenderer = RenderManager.instance.getFontRenderer(); + Tessellator tess = Tessellator.instance; - GL11.glPushMatrix(); - GL11.glScalef(0.02f, 0.02f, 0.02f); - GL11.glRotated(180, 0, 1, 0); - GL11.glTranslated(0, -40, 0); + GL11.glPushMatrix(); + GL11.glScalef(0.02f, 0.02f, 0.02f); + GL11.glRotated(180, 0, 1, 0); + GL11.glTranslated(0, -40, 0); + Point.Double p1 = new Point.Double(tileentity.xCoord + 0.5, tileentity.zCoord + 0.5); + Point.Double p2 = new Point.Double(player.posX, player.posZ); - Point.Double p1 = new Point.Double(tileentity.xCoord+0.5, tileentity.zCoord+0.5); - Point.Double p2 = new Point.Double(player.posX, player.posZ); + double xDiff = player.posX - (tileentity.xCoord + 0.5); + double yDiff = player.posY - (tileentity.yCoord + 0.5); + double zDiff = player.posZ - (tileentity.zCoord + 0.5); + double yawAngle = Math.toDegrees(Math.atan2(zDiff, xDiff)); + double pitchAngle = Math.toDegrees(Math.atan2(yDiff, Utills.getDistanceAtoB(player.posX, player.posY, player.posZ, tileentity.xCoord + 0.5, tileentity.yCoord + 0.5, tileentity.zCoord + 0.5))); - double xDiff = player.posX - (tileentity.xCoord+0.5); - double yDiff = player.posY - (tileentity.yCoord+0.5); - double zDiff = player.posZ - (tileentity.zCoord+0.5); - double yawAngle = Math.toDegrees(Math.atan2(zDiff, xDiff)); - double pitchAngle = Math.toDegrees(Math.atan2(yDiff, Utills.getDistanceAtoB(player.posX, player.posY, player.posZ, tileentity.xCoord + 0.5, tileentity.yCoord + 0.5, tileentity.zCoord + 0.5))); + GL11.glRotated(yawAngle + 90 - rotation, 0, 1, 0); + GL11.glRotated(-pitchAngle, 1, 0, 0); - GL11.glRotated(yawAngle + 90 - rotation, 0, 1, 0); - GL11.glRotated(-pitchAngle, 1, 0, 0); + int xmin = -1 - fontRenderer.getStringWidth(s) / 2; + int xmax = 1 + fontRenderer.getStringWidth(s) / 2; + int ymin = -1; + int ymax = fontRenderer.FONT_HEIGHT; - int xmin = -1 - fontRenderer.getStringWidth(s)/2; - int xmax = 1 + fontRenderer.getStringWidth(s)/2; - int ymin = -1; - int ymax = fontRenderer.FONT_HEIGHT; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(0f, 0f, 0f, 0.5f); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(0f, 0f, 0f, 0.5f); + tess.startDrawingQuads(); + tess.addVertexWithUV(xmin, ymax, 0, xmin / 64, 1); + tess.addVertexWithUV(xmax, ymax, 0, xmax / 64, 1); + tess.addVertexWithUV(xmax, ymin, 0, xmax / 64, 0.75); + tess.addVertexWithUV(xmin, ymin, 0, xmin / 64, 0.75); + tess.draw(); - tess.startDrawingQuads(); - tess.addVertexWithUV(xmin, ymax, 0, xmin/64, 1); - tess.addVertexWithUV(xmax, ymax, 0, xmax/64, 1); - tess.addVertexWithUV(xmax, ymin, 0, xmax/64, 0.75); - tess.addVertexWithUV(xmin, ymin, 0, xmin/64, 0.75); - tess.draw(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glTranslated(0, 0, -0.1); + GL11.glColor4f(1f, 1f, 1f, 1f); + GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - GL11.glTranslated(0, 0, -0.1); - GL11.glColor4f(1f, 1f, 1f, 1f); - GL11.glDisable(GL11.GL_LIGHTING); + fontRenderer.drawString(s, -fontRenderer.getStringWidth(s) / 2, 0, 0xffffff); - fontRenderer.drawString(s, -fontRenderer.getStringWidth(s)/2, 0, 0xffffff); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileTestBlock.java b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileTestBlock.java index ad442fa1..cc68146d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileTestBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileTestBlock.java @@ -16,51 +16,49 @@ import org.lwjgl.opengl.GL11; */ public class RenderTileTestBlock extends TileEntitySpecialRenderer { - private static final ResourceLocation iner_model_texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/power_sphere_layer_1.png"); - private static final ResourceLocation outer_model_texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/power_sphere_layer_2.png"); - private IModelCustom iner_model; - private IModelCustom outer_model; + private static final ResourceLocation iner_model_texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/power_sphere_layer_1.png"); + private static final ResourceLocation outer_model_texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/power_sphere_layer_2.png"); + private IModelCustom iner_model; + private IModelCustom outer_model; - public RenderTileTestBlock() - { - iner_model = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/power_sphere_layer_1.obj")); - //outer_model = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/power_sphere_layer_2.obj")); - } + public RenderTileTestBlock() { + iner_model = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/power_sphere_layer_1.obj")); + //outer_model = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/power_sphere_layer_2.obj")); + } - @Override - public void renderTileEntityAt(TileEntity var1, double x, double y, double z, float var8) - { - GL11.glPushMatrix(); - GL11.glColor4f(1F, 1F, 1F, 1F); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) 100, (float) 100); + @Override + public void renderTileEntityAt(TileEntity var1, double x, double y, double z, float var8) { + GL11.glPushMatrix(); + GL11.glColor4f(1F, 1F, 1F, 1F); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) 100, (float) 100); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_CULL_FACE); - //GL11.glDepthMask(false); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + //GL11.glDepthMask(false); - GL11.glTranslated(x+0.5, y+0.5, z+0.5); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); - FMLClientHandler.instance().getClient().getTextureManager().bindTexture(iner_model_texture); + FMLClientHandler.instance().getClient().getTextureManager().bindTexture(iner_model_texture); - GL11.glPushMatrix(); - GL11.glRotatef(((TileTestBlock)var1).modelRotation, 0F, 1F, 0.5F); - //GL11.glColor4f(2F, 2F, 2F, 1F); - iner_model.renderAll(); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glRotatef(((TileTestBlock) var1).modelRotation, 0F, 1F, 0.5F); + //GL11.glColor4f(2F, 2F, 2F, 1F); + iner_model.renderAll(); + GL11.glPopMatrix(); - GL11.glScalef(1.1F, 1.1F, 1.1F); - GL11.glDepthMask(false); - FMLClientHandler.instance().getClient().getTextureManager().bindTexture(outer_model_texture); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glEnable(GL11.GL_BLEND); - GL11.glRotatef(((TileTestBlock)var1).modelRotation*0.5F, 0F, -1F, -0.5F); - GL11.glColor4f(0.5F, 2F, 2F, 0.7F); - outer_model.renderAll(); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDepthMask(true); + GL11.glScalef(1.1F, 1.1F, 1.1F); + GL11.glDepthMask(false); + FMLClientHandler.instance().getClient().getTextureManager().bindTexture(outer_model_texture); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_BLEND); + GL11.glRotatef(((TileTestBlock) var1).modelRotation * 0.5F, 0F, -1F, -0.5F); + GL11.glColor4f(0.5F, 2F, 2F, 0.7F); + outer_model.renderAll(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileUpgradeModifier.java b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileUpgradeModifier.java index f1fc6a53..b3db407f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileUpgradeModifier.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/tile/RenderTileUpgradeModifier.java @@ -12,230 +12,220 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import org.lwjgl.opengl.GL11; -public class RenderTileUpgradeModifier extends TileEntitySpecialRenderer -{ +public class RenderTileUpgradeModifier extends TileEntitySpecialRenderer { - private static float pxl = 1F / 256F; + private static float pxl = 1F / 256F; - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) - { - GL11.glPushMatrix(); + @Override + public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { + GL11.glPushMatrix(); - GL11.glTranslated(x, y, z); - TileUpgradeModifier tile = (TileUpgradeModifier) tileEntity; - renderBlock(tile, f); + GL11.glTranslated(x, y, z); + TileUpgradeModifier tile = (TileUpgradeModifier) tileEntity; + renderBlock(tile, f); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - public void renderBlock(TileUpgradeModifier tile, float pt) - { - Tessellator tess = Tessellator.instance; - tess.setColorRGBA(255, 255, 255, 255); + public void renderBlock(TileUpgradeModifier tile, float pt) { + Tessellator tess = Tessellator.instance; + tess.setColorRGBA(255, 255, 255, 255); - ResourceHandler.bindResource("textures/models/upgradeModifierGear.png"); - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_ALPHA_TEST); + ResourceHandler.bindResource("textures/models/upgradeModifierGear.png"); + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glScaled(0.8, 0.8, 0.8); - GL11.glRotatef(90, 1F, 0F, 0F); - GL11.glTranslatef(-0.5F*0.75F, -0.5F*0.75F, -0.47F); - GL11.glTranslated(1, 1, 0); - GL11.glRotatef(tile.rotation + (pt * tile.rotationSpeed), 0F, 0F, 1F); - GL11.glTranslated(-1, -1, 0); - render2DWithThicness(tess, 1, 0, 0, 1, 128, 128, 0.0625F); + GL11.glScaled(0.8, 0.8, 0.8); + GL11.glRotatef(90, 1F, 0F, 0F); + GL11.glTranslatef(-0.5F * 0.75F, -0.5F * 0.75F, -0.47F); + GL11.glTranslated(1, 1, 0); + GL11.glRotatef(tile.rotation + (pt * tile.rotationSpeed), 0F, 0F, 1F); + GL11.glTranslated(-1, -1, 0); + render2DWithThicness(tess, 1, 0, 0, 1, 128, 128, 0.0625F); - GL11.glPopMatrix(); + GL11.glPopMatrix(); - GL11.glColor4f(0, 1F, 1F, 1F); + GL11.glColor4f(0, 1F, 1F, 1F); - GL11.glPushMatrix(); + GL11.glPushMatrix(); - GL11.glScaled(0.4, 0.4, 0.4); - GL11.glRotatef(90, 1F, 0F, 0F); - GL11.glTranslatef(0.25F, 0.25F, -0.945F); - GL11.glTranslated(1, 1, 0); - GL11.glRotatef(-tile.rotation + (pt * -tile.rotationSpeed), 0F, 0F, 1F); - GL11.glTranslated(-1, -1, 0); - render2DWithThicness(tess, 1, 0, 0, 1, 128, 128, 0.0625F); - GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glScaled(0.4, 0.4, 0.4); + GL11.glRotatef(90, 1F, 0F, 0F); + GL11.glTranslatef(0.25F, 0.25F, -0.945F); + GL11.glTranslated(1, 1, 0); + GL11.glRotatef(-tile.rotation + (pt * -tile.rotationSpeed), 0F, 0F, 1F); + GL11.glTranslated(-1, -1, 0); + render2DWithThicness(tess, 1, 0, 0, 1, 128, 128, 0.0625F); + GL11.glColor4f(1F, 1F, 1F, 1F); - GL11.glPopMatrix(); + GL11.glPopMatrix(); + drawBase(tess); + renderChargingItem(tile, pt); - drawBase(tess); - renderChargingItem(tile, pt); + } - } + private void drawBase(Tessellator tess) { + ResourceHandler.bindResource("textures/models/EnergyInfuserTextureSheet.png"); + GL11.glPushMatrix(); + tess.startDrawingQuads(); + tess.setNormal(0F, 0F, 1.0F); - private void drawBase(Tessellator tess){ - ResourceHandler.bindResource("textures/models/EnergyInfuserTextureSheet.png"); - GL11.glPushMatrix(); - tess.startDrawingQuads(); - tess.setNormal(0F, 0F, 1.0F); + double srcXMin = 0D; + double srcYMin = 0D; + double srcXMax = 64D * pxl; + double srcYMax = 64D * pxl; - double srcXMin = 0D; - double srcYMin = 0D; - double srcXMax = 64D * pxl; - double srcYMax = 64D * pxl; - - tess.addVertexWithUV(0, 0.0005D, 0, srcXMin, srcYMin); - tess.addVertexWithUV(1, 0.0005D, 0, srcXMax, srcYMin); - tess.addVertexWithUV(1, 0.0005D, 1, srcXMax, srcYMax); - tess.addVertexWithUV(0, 0.0005D, 1, srcXMin, srcYMax); + tess.addVertexWithUV(0, 0.0005D, 0, srcXMin, srcYMin); + tess.addVertexWithUV(1, 0.0005D, 0, srcXMax, srcYMin); + tess.addVertexWithUV(1, 0.0005D, 1, srcXMax, srcYMax); + tess.addVertexWithUV(0, 0.0005D, 1, srcXMin, srcYMax); - srcXMin = 128D * pxl; - srcYMin = 0D; - srcXMax = 192D * pxl; - srcYMax = 64D * pxl; + srcXMin = 128D * pxl; + srcYMin = 0D; + srcXMax = 192D * pxl; + srcYMax = 64D * pxl; - tess.addVertexWithUV(0, 0.3745D, 0, srcXMin, srcYMin); - tess.addVertexWithUV(0, 0.3745D, 1, srcXMax, srcYMin); - tess.addVertexWithUV(1, 0.3745D, 1, srcXMax, srcYMax); - tess.addVertexWithUV(1, 0.3745D, 0, srcXMin, srcYMax); + tess.addVertexWithUV(0, 0.3745D, 0, srcXMin, srcYMin); + tess.addVertexWithUV(0, 0.3745D, 1, srcXMax, srcYMin); + tess.addVertexWithUV(1, 0.3745D, 1, srcXMax, srcYMax); + tess.addVertexWithUV(1, 0.3745D, 0, srcXMin, srcYMax); - srcXMin = 64D * pxl; - srcYMin = 0D; - srcXMax = 128D * pxl; - srcYMax = 24D * pxl; + srcXMin = 64D * pxl; + srcYMin = 0D; + srcXMax = 128D * pxl; + srcYMax = 24D * pxl; - tess.addVertexWithUV(1, 0, 0, srcXMin, srcYMin); - tess.addVertexWithUV(0, 0, 0, srcXMax, srcYMin); - tess.addVertexWithUV(0, 0.375D, 0, srcXMax, srcYMax); - tess.addVertexWithUV(1, 0.375D, 0, srcXMin, srcYMax); + tess.addVertexWithUV(1, 0, 0, srcXMin, srcYMin); + tess.addVertexWithUV(0, 0, 0, srcXMax, srcYMin); + tess.addVertexWithUV(0, 0.375D, 0, srcXMax, srcYMax); + tess.addVertexWithUV(1, 0.375D, 0, srcXMin, srcYMax); - tess.addVertexWithUV(1, 0, 1, srcXMin, srcYMin); - tess.addVertexWithUV(1, 0.375D, 1, srcXMin, srcYMax); - tess.addVertexWithUV(0, 0.375D, 1, srcXMax, srcYMax); - tess.addVertexWithUV(0, 0, 1, srcXMax, srcYMin); + tess.addVertexWithUV(1, 0, 1, srcXMin, srcYMin); + tess.addVertexWithUV(1, 0.375D, 1, srcXMin, srcYMax); + tess.addVertexWithUV(0, 0.375D, 1, srcXMax, srcYMax); + tess.addVertexWithUV(0, 0, 1, srcXMax, srcYMin); - tess.addVertexWithUV(0, 0.375D, 1, srcXMin, srcYMin); - tess.addVertexWithUV(0, 0.375D, 0, srcXMax, srcYMin); - tess.addVertexWithUV(0, 0, 0, srcXMax, srcYMax); - tess.addVertexWithUV(0, 0, 1, srcXMin, srcYMax); + tess.addVertexWithUV(0, 0.375D, 1, srcXMin, srcYMin); + tess.addVertexWithUV(0, 0.375D, 0, srcXMax, srcYMin); + tess.addVertexWithUV(0, 0, 0, srcXMax, srcYMax); + tess.addVertexWithUV(0, 0, 1, srcXMin, srcYMax); - tess.addVertexWithUV(1, 0.375D, 1, srcXMin, srcYMin); - tess.addVertexWithUV(1, 0, 1, srcXMin, srcYMax); - tess.addVertexWithUV(1, 0, 0, srcXMax, srcYMax); - tess.addVertexWithUV(1, 0.375D, 0, srcXMax, srcYMin); + tess.addVertexWithUV(1, 0.375D, 1, srcXMin, srcYMin); + tess.addVertexWithUV(1, 0, 1, srcXMin, srcYMax); + tess.addVertexWithUV(1, 0, 0, srcXMax, srcYMax); + tess.addVertexWithUV(1, 0.375D, 0, srcXMax, srcYMin); - tess.draw(); - GL11.glPopMatrix(); + tess.draw(); + GL11.glPopMatrix(); - } + } - public static void render2DWithThicness(Tessellator tess, float maxU, float minV, float minU, float maxV, int width, int height, float thickness) - { - double pix = 1D / 64D; - tess.startDrawingQuads(); - tess.setNormal(0.0F, 0.0F, 1.0F); - tess.addVertexWithUV(0.0D, 0.0D, 0.0D, (double)maxU, (double)maxV); - tess.addVertexWithUV(width*pix, 0.0D, 0.0D, (double)minU, (double)maxV); - tess.addVertexWithUV(width*pix, height*pix, 0.0D, (double)minU, (double)minV); - tess.addVertexWithUV(0.0D, height*pix, 0.0D, (double) maxU, (double) minV); - tess.draw(); - tess.startDrawingQuads(); - tess.setNormal(0.0F, 0.0F, -1.0F); - tess.addVertexWithUV(0.0D, height*pix, (double) (0.0F - thickness), (double) maxU, (double) minV); - tess.addVertexWithUV(width*pix, height*pix, (double) (0.0F - thickness), (double) minU, (double) minV); - tess.addVertexWithUV(width*pix, 0.0D, (double)(0.0F - thickness), (double)minU, (double)maxV); - tess.addVertexWithUV(0.0D, 0.0D, (double)(0.0F - thickness), (double)maxU, (double)maxV); - tess.draw(); - float f5 = 0.5F * (maxU - minU) / (float)width; - float f6 = 0.5F * (maxV - minV) / (float)height; - tess.startDrawingQuads(); - tess.setNormal(-1.0F, 0.0F, 0.0F); - int k; - float f7; - float f8; - double d; + public static void render2DWithThicness(Tessellator tess, float maxU, float minV, float minU, float maxV, int width, int height, float thickness) { + double pix = 1D / 64D; + tess.startDrawingQuads(); + tess.setNormal(0.0F, 0.0F, 1.0F); + tess.addVertexWithUV(0.0D, 0.0D, 0.0D, (double) maxU, (double) maxV); + tess.addVertexWithUV(width * pix, 0.0D, 0.0D, (double) minU, (double) maxV); + tess.addVertexWithUV(width * pix, height * pix, 0.0D, (double) minU, (double) minV); + tess.addVertexWithUV(0.0D, height * pix, 0.0D, (double) maxU, (double) minV); + tess.draw(); + tess.startDrawingQuads(); + tess.setNormal(0.0F, 0.0F, -1.0F); + tess.addVertexWithUV(0.0D, height * pix, (double) (0.0F - thickness), (double) maxU, (double) minV); + tess.addVertexWithUV(width * pix, height * pix, (double) (0.0F - thickness), (double) minU, (double) minV); + tess.addVertexWithUV(width * pix, 0.0D, (double) (0.0F - thickness), (double) minU, (double) maxV); + tess.addVertexWithUV(0.0D, 0.0D, (double) (0.0F - thickness), (double) maxU, (double) maxV); + tess.draw(); + float f5 = 0.5F * (maxU - minU) / (float) width; + float f6 = 0.5F * (maxV - minV) / (float) height; + tess.startDrawingQuads(); + tess.setNormal(-1.0F, 0.0F, 0.0F); + int k; + float f7; + float f8; + double d; - for (k = 0; k < width; ++k) - { - d = k*pix; - f7 = (float)k / (float)width; - f8 = maxU + (minU - maxU) * f7 - f5; - tess.addVertexWithUV(d, 0.0D, (double)(0.0F - thickness), (double)f8, (double)maxV); - tess.addVertexWithUV(d, 0.0D, 0.0D, (double)f8, (double)maxV); - tess.addVertexWithUV(d, height*pix, 0.0D, (double)f8, (double)minV); - tess.addVertexWithUV(d, height*pix, (double)(0.0F - thickness), (double)f8, (double)minV); - } + for (k = 0; k < width; ++k) { + d = k * pix; + f7 = (float) k / (float) width; + f8 = maxU + (minU - maxU) * f7 - f5; + tess.addVertexWithUV(d, 0.0D, (double) (0.0F - thickness), (double) f8, (double) maxV); + tess.addVertexWithUV(d, 0.0D, 0.0D, (double) f8, (double) maxV); + tess.addVertexWithUV(d, height * pix, 0.0D, (double) f8, (double) minV); + tess.addVertexWithUV(d, height * pix, (double) (0.0F - thickness), (double) f8, (double) minV); + } - tess.draw(); - tess.startDrawingQuads(); - tess.setNormal(1.0F, 0.0F, 0.0F); + tess.draw(); + tess.startDrawingQuads(); + tess.setNormal(1.0F, 0.0F, 0.0F); - for (k = 0; k < width; ++k) - { - d = (k+1)*pix; - f7 = (float)k / (float)width; - f8 = maxU + (minU - maxU) * f7 - f5; - tess.addVertexWithUV(d, height*pix, (double)(0.0F - thickness), (double)f8, (double)minV); - tess.addVertexWithUV(d, height*pix, 0.0D, (double)f8, (double)minV); - tess.addVertexWithUV(d, 0.0D, 0.0D, (double)f8, (double)maxV); - tess.addVertexWithUV(d, 0.0D, (double)(0.0F - thickness), (double)f8, (double)maxV); - } + for (k = 0; k < width; ++k) { + d = (k + 1) * pix; + f7 = (float) k / (float) width; + f8 = maxU + (minU - maxU) * f7 - f5; + tess.addVertexWithUV(d, height * pix, (double) (0.0F - thickness), (double) f8, (double) minV); + tess.addVertexWithUV(d, height * pix, 0.0D, (double) f8, (double) minV); + tess.addVertexWithUV(d, 0.0D, 0.0D, (double) f8, (double) maxV); + tess.addVertexWithUV(d, 0.0D, (double) (0.0F - thickness), (double) f8, (double) maxV); + } - tess.draw(); - tess.startDrawingQuads(); - tess.setNormal(0.0F, 1.0F, 0.0F); + tess.draw(); + tess.startDrawingQuads(); + tess.setNormal(0.0F, 1.0F, 0.0F); - for (k = 0; k < height; ++k) - { - d = (k+1)*pix; - f7 = (float)k / (float)height; - f8 = maxV + (minV - maxV) * f7 - f6; - tess.addVertexWithUV(0.0D, d, 0.0D, (double)maxU, (double)f8); - tess.addVertexWithUV(width*pix, d, 0.0D, (double)minU, (double)f8); - tess.addVertexWithUV(width*pix, d, (double)(0.0F - thickness), (double)minU, (double)f8); - tess.addVertexWithUV(0.0D, d, (double)(0.0F - thickness), (double)maxU, (double)f8); - } + for (k = 0; k < height; ++k) { + d = (k + 1) * pix; + f7 = (float) k / (float) height; + f8 = maxV + (minV - maxV) * f7 - f6; + tess.addVertexWithUV(0.0D, d, 0.0D, (double) maxU, (double) f8); + tess.addVertexWithUV(width * pix, d, 0.0D, (double) minU, (double) f8); + tess.addVertexWithUV(width * pix, d, (double) (0.0F - thickness), (double) minU, (double) f8); + tess.addVertexWithUV(0.0D, d, (double) (0.0F - thickness), (double) maxU, (double) f8); + } - tess.draw(); - tess.startDrawingQuads(); - tess.setNormal(0.0F, -1.0F, 0.0F); + tess.draw(); + tess.startDrawingQuads(); + tess.setNormal(0.0F, -1.0F, 0.0F); - for (k = 0; k < height; ++k) - { - d = k*pix; - f7 = (float)k / (float)height; - f8 = maxV + (minV - maxV) * f7 - f6; - tess.addVertexWithUV(width*pix, d, 0.0D, (double)minU, (double)f8); - tess.addVertexWithUV(0.0D, d, 0.0D, (double)maxU, (double)f8); - tess.addVertexWithUV(0.0D, d, (double)(0.0F - thickness), (double)maxU, (double)f8); - tess.addVertexWithUV(width*pix, d, (double)(0.0F - thickness), (double)minU, (double)f8); - } + for (k = 0; k < height; ++k) { + d = k * pix; + f7 = (float) k / (float) height; + f8 = maxV + (minV - maxV) * f7 - f6; + tess.addVertexWithUV(width * pix, d, 0.0D, (double) minU, (double) f8); + tess.addVertexWithUV(0.0D, d, 0.0D, (double) maxU, (double) f8); + tess.addVertexWithUV(0.0D, d, (double) (0.0F - thickness), (double) maxU, (double) f8); + tess.addVertexWithUV(width * pix, d, (double) (0.0F - thickness), (double) minU, (double) f8); + } - tess.draw(); - } + tess.draw(); + } - public void renderChargingItem(TileUpgradeModifier tile, float pt){ - if (tile.getStackInSlot(0) != null) { - GL11.glPushMatrix(); + public void renderChargingItem(TileUpgradeModifier tile, float pt) { + if (tile.getStackInSlot(0) != null) { + GL11.glPushMatrix(); - ItemStack stack = tile.getStackInSlot(0); - EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, tile.getStackInSlot(0)); - itemEntity.hoverStart = 0.0F; + ItemStack stack = tile.getStackInSlot(0); + EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, tile.getStackInSlot(0)); + itemEntity.hoverStart = 0.0F; - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - GL11.glScalef(1F, 1F, 1F); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glScalef(1F, 1F, 1F); - GL11.glRotatef((tile.rotation + (pt * tile.rotationSpeed)) * 0.2F, 0F, -1F, 0F); - if (stack.getItem() instanceof ItemBlock) - { - GL11.glScalef(1F, 1F, 1F); - GL11.glTranslatef(0F, 0.045F, 0.0f); - } + GL11.glRotatef((tile.rotation + (pt * tile.rotationSpeed)) * 0.2F, 0F, -1F, 0F); + if (stack.getItem() instanceof ItemBlock) { + GL11.glScalef(1F, 1F, 1F); + GL11.glTranslatef(0F, 0.045F, 0.0f); + } - RenderItem.renderInFrame = true; - RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - RenderItem.renderInFrame = false; + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; - GL11.glPopMatrix(); - } - } + GL11.glPopMatrix(); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/utill/CustomResourceLocation.java b/src/main/java/com/brandon3055/draconicevolution/client/utill/CustomResourceLocation.java index 6db8ca49..dfd88816 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/utill/CustomResourceLocation.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/utill/CustomResourceLocation.java @@ -9,22 +9,24 @@ import net.minecraft.util.ResourceLocation; */ public class CustomResourceLocation extends ResourceLocation { - private int width; - private int height; + private int width; + private int height; - public CustomResourceLocation(String texturePath, int width, int height) { - super(References.MODID.toLowerCase() , "textures/gui/manualimages/" + texturePath); - this.width = width; - this.height = height; - } + public CustomResourceLocation(String texturePath, int width, int height) { + super(References.MODID.toLowerCase(), "textures/gui/manualimages/" + texturePath); + this.width = width; + this.height = height; + } - public void bind() { ResourceHandler.bindTexture(this); } + public void bind() { + ResourceHandler.bindTexture(this); + } - public int getWidth() { - return width; - } + public int getWidth() { + return width; + } - public int getHeight() { - return height; - } + public int getHeight() { + return height; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/CommonProxy.java b/src/main/java/com/brandon3055/draconicevolution/common/CommonProxy.java index b41c0301..4f398f01 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/CommonProxy.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/CommonProxy.java @@ -46,18 +46,18 @@ import net.minecraftforge.oredict.OreDictionary; public class CommonProxy { - public void preInit(FMLPreInitializationEvent event) { - ConfigHandler.init(event.getSuggestedConfigurationFile()); - BalanceConfigHandler.init(event.getModConfigurationDirectory()); - registerEventListeners(event.getSide()); - ModBlocks.init(); - ModItems.init(); - ContributorHandler.init(); - registerTileEntities(); - initializeNetwork(); - registerOres(); + public void preInit(FMLPreInitializationEvent event) { + ConfigHandler.init(event.getSuggestedConfigurationFile()); + BalanceConfigHandler.init(event.getModConfigurationDirectory()); + registerEventListeners(event.getSide()); + ModBlocks.init(); + ModItems.init(); + ContributorHandler.init(); + registerTileEntities(); + initializeNetwork(); + registerOres(); - DraconicEvolution.reaperEnchant = new EnchantmentReaper(ConfigHandler.reaperEnchantID); + DraconicEvolution.reaperEnchant = new EnchantmentReaper(ConfigHandler.reaperEnchantID); // // Potion[] potionTypes = null; // LogHelper.info("Expanding Potion array size to 256"); @@ -82,159 +82,163 @@ public class CommonProxy { // } // } - Achievements.addModAchievements(); - LogHelper.info("Finished PreInitialization"); - } + Achievements.addModAchievements(); + LogHelper.info("Finished PreInitialization"); + } - public void init(FMLInitializationEvent event) { - CraftingHandler.init(); - registerGuiHandeler(); - registerWorldGen(); - registerEntities(); - DETab.initialize(); - PotionHandler.init(); - CCOCIntegration.init(); - ModHelper.init(); - DragonChunkLoader.init(); + public void init(FMLInitializationEvent event) { + CraftingHandler.init(); + registerGuiHandeler(); + registerWorldGen(); + registerEntities(); + DETab.initialize(); + PotionHandler.init(); + CCOCIntegration.init(); + ModHelper.init(); + DragonChunkLoader.init(); - LogHelper.info("Finished Initialization"); - } + LogHelper.info("Finished Initialization"); + } - public void postInit(FMLPostInitializationEvent event) { - BalanceConfigHandler.finishLoading(); - OreDoublingRegistry.init(); - Achievements.registerAchievementPane(); - LogHelper.info("Finished PostInitialization"); - } + public void postInit(FMLPostInitializationEvent event) { + BalanceConfigHandler.finishLoading(); + OreDoublingRegistry.init(); + Achievements.registerAchievementPane(); + LogHelper.info("Finished PostInitialization"); + } - public void initializeNetwork() { - DraconicEvolution.network = NetworkRegistry.INSTANCE.newSimpleChannel(DraconicEvolution.networkChannelName); - DraconicEvolution.network.registerMessage(ButtonPacket.Handler.class, ButtonPacket.class, 0, Side.SERVER); - DraconicEvolution.network.registerMessage(ParticleGenPacket.Handler.class, ParticleGenPacket.class, 1, Side.SERVER); - DraconicEvolution.network.registerMessage(PlacedItemPacket.Handler.class, PlacedItemPacket.class, 2, Side.SERVER); - DraconicEvolution.network.registerMessage(PlayerDetectorButtonPacket.Handler.class, PlayerDetectorButtonPacket.class, 3, Side.SERVER); - DraconicEvolution.network.registerMessage(PlayerDetectorStringPacket.Handler.class, PlayerDetectorStringPacket.class, 4, Side.SERVER); - DraconicEvolution.network.registerMessage(TeleporterPacket.Handler.class, TeleporterPacket.class, 5, Side.SERVER); - DraconicEvolution.network.registerMessage(TileObjectPacket.Handler.class, TileObjectPacket.class, 6, Side.CLIENT); - DraconicEvolution.network.registerMessage(MountUpdatePacket.Handler.class, MountUpdatePacket.class, 7, Side.CLIENT); - DraconicEvolution.network.registerMessage(MountUpdatePacket.Handler.class, MountUpdatePacket.class, 8, Side.SERVER); - DraconicEvolution.network.registerMessage(ItemConfigPacket.Handler.class, ItemConfigPacket.class, 9, Side.SERVER); - DraconicEvolution.network.registerMessage(TileObjectPacket.Handler.class, TileObjectPacket.class, 10, Side.SERVER); - DraconicEvolution.network.registerMessage(BlockUpdatePacket.Handler.class, BlockUpdatePacket.class, 11, Side.SERVER); - DraconicEvolution.network.registerMessage(SpeedRequestPacket.Handler.class, SpeedRequestPacket.class, 12, Side.SERVER); - DraconicEvolution.network.registerMessage(SpeedRequestPacket.Handler.class, SpeedRequestPacket.class, 13, Side.CLIENT); - DraconicEvolution.network.registerMessage(ToolModePacket.Handler.class, ToolModePacket.class, 14, Side.SERVER); - DraconicEvolution.network.registerMessage(GenericParticlePacket.Handler.class, GenericParticlePacket.class, 15, Side.CLIENT); - DraconicEvolution.network.registerMessage(ShieldHitPacket.Handler.class, ShieldHitPacket.class, 16, Side.CLIENT); - DraconicEvolution.network.registerMessage(ContributorPacket.Handler.class, ContributorPacket.class, 17, Side.CLIENT); - DraconicEvolution.network.registerMessage(ContributorPacket.Handler.class, ContributorPacket.class, 18, Side.SERVER); + public void initializeNetwork() { + DraconicEvolution.network = NetworkRegistry.INSTANCE.newSimpleChannel(DraconicEvolution.networkChannelName); + DraconicEvolution.network.registerMessage(ButtonPacket.Handler.class, ButtonPacket.class, 0, Side.SERVER); + DraconicEvolution.network.registerMessage(ParticleGenPacket.Handler.class, ParticleGenPacket.class, 1, Side.SERVER); + DraconicEvolution.network.registerMessage(PlacedItemPacket.Handler.class, PlacedItemPacket.class, 2, Side.SERVER); + DraconicEvolution.network.registerMessage(PlayerDetectorButtonPacket.Handler.class, PlayerDetectorButtonPacket.class, 3, Side.SERVER); + DraconicEvolution.network.registerMessage(PlayerDetectorStringPacket.Handler.class, PlayerDetectorStringPacket.class, 4, Side.SERVER); + DraconicEvolution.network.registerMessage(TeleporterPacket.Handler.class, TeleporterPacket.class, 5, Side.SERVER); + DraconicEvolution.network.registerMessage(TileObjectPacket.Handler.class, TileObjectPacket.class, 6, Side.CLIENT); + DraconicEvolution.network.registerMessage(MountUpdatePacket.Handler.class, MountUpdatePacket.class, 7, Side.CLIENT); + DraconicEvolution.network.registerMessage(MountUpdatePacket.Handler.class, MountUpdatePacket.class, 8, Side.SERVER); + DraconicEvolution.network.registerMessage(ItemConfigPacket.Handler.class, ItemConfigPacket.class, 9, Side.SERVER); + DraconicEvolution.network.registerMessage(TileObjectPacket.Handler.class, TileObjectPacket.class, 10, Side.SERVER); + DraconicEvolution.network.registerMessage(BlockUpdatePacket.Handler.class, BlockUpdatePacket.class, 11, Side.SERVER); + DraconicEvolution.network.registerMessage(SpeedRequestPacket.Handler.class, SpeedRequestPacket.class, 12, Side.SERVER); + DraconicEvolution.network.registerMessage(SpeedRequestPacket.Handler.class, SpeedRequestPacket.class, 13, Side.CLIENT); + DraconicEvolution.network.registerMessage(ToolModePacket.Handler.class, ToolModePacket.class, 14, Side.SERVER); + DraconicEvolution.network.registerMessage(GenericParticlePacket.Handler.class, GenericParticlePacket.class, 15, Side.CLIENT); + DraconicEvolution.network.registerMessage(ShieldHitPacket.Handler.class, ShieldHitPacket.class, 16, Side.CLIENT); + DraconicEvolution.network.registerMessage(ContributorPacket.Handler.class, ContributorPacket.class, 17, Side.CLIENT); + DraconicEvolution.network.registerMessage(ContributorPacket.Handler.class, ContributorPacket.class, 18, Side.SERVER); - } + } - public void registerTileEntities() { - GameRegistry.registerTileEntity(TileWeatherController.class, References.RESOURCESPREFIX + "TileWeatherController"); - GameRegistry.registerTileEntity(TileSunDial.class, References.RESOURCESPREFIX + "TileSunDial"); - GameRegistry.registerTileEntity(TileGrinder.class, References.RESOURCESPREFIX + "TileGrinder"); - GameRegistry.registerTileEntity(TilePotentiometer.class, References.RESOURCESPREFIX + "TilePotentiometer"); - GameRegistry.registerTileEntity(TileParticleGenerator.class, References.RESOURCESPREFIX + "TileParticleGenerator"); - GameRegistry.registerTileEntity(TilePlayerDetector.class, References.RESOURCESPREFIX + "TilePlayerDetector"); - GameRegistry.registerTileEntity(TilePlayerDetectorAdvanced.class, References.RESOURCESPREFIX + "TilePlayerDetectorAdvanced"); - GameRegistry.registerTileEntity(TileEnergyInfuser.class, References.RESOURCESPREFIX + "TileEnergyInfuser"); - GameRegistry.registerTileEntity(TileCustomSpawner.class, References.RESOURCESPREFIX + "TileCustomSpawner"); - GameRegistry.registerTileEntity(TileGenerator.class, References.RESOURCESPREFIX + "TileGenerator"); - GameRegistry.registerTileEntity(TileEnergyStorageCore.class, References.RESOURCESPREFIX + "TileEnergyStorageCore"); - GameRegistry.registerTileEntity(TileInvisibleMultiblock.class, References.RESOURCESPREFIX + "TileInvisibleMultiblock"); - GameRegistry.registerTileEntity(TileEnergyPylon.class, References.RESOURCESPREFIX + "TileEnergyPylon"); - GameRegistry.registerTileEntity(TileEnderResurrection.class, References.RESOURCESPREFIX + "TileEnderResurrection"); - GameRegistry.registerTileEntity(TilePlacedItem.class, References.RESOURCESPREFIX + "TilePlacedItem"); - GameRegistry.registerTileEntity(TileCKeyStone.class, References.RESOURCESPREFIX + "TileCKeyStone"); - GameRegistry.registerTileEntity(TileDissEnchanter.class, References.RESOURCESPREFIX + "TileDissEnchanter"); - GameRegistry.registerTileEntity(TileTeleporterStand.class, References.RESOURCESPREFIX + "TileTeleporterStand"); - GameRegistry.registerTileEntity(TileDraconiumChest.class, References.RESOURCESPREFIX + "TileDraconiumChest"); - GameRegistry.registerTileEntity(TileEnergyRelay.class, References.RESOURCESPREFIX + "TileEnergyRelay"); - GameRegistry.registerTileEntity(TileEnergyTransceiver.class, References.RESOURCESPREFIX + "TileEnergyTransceiver"); - GameRegistry.registerTileEntity(TileWirelessEnergyTransceiver.class, References.RESOURCESPREFIX + "TileWirelessEnergyTransceiver"); - GameRegistry.registerTileEntity(TileDislocatorReceptacle.class, References.RESOURCESPREFIX + "TileDislocatorReceptacle"); - GameRegistry.registerTileEntity(TilePortalBlock.class, References.RESOURCESPREFIX + "TilePortalBlock"); - GameRegistry.registerTileEntity(TileReactorCore.class, References.RESOURCESPREFIX + "TileReactorCore"); - GameRegistry.registerTileEntity(TileFluxGate.class, References.RESOURCESPREFIX + "TileFluxGate"); - GameRegistry.registerTileEntity(TileFluidGate.class, References.RESOURCESPREFIX + "TileFluidGate"); - GameRegistry.registerTileEntity(TileReactorStabilizer.class, References.RESOURCESPREFIX + "TileReactorStabilizer"); - GameRegistry.registerTileEntity(TileReactorEnergyInjector.class, References.RESOURCESPREFIX + "TileReactorEnergyInjector"); - GameRegistry.registerTileEntity(TileChaosShard.class, References.RESOURCESPREFIX + "TileChaosShard"); - GameRegistry.registerTileEntity(TileUpgradeModifier.class, References.RESOURCESPREFIX + "TileEnhancementModifier"); - if (DraconicEvolution.debug) { - GameRegistry.registerTileEntity(TileTestBlock.class, References.RESOURCESPREFIX + "TileTestBlock"); - GameRegistry.registerTileEntity(TileContainerTemplate.class, References.RESOURCESPREFIX + "TileContainerTemplate"); - } - } + public void registerTileEntities() { + GameRegistry.registerTileEntity(TileWeatherController.class, References.RESOURCESPREFIX + "TileWeatherController"); + GameRegistry.registerTileEntity(TileSunDial.class, References.RESOURCESPREFIX + "TileSunDial"); + GameRegistry.registerTileEntity(TileGrinder.class, References.RESOURCESPREFIX + "TileGrinder"); + GameRegistry.registerTileEntity(TilePotentiometer.class, References.RESOURCESPREFIX + "TilePotentiometer"); + GameRegistry.registerTileEntity(TileParticleGenerator.class, References.RESOURCESPREFIX + "TileParticleGenerator"); + GameRegistry.registerTileEntity(TilePlayerDetector.class, References.RESOURCESPREFIX + "TilePlayerDetector"); + GameRegistry.registerTileEntity(TilePlayerDetectorAdvanced.class, References.RESOURCESPREFIX + "TilePlayerDetectorAdvanced"); + GameRegistry.registerTileEntity(TileEnergyInfuser.class, References.RESOURCESPREFIX + "TileEnergyInfuser"); + GameRegistry.registerTileEntity(TileCustomSpawner.class, References.RESOURCESPREFIX + "TileCustomSpawner"); + GameRegistry.registerTileEntity(TileGenerator.class, References.RESOURCESPREFIX + "TileGenerator"); + GameRegistry.registerTileEntity(TileEnergyStorageCore.class, References.RESOURCESPREFIX + "TileEnergyStorageCore"); + GameRegistry.registerTileEntity(TileInvisibleMultiblock.class, References.RESOURCESPREFIX + "TileInvisibleMultiblock"); + GameRegistry.registerTileEntity(TileEnergyPylon.class, References.RESOURCESPREFIX + "TileEnergyPylon"); + GameRegistry.registerTileEntity(TileEnderResurrection.class, References.RESOURCESPREFIX + "TileEnderResurrection"); + GameRegistry.registerTileEntity(TilePlacedItem.class, References.RESOURCESPREFIX + "TilePlacedItem"); + GameRegistry.registerTileEntity(TileCKeyStone.class, References.RESOURCESPREFIX + "TileCKeyStone"); + GameRegistry.registerTileEntity(TileDissEnchanter.class, References.RESOURCESPREFIX + "TileDissEnchanter"); + GameRegistry.registerTileEntity(TileTeleporterStand.class, References.RESOURCESPREFIX + "TileTeleporterStand"); + GameRegistry.registerTileEntity(TileDraconiumChest.class, References.RESOURCESPREFIX + "TileDraconiumChest"); + GameRegistry.registerTileEntity(TileEnergyRelay.class, References.RESOURCESPREFIX + "TileEnergyRelay"); + GameRegistry.registerTileEntity(TileEnergyTransceiver.class, References.RESOURCESPREFIX + "TileEnergyTransceiver"); + GameRegistry.registerTileEntity(TileWirelessEnergyTransceiver.class, References.RESOURCESPREFIX + "TileWirelessEnergyTransceiver"); + GameRegistry.registerTileEntity(TileDislocatorReceptacle.class, References.RESOURCESPREFIX + "TileDislocatorReceptacle"); + GameRegistry.registerTileEntity(TilePortalBlock.class, References.RESOURCESPREFIX + "TilePortalBlock"); + GameRegistry.registerTileEntity(TileReactorCore.class, References.RESOURCESPREFIX + "TileReactorCore"); + GameRegistry.registerTileEntity(TileFluxGate.class, References.RESOURCESPREFIX + "TileFluxGate"); + GameRegistry.registerTileEntity(TileFluidGate.class, References.RESOURCESPREFIX + "TileFluidGate"); + GameRegistry.registerTileEntity(TileReactorStabilizer.class, References.RESOURCESPREFIX + "TileReactorStabilizer"); + GameRegistry.registerTileEntity(TileReactorEnergyInjector.class, References.RESOURCESPREFIX + "TileReactorEnergyInjector"); + GameRegistry.registerTileEntity(TileChaosShard.class, References.RESOURCESPREFIX + "TileChaosShard"); + GameRegistry.registerTileEntity(TileUpgradeModifier.class, References.RESOURCESPREFIX + "TileEnhancementModifier"); + if (DraconicEvolution.debug) { + GameRegistry.registerTileEntity(TileTestBlock.class, References.RESOURCESPREFIX + "TileTestBlock"); + GameRegistry.registerTileEntity(TileContainerTemplate.class, References.RESOURCESPREFIX + "TileContainerTemplate"); + } + } - public void registerEventListeners(Side s) { - MinecraftForge.EVENT_BUS.register(new MinecraftForgeEventHandler()); - MinecraftForge.EVENT_BUS.register(new Achievements()); - FMLCommonHandler.instance().bus().register(new Achievements()); - FMLCommonHandler.instance().bus().register(new FMLEventHandler()); - } + public void registerEventListeners(Side s) { + MinecraftForge.EVENT_BUS.register(new MinecraftForgeEventHandler()); + MinecraftForge.EVENT_BUS.register(new Achievements()); + FMLCommonHandler.instance().bus().register(new Achievements()); + FMLCommonHandler.instance().bus().register(new FMLEventHandler()); + } - public void registerGuiHandeler() { - new GuiHandler(); - } + public void registerGuiHandeler() { + new GuiHandler(); + } - public void registerWorldGen() { - GameRegistry.registerWorldGenerator(new DraconicWorldGenerator(), 0); - } + public void registerWorldGen() { + GameRegistry.registerWorldGenerator(new DraconicWorldGenerator(), 0); + } - public void registerOres(){ - if (ModBlocks.isEnabled(ModBlocks.draconiumOre)) OreDictionary.registerOre("oreDraconium", ModBlocks.draconiumOre); - if (ModBlocks.isEnabled(ModBlocks.draconiumBlock)) OreDictionary.registerOre("blockDraconium", new ItemStack(ModBlocks.draconiumBlock)); - if (ModBlocks.isEnabled(ModBlocks.draconicBlock)) OreDictionary.registerOre("blockDraconiumAwakened", new ItemStack(ModBlocks.draconicBlock)); + public void registerOres() { + if (ModBlocks.isEnabled(ModBlocks.draconiumOre)) + OreDictionary.registerOre("oreDraconium", ModBlocks.draconiumOre); + if (ModBlocks.isEnabled(ModBlocks.draconiumBlock)) + OreDictionary.registerOre("blockDraconium", new ItemStack(ModBlocks.draconiumBlock)); + if (ModBlocks.isEnabled(ModBlocks.draconicBlock)) + OreDictionary.registerOre("blockDraconiumAwakened", new ItemStack(ModBlocks.draconicBlock)); - if (ModItems.isEnabled(ModItems.draconiumIngot)) OreDictionary.registerOre("ingotDraconium", ModItems.draconiumIngot); - if (ModItems.isEnabled(ModItems.draconiumDust)) OreDictionary.registerOre("dustDraconium", ModItems.draconiumDust); - if (ModItems.isEnabled(ModItems.draconicIngot)) OreDictionary.registerOre("ingotDraconiumAwakened", ModItems.draconicIngot); - if (ModItems.isEnabled(ModItems.nugget)) { - OreDictionary.registerOre("nuggetDraconium", ModItems.nuggetDraconium.copy()); - OreDictionary.registerOre("nuggetDraconiumAwakened", ModItems.nuggetAwakened.copy()); - } - } + if (ModItems.isEnabled(ModItems.draconiumIngot)) + OreDictionary.registerOre("ingotDraconium", ModItems.draconiumIngot); + if (ModItems.isEnabled(ModItems.draconiumDust)) + OreDictionary.registerOre("dustDraconium", ModItems.draconiumDust); + if (ModItems.isEnabled(ModItems.draconicIngot)) + OreDictionary.registerOre("ingotDraconiumAwakened", ModItems.draconicIngot); + if (ModItems.isEnabled(ModItems.nugget)) { + OreDictionary.registerOre("nuggetDraconium", ModItems.nuggetDraconium.copy()); + OreDictionary.registerOre("nuggetDraconiumAwakened", ModItems.nuggetAwakened.copy()); + } + } - //@Callback - public void registerEntities() { - EntityRegistry.registerModEntity(EntityCustomDragon.class, "EnderDragon", 0, DraconicEvolution.instance, 256, 3, true); - EntityRegistry.registerModEntity(EntityPersistentItem.class, "Persistent Item", 1, DraconicEvolution.instance, 32, 5, true); - EntityRegistry.registerModEntity(EntityDraconicArrow.class, "Arrow", 2, DraconicEvolution.instance, 32, 5, true); - EntityRegistry.registerModEntity(EntityEnderArrow.class, "Ender Arrow", 3, DraconicEvolution.instance, 32, 1, true); - //EntityRegistry.registerModEntity(EntityChaosDrill.class, "Chaos Drill", 4, DraconicEvolution.instance, 10, 5, false); - EntityRegistry.registerModEntity(EntityDragonHeart.class, "Dragon Heart Item", 5, DraconicEvolution.instance, 32, 5, true); - EntityRegistry.registerModEntity(EntityChaosGuardian.class, "ChaosGuardian", 6, DraconicEvolution.instance, 256, 1, true); - EntityRegistry.registerModEntity(EntityDragonProjectile.class, "DragonProjectile", 7, DraconicEvolution.instance, 256, 1, true); - EntityRegistry.registerModEntity(EntityChaosCrystal.class, "ChaosCrystal", 8, DraconicEvolution.instance, 256, 5, false); - EntityRegistry.registerModEntity(EntityChaosBolt.class, "ChaosBolt", 9, DraconicEvolution.instance, 32, 5, true); - EntityRegistry.registerModEntity(EntityChaosVortex.class, "EntityChaosEnergyVortex", 10, DraconicEvolution.instance, 512, 5, true); - EntityRegistry.registerModEntity(EntityCustomArrow.class, "CustomArrow", 11, DraconicEvolution.instance, 128, 1, true); + //@Callback + public void registerEntities() { + EntityRegistry.registerModEntity(EntityCustomDragon.class, "EnderDragon", 0, DraconicEvolution.instance, 256, 3, true); + EntityRegistry.registerModEntity(EntityPersistentItem.class, "Persistent Item", 1, DraconicEvolution.instance, 32, 5, true); + EntityRegistry.registerModEntity(EntityDraconicArrow.class, "Arrow", 2, DraconicEvolution.instance, 32, 5, true); + EntityRegistry.registerModEntity(EntityEnderArrow.class, "Ender Arrow", 3, DraconicEvolution.instance, 32, 1, true); + //EntityRegistry.registerModEntity(EntityChaosDrill.class, "Chaos Drill", 4, DraconicEvolution.instance, 10, 5, false); + EntityRegistry.registerModEntity(EntityDragonHeart.class, "Dragon Heart Item", 5, DraconicEvolution.instance, 32, 5, true); + EntityRegistry.registerModEntity(EntityChaosGuardian.class, "ChaosGuardian", 6, DraconicEvolution.instance, 256, 1, true); + EntityRegistry.registerModEntity(EntityDragonProjectile.class, "DragonProjectile", 7, DraconicEvolution.instance, 256, 1, true); + EntityRegistry.registerModEntity(EntityChaosCrystal.class, "ChaosCrystal", 8, DraconicEvolution.instance, 256, 5, false); + EntityRegistry.registerModEntity(EntityChaosBolt.class, "ChaosBolt", 9, DraconicEvolution.instance, 32, 5, true); + EntityRegistry.registerModEntity(EntityChaosVortex.class, "EntityChaosEnergyVortex", 10, DraconicEvolution.instance, 512, 5, true); + EntityRegistry.registerModEntity(EntityCustomArrow.class, "CustomArrow", 11, DraconicEvolution.instance, 128, 1, true); - } + } - public ParticleEnergyBeam energyBeam(World worldObj, double x, double y, double z, double tx, double ty, double tz, int powerFlow, boolean advanced, ParticleEnergyBeam oldBeam, boolean render, int beamType) - { - return null; - } + public ParticleEnergyBeam energyBeam(World worldObj, double x, double y, double z, double tx, double ty, double tz, int powerFlow, boolean advanced, ParticleEnergyBeam oldBeam, boolean render, int beamType) { + return null; + } - public ParticleEnergyField energyField(World worldObj, double x, double y, double z, int type, boolean advanced, ParticleEnergyField oldBeam, boolean render) { - return null; - } + public ParticleEnergyField energyField(World worldObj, double x, double y, double z, int type, boolean advanced, ParticleEnergyField oldBeam, boolean render) { + return null; + } - public ParticleReactorBeam reactorBeam(TileEntity tile, ParticleReactorBeam oldBeam, boolean render) { - return null; - } + public ParticleReactorBeam reactorBeam(TileEntity tile, ParticleReactorBeam oldBeam, boolean render) { + return null; + } - public void spawnParticle(Object particle, int range) - { + public void spawnParticle(Object particle, int range) { - } + } - public ISound playISound(ISound sound){ - return null; - } + public ISound playISound(ISound sound) { + return null; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/ModBlocks.java b/src/main/java/com/brandon3055/draconicevolution/common/ModBlocks.java index c6937f8b..5a1af918 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/ModBlocks.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/ModBlocks.java @@ -13,116 +13,111 @@ import net.minecraft.item.ItemStack; @GameRegistry.ObjectHolder(References.MODID) public class ModBlocks { - public static BlockDE xRayBlock; - public static BlockDE weatherController; - public static BlockDE sunDial; - public static BlockDE draconiumOre; - public static BlockDE testBlock; - public static BlockDE grinder; - public static BlockDE potentiometer; - public static BlockDE rainSensor; - public static BlockDE particleGenerator; - public static BlockDE playerDetector; - public static BlockDE playerDetectorAdvanced; - public static BlockDE energyInfuser; - public static BlockDE customSpawner; - public static BlockDE longRangeDislocator; - public static BlockDE generator; - public static BlockDE energyStorageCore; - public static BlockDE draconiumBlock; - public static BlockDE invisibleMultiblock; - public static BlockDE energyPylon; - public static BlockDE placedItem; - public static BlockDE cKeyStone; - public static BlockDE containerTemplate; - public static BlockDE dissEnchanter; - public static BlockDE teleporterStand; - public static BlockDE draconiumChest; - public static BlockDE draconicBlock; - public static BlockDE energyCrystal; - public static BlockDE infusedObsidian; - public static BlockDE dislocatorReceptacle; - public static BlockDE portal; - public static BlockDE reactorCore; - public static BlockDE flowGate; - public static BlockDE reactorStabilizer; - public static BlockDE reactorEnergyInjector; - public static BlockDE chaosCrystal; - public static BlockDE upgradeModifier; - public static Block safetyFlame; - public static Block chaosShardAtmos = new ChaosShardAtmos().setBlockName(References.RESOURCESPREFIX+"chaosShardAtmos").setBlockTextureName(References.RESOURCESPREFIX+"transparency"); + public static BlockDE xRayBlock; + public static BlockDE weatherController; + public static BlockDE sunDial; + public static BlockDE draconiumOre; + public static BlockDE testBlock; + public static BlockDE grinder; + public static BlockDE potentiometer; + public static BlockDE rainSensor; + public static BlockDE particleGenerator; + public static BlockDE playerDetector; + public static BlockDE playerDetectorAdvanced; + public static BlockDE energyInfuser; + public static BlockDE customSpawner; + public static BlockDE longRangeDislocator; + public static BlockDE generator; + public static BlockDE energyStorageCore; + public static BlockDE draconiumBlock; + public static BlockDE invisibleMultiblock; + public static BlockDE energyPylon; + public static BlockDE placedItem; + public static BlockDE cKeyStone; + public static BlockDE containerTemplate; + public static BlockDE dissEnchanter; + public static BlockDE teleporterStand; + public static BlockDE draconiumChest; + public static BlockDE draconicBlock; + public static BlockDE energyCrystal; + public static BlockDE infusedObsidian; + public static BlockDE dislocatorReceptacle; + public static BlockDE portal; + public static BlockDE reactorCore; + public static BlockDE flowGate; + public static BlockDE reactorStabilizer; + public static BlockDE reactorEnergyInjector; + public static BlockDE chaosCrystal; + public static BlockDE upgradeModifier; + public static Block safetyFlame; + public static Block chaosShardAtmos = new ChaosShardAtmos().setBlockName(References.RESOURCESPREFIX + "chaosShardAtmos").setBlockTextureName(References.RESOURCESPREFIX + "transparency"); - public static ItemStack resurrectionStone; + public static ItemStack resurrectionStone; - public static void init() - { - xRayBlock = new XRayBlock(); - weatherController = new WeatherController(); - sunDial = new SunDial(); - draconiumOre = new DraconiumOre(); - grinder = new Grinder(); - potentiometer = new Potentiometer(); - rainSensor = new RainSensor(); - particleGenerator = new ParticleGenerator(); - playerDetector = new PlayerDetector(); - playerDetectorAdvanced = new PlayerDetectorAdvanced(); - energyInfuser = new EnergyInfuser(); - customSpawner = new CustomSpawner(); - generator = new Generator(); - energyStorageCore = new EnergyStorageCore(); - draconiumBlock = new DraconiumBlock(); - invisibleMultiblock = new InvisibleMultiblock(); - energyPylon = new EnergyPylon(); - placedItem = new PlacedItem(); - safetyFlame = new SafetyFlame(); - cKeyStone = new CKeyStone(); - dissEnchanter = new DissEnchanter(); - teleporterStand = new TeleporterStand(); - draconiumChest = new DraconiumChest(); - draconicBlock = new DraconicBlock(); - energyCrystal = new EnergyCrystal(); - infusedObsidian = new InfusedObsidian(); - dislocatorReceptacle = new DislocatorReceptacle(); - portal = new Portal(); - reactorCore = new ReactorCore(); - flowGate = new FlowGate(); - reactorStabilizer = new ReactorStabilizer(); - reactorEnergyInjector = new ReactorEnergyInjector(); - chaosCrystal = new ChaosCrystal(); - upgradeModifier = new UpgradeModifier(); + public static void init() { + xRayBlock = new XRayBlock(); + weatherController = new WeatherController(); + sunDial = new SunDial(); + draconiumOre = new DraconiumOre(); + grinder = new Grinder(); + potentiometer = new Potentiometer(); + rainSensor = new RainSensor(); + particleGenerator = new ParticleGenerator(); + playerDetector = new PlayerDetector(); + playerDetectorAdvanced = new PlayerDetectorAdvanced(); + energyInfuser = new EnergyInfuser(); + customSpawner = new CustomSpawner(); + generator = new Generator(); + energyStorageCore = new EnergyStorageCore(); + draconiumBlock = new DraconiumBlock(); + invisibleMultiblock = new InvisibleMultiblock(); + energyPylon = new EnergyPylon(); + placedItem = new PlacedItem(); + safetyFlame = new SafetyFlame(); + cKeyStone = new CKeyStone(); + dissEnchanter = new DissEnchanter(); + teleporterStand = new TeleporterStand(); + draconiumChest = new DraconiumChest(); + draconicBlock = new DraconicBlock(); + energyCrystal = new EnergyCrystal(); + infusedObsidian = new InfusedObsidian(); + dislocatorReceptacle = new DislocatorReceptacle(); + portal = new Portal(); + reactorCore = new ReactorCore(); + flowGate = new FlowGate(); + reactorStabilizer = new ReactorStabilizer(); + reactorEnergyInjector = new ReactorEnergyInjector(); + chaosCrystal = new ChaosCrystal(); + upgradeModifier = new UpgradeModifier(); - longRangeDislocator = new LongRangeDislocator(); + longRangeDislocator = new LongRangeDislocator(); - if (isEnabled(chaosShardAtmos))GameRegistry.registerBlock(chaosShardAtmos, "chaosShardAtmos"); - - if(DraconicEvolution.debug) { - testBlock = new TestBlock(); - containerTemplate = new BlockContainerTemplate(); - } + if (isEnabled(chaosShardAtmos)) GameRegistry.registerBlock(chaosShardAtmos, "chaosShardAtmos"); - resurrectionStone = new ItemStack(ModBlocks.draconiumBlock, 1, 1); - } + if (DraconicEvolution.debug) { + testBlock = new TestBlock(); + containerTemplate = new BlockContainerTemplate(); + } - public static void register(BlockDE block) - { - String name = block.getUnwrappedUnlocalizedName(block.getUnlocalizedName()); - if (isEnabled(block))GameRegistry.registerBlock(block, name.substring(name.indexOf(":") + 1)); - } + resurrectionStone = new ItemStack(ModBlocks.draconiumBlock, 1, 1); + } - public static void register(BlockDE block, Class item) - { - String name = block.getUnwrappedUnlocalizedName(block.getUnlocalizedName()); - if (isEnabled(block))GameRegistry.registerBlock(block, item, name.substring(name.indexOf(":") + 1)); - } + public static void register(BlockDE block) { + String name = block.getUnwrappedUnlocalizedName(block.getUnlocalizedName()); + if (isEnabled(block)) GameRegistry.registerBlock(block, name.substring(name.indexOf(":") + 1)); + } - public static void registerOther(Block block) - { - String name = block.getUnlocalizedName().substring(block.getUnlocalizedName().indexOf(".") + 1); - if (isEnabled(block)) GameRegistry.registerBlock(block, name.substring(name.indexOf(":") + 1)); - } + public static void register(BlockDE block, Class item) { + String name = block.getUnwrappedUnlocalizedName(block.getUnlocalizedName()); + if (isEnabled(block)) GameRegistry.registerBlock(block, item, name.substring(name.indexOf(":") + 1)); + } - public static boolean isEnabled(Block block) - { - return !ConfigHandler.disabledNamesList.contains(block.getUnlocalizedName()); - } + public static void registerOther(Block block) { + String name = block.getUnlocalizedName().substring(block.getUnlocalizedName().indexOf(".") + 1); + if (isEnabled(block)) GameRegistry.registerBlock(block, name.substring(name.indexOf(":") + 1)); + } + + public static boolean isEnabled(Block block) { + return !ConfigHandler.disabledNamesList.contains(block.getUnlocalizedName()); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/ModItems.java b/src/main/java/com/brandon3055/draconicevolution/common/ModItems.java index 3f98cb82..7a20f363 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/ModItems.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/ModItems.java @@ -21,157 +21,154 @@ import net.minecraftforge.common.util.EnumHelper; @GameRegistry.ObjectHolder(References.MODID) public class ModItems { - public static ArmorMaterial WYVERN_ARMOR = EnumHelper.addArmorMaterial("WYVERN_ARMOR", -1, new int[] { 3, 8, 6, 3 }, 30); - public static ArmorMaterial DRACONIC_ARMOR = EnumHelper.addArmorMaterial("DRACONIC_ARMOR", -1, new int[] { 3, 8, 6, 3 }, 30); - public static ToolMaterial WYVERN = EnumHelper.addToolMaterial("WYVERN", 10, -1, 12.0F, 20.0F, 35); - public static ToolMaterial AWAKENED = EnumHelper.addToolMaterial("AWAKENED", 10, -1, 16.0F, 40.0F, 40); - public static ToolMaterial CHAOTIC = EnumHelper.addToolMaterial("CHAOTIC", 10, -1, 400.0F, 60.0F, 45); + public static ArmorMaterial WYVERN_ARMOR = EnumHelper.addArmorMaterial("WYVERN_ARMOR", -1, new int[]{3, 8, 6, 3}, 30); + public static ArmorMaterial DRACONIC_ARMOR = EnumHelper.addArmorMaterial("DRACONIC_ARMOR", -1, new int[]{3, 8, 6, 3}, 30); + public static ToolMaterial WYVERN = EnumHelper.addToolMaterial("WYVERN", 10, -1, 12.0F, 20.0F, 35); + public static ToolMaterial AWAKENED = EnumHelper.addToolMaterial("AWAKENED", 10, -1, 16.0F, 40.0F, 40); + public static ToolMaterial CHAOTIC = EnumHelper.addToolMaterial("CHAOTIC", 10, -1, 400.0F, 60.0F, 45); - public static Item draconicPickaxe; - public static Item draconicShovel; - public static Item draconicHoe; - public static Item draconicAxe; - public static Item draconicSword; - public static Item draconicBow; - public static ItemArmor draconicHelm; - public static ItemArmor draconicChest; - public static ItemArmor draconicLeggs; - public static ItemArmor draconicBoots; - public static Item draconicDestructionStaff; + public static Item draconicPickaxe; + public static Item draconicShovel; + public static Item draconicHoe; + public static Item draconicAxe; + public static Item draconicSword; + public static Item draconicBow; + public static ItemArmor draconicHelm; + public static ItemArmor draconicChest; + public static ItemArmor draconicLeggs; + public static ItemArmor draconicBoots; + public static Item draconicDestructionStaff; - public static Item wyvernPickaxe; - public static Item wyvernShovel; - public static Item wyvernSword; - public static Item wyvernBow; - public static ItemArmor wyvernHelm; - public static ItemArmor wyvernChest; - public static ItemArmor wyvernLeggs; - public static ItemArmor wyvernBoots; + public static Item wyvernPickaxe; + public static Item wyvernShovel; + public static Item wyvernSword; + public static Item wyvernBow; + public static ItemArmor wyvernHelm; + public static ItemArmor wyvernChest; + public static ItemArmor wyvernLeggs; + public static ItemArmor wyvernBoots; - public static Item dezilsMarshmallow; + public static Item dezilsMarshmallow; - public static ItemDE wyvernCore; - public static ItemDE draconiumDust; - public static ItemDE draconiumIngot; - public static ItemDE draconiumBlend; - public static ItemDE dragonHeart; - public static ItemDE awakenedCore; - public static ItemDE tclogo; - public static ItemDE draconicCore; - public static ItemDE sunFocus; - public static ItemDE mobSoul; - public static ItemDE enderArrow; - public static ItemDE safetyMatch; - public static ItemDE key; - public static ItemDE creativeStructureSpawner; - public static ItemDE adminSpawnEgg; - public static ItemDE infoTablet; - public static ItemDE draconicIngot; - public static ItemDE draconiumEnergyCore; - public static ItemDE draconiumFluxCapacitor; - public static ItemDE wrench; - public static ItemDE chaosShard; - public static ItemDE reactorStabilizerParts; - public static ItemDE chaoticCore; - public static ItemDE nugget; - public static ItemDE chaosFragment; - public static ItemDE magnet; + public static ItemDE wyvernCore; + public static ItemDE draconiumDust; + public static ItemDE draconiumIngot; + public static ItemDE draconiumBlend; + public static ItemDE dragonHeart; + public static ItemDE awakenedCore; + public static ItemDE tclogo; + public static ItemDE draconicCore; + public static ItemDE sunFocus; + public static ItemDE mobSoul; + public static ItemDE enderArrow; + public static ItemDE safetyMatch; + public static ItemDE key; + public static ItemDE creativeStructureSpawner; + public static ItemDE adminSpawnEgg; + public static ItemDE infoTablet; + public static ItemDE draconicIngot; + public static ItemDE draconiumEnergyCore; + public static ItemDE draconiumFluxCapacitor; + public static ItemDE wrench; + public static ItemDE chaosShard; + public static ItemDE reactorStabilizerParts; + public static ItemDE chaoticCore; + public static ItemDE nugget; + public static ItemDE chaosFragment; + public static ItemDE magnet; - public static ItemDE teleporterMKI; - public static ItemDE teleporterMKII; + public static ItemDE teleporterMKI; + public static ItemDE teleporterMKII; - public static ItemStack wyvernFluxCapacitor; - public static ItemStack draconicFluxCapacitor; - public static ItemStack wyvernEnergyCore; - public static ItemStack draconicEnergyCore; + public static ItemStack wyvernFluxCapacitor; + public static ItemStack draconicFluxCapacitor; + public static ItemStack wyvernEnergyCore; + public static ItemStack draconicEnergyCore; - public static ItemStack partStabFrame; - public static ItemStack partStabRotorInner; - public static ItemStack partStabRotorOuter; - public static ItemStack partStabRotorAssembly; - public static ItemStack partStabRing; + public static ItemStack partStabFrame; + public static ItemStack partStabRotorInner; + public static ItemStack partStabRotorOuter; + public static ItemStack partStabRotorAssembly; + public static ItemStack partStabRing; - public static ItemStack nuggetDraconium; - public static ItemStack nuggetAwakened; + public static ItemStack nuggetDraconium; + public static ItemStack nuggetAwakened; - public static void init() - { - draconicDestructionStaff = new DraconicDistructionStaff(); - draconicPickaxe = new DraconicPickaxe(); - draconicAxe = new DraconicAxe(); - draconicShovel = new DraconicShovel(); - draconicHoe = new DraconicHoe(); - draconicSword = new DraconicSword(); - draconicBow = new DraconicBow(); - draconicHelm = new DraconicArmor(DRACONIC_ARMOR, 0, Strings.draconicHelmName); - draconicChest = new DraconicArmor(DRACONIC_ARMOR, 1, Strings.draconicChestName); - draconicLeggs = new DraconicArmor(DRACONIC_ARMOR, 2, Strings.draconicLeggsName); - draconicBoots = new DraconicArmor(DRACONIC_ARMOR, 3, Strings.draconicBootsName); - - wyvernPickaxe = new WyvernPickaxe(); - wyvernShovel = new WyvernShovel(); - wyvernSword = new WyvernSword(); - wyvernBow = new WyvernBow(); - wyvernHelm = new WyvernArmor(WYVERN_ARMOR, 0, Strings.wyvernHelmName); - wyvernChest = new WyvernArmor(WYVERN_ARMOR, 1, Strings.wyvernChestName); - wyvernLeggs = new WyvernArmor(WYVERN_ARMOR, 2, Strings.wyvernLeggsName); - wyvernBoots = new WyvernArmor(WYVERN_ARMOR, 3, Strings.wyvernBootsName); + public static void init() { + draconicDestructionStaff = new DraconicDistructionStaff(); + draconicPickaxe = new DraconicPickaxe(); + draconicAxe = new DraconicAxe(); + draconicShovel = new DraconicShovel(); + draconicHoe = new DraconicHoe(); + draconicSword = new DraconicSword(); + draconicBow = new DraconicBow(); + draconicHelm = new DraconicArmor(DRACONIC_ARMOR, 0, Strings.draconicHelmName); + draconicChest = new DraconicArmor(DRACONIC_ARMOR, 1, Strings.draconicChestName); + draconicLeggs = new DraconicArmor(DRACONIC_ARMOR, 2, Strings.draconicLeggsName); + draconicBoots = new DraconicArmor(DRACONIC_ARMOR, 3, Strings.draconicBootsName); - draconicCore = new DraconicCore(); - wyvernCore = new WyvernCore(); - awakenedCore = new AwakenedCore(); - chaoticCore = new ChaoticCore(); - draconiumDust = new DraconiumDust(); - draconiumIngot = new DraconiumIngot(); - draconiumBlend = new DraconiumBlend(); - dragonHeart = new DragonHeart(); - teleporterMKI = new TeleporterMKI(); - teleporterMKII = new TeleporterMKII(); - tclogo = new Tclogo(); - sunFocus = new SunFocus(); - mobSoul = new MobSoul(); - enderArrow = new EnderArrow(); - safetyMatch = new SafetyMatch(); - key = new Key(); - creativeStructureSpawner = new CreativeStructureSpawner(); - adminSpawnEgg = new AdminSpawnEgg(); - infoTablet = new InfoTablet(); - draconicIngot = new DraconicIngot(); - draconiumEnergyCore = new DraconiumEnergyCore(); - draconiumFluxCapacitor = new DraconiumFluxCapacitor(); - wrench = new Wrench(); - chaosShard = new ChaosShard(); - reactorStabilizerParts = new ReactorStabiliserPart(); - nugget = new Nugget(); - chaosFragment = new ChaosFragment(); - magnet = new Magnet(); + wyvernPickaxe = new WyvernPickaxe(); + wyvernShovel = new WyvernShovel(); + wyvernSword = new WyvernSword(); + wyvernBow = new WyvernBow(); + wyvernHelm = new WyvernArmor(WYVERN_ARMOR, 0, Strings.wyvernHelmName); + wyvernChest = new WyvernArmor(WYVERN_ARMOR, 1, Strings.wyvernChestName); + wyvernLeggs = new WyvernArmor(WYVERN_ARMOR, 2, Strings.wyvernLeggsName); + wyvernBoots = new WyvernArmor(WYVERN_ARMOR, 3, Strings.wyvernBootsName); - dezilsMarshmallow = new DezilsMarshmallow(); + draconicCore = new DraconicCore(); + wyvernCore = new WyvernCore(); + awakenedCore = new AwakenedCore(); + chaoticCore = new ChaoticCore(); + draconiumDust = new DraconiumDust(); + draconiumIngot = new DraconiumIngot(); + draconiumBlend = new DraconiumBlend(); + dragonHeart = new DragonHeart(); + teleporterMKI = new TeleporterMKI(); + teleporterMKII = new TeleporterMKII(); + tclogo = new Tclogo(); + sunFocus = new SunFocus(); + mobSoul = new MobSoul(); + enderArrow = new EnderArrow(); + safetyMatch = new SafetyMatch(); + key = new Key(); + creativeStructureSpawner = new CreativeStructureSpawner(); + adminSpawnEgg = new AdminSpawnEgg(); + infoTablet = new InfoTablet(); + draconicIngot = new DraconicIngot(); + draconiumEnergyCore = new DraconiumEnergyCore(); + draconiumFluxCapacitor = new DraconiumFluxCapacitor(); + wrench = new Wrench(); + chaosShard = new ChaosShard(); + reactorStabilizerParts = new ReactorStabiliserPart(); + nugget = new Nugget(); + chaosFragment = new ChaosFragment(); + magnet = new Magnet(); - //Custom ItemStacks - wyvernEnergyCore = new ItemStack(ModItems.draconiumEnergyCore, 1, 0); - draconicEnergyCore = new ItemStack(ModItems.draconiumEnergyCore, 1, 1); - wyvernFluxCapacitor = new ItemStack(ModItems.draconiumFluxCapacitor, 1, 0); - draconicFluxCapacitor = new ItemStack(ModItems.draconiumFluxCapacitor, 1, 1); + dezilsMarshmallow = new DezilsMarshmallow(); - partStabFrame = new ItemStack(reactorStabilizerParts, 1, 0); - partStabRotorInner = new ItemStack(reactorStabilizerParts, 1, 1); - partStabRotorOuter = new ItemStack(reactorStabilizerParts, 1, 2); - partStabRotorAssembly = new ItemStack(reactorStabilizerParts, 1, 3); - partStabRing = new ItemStack(reactorStabilizerParts, 1, 4); + //Custom ItemStacks + wyvernEnergyCore = new ItemStack(ModItems.draconiumEnergyCore, 1, 0); + draconicEnergyCore = new ItemStack(ModItems.draconiumEnergyCore, 1, 1); + wyvernFluxCapacitor = new ItemStack(ModItems.draconiumFluxCapacitor, 1, 0); + draconicFluxCapacitor = new ItemStack(ModItems.draconiumFluxCapacitor, 1, 1); - nuggetDraconium = new ItemStack(nugget, 1, 0); - nuggetAwakened = new ItemStack(nugget, 1, 1); - } + partStabFrame = new ItemStack(reactorStabilizerParts, 1, 0); + partStabRotorInner = new ItemStack(reactorStabilizerParts, 1, 1); + partStabRotorOuter = new ItemStack(reactorStabilizerParts, 1, 2); + partStabRotorAssembly = new ItemStack(reactorStabilizerParts, 1, 3); + partStabRing = new ItemStack(reactorStabilizerParts, 1, 4); - public static void register(final ItemDE item) - { - String name = item.getUnwrappedUnlocalizedName(item.getUnlocalizedName()); - if (isEnabled(item)) GameRegistry.registerItem(item, name.substring(name.indexOf(":") + 1)); - } + nuggetDraconium = new ItemStack(nugget, 1, 0); + nuggetAwakened = new ItemStack(nugget, 1, 1); + } - public static boolean isEnabled(Item item) - { - return !ConfigHandler.disabledNamesList.contains(item.getUnlocalizedName()); - } + public static void register(final ItemDE item) { + String name = item.getUnwrappedUnlocalizedName(item.getUnlocalizedName()); + if (isEnabled(item)) GameRegistry.registerItem(item, name.substring(name.indexOf(":") + 1)); + } + + public static boolean isEnabled(Item item) { + return !ConfigHandler.disabledNamesList.contains(item.getUnlocalizedName()); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/achievements/Achievements.java b/src/main/java/com/brandon3055/draconicevolution/common/achievements/Achievements.java index 1cd0abf0..4f3b704f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/achievements/Achievements.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/achievements/Achievements.java @@ -19,144 +19,141 @@ import java.util.HashMap; */ public class Achievements { - private static AchievementPage achievementsPage; - private static HashMap achievementsList = new HashMap(); - private static HashMap achievementItems = new HashMap(); + private static AchievementPage achievementsPage; + private static HashMap achievementsList = new HashMap(); + private static HashMap achievementItems = new HashMap(); - public static void addAchievement (String name, Achievement achievement, ItemStack stack, String triggerCondition) - { - if (stack == null || stack.getItem() == null) return; - achievementsList.put(name, achievement.registerStat()); - achievementItems.put(stack.getUnlocalizedName(), new AchievementCondition(name, triggerCondition)); - } + public static void addAchievement(String name, Achievement achievement, ItemStack stack, String triggerCondition) { + if (stack == null || stack.getItem() == null) return; + achievementsList.put(name, achievement.registerStat()); + achievementItems.put(stack.getUnlocalizedName(), new AchievementCondition(name, triggerCondition)); + } - public static void addAchievement (String name, Achievement achievement, String triggerCondition) - { - addAchievement(name, achievement, achievement.theItemStack, triggerCondition); - } + public static void addAchievement(String name, Achievement achievement, String triggerCondition) { + addAchievement(name, achievement, achievement.theItemStack, triggerCondition); + } - public static void addAchievement (String name, Achievement achievement) - { - addAchievement(name, achievement, achievement.theItemStack, "null"); - } + public static void addAchievement(String name, Achievement achievement) { + addAchievement(name, achievement, achievement.theItemStack, "null"); + } - public static Achievement getAchievement (String name) - { - return achievementsList.get(name); - } + public static Achievement getAchievement(String name) { + return achievementsList.get(name); + } - public static void triggerAchievement (EntityPlayer player, String name) - { + public static void triggerAchievement(EntityPlayer player, String name) { - Achievement ach = getAchievement(name); + Achievement ach = getAchievement(name); - if (ach != null) - { - player.triggerAchievement(ach); - } - } + if (ach != null) { + player.triggerAchievement(ach); + } + } - public static void addModAchievements() - { - int x = 5; - addAchievement("draconicevolution.dust", new Achievement("draconicevolution.dust", "draconicevolution.dust", -10+x, 0, ModItems.draconiumDust, null).initIndependentStat().setSpecial(), "pickup"); - addAchievement("draconicevolution.ingot", new Achievement("draconicevolution.ingot", "draconicevolution.ingot", -8+x, 0, ModItems.draconiumIngot, getAchievement("draconicevolution.dust")), "smelt"); - addAchievement("draconicevolution.core", new Achievement("draconicevolution.core", "draconicevolution.core", -6+x, 0, ModItems.draconicCore, getAchievement("draconicevolution.ingot")), "craft"); - addAchievement("draconicevolution.core2", new Achievement("draconicevolution.core2", "draconicevolution.core2", -4+x, 0, ModItems.wyvernCore, getAchievement("draconicevolution.core")).setSpecial(), "craft"); + public static void addModAchievements() { + int x = 5; + addAchievement("draconicevolution.dust", new Achievement("draconicevolution.dust", "draconicevolution.dust", -10 + x, 0, ModItems.draconiumDust, null).initIndependentStat().setSpecial(), "pickup"); + addAchievement("draconicevolution.ingot", new Achievement("draconicevolution.ingot", "draconicevolution.ingot", -8 + x, 0, ModItems.draconiumIngot, getAchievement("draconicevolution.dust")), "smelt"); + addAchievement("draconicevolution.core", new Achievement("draconicevolution.core", "draconicevolution.core", -6 + x, 0, ModItems.draconicCore, getAchievement("draconicevolution.ingot")), "craft"); + addAchievement("draconicevolution.core2", new Achievement("draconicevolution.core2", "draconicevolution.core2", -4 + x, 0, ModItems.wyvernCore, getAchievement("draconicevolution.core")).setSpecial(), "craft"); - addAchievement("draconicevolution.dislocator", new Achievement("draconicevolution.dislocator", "draconicevolution.dislocator", -8+x, 1, ModItems.teleporterMKI, getAchievement("draconicevolution.dust")), "craft"); - addAchievement("draconicevolution.chest", new Achievement("draconicevolution.chest", "draconicevolution.chest", -5+x, 2, ModBlocks.draconiumChest, getAchievement("draconicevolution.core")), "craft"); - addAchievement("draconicevolution.particles", new Achievement("draconicevolution.particles", "draconicevolution.particles", -7+x, 2, ModBlocks.particleGenerator, getAchievement("draconicevolution.core")), "craft"); - addAchievement("draconicevolution.weather", new Achievement("draconicevolution.weather", "draconicevolution.weather", -5+x, -2, ModBlocks.weatherController, getAchievement("draconicevolution.core")), "craft"); - addAchievement("draconicevolution.dissenchanter", new Achievement("draconicevolution.dissenchanter", "draconicevolution.dissenchanter", -7+x, -2, ModBlocks.dissEnchanter, getAchievement("draconicevolution.core")), "craft"); - addAchievement("draconicevolution.ecore", new Achievement("draconicevolution.ecore", "draconicevolution.ecore", -4+x, -6, ModBlocks.energyStorageCore, getAchievement("draconicevolution.core2")), "craft"); - addAchievement("draconicevolution.wpick", new Achievement("draconicevolution.wpick", "draconicevolution.wpick", -2+x, 1, ModItems.wyvernPickaxe, getAchievement("draconicevolution.core2")), "craft"); - addAchievement("draconicevolution.wshovel", new Achievement("draconicevolution.wshovel", "draconicevolution.wshovel", -2+x, -1, ModItems.wyvernShovel, getAchievement("draconicevolution.core2")), "craft"); - addAchievement("draconicevolution.wsword", new Achievement("draconicevolution.wsword", "draconicevolution.wsword", -2+x, 2, ModItems.wyvernSword, getAchievement("draconicevolution.core2")), "craft"); - addAchievement("draconicevolution.wbow", new Achievement("draconicevolution.wbow", "draconicevolution.wbow", -2+x, -2, ModItems.wyvernBow, getAchievement("draconicevolution.core2")), "craft"); - addAchievement("draconicevolution.whelm", new Achievement("draconicevolution.whelm", "draconicevolution.whelm", -2+x, -4, ModItems.wyvernHelm, getAchievement("draconicevolution.core2")), "craft"); - addAchievement("draconicevolution.wchest", new Achievement("draconicevolution.wchest", "draconicevolution.wchest", -2+x, -3, ModItems.wyvernChest, getAchievement("draconicevolution.core2")), "craft"); - addAchievement("draconicevolution.wleggs", new Achievement("draconicevolution.wleggs", "draconicevolution.wleggs", -2+x, 3, ModItems.wyvernLeggs, getAchievement("draconicevolution.core2")), "craft"); - addAchievement("draconicevolution.wboots", new Achievement("draconicevolution.wboots", "draconicevolution.wboots", -2+x, 4, ModItems.wyvernBoots, getAchievement("draconicevolution.core2")), "craft"); - addAchievement("draconicevolution.resurrection", new Achievement("draconicevolution.resurrection", "draconicevolution.resurrection", -4+x, 6, ModBlocks.resurrectionStone, getAchievement("draconicevolution.core2")), "craft"); - addAchievement("draconicevolution.dislocator2", new Achievement("draconicevolution.dislocator2", "draconicevolution.dislocator2", -2+x, -5, ModItems.teleporterMKII, getAchievement("draconicevolution.core2")), "craft"); - addAchievement("draconicevolution.flux", new Achievement("draconicevolution.flux", "draconicevolution.flux", -2+x, 5, ModItems.wyvernFluxCapacitor, getAchievement("draconicevolution.core2")), "craft"); + addAchievement("draconicevolution.dislocator", new Achievement("draconicevolution.dislocator", "draconicevolution.dislocator", -8 + x, 1, ModItems.teleporterMKI, getAchievement("draconicevolution.dust")), "craft"); + addAchievement("draconicevolution.chest", new Achievement("draconicevolution.chest", "draconicevolution.chest", -5 + x, 2, ModBlocks.draconiumChest, getAchievement("draconicevolution.core")), "craft"); + addAchievement("draconicevolution.particles", new Achievement("draconicevolution.particles", "draconicevolution.particles", -7 + x, 2, ModBlocks.particleGenerator, getAchievement("draconicevolution.core")), "craft"); + addAchievement("draconicevolution.weather", new Achievement("draconicevolution.weather", "draconicevolution.weather", -5 + x, -2, ModBlocks.weatherController, getAchievement("draconicevolution.core")), "craft"); + addAchievement("draconicevolution.dissenchanter", new Achievement("draconicevolution.dissenchanter", "draconicevolution.dissenchanter", -7 + x, -2, ModBlocks.dissEnchanter, getAchievement("draconicevolution.core")), "craft"); + addAchievement("draconicevolution.ecore", new Achievement("draconicevolution.ecore", "draconicevolution.ecore", -4 + x, -6, ModBlocks.energyStorageCore, getAchievement("draconicevolution.core2")), "craft"); + addAchievement("draconicevolution.wpick", new Achievement("draconicevolution.wpick", "draconicevolution.wpick", -2 + x, 1, ModItems.wyvernPickaxe, getAchievement("draconicevolution.core2")), "craft"); + addAchievement("draconicevolution.wshovel", new Achievement("draconicevolution.wshovel", "draconicevolution.wshovel", -2 + x, -1, ModItems.wyvernShovel, getAchievement("draconicevolution.core2")), "craft"); + addAchievement("draconicevolution.wsword", new Achievement("draconicevolution.wsword", "draconicevolution.wsword", -2 + x, 2, ModItems.wyvernSword, getAchievement("draconicevolution.core2")), "craft"); + addAchievement("draconicevolution.wbow", new Achievement("draconicevolution.wbow", "draconicevolution.wbow", -2 + x, -2, ModItems.wyvernBow, getAchievement("draconicevolution.core2")), "craft"); + addAchievement("draconicevolution.whelm", new Achievement("draconicevolution.whelm", "draconicevolution.whelm", -2 + x, -4, ModItems.wyvernHelm, getAchievement("draconicevolution.core2")), "craft"); + addAchievement("draconicevolution.wchest", new Achievement("draconicevolution.wchest", "draconicevolution.wchest", -2 + x, -3, ModItems.wyvernChest, getAchievement("draconicevolution.core2")), "craft"); + addAchievement("draconicevolution.wleggs", new Achievement("draconicevolution.wleggs", "draconicevolution.wleggs", -2 + x, 3, ModItems.wyvernLeggs, getAchievement("draconicevolution.core2")), "craft"); + addAchievement("draconicevolution.wboots", new Achievement("draconicevolution.wboots", "draconicevolution.wboots", -2 + x, 4, ModItems.wyvernBoots, getAchievement("draconicevolution.core2")), "craft"); + addAchievement("draconicevolution.resurrection", new Achievement("draconicevolution.resurrection", "draconicevolution.resurrection", -4 + x, 6, ModBlocks.resurrectionStone, getAchievement("draconicevolution.core2")), "craft"); + addAchievement("draconicevolution.dislocator2", new Achievement("draconicevolution.dislocator2", "draconicevolution.dislocator2", -2 + x, -5, ModItems.teleporterMKII, getAchievement("draconicevolution.core2")), "craft"); + addAchievement("draconicevolution.flux", new Achievement("draconicevolution.flux", "draconicevolution.flux", -2 + x, 5, ModItems.wyvernFluxCapacitor, getAchievement("draconicevolution.core2")), "craft"); - addAchievement("draconicevolution.heart", new Achievement("draconicevolution.heart", "draconicevolution.heart", 0+x, 0, ModItems.dragonHeart, getAchievement("draconicevolution.core2")).setSpecial(), "pickup"); - addAchievement("draconicevolution.awakenedblock", new Achievement("draconicevolution.awakenedblock", "draconicevolution.awakenedblock", 2+x, 0, ModBlocks.draconicBlock, getAchievement("draconicevolution.heart")), "pickup"); - addAchievement("draconicevolution.core3", new Achievement("draconicevolution.core3", "draconicevolution.core3", 4+x, 0, ModItems.awakenedCore, getAchievement("draconicevolution.awakenedblock")).setSpecial(), "craft"); + addAchievement("draconicevolution.heart", new Achievement("draconicevolution.heart", "draconicevolution.heart", 0 + x, 0, ModItems.dragonHeart, getAchievement("draconicevolution.core2")).setSpecial(), "pickup"); + addAchievement("draconicevolution.awakenedblock", new Achievement("draconicevolution.awakenedblock", "draconicevolution.awakenedblock", 2 + x, 0, ModBlocks.draconicBlock, getAchievement("draconicevolution.heart")), "pickup"); + addAchievement("draconicevolution.core3", new Achievement("draconicevolution.core3", "draconicevolution.core3", 4 + x, 0, ModItems.awakenedCore, getAchievement("draconicevolution.awakenedblock")).setSpecial(), "craft"); - addAchievement("draconicevolution.dhelm", new Achievement("draconicevolution.dhelm", "draconicevolution.dhelm", 2+x, -3, ModItems.draconicHelm, getAchievement("draconicevolution.core3")), "craft"); - addAchievement("draconicevolution.dChest", new Achievement("draconicevolution.dChest", "draconicevolution.dChest", 2+x, -2, ModItems.draconicChest, getAchievement("draconicevolution.core3")), "craft"); - addAchievement("draconicevolution.dleggs", new Achievement("draconicevolution.dleggs", "draconicevolution.dleggs", 2+x, 2, ModItems.draconicLeggs, getAchievement("draconicevolution.core3")), "craft"); - addAchievement("draconicevolution.dboots", new Achievement("draconicevolution.dboots", "draconicevolution.dboots", 2+x, 3, ModItems.draconicBoots, getAchievement("draconicevolution.core3")), "craft"); + addAchievement("draconicevolution.dhelm", new Achievement("draconicevolution.dhelm", "draconicevolution.dhelm", 2 + x, -3, ModItems.draconicHelm, getAchievement("draconicevolution.core3")), "craft"); + addAchievement("draconicevolution.dChest", new Achievement("draconicevolution.dChest", "draconicevolution.dChest", 2 + x, -2, ModItems.draconicChest, getAchievement("draconicevolution.core3")), "craft"); + addAchievement("draconicevolution.dleggs", new Achievement("draconicevolution.dleggs", "draconicevolution.dleggs", 2 + x, 2, ModItems.draconicLeggs, getAchievement("draconicevolution.core3")), "craft"); + addAchievement("draconicevolution.dboots", new Achievement("draconicevolution.dboots", "draconicevolution.dboots", 2 + x, 3, ModItems.draconicBoots, getAchievement("draconicevolution.core3")), "craft"); - addAchievement("draconicevolution.dpick", new Achievement("draconicevolution.dpick", "draconicevolution.dpick", 6+x, 0, ModItems.draconicPickaxe, getAchievement("draconicevolution.core3")), "craft"); - addAchievement("draconicevolution.dshovel", new Achievement("draconicevolution.dshovel", "draconicevolution.dshovel", 6+x, -1, ModItems.draconicShovel, getAchievement("draconicevolution.core3")), "craft"); - addAchievement("draconicevolution.daxe", new Achievement("draconicevolution.daxe", "draconicevolution.daxe", 6+x, 1, ModItems.draconicAxe, getAchievement("draconicevolution.core3")), "craft"); - addAchievement("draconicevolution.dsword", new Achievement("draconicevolution.dsword", "draconicevolution.dsword", 6+x, -2, ModItems.draconicSword, getAchievement("draconicevolution.core3")), "craft"); - addAchievement("draconicevolution.dbow", new Achievement("draconicevolution.dbow", "draconicevolution.dbow", 6+x, 2, ModItems.draconicBow, getAchievement("draconicevolution.core3")), "craft"); - addAchievement("draconicevolution.flux2", new Achievement("draconicevolution.flux2", "draconicevolution.flux2", 6+x, -3, ModItems.draconicFluxCapacitor, getAchievement("draconicevolution.core3")), "craft"); - addAchievement("draconicevolution.dhoe", new Achievement("draconicevolution.dhoe", "draconicevolution.dhoe", 6+x, 3, ModItems.draconicHoe, getAchievement("draconicevolution.core3")), "craft"); + addAchievement("draconicevolution.dpick", new Achievement("draconicevolution.dpick", "draconicevolution.dpick", 6 + x, 0, ModItems.draconicPickaxe, getAchievement("draconicevolution.core3")), "craft"); + addAchievement("draconicevolution.dshovel", new Achievement("draconicevolution.dshovel", "draconicevolution.dshovel", 6 + x, -1, ModItems.draconicShovel, getAchievement("draconicevolution.core3")), "craft"); + addAchievement("draconicevolution.daxe", new Achievement("draconicevolution.daxe", "draconicevolution.daxe", 6 + x, 1, ModItems.draconicAxe, getAchievement("draconicevolution.core3")), "craft"); + addAchievement("draconicevolution.dsword", new Achievement("draconicevolution.dsword", "draconicevolution.dsword", 6 + x, -2, ModItems.draconicSword, getAchievement("draconicevolution.core3")), "craft"); + addAchievement("draconicevolution.dbow", new Achievement("draconicevolution.dbow", "draconicevolution.dbow", 6 + x, 2, ModItems.draconicBow, getAchievement("draconicevolution.core3")), "craft"); + addAchievement("draconicevolution.flux2", new Achievement("draconicevolution.flux2", "draconicevolution.flux2", 6 + x, -3, ModItems.draconicFluxCapacitor, getAchievement("draconicevolution.core3")), "craft"); + addAchievement("draconicevolution.dhoe", new Achievement("draconicevolution.dhoe", "draconicevolution.dhoe", 6 + x, 3, ModItems.draconicHoe, getAchievement("draconicevolution.core3")), "craft"); - addAchievement("draconicevolution.dstaff", new Achievement("draconicevolution.dstaff", "draconicevolution.dstaff", 8+x, 0, ModItems.draconicDestructionStaff, getAchievement("draconicevolution.dpick")).setSpecial(), "craft"); + addAchievement("draconicevolution.dstaff", new Achievement("draconicevolution.dstaff", "draconicevolution.dstaff", 8 + x, 0, ModItems.draconicDestructionStaff, getAchievement("draconicevolution.dpick")).setSpecial(), "craft"); - ItemStack mobSoul = new ItemStack(ModItems.mobSoul); - ItemNBTHelper.setString(mobSoul, "Name", "Any"); - addAchievement("draconicevolution.soul", new Achievement("draconicevolution.soul", "draconicevolution.soul", 0+x, -2, mobSoul, null).initIndependentStat(), "null"); - //if (ConfigHandler.disableSunDial == 0)addAchievement("draconicevolution.sundial", new Achievement("draconicevolution.sundial", "draconicevolution.sundial", 4+x, -4, ModBlocks.sunDial, getAchievement("draconicevolution.core3")).setSpecial(), "craft"); - addAchievement("draconicevolution.manual", new Achievement("draconicevolution.manual", "draconicevolution.manual", -8+x, -1, ModItems.infoTablet, getAchievement("draconicevolution.dust")), "craft"); + ItemStack mobSoul = new ItemStack(ModItems.mobSoul); + ItemNBTHelper.setString(mobSoul, "Name", "Any"); + addAchievement("draconicevolution.soul", new Achievement("draconicevolution.soul", "draconicevolution.soul", 0 + x, -2, mobSoul, null).initIndependentStat(), "null"); + //if (ConfigHandler.disableSunDial == 0)addAchievement("draconicevolution.sundial", new Achievement("draconicevolution.sundial", "draconicevolution.sundial", 4+x, -4, ModBlocks.sunDial, getAchievement("draconicevolution.core3")).setSpecial(), "craft"); + addAchievement("draconicevolution.manual", new Achievement("draconicevolution.manual", "draconicevolution.manual", -8 + x, -1, ModItems.infoTablet, getAchievement("draconicevolution.dust")), "craft"); - } + } - public static void registerAchievementPane () - { - Achievement[] achievements = new Achievement[achievementsList.size()]; + public static void registerAchievementPane() { + Achievement[] achievements = new Achievement[achievementsList.size()]; - achievements = achievementsList.values().toArray(achievements); - achievementsPage = new AchievementPage(StatCollector.translateToLocal("draconicevolution.achievementPage.name"), achievements); - AchievementPage.registerAchievementPage(achievementsPage); - } + achievements = achievementsList.values().toArray(achievements); + achievementsPage = new AchievementPage(StatCollector.translateToLocal("draconicevolution.achievementPage.name"), achievements); + AchievementPage.registerAchievementPage(achievementsPage); + } - @SubscribeEvent - public void entityPickupEvent(EntityItemPickupEvent event){ - ItemStack stack = event.item.getEntityItem().copy(); - stack.stackSize = 1; - if (achievementItems.containsKey(stack.getUnlocalizedName()) && achievementItems.get(stack.getUnlocalizedName()).isCorrectCondition("pickup")){ - triggerAchievement(event.entityPlayer, achievementItems.get(stack.getUnlocalizedName()).getName()); - } - } + @SubscribeEvent + public void entityPickupEvent(EntityItemPickupEvent event) { + ItemStack stack = event.item.getEntityItem().copy(); + stack.stackSize = 1; + if (achievementItems.containsKey(stack.getUnlocalizedName()) && achievementItems.get(stack.getUnlocalizedName()).isCorrectCondition("pickup")) { + triggerAchievement(event.entityPlayer, achievementItems.get(stack.getUnlocalizedName()).getName()); + } + } - @SubscribeEvent - public void craftEvent(PlayerEvent.ItemCraftedEvent event){ - ItemStack stack = event.crafting.copy(); - stack.stackSize = 1; - if (achievementItems.containsKey(stack.getUnlocalizedName()) && achievementItems.get(stack.getUnlocalizedName()).isCorrectCondition("craft")){ - triggerAchievement(event.player, achievementItems.get(stack.getUnlocalizedName()).getName()); - } - } + @SubscribeEvent + public void craftEvent(PlayerEvent.ItemCraftedEvent event) { + ItemStack stack = event.crafting.copy(); + stack.stackSize = 1; + if (achievementItems.containsKey(stack.getUnlocalizedName()) && achievementItems.get(stack.getUnlocalizedName()).isCorrectCondition("craft")) { + triggerAchievement(event.player, achievementItems.get(stack.getUnlocalizedName()).getName()); + } + } - @SubscribeEvent - public void smeltEvent(PlayerEvent.ItemSmeltedEvent event){ - ItemStack stack = event.smelting.copy(); - stack.stackSize = 1; - if (achievementItems.containsKey(stack.getUnlocalizedName()) && achievementItems.get(stack.getUnlocalizedName()).isCorrectCondition("smelt")){ - triggerAchievement(event.player, achievementItems.get(stack.getUnlocalizedName()).getName()); - } - } + @SubscribeEvent + public void smeltEvent(PlayerEvent.ItemSmeltedEvent event) { + ItemStack stack = event.smelting.copy(); + stack.stackSize = 1; + if (achievementItems.containsKey(stack.getUnlocalizedName()) && achievementItems.get(stack.getUnlocalizedName()).isCorrectCondition("smelt")) { + triggerAchievement(event.player, achievementItems.get(stack.getUnlocalizedName()).getName()); + } + } - private static class AchievementCondition { - private final String name; - public final String condition; - public AchievementCondition(String name, String condition){ - this.name = name; - this.condition = condition; - } + private static class AchievementCondition { + private final String name; + public final String condition; - public boolean isCorrectCondition(String s) { return s.equals(condition); } + public AchievementCondition(String name, String condition) { + this.name = name; + this.condition = condition; + } - public String getName() { return name; } - } + public boolean isCorrectCondition(String s) { + return s.equals(condition); + } + + public String getName() { + return name; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockContainerDE.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockContainerDE.java index 19581ce7..1dae80e2 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockContainerDE.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockContainerDE.java @@ -11,33 +11,33 @@ import net.minecraft.world.World; */ public class BlockContainerDE extends BlockDE implements ITileEntityProvider { - public BlockContainerDE(final Material material) { - super(material); - this.isBlockContainer = true; - } + public BlockContainerDE(final Material material) { + super(material); + this.isBlockContainer = true; + } - public BlockContainerDE() { - super(Material.rock); - this.isBlockContainer = true; - } + public BlockContainerDE() { + super(Material.rock); + this.isBlockContainer = true; + } - @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { - return null; - } + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + return null; + } - public void onBlockAdded(World world, int x, int y, int z){ - super.onBlockAdded(world, x, y, z); - } + public void onBlockAdded(World world, int x, int y, int z) { + super.onBlockAdded(world, x, y, z); + } - public void breakBlock(World world, int x, int y, int z, Block block, int meta){ - super.breakBlock(world, x, y, z, block, meta); - world.removeTileEntity(x, y, z); - } + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + super.breakBlock(world, x, y, z, block, meta); + world.removeTileEntity(x, y, z); + } - public boolean onBlockEventReceived(World world, int x, int y, int z, int p_149696_5_, int p_149696_6_){ - super.onBlockEventReceived(world, x, y, z, p_149696_5_, p_149696_6_); - TileEntity tileentity = world.getTileEntity(x, y, z); - return tileentity != null ? tileentity.receiveClientEvent(p_149696_5_, p_149696_6_) : false; - } + public boolean onBlockEventReceived(World world, int x, int y, int z, int p_149696_5_, int p_149696_6_) { + super.onBlockEventReceived(world, x, y, z, p_149696_5_, p_149696_6_); + TileEntity tileentity = world.getTileEntity(x, y, z); + return tileentity != null ? tileentity.receiveClientEvent(p_149696_5_, p_149696_6_) : false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockContainerTemplate.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockContainerTemplate.java index 9dc9bfae..97dce033 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockContainerTemplate.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockContainerTemplate.java @@ -23,79 +23,78 @@ import net.minecraft.world.World; * Created by Brandon on 27/06/2014. */ public class BlockContainerTemplate extends BlockContainerDE { - public BlockContainerTemplate() { - super(Material.iron); - this.setBlockName(Strings.containerTemplateName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setStepSound(soundTypeStone); - this.setHardness(1f); - this.setResistance(200.0f); - ModBlocks.register(this); - } + public BlockContainerTemplate() { + super(Material.iron); + this.setBlockName(Strings.containerTemplateName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setStepSound(soundTypeStone); + this.setHardness(1f); + this.setResistance(200.0f); + ModBlocks.register(this); + } - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileContainerTemplate(); - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileContainerTemplate(); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float prx, float pry, float prz) { - if (!world.isRemote) { - FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_CONTAINER_TEMPLATE, world, x, y, z); - } - return true; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float prx, float pry, float prz) { + if (!world.isRemote) { + FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_CONTAINER_TEMPLATE, world, x, y, z); + } + return true; + } - @SideOnly(Side.CLIENT) - @Override - public int getRenderType() { - return super.getRenderType(); - } + @SideOnly(Side.CLIENT) + @Override + public int getRenderType() { + return super.getRenderType(); + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int meta) - { - TileEntity te = world.getTileEntity(x, y, z); - if (te != null && te instanceof IInventory) { - IInventory inventory = (IInventory) te; + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + TileEntity te = world.getTileEntity(x, y, z); + if (te != null && te instanceof IInventory) { + IInventory inventory = (IInventory) te; - for (int i = 0; i < inventory.getSizeInventory(); i++) { - ItemStack stack = inventory.getStackInSlot(i); + for (int i = 0; i < inventory.getSizeInventory(); i++) { + ItemStack stack = inventory.getStackInSlot(i); - if (stack != null) { - float spawnX = x + world.rand.nextFloat(); - float spawnY = y + world.rand.nextFloat(); - float spawnZ = z + world.rand.nextFloat(); + if (stack != null) { + float spawnX = x + world.rand.nextFloat(); + float spawnY = y + world.rand.nextFloat(); + float spawnZ = z + world.rand.nextFloat(); - EntityItem droppedItem = new EntityItem(world, spawnX, spawnY, spawnZ, stack); + EntityItem droppedItem = new EntityItem(world, spawnX, spawnY, spawnZ, stack); - float multiplier = 0.05F; + float multiplier = 0.05F; - droppedItem.motionX = (-0.5F + world.rand.nextFloat()) * multiplier; - droppedItem.motionY = (4 + world.rand.nextFloat()) * multiplier; - droppedItem.motionZ = (-0.5F + world.rand.nextFloat()) * multiplier; + droppedItem.motionX = (-0.5F + world.rand.nextFloat()) * multiplier; + droppedItem.motionY = (4 + world.rand.nextFloat()) * multiplier; + droppedItem.motionZ = (-0.5F + world.rand.nextFloat()) * multiplier; - world.spawnEntityInWorld(droppedItem); - } - } - } + world.spawnEntityInWorld(droppedItem); + } + } + } - super.breakBlock(world, x, y, z, block, meta); - } + super.breakBlock(world, x, y, z, block, meta); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockCustomDrop.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockCustomDrop.java index e21181a4..66591ce8 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockCustomDrop.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockCustomDrop.java @@ -16,59 +16,66 @@ import java.util.List; * Created by Brandon on 13/11/2014. */ public abstract class BlockCustomDrop extends BlockContainerDE { - public BlockCustomDrop(final Material material) { - super(material); - } + public BlockCustomDrop(final Material material) { + super(material); + } - /**If true the tile will drop its inventory when broken*/ - protected abstract boolean dropInventory(); + /** + * If true the tile will drop its inventory when broken + */ + protected abstract boolean dropInventory(); - /**If true the tile will drop a custom block with custom data when broken*/ - protected abstract boolean hasCustomDropps(); + /** + * If true the tile will drop a custom block with custom data when broken + */ + protected abstract boolean hasCustomDropps(); - /**Use to specify custom drops*/ - protected abstract void getCustomTileEntityDrops(TileEntity te, List droppes); + /** + * Use to specify custom drops + */ + protected abstract void getCustomTileEntityDrops(TileEntity te, List droppes); - private void getCustomDrops(TileEntity te, List droppes){ - if (te == null) return; - if (hasCustomDropps()){ - getCustomTileEntityDrops(te, droppes); - } - if (dropInventory() && te instanceof IInventory){ - droppes.addAll(InventoryUtils.getInventoryContents((IInventory)te)); - for (int i = 0; i < ((IInventory)te).getSizeInventory(); i++) ((IInventory)te).setInventorySlotContents(i, null); - } - } + private void getCustomDrops(TileEntity te, List droppes) { + if (te == null) return; + if (hasCustomDropps()) { + getCustomTileEntityDrops(te, droppes); + } + if (dropInventory() && te instanceof IInventory) { + droppes.addAll(InventoryUtils.getInventoryContents((IInventory) te)); + for (int i = 0; i < ((IInventory) te).getSizeInventory(); i++) + ((IInventory) te).setInventorySlotContents(i, null); + } + } - @Override - public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { - if (willHarvest) { - TileEntity te = world.getTileEntity(x, y, z); + @Override + public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { + if (willHarvest) { + TileEntity te = world.getTileEntity(x, y, z); - boolean result = super.removedByPlayer(world, player, x, y, z, willHarvest); + boolean result = super.removedByPlayer(world, player, x, y, z, willHarvest); - if (result) { - List teDrops = Lists.newArrayList(); - getCustomDrops(te, teDrops); - for (ItemStack drop : teDrops) - dropBlockAsItem(world, x, y, z, drop); - } + if (result) { + List teDrops = Lists.newArrayList(); + getCustomDrops(te, teDrops); + for (ItemStack drop : teDrops) + dropBlockAsItem(world, x, y, z, drop); + } - return result; - } + return result; + } - return super.removedByPlayer(world, player, x, y, z, willHarvest); - } + return super.removedByPlayer(world, player, x, y, z, willHarvest); + } - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList result = Lists.newArrayList(); - if (!hasCustomDropps()) result.addAll(super.getDrops(world, x, y, z, metadata, fortune)); - if (hasCustomDropps() || dropInventory()) { - TileEntity te = world.getTileEntity(x, y, z); - getCustomDrops(te, result); - } + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList result = Lists.newArrayList(); + if (!hasCustomDropps()) result.addAll(super.getDrops(world, x, y, z, metadata, fortune)); + if (hasCustomDropps() || dropInventory()) { + TileEntity te = world.getTileEntity(x, y, z); + getCustomDrops(te, result); + } - return result; - } + return result; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockDE.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockDE.java index 5dd5339a..7c8947ea 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockDE.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockDE.java @@ -9,34 +9,31 @@ import net.minecraft.client.renderer.texture.IIconRegister; public class BlockDE extends Block { - public BlockDE(final Material material) { - super(material); - this.setHardness(5F); - this.setResistance(10.0F); - } + public BlockDE(final Material material) { + super(material); + this.setHardness(5F); + this.setResistance(10.0F); + } - public BlockDE() { - super(Material.iron); - this.setHardness(5F); - this.setResistance(10.0F); - } + public BlockDE() { + super(Material.iron); + this.setHardness(5F); + this.setResistance(10.0F); + } - @Override - public String getUnlocalizedName() - { - return String.format("tile.%s%s", References.MODID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); - } + @Override + public String getUnlocalizedName() { + return String.format("tile.%s%s", References.MODID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + } - public String getUnwrappedUnlocalizedName(String unlocalizedName) - { - return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); - } + public String getUnwrappedUnlocalizedName(String unlocalizedName) { + return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) - { - this.blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + getUnwrappedUnlocalizedName(super.getUnlocalizedName())); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + this.blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/CKeyStone.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/CKeyStone.java index f1ba385a..69245f40 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/CKeyStone.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/CKeyStone.java @@ -25,102 +25,101 @@ import net.minecraftforge.common.util.ForgeDirection; * Created by Brandon on 27/08/2014. */ public class CKeyStone extends BlockDE { - private IIcon blockIcon1; - public CKeyStone(){ - this.setBlockUnbreakable(); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setBlockName(Strings.cKeyStoneName); - ModBlocks.register(this, CKeyStoneItemBlock.class); - } + private IIcon blockIcon1; + + public CKeyStone() { + this.setBlockUnbreakable(); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setBlockName(Strings.cKeyStoneName); + ModBlocks.register(this, CKeyStoneItemBlock.class); + } - @Override - public boolean hasTileEntity(int metadata) { - return true; - } + @Override + public boolean hasTileEntity(int metadata) { + return true; + } - @Override - public TileEntity createTileEntity(World world, int metadata) { - return new TileCKeyStone(); - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileCKeyStone(); + } - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "key_stone_inactive"); - blockIcon1 = iconRegister.registerIcon(References.RESOURCESPREFIX + "key_stone_active"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "key_stone_inactive"); + blockIcon1 = iconRegister.registerIcon(References.RESOURCESPREFIX + "key_stone_active"); + } - @SideOnly(Side.CLIENT) - @Override - public IIcon getIcon(int side, int meta) { - if (side == 0 || side == 1) return Blocks.furnace.getIcon(side, meta); - else return blockIcon1; - } + @SideOnly(Side.CLIENT) + @Override + public IIcon getIcon(int side, int meta) { + if (side == 0 || side == 1) return Blocks.furnace.getIcon(side, meta); + else return blockIcon1; + } - @Override - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { - if (side == 0 || side == 1) return Blocks.furnace.getIcon(side, 0); - TileCKeyStone tile = world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCKeyStone ? (TileCKeyStone) world.getTileEntity(x, y, z) : null; - if (tile != null) return tile.isActivated ? blockIcon1 : blockIcon; - else return blockIcon; - } + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + if (side == 0 || side == 1) return Blocks.furnace.getIcon(side, 0); + TileCKeyStone tile = world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCKeyStone ? (TileCKeyStone) world.getTileEntity(x, y, z) : null; + if (tile != null) return tile.isActivated ? blockIcon1 : blockIcon; + else return blockIcon; + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - TileCKeyStone tile = world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCKeyStone ? (TileCKeyStone) world.getTileEntity(x, y, z) : null; + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + TileCKeyStone tile = world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCKeyStone ? (TileCKeyStone) world.getTileEntity(x, y, z) : null; - if (tile != null) return tile.onActivated(player.getHeldItem(), player); - return false; - } + if (tile != null) return tile.onActivated(player.getHeldItem(), player); + return false; + } - @Override - public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { - return true; - } + @Override + public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { + return true; + } - @Override - public boolean canProvidePower(){ - return true; - } + @Override + public boolean canProvidePower() { + return true; + } - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int meta) - { - TileCKeyStone tile = world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCKeyStone ? (TileCKeyStone) world.getTileEntity(x, y, z) : null; - if (tile != null) return tile.isActivated ? 15 : 0; - return 0; - } + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int meta) { + TileCKeyStone tile = world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCKeyStone ? (TileCKeyStone) world.getTileEntity(x, y, z) : null; + if (tile != null) return tile.isActivated ? 15 : 0; + return 0; + } - @Override - public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int meta) - { - return 0; - } + @Override + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int meta) { + return 0; + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { - TileCKeyStone tile = world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCKeyStone ? (TileCKeyStone) world.getTileEntity(x, y, z) : null; - if (tile != null) { - ItemStack key = new ItemStack(ModItems.key); - ItemNBTHelper.setInteger(key, "KeyCode", tile.getKeyCode()); - ItemNBTHelper.setInteger(key, "X", x); - ItemNBTHelper.setInteger(key, "Y", y); - ItemNBTHelper.setInteger(key, "Z", z); - return key; - } - return null; - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { + TileCKeyStone tile = world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCKeyStone ? (TileCKeyStone) world.getTileEntity(x, y, z) : null; + if (tile != null) { + ItemStack key = new ItemStack(ModItems.key); + ItemNBTHelper.setInteger(key, "KeyCode", tile.getKeyCode()); + ItemNBTHelper.setInteger(key, "X", x); + ItemNBTHelper.setInteger(key, "Y", y); + ItemNBTHelper.setInteger(key, "Z", z); + return key; + } + return null; + } - @Override - public boolean isBlockSolid(IBlockAccess p_149747_1_, int p_149747_2_, int p_149747_3_, int p_149747_4_, int p_149747_5_) { - return true; - } + @Override + public boolean isBlockSolid(IBlockAccess p_149747_1_, int p_149747_2_, int p_149747_3_, int p_149747_4_, int p_149747_5_) { + return true; + } - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { - return true; - } + @Override + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return true; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/ChaosCrystal.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/ChaosCrystal.java index eec81d7b..a313640c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/ChaosCrystal.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/ChaosCrystal.java @@ -27,85 +27,87 @@ import java.util.Random; */ public class ChaosCrystal extends BlockDE { - public ChaosCrystal(){ - super(Material.rock); - this.setHardness(100.0F); - this.setResistance(4000.0F); - this.setBlockUnbreakable(); - this.setBlockName("chaosCrystal"); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); + public ChaosCrystal() { + super(Material.rock); + this.setHardness(100.0F); + this.setResistance(4000.0F); + this.setBlockUnbreakable(); + this.setBlockName("chaosCrystal"); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModBlocks.register(this); - } + ModBlocks.register(this); + } - @Override - public float getBlockHardness(World world, int x, int y, int z) { - TileChaosShard tile = world.getTileEntity(x, y, z) instanceof TileChaosShard ? (TileChaosShard) world.getTileEntity(x, y, z) : null; - if (tile != null) return tile.guardianDefeated ? 100F : -1F; - return super.getBlockHardness(world, x, y, z); - } + @Override + public float getBlockHardness(World world, int x, int y, int z) { + TileChaosShard tile = world.getTileEntity(x, y, z) instanceof TileChaosShard ? (TileChaosShard) world.getTileEntity(x, y, z) : null; + if (tile != null) return tile.guardianDefeated ? 100F : -1F; + return super.getBlockHardness(world, x, y, z); + } - @Override - public void registerBlockIcons(IIconRegister iconRegister) {blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "transparency");} + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "transparency"); + } - @Override - public boolean hasTileEntity(int metadata) { - return true; - } + @Override + public boolean hasTileEntity(int metadata) { + return true; + } - @Override - public TileEntity createTileEntity(World world, int metadata) { - return new TileChaosShard(); - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileChaosShard(); + } - @Override - public int getRenderType() { - return -1; - } + @Override + public int getRenderType() { + return -1; + } - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return ModItems.chaosShard; - } + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return ModItems.chaosShard; + } - @Override - public int quantityDropped(int meta, int fortune, Random random) { - return 5; - } + @Override + public int quantityDropped(int meta, int fortune, Random random) { + return 5; + } - @Override - public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { - return false; - } + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + return false; + } - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int i) { - if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileChaosShard){ - ((TileChaosShard)world.getTileEntity(x, y, z)).detonate(); - } - super.breakBlock(world, x, y, z, block, i); - } + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int i) { + if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileChaosShard) { + ((TileChaosShard) world.getTileEntity(x, y, z)).detonate(); + } + super.breakBlock(world, x, y, z, block, i); + } - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - entity.attackEntityFrom(punishment, Float.MAX_VALUE); - } + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + entity.attackEntityFrom(punishment, Float.MAX_VALUE); + } - private static String[] naughtyList = new String[] {"item.blockMover", "tile.CardboardBox", "item.WandCasting"}; - private static DamageSource punishment = new DamageSource("chrystalMoved").setDamageAllowedInCreativeMode().setDamageBypassesArmor().setDamageIsAbsolute(); + private static String[] naughtyList = new String[]{"item.blockMover", "tile.CardboardBox", "item.WandCasting"}; + private static DamageSource punishment = new DamageSource("chrystalMoved").setDamageAllowedInCreativeMode().setDamageBypassesArmor().setDamageIsAbsolute(); - @Override - public void onBlockAdded(World world, int x, int y, int z) { - List players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x, y, z).expand(15, 15, 15)); + @Override + public void onBlockAdded(World world, int x, int y, int z) { + List players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x, y, z, x, y, z).expand(15, 15, 15)); - for (EntityPlayer player : players){ - if (player.getHeldItem() != null){ - for (String s : naughtyList){ - if (player.getHeldItem().getUnlocalizedName().equals(s)){ - player.attackEntityFrom(punishment, Float.MAX_VALUE); - } - } - } - } - } + for (EntityPlayer player : players) { + if (player.getHeldItem() != null) { + for (String s : naughtyList) { + if (player.getHeldItem().getUnlocalizedName().equals(s)) { + player.attackEntityFrom(punishment, Float.MAX_VALUE); + } + } + } + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/ChaosShardAtmos.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/ChaosShardAtmos.java index 5d981a89..3aa8b75a 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/ChaosShardAtmos.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/ChaosShardAtmos.java @@ -14,32 +14,32 @@ import java.util.Random; */ public class ChaosShardAtmos extends BlockAir { - public ChaosShardAtmos(){ - this.setTickRandomly(true); - } + public ChaosShardAtmos() { + this.setTickRandomly(true); + } - @Override - public void updateTick(World world, int x, int y, int z, Random random) { + @Override + public void updateTick(World world, int x, int y, int z, Random random) { if (world.isRemote) { return; } - if (random.nextInt(25) == 0) { - for (int searchX = x-15; searchX < x+15; searchX++){ - for (int searchZ = z-15; searchZ < z+15; searchZ++){ - if (world.getBlock(searchX, 80, searchZ) == ModBlocks.chaosCrystal){ - EntityChaosBolt bolt = new EntityChaosBolt(world, x+0.5, y+0.5, z+0.5, searchX+0.5, 80.5, searchZ+0.5); - world.spawnEntityInWorld(bolt); - return; - } - } - } - world.setBlockToAir(x, y, z); - } - } + if (random.nextInt(25) == 0) { + for (int searchX = x - 15; searchX < x + 15; searchX++) { + for (int searchZ = z - 15; searchZ < z + 15; searchZ++) { + if (world.getBlock(searchX, 80, searchZ) == ModBlocks.chaosCrystal) { + EntityChaosBolt bolt = new EntityChaosBolt(world, x + 0.5, y + 0.5, z + 0.5, searchX + 0.5, 80.5, searchZ + 0.5); + world.spawnEntityInWorld(bolt); + return; + } + } + } + world.setBlockToAir(x, y, z); + } + } - @Override - public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { - return false; - } + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + return false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/CustomSpawner.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/CustomSpawner.java index 55c0ddf1..10aa1dbf 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/CustomSpawner.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/CustomSpawner.java @@ -35,217 +35,204 @@ import java.util.Random; * Created by Brandon on 5/07/2014. */ public class CustomSpawner extends BlockDE implements IHudDisplayBlock { - public CustomSpawner() - { - this.setBlockName(Strings.customSpawnerName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setHardness(10F); - this.setResistance(2000F); - this.setHarvestLevel("pickaxe", 1); - ModBlocks.register(this); - } + public CustomSpawner() { + this.setBlockName(Strings.customSpawnerName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setHardness(10F); + this.setResistance(2000F); + this.setHarvestLevel("pickaxe", 1); + ModBlocks.register(this); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - TileCustomSpawner spawner = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCustomSpawner) ? (TileCustomSpawner)world.getTileEntity(x, y, z) : null; - if (spawner != null) - { - ItemStack item = player.getHeldItem(); - if (item != null && item.getItem().equals(ModItems.mobSoul)) - { - String name = ItemNBTHelper.getString(item, "Name", "Pig"); - if ((!ConfigHandler.spawnerListType && Arrays.asList(ConfigHandler.spawnerList).contains(name)) || (ConfigHandler.spawnerListType && !Arrays.asList(ConfigHandler.spawnerList).contains(name))) { - if (!world.isRemote)player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "[Error] soul disabled in config!")); - return false; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + TileCustomSpawner spawner = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCustomSpawner) ? (TileCustomSpawner) world.getTileEntity(x, y, z) : null; + if (spawner != null) { + ItemStack item = player.getHeldItem(); + if (item != null && item.getItem().equals(ModItems.mobSoul)) { + String name = ItemNBTHelper.getString(item, "Name", "Pig"); + if ((!ConfigHandler.spawnerListType && Arrays.asList(ConfigHandler.spawnerList).contains(name)) || (ConfigHandler.spawnerListType && !Arrays.asList(ConfigHandler.spawnerList).contains(name))) { + if (!world.isRemote) + player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "[Error] soul disabled in config!")); + return false; + } - if (name.equals(spawner.getBaseLogic().entityName)){return false;} - spawner.getBaseLogic().entityName = name; - spawner.isSetToSpawn = true; - spawner.getBaseLogic().skeletonType = ItemNBTHelper.getInteger(item, "SkeletonType", 0); - world.markBlockForUpdate(x, y, z); - item.splitStack(1); - return true; - }else if (item != null && item.getItem().equals(Items.nether_star) && spawner.getBaseLogic().requiresPlayer){ - spawner.getBaseLogic().requiresPlayer = false; - world.markBlockForUpdate(x, y, z); - item.splitStack(1); - return true; - }else if (item != null && item.getItem().equals(ModItems.wyvernCore) && spawner.getBaseLogic().spawnSpeed == 1){ - spawner.getBaseLogic().setSpawnRate(2); - world.markBlockForUpdate(x, y, z); - item.splitStack(1); - return true; - }else if (item != null && item.getItem().equals(ModItems.awakenedCore) && spawner.getBaseLogic().spawnSpeed == 2){ - spawner.getBaseLogic().setSpawnRate(3); - world.markBlockForUpdate(x, y, z); - item.splitStack(1); - return true; - }else if (item != null && item.getItem().equals(Items.golden_apple) && item.getItemDamage() == 1 && !spawner.getBaseLogic().ignoreSpawnRequirements){ - spawner.getBaseLogic().ignoreSpawnRequirements = true; - world.markBlockForUpdate(x, y, z); - item.splitStack(1); - return true; - }else - { - if (world.isRemote && !player.isSneaking()) { - player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo1.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().entityName)); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo2.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().requiresPlayer)); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo3.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().ignoreSpawnRequirements)); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo4.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().spawnSpeed)); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo5.txt")); - player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); - }else if (world.isRemote && player.isSneaking()) - { - player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo6.txt")); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo7.txt")); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo8.txt")); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo9.txt")); - player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); - } - return true; - } - } - LogHelper.error("Invalid or nonexistent TileEntity"); - return false; - } + if (name.equals(spawner.getBaseLogic().entityName)) { + return false; + } + spawner.getBaseLogic().entityName = name; + spawner.isSetToSpawn = true; + spawner.getBaseLogic().skeletonType = ItemNBTHelper.getInteger(item, "SkeletonType", 0); + world.markBlockForUpdate(x, y, z); + item.splitStack(1); + return true; + } else if (item != null && item.getItem().equals(Items.nether_star) && spawner.getBaseLogic().requiresPlayer) { + spawner.getBaseLogic().requiresPlayer = false; + world.markBlockForUpdate(x, y, z); + item.splitStack(1); + return true; + } else if (item != null && item.getItem().equals(ModItems.wyvernCore) && spawner.getBaseLogic().spawnSpeed == 1) { + spawner.getBaseLogic().setSpawnRate(2); + world.markBlockForUpdate(x, y, z); + item.splitStack(1); + return true; + } else if (item != null && item.getItem().equals(ModItems.awakenedCore) && spawner.getBaseLogic().spawnSpeed == 2) { + spawner.getBaseLogic().setSpawnRate(3); + world.markBlockForUpdate(x, y, z); + item.splitStack(1); + return true; + } else if (item != null && item.getItem().equals(Items.golden_apple) && item.getItemDamage() == 1 && !spawner.getBaseLogic().ignoreSpawnRequirements) { + spawner.getBaseLogic().ignoreSpawnRequirements = true; + world.markBlockForUpdate(x, y, z); + item.splitStack(1); + return true; + } else { + if (world.isRemote && !player.isSneaking()) { + player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo1.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().entityName)); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo2.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().requiresPlayer)); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo3.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().ignoreSpawnRequirements)); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo4.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().spawnSpeed)); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo5.txt")); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); + } else if (world.isRemote && player.isSneaking()) { + player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo6.txt")); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo7.txt")); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo8.txt")); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo9.txt")); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); + } + return true; + } + } + LogHelper.error("Invalid or nonexistent TileEntity"); + return false; + } - @Override - public boolean hasTileEntity(int metadata) { - return true; - } + @Override + public boolean hasTileEntity(int metadata) { + return true; + } - @Override - public TileEntity createTileEntity(World world, int metadata) { - return new TileCustomSpawner(); - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileCustomSpawner(); + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public int getHarvestLevel(int metadata) { - return 4; - } + @Override + public int getHarvestLevel(int metadata) { + return 4; + } - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { - return true; - } + @Override + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return true; + } - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return Item.getItemFromBlock(ModBlocks.customSpawner); - } + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return Item.getItemFromBlock(ModBlocks.customSpawner); + } - @Override - public int quantityDropped(Random p_149745_1_) { - return 1; - } + @Override + public int quantityDropped(Random p_149745_1_) { + return 1; + } - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon("mob_spawner"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon("mob_spawner"); + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_) { - TileCustomSpawner spawner = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCustomSpawner) ? (TileCustomSpawner)world.getTileEntity(x, y, z) : null; - if (spawner != null) - { - spawner.getBaseLogic().powered = world.isBlockIndirectlyGettingPowered(x, y, z); - if (spawner.getBaseLogic().powered != spawner.getBaseLogic().ltPowered){ - spawner.getBaseLogic().ltPowered = spawner.getBaseLogic().powered; - world.markBlockForUpdate(x, y, z); - spawner.getBaseLogic().setSpawnRate(spawner.getBaseLogic().spawnSpeed); - } - } - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_) { + TileCustomSpawner spawner = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCustomSpawner) ? (TileCustomSpawner) world.getTileEntity(x, y, z) : null; + if (spawner != null) { + spawner.getBaseLogic().powered = world.isBlockIndirectlyGettingPowered(x, y, z); + if (spawner.getBaseLogic().powered != spawner.getBaseLogic().ltPowered) { + spawner.getBaseLogic().ltPowered = spawner.getBaseLogic().powered; + world.markBlockForUpdate(x, y, z); + spawner.getBaseLogic().setSpawnRate(spawner.getBaseLogic().spawnSpeed); + } + } + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { - return new ItemStack(ModBlocks.customSpawner); - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { + return new ItemStack(ModBlocks.customSpawner); + } + @Override + public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int p_149749_6_) { + TileCustomSpawner spawner = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCustomSpawner) ? (TileCustomSpawner) world.getTileEntity(x, y, z) : null; + if (spawner != null && !world.isRemote) { + float multiplyer = 0.05F; - @Override - public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int p_149749_6_) { - TileCustomSpawner spawner = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCustomSpawner) ? (TileCustomSpawner)world.getTileEntity(x, y, z) : null; - if (spawner != null && !world.isRemote) - { - float multiplyer = 0.05F; + if (spawner.getBaseLogic().ignoreSpawnRequirements) { + EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(Items.golden_apple, 1, 1)); + item.motionX = (-0.5F + world.rand.nextFloat()) * multiplyer; + item.motionY = (4 + world.rand.nextFloat()) * multiplyer; + item.motionZ = (-0.5F + world.rand.nextFloat()) * multiplyer; + world.spawnEntityInWorld(item); + } + if (spawner.getBaseLogic().spawnSpeed > 1) { + EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.wyvernCore)); + item.motionX = (-0.5F + world.rand.nextFloat()) * multiplyer; + item.motionY = (4 + world.rand.nextFloat()) * multiplyer; + item.motionZ = (-0.5F + world.rand.nextFloat()) * multiplyer; + world.spawnEntityInWorld(item); + } + if (spawner.getBaseLogic().spawnSpeed > 2) { + EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.awakenedCore)); + item.motionX = (-0.5F + world.rand.nextFloat()) * multiplyer; + item.motionY = (4 + world.rand.nextFloat()) * multiplyer; + item.motionZ = (-0.5F + world.rand.nextFloat()) * multiplyer; + world.spawnEntityInWorld(item); + } + if (!spawner.getBaseLogic().requiresPlayer) { + EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(Items.nether_star)); + item.motionX = (-0.5F + world.rand.nextFloat()) * multiplyer; + item.motionY = (4 + world.rand.nextFloat()) * multiplyer; + item.motionZ = (-0.5F + world.rand.nextFloat()) * multiplyer; + world.spawnEntityInWorld(item); + } + } + super.breakBlock(world, x, y, z, p_149749_5_, p_149749_6_); + } - if (spawner.getBaseLogic().ignoreSpawnRequirements) - { - EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(Items.golden_apple, 1, 1)); - item.motionX = (-0.5F + world.rand.nextFloat()) * multiplyer; - item.motionY = (4 + world.rand.nextFloat()) * multiplyer; - item.motionZ = (-0.5F + world.rand.nextFloat()) * multiplyer; - world.spawnEntityInWorld(item); - } - if (spawner.getBaseLogic().spawnSpeed > 1) - { - EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.wyvernCore)); - item.motionX = (-0.5F + world.rand.nextFloat()) * multiplyer; - item.motionY = (4 + world.rand.nextFloat()) * multiplyer; - item.motionZ = (-0.5F + world.rand.nextFloat()) * multiplyer; - world.spawnEntityInWorld(item); - } - if (spawner.getBaseLogic().spawnSpeed > 2) - { - EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.awakenedCore)); - item.motionX = (-0.5F + world.rand.nextFloat()) * multiplyer; - item.motionY = (4 + world.rand.nextFloat()) * multiplyer; - item.motionZ = (-0.5F + world.rand.nextFloat()) * multiplyer; - world.spawnEntityInWorld(item); - } - if (!spawner.getBaseLogic().requiresPlayer) - { - EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(Items.nether_star)); - item.motionX = (-0.5F + world.rand.nextFloat()) * multiplyer; - item.motionY = (4 + world.rand.nextFloat()) * multiplyer; - item.motionZ = (-0.5F + world.rand.nextFloat()) * multiplyer; - world.spawnEntityInWorld(item); - } - } - super.breakBlock(world, x, y, z, p_149749_5_, p_149749_6_); - } + @Override + public List getDisplayData(World world, int x, int y, int z) { + TileCustomSpawner spawner = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCustomSpawner) ? (TileCustomSpawner) world.getTileEntity(x, y, z) : null; + List list = new ArrayList(); + if (spawner != null) { + list.add(InfoHelper.HITC() + getLocalizedName()); + if (world.isRemote && !Minecraft.getMinecraft().thePlayer.isSneaking()) { + list.add(StatCollector.translateToLocal("msg.spawnerInfo1.txt") + ": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().entityName); + list.add(StatCollector.translateToLocal("msg.spawnerInfo2.txt") + ": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().requiresPlayer); + list.add(StatCollector.translateToLocal("msg.spawnerInfo3.txt") + ": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().ignoreSpawnRequirements); + list.add(StatCollector.translateToLocal("msg.spawnerInfo4.txt") + ": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().spawnSpeed); + list.add(StatCollector.translateToLocal("msg.spawnerInfo5.txt")); + } else if (world.isRemote && Minecraft.getMinecraft().thePlayer.isSneaking()) { + list.add(StatCollector.translateToLocal("msg.spawnerInfo6.txt")); + list.add(StatCollector.translateToLocal("msg.spawnerInfo7.txt")); + list.add(StatCollector.translateToLocal("msg.spawnerInfo8.txt")); + list.add(StatCollector.translateToLocal("msg.spawnerInfo9.txt")); + } - @Override - public List getDisplayData(World world, int x, int y, int z) { - TileCustomSpawner spawner = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCustomSpawner) ? (TileCustomSpawner)world.getTileEntity(x, y, z) : null; - List list = new ArrayList(); - if (spawner != null) - { - list.add(InfoHelper.HITC()+getLocalizedName()); - if (world.isRemote && !Minecraft.getMinecraft().thePlayer.isSneaking()) - { - list.add(StatCollector.translateToLocal("msg.spawnerInfo1.txt") + ": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().entityName); - list.add(StatCollector.translateToLocal("msg.spawnerInfo2.txt") + ": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().requiresPlayer); - list.add(StatCollector.translateToLocal("msg.spawnerInfo3.txt") + ": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().ignoreSpawnRequirements); - list.add(StatCollector.translateToLocal("msg.spawnerInfo4.txt") + ": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().spawnSpeed); - list.add(StatCollector.translateToLocal("msg.spawnerInfo5.txt")); - } - else if (world.isRemote && Minecraft.getMinecraft().thePlayer.isSneaking()) - { - list.add(StatCollector.translateToLocal("msg.spawnerInfo6.txt")); - list.add(StatCollector.translateToLocal("msg.spawnerInfo7.txt")); - list.add(StatCollector.translateToLocal("msg.spawnerInfo8.txt")); - list.add(StatCollector.translateToLocal("msg.spawnerInfo9.txt")); - } - - } - return list; - } + } + return list; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconicBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconicBlock.java index 70279295..d7967d3c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconicBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconicBlock.java @@ -16,38 +16,40 @@ import net.minecraft.world.World; * Created by Brandon on 21/11/2014. */ public class DraconicBlock extends BlockDE { - IIcon top; - public DraconicBlock() { - this.setHardness(20F); - this.setResistance(1000F); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setBlockName(Strings.draconicBlockName); - this.setHarvestLevel("pickaxe", 4); - ModBlocks.register(this); - } + IIcon top; - @Override - public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + public DraconicBlock() { + this.setHardness(20F); + this.setResistance(1000F); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setBlockName(Strings.draconicBlockName); + this.setHarvestLevel("pickaxe", 4); + ModBlocks.register(this); + } + + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { return entity instanceof EntityPlayer; - } + } - @Override - public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) {} + @Override + public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) { + } - @Override - public boolean canDropFromExplosion(Explosion p_149659_1_) { - return false; - } + @Override + public boolean canDropFromExplosion(Explosion p_149659_1_) { + return false; + } - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_block"); - top = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_block_blank"); - } + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_block"); + top = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_block_blank"); + } - @Override - public IIcon getIcon(int side, int p_149691_2_) { - if (side == 0 || side == 1) return top; - else return blockIcon; - } + @Override + public IIcon getIcon(int side, int p_149691_2_) { + if (side == 0 || side == 1) return top; + else return blockIcon; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumBlock.java index d4bf9e05..10de320b 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumBlock.java @@ -26,93 +26,95 @@ import java.util.List; * Created by Brandon on 25/07/2014. */ public class DraconiumBlock extends BlockDE { - private final int DRACONIUM_META = 0; - private final int SUMMON_BLOCK_META = 1; - private final int CHARGED_DRACONIUM_META = 2; - IIcon icons[] = new IIcon[3]; - public DraconiumBlock() { - this.setHardness(10F); - this.setResistance(500F); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setBlockName(Strings.draconiumBlockName); - this.setHarvestLevel("pickaxe", 4); - ModBlocks.register(this, DraconiumItemBlock.class); - } + private final int DRACONIUM_META = 0; + private final int SUMMON_BLOCK_META = 1; + private final int CHARGED_DRACONIUM_META = 2; + IIcon icons[] = new IIcon[3]; - @Override - public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + public DraconiumBlock() { + this.setHardness(10F); + this.setResistance(500F); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setBlockName(Strings.draconiumBlockName); + this.setHarvestLevel("pickaxe", 4); + ModBlocks.register(this, DraconiumItemBlock.class); + } + + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { return entity instanceof EntityPlayer; - } + } - @Override - public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) {} + @Override + public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) { + } - @Override - public boolean canDropFromExplosion(Explosion p_149659_1_) { - return false; - } + @Override + public boolean canDropFromExplosion(Explosion p_149659_1_) { + return false; + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) { - for (int i = 0; i < 3; i++) { - icons[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconium_block_" + i); - } - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + for (int i = 0; i < 3; i++) { + icons[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconium_block_" + i); + } + } - @SideOnly(Side.CLIENT) - @Override - public IIcon getIcon(int side, int meta) { - if (meta >= icons.length) return icons[0]; - return icons[meta]; - } + @SideOnly(Side.CLIENT) + @Override + public IIcon getIcon(int side, int meta) { + if (meta >= icons.length) return icons[0]; + return icons[meta]; + } - @SuppressWarnings("unchecked") - @SideOnly(Side.CLIENT) - @Override - public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) { - list.add(new ItemStack(item, 1, 0)); - list.add(new ItemStack(item, 1, 1)); - list.add(new ItemStack(item, 1, 2)); - } + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + @Override + public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) { + list.add(new ItemStack(item, 1, 0)); + list.add(new ItemStack(item, 1, 1)); + list.add(new ItemStack(item, 1, 2)); + } - @Override - public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { - return true; - } + @Override + public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { + return true; + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - int meta = world.getBlockMetadata(x, y, z); - if (meta == 0) return false; - if (meta == 1){ - TileEnderResurrection tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnderResurrection) ? (TileEnderResurrection) world.getTileEntity(x, y, z) : null; - if (tile != null) return tile.onActivated(player); - } - return false; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0) return false; + if (meta == 1) { + TileEnderResurrection tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnderResurrection) ? (TileEnderResurrection) world.getTileEntity(x, y, z) : null; + if (tile != null) return tile.onActivated(player); + } + return false; + } - @Override - public boolean hasTileEntity(int metadata) { - if (metadata == 1) return true; - return false; - } + @Override + public boolean hasTileEntity(int metadata) { + if (metadata == 1) return true; + return false; + } - @Override - public TileEntity createTileEntity(World world, int metadata) { - if (metadata == 1) return new TileEnderResurrection(); - return null; - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + if (metadata == 1) return new TileEnderResurrection(); + return null; + } - @Override - public int damageDropped(int meta) { - return meta; - } + @Override + public int damageDropped(int meta) { + return meta; + } - @Override - public float getEnchantPowerBonus(World world, int x, int y, int z) { - if (world.getBlockMetadata(x, y, z) == 0) return 4f; - if (world.getBlockMetadata(x, y, z) == 2) return 12f; - return 0; - } + @Override + public float getEnchantPowerBonus(World world, int x, int y, int z) { + if (world.getBlockMetadata(x, y, z) == 0) return 4f; + if (world.getBlockMetadata(x, y, z) == 2) return 12f; + return 0; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumChest.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumChest.java index 6b5c3525..51535c0d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumChest.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumChest.java @@ -40,234 +40,231 @@ import static net.minecraftforge.common.util.ForgeDirection.UP; */ public class DraconiumChest extends BlockCustomDrop { - private static final String[] STORAGE_BLACKLIST = new String[] {"tile.thermalexpansion.strongbox", "item.thermalexpansion.satchel", "tile.draconicevolution:draconiumChest"}; + private static final String[] STORAGE_BLACKLIST = new String[]{"tile.thermalexpansion.strongbox", "item.thermalexpansion.satchel", "tile.draconicevolution:draconiumChest"}; - public DraconiumChest() { - super(Material.iron); - this.setBlockName(Strings.draconiumChestName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setStepSound(soundTypeStone); - setBlockBounds(0.0625F, 0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); - this.setResistance(2000.0f); + public DraconiumChest() { + super(Material.iron); + this.setBlockName(Strings.draconiumChestName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setStepSound(soundTypeStone); + setBlockBounds(0.0625F, 0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); + this.setResistance(2000.0f); - ModBlocks.register(this, DraconiumChestItemBlock.class); - } + ModBlocks.register(this, DraconiumChestItemBlock.class); + } - public static boolean isStackValid(ItemStack stack) - { - for (int i = 0; i < STORAGE_BLACKLIST.length; i++) - if (stack.getUnlocalizedName().contains(STORAGE_BLACKLIST[i])) return false; - return true; - } + public static boolean isStackValid(ItemStack stack) { + for (int i = 0; i < STORAGE_BLACKLIST.length; i++) + if (stack.getUnlocalizedName().contains(STORAGE_BLACKLIST[i])) return false; + return true; + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float cx, float cy, float cz) { - TileEntity tileEntity = world.getTileEntity(x, y, z); - if (!(tileEntity instanceof TileDraconiumChest)) return false; - TileDraconiumChest te = (TileDraconiumChest) tileEntity; + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float cx, float cy, float cz) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (!(tileEntity instanceof TileDraconiumChest)) return false; + TileDraconiumChest te = (TileDraconiumChest) tileEntity; - if (player.isSneaking()) { - te.editMode = !te.editMode; - if (world.isRemote)player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.DARK_GREEN + "" + StatCollector.translateToLocal("msg.draconiumChestEditmode.txt") + EnumChatFormatting.DARK_AQUA + " " + String.valueOf(te.editMode))); - if (te.editMode){ - if (world.isRemote)player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GOLD + "" + StatCollector.translateToLocal("msg.draconiumChestEditL1.txt"))); - if (world.isRemote)player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GOLD + "" + StatCollector.translateToLocal("msg.draconiumChestEditL2.txt"))); - if (world.isRemote)player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GOLD + "" + StatCollector.translateToLocal("msg.draconiumChestEditL3.txt"))); - if (world.isRemote)player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GOLD + "" + StatCollector.translateToLocal("msg.draconiumChestEditL4.txt"))); - } - return false; - } + if (player.isSneaking()) { + te.editMode = !te.editMode; + if (world.isRemote) + player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.DARK_GREEN + "" + StatCollector.translateToLocal("msg.draconiumChestEditmode.txt") + EnumChatFormatting.DARK_AQUA + " " + String.valueOf(te.editMode))); + if (te.editMode) { + if (world.isRemote) + player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GOLD + "" + StatCollector.translateToLocal("msg.draconiumChestEditL1.txt"))); + if (world.isRemote) + player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GOLD + "" + StatCollector.translateToLocal("msg.draconiumChestEditL2.txt"))); + if (world.isRemote) + player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GOLD + "" + StatCollector.translateToLocal("msg.draconiumChestEditL3.txt"))); + if (world.isRemote) + player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GOLD + "" + StatCollector.translateToLocal("msg.draconiumChestEditL4.txt"))); + } + return false; + } - if (te.editMode && (isDye(player.getHeldItem(), "dyeRed") || isDye(player.getHeldItem(), "dyeGreen") || isDye(player.getHeldItem(), "dyeBlue"))){ - int increment = cy > 0.5F ? 5 : -5; + if (te.editMode && (isDye(player.getHeldItem(), "dyeRed") || isDye(player.getHeldItem(), "dyeGreen") || isDye(player.getHeldItem(), "dyeBlue"))) { + int increment = cy > 0.5F ? 5 : -5; - if (isDye(player.getHeldItem(), "dyeRed")) { - te.red += increment; - if (te.red > 255) te.red = 255; - if (te.red < 0) te.red = 0; - } - if (isDye(player.getHeldItem(), "dyeGreen")) { - te.green += increment; - if (te.green > 255) te.green = 255; - if (te.green < 0) te.green = 0; - } - if (isDye(player.getHeldItem(), "dyeBlue")) { - te.blue += increment; - if (te.blue > 255) te.blue = 255; - if (te.blue < 0) te.blue = 0; - } - if (world.isRemote)player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("msg.draconiumChestRed.txt") + " " + te.red)); - if (world.isRemote)player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("msg.draconiumChestGreen.txt") + " " + te.green)); - if (world.isRemote)player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("msg.draconiumChestBlue.txt") + " " + te.blue)); - return true; - } + if (isDye(player.getHeldItem(), "dyeRed")) { + te.red += increment; + if (te.red > 255) te.red = 255; + if (te.red < 0) te.red = 0; + } + if (isDye(player.getHeldItem(), "dyeGreen")) { + te.green += increment; + if (te.green > 255) te.green = 255; + if (te.green < 0) te.green = 0; + } + if (isDye(player.getHeldItem(), "dyeBlue")) { + te.blue += increment; + if (te.blue > 255) te.blue = 255; + if (te.blue < 0) te.blue = 0; + } + if (world.isRemote) + player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("msg.draconiumChestRed.txt") + " " + te.red)); + if (world.isRemote) + player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("msg.draconiumChestGreen.txt") + " " + te.green)); + if (world.isRemote) + player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("msg.draconiumChestBlue.txt") + " " + te.blue)); + return true; + } - if (te.editMode && player.getHeldItem() != null && player.getHeldItem().getItem().equals(Items.paper)){ - if (player.getHeldItem().stackSize != 1){ - if (world.isRemote)player.addChatComponentMessage(new ChatComponentTranslation("msg.draconiumChestEdit2.txt")); - return true; - } - ItemStack paper = player.getHeldItem(); - NBTTagCompound nbt = paper.getTagCompound(); - if (nbt == null) nbt = new NBTTagCompound(); - if (nbt.hasKey("Is Draconic Chest Saved Colour")){ - te.red = nbt.getInteger("R"); - te.green = nbt.getInteger("G"); - te.blue = nbt.getInteger("B"); - }else{ - NBTTagList lore = new NBTTagList(); - lore.appendTag(new NBTTagString("Red: "+te.red)); - lore.appendTag(new NBTTagString("Green: "+te.green)); - lore.appendTag(new NBTTagString("Blue: "+te.blue)); + if (te.editMode && player.getHeldItem() != null && player.getHeldItem().getItem().equals(Items.paper)) { + if (player.getHeldItem().stackSize != 1) { + if (world.isRemote) + player.addChatComponentMessage(new ChatComponentTranslation("msg.draconiumChestEdit2.txt")); + return true; + } + ItemStack paper = player.getHeldItem(); + NBTTagCompound nbt = paper.getTagCompound(); + if (nbt == null) nbt = new NBTTagCompound(); + if (nbt.hasKey("Is Draconic Chest Saved Colour")) { + te.red = nbt.getInteger("R"); + te.green = nbt.getInteger("G"); + te.blue = nbt.getInteger("B"); + } else { + NBTTagList lore = new NBTTagList(); + lore.appendTag(new NBTTagString("Red: " + te.red)); + lore.appendTag(new NBTTagString("Green: " + te.green)); + lore.appendTag(new NBTTagString("Blue: " + te.blue)); - NBTTagCompound display = new NBTTagCompound(); - display.setTag("Lore", lore); - display.setString("Name", "Draconic Chest Saved Colour"); + NBTTagCompound display = new NBTTagCompound(); + display.setTag("Lore", lore); + display.setString("Name", "Draconic Chest Saved Colour"); - nbt.setTag("display", display); - nbt.setInteger("R", te.red); - nbt.setInteger("G", te.green); - nbt.setInteger("B", te.blue); - nbt.setBoolean("Is Draconic Chest Saved Colour", true); - paper.setTagCompound(nbt); - } - return true; - } + nbt.setTag("display", display); + nbt.setInteger("R", te.red); + nbt.setInteger("G", te.green); + nbt.setInteger("B", te.blue); + nbt.setBoolean("Is Draconic Chest Saved Colour", true); + paper.setTagCompound(nbt); + } + return true; + } - if (!world.isRemote) FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_DRACONIC_CHEST, world, x, y, z); - return true; - } + if (!world.isRemote) + FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_DRACONIC_CHEST, world, x, y, z); + return true; + } - public boolean isDye(ItemStack stack, String oreName){ - if (stack == null) return false; - ArrayList items = OreDictionary.getOres(oreName); - for (ItemStack ore : items){ - if (ore.getItem().equals(stack.getItem()) && stack.getItemDamage() == ore.getItemDamage()) return true; - } - return false; - } + public boolean isDye(ItemStack stack, String oreName) { + if (stack == null) return false; + ArrayList items = OreDictionary.getOres(oreName); + for (ItemStack ore : items) { + if (ore.getItem().equals(stack.getItem()) && stack.getItemDamage() == ore.getItemDamage()) return true; + } + return false; + } - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int meta) { - super.breakBlock(world, x, y, z, block, meta); - } + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + super.breakBlock(world, x, y, z, block, meta); + } - @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { - return new TileDraconiumChest(); - } + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + return new TileDraconiumChest(); + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public int getRenderType() { - return -1; - } + @Override + public int getRenderType() { + return -1; + } - @Override - public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack itemStack) - { - byte chestFacing = 0; - int facing = MathHelper.floor_double((double) ((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3; - if (facing == 0) - { - chestFacing = 2; - } - if (facing == 1) - { - chestFacing = 5; - } - if (facing == 2) - { - chestFacing = 3; - } - if (facing == 3) - { - chestFacing = 4; - } - TileEntity te = world.getTileEntity(i, j, k); - if (te != null && te instanceof TileDraconiumChest) - { - TileDraconiumChest tedc = (TileDraconiumChest) te; - tedc.setFacing(chestFacing); - if (itemStack.hasDisplayName()) tedc.setCustomName(itemStack.getDisplayName()); - world.markBlockForUpdate(i, j, k); - } - } + @Override + public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack itemStack) { + byte chestFacing = 0; + int facing = MathHelper.floor_double((double) ((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3; + if (facing == 0) { + chestFacing = 2; + } + if (facing == 1) { + chestFacing = 5; + } + if (facing == 2) { + chestFacing = 3; + } + if (facing == 3) { + chestFacing = 4; + } + TileEntity te = world.getTileEntity(i, j, k); + if (te != null && te instanceof TileDraconiumChest) { + TileDraconiumChest tedc = (TileDraconiumChest) te; + tedc.setFacing(chestFacing); + if (itemStack.hasDisplayName()) tedc.setCustomName(itemStack.getDisplayName()); + world.markBlockForUpdate(i, j, k); + } + } - @Override - public boolean hasComparatorInputOverride() { - return true; - } + @Override + public boolean hasComparatorInputOverride() { + return true; + } - @Override - public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) - { - TileEntity te = par1World.getTileEntity(par2, par3, par4); - if (te instanceof IInventory) - { - return Container.calcRedstoneFromInventory((IInventory) te); - } - return 0; - } + @Override + public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { + TileEntity te = par1World.getTileEntity(par2, par3, par4); + if (te instanceof IInventory) { + return Container.calcRedstoneFromInventory((IInventory) te); + } + return 0; + } - @Override - public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) - { - if (worldObj.isRemote) - { - return false; - } - if (axis == UP || axis == DOWN) - { - TileEntity tileEntity = worldObj.getTileEntity(x, y, z); - if (tileEntity instanceof TileDraconiumChest) { - TileDraconiumChest te = (TileDraconiumChest) tileEntity; - te.rotateAround(axis); - } - return true; - } - return false; - } + @Override + public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { + if (worldObj.isRemote) { + return false; + } + if (axis == UP || axis == DOWN) { + TileEntity tileEntity = worldObj.getTileEntity(x, y, z); + if (tileEntity instanceof TileDraconiumChest) { + TileDraconiumChest te = (TileDraconiumChest) tileEntity; + te.rotateAround(axis); + } + return true; + } + return false; + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { - blockIcon = par1IconRegister.registerIcon(References.RESOURCESPREFIX + "draconiumChest"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + blockIcon = par1IconRegister.registerIcon(References.RESOURCESPREFIX + "draconiumChest"); + } - @Override - protected boolean dropInventory() { - return false; - } + @Override + protected boolean dropInventory() { + return false; + } - @Override - protected boolean hasCustomDropps() { - return true; - } + @Override + protected boolean hasCustomDropps() { + return true; + } - @Override - protected void getCustomTileEntityDrops(TileEntity te, List droppes) { - ItemStack stack = new ItemStack(ModBlocks.draconiumChest); - if (te instanceof ICustomItemData){ - ICustomItemData chest = (ICustomItemData)te; - NBTTagCompound tileTag = new NBTTagCompound(); - if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound()); - chest.writeDataToItem(tileTag, stack); - stack.getTagCompound().setTag(ICustomItemData.tagName, tileTag); - } - droppes.add(stack); - } + @Override + protected void getCustomTileEntityDrops(TileEntity te, List droppes) { + ItemStack stack = new ItemStack(ModBlocks.draconiumChest); + if (te instanceof ICustomItemData) { + ICustomItemData chest = (ICustomItemData) te; + NBTTagCompound tileTag = new NBTTagCompound(); + if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound()); + chest.writeDataToItem(tileTag, stack); + stack.getTagCompound().setTag(ICustomItemData.tagName, tileTag); + } + droppes.add(stack); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumOre.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumOre.java index ccd0a5d0..e5c62e7a 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumOre.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumOre.java @@ -20,20 +20,20 @@ import net.minecraft.world.World; import java.util.Random; public class DraconiumOre extends BlockDE { - public IIcon icon; - public IIcon iconEnd; - public IIcon iconNether; + public IIcon icon; + public IIcon iconEnd; + public IIcon iconNether; - public DraconiumOre() { - super(Material.rock); - this.setBlockName(Strings.draconiumOreName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setHardness(10f); - this.setResistance(20.0f); + public DraconiumOre() { + super(Material.rock); + this.setBlockName(Strings.draconiumOreName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setHardness(10f); + this.setResistance(20.0f); - this.setHarvestLevel("pickaxe", 3); - ModBlocks.register(this); - } + this.setHarvestLevel("pickaxe", 3); + ModBlocks.register(this); + } @Override public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { @@ -41,51 +41,42 @@ public class DraconiumOre extends BlockDE { } @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) - { - icon = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/draconium_ore"); - iconEnd = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/draconium_ore_end"); - iconNether = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/draconium_ore_nether"); - } + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + icon = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/draconium_ore"); + iconEnd = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/draconium_ore_end"); + iconNether = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/draconium_ore_nether"); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - World world = Minecraft.getMinecraft().theWorld; - int dim = world != null && world.provider != null ? world.provider.dimensionId : 0; + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + World world = Minecraft.getMinecraft().theWorld; + int dim = world != null && world.provider != null ? world.provider.dimensionId : 0; - if (dim == -1) - return iconNether; - else if (dim == 1) - return iconEnd; - else - return icon; - } + if (dim == -1) return iconNether; + else if (dim == 1) return iconEnd; + else return icon; + } - @Override - public int quantityDropped(Random random) - { - return 1 + random.nextInt(2); - } + @Override + public int quantityDropped(Random random) { + return 1 + random.nextInt(2); + } - @Override - public int quantityDroppedWithBonus(int fortune, Random random) - { - return fortune == 0 ? this.quantityDropped(random) : this.quantityDropped(random) + fortune + random.nextInt(fortune * 2); - } + @Override + public int quantityDroppedWithBonus(int fortune, Random random) { + return fortune == 0 ? this.quantityDropped(random) : this.quantityDropped(random) + fortune + random.nextInt(fortune * 2); + } - @Override - protected boolean canSilkHarvest() - { - return true; - } + @Override + protected boolean canSilkHarvest() { + return true; + } - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) - { - return ModItems.draconiumDust; - } + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return ModItems.draconiumDust; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/InfusedObsidian.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/InfusedObsidian.java index 97a202fe..8e768765 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/InfusedObsidian.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/InfusedObsidian.java @@ -25,53 +25,54 @@ import java.util.List; */ public class InfusedObsidian extends BlockDE { - public InfusedObsidian(){ - super(Material.rock); - this.setHardness(100.0F); - this.setResistance(4000.0F); - this.setBlockName("infusedObsidian"); - this.setHarvestLevel("pickaxe", 4); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); + public InfusedObsidian() { + super(Material.rock); + this.setHardness(100.0F); + this.setResistance(4000.0F); + this.setBlockName("infusedObsidian"); + this.setHarvestLevel("pickaxe", 4); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModBlocks.register(this, InfusedObsidianItemBlock.class); - } + ModBlocks.register(this, InfusedObsidianItemBlock.class); + } - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/infusedObsidian"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/infusedObsidian"); + } - @Override - public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { - return entity instanceof EntityPlayer; - } + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + return entity instanceof EntityPlayer; + } - @Override - public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) {} + @Override + public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) { + } - @Override - public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) { - return super.getExplosionResistance(par1Entity, world, x, y, z, explosionX, explosionY, explosionZ); - } + @Override + public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) { + return super.getExplosionResistance(par1Entity, world, x, y, z, explosionX, explosionY, explosionZ); + } - @Override - public boolean canDropFromExplosion(Explosion p_149659_1_) { - return false; - } + @Override + public boolean canDropFromExplosion(Explosion p_149659_1_) { + return false; + } - public static class InfusedObsidianItemBlock extends ItemBlock { + public static class InfusedObsidianItemBlock extends ItemBlock { - public InfusedObsidianItemBlock(Block p_i45328_1_) { - super(p_i45328_1_); - } + public InfusedObsidianItemBlock(Block p_i45328_1_) { + super(p_i45328_1_); + } - @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - @Override - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { - list.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("info.infusedObsidian.txt")); - super.addInformation(p_77624_1_, p_77624_2_, list, p_77624_4_); - } - } + @SideOnly(Side.CLIENT) + @SuppressWarnings("unchecked") + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { + list.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("info.infusedObsidian.txt")); + super.addInformation(p_77624_1_, p_77624_2_, list, p_77624_4_); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/ParticleGenerator.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/ParticleGenerator.java index f4dff291..3c8f76d4 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/ParticleGenerator.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/ParticleGenerator.java @@ -24,205 +24,186 @@ import net.minecraft.world.World; import java.util.Random; -public class ParticleGenerator extends BlockDE -{ - public static Block instance; +public class ParticleGenerator extends BlockDE { + public static Block instance; - public ParticleGenerator() { - this.setBlockName(Strings.particleGeneratorName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setStepSound(soundTypeStone); - this.setLightOpacity(0); - ModBlocks.register(this); - } + public ParticleGenerator() { + this.setBlockName(Strings.particleGeneratorName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setStepSound(soundTypeStone); + this.setLightOpacity(0); + ModBlocks.register(this); + } - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister iconRegister) - { - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float p_149727_7_, float p_149727_8_, float p_149727_9_) - { - if (world.getBlockMetadata(x, y, z) == 1) return false; + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + if (world.getBlockMetadata(x, y, z) == 1) return false; - if (player.getHeldItem() != null && player.getHeldItem().getItem() == Items.paper) - { - TileEntity tile = world.getTileEntity(x, y, z); - TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator) tile : null; - ItemStack stack = player.getHeldItem(); - if (gen != null && stack.hasTagCompound() && stack.getTagCompound().hasKey("particles_enabled")) - { - gen.setBlockNBT(stack.getTagCompound()); - return true; - } - } + if (player.getHeldItem() != null && player.getHeldItem().getItem() == Items.paper) { + TileEntity tile = world.getTileEntity(x, y, z); + TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator) tile : null; + ItemStack stack = player.getHeldItem(); + if (gen != null && stack.hasTagCompound() && stack.getTagCompound().hasKey("particles_enabled")) { + gen.setBlockNBT(stack.getTagCompound()); + return true; + } + } - if (player.isSneaking()) - { - if (activateEnergyStorageCore(world, x, y, z, player)) return true; - TileEntity tile = world.getTileEntity(x, y, z); - TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator) tile : null; - if (gen != null) - { - gen.toggleInverted(); - } - } else - FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_PARTICLEGEN, world, x, y, z); - return true; - } + if (player.isSneaking()) { + if (activateEnergyStorageCore(world, x, y, z, player)) return true; + TileEntity tile = world.getTileEntity(x, y, z); + TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator) tile : null; + if (gen != null) { + gen.toggleInverted(); + } + } else + FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_PARTICLEGEN, world, x, y, z); + return true; + } - @SideOnly(Side.CLIENT) - @Override - public int getRenderType() - { - return -1; - } + @SideOnly(Side.CLIENT) + @Override + public int getRenderType() { + return -1; + } - @Override - public void onNeighborBlockChange(final World world, final int x, final int y, final int z, final Block block) - { - TileEntity tile = world.getTileEntity(x, y, z); - TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator) tile : null; - if (gen != null) - { - gen.signal = world.isBlockIndirectlyGettingPowered(x, y, z); - world.markBlockForUpdate(x, y, z); - } - } + @Override + public void onNeighborBlockChange(final World world, final int x, final int y, final int z, final Block block) { + TileEntity tile = world.getTileEntity(x, y, z); + TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator) tile : null; + if (gen != null) { + gen.signal = world.isBlockIndirectlyGettingPowered(x, y, z); + world.markBlockForUpdate(x, y, z); + } + } - @Override - public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) - { - return true; - } + @Override + public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { + return true; + } - @SideOnly(Side.CLIENT) - @Override - public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta) - { - if (world.isRemote) - { - Random rand = world.rand; - float modifier = 0.1F; - float SCALE = 1; - double spawnX = x + 0.5D; - double spawnY = y + 0.5D; - double spawnZ = z + 0.5D; + @SideOnly(Side.CLIENT) + @Override + public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta) { + if (world.isRemote) { + Random rand = world.rand; + float modifier = 0.1F; + float SCALE = 1; + double spawnX = x + 0.5D; + double spawnY = y + 0.5D; + double spawnZ = z + 0.5D; - for (int i = 0; i < 100; i++) - { - float MX = modifier - ((2f*modifier) * rand.nextFloat()); - float MY = modifier - ((2f*modifier) * rand.nextFloat()); - float MZ = modifier - ((2f*modifier) * rand.nextFloat()); + for (int i = 0; i < 100; i++) { + float MX = modifier - ((2f * modifier) * rand.nextFloat()); + float MY = modifier - ((2f * modifier) * rand.nextFloat()); + float MZ = modifier - ((2f * modifier) * rand.nextFloat()); - - { - ParticleCustom particle = new ParticleCustom(world, spawnX, spawnY, spawnZ, MX, MY, MZ, SCALE, false, 1); - particle.red = rand.nextInt(255); - particle.green = rand.nextInt(255); - particle.blue = rand.nextInt(255); - particle.maxAge = rand.nextInt(10); - particle.fadeTime = 20; - particle.fadeLength = 20; - particle.gravity = 0F; - ParticleHandler.spawnCustomParticle(particle); - } - } - } - } + { + ParticleCustom particle = new ParticleCustom(world, spawnX, spawnY, spawnZ, MX, MY, MZ, SCALE, false, 1); + particle.red = rand.nextInt(255); + particle.green = rand.nextInt(255); + particle.blue = rand.nextInt(255); + particle.maxAge = rand.nextInt(10); + particle.fadeTime = 20; + particle.fadeLength = 20; + particle.gravity = 0F; - @Override - public boolean renderAsNormalBlock() - { - return false; - } + ParticleHandler.spawnCustomParticle(particle); + } + } + } + } - @Override - public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) - { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean isOpaqueCube() - { - return false; - } + @Override + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { + return false; + } - @Override - public boolean hasTileEntity(int meta) - { - return true; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public TileEntity createTileEntity(World world, int metadata) - { - return new TileParticleGenerator(); - } + @Override + public boolean hasTileEntity(int meta) { + return true; + } - private boolean activateEnergyStorageCore(World world, int x, int y, int z, EntityPlayer player){ - for (int x1 = x - 11; x1 <= x + 11; x1++){ - if (world.getBlock(x1, y, z) == ModBlocks.energyStorageCore) { - TileEnergyStorageCore tile = (world.getTileEntity(x1, y, z) != null && world.getTileEntity(x1, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x1, y, z) : null; - if (tile != null && !tile.isOnline()) - { - if (player.capabilities.isCreativeMode) { - if (!tile.creativeActivate()) { - if (world.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.energyStorageCoreUTA.txt")); - return false; - } - }else { - if (!tile.tryActivate()) { - if (world.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.energyStorageCoreUTA.txt")); - return false; - } - } - return true; - } - } - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileParticleGenerator(); + } - for (int z1 = z - 11; z1 <= z + 11; z1++){ - if (world.getBlock(x, y, z1) == ModBlocks.energyStorageCore) { - TileEnergyStorageCore tile = (world.getTileEntity(x, y, z1) != null && world.getTileEntity(x, y, z1) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z1) : null; - if (tile != null && !tile.isOnline()) - { - if (player.capabilities.isCreativeMode) { - if (!tile.creativeActivate()) { - if (world.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.energyStorageCoreUTA.txt")); - return false; - } - }else { - if (!tile.tryActivate()) { - if (world.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.energyStorageCoreUTA.txt")); - return false; - } - } - return true; - } - } - } - return false; - } + private boolean activateEnergyStorageCore(World world, int x, int y, int z, EntityPlayer player) { + for (int x1 = x - 11; x1 <= x + 11; x1++) { + if (world.getBlock(x1, y, z) == ModBlocks.energyStorageCore) { + TileEnergyStorageCore tile = (world.getTileEntity(x1, y, z) != null && world.getTileEntity(x1, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x1, y, z) : null; + if (tile != null && !tile.isOnline()) { + if (player.capabilities.isCreativeMode) { + if (!tile.creativeActivate()) { + if (world.isRemote) + player.addChatComponentMessage(new ChatComponentTranslation("msg.energyStorageCoreUTA.txt")); + return false; + } + } else { + if (!tile.tryActivate()) { + if (world.isRemote) + player.addChatComponentMessage(new ChatComponentTranslation("msg.energyStorageCoreUTA.txt")); + return false; + } + } + return true; + } + } + } - @Override - public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int meta) { - if (meta == 1) - { - TileEntity tile = world.getTileEntity(x, y, z); - TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator) tile : null; - if (gen != null && gen.getMaster() != null) - { - world.setBlockMetadataWithNotify(x, y, z, 0, 2); - //LogHelper.info("deActivate"); - gen.getMaster().isStructureStillValid(true); - } - } - super.breakBlock(world, x, y, z, p_149749_5_, meta); - } + for (int z1 = z - 11; z1 <= z + 11; z1++) { + if (world.getBlock(x, y, z1) == ModBlocks.energyStorageCore) { + TileEnergyStorageCore tile = (world.getTileEntity(x, y, z1) != null && world.getTileEntity(x, y, z1) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z1) : null; + if (tile != null && !tile.isOnline()) { + if (player.capabilities.isCreativeMode) { + if (!tile.creativeActivate()) { + if (world.isRemote) + player.addChatComponentMessage(new ChatComponentTranslation("msg.energyStorageCoreUTA.txt")); + return false; + } + } else { + if (!tile.tryActivate()) { + if (world.isRemote) + player.addChatComponentMessage(new ChatComponentTranslation("msg.energyStorageCoreUTA.txt")); + return false; + } + } + return true; + } + } + } + return false; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int meta) { + if (meta == 1) { + TileEntity tile = world.getTileEntity(x, y, z); + TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator) tile : null; + if (gen != null && gen.getMaster() != null) { + world.setBlockMetadataWithNotify(x, y, z, 0, 2); + //LogHelper.info("deActivate"); + gen.getMaster().isStructureStillValid(true); + } + } + super.breakBlock(world, x, y, z, p_149749_5_, meta); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/PlacedItem.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/PlacedItem.java index 0fce2e71..e1e8becb 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/PlacedItem.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/PlacedItem.java @@ -23,193 +23,193 @@ import java.util.Random; * Created by Brandon on 13/08/2014. */ public class PlacedItem extends BlockDE { - public PlacedItem() { - super(Material.circuits); - this.setHardness(5F); - this.setResistance(20F); - this.setBlockName(Strings.placedItemName); - ModBlocks.register(this); - } + public PlacedItem() { + super(Material.circuits); + this.setHardness(5F); + this.setResistance(20F); + this.setBlockName(Strings.placedItemName); + ModBlocks.register(this); + } - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon("glass"); - } + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon("glass"); + } - @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { - switch (world.getBlockMetadata(x, y, z)){ - case 0: - setBlockBounds(0.0F, 0.8F, 0.0F, 1.0F, 1.0F, 1.0F); - break; - case 1: - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.2F, 1.0F); - break; - case 2: - setBlockBounds(0.0F, 0.0F, 0.8F, 1.0F, 1.0F, 1.0F); - break; - case 3: - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.2F); - break; - case 4: - setBlockBounds(0.8F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - break; - case 5: - setBlockBounds(0.0F, 0.0F, 0.0F, 0.2F, 1.0F, 1.0F); - break; - default: - super.setBlockBoundsBasedOnState(world, x, y, z); - } - } + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + switch (world.getBlockMetadata(x, y, z)) { + case 0: + setBlockBounds(0.0F, 0.8F, 0.0F, 1.0F, 1.0F, 1.0F); + break; + case 1: + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.2F, 1.0F); + break; + case 2: + setBlockBounds(0.0F, 0.0F, 0.8F, 1.0F, 1.0F, 1.0F); + break; + case 3: + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.2F); + break; + case 4: + setBlockBounds(0.8F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + break; + case 5: + setBlockBounds(0.0F, 0.0F, 0.0F, 0.2F, 1.0F, 1.0F); + break; + default: + super.setBlockBoundsBasedOnState(world, x, y, z); + } + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { - TilePlacedItem tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TilePlacedItem) ? (TilePlacedItem) world.getTileEntity(x, y, z) : null; - int meta = world.getBlockMetadata(x, y, z); - if (tile != null && tile.getStack() != null) { - if (tile.getStack().getItem() instanceof ItemBlock){ - switch (meta){ - case 0: - return AxisAlignedBB.getBoundingBox(x+0.25D, y+0.5D, z+0.25D, x+0.75D, y+1D, z+0.75D); - case 1: - return AxisAlignedBB.getBoundingBox(x+0.25D, y+0D, z+0.25D, x+0.75D, y+0.5D, z+0.75D); - case 2: - return AxisAlignedBB.getBoundingBox(x+0.25D, y+0.25D, z+0.5D, x+0.75D, y+0.75D, z+1D); - case 3: - return AxisAlignedBB.getBoundingBox(x+0.25D, y+0.25D, z+0D, x+0.75D, y+0.75D, z+0.5D); - case 4: - return AxisAlignedBB.getBoundingBox(x+0.5D, y+0.25D, z+0.25D, x+1D, y+0.75D, z+0.75D); - case 5: - return AxisAlignedBB.getBoundingBox(x+0D, y+0.25D, z+0.25D, x+0.5D, y+0.75D, z+0.75D); - } - } - else { - switch (meta){ - case 0: - return AxisAlignedBB.getBoundingBox(x+0.25D, y+0.9D, z+0.25D, x+0.75D, y+1D, z+0.75D); - case 1: - return AxisAlignedBB.getBoundingBox(x+0.25D, y+0D, z+0.25D, x+0.75D, y+0.1D, z+0.75D); - case 2: - return AxisAlignedBB.getBoundingBox(x+0.25D, y+0.25D, z+0.9D, x+0.75D, y+0.75D, z+1D); - case 3: - return AxisAlignedBB.getBoundingBox(x+0.25D, y+0.25D, z+0D, x+0.75D, y+0.75D, z+0.1D); - case 4: - return AxisAlignedBB.getBoundingBox(x+0.9D, y+0.25D, z+0.25D, x+1D, y+0.75D, z+0.75D); - case 5: - return AxisAlignedBB.getBoundingBox(x+0D, y+0.25D, z+0.25D, x+0.1D, y+0.75D, z+0.75D); - } - } - } - return super.getCollisionBoundingBoxFromPool(world, x, y, z); - } + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + TilePlacedItem tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TilePlacedItem) ? (TilePlacedItem) world.getTileEntity(x, y, z) : null; + int meta = world.getBlockMetadata(x, y, z); + if (tile != null && tile.getStack() != null) { + if (tile.getStack().getItem() instanceof ItemBlock) { + switch (meta) { + case 0: + return AxisAlignedBB.getBoundingBox(x + 0.25D, y + 0.5D, z + 0.25D, x + 0.75D, y + 1D, z + 0.75D); + case 1: + return AxisAlignedBB.getBoundingBox(x + 0.25D, y + 0D, z + 0.25D, x + 0.75D, y + 0.5D, z + 0.75D); + case 2: + return AxisAlignedBB.getBoundingBox(x + 0.25D, y + 0.25D, z + 0.5D, x + 0.75D, y + 0.75D, z + 1D); + case 3: + return AxisAlignedBB.getBoundingBox(x + 0.25D, y + 0.25D, z + 0D, x + 0.75D, y + 0.75D, z + 0.5D); + case 4: + return AxisAlignedBB.getBoundingBox(x + 0.5D, y + 0.25D, z + 0.25D, x + 1D, y + 0.75D, z + 0.75D); + case 5: + return AxisAlignedBB.getBoundingBox(x + 0D, y + 0.25D, z + 0.25D, x + 0.5D, y + 0.75D, z + 0.75D); + } + } else { + switch (meta) { + case 0: + return AxisAlignedBB.getBoundingBox(x + 0.25D, y + 0.9D, z + 0.25D, x + 0.75D, y + 1D, z + 0.75D); + case 1: + return AxisAlignedBB.getBoundingBox(x + 0.25D, y + 0D, z + 0.25D, x + 0.75D, y + 0.1D, z + 0.75D); + case 2: + return AxisAlignedBB.getBoundingBox(x + 0.25D, y + 0.25D, z + 0.9D, x + 0.75D, y + 0.75D, z + 1D); + case 3: + return AxisAlignedBB.getBoundingBox(x + 0.25D, y + 0.25D, z + 0D, x + 0.75D, y + 0.75D, z + 0.1D); + case 4: + return AxisAlignedBB.getBoundingBox(x + 0.9D, y + 0.25D, z + 0.25D, x + 1D, y + 0.75D, z + 0.75D); + case 5: + return AxisAlignedBB.getBoundingBox(x + 0D, y + 0.25D, z + 0.25D, x + 0.1D, y + 0.75D, z + 0.75D); + } + } + } + return super.getCollisionBoundingBoxFromPool(world, x, y, z); + } - @Override - public int getRenderType() { - return -1; - } + @Override + public int getRenderType() { + return -1; + } - @Override - public boolean hasTileEntity(int metadata) { - return true; - } + @Override + public boolean hasTileEntity(int metadata) { + return true; + } - @Override - public TileEntity createTileEntity(World world, int metadata) { - return new TilePlacedItem(); - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TilePlacedItem(); + } - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int meta) { - TileEntity te = world.getTileEntity(x, y, z); - if (te != null && te instanceof TilePlacedItem && ((TilePlacedItem)te).getStack() != null) { - TilePlacedItem tile = (TilePlacedItem) te; + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + TileEntity te = world.getTileEntity(x, y, z); + if (te != null && te instanceof TilePlacedItem && ((TilePlacedItem) te).getStack() != null) { + TilePlacedItem tile = (TilePlacedItem) te; - float spawnX = x + world.rand.nextFloat(); - float spawnY = y + world.rand.nextFloat(); - float spawnZ = z + world.rand.nextFloat(); + float spawnX = x + world.rand.nextFloat(); + float spawnY = y + world.rand.nextFloat(); + float spawnZ = z + world.rand.nextFloat(); - EntityItem droppedItem = new EntityItem(world, spawnX, spawnY, spawnZ, tile.getStack()); - tile.setStack(null); + EntityItem droppedItem = new EntityItem(world, spawnX, spawnY, spawnZ, tile.getStack()); + tile.setStack(null); - float multiplier = 0.05F; + float multiplier = 0.05F; - droppedItem.motionX = (-0.5F + world.rand.nextFloat()) * multiplier; - droppedItem.motionY = (4 + world.rand.nextFloat()) * multiplier; - droppedItem.motionZ = (-0.5F + world.rand.nextFloat()) * multiplier; + droppedItem.motionX = (-0.5F + world.rand.nextFloat()) * multiplier; + droppedItem.motionY = (4 + world.rand.nextFloat()) * multiplier; + droppedItem.motionZ = (-0.5F + world.rand.nextFloat()) * multiplier; - world.spawnEntityInWorld(droppedItem); - } - super.breakBlock(world, x, y, z, block, meta); - } + world.spawnEntityInWorld(droppedItem); + } + super.breakBlock(world, x, y, z, block, meta); + } - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return null; - } + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return null; + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - if (player.isSneaking()){ - TilePlacedItem tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TilePlacedItem) ? (TilePlacedItem) world.getTileEntity(x, y, z) : null; - if (tile == null) { - world.setBlockToAir(x, y, z); - } - tile.rotation += 5.625F; - }else { - if (!world.isRemote) breakBlock(world, x, y, z, this, world.getBlockMetadata(x, y, z)); - world.setBlockToAir(x, y, z); - } - world.markBlockForUpdate(x, y, z); - return true; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + if (player.isSneaking()) { + TilePlacedItem tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TilePlacedItem) ? (TilePlacedItem) world.getTileEntity(x, y, z) : null; + if (tile == null) { + world.setBlockToAir(x, y, z); + } + tile.rotation += 5.625F; + } else { + if (!world.isRemote) breakBlock(world, x, y, z, this, world.getBlockMetadata(x, y, z)); + world.setBlockToAir(x, y, z); + } + world.markBlockForUpdate(x, y, z); + return true; + } - @Override - public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) { - if (player.isSneaking()){ - TilePlacedItem tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TilePlacedItem) ? (TilePlacedItem) world.getTileEntity(x, y, z) : null; - if (tile == null) { - world.setBlockToAir(x, y, z); - } - tile.rotation += 22.5F; - }else { - TilePlacedItem tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TilePlacedItem) ? (TilePlacedItem) world.getTileEntity(x, y, z) : null; - if (tile == null) { - world.setBlockToAir(x, y, z); - } - tile.rotation -= 22.5F; - } - world.markBlockForUpdate(x, y, z); - } + @Override + public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) { + if (player.isSneaking()) { + TilePlacedItem tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TilePlacedItem) ? (TilePlacedItem) world.getTileEntity(x, y, z) : null; + if (tile == null) { + world.setBlockToAir(x, y, z); + } + tile.rotation += 22.5F; + } else { + TilePlacedItem tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TilePlacedItem) ? (TilePlacedItem) world.getTileEntity(x, y, z) : null; + if (tile == null) { + world.setBlockToAir(x, y, z); + } + tile.rotation -= 22.5F; + } + world.markBlockForUpdate(x, y, z); + } - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) { - TileEntity te = world.getTileEntity(x, y, z); - if (te != null && te instanceof TilePlacedItem && ((TilePlacedItem)te).getStack() != null) { - TilePlacedItem tile = (TilePlacedItem) te; - if (tile.getStack() != null && tile.getStack().getItem() instanceof ItemBlock) return Block.getBlockFromItem(tile.getStack().getItem()).getLightValue(); - } - return 0; - } + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + TileEntity te = world.getTileEntity(x, y, z); + if (te != null && te instanceof TilePlacedItem && ((TilePlacedItem) te).getStack() != null) { + TilePlacedItem tile = (TilePlacedItem) te; + if (tile.getStack() != null && tile.getStack().getItem() instanceof ItemBlock) + return Block.getBlockFromItem(tile.getStack().getItem()).getLightValue(); + } + return 0; + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - TileEntity te = world.getTileEntity(x, y, z); - if (te != null && te instanceof TilePlacedItem && ((TilePlacedItem)te).getStack() != null) { - TilePlacedItem tile = (TilePlacedItem) te; - return tile.getStack(); - } - return null; - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + TileEntity te = world.getTileEntity(x, y, z); + if (te != null && te instanceof TilePlacedItem && ((TilePlacedItem) te).getStack() != null) { + TilePlacedItem tile = (TilePlacedItem) te; + return tile.getStack(); + } + return null; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/Potentiometer.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/Potentiometer.java index 7270a5ad..d5dd6c6c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/Potentiometer.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/Potentiometer.java @@ -21,332 +21,255 @@ import net.minecraftforge.common.util.ForgeDirection; import static net.minecraftforge.common.util.ForgeDirection.*; -public class Potentiometer extends BlockDE -{ - IIcon icons[] = new IIcon[16]; +public class Potentiometer extends BlockDE { + IIcon icons[] = new IIcon[16]; - public Potentiometer() { - super(Material.circuits); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setHardness(0.3f); - this.setResistance(0.1f); - this.setLightLevel(0.3F); - this.setBlockName(Strings.potentiometerName); - ModBlocks.register(this); - } + public Potentiometer() { + super(Material.circuits); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setHardness(0.3f); + this.setResistance(0.1f); + this.setLightLevel(0.3F); + this.setBlockName(Strings.potentiometerName); + ModBlocks.register(this); + } - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) - { + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { return null; } - - @Override - public boolean hasTileEntity(int metadata) - { - return true; - } - @Override - public TileEntity createTileEntity(World world, int metadata) - { - return new TilePotentiometer(); - } + @Override + public boolean hasTileEntity(int metadata) { + return true; + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iconRegister) - { - for (int i = 0; i < 16; i++) - { - icons[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "potentiometer/potentiometer_" + i); - } - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TilePotentiometer(); + } - @Override - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int meta) - { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null && tile instanceof TilePotentiometer) - return icons[((TilePotentiometer)tile).power]; - else return null; - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iconRegister) { + for (int i = 0; i < 16; i++) { + icons[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "potentiometer/potentiometer_" + i); + } + } - @Override - public IIcon getIcon(int side, int meta) - { - return icons[0]; - } - - @Override - public boolean canPlaceBlockAt(World world, int x, int y, int z) - { - return (world.isSideSolid(x, y + 1, z, UP)) || (world.isSideSolid(x, y - 1, z, DOWN)) || (world.isSideSolid(x - 1, y, z, EAST)) || (world.isSideSolid(x + 1, y, z, WEST)) || (world.isSideSolid(x, y, z - 1, SOUTH)) || (world.isSideSolid(x, y, z + 1, NORTH)); - } + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int meta) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null && tile instanceof TilePotentiometer) return icons[((TilePotentiometer) tile).power]; + else return null; + } - @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) - { - int l = world.getBlockMetadata(x, y, z); - this.setBounds(l); - } + @Override + public IIcon getIcon(int side, int meta) { + return icons[0]; + } - private void setBounds(int meta) - { - int j = meta; - float f = 0.206F; - float f1 = 0.796F; - float f2 = 0.296F; - float f3 = 0.125F; + @Override + public boolean canPlaceBlockAt(World world, int x, int y, int z) { + return (world.isSideSolid(x, y + 1, z, UP)) || (world.isSideSolid(x, y - 1, z, DOWN)) || (world.isSideSolid(x - 1, y, z, EAST)) || (world.isSideSolid(x + 1, y, z, WEST)) || (world.isSideSolid(x, y, z - 1, SOUTH)) || (world.isSideSolid(x, y, z + 1, NORTH)); + } - if (j == 6) - { - this.setBlockBounds(0.5F - f2, 0.0F, 0.5F - f2, 0.5F + f2, f3, 0.5F + f2); - } - if (j == 1) - { - this.setBlockBounds(0.0F, f, 0.5F - f2, f3, f1, 0.5F + f2); - } else if (j == 2) - { - this.setBlockBounds(1.0F - f3, f, 0.5F - f2, 1.0F, f1, 0.5F + f2); - } else if (j == 3) - { - this.setBlockBounds(0.5F - f2, f, 0.0F, 0.5F + f2, f1, f3); - } else if (j == 4) - { - this.setBlockBounds(0.5F - f2, f, 1.0F - f3, 0.5F + f2, f1, 1.0F); - } - if (j == 5) - { - this.setBlockBounds(0.5F - f2, 1.0F - f3, 0.5F - f2, 0.5F + f2, 1.0F, 0.5F + f2); - } - } - - @Override - public void setBlockBoundsForItemRender() - { - float f = 0.206F; - float f1 = 0.796F; - float f2 = 0.296F; - float f3 = 0.125F; + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + int l = world.getBlockMetadata(x, y, z); + this.setBounds(l); + } + + private void setBounds(int meta) { + int j = meta; + float f = 0.206F; + float f1 = 0.796F; + float f2 = 0.296F; + float f3 = 0.125F; + + if (j == 6) { + this.setBlockBounds(0.5F - f2, 0.0F, 0.5F - f2, 0.5F + f2, f3, 0.5F + f2); + } + if (j == 1) { + this.setBlockBounds(0.0F, f, 0.5F - f2, f3, f1, 0.5F + f2); + } else if (j == 2) { + this.setBlockBounds(1.0F - f3, f, 0.5F - f2, 1.0F, f1, 0.5F + f2); + } else if (j == 3) { + this.setBlockBounds(0.5F - f2, f, 0.0F, 0.5F + f2, f1, f3); + } else if (j == 4) { + this.setBlockBounds(0.5F - f2, f, 1.0F - f3, 0.5F + f2, f1, 1.0F); + } + if (j == 5) { + this.setBlockBounds(0.5F - f2, 1.0F - f3, 0.5F - f2, 0.5F + f2, 1.0F, 0.5F + f2); + } + } + + @Override + public void setBlockBoundsForItemRender() { + float f = 0.206F; + float f1 = 0.796F; + float f2 = 0.296F; + float f3 = 0.125F; this.setBlockBounds(0.5F - f2, f, 0.3F, 0.5F + f2, f1, f3 + 0.3F); } - @Override - public int onBlockPlaced(World world, int x, int y, int z, int side, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) - { - int j1 = world.getBlockMetadata(x, y, z); - int k1 = j1 & 8; - j1 &= 7; + @Override + public int onBlockPlaced(World world, int x, int y, int z, int side, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) { + int j1 = world.getBlockMetadata(x, y, z); + int k1 = j1 & 8; + j1 &= 7; - ForgeDirection dir = ForgeDirection.getOrientation(side); + ForgeDirection dir = ForgeDirection.getOrientation(side); - if (dir == NORTH && world.isSideSolid(x, y, z + 1, NORTH)) - { - j1 = 4; - } else if (dir == SOUTH && world.isSideSolid(x, y, z - 1, SOUTH)) - { - j1 = 3; - } else if (dir == WEST && world.isSideSolid(x + 1, y, z, WEST)) - { - j1 = 2; - } else if (dir == EAST && world.isSideSolid(x - 1, y, z, EAST)) - { - j1 = 1; - } else if (dir == UP && world.isSideSolid(x, y - 1, z, UP)) - { - j1 = 6; - } else if (dir == DOWN && world.isSideSolid(x, y + 1, z, DOWN)) - { - j1 = 5; - } else - { - j1 = this.fundSolidSide(world, x, y, z); - } + if (dir == NORTH && world.isSideSolid(x, y, z + 1, NORTH)) { + j1 = 4; + } else if (dir == SOUTH && world.isSideSolid(x, y, z - 1, SOUTH)) { + j1 = 3; + } else if (dir == WEST && world.isSideSolid(x + 1, y, z, WEST)) { + j1 = 2; + } else if (dir == EAST && world.isSideSolid(x - 1, y, z, EAST)) { + j1 = 1; + } else if (dir == UP && world.isSideSolid(x, y - 1, z, UP)) { + j1 = 6; + } else if (dir == DOWN && world.isSideSolid(x, y + 1, z, DOWN)) { + j1 = 5; + } else { + j1 = this.fundSolidSide(world, x, y, z); + } - return j1 + k1; - } + return j1 + k1; + } - private int fundSolidSide(World world, int x, int y, int z) - { - if (world.isSideSolid(x, y - 1, z, UP)) - return 6; - if (world.isSideSolid(x - 1, y, z, EAST)) - return 1; - if (world.isSideSolid(x + 1, y, z, WEST)) - return 2; - if (world.isSideSolid(x, y, z - 1, SOUTH)) - return 3; - if (world.isSideSolid(x, y, z + 1, NORTH)) - return 4; - if (world.isSideSolid(x, y + 1, z, UP)) - return 5; - return 1; - } + private int fundSolidSide(World world, int x, int y, int z) { + if (world.isSideSolid(x, y - 1, z, UP)) return 6; + if (world.isSideSolid(x - 1, y, z, EAST)) return 1; + if (world.isSideSolid(x + 1, y, z, WEST)) return 2; + if (world.isSideSolid(x, y, z - 1, SOUTH)) return 3; + if (world.isSideSolid(x, y, z + 1, NORTH)) return 4; + if (world.isSideSolid(x, y + 1, z, UP)) return 5; + return 1; + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - if (this.isLocationStillValid(world, x, y, z)) - { - int l = world.getBlockMetadata(x, y, z) & 7; - boolean flag = false; + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + if (this.isLocationStillValid(world, x, y, z)) { + int l = world.getBlockMetadata(x, y, z) & 7; + boolean flag = false; - if (!world.isSideSolid(x, y - 1, z, UP) && l == 6) - { - flag = true; - } + if (!world.isSideSolid(x, y - 1, z, UP) && l == 6) { + flag = true; + } - if (!world.isSideSolid(x - 1, y, z, EAST) && l == 1) - { - flag = true; - } + if (!world.isSideSolid(x - 1, y, z, EAST) && l == 1) { + flag = true; + } - if (!world.isSideSolid(x + 1, y, z, WEST) && l == 2) - { - flag = true; - } + if (!world.isSideSolid(x + 1, y, z, WEST) && l == 2) { + flag = true; + } - if (!world.isSideSolid(x, y, z - 1, SOUTH) && l == 3) - { - flag = true; - } + if (!world.isSideSolid(x, y, z - 1, SOUTH) && l == 3) { + flag = true; + } - if (!world.isSideSolid(x, y, z + 1, NORTH) && l == 4) - { - flag = true; - } + if (!world.isSideSolid(x, y, z + 1, NORTH) && l == 4) { + flag = true; + } - if (!world.isSideSolid(x, y + 1, z, DOWN) && l == 5) - { - flag = true; - } + if (!world.isSideSolid(x, y + 1, z, DOWN) && l == 5) { + flag = true; + } - if (flag) - { - this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); - world.setBlockToAir(x, y, z); - } - } - } + if (flag) { + this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); + world.setBlockToAir(x, y, z); + } + } + } - private boolean isLocationStillValid(World world, int x, int y, int z) - { - if (!this.canPlaceBlockAt(world, x, y, z)) - { - this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); - world.setBlockToAir(x, y, z); - return false; - } else - { - return true; - } - } + private boolean isLocationStillValid(World world, int x, int y, int z) { + if (!this.canPlaceBlockAt(world, x, y, z)) { + this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); + world.setBlockToAir(x, y, z); + return false; + } else { + return true; + } + } - @Override - public boolean canProvidePower() - { - return true; - } + @Override + public boolean canProvidePower() { + return true; + } - @Override - public boolean isOpaqueCube() - { - return false; - } - - public void breakBlock(World world, int x, int y, int z, Block block, int meta) - { - if (meta > 0) - { + @Override + public boolean isOpaqueCube() { + return false; + } + + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + if (meta > 0) { int i1 = meta; this.updateBlocks(world, x, y, z, i1); } super.breakBlock(world, x, y, z, block, meta); } - - private void updateBlocks(World world, int x, int y, int z, int meta) - { + + private void updateBlocks(World world, int x, int y, int z, int meta) { world.notifyBlocksOfNeighborChange(x, y, z, this); - if (meta == 1) - { + if (meta == 1) { world.notifyBlocksOfNeighborChange(x - 1, y, z, this); - } - else if (meta == 2) - { + } else if (meta == 2) { world.notifyBlocksOfNeighborChange(x + 1, y, z, this); - } - else if (meta == 3) - { + } else if (meta == 3) { world.notifyBlocksOfNeighborChange(x, y, z - 1, this); - } - else if (meta == 4) - { + } else if (meta == 4) { world.notifyBlocksOfNeighborChange(x, y, z + 1, this); - } - else if (meta == 5) - { + } else if (meta == 5) { world.notifyBlocksOfNeighborChange(x, y + 1, z, this); - } - else if (meta == 6) - { + } else if (meta == 6) { world.notifyBlocksOfNeighborChange(x, y - 1, z, this); - } - else - { + } else { world.notifyBlocksOfNeighborChange(x, y - 1, z, this); } } - //#################################LOGIC##################################// - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float p_149727_7_, float p_149727_8_, float p_149727_9_) - { - TilePotentiometer tile = (TilePotentiometer) world.getTileEntity(x, y, z); - - if (tile != null && tile instanceof TilePotentiometer) - { - if (!player.isSneaking()) - ((TilePotentiometer)tile).increasePower(); - else - ((TilePotentiometer)tile).decreasePower(); - - if (world.isRemote) - player.addChatMessage(new ChatComponentText(String.valueOf(((TilePotentiometer)tile).power))); - world.markBlockRangeForRenderUpdate(x, y, z, x, y, z); - } - else - System.out.println("Invalid tile"); - return true; - } + //#################################LOGIC##################################// + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + TilePotentiometer tile = (TilePotentiometer) world.getTileEntity(x, y, z); - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) - { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null && tile instanceof TilePotentiometer) - return ((TilePotentiometer) tile).power; - else - return 0; - } + if (tile != null && tile instanceof TilePotentiometer) { + if (!player.isSneaking()) ((TilePotentiometer) tile).increasePower(); + else ((TilePotentiometer) tile).decreasePower(); - @Override - public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) - { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null && tile instanceof TilePotentiometer) - return ((TilePotentiometer) tile).power; - else - return 0; - } + if (world.isRemote) + player.addChatMessage(new ChatComponentText(String.valueOf(((TilePotentiometer) tile).power))); + world.markBlockRangeForRenderUpdate(x, y, z, x, y, z); + } else System.out.println("Invalid tile"); + return true; + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null && tile instanceof TilePotentiometer) return ((TilePotentiometer) tile).power; + else return 0; + } + + @Override + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null && tile instanceof TilePotentiometer) return ((TilePotentiometer) tile).power; + else return 0; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/RainSensor.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/RainSensor.java index 27a9ee8b..79692513 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/RainSensor.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/RainSensor.java @@ -15,119 +15,97 @@ import net.minecraft.world.World; import java.util.Random; -public class RainSensor extends BlockDE -{ - IIcon icon_inactive; - IIcon icon_active; - IIcon icon_side; +public class RainSensor extends BlockDE { + IIcon icon_inactive; + IIcon icon_active; + IIcon icon_side; - public RainSensor() { - super(Material.circuits); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setBlockBounds(0, 0, 0, 1, 0.125F, 1); - this.setHardness(0.3f); - this.setResistance(0.5f); - this.setTickRandomly(true); - this.setBlockName(Strings.rainSensorName); - ModBlocks.register(this); - } + public RainSensor() { + super(Material.circuits); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setBlockBounds(0, 0, 0, 1, 0.125F, 1); + this.setHardness(0.3f); + this.setResistance(0.5f); + this.setTickRandomly(true); + this.setBlockName(Strings.rainSensorName); + ModBlocks.register(this); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) - { - icon_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "rain_sensor_inactive"); - icon_active = iconRegister.registerIcon(References.RESOURCESPREFIX + "rain_sensor_active"); - icon_side = iconRegister.registerIcon(References.RESOURCESPREFIX + "rain_sensor_side"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + icon_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "rain_sensor_inactive"); + icon_active = iconRegister.registerIcon(References.RESOURCESPREFIX + "rain_sensor_active"); + icon_side = iconRegister.registerIcon(References.RESOURCESPREFIX + "rain_sensor_side"); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int face, int meta) - { - IIcon iconstate = (meta == 0 ? icon_inactive : icon_active); - return face == 1 ? iconstate : icon_side; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int face, int meta) { + IIcon iconstate = (meta == 0 ? icon_inactive : icon_active); + return face == 1 ? iconstate : icon_side; + } - @Override - public boolean canProvidePower() - { - return true; - } + @Override + public boolean canProvidePower() { + return true; + } - @Override - public int tickRate(World world) - { - return 100; - } + @Override + public int tickRate(World world) { + return 100; + } - @Override - public boolean isOpaqueCube() - { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public void updateTick(World world, int x, int y, int z, Random random) - { - if (world.canBlockSeeTheSky(x, y, z)) - world.setBlockMetadataWithNotify(x, y, z, world.getWorldInfo().isRaining() ? 1 : 0, 2); - else - world.setBlockMetadataWithNotify(x, y, z, 0, 2); - world.scheduleBlockUpdate(x, y, z, this, 100); - world.notifyBlocksOfNeighborChange(x, y, z, this); - } + @Override + public void updateTick(World world, int x, int y, int z, Random random) { + if (world.canBlockSeeTheSky(x, y, z)) + world.setBlockMetadataWithNotify(x, y, z, world.getWorldInfo().isRaining() ? 1 : 0, 2); + else world.setBlockMetadataWithNotify(x, y, z, 0, 2); + world.scheduleBlockUpdate(x, y, z, this, 100); + world.notifyBlocksOfNeighborChange(x, y, z, this); + } - @Override - public boolean renderAsNormalBlock() - { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int meta) - { - return world.getBlockMetadata(x, y, z) == 1 ? 15 : 0; - } + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int meta) { + return world.getBlockMetadata(x, y, z) == 1 ? 15 : 0; + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_) - { - world.scheduleBlockUpdate(x, y, z, this, 100); - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_) { + world.scheduleBlockUpdate(x, y, z, this, 100); + } - @Override - public int onBlockPlaced(World world, int x, int y, int z, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) - { - world.scheduleBlockUpdate(x, y, z, this, 10); - return super.onBlockPlaced(world, x, y, z, p_149660_5_, p_149660_6_, p_149660_7_, p_149660_8_, p_149660_9_); - } + @Override + public int onBlockPlaced(World world, int x, int y, int z, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) { + world.scheduleBlockUpdate(x, y, z, this, 10); + return super.onBlockPlaced(world, x, y, z, p_149660_5_, p_149660_6_, p_149660_7_, p_149660_8_, p_149660_9_); + } - @Override - @SideOnly(Side.CLIENT) - public void randomDisplayTick(World world, int x, int y, int z, Random random) - { - int l = world.getBlockMetadata(x, y, z); - int rand = random.nextInt(3); + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random random) { + int l = world.getBlockMetadata(x, y, z); + int rand = random.nextInt(3); - if (l == 1) - { - if (rand == 0) - world.spawnParticle("reddust", x + 1 - 0.155, y + 0.12, z + 1 - 0.155, 0.5, 0.4, 1); - if (rand == 1) - world.spawnParticle("reddust", x + 1 - 0.155, y + 0.12, z + 1 - 0.155, 1, 0.2, 0.2); - if (rand == 1) - world.spawnParticle("reddust", x + 1 - 0.155, y + 0.12, z + 0.155, 0.5, 0.4, 1); - if (rand == 2) - world.spawnParticle("reddust", x + 1 - 0.155, y + 0.12, z + 0.155, 1, 0.2, 0.2); - if (rand == 2) - world.spawnParticle("reddust", x + 0.155, y + 0.12, z + 1 - 0.155, 0.5, 0.4, 1); - if (rand == 3) - world.spawnParticle("reddust", x + 0.155, y + 0.12, z + 1 - 0.155, 1, 0.2, 0.2); - if (rand == 3) - world.spawnParticle("reddust", x + 0.155, y + 0.12, z + 0.155, 0.5, 0.4, 1); - if (rand == 0) - world.spawnParticle("reddust", x + 0.155, y + 0.12, z + 0.155, 1, 0.2, 0.2); - } - } + if (l == 1) { + if (rand == 0) world.spawnParticle("reddust", x + 1 - 0.155, y + 0.12, z + 1 - 0.155, 0.5, 0.4, 1); + if (rand == 1) world.spawnParticle("reddust", x + 1 - 0.155, y + 0.12, z + 1 - 0.155, 1, 0.2, 0.2); + if (rand == 1) world.spawnParticle("reddust", x + 1 - 0.155, y + 0.12, z + 0.155, 0.5, 0.4, 1); + if (rand == 2) world.spawnParticle("reddust", x + 1 - 0.155, y + 0.12, z + 0.155, 1, 0.2, 0.2); + if (rand == 2) world.spawnParticle("reddust", x + 0.155, y + 0.12, z + 1 - 0.155, 0.5, 0.4, 1); + if (rand == 3) world.spawnParticle("reddust", x + 0.155, y + 0.12, z + 1 - 0.155, 1, 0.2, 0.2); + if (rand == 3) world.spawnParticle("reddust", x + 0.155, y + 0.12, z + 0.155, 0.5, 0.4, 1); + if (rand == 0) world.spawnParticle("reddust", x + 0.155, y + 0.12, z + 0.155, 1, 0.2, 0.2); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/SafetyFlame.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/SafetyFlame.java index 844f7df6..b703e1fe 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/SafetyFlame.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/SafetyFlame.java @@ -12,38 +12,36 @@ import java.util.Random; /** * Created by Brandon on 23/08/2014. */ -public class SafetyFlame extends BlockFire{ - public SafetyFlame(){ - super(); - this.setBlockName(Strings.safetyFlameName); - this.setBlockTextureName("fire"); - this.setLightLevel(1F); - ModBlocks.registerOther(this); - } +public class SafetyFlame extends BlockFire { + public SafetyFlame() { + super(); + this.setBlockName(Strings.safetyFlameName); + this.setBlockTextureName("fire"); + this.setLightLevel(1F); + ModBlocks.registerOther(this); + } - @Override - public String getUnlocalizedName() - { - return String.format("tile.%s%s", References.MODID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); - } + @Override + public String getUnlocalizedName() { + return String.format("tile.%s%s", References.MODID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + } - public String getUnwrappedUnlocalizedName(String unlocalizedName) - { - return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); - } + public String getUnwrappedUnlocalizedName(String unlocalizedName) { + return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); + } - @Override - public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) { + @Override + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) { - } + } - @Override - public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) { - super.onNeighborChange(world, x, y, z, tileX, tileY, tileZ); - } + @Override + public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) { + super.onNeighborChange(world, x, y, z, tileX, tileY, tileZ); + } - @Override - public void onBlockAdded(World world, int x, int y, int z) { - super.onBlockAdded(world, x, y, z); - } + @Override + public void onBlockAdded(World world, int x, int y, int z) { + super.onBlockAdded(world, x, y, z); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/TeleporterStand.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/TeleporterStand.java index 0c12c827..fd8c9d0c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/TeleporterStand.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/TeleporterStand.java @@ -27,107 +27,107 @@ import java.util.List; * Created by Brandon on 27/06/2014. */ public class TeleporterStand extends BlockCustomDrop { - public TeleporterStand() { - super(Material.rock); - this.setBlockName(Strings.teleporterStandName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setStepSound(soundTypeStone); - this.setHardness(1.5f); - this.setResistance(10.0f); - this.setBlockBounds(0.35f, 0f, 0.35f, 0.65f, 0.8f, 0.65f); - ModBlocks.register(this); - } + public TeleporterStand() { + super(Material.rock); + this.setBlockName(Strings.teleporterStandName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setStepSound(soundTypeStone); + this.setHardness(1.5f); + this.setResistance(10.0f); + this.setBlockBounds(0.35f, 0f, 0.35f, 0.65f, 0.8f, 0.65f); + ModBlocks.register(this); + } - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - //blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + //blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileTeleporterStand(); - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileTeleporterStand(); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float prx, float pry, float prz) { - TileTeleporterStand tile = world.getTileEntity(x, y, z) instanceof TileTeleporterStand ? (TileTeleporterStand)world.getTileEntity(x, y, z) : null; - if (tile == null) return false; - if (tile.getStackInSlot(0) == null && player.getHeldItem() != null && (player.getHeldItem().getItem() instanceof TeleporterMKI)) { - ItemStack stack = player.getHeldItem(); - tile.setInventorySlotContents(0, stack.copy()); - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - world.markBlockForUpdate(x, y, z); - return true; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float prx, float pry, float prz) { + TileTeleporterStand tile = world.getTileEntity(x, y, z) instanceof TileTeleporterStand ? (TileTeleporterStand) world.getTileEntity(x, y, z) : null; + if (tile == null) return false; + if (tile.getStackInSlot(0) == null && player.getHeldItem() != null && (player.getHeldItem().getItem() instanceof TeleporterMKI)) { + ItemStack stack = player.getHeldItem(); + tile.setInventorySlotContents(0, stack.copy()); + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + world.markBlockForUpdate(x, y, z); + return true; + } - if(tile.getStackInSlot(0) != null && player.isSneaking()){ - EntityItem item = new EntityItem(world, x+0.5, y+0.9, z+0.5, tile.getStackInSlot(0).copy()); - item.motionX = 0; - item.motionY = 0; - item.motionZ = 0; - item.delayBeforeCanPickup = 0; - tile.setInventorySlotContents(0, null); - if (!world.isRemote) world.spawnEntityInWorld(item); - return true; - } + if (tile.getStackInSlot(0) != null && player.isSneaking()) { + EntityItem item = new EntityItem(world, x + 0.5, y + 0.9, z + 0.5, tile.getStackInSlot(0).copy()); + item.motionX = 0; + item.motionY = 0; + item.motionZ = 0; + item.delayBeforeCanPickup = 0; + tile.setInventorySlotContents(0, null); + if (!world.isRemote) world.spawnEntityInWorld(item); + return true; + } - if(tile.getStackInSlot(0) != null && !player.isSneaking() && tile.getStackInSlot(0).getItem() instanceof TeleporterMKI){ - Teleporter.TeleportLocation l = ((TeleporterMKI) tile.getStackInSlot(0).getItem()).getLocation(tile.getStackInSlot(0)); - if (l != null) l.sendEntityToCoords(player); - return true; - } + if (tile.getStackInSlot(0) != null && !player.isSneaking() && tile.getStackInSlot(0).getItem() instanceof TeleporterMKI) { + Teleporter.TeleportLocation l = ((TeleporterMKI) tile.getStackInSlot(0).getItem()).getLocation(tile.getStackInSlot(0)); + if (l != null) l.sendEntityToCoords(player); + return true; + } - return true; - } + return true; + } - @SideOnly(Side.CLIENT) - @Override - public int getRenderType() { - return References.idTeleporterStand; - } + @SideOnly(Side.CLIENT) + @Override + public int getRenderType() { + return References.idTeleporterStand; + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int par1, int par2) { - return Block.getBlockFromName("stone").getIcon(par1, 1); - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int par1, int par2) { + return Block.getBlockFromName("stone").getIcon(par1, 1); + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - protected boolean dropInventory() { - return true; - } + @Override + protected boolean dropInventory() { + return true; + } - @Override - protected boolean hasCustomDropps() { - return false; - } + @Override + protected boolean hasCustomDropps() { + return false; + } - @Override - protected void getCustomTileEntityDrops(TileEntity te, List droppes) { + @Override + protected void getCustomTileEntityDrops(TileEntity te, List droppes) { - } + } - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack p_149689_6_) { - super.onBlockPlacedBy(world, x, y, z, entity, p_149689_6_); - TileTeleporterStand tile = world.getTileEntity(x, y, z) instanceof TileTeleporterStand ? (TileTeleporterStand)world.getTileEntity(x, y, z) : null; - if (tile == null) return; - tile.rotation = (int)entity.rotationYawHead; - } + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack p_149689_6_) { + super.onBlockPlacedBy(world, x, y, z, entity, p_149689_6_); + TileTeleporterStand tile = world.getTileEntity(x, y, z) instanceof TileTeleporterStand ? (TileTeleporterStand) world.getTileEntity(x, y, z) : null; + if (tile == null) return; + tile.rotation = (int) entity.rotationYawHead; + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { - return super.getPickBlock(target, world, x, y, z, player); - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { + return super.getPickBlock(target, world, x, y, z, player); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/TestBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/TestBlock.java index fc083864..30866355 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/TestBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/TestBlock.java @@ -23,64 +23,62 @@ import java.util.Random; public class TestBlock extends BlockDE { - public TestBlock() { - super(Material.rock); - this.setBlockName("testBlock"); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setHardness(5f); - this.setResistance(200.0f); - //this.setBlockBounds(0.4f, 0f, 0.4f, 0.6f, 1f, 0.6f); - ModBlocks.register(this, TestItemBlock.class); - } + public TestBlock() { + super(Material.rock); + this.setBlockName("testBlock"); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setHardness(5f); + this.setResistance(200.0f); + //this.setBlockBounds(0.4f, 0f, 0.4f, 0.6f, 1f, 0.6f); + ModBlocks.register(this, TestItemBlock.class); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) { - return null; - //return super.getIcon(p_149673_1_, p_149673_2_, p_149673_3_, p_149673_4_, p_149673_5_); - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) { + return null; + //return super.getIcon(p_149673_1_, p_149673_2_, p_149673_3_, p_149673_4_, p_149673_5_); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int p_149691_2_) { - return null; - //return super.getIcon(p_149691_1_, p_149691_2_); - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return null; + //return super.getIcon(p_149691_1_, p_149691_2_); + } - @Override - public boolean hasTileEntity(int metadata) { - return true; - } + @Override + public boolean hasTileEntity(int metadata) { + return true; + } - @Override - public TileEntity createTileEntity(World world, int metadata) { - return new TileTestBlock(); - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileTestBlock(); + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - return new ItemStack(Item.getItemFromBlock(world.getBlock(x,y,z)), 1, world.getBlockMetadata(x,y,z)); - //return super.getPickBlock(target, world, x, y, z); - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + return new ItemStack(Item.getItemFromBlock(world.getBlock(x, y, z)), 1, world.getBlockMetadata(x, y, z)); + //return super.getPickBlock(target, world, x, y, z); + } - @Override - public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { - return true; - } + @Override + public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { + return true; + } - @Override - public boolean isOpaqueCube() - { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float px, float py, float pz) - { - EntityLightningBolt bolt = new EntityLightningBolt(world, x, y, z + 5); - //System.out.println(world.getBlockMetadata(x,y,z)); - world.spawnEntityInWorld(bolt); - /* + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float px, float py, float pz) { + EntityLightningBolt bolt = new EntityLightningBolt(world, x, y, z + 5); + //System.out.println(world.getBlockMetadata(x,y,z)); + world.spawnEntityInWorld(bolt); + /* if (!world.isRemote && !player.isSneaking()) { @@ -94,46 +92,44 @@ public class TestBlock extends BlockDE { DraconicEvolution.channelHandler.sendToServer(new ExamplePacket()); } */ - return true; - } + return true; + } - @SideOnly(Side.CLIENT) - @Override - public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) { - //for (int i = 0; i < 16; i++) { - list.add(new ItemStack(item, 1, 0)); - //} - } + @SideOnly(Side.CLIENT) + @Override + public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) { + //for (int i = 0; i < 16; i++) { + list.add(new ItemStack(item, 1, 0)); + //} + } - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) - { - return super.getItemDropped( p_149650_1_, p_149650_2_, p_149650_3_); - } + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return super.getItemDropped(p_149650_1_, p_149650_2_, p_149650_3_); + } - @Override - public void randomDisplayTick(World world, int x, int y, int z, Random rand) - { + @Override + public void randomDisplayTick(World world, int x, int y, int z, Random rand) { - } + } - @Override - public int getRenderType() { - return -1;//super.getRenderType(); - } + @Override + public int getRenderType() { + return -1;//super.getRenderType(); + } - @Override - public boolean shouldSideBeRendered(IBlockAccess world, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { - return true; - } + @Override + public boolean shouldSideBeRendered(IBlockAccess world, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { + return true; + } - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return 0; - } + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return 0; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/XRayBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/XRayBlock.java index a0952b30..4aedceec 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/XRayBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/XRayBlock.java @@ -20,100 +20,87 @@ import java.util.Random; public class XRayBlock extends BlockDE { - public XRayBlock() { - this.setBlockName(Strings.xrayBlockName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setBlockBounds(0.4F, 0.4F, 0.4F, 0.6F, 0.6F, 0.6F); - this.setHardness(10f); - this.setHarvestLevel("pickaxe", 4); - ModBlocks.register(this); - } - - @Override - public int getRenderType() - { - return -1; - } + public XRayBlock() { + this.setBlockName(Strings.xrayBlockName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setBlockBounds(0.4F, 0.4F, 0.4F, 0.6F, 0.6F, 0.6F); + this.setHardness(10f); + this.setHarvestLevel("pickaxe", 4); + ModBlocks.register(this); + } - @Override - public boolean isReplaceable(IBlockAccess world, int x, int y, int z) - { - return super.isReplaceable(world, x, y, z); - } - - @Override - public boolean renderAsNormalBlock() - { - return false; - } + @Override + public int getRenderType() { + return -1; + } - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(final World p_149668_1_, final int p_149668_2_, final int p_149668_3_, final int p_149668_4_) - { - return null; - } + @Override + public boolean isReplaceable(IBlockAccess world, int x, int y, int z) { + return super.isReplaceable(world, x, y, z); + } - @Override - @SideOnly(Side.CLIENT) - public void randomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) - { - final double d0 = x + 0.5F; - final double d1 = y + 0.48F; - final double d2 = z + 0.5F; + @Override + public boolean renderAsNormalBlock() { + return false; + } - float mX1 = (rand.nextFloat() - 0.5F) * 0.005F; - float mY1 = rand.nextFloat() * 0.01F; - float mZ1 = (rand.nextFloat() - 0.5F) * 0.005F; - ParticleHandler.spawnParticle("distortionParticle", d0, d1, d2, mX1, mY1, mZ1, 1); - for (int i = 0; i < 3; i++) - { - float mX = (rand.nextFloat() - 0.5F) * 0.005F; - float mY = 0.01F + rand.nextFloat() * 0.005F; - float mZ = (rand.nextFloat() - 0.5F) * 0.005F; - float scale = 0.2F + (rand.nextFloat() * 0.2F); - ParticleHandler.spawnParticle("distortionParticle", d0, d1, d2, mX, mY, mZ, scale); - } - } + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(final World p_149668_1_, final int p_149668_2_, final int p_149668_3_, final int p_149668_4_) { + return null; + } - @Override - public int quantityDropped(final Random p_149745_1_) - { - return 0; - } - - @Override - public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) - { - ItemStack tool = player.getCurrentEquippedItem(); - if (tool != null && (player.getCurrentEquippedItem().isItemEqual(new ItemStack(ModItems.draconicDestructionStaff)) || player.getCurrentEquippedItem().isItemEqual(new ItemStack(ModItems.draconicPickaxe)))) - { - EntityItem item = new EntityItem(world, player.posX, player.posY, player.posZ, new ItemStack(Item.getItemFromBlock(ModBlocks.xRayBlock))); - world.setBlockToAir(x, y, z); - if (!world.isRemote) - world.spawnEntityInWorld(item); - } - super.onBlockClicked(world, x, y, z, player); - } + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) { + final double d0 = x + 0.5F; + final double d1 = y + 0.48F; + final double d2 = z + 0.5F; - @Override - protected boolean canSilkHarvest() - { - return false; - } + float mX1 = (rand.nextFloat() - 0.5F) * 0.005F; + float mY1 = rand.nextFloat() * 0.01F; + float mZ1 = (rand.nextFloat() - 0.5F) * 0.005F; + ParticleHandler.spawnParticle("distortionParticle", d0, d1, d2, mX1, mY1, mZ1, 1); + for (int i = 0; i < 3; i++) { + float mX = (rand.nextFloat() - 0.5F) * 0.005F; + float mY = 0.01F + rand.nextFloat() * 0.005F; + float mZ = (rand.nextFloat() - 0.5F) * 0.005F; + float scale = 0.2F + (rand.nextFloat() * 0.2F); + ParticleHandler.spawnParticle("distortionParticle", d0, d1, d2, mX, mY, mZ, scale); + } + } - @Override - public void onEntityCollidedWithBlock(final World world, final int x, final int y, final int z, final Entity entity) - { - //if(entity != EntityItem) - //System.out.println(); - //entity.attackEntityFrom(DamageSource.magic, 10F); - } + @Override + public int quantityDropped(final Random p_149745_1_) { + return 0; + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) - { - //world.spawnEntityInWorld(new EntityLightningBolt(world, x, y, z)); - return false; - } + @Override + public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) { + ItemStack tool = player.getCurrentEquippedItem(); + if (tool != null && (player.getCurrentEquippedItem().isItemEqual(new ItemStack(ModItems.draconicDestructionStaff)) || player.getCurrentEquippedItem().isItemEqual(new ItemStack(ModItems.draconicPickaxe)))) { + EntityItem item = new EntityItem(world, player.posX, player.posY, player.posZ, new ItemStack(Item.getItemFromBlock(ModBlocks.xRayBlock))); + world.setBlockToAir(x, y, z); + if (!world.isRemote) world.spawnEntityInWorld(item); + } + super.onBlockClicked(world, x, y, z, player); + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public void onEntityCollidedWithBlock(final World world, final int x, final int y, final int z, final Entity entity) { + //if(entity != EntityItem) + //System.out.println(); + //entity.attackEntityFrom(DamageSource.magic, 10F); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + //world.spawnEntityInWorld(new EntityLightningBolt(world, x, y, z)); + return false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/CKeyStoneItemBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/CKeyStoneItemBlock.java index 8e592538..b94dcd84 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/CKeyStoneItemBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/CKeyStoneItemBlock.java @@ -14,41 +14,41 @@ import java.util.List; */ public class CKeyStoneItemBlock extends ItemBlock { - public CKeyStoneItemBlock(Block block) { - super(block); - setHasSubtypes(true); - } + public CKeyStoneItemBlock(Block block) { + super(block); + setHasSubtypes(true); + } - @SuppressWarnings("unchecked") - @Override - public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { - list.add(new ItemStack(item, 1, 0)); - list.add(new ItemStack(item, 1, 1)); - list.add(new ItemStack(item, 1, 2)); - list.add(new ItemStack(item, 1, 3)); - } + @SuppressWarnings("unchecked") + @Override + public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { + list.add(new ItemStack(item, 1, 0)); + list.add(new ItemStack(item, 1, 1)); + list.add(new ItemStack(item, 1, 2)); + list.add(new ItemStack(item, 1, 3)); + } - @Override - public int getMetadata(int par1) { - return par1; - } + @Override + public int getMetadata(int par1) { + return par1; + } - @Override - public void addInformation(ItemStack stack, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { - int meta = stack.getItemDamage(); - switch (meta){ - case 0: - list.add("Permanent Activation (Consume Key)"); - break; - case 1: - list.add("Button Activation"); - break; - case 2: - list.add("Toggle Activation"); - break; - case 3: - list.add("Button Activation (Consume Key)"); - break; - } - } + @Override + public void addInformation(ItemStack stack, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { + int meta = stack.getItemDamage(); + switch (meta) { + case 0: + list.add("Permanent Activation (Consume Key)"); + break; + case 1: + list.add("Button Activation"); + break; + case 2: + list.add("Toggle Activation"); + break; + case 3: + list.add("Button Activation (Consume Key)"); + break; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/DraconiumChestItemBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/DraconiumChestItemBlock.java index fd1f5423..3e5e276c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/DraconiumChestItemBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/DraconiumChestItemBlock.java @@ -14,34 +14,34 @@ import java.util.List; * Created by Brandon on 31/10/2014. */ public class DraconiumChestItemBlock extends ItemBlockCustomData { - public DraconiumChestItemBlock(Block block) { - super(block); - } + public DraconiumChestItemBlock(Block block) { + super(block); + } - @SuppressWarnings("unchecked") - @Override - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { - list.add(StatCollector.translateToLocal("info.draconiumChestInfo1.txt")); - list.add(StatCollector.translateToLocal("info.draconiumChestInfo2.txt")); - } + @SuppressWarnings("unchecked") + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { + list.add(StatCollector.translateToLocal("info.draconiumChestInfo1.txt")); + list.add(StatCollector.translateToLocal("info.draconiumChestInfo2.txt")); + } - @Override - public Entity createEntity(World world, Entity location, ItemStack itemstack) { - return new EntityPersistentItem(world, location, itemstack); - } + @Override + public Entity createEntity(World world, Entity location, ItemStack itemstack) { + return new EntityPersistentItem(world, location, itemstack); + } - @Override - public boolean hasCustomEntity(ItemStack stack) { - return true; - } + @Override + public boolean hasCustomEntity(ItemStack stack) { + return true; + } - @Override - public boolean getShareTag() { - return false; - } + @Override + public boolean getShareTag() { + return false; + } - @Override - public boolean isDamageable() { - return false; - } + @Override + public boolean isDamageable() { + return false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/DraconiumItemBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/DraconiumItemBlock.java index e4abf3c3..9be3fe14 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/DraconiumItemBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/DraconiumItemBlock.java @@ -19,84 +19,84 @@ import net.minecraft.world.World; /** * Created by Brandon on 8/08/2014. */ -public class DraconiumItemBlock extends ItemBlock implements IEnergyContainerItem{ - public DraconiumItemBlock(Block block) { - super(block); - setHasSubtypes(true); - } +public class DraconiumItemBlock extends ItemBlock implements IEnergyContainerItem { + public DraconiumItemBlock(Block block) { + super(block); + setHasSubtypes(true); + } - protected int capacity = BalanceConfigHandler.draconiumBlockEnergyToChange; - protected int maxReceive = BalanceConfigHandler.draconiumBlockChargingSpeed; - protected int maxExtract = BalanceConfigHandler.draconiumBlockChargingSpeed; + protected int capacity = BalanceConfigHandler.draconiumBlockEnergyToChange; + protected int maxReceive = BalanceConfigHandler.draconiumBlockChargingSpeed; + protected int maxExtract = BalanceConfigHandler.draconiumBlockChargingSpeed; - @SuppressWarnings("unchecked") - @Override - public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { - list.add(new ItemStack(item, 1, 0)); - list.add(new ItemStack(item, 1, 1)); - list.add(new ItemStack(item, 1, 2)); - } + @SuppressWarnings("unchecked") + @Override + public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { + list.add(new ItemStack(item, 1, 0)); + list.add(new ItemStack(item, 1, 1)); + list.add(new ItemStack(item, 1, 2)); + } - @Override - public int getMetadata(int par1) { - return par1; - } + @Override + public int getMetadata(int par1) { + return par1; + } - @Override - public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName(stack) + stack.getItemDamage(); - } + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName(stack) + stack.getItemDamage(); + } - @Override - public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { - if(container.getItemDamage() != 0 || container.stackSize <= 0) return 0; - maxReceive /= container.stackSize; - if (container.stackTagCompound == null) { - container.stackTagCompound = new NBTTagCompound(); - } - int energy = container.stackTagCompound.getInteger("Energy"); - int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + if (container.getItemDamage() != 0 || container.stackSize <= 0) return 0; + maxReceive /= container.stackSize; + if (container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); - if (!simulate) { - energy += energyReceived; - container.stackTagCompound.setInteger("Energy", energy); - } - if (getEnergyStored(container) == getMaxEnergyStored(container)) { - container.setItemDamage(2); - container.setTagCompound(null); - } - return energyReceived * container.stackSize; - } + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("Energy", energy); + } + if (getEnergyStored(container) == getMaxEnergyStored(container)) { + container.setItemDamage(2); + container.setTagCompound(null); + } + return energyReceived * container.stackSize; + } - @Override - public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { - return 0; - } + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + return 0; + } - @Override - public int getEnergyStored(ItemStack container) { - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - return container.stackTagCompound.getInteger("Energy"); - } + @Override + public int getEnergyStored(ItemStack container) { + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + return 0; + } + return container.stackTagCompound.getInteger("Energy"); + } - @Override - public int getMaxEnergyStored(ItemStack container) { - return capacity; - } + @Override + public int getMaxEnergyStored(ItemStack container) { + return capacity; + } - @Override - public void onUpdate(ItemStack stack, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { - if (stack.getItemDamage() == 0 && getEnergyStored(stack) == getMaxEnergyStored(stack)) stack.setItemDamage(2); - super.onUpdate(stack, p_77663_2_, p_77663_3_, p_77663_4_, p_77663_5_); - } + @Override + public void onUpdate(ItemStack stack, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { + if (stack.getItemDamage() == 0 && getEnergyStored(stack) == getMaxEnergyStored(stack)) stack.setItemDamage(2); + super.onUpdate(stack, p_77663_2_, p_77663_3_, p_77663_4_, p_77663_5_); + } - @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - @Override - public void addInformation(ItemStack stack, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { - if (stack.hasTagCompound()) list.add(getEnergyStored(stack) + " / " + getMaxEnergyStored(stack) + "RF"); - } + @SideOnly(Side.CLIENT) + @SuppressWarnings("unchecked") + @Override + public void addInformation(ItemStack stack, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { + if (stack.hasTagCompound()) list.add(getEnergyStored(stack) + " / " + getMaxEnergyStored(stack) + "RF"); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/EnergyCrystalItemBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/EnergyCrystalItemBlock.java index 1a43ed5c..04cece71 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/EnergyCrystalItemBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/EnergyCrystalItemBlock.java @@ -12,26 +12,26 @@ import net.minecraft.world.World; */ public class EnergyCrystalItemBlock extends ItemBlock { - public EnergyCrystalItemBlock(Block block) { - super(block); - this.setHasSubtypes(true); - } + public EnergyCrystalItemBlock(Block block) { + super(block); + this.setHasSubtypes(true); + } - @Override - public int getMetadata(int par1) { - return par1; - } + @Override + public int getMetadata(int par1) { + return par1; + } - @Override - public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName(stack) + stack.getItemDamage(); - } + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName(stack) + stack.getItemDamage(); + } - @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { - boolean b = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); - TileEnergyTransceiver transceiver = world.getTileEntity(x, y, z) instanceof TileEnergyTransceiver ? (TileEnergyTransceiver) world.getTileEntity(x, y, z) : null; - if (transceiver != null) transceiver.facing = side; - return b; - } + @Override + public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { + boolean b = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); + TileEnergyTransceiver transceiver = world.getTileEntity(x, y, z) instanceof TileEnergyTransceiver ? (TileEnergyTransceiver) world.getTileEntity(x, y, z) : null; + if (transceiver != null) transceiver.facing = side; + return b; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/ItemBlockCustomData.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/ItemBlockCustomData.java index 525fb27a..34751756 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/ItemBlockCustomData.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/ItemBlockCustomData.java @@ -17,50 +17,50 @@ import net.minecraftforge.common.util.ForgeDirection; */ public class ItemBlockCustomData extends ItemBlock { - public ItemBlockCustomData(Block block) { - super(block); - } + public ItemBlockCustomData(Block block) { + super(block); + } - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { - if (stack.stackSize <= 0) 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) { + if (stack.stackSize <= 0) return false; - Block block = world.getBlock(x, y, z); + Block block = world.getBlock(x, y, z); - if (block == Blocks.snow && (world.getBlockMetadata(x, y, z) & 7) < 1) side = 1; + if (block == Blocks.snow && (world.getBlockMetadata(x, y, z) & 7) < 1) side = 1; - ForgeDirection sideDir = ForgeDirection.getOrientation(side); + ForgeDirection sideDir = ForgeDirection.getOrientation(side); - if (!(block != null && block.isReplaceable(world, x, y, z))) { - x += sideDir.offsetX; - y += sideDir.offsetY; - z += sideDir.offsetZ; - } + if (!(block != null && block.isReplaceable(world, x, y, z))) { + x += sideDir.offsetX; + y += sideDir.offsetY; + z += sideDir.offsetZ; + } - if (!player.canPlayerEdit(x, y, z, side, stack)) return false; + if (!player.canPlayerEdit(x, y, z, side, stack)) return false; - Block ownBlock = this.field_150939_a; - if (y == 255 && ownBlock.getMaterial().isSolid()) return false; + Block ownBlock = this.field_150939_a; + if (y == 255 && ownBlock.getMaterial().isSolid()) return false; - if (!world.canPlaceEntityOnSide(this.field_150939_a, x, y, z, false, side, player, stack)) return false; + if (!world.canPlaceEntityOnSide(this.field_150939_a, x, y, z, false, side, player, stack)) return false; - int newMeta = getMetadata(stack.getItemDamage()); - newMeta = ownBlock.onBlockPlaced(world, x, y, z, side, hitX, hitY, hitZ, newMeta); + int newMeta = getMetadata(stack.getItemDamage()); + newMeta = ownBlock.onBlockPlaced(world, x, y, z, side, hitX, hitY, hitZ, newMeta); - if (!placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, newMeta)) return false; + if (!placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, newMeta)) return false; - TileEntity te = world.getTileEntity(x, y, z) instanceof TileDraconiumChest ? (TileDraconiumChest)world.getTileEntity(x, y, z) : null; + TileEntity te = world.getTileEntity(x, y, z) instanceof TileDraconiumChest ? (TileDraconiumChest) world.getTileEntity(x, y, z) : null; - if (te instanceof ICustomItemData){ - NBTTagCompound itemTag = stack.getTagCompound(); - if (itemTag != null && itemTag.hasKey(ICustomItemData.tagName)) { - ((ICustomItemData)te).readDataFromItem(itemTag.getCompoundTag(ICustomItemData.tagName), stack); - } - } + if (te instanceof ICustomItemData) { + NBTTagCompound itemTag = stack.getTagCompound(); + if (itemTag != null && itemTag.hasKey(ICustomItemData.tagName)) { + ((ICustomItemData) te).readDataFromItem(itemTag.getCompoundTag(ICustomItemData.tagName), stack); + } + } - world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, ownBlock.stepSound.getBreakSound(), (ownBlock.stepSound.getVolume() + 1.0F) / 2.0F, ownBlock.stepSound.getPitch() * 0.8F); - stack.stackSize--; - return true; - } + world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, ownBlock.stepSound.getBreakSound(), (ownBlock.stepSound.getVolume() + 1.0F) / 2.0F, ownBlock.stepSound.getPitch() * 0.8F); + stack.stackSize--; + return true; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/ItemBlockFrowGate.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/ItemBlockFrowGate.java index 974bcf7a..1644d0f3 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/ItemBlockFrowGate.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/ItemBlockFrowGate.java @@ -8,18 +8,18 @@ import net.minecraft.item.ItemStack; * Created by Brandon on 25/6/2015. */ public class ItemBlockFrowGate extends ItemBlock { - public ItemBlockFrowGate(Block block) { - super(block); - this.setHasSubtypes(true); - } + public ItemBlockFrowGate(Block block) { + super(block); + this.setHasSubtypes(true); + } - @Override - public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName(stack) + (stack.getItemDamage() / 6 == 0 ? "Flux" : "Fluid"); - } + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName(stack) + (stack.getItemDamage() / 6 == 0 ? "Flux" : "Fluid"); + } - @Override - public int getMetadata(int p_77647_1_) { - return p_77647_1_; - } + @Override + public int getMetadata(int p_77647_1_) { + return p_77647_1_; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/LRDItemBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/LRDItemBlock.java index 17f2d165..9689981f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/LRDItemBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/LRDItemBlock.java @@ -12,19 +12,19 @@ import java.util.List; * Created by Brandon on 23/06/2014. */ public class LRDItemBlock extends ItemBlock { - public LRDItemBlock(Block block) { - super(block); - setHasSubtypes(true); - } + public LRDItemBlock(Block block) { + super(block); + setHasSubtypes(true); + } - @Override - public int getMetadata(int par1) { - return par1; - } + @Override + public int getMetadata(int par1) { + return par1; + } - @Override - public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName(stack) + stack.getItemDamage(); - } + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName(stack) + stack.getItemDamage(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/TestItemBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/TestItemBlock.java index c7862e9b..5b84d408 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/TestItemBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/itemblocks/TestItemBlock.java @@ -8,19 +8,19 @@ import net.minecraft.item.ItemStack; * Created by Brandon on 23/06/2014. */ public class TestItemBlock extends ItemBlock { - public TestItemBlock(Block block) { - super(block); - setHasSubtypes(true); - //this.hasSubtypes = true; - } + public TestItemBlock(Block block) { + super(block); + setHasSubtypes(true); + //this.hasSubtypes = true; + } - @Override - public int getMetadata(int par1) { - return par1; - } + @Override + public int getMetadata(int par1) { + return par1; + } - @Override - public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName(stack) + stack.getItemDamage(); - } + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName(stack) + stack.getItemDamage(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/DissEnchanter.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/DissEnchanter.java index 771382d9..57127699 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/DissEnchanter.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/DissEnchanter.java @@ -26,101 +26,100 @@ import java.util.Random; * Created by Brandon on 27/06/2014. */ public class DissEnchanter extends BlockCustomDrop { - IIcon top; - IIcon bottom; - public DissEnchanter() { - super(Material.iron); - this.setBlockName(Strings.dissEnchanterName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setStepSound(soundTypeStone); - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.75F, 1.0F); - ModBlocks.register(this); - } + IIcon top; + IIcon bottom; - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "dissEnchanter_side"); - top = iconRegister.registerIcon(References.RESOURCESPREFIX + "dissEnchanter_top"); - bottom = iconRegister.registerIcon(References.RESOURCESPREFIX + "dissEnchanter_bottom"); - } + public DissEnchanter() { + super(Material.iron); + this.setBlockName(Strings.dissEnchanterName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setStepSound(soundTypeStone); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.75F, 1.0F); + ModBlocks.register(this); + } - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - return side == 0 ? bottom : (side == 1 ? top : blockIcon); - } + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "dissEnchanter_side"); + top = iconRegister.registerIcon(References.RESOURCESPREFIX + "dissEnchanter_top"); + bottom = iconRegister.registerIcon(References.RESOURCESPREFIX + "dissEnchanter_bottom"); + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileDissEnchanter(); - } + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return side == 0 ? bottom : (side == 1 ? top : blockIcon); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float prx, float pry, float prz) { - if (!world.isRemote) { - FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_DISSENCHANTER, world, x, y, z); - } - return true; - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileDissEnchanter(); + } - @SideOnly(Side.CLIENT) - @Override - public int getRenderType() { - return super.getRenderType(); - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float prx, float pry, float prz) { + if (!world.isRemote) { + FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_DISSENCHANTER, world, x, y, z); + } + return true; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @SideOnly(Side.CLIENT) + @Override + public int getRenderType() { + return super.getRenderType(); + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - protected boolean dropInventory() { - return true; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - protected boolean hasCustomDropps() { - return false; - } + @Override + protected boolean dropInventory() { + return true; + } - @Override - protected void getCustomTileEntityDrops(TileEntity te, List droppes) { + @Override + protected boolean hasCustomDropps() { + return false; + } - } + @Override + protected void getCustomTileEntityDrops(TileEntity te, List droppes) { - @Override - @SideOnly(Side.CLIENT) - public void randomDisplayTick(World world, int x, int y, int z, Random rand) { - super.randomDisplayTick(world, x, y, z, rand); + } - for (int x1 = x - 2; x1 <= x + 2; ++x1) { - for (int z1 = z - 2; z1 <= z + 2; ++z1) { - if (x1 > x - 2 && x1 < x + 2 && z1 == z - 1) { - z1 = z + 2; - } + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random rand) { + super.randomDisplayTick(world, x, y, z, rand); - if (rand.nextInt(16) == 0) { - for (int y1 = y; y1 <= y + 1; ++y1) { - if (world.getBlock(x1, y1, z1) == Blocks.bookshelf) { - if (!world.isAirBlock((x1 - x) / 2 + x, y1, (z1 - z) - / 2 + z)) { - break; - } + for (int x1 = x - 2; x1 <= x + 2; ++x1) { + for (int z1 = z - 2; z1 <= z + 2; ++z1) { + if (x1 > x - 2 && x1 < x + 2 && z1 == z - 1) { + z1 = z + 2; + } - //world.spawnParticle("enchantmenttable", x + 0.5D, y + 2.0D, z + 0.5D, l - x + rand.nextFloat() - 0.5D, j1 - y - rand.nextFloat() - 1.0F, i1 - z + rand.nextFloat() - 0.5D); - world.spawnParticle("enchantmenttable", x1+0.4+(rand.nextFloat()*0.2), y1+0.8, z1+0.4+(rand.nextFloat()*0.2), x - x1+rand.nextFloat()-0.5, y - y1+rand.nextFloat(), z - z1+rand.nextFloat()-0.5); + if (rand.nextInt(16) == 0) { + for (int y1 = y; y1 <= y + 1; ++y1) { + if (world.getBlock(x1, y1, z1) == Blocks.bookshelf) { + if (!world.isAirBlock((x1 - x) / 2 + x, y1, (z1 - z) / 2 + z)) { + break; + } - } - } - } - } - } - } + //world.spawnParticle("enchantmenttable", x + 0.5D, y + 2.0D, z + 0.5D, l - x + rand.nextFloat() - 0.5D, j1 - y - rand.nextFloat() - 1.0F, i1 - z + rand.nextFloat() - 0.5D); + world.spawnParticle("enchantmenttable", x1 + 0.4 + (rand.nextFloat() * 0.2), y1 + 0.8, z1 + 0.4 + (rand.nextFloat() * 0.2), x - x1 + rand.nextFloat() - 0.5, y - y1 + rand.nextFloat(), z - z1 + rand.nextFloat() - 0.5); + + } + } + } + } + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/EnergyCrystal.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/EnergyCrystal.java index 49d6fca4..5e2eaa10 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/EnergyCrystal.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/EnergyCrystal.java @@ -31,209 +31,199 @@ import java.util.List; /** * Created by Brandon on 10/02/2015. */ -public class EnergyCrystal extends BlockDE implements IHudDisplayBlock -{ - public static final byte RELAY_TIER_1 = 0; - public static final byte RELAY_TIER_2 = 1; - public static final byte TRANSCEIVER_TIER_1 = 2; - public static final byte TRANSCEIVER_TIER_2 = 3; - public static final byte WIRELESS_TRANSCEIVER_TIER_1 = 3; - public static final byte WIRELESS_TRANSCEIVER_TIER_2 = 4; +public class EnergyCrystal extends BlockDE implements IHudDisplayBlock { + public static final byte RELAY_TIER_1 = 0; + public static final byte RELAY_TIER_2 = 1; + public static final byte TRANSCEIVER_TIER_1 = 2; + public static final byte TRANSCEIVER_TIER_2 = 3; + public static final byte WIRELESS_TRANSCEIVER_TIER_1 = 3; + public static final byte WIRELESS_TRANSCEIVER_TIER_2 = 4; - public EnergyCrystal() - { - super(Material.glass); - this.setBlockName(Strings.energyCrystalName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setStepSound(soundTypeGlass); - ModBlocks.register(this, EnergyCrystalItemBlock.class); - } + public EnergyCrystal() { + super(Material.glass); + this.setBlockName(Strings.energyCrystalName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setStepSound(soundTypeGlass); + ModBlocks.register(this, EnergyCrystalItemBlock.class); + } - @SuppressWarnings("unchecked") - @SideOnly(Side.CLIENT) - @Override - public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) { - list.add(new ItemStack(item, 1, 0)); - list.add(new ItemStack(item, 1, 1)); - list.add(new ItemStack(item, 1, 2)); - list.add(new ItemStack(item, 1, 3)); - list.add(new ItemStack(item, 1, 4)); - list.add(new ItemStack(item, 1, 5)); - } + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + @Override + public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) { + list.add(new ItemStack(item, 1, 0)); + list.add(new ItemStack(item, 1, 1)); + list.add(new ItemStack(item, 1, 2)); + list.add(new ItemStack(item, 1, 3)); + list.add(new ItemStack(item, 1, 4)); + list.add(new ItemStack(item, 1, 5)); + } - @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - if (meta == 1 || meta == 0 || meta == 4 || meta == 5) setBlockBounds(0.37F, 0.135F, 0.37F, 0.63F, 0.865F, 0.63F); - else if (meta == 2 || meta == 3) - { - TileEnergyTransceiver tile = world.getTileEntity(x, y, z) instanceof TileEnergyTransceiver ? (TileEnergyTransceiver) world.getTileEntity(x, y, z) : null; - if (tile != null) - { - switch (tile.facing) - { - case 0: - setBlockBounds(0.37F, 0.59F, 0.37F, 0.63F, 1.0F, 0.63F); - break; - case 1: - setBlockBounds(0.37F, 0.0F, 0.37F, 0.63F, 0.41F, 0.63F); - break; - case 2: - setBlockBounds(0.37F, 0.37F, 0.59F, 0.63F, 0.63F, 1.0F); - break; - case 3: - setBlockBounds(0.37F, 0.37F, 0.0F, 0.63F, 0.63F, 0.41F); - break; - case 4: - setBlockBounds(0.59F, 0.37F, 0.37F, 1.0F, 0.63F, 0.63F); - break; - case 5: - setBlockBounds(0.0F, 0.37F, 0.37F, 0.41F, 0.63F, 0.63F); - break; - } - } - } - } + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 1 || meta == 0 || meta == 4 || meta == 5) + setBlockBounds(0.37F, 0.135F, 0.37F, 0.63F, 0.865F, 0.63F); + else if (meta == 2 || meta == 3) { + TileEnergyTransceiver tile = world.getTileEntity(x, y, z) instanceof TileEnergyTransceiver ? (TileEnergyTransceiver) world.getTileEntity(x, y, z) : null; + if (tile != null) { + switch (tile.facing) { + case 0: + setBlockBounds(0.37F, 0.59F, 0.37F, 0.63F, 1.0F, 0.63F); + break; + case 1: + setBlockBounds(0.37F, 0.0F, 0.37F, 0.63F, 0.41F, 0.63F); + break; + case 2: + setBlockBounds(0.37F, 0.37F, 0.59F, 0.63F, 0.63F, 1.0F); + break; + case 3: + setBlockBounds(0.37F, 0.37F, 0.0F, 0.63F, 0.63F, 0.41F); + break; + case 4: + setBlockBounds(0.59F, 0.37F, 0.37F, 1.0F, 0.63F, 0.63F); + break; + case 5: + setBlockBounds(0.0F, 0.37F, 0.37F, 0.41F, 0.63F, 0.63F); + break; + } + } + } + } - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - if (meta == 1 || meta == 0 || meta == 4 || meta == 5) return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.135F, z + 0.37F, x + 0.63F, y + 0.865F, z + 0.63F); - else if (meta == 2 || meta == 3) - { - TileEnergyTransceiver tile = world.getTileEntity(x, y, z) instanceof TileEnergyTransceiver ? (TileEnergyTransceiver) world.getTileEntity(x, y, z) : null; - if (tile != null) - { - switch (tile.facing) - { - case 0: - return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.59F, z + 0.37F, x + 0.63F, y + 1.0F, z + 0.63F); - case 1: - return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.0F, z + 0.37F, x + 0.63F, y + 0.41F, z + 0.63F); - case 2: - return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.37F, z + 0.59F, x + 0.63F, y + 0.63F, z + 1.0F); - case 3: - return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.37F, z + 0.0F, x + 0.63F, y + 0.63F, z + 0.41F); - case 4: - return AxisAlignedBB.getBoundingBox(x + 0.59F, y + 0.37F, z + 0.37F, x + 1.0F, y + 0.63F, z + 0.63F); - case 5: - return AxisAlignedBB.getBoundingBox(x + 0.0F, y + 0.37F, z + 0.37F, x + 0.41F, y + 0.63F, z + 0.63F); - } - } - } + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 1 || meta == 0 || meta == 4 || meta == 5) + return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.135F, z + 0.37F, x + 0.63F, y + 0.865F, z + 0.63F); + else if (meta == 2 || meta == 3) { + TileEnergyTransceiver tile = world.getTileEntity(x, y, z) instanceof TileEnergyTransceiver ? (TileEnergyTransceiver) world.getTileEntity(x, y, z) : null; + if (tile != null) { + switch (tile.facing) { + case 0: + return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.59F, z + 0.37F, x + 0.63F, y + 1.0F, z + 0.63F); + case 1: + return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.0F, z + 0.37F, x + 0.63F, y + 0.41F, z + 0.63F); + case 2: + return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.37F, z + 0.59F, x + 0.63F, y + 0.63F, z + 1.0F); + case 3: + return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.37F, z + 0.0F, x + 0.63F, y + 0.63F, z + 0.41F); + case 4: + return AxisAlignedBB.getBoundingBox(x + 0.59F, y + 0.37F, z + 0.37F, x + 1.0F, y + 0.63F, z + 0.63F); + case 5: + return AxisAlignedBB.getBoundingBox(x + 0.0F, y + 0.37F, z + 0.37F, x + 0.41F, y + 0.63F, z + 0.63F); + } + } + } - return super.getCollisionBoundingBoxFromPool(world, x, y, z); - } + return super.getCollisionBoundingBoxFromPool(world, x, y, z); + } - @Override - public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - if (meta == 1 || meta == 0) return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.135F, z + 0.37F, x + 0.63F, y + 0.865F, z + 0.63F); - else if (meta == 2 || meta == 3) - { - TileEnergyTransceiver tile = world.getTileEntity(x, y, z) instanceof TileEnergyTransceiver ? (TileEnergyTransceiver) world.getTileEntity(x, y, z) : null; - if (tile != null) - { - switch (tile.facing) - { - case 0: - return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.59F, z + 0.37F, x + 0.63F, y + 1.0F, z + 0.63F); - case 1: - return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.0F, z + 0.37F, x + 0.63F, y + 0.41F, z + 0.63F); - case 2: - return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.37F, z + 0.59F, x + 0.63F, y + 0.63F, z + 1.0F); - case 3: - return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.37F, z + 0.0F, x + 0.63F, y + 0.63F, z + 0.41F); - case 4: - return AxisAlignedBB.getBoundingBox(x + 0.59F, y + 0.37F, z + 0.37F, x + 1.0F, y + 0.63F, z + 0.63F); - case 5: - return AxisAlignedBB.getBoundingBox(x + 0.0F, y + 0.37F, z + 0.37F, x + 0.41F, y + 0.63F, z + 0.63F); - } - } - } + @Override + public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 1 || meta == 0) + return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.135F, z + 0.37F, x + 0.63F, y + 0.865F, z + 0.63F); + else if (meta == 2 || meta == 3) { + TileEnergyTransceiver tile = world.getTileEntity(x, y, z) instanceof TileEnergyTransceiver ? (TileEnergyTransceiver) world.getTileEntity(x, y, z) : null; + if (tile != null) { + switch (tile.facing) { + case 0: + return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.59F, z + 0.37F, x + 0.63F, y + 1.0F, z + 0.63F); + case 1: + return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.0F, z + 0.37F, x + 0.63F, y + 0.41F, z + 0.63F); + case 2: + return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.37F, z + 0.59F, x + 0.63F, y + 0.63F, z + 1.0F); + case 3: + return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.37F, z + 0.0F, x + 0.63F, y + 0.63F, z + 0.41F); + case 4: + return AxisAlignedBB.getBoundingBox(x + 0.59F, y + 0.37F, z + 0.37F, x + 1.0F, y + 0.63F, z + 0.63F); + case 5: + return AxisAlignedBB.getBoundingBox(x + 0.0F, y + 0.37F, z + 0.37F, x + 0.41F, y + 0.63F, z + 0.63F); + } + } + } - return super.getSelectedBoundingBoxFromPool(world, x, y, z); - } + return super.getSelectedBoundingBoxFromPool(world, x, y, z); + } - @Override - public boolean hasTileEntity(int metadata) { - return true; - } + @Override + public boolean hasTileEntity(int metadata) { + return true; + } - @Override - public TileEntity createTileEntity(World world, int metadata) { - return metadata == 0 || metadata == 1 ? new TileEnergyRelay(metadata) : metadata == 2 || metadata == 3 ? new TileEnergyTransceiver(metadata - 2) : metadata == 4 || metadata == 5 ? new TileWirelessEnergyTransceiver(metadata - 4) : null; - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + return metadata == 0 || metadata == 1 ? new TileEnergyRelay(metadata) : metadata == 2 || metadata == 3 ? new TileEnergyTransceiver(metadata - 2) : metadata == 4 || metadata == 5 ? new TileWirelessEnergyTransceiver(metadata - 4) : null; + } - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconium_block_0"); - } + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconium_block_0"); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xx, float yy, float zz) { - if (world.getTileEntity(x, y, z) instanceof TileRemoteEnergyBase) ((TileRemoteEnergyBase)world.getTileEntity(x, y, z)).onBlockActivated(player); - return true; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xx, float yy, float zz) { + if (world.getTileEntity(x, y, z) instanceof TileRemoteEnergyBase) + ((TileRemoteEnergyBase) world.getTileEntity(x, y, z)).onBlockActivated(player); + return true; + } - @Override - public int getRenderType() { - return -1; - } + @Override + public int getRenderType() { + return -1; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) { - return 4;//super.getLightValue(world, x, y, z); - } + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + return 4;//super.getLightValue(world, x, y, z); + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { - return new ItemStack(this, 1, world.getBlockMetadata(x, y, z)); - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { + return new ItemStack(this, 1, world.getBlockMetadata(x, y, z)); + } - @Override - public List getDisplayData(World world, int x, int y, int z) { - List list = new ArrayList(); - IRemoteEnergyHandler tile = world.getTileEntity(x, y, z) instanceof IRemoteEnergyHandler ? (IRemoteEnergyHandler) world.getTileEntity(x, y, z) : null; - if (tile != null) - { - list.add(InfoHelper.HITC()+StatCollector.translateToLocal(this.getUnlocalizedName() + world.getBlockMetadata(x, y, z) + ".name")); - list.add("RF: " + tile.getEnergyStored(ForgeDirection.DOWN)); - list.add("Cap: " + tile.getCapacity() + "%"); - if (tile instanceof TileEnergyTransceiver) { - String x5 = ((TileEnergyTransceiver) tile).getPowerTier() > 0 && ((TileEnergyTransceiver) tile).transferBoost ? StatCollector.translateToLocal("info.de.5xTransfer.txt") : ""; - list.add(((TileEnergyTransceiver)tile).getInput() ? StatCollector.translateToLocal("info.de.modeIn.txt") + x5 : StatCollector.translateToLocal("info.de.modeOut.txt") + x5); - } - if (tile instanceof TileRemoteEnergyBase) { - list.add(StatCollector.translateToLocal("info.de.connections.txt") + ": " + ((TileRemoteEnergyBase) tile).linkedDevices.size() + "/" + tile.getMaxConnections()); - } - if (tile instanceof TileWirelessEnergyTransceiver){ - list.add(StatCollector.translateToLocal("info.de.wirelessConnections.txt") + ": " + ((TileWirelessEnergyTransceiver) tile).receiverList.size() + "/" + ((TileWirelessEnergyTransceiver) tile).getmaxWirelessConnections()); - } + @Override + public List getDisplayData(World world, int x, int y, int z) { + List list = new ArrayList(); + IRemoteEnergyHandler tile = world.getTileEntity(x, y, z) instanceof IRemoteEnergyHandler ? (IRemoteEnergyHandler) world.getTileEntity(x, y, z) : null; + if (tile != null) { + list.add(InfoHelper.HITC() + StatCollector.translateToLocal(this.getUnlocalizedName() + world.getBlockMetadata(x, y, z) + ".name")); + list.add("RF: " + tile.getEnergyStored(ForgeDirection.DOWN)); + list.add("Cap: " + tile.getCapacity() + "%"); + if (tile instanceof TileEnergyTransceiver) { + String x5 = ((TileEnergyTransceiver) tile).getPowerTier() > 0 && ((TileEnergyTransceiver) tile).transferBoost ? StatCollector.translateToLocal("info.de.5xTransfer.txt") : ""; + list.add(((TileEnergyTransceiver) tile).getInput() ? StatCollector.translateToLocal("info.de.modeIn.txt") + x5 : StatCollector.translateToLocal("info.de.modeOut.txt") + x5); + } + if (tile instanceof TileRemoteEnergyBase) { + list.add(StatCollector.translateToLocal("info.de.connections.txt") + ": " + ((TileRemoteEnergyBase) tile).linkedDevices.size() + "/" + tile.getMaxConnections()); + } + if (tile instanceof TileWirelessEnergyTransceiver) { + list.add(StatCollector.translateToLocal("info.de.wirelessConnections.txt") + ": " + ((TileWirelessEnergyTransceiver) tile).receiverList.size() + "/" + ((TileWirelessEnergyTransceiver) tile).getmaxWirelessConnections()); + } - if (tile instanceof TileRemoteEnergyBase) - { - for (LinkedEnergyDevice l : ((TileRemoteEnergyBase) tile).linkedDevices) - { - list.add(l.toString()); - } - } - } - return list; - } + if (tile instanceof TileRemoteEnergyBase) { + for (LinkedEnergyDevice l : ((TileRemoteEnergyBase) tile).linkedDevices) { + list.add(l.toString()); + } + } + } + return list; + } - @Override - public int damageDropped(int dmg) { - return dmg; - } + @Override + public int damageDropped(int dmg) { + return dmg; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/EnergyInfuser.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/EnergyInfuser.java index c585cd3c..0b84755a 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/EnergyInfuser.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/EnergyInfuser.java @@ -25,73 +25,73 @@ import java.util.List; * Created by Brandon on 27/06/2014. */ public class EnergyInfuser extends BlockCustomDrop { - public EnergyInfuser() { - super(Material.iron); - this.setBlockName(Strings.energyInfuserName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setStepSound(soundTypeStone); - this.setBlockBounds(0f, 0f, 0f, 1f, 0.375f, 1f); - ModBlocks.register(this); - } + public EnergyInfuser() { + super(Material.iron); + this.setBlockName(Strings.energyInfuserName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setStepSound(soundTypeStone); + this.setBlockBounds(0f, 0f, 0f, 1f, 0.375f, 1f); + ModBlocks.register(this); + } - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileEnergyInfuser(); - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEnergyInfuser(); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float prx, float pry, float prz) { - if (!world.isRemote) { - FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_ENERGY_INFUSER, world, x, y, z); - } - world.markBlockForUpdate(x, y, z); - return true; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float prx, float pry, float prz) { + if (!world.isRemote) { + FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_ENERGY_INFUSER, world, x, y, z); + } + world.markBlockForUpdate(x, y, z); + return true; + } - @SideOnly(Side.CLIENT) - @Override - public int getRenderType() { - return -1; - } + @SideOnly(Side.CLIENT) + @Override + public int getRenderType() { + return -1; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - protected boolean dropInventory() { - return true; - } + @Override + protected boolean dropInventory() { + return true; + } - @Override - protected boolean hasCustomDropps() { - return false; - } + @Override + protected boolean hasCustomDropps() { + return false; + } - @Override - protected void getCustomTileEntityDrops(TileEntity te, List droppes) { + @Override + protected void getCustomTileEntityDrops(TileEntity te, List droppes) { - } + } - @Override - public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side) { - return false; - } + @Override + public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side) { + return false; + } - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { - return true; - } + @Override + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return true; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/FlowGate.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/FlowGate.java index 4ac32319..419b31f5 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/FlowGate.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/FlowGate.java @@ -35,195 +35,178 @@ import java.util.List; */ public class FlowGate extends BlockDE { - IIcon icon_input; - IIcon icon_output; - IIcon[] icon_fluid = new IIcon[4]; - IIcon[] icon_flux = new IIcon[4]; + IIcon icon_input; + IIcon icon_output; + IIcon[] icon_fluid = new IIcon[4]; + IIcon[] icon_flux = new IIcon[4]; - public FlowGate(){ - this.setBlockName("flowGate"); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); + public FlowGate() { + this.setBlockName("flowGate"); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModBlocks.register(this, ItemBlockFrowGate.class); - } + ModBlocks.register(this, ItemBlockFrowGate.class); + } - @Override - public boolean hasTileEntity(int metadata) { - return true; - } + @Override + public boolean hasTileEntity(int metadata) { + return true; + } - @Override - public TileEntity createTileEntity(World world, int metadata) { - return metadata < 6 ? new TileFluxGate() : new TileFluidGate(); - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + return metadata < 6 ? new TileFluxGate() : new TileFluidGate(); + } - @Override - public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) { - list.add(new ItemStack(item)); - list.add(new ItemStack(item, 1, 6)); - } + @Override + public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) { + list.add(new ItemStack(item)); + list.add(new ItemStack(item, 1, 6)); + } - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); - icon_input = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_io_i"); - icon_output = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_io_o"); - for (int i = 0; i < 4; i++){ - icon_fluid[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "gates/fluidGate" + i); - icon_flux[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "gates/fluxGate" + i); - } - } + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); + icon_input = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_io_i"); + icon_output = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_io_o"); + for (int i = 0; i < 4; i++) { + icon_fluid[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "gates/fluidGate" + i); + icon_flux[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "gates/fluxGate" + i); + } + } - @SideOnly(Side.CLIENT) - @Override - public IIcon getIcon(int side, int meta) { - int f = meta % 6; - int type = meta / 6; + @SideOnly(Side.CLIENT) + @Override + public IIcon getIcon(int side, int meta) { + int f = meta % 6; + int type = meta / 6; - if (side == f) return icon_output; - else if (ForgeDirection.getOrientation(side).getOpposite().ordinal() == f) return icon_input; - else { - int t = 0; - if (f == 0) t = 1; - else if (f == 1) t = 3; - else if (f == 2) { - t = (side == 0 ? 3 : (side == 1 ? 3 : (side == 4 ? 2 : 0))); - } - else if (f == 3) { - t = (side == 0 ? 1 : (side == 1 ? 1 : (side == 4 ? 0 : 2))); - } - else if (f == 4) { - t = (side == 0 ? 2 : (side == 1 ? 2 : (side == 2 ? 0 : 2))); - } - else if (f == 5) { - t = (side == 0 ? 0 : (side == 1 ? 0 : (side == 2 ? 2 : 0))); - } - return type == 0 ? icon_flux[t] : icon_fluid[t]; - } - } + if (side == f) return icon_output; + else if (ForgeDirection.getOrientation(side).getOpposite().ordinal() == f) return icon_input; + else { + int t = 0; + if (f == 0) t = 1; + else if (f == 1) t = 3; + else if (f == 2) { + t = (side == 0 ? 3 : (side == 1 ? 3 : (side == 4 ? 2 : 0))); + } else if (f == 3) { + t = (side == 0 ? 1 : (side == 1 ? 1 : (side == 4 ? 0 : 2))); + } else if (f == 4) { + t = (side == 0 ? 2 : (side == 1 ? 2 : (side == 2 ? 0 : 2))); + } else if (f == 5) { + t = (side == 0 ? 0 : (side == 1 ? 0 : (side == 2 ? 2 : 0))); + } + return type == 0 ? icon_flux[t] : icon_fluid[t]; + } + } - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - int d = determineOrientation(world, x, y, z, entity) + stack.getItemDamage(); - TileGate gate = (TileGate)world.getTileEntity(x, y, z); - gate.output = ForgeDirection.getOrientation(d % 6); - world.setBlockMetadataWithNotify(x, y, z, d, 2); - } + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + int d = determineOrientation(world, x, y, z, entity) + stack.getItemDamage(); + TileGate gate = (TileGate) world.getTileEntity(x, y, z); + gate.output = ForgeDirection.getOrientation(d % 6); + world.setBlockMetadataWithNotify(x, y, z, d, 2); + } - public static int determineOrientation(World world, int x, int y, int z, EntityLivingBase entity) - { - if (MathHelper.abs((float)entity.posX - (float)x) < 2.0F && MathHelper.abs((float)entity.posZ - (float)z) < 2.0F) - { - double d0 = entity.posY + 1.82D - (double)entity.yOffset; + public static int determineOrientation(World world, int x, int y, int z, EntityLivingBase entity) { + if (MathHelper.abs((float) entity.posX - (float) x) < 2.0F && MathHelper.abs((float) entity.posZ - (float) z) < 2.0F) { + double d0 = entity.posY + 1.82D - (double) entity.yOffset; - if (d0 - (double)y > 2.0D) - { - return 0; - } + if (d0 - (double) y > 2.0D) { + return 0; + } - if ((double)y - d0 > 0.0D) - { - return 1; - } - } + if ((double) y - d0 > 0.0D) { + return 1; + } + } - int l = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - return l == 0 ? 3 : (l == 1 ? 4 : (l == 2 ? 2 : (l == 3 ? 5 : 0))); - } + int l = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + return l == 0 ? 3 : (l == 1 ? 4 : (l == 2 ? 2 : (l == 3 ? 5 : 0))); + } - @Override - public int damageDropped(int meta) { - return (meta / 6) * 6; - } + @Override + public int damageDropped(int meta) { + return (meta / 6) * 6; + } - @Override - public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { - int meta = worldObj.getBlockMetadata(x, y, z); - int type = meta / 6; - ForgeDirection facing = ForgeDirection.getOrientation(meta % 6); + @Override + public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { + int meta = worldObj.getBlockMetadata(x, y, z); + int type = meta / 6; + ForgeDirection facing = ForgeDirection.getOrientation(meta % 6); - if (facing == axis || facing == axis.getOpposite()) return false; - else if (axis == ForgeDirection.UP || axis == ForgeDirection.DOWN){ - if (facing == ForgeDirection.NORTH){ - facing = ForgeDirection.EAST; - } - else if (facing == ForgeDirection.SOUTH){ - facing = ForgeDirection.WEST; - } - else if (facing == ForgeDirection.EAST){ - facing = ForgeDirection.SOUTH; - } - else if (facing == ForgeDirection.WEST){ - facing = ForgeDirection.NORTH; - } - } - else if (axis == ForgeDirection.NORTH || axis == ForgeDirection.SOUTH){ - if (facing == ForgeDirection.UP){ - facing = ForgeDirection.WEST; - } - else if (facing == ForgeDirection.DOWN){ - facing = ForgeDirection.EAST; - } - else if (facing == ForgeDirection.EAST){ - facing = ForgeDirection.UP; - } - else if (facing == ForgeDirection.WEST){ - facing = ForgeDirection.DOWN; - } - } - else if (axis == ForgeDirection.EAST || axis == ForgeDirection.WEST){ - if (facing == ForgeDirection.UP){ - facing = ForgeDirection.NORTH; - } - else if (facing == ForgeDirection.DOWN){ - facing = ForgeDirection.SOUTH; - } - else if (facing == ForgeDirection.SOUTH){ - facing = ForgeDirection.UP; - } - else if (facing == ForgeDirection.NORTH){ - facing = ForgeDirection.DOWN; - } - } + if (facing == axis || facing == axis.getOpposite()) return false; + else if (axis == ForgeDirection.UP || axis == ForgeDirection.DOWN) { + if (facing == ForgeDirection.NORTH) { + facing = ForgeDirection.EAST; + } else if (facing == ForgeDirection.SOUTH) { + facing = ForgeDirection.WEST; + } else if (facing == ForgeDirection.EAST) { + facing = ForgeDirection.SOUTH; + } else if (facing == ForgeDirection.WEST) { + facing = ForgeDirection.NORTH; + } + } else if (axis == ForgeDirection.NORTH || axis == ForgeDirection.SOUTH) { + if (facing == ForgeDirection.UP) { + facing = ForgeDirection.WEST; + } else if (facing == ForgeDirection.DOWN) { + facing = ForgeDirection.EAST; + } else if (facing == ForgeDirection.EAST) { + facing = ForgeDirection.UP; + } else if (facing == ForgeDirection.WEST) { + facing = ForgeDirection.DOWN; + } + } else if (axis == ForgeDirection.EAST || axis == ForgeDirection.WEST) { + if (facing == ForgeDirection.UP) { + facing = ForgeDirection.NORTH; + } else if (facing == ForgeDirection.DOWN) { + facing = ForgeDirection.SOUTH; + } else if (facing == ForgeDirection.SOUTH) { + facing = ForgeDirection.UP; + } else if (facing == ForgeDirection.NORTH) { + facing = ForgeDirection.DOWN; + } + } - ((TileGate)worldObj.getTileEntity(x, y, z)).output = facing; - worldObj.setBlockMetadataWithNotify(x, y, z, facing.ordinal() + (type * 6), 2); - Utills.updateNeabourBlocks(worldObj, x, y, z); - return true; - } + ((TileGate) worldObj.getTileEntity(x, y, z)).output = facing; + worldObj.setBlockMetadataWithNotify(x, y, z, facing.ordinal() + (type * 6), 2); + Utills.updateNeabourBlocks(worldObj, x, y, z); + return true; + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { - return new ItemStack(this, 1, (world.getBlockMetadata(x, y, z) / 6) * 6); - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { + return new ItemStack(this, 1, (world.getBlockMetadata(x, y, z) / 6) * 6); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - if (world.isRemote && !(player.getHeldItem() != null && player.getHeldItem().getItem().equals(ModItems.wrench))) player.openGui(DraconicEvolution.instance, GuiHandler.GUIID_FLOW_GATE, world, x, y, z); - return true; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + if (world.isRemote && !(player.getHeldItem() != null && player.getHeldItem().getItem().equals(ModItems.wrench))) + player.openGui(DraconicEvolution.instance, GuiHandler.GUIID_FLOW_GATE, world, x, y, z); + return true; + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - updateSignal(world, x, y, z); - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + updateSignal(world, x, y, z); + } - @Override - public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) { - updateSignal(world, x, y, z); - } + @Override + public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) { + updateSignal(world, x, y, z); + } - private void updateSignal(IBlockAccess world, int x, int y, int z){ - TileGate gate = world.getTileEntity(x, y, z) instanceof TileGate ? (TileGate)world.getTileEntity(x, y, z) : null; - if (gate != null && world instanceof World) { - gate.signal = ((World) world).getStrongestIndirectPower(x, y, z); - ((World) world).markBlockForUpdate(x, y, z); - } - } + private void updateSignal(IBlockAccess world, int x, int y, int z) { + TileGate gate = world.getTileEntity(x, y, z) instanceof TileGate ? (TileGate) world.getTileEntity(x, y, z) : null; + if (gate != null && world instanceof World) { + gate.signal = ((World) world).getStrongestIndirectPower(x, y, z); + ((World) world).markBlockForUpdate(x, y, z); + } + } - @Override - public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { - return true; - } + @Override + public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { + return true; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/Generator.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/Generator.java index be6d7168..4d533f13 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/Generator.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/Generator.java @@ -35,260 +35,208 @@ import java.util.Random; */ public class Generator extends BlockCustomDrop { - public IIcon icon_front; - public IIcon icon_side; - public IIcon icon_back; - public IIcon icon_back_inactive; - public IIcon icon_front_inactive; - public IIcon icon_top[] = new IIcon[4]; + public IIcon icon_front; + public IIcon icon_side; + public IIcon icon_back; + public IIcon icon_back_inactive; + public IIcon icon_front_inactive; + public IIcon icon_top[] = new IIcon[4]; - public Generator() { - super(Material.iron); - this.setBlockName(Strings.generatorName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setStepSound(soundTypeStone); - ModBlocks.register(this); + public Generator() { + super(Material.iron); + this.setBlockName(Strings.generatorName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setStepSound(soundTypeStone); + ModBlocks.register(this); - } + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iconRegister) - { - icon_front = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/generator_front_active"); - icon_front_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "generator_front"); - icon_side = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); - icon_back = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/machine_fan"); - icon_back_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_fan"); - for (int i = 0; i < 4; i++) - { - icon_top[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_top_" + i); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iconRegister) { + icon_front = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/generator_front_active"); + icon_front_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "generator_front"); + icon_side = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); + icon_back = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/machine_fan"); + icon_back_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_fan"); + for (int i = 0; i < 4; i++) { + icon_top[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_top_" + i); + } - } + } - @SuppressWarnings({ "rawtypes", "unchecked" }) - @SideOnly(Side.CLIENT) - @Override - public void getSubBlocks(final Item item, final CreativeTabs tab, final List par3list) - { - par3list.add(new ItemStack(item, 1, 3)); - } + @SuppressWarnings({"rawtypes", "unchecked"}) + @SideOnly(Side.CLIENT) + @Override + public void getSubBlocks(final Item item, final CreativeTabs tab, final List par3list) { + par3list.add(new ItemStack(item, 1, 3)); + } - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) { - TileGenerator tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileGenerator) ? (TileGenerator) world.getTileEntity(x, y, z) : null; - if (tile == null) - { - LogHelper.error("Missing Tile Entity (Generator)"); - return 0; - } - return tile.isBurning ? 13 : 0; - } + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + TileGenerator tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileGenerator) ? (TileGenerator) world.getTileEntity(x, y, z) : null; + if (tile == null) { + LogHelper.error("Missing Tile Entity (Generator)"); + return 0; + } + return tile.isBurning ? 13 : 0; + } - @Override - public int damageDropped(int p_149692_1_) - { - return 3; - } + @Override + public int damageDropped(int p_149692_1_) { + return 3; + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) - { - TileGenerator tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileGenerator) ? (TileGenerator) world.getTileEntity(x, y, z) : null; - if (tile == null) - { - LogHelper.error("Missing Tile Entity (Generator)"); - return null; - } - int meta = world.getBlockMetadata(x, y, z); + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + TileGenerator tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileGenerator) ? (TileGenerator) world.getTileEntity(x, y, z) : null; + if (tile == null) { + LogHelper.error("Missing Tile Entity (Generator)"); + return null; + } + int meta = world.getBlockMetadata(x, y, z); - IIcon back; - IIcon front; + IIcon back; + IIcon front; - if (tile.isBurning) - { - back = icon_back; - front = icon_front; - } - else - { - back = icon_back_inactive; - front = icon_front_inactive; - } + if (tile.isBurning) { + back = icon_back; + front = icon_front; + } else { + back = icon_back_inactive; + front = icon_front_inactive; + } - switch (side) - { - case 0: - return icon_side; - case 1: - return icon_top[meta]; - case 2: - if (meta == 0) - return front; - else if (meta == 2) - return back; - else - return icon_side; - case 3: - if (meta == 2) - return front; - else if (meta == 0) - return back; - else - return icon_side; - case 4: - if (meta == 3) - return front; - else if (meta == 1) - return back; - else - return icon_side; - case 5: - if (meta == 1) - return front; - else if (meta == 3) - return back; - else - return icon_side; - } - return null; - } + switch (side) { + case 0: + return icon_side; + case 1: + return icon_top[meta]; + case 2: + if (meta == 0) return front; + else if (meta == 2) return back; + else return icon_side; + case 3: + if (meta == 2) return front; + else if (meta == 0) return back; + else return icon_side; + case 4: + if (meta == 3) return front; + else if (meta == 1) return back; + else return icon_side; + case 5: + if (meta == 1) return front; + else if (meta == 3) return back; + else return icon_side; + } + return null; + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - switch (side) - { - case 0: - return icon_side; - case 1: - return icon_top[meta]; - case 2: - if (meta == 0) - return icon_front; - else if (meta == 2) - return icon_back; - else - return icon_side; - case 3: - if (meta == 2) - return icon_front; - else if (meta == 0) - return icon_back; - else - return icon_side; - case 4: - if (meta == 3) - return icon_front; - else if (meta == 1) - return icon_back; - else - return icon_side; - case 5: - if (meta == 1) - return icon_front; - else if (meta == 3) - return icon_back; - else - return icon_side; - } - return null; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + switch (side) { + case 0: + return icon_side; + case 1: + return icon_top[meta]; + case 2: + if (meta == 0) return icon_front; + else if (meta == 2) return icon_back; + else return icon_side; + case 3: + if (meta == 2) return icon_front; + else if (meta == 0) return icon_back; + else return icon_side; + case 4: + if (meta == 3) return icon_front; + else if (meta == 1) return icon_back; + else return icon_side; + case 5: + if (meta == 1) return icon_front; + else if (meta == 3) return icon_back; + else return icon_side; + } + return null; + } - @Override - public TileEntity createNewTileEntity(World var1, int var2) - { - return new TileGenerator(); - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileGenerator(); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float prx, float pry, float prz) - { - if (!world.isRemote) { - FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_GENERATOR, world, x, y, z); - } - return true; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float prx, float pry, float prz) { + if (!world.isRemote) { + FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_GENERATOR, world, x, y, z); + } + return true; + } - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase placer, ItemStack stack) - { - int l = MathHelper.floor_double((double) (placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - if (l == 0) - { - world.setBlockMetadataWithNotify(x, y, z, 0, 2); - } + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase placer, ItemStack stack) { + int l = MathHelper.floor_double((double) (placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + if (l == 0) { + world.setBlockMetadataWithNotify(x, y, z, 0, 2); + } - if (l == 1) - { - world.setBlockMetadataWithNotify(x, y, z, 1, 2); - } + if (l == 1) { + world.setBlockMetadataWithNotify(x, y, z, 1, 2); + } - if (l == 2) - { - world.setBlockMetadataWithNotify(x, y, z, 2, 2); - } + if (l == 2) { + world.setBlockMetadataWithNotify(x, y, z, 2, 2); + } - if (l == 3) - { - world.setBlockMetadataWithNotify(x, y, z, 3, 2); - } - } + if (l == 3) { + world.setBlockMetadataWithNotify(x, y, z, 3, 2); + } + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof TileGrinder) - { - ((TileGrinder)tile).disabled = world.isBlockIndirectlyGettingPowered(x, y, z); - world.markBlockForUpdate(x, y, z); - } - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof TileGrinder) { + ((TileGrinder) tile).disabled = world.isBlockIndirectlyGettingPowered(x, y, z); + world.markBlockForUpdate(x, y, z); + } + } - @Override - protected boolean dropInventory() { - return true; - } + @Override + protected boolean dropInventory() { + return true; + } - @Override - protected boolean hasCustomDropps() { - return false; - } + @Override + protected boolean hasCustomDropps() { + return false; + } - @Override - protected void getCustomTileEntityDrops(TileEntity te, List droppes) { + @Override + protected void getCustomTileEntityDrops(TileEntity te, List droppes) { - } + } - @Override - public void randomDisplayTick(World world, int x, int y, int z, Random random) { - TileGenerator tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileGenerator) ? (TileGenerator) world.getTileEntity(x, y, z) : null; - if (tile == null) - { - LogHelper.error("Missing Tile Entity (Generator)"); - return; - } - if(tile.burnTimeRemaining > 0 && tile.getEnergyStored(ForgeDirection.UP) < tile.getMaxEnergyStored(ForgeDirection.UP)) - { - double ox = 0; - double oz = 0; - if (world.getBlockMetadata(x, y, z) == 0) - oz = -0.5; - if (world.getBlockMetadata(x, y, z) == 1) - ox = 0.5; - if (world.getBlockMetadata(x, y, z) == 2) - oz = 0.5; - if (world.getBlockMetadata(x, y, z) == 3) - ox = -0.5; + @Override + public void randomDisplayTick(World world, int x, int y, int z, Random random) { + TileGenerator tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileGenerator) ? (TileGenerator) world.getTileEntity(x, y, z) : null; + if (tile == null) { + LogHelper.error("Missing Tile Entity (Generator)"); + return; + } + if (tile.burnTimeRemaining > 0 && tile.getEnergyStored(ForgeDirection.UP) < tile.getMaxEnergyStored(ForgeDirection.UP)) { + double ox = 0; + double oz = 0; + if (world.getBlockMetadata(x, y, z) == 0) oz = -0.5; + if (world.getBlockMetadata(x, y, z) == 1) ox = 0.5; + if (world.getBlockMetadata(x, y, z) == 2) oz = 0.5; + if (world.getBlockMetadata(x, y, z) == 3) ox = -0.5; - world.spawnParticle("flame", ox + x + 0.5 + (Math.abs(ox)-0.5) * ((random.nextDouble() - 0.5)*1), y + 0.3 + (random.nextDouble() * 0.5), oz + z + 0.5 + (Math.abs(oz)-0.5) * ((random.nextDouble() - 0.5)*1), (ox*0.05)*random.nextDouble(), (random.nextDouble() - 0.2)*0.03, (oz*0.05)*random.nextDouble()); - world.spawnParticle("smoke", ox + x + 0.5 + (Math.abs(ox)-0.5) * ((random.nextDouble() - 0.5)*1), y + 0.3 + (random.nextDouble() * 0.5), oz + z + 0.5 + (Math.abs(oz)-0.5) * ((random.nextDouble() - 0.5)*1), (ox*0.05)*random.nextDouble(), (random.nextDouble() - 0.2)*0.03, (oz*0.05)*random.nextDouble()); + world.spawnParticle("flame", ox + x + 0.5 + (Math.abs(ox) - 0.5) * ((random.nextDouble() - 0.5) * 1), y + 0.3 + (random.nextDouble() * 0.5), oz + z + 0.5 + (Math.abs(oz) - 0.5) * ((random.nextDouble() - 0.5) * 1), (ox * 0.05) * random.nextDouble(), (random.nextDouble() - 0.2) * 0.03, (oz * 0.05) * random.nextDouble()); + world.spawnParticle("smoke", ox + x + 0.5 + (Math.abs(ox) - 0.5) * ((random.nextDouble() - 0.5) * 1), y + 0.3 + (random.nextDouble() * 0.5), oz + z + 0.5 + (Math.abs(oz) - 0.5) * ((random.nextDouble() - 0.5) * 1), (ox * 0.05) * random.nextDouble(), (random.nextDouble() - 0.2) * 0.03, (oz * 0.05) * random.nextDouble()); - world.playSound((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), "fire.fire", 0.2F + (random.nextFloat()*0.1F), random.nextFloat() * 0.7F + 0.5F, false); - } - } + world.playSound((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), "fire.fire", 0.2F + (random.nextFloat() * 0.1F), random.nextFloat() * 0.7F + 0.5F, false); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/Grinder.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/Grinder.java index 8b78a26c..2957934f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/Grinder.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/Grinder.java @@ -27,235 +27,190 @@ import net.minecraft.world.World; import java.util.List; -public class Grinder extends BlockCustomDrop -{ - public IIcon icon_front; - public IIcon icon_side; - public IIcon icon_back; - public IIcon icon_back_inactive; - public IIcon icon_front_inactive; - public IIcon icon_top[] = new IIcon[4]; +public class Grinder extends BlockCustomDrop { + public IIcon icon_front; + public IIcon icon_side; + public IIcon icon_back; + public IIcon icon_back_inactive; + public IIcon icon_front_inactive; + public IIcon icon_top[] = new IIcon[4]; - public Grinder() { - super(Material.iron); - this.setBlockName(Strings.grinderName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setStepSound(soundTypeStone); - this.setResistance(2000.0f); - ModBlocks.register(this); + public Grinder() { + super(Material.iron); + this.setBlockName(Strings.grinderName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setStepSound(soundTypeStone); + this.setResistance(2000.0f); + ModBlocks.register(this); - } + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iconRegister) - { - icon_front = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/grinder_front_active"); - icon_front_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "grinder_front"); - icon_side = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); - icon_back = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/machine_fan"); - icon_back_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_fan"); - for (int i = 0; i < 4; i++) - { - icon_top[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_top_" + i); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iconRegister) { + icon_front = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/grinder_front_active"); + icon_front_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "grinder_front"); + icon_side = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); + icon_back = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/machine_fan"); + icon_back_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_fan"); + for (int i = 0; i < 4; i++) { + icon_top[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_top_" + i); + } - } + } - @Override - public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) {} - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @SideOnly(Side.CLIENT) - @Override - public void getSubBlocks(final Item item, final CreativeTabs tab, final List par3list) - { - par3list.add(new ItemStack(item, 1, 3)); - } - - @Override - public int damageDropped(int p_149692_1_) - { - return 3; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) - { - TileGrinder tile = (TileGrinder) world.getTileEntity(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - IIcon back; - IIcon front; + @Override + public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) { + } - if (!tile.disabled && tile.hasPower) - { - back = icon_back; - front = icon_front; - } - else - { - back = icon_back_inactive; - front = icon_front_inactive; - } - - switch (side) - { - case 0: - return icon_side; - case 1: - return icon_top[meta]; - case 2: - if (meta == 0) - return front; - else if (meta == 2) - return back; - else - return icon_side; - case 3: - if (meta == 2) - return front; - else if (meta == 0) - return back; - else - return icon_side; - case 4: - if (meta == 3) - return front; - else if (meta == 1) - return back; - else - return icon_side; - case 5: - if (meta == 1) - return front; - else if (meta == 3) - return back; - else - return icon_side; - } - return null; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - switch (side) - { - case 0: - return icon_side; - case 1: - return icon_top[meta]; - case 2: - if (meta == 0) - return icon_front; - else if (meta == 2) - return icon_back; - else - return icon_side; - case 3: - if (meta == 2) - return icon_front; - else if (meta == 0) - return icon_back; - else - return icon_side; - case 4: - if (meta == 3) - return icon_front; - else if (meta == 1) - return icon_back; - else - return icon_side; - case 5: - if (meta == 1) - return icon_front; - else if (meta == 3) - return icon_back; - else - return icon_side; - } - return null; - } - - @Override - public TileEntity createNewTileEntity(World var1, int var2) - { - return new TileGrinder(); - } - - @Override - public boolean onBlockActivated(World world, int X, int Y, int Z, EntityPlayer player, int side, float prx, float pry, float prz) - { - TileEntity tile = world.getTileEntity(X, Y, Z); - if (!(tile instanceof TileGrinder)) - { - return false; - } - if (!world.isRemote && ! player.isSneaking()) { - FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_GRINDER, world, X, Y, Z); - } else if (player.isSneaking()){ - for (double x = ((TileGrinder)tile).centreX - 4; x <= ((TileGrinder)tile).centreX + 4; x++) { - for (double y = ((TileGrinder)tile).centreY - 4; y <= ((TileGrinder)tile).centreY + 4; y++) { - for (double z = ((TileGrinder)tile).centreZ - 4; z <= ((TileGrinder)tile).centreZ + 4; z++) { - world.spawnParticle("flame", x, y, z, 0D, 0D, 0D); - } - } - } - } - return true; - } + @SuppressWarnings({"rawtypes", "unchecked"}) + @SideOnly(Side.CLIENT) + @Override + public void getSubBlocks(final Item item, final CreativeTabs tab, final List par3list) { + par3list.add(new ItemStack(item, 1, 3)); + } - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase placer, ItemStack stack) - { - int l = MathHelper.floor_double((double)(placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - if (l == 0) - { + @Override + public int damageDropped(int p_149692_1_) { + return 3; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + TileGrinder tile = (TileGrinder) world.getTileEntity(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + IIcon back; + IIcon front; + + if (!tile.disabled && tile.hasPower) { + back = icon_back; + front = icon_front; + } else { + back = icon_back_inactive; + front = icon_front_inactive; + } + + switch (side) { + case 0: + return icon_side; + case 1: + return icon_top[meta]; + case 2: + if (meta == 0) return front; + else if (meta == 2) return back; + else return icon_side; + case 3: + if (meta == 2) return front; + else if (meta == 0) return back; + else return icon_side; + case 4: + if (meta == 3) return front; + else if (meta == 1) return back; + else return icon_side; + case 5: + if (meta == 1) return front; + else if (meta == 3) return back; + else return icon_side; + } + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + switch (side) { + case 0: + return icon_side; + case 1: + return icon_top[meta]; + case 2: + if (meta == 0) return icon_front; + else if (meta == 2) return icon_back; + else return icon_side; + case 3: + if (meta == 2) return icon_front; + else if (meta == 0) return icon_back; + else return icon_side; + case 4: + if (meta == 3) return icon_front; + else if (meta == 1) return icon_back; + else return icon_side; + case 5: + if (meta == 1) return icon_front; + else if (meta == 3) return icon_back; + else return icon_side; + } + return null; + } + + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileGrinder(); + } + + @Override + public boolean onBlockActivated(World world, int X, int Y, int Z, EntityPlayer player, int side, float prx, float pry, float prz) { + TileEntity tile = world.getTileEntity(X, Y, Z); + if (!(tile instanceof TileGrinder)) { + return false; + } + if (!world.isRemote && !player.isSneaking()) { + FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_GRINDER, world, X, Y, Z); + } else if (player.isSneaking()) { + for (double x = ((TileGrinder) tile).centreX - 4; x <= ((TileGrinder) tile).centreX + 4; x++) { + for (double y = ((TileGrinder) tile).centreY - 4; y <= ((TileGrinder) tile).centreY + 4; y++) { + for (double z = ((TileGrinder) tile).centreZ - 4; z <= ((TileGrinder) tile).centreZ + 4; z++) { + world.spawnParticle("flame", x, y, z, 0D, 0D, 0D); + } + } + } + } + return true; + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase placer, ItemStack stack) { + int l = MathHelper.floor_double((double) (placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + if (l == 0) { world.setBlockMetadataWithNotify(x, y, z, 0, 2); } - if (l == 1) - { + if (l == 1) { world.setBlockMetadataWithNotify(x, y, z, 1, 2); } - if (l == 2) - { + if (l == 2) { world.setBlockMetadataWithNotify(x, y, z, 2, 2); } - if (l == 3) - { + if (l == 3) { world.setBlockMetadataWithNotify(x, y, z, 3, 2); } } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof TileGrinder) - { - ((TileGrinder)tile).disabled = world.isBlockIndirectlyGettingPowered(x, y, z); - world.markBlockForUpdate(x, y, z); - } - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof TileGrinder) { + ((TileGrinder) tile).disabled = world.isBlockIndirectlyGettingPowered(x, y, z); + world.markBlockForUpdate(x, y, z); + } + } - @Override - protected boolean dropInventory() { - return true; - } + @Override + protected boolean dropInventory() { + return true; + } - @Override - protected boolean hasCustomDropps() { - return false; - } + @Override + protected boolean hasCustomDropps() { + return false; + } - @Override - protected void getCustomTileEntityDrops(TileEntity te, List droppes) { + @Override + protected void getCustomTileEntityDrops(TileEntity te, List droppes) { - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/LongRangeDislocator.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/LongRangeDislocator.java index eecbc22a..cd2037f8 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/LongRangeDislocator.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/LongRangeDislocator.java @@ -31,131 +31,116 @@ import java.util.Random; */ public class LongRangeDislocator extends BlockDE { - IIcon blockIconTop; + IIcon blockIconTop; - public LongRangeDislocator() { - this.setBlockName(Strings.longRangeDislocatorName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModBlocks.register(this, LRDItemBlock.class); - } + public LongRangeDislocator() { + this.setBlockName(Strings.longRangeDislocatorName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + ModBlocks.register(this, LRDItemBlock.class); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iconRegister) - { - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "teleporter_front"); - blockIconTop = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_top_0"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "teleporter_front"); + blockIconTop = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_top_0"); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int side, final int meta) - { - if (side == 0 || side == 1) - return blockIconTop; - else - return blockIcon; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int side, final int meta) { + if (side == 0 || side == 1) return blockIconTop; + else return blockIcon; + } - @SideOnly(Side.CLIENT) - @Override - public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) { - //list.add(new ItemStack(item, 1, 0)); - list.add(new ItemStack(item, 1, 1)); - } + @SideOnly(Side.CLIENT) + @Override + public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) { + //list.add(new ItemStack(item, 1, 0)); + list.add(new ItemStack(item, 1, 1)); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - int meta = world.getBlockMetadata(x,y,z); - if (meta == 0) - return false;//return teleportPlayer(world, player, false); - else if (meta == 1) - return false; - else{ - LogHelper.error("Invalid LRT Metadata"); - return false; - } - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0) return false;//return teleportPlayer(world, player, false); + else if (meta == 1) return false; + else { + LogHelper.error("Invalid LRT Metadata"); + return false; + } + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_) { - EntityPlayer player; - if (world.getBlockMetadata(x, y, z) == 1 && world.isBlockIndirectlyGettingPowered(x, y, z)) - { - player = world.getClosestPlayer(x, y, z, ConfigHandler.admin_dislocator_Detect_Range); - if (player != null) - { - teleportPlayer(world, player, true); - } - } - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_) { + EntityPlayer player; + if (world.getBlockMetadata(x, y, z) == 1 && world.isBlockIndirectlyGettingPowered(x, y, z)) { + player = world.getClosestPlayer(x, y, z, ConfigHandler.admin_dislocator_Detect_Range); + if (player != null) { + teleportPlayer(world, player, true); + } + } + } - private boolean teleportPlayer(World world, EntityPlayer player, boolean admin){ - if (world.isRemote) return true; - Random rand = new Random(); + private boolean teleportPlayer(World world, EntityPlayer player, boolean admin) { + if (world.isRemote) return true; + Random rand = new Random(); - if (admin) - { - int randX = ConfigHandler.admin_dislocator_Min_Range + rand.nextInt(ConfigHandler.admin_dislocator_Max_Range - ConfigHandler.admin_dislocator_Min_Range); - int randZ = ConfigHandler.admin_dislocator_Min_Range + rand.nextInt(ConfigHandler.admin_dislocator_Max_Range - ConfigHandler.admin_dislocator_Min_Range); - randX = rand.nextBoolean() ? randX * -1 : randX * 1; - randZ = rand.nextBoolean() ? randZ * -1 : randZ * 1; - randX += (int)player.posX; - randZ += (int)player.posZ; - int y = 255; - for (int i = 255; i > 1; i--) - { - if (world.getBlock(randX, i, randZ) != Blocks.air) - { - y = i; - break; - } - } - player.addChatComponentMessage(new ChatComponentText(""+ EnumChatFormatting.RED+"[WARNING]"+EnumChatFormatting.WHITE+" Do not move until the world loads!")); - if (world.getBlock(randX, y, randZ).isBlockSolid(world, randX, y, randZ, 0)) - { - world.setBlock(randX, y, randZ, world.getBlock(randX, y, randZ)); - player.setLocationAndAngles(randX + 0.5, y + 1.5, randZ + 0.5, 0F, 0F); - player.setPositionAndUpdate(randX + 0.5, y + 1.5, randZ + 0.5); - }else{ - world.setBlock(randX, y, randZ, Blocks.stone); - player.setLocationAndAngles(randX + 0.5, y + 1.5, randZ + 0.5, 0F, 0F); - player.setPositionAndUpdate(randX + 0.5, y + 1.5, randZ + 0.5); - } + if (admin) { + int randX = ConfigHandler.admin_dislocator_Min_Range + rand.nextInt(ConfigHandler.admin_dislocator_Max_Range - ConfigHandler.admin_dislocator_Min_Range); + int randZ = ConfigHandler.admin_dislocator_Min_Range + rand.nextInt(ConfigHandler.admin_dislocator_Max_Range - ConfigHandler.admin_dislocator_Min_Range); + randX = rand.nextBoolean() ? randX * -1 : randX * 1; + randZ = rand.nextBoolean() ? randZ * -1 : randZ * 1; + randX += (int) player.posX; + randZ += (int) player.posZ; + int y = 255; + for (int i = 255; i > 1; i--) { + if (world.getBlock(randX, i, randZ) != Blocks.air) { + y = i; + break; + } + } + player.addChatComponentMessage(new ChatComponentText("" + EnumChatFormatting.RED + "[WARNING]" + EnumChatFormatting.WHITE + " Do not move until the world loads!")); + if (world.getBlock(randX, y, randZ).isBlockSolid(world, randX, y, randZ, 0)) { + world.setBlock(randX, y, randZ, world.getBlock(randX, y, randZ)); + player.setLocationAndAngles(randX + 0.5, y + 1.5, randZ + 0.5, 0F, 0F); + player.setPositionAndUpdate(randX + 0.5, y + 1.5, randZ + 0.5); + } else { + world.setBlock(randX, y, randZ, Blocks.stone); + player.setLocationAndAngles(randX + 0.5, y + 1.5, randZ + 0.5, 0F, 0F); + player.setPositionAndUpdate(randX + 0.5, y + 1.5, randZ + 0.5); + } - return true; - }else{ - int randX = ConfigHandler.dislocator_Min_Range + rand.nextInt(ConfigHandler.dislocator_Max_Range - ConfigHandler.dislocator_Min_Range); - int randZ = ConfigHandler.dislocator_Min_Range + rand.nextInt(ConfigHandler.dislocator_Max_Range - ConfigHandler.dislocator_Min_Range); - randX = rand.nextBoolean() ? randX * -1 : randX * 1; - randZ = rand.nextBoolean() ? randZ * -1 : randZ * 1; - int y = 255; - for (int i = 255; i > 1; i--) - { - if (world.getBlock(randX, i, randZ) != Blocks.air) - { - //LogHelper.info(world.getBlock(randX, i, randZ)); - y = i; - break; - } - } + return true; + } else { + int randX = ConfigHandler.dislocator_Min_Range + rand.nextInt(ConfigHandler.dislocator_Max_Range - ConfigHandler.dislocator_Min_Range); + int randZ = ConfigHandler.dislocator_Min_Range + rand.nextInt(ConfigHandler.dislocator_Max_Range - ConfigHandler.dislocator_Min_Range); + randX = rand.nextBoolean() ? randX * -1 : randX * 1; + randZ = rand.nextBoolean() ? randZ * -1 : randZ * 1; + int y = 255; + for (int i = 255; i > 1; i--) { + if (world.getBlock(randX, i, randZ) != Blocks.air) { + //LogHelper.info(world.getBlock(randX, i, randZ)); + y = i; + break; + } + } - if (world.getBlock(randX, y, randZ).isBlockSolid(world, randX, y, randZ, 0)) - { - world.setBlock(randX, y, randZ, world.getBlock(randX, y, randZ)); - player.setLocationAndAngles(randX + 0.5, y + 1.5, randZ + 0.5, 0F, 0F); - player.setPositionAndUpdate(randX + 0.5, y + 1.5, randZ + 0.5); - }else{ - world.setBlock(randX, y, randZ, Blocks.stone); - player.setLocationAndAngles(randX + 0.5, y + 1.5, randZ + 0.5, 0F, 0F); - player.setPositionAndUpdate(randX + 0.5, y + 1.5, randZ + 0.5); - } - } - return true; - } + if (world.getBlock(randX, y, randZ).isBlockSolid(world, randX, y, randZ, 0)) { + world.setBlock(randX, y, randZ, world.getBlock(randX, y, randZ)); + player.setLocationAndAngles(randX + 0.5, y + 1.5, randZ + 0.5, 0F, 0F); + player.setPositionAndUpdate(randX + 0.5, y + 1.5, randZ + 0.5); + } else { + world.setBlock(randX, y, randZ, Blocks.stone); + player.setLocationAndAngles(randX + 0.5, y + 1.5, randZ + 0.5, 0F, 0F); + player.setPositionAndUpdate(randX + 0.5, y + 1.5, randZ + 0.5); + } + } + return true; + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - return new ItemStack(ModBlocks.longRangeDislocator, 1, world.getBlockMetadata(x, y, z)); - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + return new ItemStack(ModBlocks.longRangeDislocator, 1, world.getBlockMetadata(x, y, z)); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/PlayerDetector.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/PlayerDetector.java index 2bc5acff..7252c91b 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/PlayerDetector.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/PlayerDetector.java @@ -17,155 +17,125 @@ import com.brandon3055.draconicevolution.common.lib.Strings; import com.brandon3055.draconicevolution.common.tileentities.TilePlayerDetector; import net.minecraftforge.common.util.ForgeDirection; -public class PlayerDetector extends BlockDE -{ - IIcon side_inactive; - IIcon side_active; - IIcon top; - IIcon bottom; +public class PlayerDetector extends BlockDE { + IIcon side_inactive; + IIcon side_active; + IIcon top; + IIcon bottom; - public PlayerDetector() { - this.setBlockName(Strings.playerDetectorName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setStepSound(soundTypeStone); - ModBlocks.register(this); - } - - @Override - public void registerBlockIcons(IIconRegister iconRegister) - { - side_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "player_detector_side_inactive"); - side_active = iconRegister.registerIcon(References.RESOURCESPREFIX + "player_detector_side_active"); - top = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_top_0"); - bottom = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); - } - - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) - { - IIcon side_icon; - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null && tile instanceof TilePlayerDetector && ((TilePlayerDetector)tile).output) - side_icon = side_active; - else - side_icon = side_inactive; + public PlayerDetector() { + this.setBlockName(Strings.playerDetectorName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setStepSound(soundTypeStone); + ModBlocks.register(this); + } - if (side == 0) - return bottom; - else if (side == 1) - return top; - else - return side_icon; - } + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + side_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "player_detector_side_inactive"); + side_active = iconRegister.registerIcon(References.RESOURCESPREFIX + "player_detector_side_active"); + top = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_top_0"); + bottom = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); + } - @Override - public IIcon getIcon(int side, int meta) - { - if (side == 0) - return bottom; - else if (side == 1) - return top; - else - return side_active; - } + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + IIcon side_icon; + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null && tile instanceof TilePlayerDetector && ((TilePlayerDetector) tile).output) + side_icon = side_active; + else side_icon = side_inactive; - @Override - public boolean isBlockSolid(IBlockAccess p_149747_1_, int p_149747_2_, int p_149747_3_, int p_149747_4_, int p_149747_5_) { - return true; - } + if (side == 0) return bottom; + else if (side == 1) return top; + else return side_icon; + } - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { - return true; - } + @Override + public IIcon getIcon(int side, int meta) { + if (side == 0) return bottom; + else if (side == 1) return top; + else return side_active; + } - @Override - public boolean hasTileEntity(int meta) - { - return true; - } + @Override + public boolean isBlockSolid(IBlockAccess p_149747_1_, int p_149747_2_, int p_149747_3_, int p_149747_4_, int p_149747_5_) { + return true; + } - @Override - public TileEntity createTileEntity(World world, int metadata) - { - return new TilePlayerDetector(); - } + @Override + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return true; + } - @Override - public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) - { - if (side == 0 || side == 1) - return false; - else - return true; - } + @Override + public boolean hasTileEntity(int meta) { + return true; + } - @Override - public boolean canProvidePower() - { - return true; - } - - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int meta) - { - TileEntity te = world.getTileEntity(x, y, z); - TilePlayerDetector detector = (te != null && te instanceof TilePlayerDetector) ? (TilePlayerDetector) te : null; - if(detector != null) - return detector.output ? 15 : 0; - else - return 0; - } - - @Override - public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int meta) - { - TileEntity te = world.getTileEntity(x, y, z); - TilePlayerDetector detector = (te != null && te instanceof TilePlayerDetector) ? (TilePlayerDetector) te : null; - if(detector != null) - return detector.output ? 15 : 0; - else - return 0; - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TilePlayerDetector(); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float p_149727_7_, float p_149727_8_, float p_149727_9_) - { - TileEntity te = world.getTileEntity(x, y, z); - TilePlayerDetector detector = (te != null && te instanceof TilePlayerDetector) ? (TilePlayerDetector) te : null; - if(detector != null) - { - int range = detector.getRange(); - - if(player.isSneaking()) - { - range--; - }else - { - range++; - } - - if (range > 10) - range = 1; - if (range < 1) - range = 10; - detector.setRange(range); - - if (world.isRemote) - player.addChatMessage(new ChatComponentTranslation("msg.range.txt").appendSibling(new ChatComponentText(" " + range))); - } - return true; - } + @Override + public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { + if (side == 0 || side == 1) return false; + else return true; + } - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int meta) - { - super.breakBlock(world, x, y, z, block, meta); + @Override + public boolean canProvidePower() { + return true; + } - world.notifyBlocksOfNeighborChange(x - 1, y, z, world.getBlock(x, y, z)); - world.notifyBlocksOfNeighborChange(x + 1, y, z, world.getBlock(x, y, z)); - world.notifyBlocksOfNeighborChange(x, y - 1, z, world.getBlock(x, y, z)); - world.notifyBlocksOfNeighborChange(x, y + 1, z, world.getBlock(x, y, z)); - world.notifyBlocksOfNeighborChange(x, y, z - 1, world.getBlock(x, y, z)); - world.notifyBlocksOfNeighborChange(x, y, z + 1, world.getBlock(x, y, z)); - } + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int meta) { + TileEntity te = world.getTileEntity(x, y, z); + TilePlayerDetector detector = (te != null && te instanceof TilePlayerDetector) ? (TilePlayerDetector) te : null; + if (detector != null) return detector.output ? 15 : 0; + else return 0; + } + + @Override + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int meta) { + TileEntity te = world.getTileEntity(x, y, z); + TilePlayerDetector detector = (te != null && te instanceof TilePlayerDetector) ? (TilePlayerDetector) te : null; + if (detector != null) return detector.output ? 15 : 0; + else return 0; + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + TileEntity te = world.getTileEntity(x, y, z); + TilePlayerDetector detector = (te != null && te instanceof TilePlayerDetector) ? (TilePlayerDetector) te : null; + if (detector != null) { + int range = detector.getRange(); + + if (player.isSneaking()) { + range--; + } else { + range++; + } + + if (range > 10) range = 1; + if (range < 1) range = 10; + detector.setRange(range); + + if (world.isRemote) + player.addChatMessage(new ChatComponentTranslation("msg.range.txt").appendSibling(new ChatComponentText(" " + range))); + } + return true; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + super.breakBlock(world, x, y, z, block, meta); + + world.notifyBlocksOfNeighborChange(x - 1, y, z, world.getBlock(x, y, z)); + world.notifyBlocksOfNeighborChange(x + 1, y, z, world.getBlock(x, y, z)); + world.notifyBlocksOfNeighborChange(x, y - 1, z, world.getBlock(x, y, z)); + world.notifyBlocksOfNeighborChange(x, y + 1, z, world.getBlock(x, y, z)); + world.notifyBlocksOfNeighborChange(x, y, z - 1, world.getBlock(x, y, z)); + world.notifyBlocksOfNeighborChange(x, y, z + 1, world.getBlock(x, y, z)); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/PlayerDetectorAdvanced.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/PlayerDetectorAdvanced.java index ac31c61a..e85927a0 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/PlayerDetectorAdvanced.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/PlayerDetectorAdvanced.java @@ -24,165 +24,134 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.List; -public class PlayerDetectorAdvanced extends BlockCustomDrop -{ - IIcon side_inactive; - IIcon side_active; - IIcon top; - IIcon bottom; +public class PlayerDetectorAdvanced extends BlockCustomDrop { + IIcon side_inactive; + IIcon side_active; + IIcon top; + IIcon bottom; - public PlayerDetectorAdvanced() { - super(Material.iron); - this.setBlockName(Strings.playerDetectorAdvancedName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setStepSound(soundTypeStone); - ModBlocks.register(this); - } + public PlayerDetectorAdvanced() { + super(Material.iron); + this.setBlockName(Strings.playerDetectorAdvancedName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setStepSound(soundTypeStone); + ModBlocks.register(this); + } - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister iconRegister) - { - side_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "advanced_player_detector_side_inactive"); - side_active = iconRegister.registerIcon(References.RESOURCESPREFIX + "advanced_player_detector_side_active"); - top = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_top_0"); - bottom = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + side_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "advanced_player_detector_side_inactive"); + side_active = iconRegister.registerIcon(References.RESOURCESPREFIX + "advanced_player_detector_side_active"); + top = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_top_0"); + bottom = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); + } - @Override - public boolean isBlockSolid(IBlockAccess p_149747_1_, int p_149747_2_, int p_149747_3_, int p_149747_4_, int p_149747_5_) { - return true; - } + @Override + public boolean isBlockSolid(IBlockAccess p_149747_1_, int p_149747_2_, int p_149747_3_, int p_149747_4_, int p_149747_5_) { + return true; + } - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { - return true; - } + @Override + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return true; + } - @SideOnly(Side.CLIENT) - @Override - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) - { - IIcon side_icon; - - TileEntity tile = world.getTileEntity(x, y, z); - TilePlayerDetectorAdvanced detector = (tile != null && tile instanceof TilePlayerDetectorAdvanced) ? (TilePlayerDetectorAdvanced)tile : null; - if (detector != null && detector.getStackInSlot(0) != null) - { - ItemStack stack = detector.getStackInSlot(0); - Block block = Block.getBlockFromItem(stack.getItem()); - if (block != null && block.renderAsNormalBlock()) - return block.getIcon(side, stack.getItemDamage()); - }else - { - if (detector != null && detector.output) - side_icon = side_active; - else - side_icon = side_inactive; + @SideOnly(Side.CLIENT) + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + IIcon side_icon; - if (side == 0) - return bottom; - else if (side == 1) - return top; - else - return side_icon; - } - - return null; - } + TileEntity tile = world.getTileEntity(x, y, z); + TilePlayerDetectorAdvanced detector = (tile != null && tile instanceof TilePlayerDetectorAdvanced) ? (TilePlayerDetectorAdvanced) tile : null; + if (detector != null && detector.getStackInSlot(0) != null) { + ItemStack stack = detector.getStackInSlot(0); + Block block = Block.getBlockFromItem(stack.getItem()); + if (block != null && block.renderAsNormalBlock()) return block.getIcon(side, stack.getItemDamage()); + } else { + if (detector != null && detector.output) side_icon = side_active; + else side_icon = side_inactive; - @SideOnly(Side.CLIENT) - @Override - public IIcon getIcon(int side, int meta) - { - if (side == 0) - return bottom; - else if (side == 1) - return top; - else - return side_active; - } - - @Override - public TileEntity createNewTileEntity(World var1, int var2) - { - return new TilePlayerDetectorAdvanced(); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) - { - if (!world.isRemote) { - FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_PLAYERDETECTOR, world, x, y, z); - } - return true; - } - - @Override - public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) - { - if (side == 0 || side == 1) - return false; - else - return true; - } - - @Override - public boolean canProvidePower() - { - return true; - } - - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int meta) - { - TileEntity te = world.getTileEntity(x, y, z); - TilePlayerDetectorAdvanced detector = (te != null && te instanceof TilePlayerDetectorAdvanced) ? (TilePlayerDetectorAdvanced) te : null; - if(detector != null) - if (!detector.outputInverted) - return detector.output ? 15 : 0; - else - return detector.output ? 0 : 15; - else - return 0; - } - - @Override - public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int meta) - { - TileEntity te = world.getTileEntity(x, y, z); - TilePlayerDetectorAdvanced detector = (te != null && te instanceof TilePlayerDetectorAdvanced) ? (TilePlayerDetectorAdvanced) te : null; - if(detector != null) - if (!detector.outputInverted) - return detector.output ? 15 : 0; - else - return detector.output ? 0 : 15; - else - return 0; - } + if (side == 0) return bottom; + else if (side == 1) return top; + else return side_icon; + } - @Override - protected boolean dropInventory() { - return true; - } + return null; + } - @Override - protected boolean hasCustomDropps() { - return false; - } + @SideOnly(Side.CLIENT) + @Override + public IIcon getIcon(int side, int meta) { + if (side == 0) return bottom; + else if (side == 1) return top; + else return side_active; + } - @Override - protected void getCustomTileEntityDrops(TileEntity te, List droppes) { + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TilePlayerDetectorAdvanced(); + } - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + if (!world.isRemote) { + FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_PLAYERDETECTOR, world, x, y, z); + } + return true; + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - TileEntity te = world.getTileEntity(x, y, z); - TilePlayerDetectorAdvanced detector = (te != null && te instanceof TilePlayerDetectorAdvanced) ? (TilePlayerDetectorAdvanced) te : null; - if(detector != null && detector.getStackInSlot(0) != null){ - return detector.getStackInSlot(0); - } - return super.getPickBlock(target, world, x, y, z); - } + @Override + public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { + if (side == 0 || side == 1) return false; + else return true; + } + + @Override + public boolean canProvidePower() { + return true; + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int meta) { + TileEntity te = world.getTileEntity(x, y, z); + TilePlayerDetectorAdvanced detector = (te != null && te instanceof TilePlayerDetectorAdvanced) ? (TilePlayerDetectorAdvanced) te : null; + if (detector != null) if (!detector.outputInverted) return detector.output ? 15 : 0; + else return detector.output ? 0 : 15; + else return 0; + } + + @Override + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int meta) { + TileEntity te = world.getTileEntity(x, y, z); + TilePlayerDetectorAdvanced detector = (te != null && te instanceof TilePlayerDetectorAdvanced) ? (TilePlayerDetectorAdvanced) te : null; + if (detector != null) if (!detector.outputInverted) return detector.output ? 15 : 0; + else return detector.output ? 0 : 15; + else return 0; + } + + @Override + protected boolean dropInventory() { + return true; + } + + @Override + protected boolean hasCustomDropps() { + return false; + } + + @Override + protected void getCustomTileEntityDrops(TileEntity te, List droppes) { + + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + TileEntity te = world.getTileEntity(x, y, z); + TilePlayerDetectorAdvanced detector = (te != null && te instanceof TilePlayerDetectorAdvanced) ? (TilePlayerDetectorAdvanced) te : null; + if (detector != null && detector.getStackInSlot(0) != null) { + return detector.getStackInSlot(0); + } + return super.getPickBlock(target, world, x, y, z); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/SunDial.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/SunDial.java index f17f75e9..c132db52 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/SunDial.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/SunDial.java @@ -17,79 +17,68 @@ import com.brandon3055.draconicevolution.common.lib.Strings; import com.brandon3055.draconicevolution.common.tileentities.TileSunDial; public class SunDial extends BlockDE { - //@SideOnly(Side.CLIENT) - public IIcon icon_front; - public IIcon icon_front_active; - public IIcon icon_side; - //public boolean blockState = true; + //@SideOnly(Side.CLIENT) + public IIcon icon_front; + public IIcon icon_front_active; + public IIcon icon_side; + //public boolean blockState = true; - public SunDial() { - this.setBlockName(Strings.blockSunDialName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setStepSound(soundTypeStone); - ModBlocks.register(this); - } + public SunDial() { + this.setBlockName(Strings.blockSunDialName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setStepSound(soundTypeStone); + ModBlocks.register(this); + } - @Override - public boolean hasTileEntity(final int meta) - { - return true; - } + @Override + public boolean hasTileEntity(final int meta) { + return true; + } - @Override - public TileEntity createTileEntity(final World world, final int meta) - { - return new TileSunDial(); - } + @Override + public TileEntity createTileEntity(final World world, final int meta) { + return new TileSunDial(); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iconRegister) - { - icon_front = iconRegister.registerIcon(References.RESOURCESPREFIX + "sun_dial_front"); - icon_front_active = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/sun_dial_front_active"); - icon_side = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iconRegister) { + icon_front = iconRegister.registerIcon(References.RESOURCESPREFIX + "sun_dial_front"); + icon_front_active = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/sun_dial_front_active"); + icon_side = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int side, final int meta) - { - if (side == 0 || side == 1 || side == 4 || side == 5) - return icon_side; - else - return icon_front; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) - { - TileEntity tile = world.getTileEntity(x, y, z); - IIcon front = null; - if (tile != null && tile instanceof TileSunDial) - front = ((TileSunDial)tile).running == true ? icon_front_active : icon_front; - - if (side == 0 || side == 1 || side == 4 || side == 5) - return icon_side; - else - return front; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int side, final int meta) { + if (side == 0 || side == 1 || side == 4 || side == 5) return icon_side; + else return icon_front; + } - @Override - public void onNeighborBlockChange(final World world, final int x, final int y, final int z, final Block block) - { - //if (!world.isRemote) { - //world.setBlock(x, y, z, ModBlocks.sunDial, 0, 2); - //} - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + TileEntity tile = world.getTileEntity(x, y, z); + IIcon front = null; + if (tile != null && tile instanceof TileSunDial) + front = ((TileSunDial) tile).running == true ? icon_front_active : icon_front; - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer entityPlayer, final int par1, final float par2, final float par3, final float par4) - { - if (!world.isRemote) { - //FMLNetworkHandler.openGui(entityPlayer, DraconicEvolution.instance, 1, world, x, y, z); - } - return true; - } + if (side == 0 || side == 1 || side == 4 || side == 5) return icon_side; + else return front; + } + + @Override + public void onNeighborBlockChange(final World world, final int x, final int y, final int z, final Block block) { + //if (!world.isRemote) { + //world.setBlock(x, y, z, ModBlocks.sunDial, 0, 2); + //} + } + + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer entityPlayer, final int par1, final float par2, final float par3, final float par4) { + if (!world.isRemote) { + //FMLNetworkHandler.openGui(entityPlayer, DraconicEvolution.instance, 1, world, x, y, z); + } + return true; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/UpgradeModifier.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/UpgradeModifier.java index 2ee62263..aba2e4da 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/UpgradeModifier.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/UpgradeModifier.java @@ -23,73 +23,73 @@ import java.util.List; * Created by brandon3055 on 23/12/2015. */ public class UpgradeModifier extends BlockCustomDrop { - public UpgradeModifier() { - super(Material.iron); - this.setBlockName("upgradeModifier"); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setStepSound(soundTypeStone); - this.setBlockBounds(0f, 0f, 0f, 1f, 0.375f, 1f); - ModBlocks.register(this); - } + public UpgradeModifier() { + super(Material.iron); + this.setBlockName("upgradeModifier"); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setStepSound(soundTypeStone); + this.setBlockBounds(0f, 0f, 0f, 1f, 0.375f, 1f); + ModBlocks.register(this); + } - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - //blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + //blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); + } - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileUpgradeModifier(); - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileUpgradeModifier(); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float prx, float pry, float prz) { - if (!world.isRemote) { - FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_UPGRADE_MODIFIER, world, x, y, z); - } - world.markBlockForUpdate(x, y, z); - return true; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float prx, float pry, float prz) { + if (!world.isRemote) { + FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_UPGRADE_MODIFIER, world, x, y, z); + } + world.markBlockForUpdate(x, y, z); + return true; + } - @SideOnly(Side.CLIENT) - @Override - public int getRenderType() { - return -1; - } + @SideOnly(Side.CLIENT) + @Override + public int getRenderType() { + return -1; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - protected boolean dropInventory() { - return true; - } + @Override + protected boolean dropInventory() { + return true; + } - @Override - protected boolean hasCustomDropps() { - return false; - } + @Override + protected boolean hasCustomDropps() { + return false; + } - @Override - protected void getCustomTileEntityDrops(TileEntity te, List droppes) { + @Override + protected void getCustomTileEntityDrops(TileEntity te, List droppes) { - } + } - @Override - public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side) { - return false; - } + @Override + public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side) { + return false; + } - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { - return side == ForgeDirection.DOWN; - } + @Override + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return side == ForgeDirection.DOWN; + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/WeatherController.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/WeatherController.java index f6735bb2..6854b0b3 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/WeatherController.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/machine/WeatherController.java @@ -26,143 +26,120 @@ import java.util.List; public class WeatherController extends BlockCustomDrop { - public boolean blockState = true; - public IIcon icon_top; - public IIcon icon_bottom; - public IIcon icon_side_rain_off; - public IIcon icon_side_rain_on; - public IIcon icon_side_thunder_off; - public IIcon icon_side_thunder_on; - public IIcon icon_side_sun_on; - public IIcon icon_side_sun_off; + public boolean blockState = true; + public IIcon icon_top; + public IIcon icon_bottom; + public IIcon icon_side_rain_off; + public IIcon icon_side_rain_on; + public IIcon icon_side_thunder_off; + public IIcon icon_side_thunder_on; + public IIcon icon_side_sun_on; + public IIcon icon_side_sun_off; - public WeatherController() { - super(Material.iron); - this.setBlockName(Strings.blockWeatherControllerName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setStepSound(soundTypeStone); - ModBlocks.register(this); - } + public WeatherController() { + super(Material.iron); + this.setBlockName(Strings.blockWeatherControllerName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setStepSound(soundTypeStone); + ModBlocks.register(this); + } - @Override - public boolean hasTileEntity(final int meta) - { - return true; - } + @Override + public boolean hasTileEntity(final int meta) { + return true; + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iconRegister) - { - icon_top = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weather_controller_top"); - icon_bottom = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); - icon_side_rain_off = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weather_controller_rain"); - icon_side_rain_on = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weatherController_rain_active"); - icon_side_thunder_off = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weatherController_thunderstorm"); - icon_side_thunder_on = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weatherController_thunderstorm_active"); - icon_side_sun_off = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weatherController_sun"); - icon_side_sun_on = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weatherController_sun_active"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iconRegister) { + icon_top = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weather_controller_top"); + icon_bottom = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); + icon_side_rain_off = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weather_controller_rain"); + icon_side_rain_on = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weatherController_rain_active"); + icon_side_thunder_off = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weatherController_thunderstorm"); + icon_side_thunder_on = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weatherController_thunderstorm_active"); + icon_side_sun_off = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weatherController_sun"); + icon_side_sun_on = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weatherController_sun_active"); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) - { - IIcon icon_side = null; - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null && tile instanceof TileWeatherController) - { - if (((TileWeatherController)tile).charges > 0) - { - if (((TileWeatherController)tile).mode == 0) - icon_side = icon_side_sun_on; - else if (((TileWeatherController)tile).mode == 1) - icon_side = icon_side_rain_on; - else - icon_side = icon_side_thunder_on; - }else{ - if (((TileWeatherController)tile).mode == 0) - icon_side = icon_side_sun_off; - else if (((TileWeatherController)tile).mode == 1) - icon_side = icon_side_rain_off; - else - icon_side = icon_side_thunder_off; - } - } - + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + IIcon icon_side = null; + TileEntity tile = world.getTileEntity(x, y, z); + if (tile != null && tile instanceof TileWeatherController) { + if (((TileWeatherController) tile).charges > 0) { + if (((TileWeatherController) tile).mode == 0) icon_side = icon_side_sun_on; + else if (((TileWeatherController) tile).mode == 1) icon_side = icon_side_rain_on; + else icon_side = icon_side_thunder_on; + } else { + if (((TileWeatherController) tile).mode == 0) icon_side = icon_side_sun_off; + else if (((TileWeatherController) tile).mode == 1) icon_side = icon_side_rain_off; + else icon_side = icon_side_thunder_off; + } + } - - if (side > 1) - return icon_side; - else if (side == 0) - return icon_bottom; - else - return icon_top; - - } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { + if (side > 1) return icon_side; + else if (side == 0) return icon_bottom; + else return icon_top; - if (side > 1) - return icon_side_sun_on; - else if (side == 0) - return icon_bottom; - else - return icon_top; - } + } - @SuppressWarnings({ "rawtypes", "unchecked" }) - @SideOnly(Side.CLIENT) - @Override - public void getSubBlocks(final Item item, final CreativeTabs tab, final List par3list) - { - par3list.add(new ItemStack(item, 1, 0)); - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer entityPlayer, final int par1, final float par2, final float par3, final float par4) - { - if (!world.isRemote) { - FMLNetworkHandler.openGui(entityPlayer, DraconicEvolution.instance, GuiHandler.GUIID_WEATHER_CONTROLLER, world, x, y, z); - } - return true; - } + if (side > 1) return icon_side_sun_on; + else if (side == 0) return icon_bottom; + else return icon_top; + } - @Override - public TileEntity createNewTileEntity(World var1, int var2) - { - return new TileWeatherController(); - } + @SuppressWarnings({"rawtypes", "unchecked"}) + @SideOnly(Side.CLIENT) + @Override + public void getSubBlocks(final Item item, final CreativeTabs tab, final List par3list) { + par3list.add(new ItemStack(item, 1, 0)); + } - @Override - protected boolean dropInventory() { - return true; - } + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer entityPlayer, final int par1, final float par2, final float par3, final float par4) { + if (!world.isRemote) { + FMLNetworkHandler.openGui(entityPlayer, DraconicEvolution.instance, GuiHandler.GUIID_WEATHER_CONTROLLER, world, x, y, z); + } + return true; + } - @Override - protected boolean hasCustomDropps() { - return false; - } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileWeatherController(); + } - @Override - protected void getCustomTileEntityDrops(TileEntity te, List droppes) { + @Override + protected boolean dropInventory() { + return true; + } - } + @Override + protected boolean hasCustomDropps() { + return false; + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - TileWeatherController tile = (TileWeatherController) world.getTileEntity(x, y, z); - if (tile != null){ - if(!tile.lastTickInput){ - if (world.isBlockIndirectlyGettingPowered(x, y, z)){ - tile.activate(); - } - } - tile.lastTickInput = world.isBlockIndirectlyGettingPowered(x, y, z); - } - } + @Override + protected void getCustomTileEntityDrops(TileEntity te, List droppes) { + + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + TileWeatherController tile = (TileWeatherController) world.getTileEntity(x, y, z); + if (tile != null) { + if (!tile.lastTickInput) { + if (world.isBlockIndirectlyGettingPowered(x, y, z)) { + tile.activate(); + } + } + tile.lastTickInput = world.isBlockIndirectlyGettingPowered(x, y, z); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/DislocatorReceptacle.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/DislocatorReceptacle.java index d41a9e12..41295543 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/DislocatorReceptacle.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/DislocatorReceptacle.java @@ -25,113 +25,112 @@ import java.util.Random; * Created by Brandon on 19/5/2015. */ public class DislocatorReceptacle extends BlockCustomDrop implements ITileEntityProvider { - IIcon textureInactive; + IIcon textureInactive; - public DislocatorReceptacle(){ - super(Material.rock); - this.setHardness(50.0F); - this.setResistance(2000.0F); - this.setBlockName("dislocatorReceptacle"); - this.setHarvestLevel("pickaxe", 3); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); + public DislocatorReceptacle() { + super(Material.rock); + this.setHardness(50.0F); + this.setResistance(2000.0F); + this.setBlockName("dislocatorReceptacle"); + this.setHarvestLevel("pickaxe", 3); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModBlocks.register(this); - } + ModBlocks.register(this); + } - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - textureInactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/dislocatorReceptacle_inactive"); - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/dislocatorReceptacle_active"); - } + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + textureInactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/dislocatorReceptacle_inactive"); + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/dislocatorReceptacle_active"); + } - @Override - public IIcon getIcon(IBlockAccess access, int x, int y, int z, int side) { - TileDislocatorReceptacle tile = access.getTileEntity(x, y, z) instanceof TileDislocatorReceptacle ? (TileDislocatorReceptacle)access.getTileEntity(x, y, z) : null; - if (tile != null) return tile.isActive ? blockIcon : textureInactive; - return blockIcon; - } + @Override + public IIcon getIcon(IBlockAccess access, int x, int y, int z, int side) { + TileDislocatorReceptacle tile = access.getTileEntity(x, y, z) instanceof TileDislocatorReceptacle ? (TileDislocatorReceptacle) access.getTileEntity(x, y, z) : null; + if (tile != null) return tile.isActive ? blockIcon : textureInactive; + return blockIcon; + } - @Override - public void updateTick(World world, int x, int y, int z, Random random) { - TileDislocatorReceptacle tile = (TileDislocatorReceptacle) world.getTileEntity(x, y, z); - if (tile != null) tile.updateState(); + @Override + public void updateTick(World world, int x, int y, int z, Random random) { + TileDislocatorReceptacle tile = (TileDislocatorReceptacle) world.getTileEntity(x, y, z); + if (tile != null) tile.updateState(); - } + } - @Override - public IIcon getIcon(int p_149691_1_, int meta) { - return blockIcon; - } + @Override + public IIcon getIcon(int p_149691_1_, int meta) { + return blockIcon; + } - @Override - public boolean hasTileEntity(int metadata) { - return true; - } + @Override + public boolean hasTileEntity(int metadata) { + return true; + } - @Override - public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { - return false; - } + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + return false; + } - @Override - public TileEntity createNewTileEntity(World world, int i) { - return new TileDislocatorReceptacle(); - } + @Override + public TileEntity createNewTileEntity(World world, int i) { + return new TileDislocatorReceptacle(); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - if (world.isRemote) return true; - TileDislocatorReceptacle tile = (TileDislocatorReceptacle) world.getTileEntity(x, y, z); - if (tile == null) return false; + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + if (world.isRemote) return true; + TileDislocatorReceptacle tile = (TileDislocatorReceptacle) world.getTileEntity(x, y, z); + if (tile == null) return false; - if (tile.getStackInSlot(0) != null){ - if (player.getHeldItem() == null){ - player.inventory.setInventorySlotContents(player.inventory.currentItem, tile.getStackInSlot(0)); - tile.setInventorySlotContents(0, null); - }else { - world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, tile.getStackInSlot(0))); - tile.setInventorySlotContents(0, null); - } - world.markBlockForUpdate(x, y, z); - world.notifyBlockChange(x, y, z, this); + if (tile.getStackInSlot(0) != null) { + if (player.getHeldItem() == null) { + player.inventory.setInventorySlotContents(player.inventory.currentItem, tile.getStackInSlot(0)); + tile.setInventorySlotContents(0, null); + } else { + world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, tile.getStackInSlot(0))); + tile.setInventorySlotContents(0, null); + } + world.markBlockForUpdate(x, y, z); + world.notifyBlockChange(x, y, z, this); - }else { - ItemStack stack = player.getHeldItem(); - if (stack != null && stack.getItem() instanceof TeleporterMKI && ((TeleporterMKI)stack.getItem()).getLocation(stack) != null){ - tile.setInventorySlotContents(0, player.getHeldItem()); - player.destroyCurrentEquippedItem(); - } + } else { + ItemStack stack = player.getHeldItem(); + if (stack != null && stack.getItem() instanceof TeleporterMKI && ((TeleporterMKI) stack.getItem()).getLocation(stack) != null) { + tile.setInventorySlotContents(0, player.getHeldItem()); + player.destroyCurrentEquippedItem(); + } - } + } + return true; + } - return true; - } + @Override + public boolean hasComparatorInputOverride() { + return true; + } - @Override - public boolean hasComparatorInputOverride() { - return true; - } + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int p_149736_5_) { + TileDislocatorReceptacle tile = (TileDislocatorReceptacle) world.getTileEntity(x, y, z); + return tile == null ? 0 : tile.getStackInSlot(0) != null ? 15 : 0; + } - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int p_149736_5_) { - TileDislocatorReceptacle tile = (TileDislocatorReceptacle)world.getTileEntity(x, y, z); - return tile == null ? 0 : tile.getStackInSlot(0) != null ? 15 : 0; - } + @Override + protected boolean dropInventory() { + return true; + } - @Override - protected boolean dropInventory() { - return true; - } + @Override + protected boolean hasCustomDropps() { + return false; + } - @Override - protected boolean hasCustomDropps() { - return false; - } + @Override + protected void getCustomTileEntityDrops(TileEntity te, List droppes) { - @Override - protected void getCustomTileEntityDrops(TileEntity te, List droppes) { - - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyPylon.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyPylon.java index 63693ef7..6b4a7271 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyPylon.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyPylon.java @@ -22,140 +22,134 @@ import net.minecraft.world.World; * Created by Brandon on 28/07/2014. */ public class EnergyPylon extends BlockDE {//todo fix sphere renderer - @SideOnly(Side.CLIENT) - public IIcon icon_active_face; - public IIcon icon_input; - public IIcon icon_output; + @SideOnly(Side.CLIENT) + public IIcon icon_active_face; + public IIcon icon_input; + public IIcon icon_output; - public EnergyPylon() { - super(Material.iron); - this.setHardness(10F); - this.setResistance(20F); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setBlockName(Strings.energyPylonName); - ModBlocks.register(this); - } + public EnergyPylon() { + super(Material.iron); + this.setHardness(10F); + this.setResistance(20F); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setBlockName(Strings.energyPylonName); + ModBlocks.register(this); + } - @Override - public boolean hasTileEntity(int metadata) { - return metadata == 1 || metadata == 2; - } + @Override + public boolean hasTileEntity(int metadata) { + return metadata == 1 || metadata == 2; + } - @Override - public TileEntity createTileEntity(World world, int metadata) { - if (metadata == 1 || metadata == 2) - return new TileEnergyPylon(); - else - return null; - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + if (metadata == 1 || metadata == 2) return new TileEnergyPylon(); + else return null; + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) { - icon_input = iconRegister.registerIcon(References.RESOURCESPREFIX + "energy_pylon_input"); - icon_output = iconRegister.registerIcon(References.RESOURCESPREFIX + "energy_pylon_output"); - icon_active_face = iconRegister.registerIcon(References.RESOURCESPREFIX + "energy_pylon_active_face"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + icon_input = iconRegister.registerIcon(References.RESOURCESPREFIX + "energy_pylon_input"); + icon_output = iconRegister.registerIcon(References.RESOURCESPREFIX + "energy_pylon_output"); + icon_active_face = iconRegister.registerIcon(References.RESOURCESPREFIX + "energy_pylon_active_face"); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) { - if (meta == 1 && side == 1) - return icon_active_face; - if (meta == 2 && side == 0) - return icon_active_face; - return icon_input; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + if (meta == 1 && side == 1) return icon_active_face; + if (meta == 2 && side == 0) return icon_active_face; + return icon_input; + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { - int meta = world.getBlockMetadata(x, y, z); - if (meta == 1 && side == 1) - return icon_active_face; - if (meta == 2 && side == 0) - return icon_active_face; - TileEnergyPylon thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y, z) : null; - if (thisTile == null) return icon_input; - return !thisTile.reciveEnergy ? icon_output : icon_input; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 1 && side == 1) return icon_active_face; + if (meta == 2 && side == 0) return icon_active_face; + TileEnergyPylon thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y, z) : null; + if (thisTile == null) return icon_input; + return !thisTile.reciveEnergy ? icon_output : icon_input; + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_) { - int meta = world.getBlockMetadata(x, y, z); - if (meta == 0) { - if (world.getBlock(x, y + 1, z) == Blocks.glass) { - world.setBlockMetadataWithNotify(x, y, z, 1, 2); - world.setBlock(x, y + 1, z, ModBlocks.invisibleMultiblock, 2, 2); - } - else if (world.getBlock(x, y - 1, z) == Blocks.glass) { - world.setBlockMetadataWithNotify(x, y, z, 2, 2); - world.setBlock(x, y - 1, z, ModBlocks.invisibleMultiblock, 2, 2); - } - }else { - TileEnergyPylon thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y, z) : null; - if (thisTile == null || (meta == 1 && !isGlass(world, x, y+1, z)) || (meta == 2 && !isGlass(world, x, y-1, z))) { - world.setBlockMetadataWithNotify(x, y, z, 0, 2); - } - } - TileEnergyPylon thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y, z) : null; - if (thisTile != null) { - thisTile.onActivated(); - } - if (world.getBlockMetadata(x, y, z) == 0 && world.getTileEntity(x, y, z) != null) world.removeTileEntity(x, y, z); - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_) { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0) { + if (world.getBlock(x, y + 1, z) == Blocks.glass) { + world.setBlockMetadataWithNotify(x, y, z, 1, 2); + world.setBlock(x, y + 1, z, ModBlocks.invisibleMultiblock, 2, 2); + } else if (world.getBlock(x, y - 1, z) == Blocks.glass) { + world.setBlockMetadataWithNotify(x, y, z, 2, 2); + world.setBlock(x, y - 1, z, ModBlocks.invisibleMultiblock, 2, 2); + } + } else { + TileEnergyPylon thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y, z) : null; + if (thisTile == null || (meta == 1 && !isGlass(world, x, y + 1, z)) || (meta == 2 && !isGlass(world, x, y - 1, z))) { + world.setBlockMetadataWithNotify(x, y, z, 0, 2); + } + } + TileEnergyPylon thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y, z) : null; + if (thisTile != null) { + thisTile.onActivated(); + } + if (world.getBlockMetadata(x, y, z) == 0 && world.getTileEntity(x, y, z) != null) + world.removeTileEntity(x, y, z); + } - private boolean isGlass(World world, int x, int y, int z){ - return world.getBlock(x, y, z) == ModBlocks.invisibleMultiblock && world.getBlockMetadata(x, y, z) == 2; - } + private boolean isGlass(World world, int x, int y, int z) { + return world.getBlock(x, y, z) == ModBlocks.invisibleMultiblock && world.getBlockMetadata(x, y, z) == 2; + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - int meta = world.getBlockMetadata(x, y, z); - if (meta == 0) return false; - TileEnergyPylon thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y, z) : null; - if (thisTile != null) { - if (!player.isSneaking()) thisTile.onActivated(); - else thisTile.nextCore(); - return true; - } - return false; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0) return false; + TileEnergyPylon thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y, z) : null; + if (thisTile != null) { + if (!player.isSneaking()) thisTile.onActivated(); + else thisTile.nextCore(); + return true; + } + return false; + } - @Override - public void onPostBlockPlaced(World world, int x, int y, int z, int p_149714_5_) { - int meta = world.getBlockMetadata(x, y, z); - if (meta == 0) { - if (world.getBlock(x, y + 1, z) == Blocks.glass) { - world.setBlockMetadataWithNotify(x, y, z, 1, 2); - world.setBlock(x, y + 1, z, ModBlocks.invisibleMultiblock, 2, 2); - } - else if (world.getBlock(x, y - 1, z) == Blocks.glass) { - world.setBlockMetadataWithNotify(x, y, z, 2, 2); - world.setBlock(x, y - 1, z, ModBlocks.invisibleMultiblock, 2, 2); - } - }else { - TileEnergyPylon thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y, z) : null; - if (thisTile == null || (meta == 1 && !isGlass(world, x, y+1, z)) || (meta == 2 && !isGlass(world, x, y-1, z))) { - world.setBlockMetadataWithNotify(x, y, z, 0, 2); - } - } - TileEnergyPylon thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y, z) : null; - if (thisTile != null) { - thisTile.onActivated(); - } - if (world.getBlockMetadata(x, y, z) == 0 && world.getTileEntity(x, y, z) != null) world.removeTileEntity(x, y, z); - } + @Override + public void onPostBlockPlaced(World world, int x, int y, int z, int p_149714_5_) { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0) { + if (world.getBlock(x, y + 1, z) == Blocks.glass) { + world.setBlockMetadataWithNotify(x, y, z, 1, 2); + world.setBlock(x, y + 1, z, ModBlocks.invisibleMultiblock, 2, 2); + } else if (world.getBlock(x, y - 1, z) == Blocks.glass) { + world.setBlockMetadataWithNotify(x, y, z, 2, 2); + world.setBlock(x, y - 1, z, ModBlocks.invisibleMultiblock, 2, 2); + } + } else { + TileEnergyPylon thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y, z) : null; + if (thisTile == null || (meta == 1 && !isGlass(world, x, y + 1, z)) || (meta == 2 && !isGlass(world, x, y - 1, z))) { + world.setBlockMetadataWithNotify(x, y, z, 0, 2); + } + } + TileEnergyPylon thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y, z) : null; + if (thisTile != null) { + thisTile.onActivated(); + } + if (world.getBlockMetadata(x, y, z) == 0 && world.getTileEntity(x, y, z) != null) + world.removeTileEntity(x, y, z); + } - @Override - public boolean hasComparatorInputOverride() { - return true; - } + @Override + public boolean hasComparatorInputOverride() { + return true; + } - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int meta) { - TileEnergyPylon tile = world.getTileEntity(x, y, z) instanceof TileEnergyPylon ? (TileEnergyPylon) world.getTileEntity(x, y, z) : null; - if (tile != null) return (int)(tile.getEnergyStored() / tile.getMaxEnergyStored() * 15D); - return 0; - } + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int meta) { + TileEnergyPylon tile = world.getTileEntity(x, y, z) instanceof TileEnergyPylon ? (TileEnergyPylon) world.getTileEntity(x, y, z) : null; + if (tile != null) return (int) (tile.getEnergyStored() / tile.getMaxEnergyStored() * 15D); + return 0; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyStorageCore.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyStorageCore.java index e7f040d2..2f93314d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyStorageCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyStorageCore.java @@ -30,121 +30,114 @@ import java.util.List; /** * Created by Brandon on 25/07/2014. */ -public class EnergyStorageCore extends BlockDE implements IHudDisplayBlock{ +public class EnergyStorageCore extends BlockDE implements IHudDisplayBlock { - public EnergyStorageCore() { - super(Material.iron); - this.setHardness(10F); - this.setResistance(20f); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setBlockName(Strings.energyStorageCoreName); - ModBlocks.register(this); - } + public EnergyStorageCore() { + super(Material.iron); + this.setHardness(10F); + this.setResistance(20f); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setBlockName(Strings.energyStorageCoreName); + ModBlocks.register(this); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "energy_storage_core"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "energy_storage_core"); + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean hasTileEntity(int metadata) { - return true; - } + @Override + public boolean hasTileEntity(int metadata) { + return true; + } - @Override - public TileEntity createTileEntity(World world, int metadata) { - return new TileEnergyStorageCore(); - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileEnergyStorageCore(); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - TileEnergyStorageCore tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z) : null; - if (tile == null) - { - LogHelper.error("Missing Tile Entity (EnergyStorageCore)"); - return false; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + TileEnergyStorageCore tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z) : null; + if (tile == null) { + LogHelper.error("Missing Tile Entity (EnergyStorageCore)"); + return false; + } - if (!world.isRemote) { - player.addChatComponentMessage(new ChatComponentText("Tier:" + (tile.getTier() + 1))); - String BN = String.valueOf(tile.getEnergyStored()); - player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("info.de.charge.txt") + ": " + Utills.formatNumber(tile.getEnergyStored()) + " / " + Utills.formatNumber(tile.getMaxEnergyStored()) + " [" + BN + " RF]")); } - return true; - } + if (!world.isRemote) { + player.addChatComponentMessage(new ChatComponentText("Tier:" + (tile.getTier() + 1))); + String BN = String.valueOf(tile.getEnergyStored()); + player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("info.de.charge.txt") + ": " + Utills.formatNumber(tile.getEnergyStored()) + " / " + Utills.formatNumber(tile.getMaxEnergyStored()) + " [" + BN + " RF]")); + } + return true; + } - @Override - @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { - TileEnergyStorageCore tile = (world.getTileEntity(x - ForgeDirection.getOrientation(side).offsetX, y - ForgeDirection.getOrientation(side).offsetY, z - ForgeDirection.getOrientation(side).offsetZ) != null && world.getTileEntity(x - ForgeDirection.getOrientation(side).offsetX, y - ForgeDirection.getOrientation(side).offsetY, z - ForgeDirection.getOrientation(side).offsetZ) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x - ForgeDirection.getOrientation(side).offsetX, y - ForgeDirection.getOrientation(side).offsetY, z - ForgeDirection.getOrientation(side).offsetZ) : null; - //LogHelper.error(world.getTileEntity(x - ForgeDirection.getOrientation(side).offsetX, y - ForgeDirection.getOrientation(side).offsetY, z - ForgeDirection.getOrientation(side).offsetZ)); - if (tile == null) - { - LogHelper.error("Missing Tile Entity (EnergyStorageCore)(shouldSideBeRendered)"); - return true; - } - if (tile.isOnline()) - return false; - else - return super.shouldSideBeRendered(world, x, y, z, side); - } + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { + TileEnergyStorageCore tile = (world.getTileEntity(x - ForgeDirection.getOrientation(side).offsetX, y - ForgeDirection.getOrientation(side).offsetY, z - ForgeDirection.getOrientation(side).offsetZ) != null && world.getTileEntity(x - ForgeDirection.getOrientation(side).offsetX, y - ForgeDirection.getOrientation(side).offsetY, z - ForgeDirection.getOrientation(side).offsetZ) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x - ForgeDirection.getOrientation(side).offsetX, y - ForgeDirection.getOrientation(side).offsetY, z - ForgeDirection.getOrientation(side).offsetZ) : null; + //LogHelper.error(world.getTileEntity(x - ForgeDirection.getOrientation(side).offsetX, y - ForgeDirection.getOrientation(side).offsetY, z - ForgeDirection.getOrientation(side).offsetZ)); + if (tile == null) { + LogHelper.error("Missing Tile Entity (EnergyStorageCore)(shouldSideBeRendered)"); + return true; + } + if (tile.isOnline()) return false; + else return super.shouldSideBeRendered(world, x, y, z, side); + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_) { - TileEnergyStorageCore thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z) : null; - if (thisTile != null && thisTile.isOnline() && thisTile.getTier() == 0) - { - thisTile.isStructureStillValid(false); - } - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_) { + TileEnergyStorageCore thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z) : null; + if (thisTile != null && thisTile.isOnline() && thisTile.getTier() == 0) { + thisTile.isStructureStillValid(false); + } + } - @Override - public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int p_149749_6_) { - TileEnergyStorageCore thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z) : null; - if (thisTile != null && thisTile.isOnline() && thisTile.getTier() == 0) - { - thisTile.deactivateStabilizers(); - } - super.breakBlock(world, x, y, z, p_149749_5_, p_149749_6_); - } + @Override + public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int p_149749_6_) { + TileEnergyStorageCore thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z) : null; + if (thisTile != null && thisTile.isOnline() && thisTile.getTier() == 0) { + thisTile.deactivateStabilizers(); + } + super.breakBlock(world, x, y, z, p_149749_5_, p_149749_6_); + } - @Override - public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) { - TileEnergyStorageCore thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z) : null; - if (thisTile != null && thisTile.isOnline()) - { - return AxisAlignedBB.getBoundingBox(thisTile.xCoord + 0.5, thisTile.yCoord + 0.5, thisTile.zCoord + 0.5, thisTile.xCoord + 0.5, thisTile.yCoord + 0.5, thisTile.zCoord + 0.5); - } - return super.getSelectedBoundingBoxFromPool(world, x, y, z); - } + @Override + public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) { + TileEnergyStorageCore thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z) : null; + if (thisTile != null && thisTile.isOnline()) { + return AxisAlignedBB.getBoundingBox(thisTile.xCoord + 0.5, thisTile.yCoord + 0.5, thisTile.zCoord + 0.5, thisTile.xCoord + 0.5, thisTile.yCoord + 0.5, thisTile.zCoord + 0.5); + } + return super.getSelectedBoundingBoxFromPool(world, x, y, z); + } - @Override - public List getDisplayData(World world, int x, int y, int z) { - List list = new ArrayList(); + @Override + public List getDisplayData(World world, int x, int y, int z) { + List list = new ArrayList(); - TileEnergyStorageCore tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z) : null; - if (tile == null) - { - LogHelper.error("Missing Tile Entity (EnergyStorageCore getDisplayData)"); - return list; - } + TileEnergyStorageCore tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z) : null; + if (tile == null) { + LogHelper.error("Missing Tile Entity (EnergyStorageCore getDisplayData)"); + return list; + } - list.add(InfoHelper.HITC()+getLocalizedName()); - list.add("Tier: " + InfoHelper.ITC() + (tile.getTier() + 1)); - String BN = String.valueOf(tile.getEnergyStored()); - list.add(StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.ITC() + Utills.formatNumber(tile.getEnergyStored()) + " / " + Utills.formatNumber(tile.getMaxEnergyStored()) + " [" + BN + " RF]"); + list.add(InfoHelper.HITC() + getLocalizedName()); + list.add("Tier: " + InfoHelper.ITC() + (tile.getTier() + 1)); + String BN = String.valueOf(tile.getEnergyStored()); + list.add(StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.ITC() + Utills.formatNumber(tile.getEnergyStored()) + " / " + Utills.formatNumber(tile.getMaxEnergyStored()) + " [" + BN + " RF]"); - return list; - } + return list; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/IReactorPart.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/IReactorPart.java index 12e9a3f4..974d24e1 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/IReactorPart.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/IReactorPart.java @@ -4,27 +4,27 @@ package com.brandon3055.draconicevolution.common.blocks.multiblock; * Created by Brandon on 23/7/2015. */ public interface IReactorPart { - public static int RMODE_TEMP = 0; - public static int RMODE_TEMP_INV = 1; - public static int RMODE_FIELD = 2; - public static int RMODE_FIELD_INV = 3; - public static int RMODE_SAT = 4; - public static int RMODE_SAT_INV = 5; - public static int RMODE_FUEL = 6; - public static int RMODE_FUEL_INV = 7; + public static int RMODE_TEMP = 0; + public static int RMODE_TEMP_INV = 1; + public static int RMODE_FIELD = 2; + public static int RMODE_FIELD_INV = 3; + public static int RMODE_SAT = 4; + public static int RMODE_SAT_INV = 5; + public static int RMODE_FUEL = 6; + public static int RMODE_FUEL_INV = 7; - public MultiblockHelper.TileLocation getMaster(); + public MultiblockHelper.TileLocation getMaster(); - public void shutDown(); + public void shutDown(); - public boolean checkForMaster(); + public boolean checkForMaster(); - public boolean isActive(); + public boolean isActive(); - public String getRedstoneModeString(); + public String getRedstoneModeString(); - public void changeRedstoneMode(); + public void changeRedstoneMode(); - public int getRedstoneMode(); + public int getRedstoneMode(); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/InvisibleMultiblock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/InvisibleMultiblock.java index fcbe14de..9a20ffd4 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/InvisibleMultiblock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/InvisibleMultiblock.java @@ -37,205 +37,199 @@ import net.minecraft.world.World; */ public class InvisibleMultiblock extends BlockDE implements IHudDisplayBlock { - public InvisibleMultiblock() { - super(Material.iron); - this.setHardness(10F); - this.setResistance(2000F); - //this.setCreativeTab(DraconicEvolution.getCreativeTab(2)); - this.setBlockName(Strings.invisibleMultiblockName); - ModBlocks.register(this); - } + public InvisibleMultiblock() { + super(Material.iron); + this.setHardness(10F); + this.setResistance(2000F); + //this.setCreativeTab(DraconicEvolution.getCreativeTab(2)); + this.setBlockName(Strings.invisibleMultiblockName); + ModBlocks.register(this); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconium_block_0"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconium_block_0"); + } - @Override - @SideOnly(Side.CLIENT) - public int getRenderType() { - return -1; - } + @Override + @SideOnly(Side.CLIENT) + public int getRenderType() { + return -1; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean hasTileEntity(int metadata) { - return metadata == 0 || metadata == 1; - } + @Override + public boolean hasTileEntity(int metadata) { + return metadata == 0 || metadata == 1; + } - @Override - public TileEntity createTileEntity(World world, int metadata) { - if (metadata == 0 || metadata == 1) - return new TileInvisibleMultiblock(); - else return null; - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + if (metadata == 0 || metadata == 1) return new TileInvisibleMultiblock(); + else return null; + } - @Override - public Item getItemDropped(int meta, Random p_149650_2_, int var2) { - if (meta == 0) - return Item.getItemFromBlock(ModBlocks.draconiumBlock); - else if (meta == 1) - return Item.getItemFromBlock(BalanceConfigHandler.energyStorageStructureBlock); - else - return null; - } - @Override - public int damageDropped(int metadata) - { - if (metadata == 1) - { - return BalanceConfigHandler.energyStorageStructureBlockMetadata; - } - return super.damageDropped(metadata); - } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - int meta = world.getBlockMetadata(x, y, z); - if (meta == 0 || meta == 1) { - TileInvisibleMultiblock thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) world.getTileEntity(x, y, z) : null; - if (thisTile == null) { - LogHelper.error("Missing Tile Entity (TileInvisibleMultiblock)"); - return false; - } - TileEnergyStorageCore master = thisTile.getMaster(); - if (master == null) { - onNeighborBlockChange(world, x, y, z, this); - return false; - } - if (!world.isRemote) { - world.markBlockForUpdate(master.xCoord, master.yCoord, master.zCoord); - player.addChatComponentMessage(new ChatComponentText("Tier:" + (master.getTier() + 1))); - String BN = String.valueOf(master.getEnergyStored()); - player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("info.de.charge.txt") + ": " + Utills.formatNumber(master.getEnergyStored()) + " / " + Utills.formatNumber(master.getMaxEnergyStored()) + " [" + BN + " RF]")); - } - return true; - } else if (meta == 2) { - TileEnergyPylon pylon = (world.getTileEntity(x, y+1, z) != null && world.getTileEntity(x, y+1, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y+1, z) : (world.getTileEntity(x, y-1, z) != null && world.getTileEntity(x, y-1, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y-1, z) : null; - if (pylon == null) return false; - pylon.reciveEnergy = !pylon.reciveEnergy; - world.markBlockForUpdate(pylon.xCoord, pylon.yCoord, pylon.zCoord); - pylon.onActivated(); - return true; - } - return false; - } + @Override + public Item getItemDropped(int meta, Random p_149650_2_, int var2) { + if (meta == 0) return Item.getItemFromBlock(ModBlocks.draconiumBlock); + else if (meta == 1) return Item.getItemFromBlock(BalanceConfigHandler.energyStorageStructureBlock); + else return null; + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_) { - int meta = world.getBlockMetadata(x, y, z); - if (meta == 0 || meta == 1) { - TileInvisibleMultiblock thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) world.getTileEntity(x, y, z) : null; - if (thisTile == null) { - LogHelper.error("Missing Tile Entity (TileInvisibleMultiblock)"); - revert(world, x, y, z); - return; - } - TileEnergyStorageCore master = thisTile.getMaster(); - if (master == null) { - LogHelper.error("Master = null reverting!"); - revert(world, x, y, z); - return; - } - if (master.isOnline()) master.isStructureStillValid(thisTile.getMaster().getTier() == 1); - if (!master.isOnline()) revert(world, x, y, z); - }else if (meta == 2) { - if (world.getBlock(x, y + 1, z) != ModBlocks.energyPylon && world.getBlock(x, y - 1, z) != ModBlocks.energyPylon) world.setBlock(x, y, z, Blocks.glass); - } - } + @Override + public int damageDropped(int metadata) { + if (metadata == 1) { + return BalanceConfigHandler.energyStorageStructureBlockMetadata; + } + return super.damageDropped(metadata); + } - private void revert(World world, int x, int y, int z){ - int meta = world.getBlockMetadata(x, y, z); - if (meta == 0) - world.setBlock(x, y, z, ModBlocks.draconiumBlock); - else if (meta == 1) - world.setBlock(x, y, z, BalanceConfigHandler.energyStorageStructureBlock, BalanceConfigHandler.energyStorageStructureBlockMetadata, 3); - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0 || meta == 1) { + TileInvisibleMultiblock thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) world.getTileEntity(x, y, z) : null; + if (thisTile == null) { + LogHelper.error("Missing Tile Entity (TileInvisibleMultiblock)"); + return false; + } + TileEnergyStorageCore master = thisTile.getMaster(); + if (master == null) { + onNeighborBlockChange(world, x, y, z, this); + return false; + } + if (!world.isRemote) { + world.markBlockForUpdate(master.xCoord, master.yCoord, master.zCoord); + player.addChatComponentMessage(new ChatComponentText("Tier:" + (master.getTier() + 1))); + String BN = String.valueOf(master.getEnergyStored()); + player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("info.de.charge.txt") + ": " + Utills.formatNumber(master.getEnergyStored()) + " / " + Utills.formatNumber(master.getMaxEnergyStored()) + " [" + BN + " RF]")); + } + return true; + } else if (meta == 2) { + TileEnergyPylon pylon = (world.getTileEntity(x, y + 1, z) != null && world.getTileEntity(x, y + 1, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y + 1, z) : (world.getTileEntity(x, y - 1, z) != null && world.getTileEntity(x, y - 1, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y - 1, z) : null; + if (pylon == null) return false; + pylon.reciveEnergy = !pylon.reciveEnergy; + world.markBlockForUpdate(pylon.xCoord, pylon.yCoord, pylon.zCoord); + pylon.onActivated(); + return true; + } + return false; + } - @Override - public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int meta) { - TileEntity tile = world.getTileEntity(x, y, z); - TileInvisibleMultiblock thisTile = (tile != null && tile instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) tile : null; - if (thisTile != null && thisTile.getMaster() != null && thisTile.getMaster().isOnline()) - { - world.setBlockMetadataWithNotify(x, y, z, 0, 2); + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_) { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0 || meta == 1) { + TileInvisibleMultiblock thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) world.getTileEntity(x, y, z) : null; + if (thisTile == null) { + LogHelper.error("Missing Tile Entity (TileInvisibleMultiblock)"); + revert(world, x, y, z); + return; + } + TileEnergyStorageCore master = thisTile.getMaster(); + if (master == null) { + LogHelper.error("Master = null reverting!"); + revert(world, x, y, z); + return; + } + if (master.isOnline()) master.isStructureStillValid(thisTile.getMaster().getTier() == 1); + if (!master.isOnline()) revert(world, x, y, z); + } else if (meta == 2) { + if (world.getBlock(x, y + 1, z) != ModBlocks.energyPylon && world.getBlock(x, y - 1, z) != ModBlocks.energyPylon) + world.setBlock(x, y, z, Blocks.glass); + } + } - thisTile.getMaster().isStructureStillValid(thisTile.getMaster().getTier() == 1); - } - super.breakBlock(world, x, y, z, p_149749_5_, meta); - } + private void revert(World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0) world.setBlock(x, y, z, ModBlocks.draconiumBlock); + else if (meta == 1) + world.setBlock(x, y, z, BalanceConfigHandler.energyStorageStructureBlock, BalanceConfigHandler.energyStorageStructureBlockMetadata, 3); + } - @Override - public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - if (meta == 0 || meta == 1) { - TileInvisibleMultiblock thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) world.getTileEntity(x, y, z) : null; - if (thisTile != null && thisTile.getMaster() != null) { - return AxisAlignedBB.getBoundingBox(thisTile.getMaster().xCoord, thisTile.getMaster().yCoord, thisTile.getMaster().zCoord, thisTile.getMaster().xCoord + 0.5, thisTile.getMaster().yCoord + 0.5, thisTile.getMaster().zCoord + 0.5); - } - return super.getSelectedBoundingBoxFromPool(world, x, y, z); - }else if (meta == 2) { - return AxisAlignedBB.getBoundingBox(x + 0.49, y + 0.49, z + 0.49, x + 0.51, y + 0.51, z + 0.51); - } - return super.getSelectedBoundingBoxFromPool(world, x, y, z); - } + @Override + public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int meta) { + TileEntity tile = world.getTileEntity(x, y, z); + TileInvisibleMultiblock thisTile = (tile != null && tile instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) tile : null; + if (thisTile != null && thisTile.getMaster() != null && thisTile.getMaster().isOnline()) { + world.setBlockMetadataWithNotify(x, y, z, 0, 2); - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + thisTile.getMaster().isStructureStillValid(thisTile.getMaster().getTier() == 1); + } + super.breakBlock(world, x, y, z, p_149749_5_, meta); + } - int meta = world.getBlockMetadata(x, y, z); - if(meta == 2){ - return AxisAlignedBB.getBoundingBox(x, y, z, x, y, z); - } - return super.getCollisionBoundingBoxFromPool(world, x, y, z); - } + @Override + public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0 || meta == 1) { + TileInvisibleMultiblock thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) world.getTileEntity(x, y, z) : null; + if (thisTile != null && thisTile.getMaster() != null) { + return AxisAlignedBB.getBoundingBox(thisTile.getMaster().xCoord, thisTile.getMaster().yCoord, thisTile.getMaster().zCoord, thisTile.getMaster().xCoord + 0.5, thisTile.getMaster().yCoord + 0.5, thisTile.getMaster().zCoord + 0.5); + } + return super.getSelectedBoundingBoxFromPool(world, x, y, z); + } else if (meta == 2) { + return AxisAlignedBB.getBoundingBox(x + 0.49, y + 0.49, z + 0.49, x + 0.51, y + 0.51, z + 0.51); + } + return super.getSelectedBoundingBoxFromPool(world, x, y, z); + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { - if (world.getBlockMetadata(x, y, z) == 0) - return new ItemStack(ModBlocks.draconiumBlock); - else if (world.getBlockMetadata(x, y, z) == 1) - return new ItemStack(BalanceConfigHandler.energyStorageStructureBlock, 1, BalanceConfigHandler.energyStorageStructureBlockMetadata); - else - return new ItemStack(Blocks.glass); - } + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { - @Override - public List getDisplayData(World world, int x, int y, int z) { - List list = new ArrayList(); + int meta = world.getBlockMetadata(x, y, z); + if (meta == 2) { + return AxisAlignedBB.getBoundingBox(x, y, z, x, y, z); + } + return super.getCollisionBoundingBoxFromPool(world, x, y, z); + } - int meta = world.getBlockMetadata(x, y, z); - if (meta == 0 || meta == 1) - { - TileInvisibleMultiblock thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) world.getTileEntity(x, y, z) : null; - if (thisTile == null) { - LogHelper.error("Missing Tile Entity (TileInvisibleMultiblock getDisplayData)"); - return list; - } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { + if (world.getBlockMetadata(x, y, z) == 0) return new ItemStack(ModBlocks.draconiumBlock); + else if (world.getBlockMetadata(x, y, z) == 1) + return new ItemStack(BalanceConfigHandler.energyStorageStructureBlock, 1, BalanceConfigHandler.energyStorageStructureBlockMetadata); + else return new ItemStack(Blocks.glass); + } - TileEnergyStorageCore master = thisTile.getMaster(); + @Override + public List getDisplayData(World world, int x, int y, int z) { + List list = new ArrayList(); - if (master == null) { return list; } + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0 || meta == 1) { + TileInvisibleMultiblock thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) world.getTileEntity(x, y, z) : null; + if (thisTile == null) { + LogHelper.error("Missing Tile Entity (TileInvisibleMultiblock getDisplayData)"); + return list; + } - list.add(InfoHelper.HITC() + ModBlocks.energyStorageCore.getLocalizedName()); - list.add("Tier: " + InfoHelper.ITC() + (master.getTier() + 1)); - String BN = String.valueOf(master.getEnergyStored()); - list.add(StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.ITC() + Utills.formatNumber(master.getEnergyStored()) + " / " + Utills.formatNumber(master.getMaxEnergyStored()) + " [" + Utills.addCommas(master.getEnergyStored()) + " RF]"); + TileEnergyStorageCore master = thisTile.getMaster(); - return list; - } + if (master == null) { + return list; + } - return list; - } + list.add(InfoHelper.HITC() + ModBlocks.energyStorageCore.getLocalizedName()); + list.add("Tier: " + InfoHelper.ITC() + (master.getTier() + 1)); + String BN = String.valueOf(master.getEnergyStored()); + list.add(StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.ITC() + Utills.formatNumber(master.getEnergyStored()) + " / " + Utills.formatNumber(master.getMaxEnergyStored()) + " [" + Utills.addCommas(master.getEnergyStored()) + " RF]"); + + return list; + } + + return list; + } @Override public String getUnlocalizedName() { diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/MultiblockHelper.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/MultiblockHelper.java index 02481f35..06be95b1 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/MultiblockHelper.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/MultiblockHelper.java @@ -11,131 +11,135 @@ import net.minecraft.world.World; public class MultiblockHelper { + public static class TileLocation extends ChunkCoordinates { + public boolean initialized = false; - public static class TileLocation extends ChunkCoordinates { - public boolean initialized = false; + public TileLocation() { - public TileLocation(){ + } - } + public TileLocation(int x, int y, int z) { + this.posX = x; + this.posY = y; + this.posZ = z; + initialized = true; + } - public TileLocation(int x, int y, int z){ - this.posX = x; - this.posY = y; - this.posZ = z; - initialized = true; - } + public int getXCoord() { + return posX; + } - public int getXCoord(){ - return posX; - } + public int getYCoord() { + return posY; + } - public int getYCoord(){ - return posY; - } + public int getZCoord() { + return posZ; + } - public int getZCoord(){ - return posZ; - } + public boolean isThisLocation(int x, int y, int z) { + return x == posX && y == posY && z == posZ; + } - public boolean isThisLocation(int x, int y, int z){ - return x == posX && y == posY && z == posZ; - } + @Override + public void set(int x, int y, int z) { + initialized = true; + super.set(x, y, z); + } - @Override - public void set(int x, int y, int z) { - initialized = true; - super.set(x, y, z); - } + public void setXCoord(int x) { + posX = x; + initialized = true; + } - public void setXCoord(int x){ - posX = x; - initialized = true; - } + public void setYCoord(int y) { + posY = y; + initialized = true; + } - public void setYCoord(int y){ - posY = y; - initialized = true; - } + public void setZCoord(int z) { + posZ = z; + initialized = true; + } - public void setZCoord(int z){ - posZ = z; - initialized = true; - } + public TileEntity getTileEntity(World world) { + return world.getTileEntity(posX, posY, posZ); + } - public TileEntity getTileEntity(World world) { return world.getTileEntity(posX, posY, posZ); } + public void writeToNBT(NBTTagCompound compound, String key) { + compound.setInteger("X_" + key, posX); + compound.setInteger("Y_" + key, posY); + compound.setInteger("Z_" + key, posZ); + compound.setBoolean("Init_" + key, initialized); + } - public void writeToNBT(NBTTagCompound compound, String key) { - compound.setInteger("X_"+key, posX); - compound.setInteger("Y_"+key, posY); - compound.setInteger("Z_"+key, posZ); - compound.setBoolean("Init_"+key, initialized); - } + public void readFromNBT(NBTTagCompound compound, String key) { + posX = compound.getInteger("X_" + key); + posY = compound.getInteger("Y_" + key); + posZ = compound.getInteger("Z_" + key); + initialized = compound.getBoolean("Z_" + key); + } + } - public void readFromNBT(NBTTagCompound compound, String key) { - posX = compound.getInteger("X_"+key); - posY = compound.getInteger("Y_"+key); - posZ = compound.getInteger("Z_"+key); - initialized = compound.getBoolean("Z_"+key); - } - } + public static class TileOffset { + public int offsetX; + public int offsetY; + public int offsetZ; - public static class TileOffset { - public int offsetX; - public int offsetY; - public int offsetZ; + public TileOffset() { + } - public TileOffset(){} + public TileOffset(int x, int y, int z, int offsetX, int offsetY, int offsetZ) { + this.offsetX = x - offsetX; + this.offsetY = y - offsetY; + this.offsetZ = z - offsetZ; + } - public TileOffset(int x, int y, int z, int offsetX, int offsetY, int offsetZ){ - this.offsetX = x - offsetX; - this.offsetY = y - offsetY; - this.offsetZ = z - offsetZ; - } + public TileOffset(TileEntity tile1, TileEntity offsetTile) { + this.offsetX = tile1.xCoord - offsetTile.xCoord; + this.offsetY = tile1.yCoord - offsetTile.yCoord; + this.offsetZ = tile1.zCoord - offsetTile.zCoord; + } - public TileOffset(TileEntity tile1, TileEntity offsetTile){ - this.offsetX = tile1.xCoord - offsetTile.xCoord; - this.offsetY = tile1.yCoord - offsetTile.yCoord; - this.offsetZ = tile1.zCoord - offsetTile.zCoord; - } + public int getXCoord(TileEntity tileEntity) { + return tileEntity.xCoord - offsetX; + } - public int getXCoord(TileEntity tileEntity){ - return tileEntity.xCoord - offsetX; - } + public int getYCoord(TileEntity tileEntity) { + return tileEntity.yCoord - offsetY; + } - public int getYCoord(TileEntity tileEntity){ - return tileEntity.yCoord - offsetY; - } + public int getZCoord(TileEntity tileEntity) { + return tileEntity.zCoord - offsetZ; + } - public int getZCoord(TileEntity tileEntity){ - return tileEntity.zCoord - offsetZ; - } + public int getXCoord(int xCoord) { + return xCoord - offsetX; + } - public int getXCoord(int xCoord){ - return xCoord - offsetX; - } + public int getYCoord(int yCoord) { + return yCoord - offsetY; + } - public int getYCoord(int yCoord){ - return yCoord - offsetY; - } + public int getZCoord(int zCoord) { + return zCoord - offsetZ; + } - public int getZCoord(int zCoord){ - return zCoord - offsetZ; - } + public TileEntity getTileEntity(TileEntity tileEntity) { + return tileEntity.getWorldObj().getTileEntity(getXCoord(tileEntity), getYCoord(tileEntity), getZCoord(tileEntity)); + } - public TileEntity getTileEntity(TileEntity tileEntity) { return tileEntity.getWorldObj().getTileEntity(getXCoord(tileEntity), getYCoord(tileEntity), getZCoord(tileEntity)); } + public void writeToNBT(NBTTagCompound compound, String key) { + compound.setInteger("X_" + key, offsetX); + compound.setInteger("Y_" + key, offsetY); + compound.setInteger("Z_" + key, offsetZ); + } - public void writeToNBT(NBTTagCompound compound, String key) { - compound.setInteger("X_"+key, offsetX); - compound.setInteger("Y_"+key, offsetY); - compound.setInteger("Z_"+key, offsetZ); - } - - public void readFromNBT(NBTTagCompound compound, String key) { - offsetX = compound.getInteger("X_"+key); - offsetY = compound.getInteger("Y_"+key); - offsetZ = compound.getInteger("Z_"+key); - } - } + public void readFromNBT(NBTTagCompound compound, String key) { + offsetX = compound.getInteger("X_" + key); + offsetY = compound.getInteger("Y_" + key); + offsetZ = compound.getInteger("Z_" + key); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/Portal.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/Portal.java index c65cbe9b..915faead 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/Portal.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/Portal.java @@ -23,108 +23,111 @@ import java.util.Random; /** * Created by Brandon on 23/5/2015. */ -public class Portal extends BlockDE implements ITileEntityProvider{ +public class Portal extends BlockDE implements ITileEntityProvider { - public Portal(){ - super(Material.portal); - this.setBlockUnbreakable(); - this.setBlockName("portal"); + public Portal() { + super(Material.portal); + this.setBlockUnbreakable(); + this.setBlockName("portal"); - ModBlocks.register(this); - } + ModBlocks.register(this); + } - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "transparency"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "transparency"); + } - @Override - public int getRenderType() { - return References.idPortal; - } + @Override + public int getRenderType() { + return References.idPortal; + } - @Override - public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_) { - return AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0); - } + @Override + public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_) { + return AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0); + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public TileEntity createNewTileEntity(World world, int i) { - return new TilePortalBlock(); - } + @Override + public TileEntity createNewTileEntity(World world, int i) { + return new TilePortalBlock(); + } - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { - return null; - } + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) { + return null; + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - if (world.isRemote) return; - if (getMaster(world, x, y, z) == null){ - world.setBlockToAir(x, y, z); - return; - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + if (world.isRemote) return; + if (getMaster(world, x, y, z) == null) { + world.setBlockToAir(x, y, z); + return; + } - if (getMaster(world, x, y, z).isActive) getMaster(world, x, y, z).validateActivePortal(); - if (!getMaster(world, x, y, z).isActive && !getMaster(world, x, y, z).updating) { - world.setBlockToAir(x, y, z); - return; - } - updateMetadata(world, x, y, z); - } + if (getMaster(world, x, y, z).isActive) getMaster(world, x, y, z).validateActivePortal(); + if (!getMaster(world, x, y, z).isActive && !getMaster(world, x, y, z).updating) { + world.setBlockToAir(x, y, z); + return; + } + updateMetadata(world, x, y, z); + } - @Override - public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { - if (world.isRemote) return; - TileDislocatorReceptacle tile = getMaster(world, x, y, z); - if (tile != null && tile.isActive && tile.getLocation() != null) { - if (tile.coolDown > 0) return; - tile.coolDown = 1; - tile.getLocation().sendEntityToCoords(entity); - } - else if (tile != null) tile.validateActivePortal(); - else world.setBlockToAir(x, y, z); - } + @Override + public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { + if (world.isRemote) return; + TileDislocatorReceptacle tile = getMaster(world, x, y, z); + if (tile != null && tile.isActive && tile.getLocation() != null) { + if (tile.coolDown > 0) return; + tile.coolDown = 1; + tile.getLocation().sendEntityToCoords(entity); + } else if (tile != null) tile.validateActivePortal(); + else world.setBlockToAir(x, y, z); + } - private TileDislocatorReceptacle getMaster(World world, int x, int y, int z){ - return world.getTileEntity(x, y, z) instanceof TilePortalBlock ? ((TilePortalBlock)world.getTileEntity(x, y, z)).getMaster() : null; - } + private TileDislocatorReceptacle getMaster(World world, int x, int y, int z) { + return world.getTileEntity(x, y, z) instanceof TilePortalBlock ? ((TilePortalBlock) world.getTileEntity(x, y, z)).getMaster() : null; + } - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return null; } + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return null; + } - private boolean isPortalOrFrame(IBlockAccess access, int x, int y, int z) { - Block block = access.getBlock(x, y, z); - return block == ModBlocks.portal || block == ModBlocks.infusedObsidian || block == ModBlocks.dislocatorReceptacle; - } + private boolean isPortalOrFrame(IBlockAccess access, int x, int y, int z) { + Block block = access.getBlock(x, y, z); + return block == ModBlocks.portal || block == ModBlocks.infusedObsidian || block == ModBlocks.dislocatorReceptacle; + } - @Override - public void onBlockAdded(World world, int x, int y, int z) { - updateMetadata(world, x, y, z); - } + @Override + public void onBlockAdded(World world, int x, int y, int z) { + updateMetadata(world, x, y, z); + } - private void updateMetadata(World world, int x, int y, int z) { - if (world.isRemote || world.getBlockMetadata(x, y, z) != 0) return; - int meta = 0; + private void updateMetadata(World world, int x, int y, int z) { + if (world.isRemote || world.getBlockMetadata(x, y, z) != 0) return; + int meta = 0; - if (isPortalOrFrame(world, x, y + 1, z) && isPortalOrFrame(world, x, y - 1, z) && isPortalOrFrame(world, x + 1, y, z) && isPortalOrFrame(world, x - 1, y, z)) meta = 1; - else if (isPortalOrFrame(world, x, y + 1, z) && isPortalOrFrame(world, x, y - 1, z) && isPortalOrFrame(world, x, y, z + 1) && isPortalOrFrame(world, x, y, z - 1)) meta = 2; - else if (isPortalOrFrame(world, x + 1, y, z) && isPortalOrFrame(world, x - 1, y, z) && isPortalOrFrame(world, x, y, z + 1) && isPortalOrFrame(world, x, y, z - 1)) meta = 3; + if (isPortalOrFrame(world, x, y + 1, z) && isPortalOrFrame(world, x, y - 1, z) && isPortalOrFrame(world, x + 1, y, z) && isPortalOrFrame(world, x - 1, y, z)) + meta = 1; + else if (isPortalOrFrame(world, x, y + 1, z) && isPortalOrFrame(world, x, y - 1, z) && isPortalOrFrame(world, x, y, z + 1) && isPortalOrFrame(world, x, y, z - 1)) + meta = 2; + else if (isPortalOrFrame(world, x + 1, y, z) && isPortalOrFrame(world, x - 1, y, z) && isPortalOrFrame(world, x, y, z + 1) && isPortalOrFrame(world, x, y, z - 1)) + meta = 3; - world.setBlockMetadataWithNotify(x, y, z, meta, 2); - } + world.setBlockMetadataWithNotify(x, y, z, meta, 2); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/ReactorCore.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/ReactorCore.java index 533e949d..2d6f296f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/ReactorCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/ReactorCore.java @@ -19,69 +19,69 @@ import net.minecraft.world.World; */ public class ReactorCore extends BlockDE { - public ReactorCore(){ - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setBlockName("reactorCore"); - this.setHardness(100F); + public ReactorCore() { + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setBlockName("reactorCore"); + this.setHardness(100F); - ModBlocks.register(this); - } + ModBlocks.register(this); + } - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "transparency"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "transparency"); + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public int getRenderType() { - return -1; - } + @Override + public int getRenderType() { + return -1; + } - @Override - public boolean hasTileEntity(int metadata) { - return true; - } + @Override + public boolean hasTileEntity(int metadata) { + return true; + } - @Override - public TileEntity createTileEntity(World world, int metadata) { - return new TileReactorCore(); - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileReactorCore(); + } - @Override - public void onBlockAdded(World world, int x, int y, int z) { - TileReactorCore tile = world.getTileEntity(x, y, z) instanceof TileReactorCore ? (TileReactorCore) world.getTileEntity(x, y, z) : null; - if (tile != null) tile.onPlaced(); - } + @Override + public void onBlockAdded(World world, int x, int y, int z) { + TileReactorCore tile = world.getTileEntity(x, y, z) instanceof TileReactorCore ? (TileReactorCore) world.getTileEntity(x, y, z) : null; + if (tile != null) tile.onPlaced(); + } - @Override - public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int x, int y, int z) { + @Override + public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int x, int y, int z) { - return AxisAlignedBB.getBoundingBox(0, 0, 0, 1, 1, 1);//super.getSelectedBoundingBoxFromPool(p_149633_1_, x, y, z); - } + return AxisAlignedBB.getBoundingBox(0, 0, 0, 1, 1, 1);//super.getSelectedBoundingBoxFromPool(p_149633_1_, x, y, z); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - //TileReactorCore tile = world.getTileEntity(x, y, z) instanceof TileReactorCore ? (TileReactorCore) world.getTileEntity(x, y, z) : null; - //if (tile != null) return tile.onStructureRightClicked(player); - return false; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + //TileReactorCore tile = world.getTileEntity(x, y, z) instanceof TileReactorCore ? (TileReactorCore) world.getTileEntity(x, y, z) : null; + //if (tile != null) return tile.onStructureRightClicked(player); + return false; + } - @Override - public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int p_149749_6_) { - TileReactorCore tile = world.getTileEntity(x, y, z) instanceof TileReactorCore ? (TileReactorCore) world.getTileEntity(x, y, z) : null; - if (tile != null) tile.onBroken(); - super.breakBlock(world, x, y, z, p_149749_5_, p_149749_6_); - } + @Override + public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int p_149749_6_) { + TileReactorCore tile = world.getTileEntity(x, y, z) instanceof TileReactorCore ? (TileReactorCore) world.getTileEntity(x, y, z) : null; + if (tile != null) tile.onBroken(); + super.breakBlock(world, x, y, z, p_149749_5_, p_149749_6_); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/ReactorEnergyInjector.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/ReactorEnergyInjector.java index 6c685445..4bb3098d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/ReactorEnergyInjector.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/ReactorEnergyInjector.java @@ -24,107 +24,130 @@ import net.minecraftforge.common.util.ForgeDirection; * Created by Brandon on 23/7/2015. */ public class ReactorEnergyInjector extends BlockDE { - public ReactorEnergyInjector(){ - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setBlockName("reactorEnergyInjector"); + public ReactorEnergyInjector() { + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setBlockName("reactorEnergyInjector"); - ModBlocks.register(this); - } + ModBlocks.register(this); + } - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "transparency"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "transparency"); + } - @Override - public void setBlockBoundsBasedOnState(IBlockAccess access, int x, int y, int z) { - TileReactorEnergyInjector tile = access.getTileEntity(x, y, z) instanceof TileReactorEnergyInjector ? (TileReactorEnergyInjector) access.getTileEntity(x, y, z) : null; - if (tile != null){ - switch (tile.facingDirection){ - case 0: this.setBlockBounds(0F, 0.885F, 0F, 1F, 1F, 1F); break; - case 1: this.setBlockBounds(0F, 0F, 0F, 1F, 0.125F, 1F); break; - case 2: this.setBlockBounds(0F, 0F, 0.885F, 1F, 1F, 1F); break; - case 3: this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 0.125F); break; - case 4: this.setBlockBounds(0.885F, 0F, 0F, 1F, 1F, 1F); break; - case 5: this.setBlockBounds(0F, 0F, 0F, 0.125F, 1F, 1F); break; - } - } - super.setBlockBoundsBasedOnState(access, x, y, z); - } + @Override + public void setBlockBoundsBasedOnState(IBlockAccess access, int x, int y, int z) { + TileReactorEnergyInjector tile = access.getTileEntity(x, y, z) instanceof TileReactorEnergyInjector ? (TileReactorEnergyInjector) access.getTileEntity(x, y, z) : null; + if (tile != null) { + switch (tile.facingDirection) { + case 0: + this.setBlockBounds(0F, 0.885F, 0F, 1F, 1F, 1F); + break; + case 1: + this.setBlockBounds(0F, 0F, 0F, 1F, 0.125F, 1F); + break; + case 2: + this.setBlockBounds(0F, 0F, 0.885F, 1F, 1F, 1F); + break; + case 3: + this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 0.125F); + break; + case 4: + this.setBlockBounds(0.885F, 0F, 0F, 1F, 1F, 1F); + break; + case 5: + this.setBlockBounds(0F, 0F, 0F, 0.125F, 1F, 1F); + break; + } + } + super.setBlockBoundsBasedOnState(access, x, y, z); + } - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { - TileReactorEnergyInjector tile = world.getTileEntity(x, y, z) instanceof TileReactorEnergyInjector ? (TileReactorEnergyInjector) world.getTileEntity(x, y, z) : null; - if (tile != null){ - switch (tile.facingDirection){ - case 0: this.setBlockBounds(0F, 0.885F, 0F, 1F, 1F, 1F); break; - case 1: this.setBlockBounds(0F, 0F, 0F, 1F, 0.125F, 1F); break; - case 2: this.setBlockBounds(0F, 0F, 0.885F, 1F, 1F, 1F); break; - case 3: this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 0.125F); break; - case 4: this.setBlockBounds(0.885F, 0F, 0F, 1F, 1F, 1F); break; - case 5: this.setBlockBounds(0F, 0F, 0F, 0.125F, 1F, 1F); break; - } - } - return super.getCollisionBoundingBoxFromPool(world, x, y, z); - } + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + TileReactorEnergyInjector tile = world.getTileEntity(x, y, z) instanceof TileReactorEnergyInjector ? (TileReactorEnergyInjector) world.getTileEntity(x, y, z) : null; + if (tile != null) { + switch (tile.facingDirection) { + case 0: + this.setBlockBounds(0F, 0.885F, 0F, 1F, 1F, 1F); + break; + case 1: + this.setBlockBounds(0F, 0F, 0F, 1F, 0.125F, 1F); + break; + case 2: + this.setBlockBounds(0F, 0F, 0.885F, 1F, 1F, 1F); + break; + case 3: + this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 0.125F); + break; + case 4: + this.setBlockBounds(0.885F, 0F, 0F, 1F, 1F, 1F); + break; + case 5: + this.setBlockBounds(0F, 0F, 0F, 0.125F, 1F, 1F); + break; + } + } + return super.getCollisionBoundingBoxFromPool(world, x, y, z); + } - @Override - public int getRenderType() { - return -1; - } + @Override + public int getRenderType() { + return -1; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - int d = Utills.determineOrientation(x, y, z, entity); - TileReactorEnergyInjector tile = (TileReactorEnergyInjector)world.getTileEntity(x, y, z); - tile.facingDirection = ForgeDirection.getOrientation(d).getOpposite().ordinal(); - tile.onPlaced(); - } + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + int d = Utills.determineOrientation(x, y, z, entity); + TileReactorEnergyInjector tile = (TileReactorEnergyInjector) world.getTileEntity(x, y, z); + tile.facingDirection = ForgeDirection.getOrientation(d).getOpposite().ordinal(); + tile.onPlaced(); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - IReactorPart tile = world.getTileEntity(x, y, z) instanceof IReactorPart ? (IReactorPart)world.getTileEntity(x, y, z) : null; - if (tile != null && player.isSneaking()) { - tile.changeRedstoneMode(); - if(!world.isRemote) player.addChatComponentMessage(new ChatComponentText(tile.getRedstoneModeString())); - return true; - } - return false; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + IReactorPart tile = world.getTileEntity(x, y, z) instanceof IReactorPart ? (IReactorPart) world.getTileEntity(x, y, z) : null; + if (tile != null && player.isSneaking()) { + tile.changeRedstoneMode(); + if (!world.isRemote) player.addChatComponentMessage(new ChatComponentText(tile.getRedstoneModeString())); + return true; + } + return false; + } - public boolean hasComparatorInputOverride() - { - return true; - } + public boolean hasComparatorInputOverride() { + return true; + } - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int p_149736_5_) { - IReactorPart tile = world.getTileEntity(x, y, z) instanceof IReactorPart ? (IReactorPart)world.getTileEntity(x, y, z) : null; - if (tile == null) return 0; - TileReactorCore core = tile.getMaster().getTileEntity(world) instanceof TileReactorCore ? (TileReactorCore) tile.getMaster().getTileEntity(world) : null; - if (core != null) return core.getComparatorOutput(tile.getRedstoneMode()); - return 0; - } + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int p_149736_5_) { + IReactorPart tile = world.getTileEntity(x, y, z) instanceof IReactorPart ? (IReactorPart) world.getTileEntity(x, y, z) : null; + if (tile == null) return 0; + TileReactorCore core = tile.getMaster().getTileEntity(world) instanceof TileReactorCore ? (TileReactorCore) tile.getMaster().getTileEntity(world) : null; + if (core != null) return core.getComparatorOutput(tile.getRedstoneMode()); + return 0; + } - @Override - public boolean hasTileEntity(int metadata) { - return true; - } + @Override + public boolean hasTileEntity(int metadata) { + return true; + } - @Override - public TileEntity createTileEntity(World world, int metadata) { - return new TileReactorEnergyInjector(); - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileReactorEnergyInjector(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/ReactorStabilizer.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/ReactorStabilizer.java index 642d1ec7..81ed47d3 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/ReactorStabilizer.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/ReactorStabilizer.java @@ -23,98 +23,95 @@ import net.minecraftforge.common.util.ForgeDirection; * Created by Brandon on 5/7/2015. */ public class ReactorStabilizer extends BlockDE { - public ReactorStabilizer() { - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setBlockName("reactorStabilizer"); - ModBlocks.register(this); - } + public ReactorStabilizer() { + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setBlockName("reactorStabilizer"); + ModBlocks.register(this); + } - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "transparency"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "transparency"); + } - @Override - public int getRenderType() { - return -1; - } + @Override + public int getRenderType() { + return -1; + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - if (!player.isSneaking()) - { - TileReactorStabilizer tile = world.getTileEntity(x, y, z) instanceof TileReactorStabilizer ? (TileReactorStabilizer) world.getTileEntity(x, y, z) : null; - TileEntity core = null; - if (tile != null) core = tile.getMaster().getTileEntity(world); - if (core instanceof TileReactorCore) - { - ((TileReactorCore) core).onStructureRightClicked(player); - return true; - } - } - else if (!world.isRemote){ - IReactorPart tile = world.getTileEntity(x, y, z) instanceof IReactorPart ? (IReactorPart)world.getTileEntity(x, y, z) : null; - if (tile != null) { - tile.changeRedstoneMode(); - if(!world.isRemote) player.addChatComponentMessage(new ChatComponentText(tile.getRedstoneModeString())); - return true; - } - } - return false; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + if (!player.isSneaking()) { + TileReactorStabilizer tile = world.getTileEntity(x, y, z) instanceof TileReactorStabilizer ? (TileReactorStabilizer) world.getTileEntity(x, y, z) : null; + TileEntity core = null; + if (tile != null) core = tile.getMaster().getTileEntity(world); + if (core instanceof TileReactorCore) { + ((TileReactorCore) core).onStructureRightClicked(player); + return true; + } + } else if (!world.isRemote) { + IReactorPart tile = world.getTileEntity(x, y, z) instanceof IReactorPart ? (IReactorPart) world.getTileEntity(x, y, z) : null; + if (tile != null) { + tile.changeRedstoneMode(); + if (!world.isRemote) + player.addChatComponentMessage(new ChatComponentText(tile.getRedstoneModeString())); + return true; + } + } + return false; + } - @Override - public boolean renderAsNormalBlock() { - return false; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public boolean hasTileEntity(int metadata) { - return true; - } + @Override + public boolean hasTileEntity(int metadata) { + return true; + } - @Override - public TileEntity createTileEntity(World world, int metadata) { - return new TileReactorStabilizer(); - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileReactorStabilizer(); + } - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { - int d = Utills.determineOrientation(x, y, z, entity); - TileReactorStabilizer tile = world.getTileEntity(x, y, z) instanceof TileReactorStabilizer ? (TileReactorStabilizer)world.getTileEntity(x, y, z) : null; - if (tile != null){ - if (entity.isSneaking()) tile.facingDirection = ForgeDirection.getOrientation(d).getOpposite().ordinal(); - else tile.facingDirection = ForgeDirection.getOrientation(d).ordinal(); - tile.onPlaced(); - } - } + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + int d = Utills.determineOrientation(x, y, z, entity); + TileReactorStabilizer tile = world.getTileEntity(x, y, z) instanceof TileReactorStabilizer ? (TileReactorStabilizer) world.getTileEntity(x, y, z) : null; + if (tile != null) { + if (entity.isSneaking()) tile.facingDirection = ForgeDirection.getOrientation(d).getOpposite().ordinal(); + else tile.facingDirection = ForgeDirection.getOrientation(d).ordinal(); + tile.onPlaced(); + } + } - @Override - public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int p_149749_6_) { - TileReactorStabilizer tile = world.getTileEntity(x, y, z) instanceof TileReactorStabilizer ? (TileReactorStabilizer)world.getTileEntity(x, y, z) : null; - TileEntity core = null; - if (tile != null) core = tile.getMaster().getTileEntity(world); - super.breakBlock(world, x, y, z, p_149749_5_, p_149749_6_); - if (core instanceof TileReactorCore) ((TileReactorCore) core).validateStructure(); - } + @Override + public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int p_149749_6_) { + TileReactorStabilizer tile = world.getTileEntity(x, y, z) instanceof TileReactorStabilizer ? (TileReactorStabilizer) world.getTileEntity(x, y, z) : null; + TileEntity core = null; + if (tile != null) core = tile.getMaster().getTileEntity(world); + super.breakBlock(world, x, y, z, p_149749_5_, p_149749_6_); + if (core instanceof TileReactorCore) ((TileReactorCore) core).validateStructure(); + } - public boolean hasComparatorInputOverride() - { - return true; - } + public boolean hasComparatorInputOverride() { + return true; + } - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int p_149736_5_) { - IReactorPart tile = world.getTileEntity(x, y, z) instanceof IReactorPart ? (IReactorPart)world.getTileEntity(x, y, z) : null; - if (tile == null) return 0; - TileReactorCore core = tile.getMaster().getTileEntity(world) instanceof TileReactorCore ? (TileReactorCore) tile.getMaster().getTileEntity(world) : null; - if (core != null) return core.getComparatorOutput(tile.getRedstoneMode()); - return 0; - } + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int p_149736_5_) { + IReactorPart tile = world.getTileEntity(x, y, z) instanceof IReactorPart ? (IReactorPart) world.getTileEntity(x, y, z) : null; + if (tile == null) return 0; + TileReactorCore core = tile.getMaster().getTileEntity(world) instanceof TileReactorCore ? (TileReactorCore) tile.getMaster().getTileEntity(world) : null; + if (core != null) return core.getComparatorOutput(tile.getRedstoneMode()); + return 0; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerAdvTool.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerAdvTool.java index 93b5d557..740eeef4 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerAdvTool.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerAdvTool.java @@ -21,79 +21,73 @@ import java.util.ArrayList; */ public class ContainerAdvTool extends ContainerDataSync { - public InventoryTool inventoryTool; - private EntityPlayer player; - public int inventoryItemSlot = -1; - private boolean slotsActive = false; + public InventoryTool inventoryTool; + private EntityPlayer player; + public int inventoryItemSlot = -1; + private boolean slotsActive = false; - public ContainerAdvTool(InventoryPlayer invPlayer, InventoryTool inventory) { - this.inventoryTool = inventory; - this.inventoryTool.setContainer(this); - this.player = invPlayer.player; - setSlotsActive(false); - } + public ContainerAdvTool(InventoryPlayer invPlayer, InventoryTool inventory) { + this.inventoryTool = inventory; + this.inventoryTool.setContainer(this); + this.player = invPlayer.player; + setSlotsActive(false); + } - public void setSlotsActive(boolean active) { - slotsActive = active; - inventoryItemStacks = new ArrayList(); - inventorySlots = new ArrayList(); + public void setSlotsActive(boolean active) { + slotsActive = active; + inventoryItemStacks = new ArrayList(); + inventorySlots = new ArrayList(); - if (slotsActive) - { - for (int x = 0; x < 9; x++) { - addSlotToContainer(new SlotPlayerInv(player.inventory, x, 8 + 18 * x, 103, inventoryItemSlot)); - } + if (slotsActive) { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new SlotPlayerInv(player.inventory, x, 8 + 18 * x, 103, inventoryItemSlot)); + } - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 9; x++) { - addSlotToContainer(new SlotPlayerInv(player.inventory, x + y * 9 + 9, 8 + 18 * x, 45 + y * 18, inventoryItemSlot)); - } - } + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new SlotPlayerInv(player.inventory, x + y * 9 + 9, 8 + 18 * x, 45 + y * 18, inventoryItemSlot)); + } + } - for (int x = 0; x < inventoryTool.size; x++) { - addSlotToContainer(new SlotOblitFilter(inventoryTool, x, 8 + 18 * x, 19)); - } + for (int x = 0; x < inventoryTool.size; x++) { + addSlotToContainer(new SlotOblitFilter(inventoryTool, x, 8 + 18 * x, 19)); + } - for (int y = 0; y < 5; y++) { - addSlotToContainer(new SlotEnchantment(inventoryTool, inventoryTool.size + y, 173, 19 + y * 21)); - } - } - else - { - for (int x = 0; x < 9; x++) { - addSlotToContainer(new SlotPlayerInv(player.inventory, x, -1000 + 8 + 18 * x, -1000 + 103, inventoryItemSlot)); - } + for (int y = 0; y < 5; y++) { + addSlotToContainer(new SlotEnchantment(inventoryTool, inventoryTool.size + y, 173, 19 + y * 21)); + } + } else { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new SlotPlayerInv(player.inventory, x, -1000 + 8 + 18 * x, -1000 + 103, inventoryItemSlot)); + } - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 9; x++) { - addSlotToContainer(new SlotPlayerInv(player.inventory, x + y * 9 + 9, -1000 + 8 + 18 * x, -1000 + 45 + y * 18, inventoryItemSlot)); - } - } - } + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new SlotPlayerInv(player.inventory, x + y * 9 + 9, -1000 + 8 + 18 * x, -1000 + 45 + y * 18, inventoryItemSlot)); + } + } + } - if (player.worldObj.isRemote) - { - sendObjectToServer(null, 1, active ? 1 : 0); - } - } + if (player.worldObj.isRemote) { + sendObjectToServer(null, 1, active ? 1 : 0); + } + } - public void setInventory(InventoryTool inventory) { - this.inventoryTool = inventory; - } + public void setInventory(InventoryTool inventory) { + this.inventoryTool = inventory; + } - public void setPlayer(EntityPlayer player) { - this.player = player; - } + public void setPlayer(EntityPlayer player) { + this.player = player; + } - @Override - public boolean canInteractWith(EntityPlayer player) - { - return true; - } + @Override + public boolean canInteractWith(EntityPlayer player) { + return true; + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int i) - { + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int i) { // Slot slot = getSlot(i); // // if (slot != null && slot.getHasStack()) @@ -120,75 +114,74 @@ public class ContainerAdvTool extends ContainerDataSync { // return result; // } - return null; - } + return null; + } - @Override - public void receiveSyncData(int index, int value) { - if (index == 0) - { - updateInventoryStack(value); - } - else if (index == 1) - { - setSlotsActive(value == 1); - } - } + @Override + public void receiveSyncData(int index, int value) { + if (index == 0) { + updateInventoryStack(value); + } else if (index == 1) { + setSlotsActive(value == 1); + } + } - public void updateInventoryStack(int slot){ - this.inventoryItemSlot = slot; - if (player.worldObj.isRemote){ - sendObjectToServer(null, 0, slot); - } + public void updateInventoryStack(int slot) { + this.inventoryItemSlot = slot; + if (player.worldObj.isRemote) { + sendObjectToServer(null, 0, slot); + } - if (player.inventory.getStackInSlot(slot) != null && player.inventory.getStackInSlot(slot).getItem() instanceof IInventoryTool){ - this.inventoryTool.setAndReadFromStack(player.inventory.getStackInSlot(slot), slot); - } - } + if (player.inventory.getStackInSlot(slot) != null && player.inventory.getStackInSlot(slot).getItem() instanceof IInventoryTool) { + this.inventoryTool.setAndReadFromStack(player.inventory.getStackInSlot(slot), slot); + } + } - public class SlotPlayerInv extends Slot - { - public int inventoryItemSlot = -1; - public SlotPlayerInv(IInventory iInventory, int slot, int x, int y, int inventoryItemSlot) { - super(iInventory, slot, x, y); - this.inventoryItemSlot = inventoryItemSlot; - } + public class SlotPlayerInv extends Slot { + public int inventoryItemSlot = -1; - @Override - public boolean canTakeStack(EntityPlayer player) { - return this.inventoryItemSlot != this.slotNumber && super.canTakeStack(player); - } - } + public SlotPlayerInv(IInventory iInventory, int slot, int x, int y, int inventoryItemSlot) { + super(iInventory, slot, x, y); + this.inventoryItemSlot = inventoryItemSlot; + } - public class SlotOblitFilter extends Slot - { - public SlotOblitFilter(IInventory iInventory, int slot, int x, int y) { - super(iInventory, slot, x, y); - } + @Override + public boolean canTakeStack(EntityPlayer player) { + return this.inventoryItemSlot != this.slotNumber && super.canTakeStack(player); + } + } - @Override - public boolean isItemValid(ItemStack stack) { - return stack != null && stack.getItem() instanceof ItemBlock && super.isItemValid(stack); - } + public class SlotOblitFilter extends Slot { + public SlotOblitFilter(IInventory iInventory, int slot, int x, int y) { + super(iInventory, slot, x, y); + } + + @Override + public boolean isItemValid(ItemStack stack) { + return stack != null && stack.getItem() instanceof ItemBlock && super.isItemValid(stack); + } - } + } - public class SlotEnchantment extends Slot { - InventoryTool inventory; - public SlotEnchantment(IInventory iInventory, int slot, int x, int y) { - super(iInventory, slot, x, y); - } + public class SlotEnchantment extends Slot { + InventoryTool inventory; - @Override - public boolean isItemValid(ItemStack stack) { - if (stack == null || stack.getItem() != Items.enchanted_book || !stack.hasTagCompound()) return false; - NBTTagList list = stack.getTagCompound().getTagList("StoredEnchantments", 10); - if (list.tagCount() != 1) return false; - Enchantment enchant = Enchantment.enchantmentsList[list.getCompoundTagAt(0).getInteger("id")]; - if (inventoryTool.inventoryItem == null || !(inventoryTool.inventoryItem.getItem() instanceof IInventoryTool) || (!((IInventoryTool) inventoryTool.inventoryItem.getItem()).isEnchantValid(enchant) && enchant.type != EnumEnchantmentType.all)) return false; - if (EnchantmentHelper.getEnchantments(inventoryTool.inventoryItem).containsKey(list.getCompoundTagAt(0).getInteger("id"))) return false; - return super.isItemValid(stack); - } - } + public SlotEnchantment(IInventory iInventory, int slot, int x, int y) { + super(iInventory, slot, x, y); + } + + @Override + public boolean isItemValid(ItemStack stack) { + if (stack == null || stack.getItem() != Items.enchanted_book || !stack.hasTagCompound()) return false; + NBTTagList list = stack.getTagCompound().getTagList("StoredEnchantments", 10); + if (list.tagCount() != 1) return false; + Enchantment enchant = Enchantment.enchantmentsList[list.getCompoundTagAt(0).getInteger("id")]; + if (inventoryTool.inventoryItem == null || !(inventoryTool.inventoryItem.getItem() instanceof IInventoryTool) || (!((IInventoryTool) inventoryTool.inventoryItem.getItem()).isEnchantValid(enchant) && enchant.type != EnumEnchantmentType.all)) + return false; + if (EnchantmentHelper.getEnchantments(inventoryTool.inventoryItem).containsKey(list.getCompoundTagAt(0).getInteger("id"))) + return false; + return super.isItemValid(stack); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerDataSync.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerDataSync.java index 10537de2..79eb0fe5 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerDataSync.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerDataSync.java @@ -12,34 +12,39 @@ import net.minecraft.inventory.Container; /** * Created by Brandon on 14/11/2014. */ -/**This class is for syncing values to bug for ICrafting*/ + +/** + * This class is for syncing values to bug for ICrafting + */ public abstract class ContainerDataSync extends Container { - //TODO WTF? Was i sleep coding when i wrote this? In 1.8 re write this as a common container class for all mod containers and use a dedicated sender/receiver method for each data type i want to send (Unless i think of something better between now and then) + //TODO WTF? Was i sleep coding when i wrote this? In 1.8 re write this as a common container class for all mod containers and use a dedicated sender/receiver method for each data type i want to send (Unless i think of something better between now and then) - /** - * Sends two ints to the client-side Container. Normally the first int identifies which variable to update, and the second contains the new - * value. - * if tile != null the packet will be sent to the tile client tile instead of the client container. - */ - public Object sendObjectToClient(TileObjectSync tile, int index, Object object){ - for (Object p : crafters){ - DraconicEvolution.network.sendTo(new TileObjectPacket(tile, References.INT_ID, index, object), (EntityPlayerMP)p); - } - return object; - } + /** + * Sends two ints to the client-side Container. Normally the first int identifies which variable to update, and the second contains the new + * value. + * if tile != null the packet will be sent to the tile client tile instead of the client container. + */ + public Object sendObjectToClient(TileObjectSync tile, int index, Object object) { + for (Object p : crafters) { + DraconicEvolution.network.sendTo(new TileObjectPacket(tile, References.INT_ID, index, object), (EntityPlayerMP) p); + } + return object; + } - /** - * Sends two ints to the server-side Container. Normally the first int identifies which variable to update, and the second contains the new - * value. - * if tile != null the packet will be sent to the tile client tile instead of the client container. - */ - @SideOnly(Side.CLIENT) - public Object sendObjectToServer(TileObjectSync tile, int index, Object object){ - DraconicEvolution.network.sendToServer(new TileObjectPacket(tile, References.INT_ID, index, object)); - return object; - } + /** + * Sends two ints to the server-side Container. Normally the first int identifies which variable to update, and the second contains the new + * value. + * if tile != null the packet will be sent to the tile client tile instead of the client container. + */ + @SideOnly(Side.CLIENT) + public Object sendObjectToServer(TileObjectSync tile, int index, Object object) { + DraconicEvolution.network.sendToServer(new TileObjectPacket(tile, References.INT_ID, index, object)); + return object; + } - /**Called when a packet is received from ether the client or the server*/ - public abstract void receiveSyncData(int index, int value); + /** + * Called when a packet is received from ether the client or the server + */ + public abstract void receiveSyncData(int index, int value); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerDissEnchanter.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerDissEnchanter.java index ed2f8c35..3605057f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerDissEnchanter.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerDissEnchanter.java @@ -14,148 +14,141 @@ import net.minecraft.item.ItemStack; public class ContainerDissEnchanter extends Container { - private TileDissEnchanter tile; - private EntityPlayer player; - private ItemStack cachIn0; - private ItemStack cachIn1; - private ItemStack cachIn2; - private boolean nullCheck0 = false; - private boolean nullCheck1 = false; - private boolean nullCheck2 = false; + private TileDissEnchanter tile; + private EntityPlayer player; + private ItemStack cachIn0; + private ItemStack cachIn1; + private ItemStack cachIn2; + private boolean nullCheck0 = false; + private boolean nullCheck1 = false; + private boolean nullCheck2 = false; - public ContainerDissEnchanter(InventoryPlayer invPlayer, TileDissEnchanter tile) { - this.tile = tile; - this.player = invPlayer.player; + public ContainerDissEnchanter(InventoryPlayer invPlayer, TileDissEnchanter tile) { + this.tile = tile; + this.player = invPlayer.player; - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 118)); - } + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 118)); + } - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 60 + y * 18)); - } - } + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 60 + y * 18)); + } + } - addSlotToContainer(new SlotEnchantedItem(tile, 0, 27, 23)); - addSlotToContainer(new SlotBook(tile, 1, 76, 23)); - addSlotToContainer(new SlotOutput(tile, 2, 134, 23)); - } + addSlotToContainer(new SlotEnchantedItem(tile, 0, 27, 23)); + addSlotToContainer(new SlotBook(tile, 1, 76, 23)); + addSlotToContainer(new SlotOutput(tile, 2, 134, 23)); + } - @Override - public boolean canInteractWith(EntityPlayer player) - { - return tile.isUseableByPlayer(player); - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int i) - { - Slot slot = getSlot(i); + @Override + public boolean canInteractWith(EntityPlayer player) { + return tile.isUseableByPlayer(player); + } - if (slot != null && slot.getHasStack()) - { - ItemStack stack = slot.getStack(); - ItemStack result = stack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int i) { + Slot slot = getSlot(i); - if (i >= 36){ - if (!mergeItemStack(stack, 0, 36, false)){ - return null; - } - }else if ((!isStackValidForInventory(stack, 0) || !mergeItemStack(stack, 36, 37, false)) && (!isStackValidForInventory(stack, 1) || !mergeItemStack(stack, 37, 38, false))){ - return null; - } + if (slot != null && slot.getHasStack()) { + ItemStack stack = slot.getStack(); + ItemStack result = stack.copy(); - if (stack.stackSize == 0) { - slot.putStack(null); - }else{ - slot.onSlotChanged(); - } + if (i >= 36) { + if (!mergeItemStack(stack, 0, 36, false)) { + return null; + } + } else if ((!isStackValidForInventory(stack, 0) || !mergeItemStack(stack, 36, 37, false)) && (!isStackValidForInventory(stack, 1) || !mergeItemStack(stack, 37, 38, false))) { + return null; + } - slot.onPickupFromSlot(player, stack); + if (stack.stackSize == 0) { + slot.putStack(null); + } else { + slot.onSlotChanged(); + } - return result; - } + slot.onPickupFromSlot(player, stack); - return null; - } + return result; + } - private boolean isStackValidForInventory(ItemStack stack, int slot){ - if (slot == 0 && EnchantmentHelper.getEnchantments(stack).size() > 0) return true; - if (slot == 1 && stack.getItem().equals(Items.book)) return true; - return false; - } + return null; + } - public class SlotBook extends Slot { - public SlotBook(IInventory inventory, int id, int x, int y) { - super(inventory, id, x, y); - } + private boolean isStackValidForInventory(ItemStack stack, int slot) { + if (slot == 0 && EnchantmentHelper.getEnchantments(stack).size() > 0) return true; + if (slot == 1 && stack.getItem().equals(Items.book)) return true; + return false; + } - @Override - public boolean isItemValid(ItemStack stack) - { - return stack.getItem().equals(Items.book); - } + public class SlotBook extends Slot { + public SlotBook(IInventory inventory, int id, int x, int y) { + super(inventory, id, x, y); + } - @Override - public int getSlotStackLimit() - { - return 64; - } - } + @Override + public boolean isItemValid(ItemStack stack) { + return stack.getItem().equals(Items.book); + } - public class SlotEnchantedItem extends Slot { - public SlotEnchantedItem(IInventory inventory, int id, int x, int y) { - super(inventory, id, x, y); - } + @Override + public int getSlotStackLimit() { + return 64; + } + } - @Override - public boolean isItemValid(ItemStack stack) - { - return EnchantmentHelper.getEnchantments(stack).size() > 0 || ItemNBTHelper.getInteger(stack, "RepairCost", 0) > 0; - } + public class SlotEnchantedItem extends Slot { + public SlotEnchantedItem(IInventory inventory, int id, int x, int y) { + super(inventory, id, x, y); + } - @Override - public int getSlotStackLimit() - { - return 1; - } - } + @Override + public boolean isItemValid(ItemStack stack) { + return EnchantmentHelper.getEnchantments(stack).size() > 0 || ItemNBTHelper.getInteger(stack, "RepairCost", 0) > 0; + } - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - ItemStack stack0 = tile.getStackInSlot(0); - ItemStack stack1 = tile.getStackInSlot(1); - ItemStack stack2 = tile.getStackInSlot(2); - if ((stack0 == null) != nullCheck0){ - tile.onInventoryChanged(); - nullCheck0 = (stack0 == null); - } - if ((stack1 == null) != nullCheck1){ - tile.onInventoryChanged(); - nullCheck1 = (stack1 == null); - } - if ((stack2 == null) != nullCheck2){ - tile.onInventoryChanged(); - nullCheck2 = (stack2 == null); - } + @Override + public int getSlotStackLimit() { + return 1; + } + } - if (stack0 != null && !ItemStack.areItemStacksEqual(stack0, cachIn0)) { - cachIn0 = stack0.copy(); - tile.onInventoryChanged(); - } - if (stack1 != null && !ItemStack.areItemStacksEqual(stack1, cachIn1)) { - cachIn1 = stack1.copy(); - tile.onInventoryChanged(); - } - if (stack2 != null && !ItemStack.areItemStacksEqual(stack2, cachIn2)) { - cachIn2 = stack2.copy(); - tile.onInventoryChanged(); - } - } + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + ItemStack stack0 = tile.getStackInSlot(0); + ItemStack stack1 = tile.getStackInSlot(1); + ItemStack stack2 = tile.getStackInSlot(2); + if ((stack0 == null) != nullCheck0) { + tile.onInventoryChanged(); + nullCheck0 = (stack0 == null); + } + if ((stack1 == null) != nullCheck1) { + tile.onInventoryChanged(); + nullCheck1 = (stack1 == null); + } + if ((stack2 == null) != nullCheck2) { + tile.onInventoryChanged(); + nullCheck2 = (stack2 == null); + } - public TileDissEnchanter getTile(){ - return tile; - } + if (stack0 != null && !ItemStack.areItemStacksEqual(stack0, cachIn0)) { + cachIn0 = stack0.copy(); + tile.onInventoryChanged(); + } + if (stack1 != null && !ItemStack.areItemStacksEqual(stack1, cachIn1)) { + cachIn1 = stack1.copy(); + tile.onInventoryChanged(); + } + if (stack2 != null && !ItemStack.areItemStacksEqual(stack2, cachIn2)) { + cachIn2 = stack2.copy(); + tile.onInventoryChanged(); + } + } + + public TileDissEnchanter getTile() { + return tile; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerDraconiumChest.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerDraconiumChest.java index b8ccc10d..1a6c8506 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerDraconiumChest.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerDraconiumChest.java @@ -21,268 +21,245 @@ import net.minecraftforge.common.util.ForgeDirection; @ChestContainer(isLargeChest = false, rowSize = 26) public class ContainerDraconiumChest extends Container { - /** The crafting matrix inventory (3x3). */ - public InventoryCrafting craftMatrix; - public IInventory craftResult; - private TileDraconiumChest tile; - private EntityPlayer player; - private World worldObj; + /** + * The crafting matrix inventory (3x3). + */ + public InventoryCrafting craftMatrix; + public IInventory craftResult; + private TileDraconiumChest tile; + private EntityPlayer player; + private World worldObj; - private int lastProgressTime; - /**how much energy is stored in the tile*/ - private int lastEnergyStored; - private int lastBurnSpeed; - private int lastTickFeedMode; - private boolean lastTickOutputLock; + private int lastProgressTime; + /** + * how much energy is stored in the tile + */ + private int lastEnergyStored; + private int lastBurnSpeed; + private int lastTickFeedMode; + private boolean lastTickOutputLock; - public ContainerDraconiumChest(InventoryPlayer invPlayer, TileDraconiumChest tile) { - this.tile = tile; - this.player = invPlayer.player; - this.worldObj = tile.getWorldObj(); - tile.openInventory(); + public ContainerDraconiumChest(InventoryPlayer invPlayer, TileDraconiumChest tile) { + this.tile = tile; + this.player = invPlayer.player; + this.worldObj = tile.getWorldObj(); + tile.openInventory(); - craftMatrix = new InventoryCraftingChest(this, 3, 3, tile); - craftResult = new InventoryCraftingChestResult(tile); + craftMatrix = new InventoryCraftingChest(this, 3, 3, tile); + craftResult = new InventoryCraftingChestResult(tile); - addContainerSlots(); + addContainerSlots(); - addCraftingSlots(); + addCraftingSlots(); - addPlayerInventory(); + addPlayerInventory(); - onCraftMatrixChanged(craftMatrix); - } + onCraftMatrixChanged(craftMatrix); + } - private void addContainerSlots(){ - for (int chestRow = 0; chestRow < 9; chestRow++) - { - for (int chestCol = 0; chestCol < 26; chestCol++) - { - addSlotToContainer(new SlotDChest(tile, chestCol + (chestRow * 26), 8 + chestCol * 18, 15 + chestRow * 18)); - } - } + private void addContainerSlots() { + for (int chestRow = 0; chestRow < 9; chestRow++) { + for (int chestCol = 0; chestCol < 26; chestCol++) { + addSlotToContainer(new SlotDChest(tile, chestCol + (chestRow * 26), 8 + chestCol * 18, 15 + chestRow * 18)); + } + } - } + } - private void addPlayerInventory(){ - for (int playerInvRow = 0; playerInvRow < 3; playerInvRow++) { - for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++) { - addSlotToContainer(new Slot(player.inventory, playerInvCol + (playerInvRow * 9) + 9, 161 + 18 * playerInvCol, 179 + playerInvRow * 18)); - } - } + private void addPlayerInventory() { + for (int playerInvRow = 0; playerInvRow < 3; playerInvRow++) { + for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++) { + addSlotToContainer(new Slot(player.inventory, playerInvCol + (playerInvRow * 9) + 9, 161 + 18 * playerInvCol, 179 + playerInvRow * 18)); + } + } - for (int hotbarSlot = 0; hotbarSlot < 9; hotbarSlot++) { - addSlotToContainer(new Slot(player.inventory, hotbarSlot, 161 + 18 * hotbarSlot, 235)); - } - } + for (int hotbarSlot = 0; hotbarSlot < 9; hotbarSlot++) { + addSlotToContainer(new Slot(player.inventory, hotbarSlot, 161 + 18 * hotbarSlot, 235)); + } + } - private void addCraftingSlots() { - int yOffset = 188; - int xOffset = 334; + private void addCraftingSlots() { + int yOffset = 188; + int xOffset = 334; - addSlotToContainer(new SlotChargable(tile, 239, 8, 235)); + addSlotToContainer(new SlotChargable(tile, 239, 8, 235)); - for (int row = 0; row < 5; row++){ - addSlotToContainer(new SlotSmeltable(tile, 234+row, 45 + row * 18, 197)); - } + for (int row = 0; row < 5; row++) { + addSlotToContainer(new SlotSmeltable(tile, 234 + row, 45 + row * 18, 197)); + } - addSlotToContainer(new SlotCrafting(player, craftMatrix, craftResult, 0, xOffset + 94, yOffset + 18)); + addSlotToContainer(new SlotCrafting(player, craftMatrix, craftResult, 0, xOffset + 94, yOffset + 18)); - for (int gridCol = 0; gridCol < 3; ++gridCol) - { - for (int gridRow = 0; gridRow < 3; ++gridRow) - { - addSlotToContainer(new SlotDChest(craftMatrix, gridRow + (gridCol * 3), xOffset + (gridRow * 18), yOffset + (gridCol * 18))); - } - } - } + for (int gridCol = 0; gridCol < 3; ++gridCol) { + for (int gridRow = 0; gridRow < 3; ++gridRow) { + addSlotToContainer(new SlotDChest(craftMatrix, gridRow + (gridCol * 3), xOffset + (gridRow * 18), yOffset + (gridCol * 18))); + } + } + } - @Override - public void onCraftMatrixChanged(IInventory inventory) { - craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj)); - } + @Override + public void onCraftMatrixChanged(IInventory inventory) { + craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj)); + } - @Override - public boolean canInteractWith(EntityPlayer player) { - return tile.isUseableByPlayer(player); - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int i) - { - ItemStack itemstack = null; - Slot slot = (Slot) inventorySlots.get(i); - if (slot != null && slot.getHasStack()) - { - ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); - if (i < tile.getSizeInventory()+16 && i != 240)//Transferring from container - { - if (!mergeItemStack(itemstack1, tile.getSizeInventory()+16, inventorySlots.size(), true)) - { - return null; - } - slot.onSlotChange(itemstack1, itemstack); - } - else if (i == 240) - { - if (!mergeItemStack(itemstack1, tile.getSizeInventory()+16, inventorySlots.size(), true)) - { - if (!mergeItemStack(itemstack1, 0, tile.getSizeInventory(), false)) - { - return null; - } - } - slot.onSlotChange(itemstack1, itemstack); - } - else if (!DraconiumChest.isStackValid(itemstack1) || !mergeItemStack(itemstack1, 0, tile.getSizeInventory(), false))//Transferring from player - { - return null; - } - if (itemstack1.stackSize == 0) - { - slot.putStack(null); - } - else - { - slot.onSlotChanged(); - } - slot.onPickupFromSlot(player, itemstack1); - } - return itemstack; - } + @Override + public boolean canInteractWith(EntityPlayer player) { + return tile.isUseableByPlayer(player); + } - @Override - public void onContainerClosed(EntityPlayer p_75134_1_) { - super.onContainerClosed(p_75134_1_); - tile.closeInventory(); - if (!worldObj.isRemote) - { - for (int i = 0; i < 9; ++i) - { - ItemStack itemstack = craftMatrix.getStackInSlotOnClosing(i); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int i) { + ItemStack itemstack = null; + Slot slot = (Slot) inventorySlots.get(i); + if (slot != null && slot.getHasStack()) { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + if (i < tile.getSizeInventory() + 16 && i != 240)//Transferring from container + { + if (!mergeItemStack(itemstack1, tile.getSizeInventory() + 16, inventorySlots.size(), true)) { + return null; + } + slot.onSlotChange(itemstack1, itemstack); + } else if (i == 240) { + if (!mergeItemStack(itemstack1, tile.getSizeInventory() + 16, inventorySlots.size(), true)) { + if (!mergeItemStack(itemstack1, 0, tile.getSizeInventory(), false)) { + return null; + } + } + slot.onSlotChange(itemstack1, itemstack); + } else if (!DraconiumChest.isStackValid(itemstack1) || !mergeItemStack(itemstack1, 0, tile.getSizeInventory(), false))//Transferring from player + { + return null; + } + if (itemstack1.stackSize == 0) { + slot.putStack(null); + } else { + slot.onSlotChanged(); + } + slot.onPickupFromSlot(player, itemstack1); + } + return itemstack; + } - if (itemstack != null) - { - player.dropPlayerItemWithRandomChoice(itemstack, false); - } - } - } - } + @Override + public void onContainerClosed(EntityPlayer p_75134_1_) { + super.onContainerClosed(p_75134_1_); + tile.closeInventory(); + if (!worldObj.isRemote) { + for (int i = 0; i < 9; ++i) { + ItemStack itemstack = craftMatrix.getStackInSlotOnClosing(i); - @Override - public boolean func_94530_a (ItemStack par1ItemStack, Slot par2Slot) - { - return par2Slot.inventory != craftResult && super.func_94530_a(par1ItemStack, par2Slot); - } + if (itemstack != null) { + player.dropPlayerItemWithRandomChoice(itemstack, false); + } + } + } + } - @Override - public void addCraftingToCrafters(ICrafting iCrafting) { - super.addCraftingToCrafters(iCrafting); + @Override + public boolean func_94530_a(ItemStack par1ItemStack, Slot par2Slot) { + return par2Slot.inventory != craftResult && super.func_94530_a(par1ItemStack, par2Slot); + } + + @Override + public void addCraftingToCrafters(ICrafting iCrafting) { + super.addCraftingToCrafters(iCrafting); // iCrafting.sendProgressBarUpdate(this, 0, tile.smeltingProgressTime); // iCrafting.sendProgressBarUpdate(this, 1, tile.getEnergyStored(ForgeDirection.DOWN)/32); // iCrafting.sendProgressBarUpdate(this, 2, tile.smeltingBurnSpeed); - } + } - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - for (int i = 0; i < this.crafters.size(); ++i) - { - ICrafting icrafting = (ICrafting)this.crafters.get(i); + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) { + ICrafting icrafting = (ICrafting) this.crafters.get(i); - if (lastProgressTime != tile.smeltingProgressTime) - { - icrafting.sendProgressBarUpdate(this, 0, tile.smeltingProgressTime); - } - if (lastEnergyStored != tile.getEnergyStored(ForgeDirection.DOWN)) - { - icrafting.sendProgressBarUpdate(this, 1, tile.getEnergyStored(ForgeDirection.DOWN)/32); - } - if (lastBurnSpeed != tile.smeltingBurnSpeed) - { - icrafting.sendProgressBarUpdate(this, 2, tile.smeltingBurnSpeed); - } - if (lastTickFeedMode != tile.smeltingAutoFeed) - { - icrafting.sendProgressBarUpdate(this, 3, tile.smeltingAutoFeed); - } - if (lastTickOutputLock != tile.lockOutputSlots) - { - icrafting.sendProgressBarUpdate(this, 4, tile.lockOutputSlots ? 1 : 0); - } + if (lastProgressTime != tile.smeltingProgressTime) { + icrafting.sendProgressBarUpdate(this, 0, tile.smeltingProgressTime); + } + if (lastEnergyStored != tile.getEnergyStored(ForgeDirection.DOWN)) { + icrafting.sendProgressBarUpdate(this, 1, tile.getEnergyStored(ForgeDirection.DOWN) / 32); + } + if (lastBurnSpeed != tile.smeltingBurnSpeed) { + icrafting.sendProgressBarUpdate(this, 2, tile.smeltingBurnSpeed); + } + if (lastTickFeedMode != tile.smeltingAutoFeed) { + icrafting.sendProgressBarUpdate(this, 3, tile.smeltingAutoFeed); + } + if (lastTickOutputLock != tile.lockOutputSlots) { + icrafting.sendProgressBarUpdate(this, 4, tile.lockOutputSlots ? 1 : 0); + } - } + } - lastTickOutputLock = tile.lockOutputSlots; - lastTickFeedMode = tile.smeltingAutoFeed; - lastBurnSpeed = tile.smeltingBurnSpeed; - lastProgressTime = tile.smeltingProgressTime; - lastEnergyStored = tile.getEnergyStored(ForgeDirection.DOWN); - } + lastTickOutputLock = tile.lockOutputSlots; + lastTickFeedMode = tile.smeltingAutoFeed; + lastBurnSpeed = tile.smeltingBurnSpeed; + lastProgressTime = tile.smeltingProgressTime; + lastEnergyStored = tile.getEnergyStored(ForgeDirection.DOWN); + } - @SideOnly(Side.CLIENT) - @Override - public void updateProgressBar(int id, int value) { - if (id == 0) tile.smeltingProgressTime = value; - else if (id == 1) tile.energy.setEnergyStored(value*32); - else if (id == 2) tile.smeltingBurnSpeed = value; - else if (id == 3) tile.smeltingAutoFeed = value; - else if (id == 4) tile.lockOutputSlots = value == 1; - } + @SideOnly(Side.CLIENT) + @Override + public void updateProgressBar(int id, int value) { + if (id == 0) tile.smeltingProgressTime = value; + else if (id == 1) tile.energy.setEnergyStored(value * 32); + else if (id == 2) tile.smeltingBurnSpeed = value; + else if (id == 3) tile.smeltingAutoFeed = value; + else if (id == 4) tile.lockOutputSlots = value == 1; + } - public TileDraconiumChest getTile(){return tile;} + public TileDraconiumChest getTile() { + return tile; + } - public class SlotSmeltable extends Slot { + public class SlotSmeltable extends Slot { - public SlotSmeltable(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) { - super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); - } + public SlotSmeltable(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) { + super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_); + } - @Override - public boolean isItemValid(ItemStack stack) { - return FurnaceRecipes.smelting().getSmeltingResult(stack) != null || OreDoublingRegistry.getOreResult(stack) != null; - } - } + @Override + public boolean isItemValid(ItemStack stack) { + return FurnaceRecipes.smelting().getSmeltingResult(stack) != null || OreDoublingRegistry.getOreResult(stack) != null; + } + } - public class SlotChargable extends Slot { + public class SlotChargable extends Slot { - public SlotChargable(IInventory inventory, int id, int x, int y) { - super(inventory, id, x, y); + public SlotChargable(IInventory inventory, int id, int x, int y) { + super(inventory, id, x, y); - } + } - @Override - public boolean isItemValid(ItemStack stack) - { - if (super.isItemValid(stack)) - { - return stack != null && stack.getItem() instanceof IEnergyContainerItem; - } - return false; - } + @Override + public boolean isItemValid(ItemStack stack) { + if (super.isItemValid(stack)) { + return stack != null && stack.getItem() instanceof IEnergyContainerItem; + } + return false; + } - @Override - public int getSlotStackLimit() - { - return 1; - } - } + @Override + public int getSlotStackLimit() { + return 1; + } + } - public class SlotDChest extends Slot { + public class SlotDChest extends Slot { - public SlotDChest(IInventory inventory, int id, int x, int y) { - super(inventory, id, x, y); + public SlotDChest(IInventory inventory, int id, int x, int y) { + super(inventory, id, x, y); - } + } - @Override - public boolean isItemValid(ItemStack stack) - { - return DraconiumChest.isStackValid(stack); - } + @Override + public boolean isItemValid(ItemStack stack) { + return DraconiumChest.isStackValid(stack); + } - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerEnergyInfuser.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerEnergyInfuser.java index 99097afd..2e6fd1c1 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerEnergyInfuser.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerEnergyInfuser.java @@ -12,78 +12,75 @@ import net.minecraft.item.ItemStack; public class ContainerEnergyInfuser extends ContainerDataSync { - private TileEnergyInfuser tile; - private EntityPlayer player; - private int lastTickEnergyStorage = -1; + private TileEnergyInfuser tile; + private EntityPlayer player; + private int lastTickEnergyStorage = -1; - public ContainerEnergyInfuser(InventoryPlayer invPlayer, TileEnergyInfuser tile) { - this.tile = tile; - this.player = invPlayer.player; + public ContainerEnergyInfuser(InventoryPlayer invPlayer, TileEnergyInfuser tile) { + this.tile = tile; + this.player = invPlayer.player; - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 116)); - } + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 116)); + } - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 58 + y * 18)); - } - } - - addSlotToContainer(new SlotChargable(tile, 0, 80, 22)); - } + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 58 + y * 18)); + } + } - @Override - public boolean canInteractWith(EntityPlayer player) - { - return tile.isUseableByPlayer(player); - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int i) - { - Slot slot = getSlot(i); + addSlotToContainer(new SlotChargable(tile, 0, 80, 22)); + } - if (slot != null && slot.getHasStack()) - { - ItemStack stack = slot.getStack(); - ItemStack result = stack.copy(); + @Override + public boolean canInteractWith(EntityPlayer player) { + return tile.isUseableByPlayer(player); + } - if (i >= 36){ //To player - if (!mergeItemStack(stack, 0, 36, false)){ - return null; - } - }else if (stack.stackSize != 1 || !(stack.getItem() instanceof IEnergyContainerItem) || !mergeItemStack(stack, 36, 37, false)){ - return null; - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int i) { + Slot slot = getSlot(i); - if (stack.stackSize == 0) { - slot.putStack(null); - }else{ - slot.onSlotChanged(); - } + if (slot != null && slot.getHasStack()) { + ItemStack stack = slot.getStack(); + ItemStack result = stack.copy(); - slot.onPickupFromSlot(player, stack); + if (i >= 36) { //To player + if (!mergeItemStack(stack, 0, 36, false)) { + return null; + } + } else if (stack.stackSize != 1 || !(stack.getItem() instanceof IEnergyContainerItem) || !mergeItemStack(stack, 36, 37, false)) { + return null; + } - return result; - } + if (stack.stackSize == 0) { + slot.putStack(null); + } else { + slot.onSlotChanged(); + } - return null; - } + slot.onPickupFromSlot(player, stack); + + return result; + } + + return null; + } - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (tile.energy.getEnergyStored() != lastTickEnergyStorage){ - sendObjectToClient(null, 0, tile.energy.getEnergyStored()); - lastTickEnergyStorage = tile.energy.getEnergyStored(); - } - } + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (tile.energy.getEnergyStored() != lastTickEnergyStorage) { + sendObjectToClient(null, 0, tile.energy.getEnergyStored()); + lastTickEnergyStorage = tile.energy.getEnergyStored(); + } + } - @SideOnly(Side.CLIENT) - @Override - public void receiveSyncData(int index, int value) { - tile.energy.setEnergyStored(value); - } + @SideOnly(Side.CLIENT) + @Override + public void receiveSyncData(int index, int value) { + tile.energy.setEnergyStored(value); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerGenerator.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerGenerator.java index be5c3562..56b0365d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerGenerator.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerGenerator.java @@ -12,78 +12,77 @@ import net.minecraftforge.common.util.ForgeDirection; public class ContainerGenerator extends ContainerDataSync { - private TileGenerator tile; - private int energyCach = -1; - private int burnCach = -1; - private int burnRemainingCach = -1; + private TileGenerator tile; + private int energyCach = -1; + private int burnCach = -1; + private int burnRemainingCach = -1; - public ContainerGenerator(InventoryPlayer invPlayer, TileGenerator tile) { - this.tile = tile; + public ContainerGenerator(InventoryPlayer invPlayer, TileGenerator tile) { + this.tile = tile; - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 138)); - } + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 138)); + } - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 80 + y * 18)); - } - } - - addSlotToContainer(new SlotItemValid(tile, 0, 64, 35, true)); - } + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 80 + y * 18)); + } + } - @Override - public boolean canInteractWith(EntityPlayer player) - { - return tile.isUseableByPlayer(player); - } + addSlotToContainer(new SlotItemValid(tile, 0, 64, 35, true)); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int i) - { - Slot slot = getSlot(i); + @Override + public boolean canInteractWith(EntityPlayer player) { + return tile.isUseableByPlayer(player); + } - if (slot != null && slot.getHasStack()) - { - ItemStack stack = slot.getStack(); - ItemStack result = stack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int i) { + Slot slot = getSlot(i); - if (i >= 36){ - if (!mergeItemStack(stack, 0, 36, false)){ - return null; - } - }else if (TileGenerator.getItemBurnTime(stack) == 0 || !mergeItemStack(stack, 36, 36 + tile.getSizeInventory(), false)){ - return null; - } + if (slot != null && slot.getHasStack()) { + ItemStack stack = slot.getStack(); + ItemStack result = stack.copy(); - if (stack.stackSize == 0) { - slot.putStack(null); - }else{ - slot.onSlotChanged(); - } + if (i >= 36) { + if (!mergeItemStack(stack, 0, 36, false)) { + return null; + } + } else if (TileGenerator.getItemBurnTime(stack) == 0 || !mergeItemStack(stack, 36, 36 + tile.getSizeInventory(), false)) { + return null; + } - slot.onPickupFromSlot(player, stack); + if (stack.stackSize == 0) { + slot.putStack(null); + } else { + slot.onSlotChanged(); + } - return result; - } + slot.onPickupFromSlot(player, stack); - return null; - } + return result; + } - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (energyCach != tile.getEnergyStored(ForgeDirection.UP)) energyCach = (Integer) sendObjectToClient(null, 0, tile.getEnergyStored(ForgeDirection.UP)); - if (burnCach != tile.burnTime) burnCach = (Integer) sendObjectToClient(null, 1, tile.burnTime); - if (burnRemainingCach != tile.burnTimeRemaining) burnRemainingCach = (Integer) sendObjectToClient(null, 2, tile.burnTimeRemaining); - } + return null; + } - @SideOnly(Side.CLIENT) - @Override - public void receiveSyncData(int index, int i) { - if (index == 0)tile.storage.setEnergyStored(i); - else if (index == 1) tile.burnTime = i; - else if (index == 2) tile.burnTimeRemaining = i; - } + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (energyCach != tile.getEnergyStored(ForgeDirection.UP)) + energyCach = (Integer) sendObjectToClient(null, 0, tile.getEnergyStored(ForgeDirection.UP)); + if (burnCach != tile.burnTime) burnCach = (Integer) sendObjectToClient(null, 1, tile.burnTime); + if (burnRemainingCach != tile.burnTimeRemaining) + burnRemainingCach = (Integer) sendObjectToClient(null, 2, tile.burnTimeRemaining); + } + + @SideOnly(Side.CLIENT) + @Override + public void receiveSyncData(int index, int i) { + if (index == 0) tile.storage.setEnergyStored(i); + else if (index == 1) tile.burnTime = i; + else if (index == 2) tile.burnTimeRemaining = i; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerGrinder.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerGrinder.java index 97b72115..b02cd895 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerGrinder.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerGrinder.java @@ -11,86 +11,84 @@ import net.minecraft.item.ItemStack; public class ContainerGrinder extends ContainerDataSync { - private TileGrinder tile; - private int energyCach = -1; - private int energy2Cach = -1; - private int burnCach = -1; - private int burnRemainingCach = -1; + private TileGrinder tile; + private int energyCach = -1; + private int energy2Cach = -1; + private int burnCach = -1; + private int burnRemainingCach = -1; - public ContainerGrinder(InventoryPlayer invPlayer, TileGrinder tile) { - this.tile = tile; + public ContainerGrinder(InventoryPlayer invPlayer, TileGrinder tile) { + this.tile = tile; - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 138)); - } + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 138)); + } - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 80 + y * 18)); - } - } - if (!tile.isExternallyPowered()) - addSlotToContainer(new SlotItemValid(tile, 0, 64, 35, true)); - else - addSlotToContainer(new SlotItemValid(tile, 0, -10000, -10000, true)); + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 80 + y * 18)); + } + } + if (!tile.isExternallyPowered()) addSlotToContainer(new SlotItemValid(tile, 0, 64, 35, true)); + else addSlotToContainer(new SlotItemValid(tile, 0, -10000, -10000, true)); - } + } - @Override - public boolean canInteractWith(EntityPlayer player) - { - return tile.isUseableByPlayer(player); - } + @Override + public boolean canInteractWith(EntityPlayer player) { + return tile.isUseableByPlayer(player); + } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int i) - { - Slot slot = getSlot(i); - if (slot != null && slot.getHasStack()) - { - ItemStack stack = slot.getStack(); - ItemStack result = stack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int i) { + Slot slot = getSlot(i); - if (i >= 36){ - if (!mergeItemStack(stack, 0, 36, false)){ - return null; - } - }else if (TileGrinder.getItemBurnTime(stack) == 0 || !mergeItemStack(stack, 36, 36 + tile.getSizeInventory(), false)){ - return null; - } + if (slot != null && slot.getHasStack()) { + ItemStack stack = slot.getStack(); + ItemStack result = stack.copy(); - if (stack.stackSize == 0) { - slot.putStack(null); - }else{ - slot.onSlotChanged(); - } + if (i >= 36) { + if (!mergeItemStack(stack, 0, 36, false)) { + return null; + } + } else if (TileGrinder.getItemBurnTime(stack) == 0 || !mergeItemStack(stack, 36, 36 + tile.getSizeInventory(), false)) { + return null; + } - slot.onPickupFromSlot(player, stack); + if (stack.stackSize == 0) { + slot.putStack(null); + } else { + slot.onSlotChanged(); + } - return result; - } + slot.onPickupFromSlot(player, stack); - return null; - } + return result; + } - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (energyCach != tile.externalInputBuffer.getEnergyStored()) energyCach = (Integer) sendObjectToClient(null, 0, tile.externalInputBuffer.getEnergyStored()); - if (energy2Cach != tile.internalGenBuffer.getEnergyStored()) energy2Cach = (Integer) sendObjectToClient(null, 1, tile.internalGenBuffer.getEnergyStored()); - if (burnCach != tile.burnTime) burnCach = (Integer) sendObjectToClient(null, 2, tile.burnTime); - if (burnRemainingCach != tile.burnTimeRemaining) burnRemainingCach = (Integer) sendObjectToClient(null, 3, tile.burnTimeRemaining); - } + return null; + } - @SideOnly(Side.CLIENT) - @Override - public void receiveSyncData(int index, int i) { - if (index == 0) tile.externalInputBuffer.setEnergyStored(i); - else if (index == 1) tile.internalGenBuffer.setEnergyStored(i); - else if (index == 2) tile.burnTime = i; - else if (index == 3) tile.burnTimeRemaining = i; + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (energyCach != tile.externalInputBuffer.getEnergyStored()) + energyCach = (Integer) sendObjectToClient(null, 0, tile.externalInputBuffer.getEnergyStored()); + if (energy2Cach != tile.internalGenBuffer.getEnergyStored()) + energy2Cach = (Integer) sendObjectToClient(null, 1, tile.internalGenBuffer.getEnergyStored()); + if (burnCach != tile.burnTime) burnCach = (Integer) sendObjectToClient(null, 2, tile.burnTime); + if (burnRemainingCach != tile.burnTimeRemaining) + burnRemainingCach = (Integer) sendObjectToClient(null, 3, tile.burnTimeRemaining); + } - } + @SideOnly(Side.CLIENT) + @Override + public void receiveSyncData(int index, int i) { + if (index == 0) tile.externalInputBuffer.setEnergyStored(i); + else if (index == 1) tile.internalGenBuffer.setEnergyStored(i); + else if (index == 2) tile.burnTime = i; + else if (index == 3) tile.burnTimeRemaining = i; + + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerPlayerDetector.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerPlayerDetector.java index d5c0aaf7..08ddfa45 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerPlayerDetector.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerPlayerDetector.java @@ -13,112 +13,92 @@ import java.util.Iterator; public class ContainerPlayerDetector extends Container { - private TilePlayerDetectorAdvanced tileDetector; - private GUIPlayerDetector gui = null; + private TilePlayerDetectorAdvanced tileDetector; + private GUIPlayerDetector gui = null; - public ContainerPlayerDetector(InventoryPlayer invPlayer, TilePlayerDetectorAdvanced tileDetector) { - this.tileDetector = tileDetector; + public ContainerPlayerDetector(InventoryPlayer invPlayer, TilePlayerDetectorAdvanced tileDetector) { + this.tileDetector = tileDetector; - bindPlayerInventory(invPlayer); - addContainerSlots(tileDetector); - updateContainerSlots(); - - } - - public ContainerPlayerDetector(InventoryPlayer invPlayer, TilePlayerDetectorAdvanced tileDetector, GUIPlayerDetector gui) { - this.tileDetector = tileDetector; - this.gui = gui; + bindPlayerInventory(invPlayer); + addContainerSlots(tileDetector); + updateContainerSlots(); - bindPlayerInventory(invPlayer); - addContainerSlots(tileDetector); - updateContainerSlots(); - - } - - private void bindPlayerInventory(InventoryPlayer invPlayer) - { - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 174)); - } + } - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 116 + y * 18)); - } - } - } + public ContainerPlayerDetector(InventoryPlayer invPlayer, TilePlayerDetectorAdvanced tileDetector, GUIPlayerDetector gui) { + this.tileDetector = tileDetector; + this.gui = gui; - public void addContainerSlots(TilePlayerDetectorAdvanced tileDetector) - { - addSlotToContainer(new SlotOpaqueBlock(tileDetector, 0, 145, 15)); - } - - @SuppressWarnings("unchecked") - public void updateContainerSlots() - { - if (gui == null) - { + bindPlayerInventory(invPlayer); + addContainerSlots(tileDetector); + updateContainerSlots(); + + } + + private void bindPlayerInventory(InventoryPlayer invPlayer) { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 174)); + } + + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 116 + y * 18)); + } + } + } + + public void addContainerSlots(TilePlayerDetectorAdvanced tileDetector) { + addSlotToContainer(new SlotOpaqueBlock(tileDetector, 0, 145, 15)); + } + + @SuppressWarnings("unchecked") + public void updateContainerSlots() { + if (gui == null) { return; } - Iterator i1 = inventorySlots.iterator(); - while (i1.hasNext()) - { + Iterator i1 = inventorySlots.iterator(); + while (i1.hasNext()) { Slot sl = i1.next(); - if (sl instanceof SlotOpaqueBlock) - { - if (gui.showInvSlots) - { - sl.xDisplayPosition = 143; - sl.yDisplayPosition = 20; - }else - { - sl.xDisplayPosition = -1000; - sl.yDisplayPosition = -1000; - } - }else - { - if (gui.showInvSlots) - { - if (sl.slotNumber < 9) - { - sl.xDisplayPosition = 8 + 18 * sl.slotNumber; - sl.yDisplayPosition = 174; - } - else if (sl.slotNumber < 18) - { - sl.xDisplayPosition = 8 + 18 * (sl.slotNumber - 9); - sl.yDisplayPosition = 116 + 0 * 18; - } - else if (sl.slotNumber < 27) - { - sl.xDisplayPosition = 8 + 18 * (sl.slotNumber - 18); - sl.yDisplayPosition = 116 + 1 * 18; - } - else if (sl.slotNumber < 36) - { - sl.xDisplayPosition = 8 + 18 * (sl.slotNumber - 27); - sl.yDisplayPosition = 116 + 2 * 18; - } + if (sl instanceof SlotOpaqueBlock) { + if (gui.showInvSlots) { + sl.xDisplayPosition = 143; + sl.yDisplayPosition = 20; + } else { + sl.xDisplayPosition = -1000; + sl.yDisplayPosition = -1000; + } + } else { + if (gui.showInvSlots) { + if (sl.slotNumber < 9) { + sl.xDisplayPosition = 8 + 18 * sl.slotNumber; + sl.yDisplayPosition = 174; + } else if (sl.slotNumber < 18) { + sl.xDisplayPosition = 8 + 18 * (sl.slotNumber - 9); + sl.yDisplayPosition = 116 + 0 * 18; + } else if (sl.slotNumber < 27) { + sl.xDisplayPosition = 8 + 18 * (sl.slotNumber - 18); + sl.yDisplayPosition = 116 + 1 * 18; + } else if (sl.slotNumber < 36) { + sl.xDisplayPosition = 8 + 18 * (sl.slotNumber - 27); + sl.yDisplayPosition = 116 + 2 * 18; + } - }else - { - sl.xDisplayPosition = -1000; - sl.yDisplayPosition = -1000; - } + } else { + sl.xDisplayPosition = -1000; + sl.yDisplayPosition = -1000; + } } } - } - - @Override - public boolean canInteractWith(EntityPlayer player) - { - return tileDetector.isUseableByPlayer(player); - } + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int i) - { + @Override + public boolean canInteractWith(EntityPlayer player) { + return tileDetector.isUseableByPlayer(player); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int i) { // Slot slot = getSlot(i); // // @@ -147,20 +127,19 @@ public class ContainerPlayerDetector extends Container { // return result; // } - return null; - } + return null; + } - public TilePlayerDetectorAdvanced getTileDetector(){ - return tileDetector; - } + public TilePlayerDetectorAdvanced getTileDetector() { + return tileDetector; + } - @Override - public ItemStack slotClick(int slot, int button, int par3, EntityPlayer par4EntityPlayer) - { - return super.slotClick(slot, button, par3, par4EntityPlayer); + @Override + public ItemStack slotClick(int slot, int button, int par3, EntityPlayer par4EntityPlayer) { + return super.slotClick(slot, button, par3, par4EntityPlayer); // if (par3 == 4) // return super.slotClick(slot, button, 0, par4EntityPlayer); // else // return super.slotClick(slot, button, par3, par4EntityPlayer); - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerReactor.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerReactor.java index 84e35e63..4657a474 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerReactor.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerReactor.java @@ -18,43 +18,42 @@ import java.util.Iterator; */ public class ContainerReactor extends ContainerDataSync { - private TileReactorCore reactor; - private EntityPlayer player; - private GenericInventory ioSlots = new GenericInventory() { - private ItemStack[] items = new ItemStack[2]; + private TileReactorCore reactor; + private EntityPlayer player; + private GenericInventory ioSlots = new GenericInventory() { + private ItemStack[] items = new ItemStack[2]; - @Override - public ItemStack[] getStorage() { - return items; - } + @Override + public ItemStack[] getStorage() { + return items; + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; - //return itemstack != null && (itemstack.getItem() == ModItems.draconicIngot || itemstack.getItem() == Item.getItemFromBlock(ModBlocks.draconicBlock)); - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + //return itemstack != null && (itemstack.getItem() == ModItems.draconicIngot || itemstack.getItem() == Item.getItemFromBlock(ModBlocks.draconicBlock)); + } - @Override - public int getInventoryStackLimit() { - return 1;//super.getInventoryStackLimit(); - } + @Override + public int getInventoryStackLimit() { + return 1;//super.getInventoryStackLimit(); + } - @Override - public void setInventorySlotContents(int i, ItemStack stack) { - if (i == 0 && stack != null && (stack.getItem() == ModItems.draconicIngot || stack.getItem() == Item.getItemFromBlock(ModBlocks.draconicBlock) || (stack.getItem() == ModItems.nugget && stack.getItemDamage() == 1))) - { - if (stack.getItem() == ModItems.nugget) reactor.reactorFuel += stack.stackSize * 16; - if (stack.getItem() == ModItems.draconicIngot) reactor.reactorFuel += stack.stackSize * 144; - if (stack.getItem() == Item.getItemFromBlock(ModBlocks.draconicBlock)) reactor.reactorFuel += stack.stackSize * 1296; - reactor.validateStructure(); - } - else getStorage()[i] = stack; - } - }; + @Override + public void setInventorySlotContents(int i, ItemStack stack) { + if (i == 0 && stack != null && (stack.getItem() == ModItems.draconicIngot || stack.getItem() == Item.getItemFromBlock(ModBlocks.draconicBlock) || (stack.getItem() == ModItems.nugget && stack.getItemDamage() == 1))) { + if (stack.getItem() == ModItems.nugget) reactor.reactorFuel += stack.stackSize * 16; + if (stack.getItem() == ModItems.draconicIngot) reactor.reactorFuel += stack.stackSize * 144; + if (stack.getItem() == Item.getItemFromBlock(ModBlocks.draconicBlock)) + reactor.reactorFuel += stack.stackSize * 1296; + reactor.validateStructure(); + } else getStorage()[i] = stack; + } + }; - //Syncing //todo sort out syncing - public int LTConversionUnit = -1; - public int LTReactionIntensity = -1; + //Syncing //todo sort out syncing + public int LTConversionUnit = -1; + public int LTReactionIntensity = -1; // public int LTMaxReactIntensity = -1; // public int LTFieldStrength = -1; // public int LTMaxFieldStrength = -1; @@ -62,69 +61,68 @@ public class ContainerReactor extends ContainerDataSync { // public int LTMaxEnergySaturation = -1; // public int LTFuelConversion = -1; - public double LTTempDrainFactor = -1; - public double LTGenerationRate = -1; - public int LTFieldDrain = -1; - public double LTFuelUseRate = -1; - public boolean LTOffline; - //####### + public double LTTempDrainFactor = -1; + public double LTGenerationRate = -1; + public int LTFieldDrain = -1; + public double LTFuelUseRate = -1; + public boolean LTOffline; + //####### - public ContainerReactor(EntityPlayer player, TileReactorCore reactor){ - this.reactor = reactor; - this.player = player; - this.LTOffline = reactor.reactorState == TileReactorCore.STATE_OFFLINE; + public ContainerReactor(EntityPlayer player, TileReactorCore reactor) { + this.reactor = reactor; + this.player = player; + this.LTOffline = reactor.reactorState == TileReactorCore.STATE_OFFLINE; - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(player.inventory, x, 44 + 18 * x, 198)); - } + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(player.inventory, x, 44 + 18 * x, 198)); + } - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(player.inventory, x + y * 9 + 9, 44 + 18 * x, 140 + y * 18)); - } - } + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(player.inventory, x + y * 9 + 9, 44 + 18 * x, 140 + y * 18)); + } + } - if (reactor.reactorState == TileReactorCore.STATE_OFFLINE){ - addSlotToContainer(new SlotInsert(ioSlots, 0, 15, 140, reactor)); - addSlotToContainer(new SlotExtract(ioSlots, 1, 217, 140)); - } - } + if (reactor.reactorState == TileReactorCore.STATE_OFFLINE) { + addSlotToContainer(new SlotInsert(ioSlots, 0, 15, 140, reactor)); + addSlotToContainer(new SlotExtract(ioSlots, 1, 217, 140)); + } + } - @Override - public void onContainerClosed(EntityPlayer entityPlayer) { - if (ioSlots.getStackInSlot(1) != null && !player.worldObj.isRemote) { - entityPlayer.worldObj.spawnEntityInWorld(new EntityItem(player.worldObj, entityPlayer.posX, player.posY, player.posZ, ioSlots.getStackInSlot(1))); - ioSlots.setInventorySlotContents(1, null); - } - super.onContainerClosed(entityPlayer); - } + @Override + public void onContainerClosed(EntityPlayer entityPlayer) { + if (ioSlots.getStackInSlot(1) != null && !player.worldObj.isRemote) { + entityPlayer.worldObj.spawnEntityInWorld(new EntityItem(player.worldObj, entityPlayer.posX, player.posY, player.posZ, ioSlots.getStackInSlot(1))); + ioSlots.setInventorySlotContents(1, null); + } + super.onContainerClosed(entityPlayer); + } - @Override - public boolean canInteractWith(EntityPlayer player) {//todo (the chest thing) - return true; - } + @Override + public boolean canInteractWith(EntityPlayer player) {//todo (the chest thing) + return true; + } - @Override - public void detectAndSendChanges() { //todo check what values are being synced by the tile and remove them from here + @Override + public void detectAndSendChanges() { //todo check what values are being synced by the tile and remove them from here - if (LTOffline && reactor.reactorState != TileReactorCore.STATE_OFFLINE){ - Iterator i = inventorySlots.iterator(); - while (i.hasNext()) { - Object o = i.next(); - if (o instanceof SlotExtract || o instanceof SlotInsert) i.remove(); - } - sendObjectToClient(null, 99, 1); - } - else if(!LTOffline && reactor.reactorState == TileReactorCore.STATE_OFFLINE){ - addSlotToContainer(new SlotInsert(ioSlots, 0, 15, 140, reactor)); - addSlotToContainer(new SlotExtract(ioSlots, 1, 217, 140)); - sendObjectToClient(null, 98, 1); - } - LTOffline = reactor.reactorState == TileReactorCore.STATE_OFFLINE; + if (LTOffline && reactor.reactorState != TileReactorCore.STATE_OFFLINE) { + Iterator i = inventorySlots.iterator(); + while (i.hasNext()) { + Object o = i.next(); + if (o instanceof SlotExtract || o instanceof SlotInsert) i.remove(); + } + sendObjectToClient(null, 99, 1); + } else if (!LTOffline && reactor.reactorState == TileReactorCore.STATE_OFFLINE) { + addSlotToContainer(new SlotInsert(ioSlots, 0, 15, 140, reactor)); + addSlotToContainer(new SlotExtract(ioSlots, 1, 217, 140)); + sendObjectToClient(null, 98, 1); + } + LTOffline = reactor.reactorState == TileReactorCore.STATE_OFFLINE; - - if (reactor.conversionUnit != LTConversionUnit) LTConversionUnit = (Integer) sendObjectToClient(null, 0, (int)(reactor.conversionUnit*100)); + if (reactor.conversionUnit != LTConversionUnit) + LTConversionUnit = (Integer) sendObjectToClient(null, 0, (int) (reactor.conversionUnit * 100)); // if ((int)reactor.reactionTemperature != LTReactionIntensity)LTReactionIntensity = (Integer) sendObjectToClient(null, 1, (int) reactor.reactionTemperature); // if ((int)reactor.maxReactTemperature != LTMaxReactIntensity)LTMaxReactIntensity = (Integer) sendObjectToClient(null, 2, (int) reactor.maxReactTemperature); // if ((int)reactor.fieldCharge != LTFieldStrength) LTFieldStrength = (Integer) sendObjectToClient(null, 3, (int) reactor.fieldCharge); @@ -132,18 +130,22 @@ public class ContainerReactor extends ContainerDataSync { // if (reactor.energySaturation != LTEnergySaturation) LTEnergySaturation = (Integer) sendObjectToClient(null, 4, reactor.energySaturation); // if (reactor.maxEnergySaturation != LTMaxEnergySaturation) LTMaxEnergySaturation = (Integer) sendObjectToClient(null, 5, reactor.maxEnergySaturation); // if (reactor.convertedFuel != LTFuelConversion) LTFuelConversion = (Integer) sendObjectToClient(null, 6, reactor.convertedFuel); - /*if (reactor.tempDrainFactor != LTTempDrainFactor) LTTempDrainFactor = (Integer) */sendObjectToClient(null, 8, (int)(reactor.tempDrainFactor*1000D)); - if (reactor.generationRate != LTGenerationRate) LTGenerationRate = (Integer) sendObjectToClient(null, 9, (int)(reactor.generationRate)); - if (reactor.fieldDrain != LTFieldDrain) LTFieldDrain = (Integer) sendObjectToClient(null, 10, reactor.fieldDrain); - /*if (reactor.fuelUseRate != LTFuelUseRate) LTFuelUseRate = (Integer) */sendObjectToClient(null, 11, (int)(reactor.fuelUseRate*1000000D)); + /*if (reactor.tempDrainFactor != LTTempDrainFactor) LTTempDrainFactor = (Integer) */ + sendObjectToClient(null, 8, (int) (reactor.tempDrainFactor * 1000D)); + if (reactor.generationRate != LTGenerationRate) + LTGenerationRate = (Integer) sendObjectToClient(null, 9, (int) (reactor.generationRate)); + if (reactor.fieldDrain != LTFieldDrain) + LTFieldDrain = (Integer) sendObjectToClient(null, 10, reactor.fieldDrain); + /*if (reactor.fuelUseRate != LTFuelUseRate) LTFuelUseRate = (Integer) */ + sendObjectToClient(null, 11, (int) (reactor.fuelUseRate * 1000000D)); - super.detectAndSendChanges(); - } + super.detectAndSendChanges(); + } - @Override - public void receiveSyncData(int index, int value) { - if (index == 0) reactor.conversionUnit = (double)value/100D; + @Override + public void receiveSyncData(int index, int value) { + if (index == 0) reactor.conversionUnit = (double) value / 100D; // else if (index == 1) reactor.reactionTemperature = value; // else if (index == 2) reactor.maxReactTemperature = value; // else if (index == 3) reactor.fieldCharge = value; @@ -151,112 +153,107 @@ public class ContainerReactor extends ContainerDataSync { // else if (index == 5) reactor.maxEnergySaturation = value; // else if (index == 6) reactor.convertedFuel = value; // else if (index == 7) reactor.maxFieldCharge = value; - else if (index == 8) reactor.tempDrainFactor = value/1000D; - else if (index == 9) reactor.generationRate = value; - else if (index == 10) reactor.fieldDrain = value; - else if (index == 11) reactor.fuelUseRate = value/1000000D; - if (index == 20)reactor.processButtonPress(value); - if (index == 99) - { - Iterator i = inventorySlots.iterator(); - while (i.hasNext()) { - Object o = i.next(); - if (o instanceof SlotExtract || o instanceof SlotInsert) i.remove(); - } - } - else if (index == 98) - { - addSlotToContainer(new SlotInsert(ioSlots, 0, 15, 140, reactor)); - addSlotToContainer(new SlotExtract(ioSlots, 1, 217, 140)); - } - } + else if (index == 8) reactor.tempDrainFactor = value / 1000D; + else if (index == 9) reactor.generationRate = value; + else if (index == 10) reactor.fieldDrain = value; + else if (index == 11) reactor.fuelUseRate = value / 1000000D; + if (index == 20) reactor.processButtonPress(value); + if (index == 99) { + Iterator i = inventorySlots.iterator(); + while (i.hasNext()) { + Object o = i.next(); + if (o instanceof SlotExtract || o instanceof SlotInsert) i.remove(); + } + } else if (index == 98) { + addSlotToContainer(new SlotInsert(ioSlots, 0, 15, 140, reactor)); + addSlotToContainer(new SlotExtract(ioSlots, 1, 217, 140)); + } + } - @Override - public ItemStack slotClick(int slot, int button, int p_75144_3_, EntityPlayer player1) { - if (slot == 37 && player1.inventory.getItemStack() == null){ - if (reactor.reactorFuel / 144 >= 64){ - int i = reactor.reactorFuel / 1296; - int i2 = Math.min(64, i); - ioSlots.getStorage()[1] = new ItemStack(ModBlocks.draconicBlock, i2); - reactor.reactorFuel -= i2 * 1296; - } - else if (reactor.reactorFuel >= 144){ - int i = reactor.reactorFuel / 144; - int i2 = Math.min(64, i); - ioSlots.getStorage()[1] = new ItemStack(ModItems.draconicIngot, i2); - reactor.reactorFuel -= i2 * 144; - } - else if (reactor.reactorFuel >= 16){ - int i = reactor.reactorFuel / 16; - int i2 = Math.min(64, i); - ioSlots.getStorage()[1] = new ItemStack(ModItems.nugget, i2, 1); - reactor.reactorFuel -= i2 * 16; - } - else if (reactor.convertedFuel / 144 >= 64){ - int i = reactor.convertedFuel / 1296; - int i2 = Math.min(64, i); - ioSlots.getStorage()[1] = new ItemStack(ModItems.chaosFragment, i2, 2); - reactor.convertedFuel -= i2 * 1296; - } - else if (reactor.convertedFuel >= 144){ - int i = reactor.convertedFuel / 144; - int i2 = Math.min(64, i); - ioSlots.getStorage()[1] = new ItemStack(ModItems.chaosFragment, i2, 1); - reactor.convertedFuel -= i2 * 144; - } - else if (reactor.convertedFuel >= 16){ - int i = reactor.convertedFuel / 16; - int i2 = Math.min(64, i); - ioSlots.getStorage()[1] = new ItemStack(ModItems.chaosFragment, i2, 0); - reactor.convertedFuel -= i2 * 16; - } - } - return super.slotClick(slot, button, p_75144_3_, player1); - } + @Override + public ItemStack slotClick(int slot, int button, int p_75144_3_, EntityPlayer player1) { + if (slot == 37 && player1.inventory.getItemStack() == null) { + if (reactor.reactorFuel / 144 >= 64) { + int i = reactor.reactorFuel / 1296; + int i2 = Math.min(64, i); + ioSlots.getStorage()[1] = new ItemStack(ModBlocks.draconicBlock, i2); + reactor.reactorFuel -= i2 * 1296; + } else if (reactor.reactorFuel >= 144) { + int i = reactor.reactorFuel / 144; + int i2 = Math.min(64, i); + ioSlots.getStorage()[1] = new ItemStack(ModItems.draconicIngot, i2); + reactor.reactorFuel -= i2 * 144; + } else if (reactor.reactorFuel >= 16) { + int i = reactor.reactorFuel / 16; + int i2 = Math.min(64, i); + ioSlots.getStorage()[1] = new ItemStack(ModItems.nugget, i2, 1); + reactor.reactorFuel -= i2 * 16; + } else if (reactor.convertedFuel / 144 >= 64) { + int i = reactor.convertedFuel / 1296; + int i2 = Math.min(64, i); + ioSlots.getStorage()[1] = new ItemStack(ModItems.chaosFragment, i2, 2); + reactor.convertedFuel -= i2 * 1296; + } else if (reactor.convertedFuel >= 144) { + int i = reactor.convertedFuel / 144; + int i2 = Math.min(64, i); + ioSlots.getStorage()[1] = new ItemStack(ModItems.chaosFragment, i2, 1); + reactor.convertedFuel -= i2 * 144; + } else if (reactor.convertedFuel >= 16) { + int i = reactor.convertedFuel / 16; + int i2 = Math.min(64, i); + ioSlots.getStorage()[1] = new ItemStack(ModItems.chaosFragment, i2, 0); + reactor.convertedFuel -= i2 * 16; + } + } + return super.slotClick(slot, button, p_75144_3_, player1); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { - return null; - } + @Override + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { + return null; + } - public static class SlotInsert extends Slot { - private int numberAllowed = -1; - private TileReactorCore reactor; + public static class SlotInsert extends Slot { + private int numberAllowed = -1; + private TileReactorCore reactor; - public SlotInsert(IInventory iInventory, int iSlot, int x, int y, TileReactorCore reactor) { - super(iInventory, iSlot, x, y); - this.reactor = reactor; - } + public SlotInsert(IInventory iInventory, int iSlot, int x, int y, TileReactorCore reactor) { + super(iInventory, iSlot, x, y); + this.reactor = reactor; + } - @Override - public boolean isItemValid(ItemStack stack) { - if (stack == null) return false; - else if (stack.getItem() == ModItems.nugget && stack.getItemDamage() == 1) numberAllowed = (10368 - (reactor.reactorFuel + reactor.convertedFuel)) / 16; - else if (stack.getItem() == ModItems.draconicIngot) numberAllowed = (10368 - (reactor.reactorFuel + reactor.convertedFuel)) / 144; - else if (stack.getItem() == Item.getItemFromBlock(ModBlocks.draconicBlock)) numberAllowed = (10368 - (reactor.reactorFuel + reactor.convertedFuel)) / 1296; - else return false; + @Override + public boolean isItemValid(ItemStack stack) { + if (stack == null) return false; + else if (stack.getItem() == ModItems.nugget && stack.getItemDamage() == 1) + numberAllowed = (10368 - (reactor.reactorFuel + reactor.convertedFuel)) / 16; + else if (stack.getItem() == ModItems.draconicIngot) + numberAllowed = (10368 - (reactor.reactorFuel + reactor.convertedFuel)) / 144; + else if (stack.getItem() == Item.getItemFromBlock(ModBlocks.draconicBlock)) + numberAllowed = (10368 - (reactor.reactorFuel + reactor.convertedFuel)) / 1296; + else return false; - return numberAllowed > 0; - } + return numberAllowed > 0; + } - @Override - public int getSlotStackLimit() { - return numberAllowed; - } - } + @Override + public int getSlotStackLimit() { + return numberAllowed; + } + } - public static class SlotExtract extends Slot { + public static class SlotExtract extends Slot { - private GenericInventory inventory; + private GenericInventory inventory; - public SlotExtract(GenericInventory iInventory, int iSlot, int x, int y) { - super(iInventory, iSlot, x, y); - inventory = iInventory; - } + public SlotExtract(GenericInventory iInventory, int iSlot, int x, int y) { + super(iInventory, iSlot, x, y); + inventory = iInventory; + } - @Override - public boolean isItemValid(ItemStack stack) { - return false; - } - } + @Override + public boolean isItemValid(ItemStack stack) { + return false; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerSunDial.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerSunDial.java index 9be5bdec..4189db52 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerSunDial.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerSunDial.java @@ -8,28 +8,26 @@ import net.minecraft.item.ItemStack; public class ContainerSunDial extends Container { - private TileSunDial tile; + private TileSunDial tile; - public ContainerSunDial(InventoryPlayer invPlayer, TileSunDial tile) { - this.tile = tile; + public ContainerSunDial(InventoryPlayer invPlayer, TileSunDial tile) { + this.tile = tile; - } + } - @Override - public boolean canInteractWith(EntityPlayer player) - { - return tile.isUseableByPlayer(player); - } + @Override + public boolean canInteractWith(EntityPlayer player) { + return tile.isUseableByPlayer(player); + } - - @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) - { - return null; - } - public TileSunDial getTile(){ - return tile; - } + @Override + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) { + return null; + } + + public TileSunDial getTile() { + return tile; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerTemplate.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerTemplate.java index 3abe69bd..917cedf7 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerTemplate.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerTemplate.java @@ -9,69 +9,66 @@ import net.minecraft.item.ItemStack; public class ContainerTemplate extends Container { - private TileContainerTemplate tile; - private EntityPlayer player; + private TileContainerTemplate tile; + private EntityPlayer player; - public ContainerTemplate(InventoryPlayer invPlayer, TileContainerTemplate tile) { - this.tile = tile; - this.player = invPlayer.player; + public ContainerTemplate(InventoryPlayer invPlayer, TileContainerTemplate tile) { + this.tile = tile; + this.player = invPlayer.player; - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 116)); - } + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 116)); + } - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 58 + y * 18)); - } - } + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 58 + y * 18)); + } + } - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(tile, x, 8 + 18 * x, 10)); - } + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(tile, x, 8 + 18 * x, 10)); + } - } + } - @Override - public boolean canInteractWith(EntityPlayer player) - { - return tile.isUseableByPlayer(player); - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int i) - { - Slot slot = getSlot(i); + @Override + public boolean canInteractWith(EntityPlayer player) { + return tile.isUseableByPlayer(player); + } - if (slot != null && slot.getHasStack()) - { - ItemStack stack = slot.getStack(); - ItemStack result = stack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int i) { + Slot slot = getSlot(i); - if (i >= 36){ - if (!mergeItemStack(stack, 0, 36, false)){ - return null; - } - }else if (!isStackValidForInventory(stack, 0) || !mergeItemStack(stack, 36, 36 + tile.getSizeInventory(), false)){ - return null; - } + if (slot != null && slot.getHasStack()) { + ItemStack stack = slot.getStack(); + ItemStack result = stack.copy(); - if (stack.stackSize == 0) { - slot.putStack(null); - }else{ - slot.onSlotChanged(); - } + if (i >= 36) { + if (!mergeItemStack(stack, 0, 36, false)) { + return null; + } + } else if (!isStackValidForInventory(stack, 0) || !mergeItemStack(stack, 36, 36 + tile.getSizeInventory(), false)) { + return null; + } - slot.onPickupFromSlot(player, stack); + if (stack.stackSize == 0) { + slot.putStack(null); + } else { + slot.onSlotChanged(); + } - return result; - } + slot.onPickupFromSlot(player, stack); - return null; - } + return result; + } - private boolean isStackValidForInventory(ItemStack stack, int slot){ - return true; - } + return null; + } + + private boolean isStackValidForInventory(ItemStack stack, int slot) { + return true; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerUpgradeModifier.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerUpgradeModifier.java index bb9e1643..b4e0d823 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerUpgradeModifier.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerUpgradeModifier.java @@ -13,157 +13,150 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -public class ContainerUpgradeModifier extends ContainerDataSync -{ - private static final Item[] CORES_INDEX = {ModItems.draconicCore, ModItems.wyvernCore, ModItems.awakenedCore, ModItems.chaoticCore}; - private TileUpgradeModifier tile; - private EntityPlayer player; - private boolean slotsActive = true; +public class ContainerUpgradeModifier extends ContainerDataSync { + private static final Item[] CORES_INDEX = {ModItems.draconicCore, ModItems.wyvernCore, ModItems.awakenedCore, ModItems.chaoticCore}; + private TileUpgradeModifier tile; + private EntityPlayer player; + private boolean slotsActive = true; - public ContainerUpgradeModifier(InventoryPlayer invPlayer, TileUpgradeModifier tile) { - this.tile = tile; - this.player = invPlayer.player; + public ContainerUpgradeModifier(InventoryPlayer invPlayer, TileUpgradeModifier tile) { + this.tile = tile; + this.player = invPlayer.player; - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 167)); - } + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 167)); + } - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 111 + y * 18)); - } - } + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 111 + y * 18)); + } + } - addSlotToContainer(new SlotUpgradable(tile, 0, 112, 48)); + addSlotToContainer(new SlotUpgradable(tile, 0, 112, 48)); - } + } - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - for (int i = 0; i < this.crafters.size(); ++i) - { - ICrafting icrafting = (ICrafting)this.crafters.get(i); - icrafting.sendProgressBarUpdate(this, 0, 0); - } - updateSlotState(); - } + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) { + ICrafting icrafting = (ICrafting) this.crafters.get(i); + icrafting.sendProgressBarUpdate(this, 0, 0); + } + updateSlotState(); + } - @Override - public void updateProgressBar(int index, int value) { - super.updateProgressBar(index, value); - if (index == 0) updateSlotState(); - } + @Override + public void updateProgressBar(int index, int value) { + super.updateProgressBar(index, value); + if (index == 0) updateSlotState(); + } - private void updateSlotState(){ - if (tile.getStackInSlot(0) != null && tile.getStackInSlot(0).getItem() instanceof IUpgradableItem && slotsActive) { - for (Object o : inventorySlots) { - if (o instanceof Slot && !(o instanceof SlotUpgradable)) ((Slot)o).xDisplayPosition += 1000; - } - slotsActive = false; - } - else if ((tile.getStackInSlot(0) == null || !(tile.getStackInSlot(0).getItem() instanceof IUpgradableItem)) && !slotsActive) { - for (Object o : inventorySlots) { - if (o instanceof Slot && !(o instanceof SlotUpgradable)) ((Slot)o).xDisplayPosition -= 1000; - } - slotsActive = true; - } - } + private void updateSlotState() { + if (tile.getStackInSlot(0) != null && tile.getStackInSlot(0).getItem() instanceof IUpgradableItem && slotsActive) { + for (Object o : inventorySlots) { + if (o instanceof Slot && !(o instanceof SlotUpgradable)) ((Slot) o).xDisplayPosition += 1000; + } + slotsActive = false; + } else if ((tile.getStackInSlot(0) == null || !(tile.getStackInSlot(0).getItem() instanceof IUpgradableItem)) && !slotsActive) { + for (Object o : inventorySlots) { + if (o instanceof Slot && !(o instanceof SlotUpgradable)) ((Slot) o).xDisplayPosition -= 1000; + } + slotsActive = true; + } + } - @Override - public boolean canInteractWith(EntityPlayer player) - { - return tile.isUseableByPlayer(player); - } + @Override + public boolean canInteractWith(EntityPlayer player) { + return tile.isUseableByPlayer(player); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int i) - { - Slot slot = getSlot(i); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int i) { + Slot slot = getSlot(i); - if (slot != null && slot.getHasStack()) - { - ItemStack stack = slot.getStack(); - ItemStack result = stack.copy(); + if (slot != null && slot.getHasStack()) { + ItemStack stack = slot.getStack(); + ItemStack result = stack.copy(); - if (i >= 36){ - if (!mergeItemStack(stack, 0, 36, false)){ - return null; - } - }else if (!isStackValidForInventory(stack, 0) || !mergeItemStack(stack, 36, 36 + tile.getSizeInventory(), false)){ - return null; - } + if (i >= 36) { + if (!mergeItemStack(stack, 0, 36, false)) { + return null; + } + } else if (!isStackValidForInventory(stack, 0) || !mergeItemStack(stack, 36, 36 + tile.getSizeInventory(), false)) { + return null; + } - if (stack.stackSize == 0) { - slot.putStack(null); - }else{ - slot.onSlotChanged(); - } + if (stack.stackSize == 0) { + slot.putStack(null); + } else { + slot.onSlotChanged(); + } - slot.onPickupFromSlot(player, stack); + slot.onPickupFromSlot(player, stack); - return result; - } + return result; + } - return null; - } + return null; + } - private boolean isStackValidForInventory(ItemStack stack, int slot){ - return true; - } + private boolean isStackValidForInventory(ItemStack stack, int slot) { + return true; + } - @Override - public void receiveSyncData(int index, int value) { - EnumUpgrade upgrade = EnumUpgrade.getUpgradeByIndex(index); - int coreTier = value/2; - boolean addCore = value % 2 == 0; - ItemStack stack = tile.getStackInSlot(0); - if (upgrade == null || stack == null || !(stack.getItem() instanceof IUpgradableItem) || coreTier < 0 || coreTier > 3 || (upgrade.getCoresApplied(stack)[coreTier] <= 0 && !addCore)) return; - handleCoreTransaction(upgrade, coreTier, addCore, (IUpgradableItem)stack.getItem(), stack); - } + @Override + public void receiveSyncData(int index, int value) { + EnumUpgrade upgrade = EnumUpgrade.getUpgradeByIndex(index); + int coreTier = value / 2; + boolean addCore = value % 2 == 0; + ItemStack stack = tile.getStackInSlot(0); + if (upgrade == null || stack == null || !(stack.getItem() instanceof IUpgradableItem) || coreTier < 0 || coreTier > 3 || (upgrade.getCoresApplied(stack)[coreTier] <= 0 && !addCore)) + return; + handleCoreTransaction(upgrade, coreTier, addCore, (IUpgradableItem) stack.getItem(), stack); + } - private void handleCoreTransaction(EnumUpgrade upgrade, int coreTier, boolean addCoreElseRemove, IUpgradableItem upgradableItem, ItemStack stack) { - int coreSlots = upgradableItem.getUpgradeCap(stack); - int totalCores = 0; - int[] coresApplied = upgrade.getCoresApplied(stack); - for (EnumUpgrade u : upgradableItem.getUpgrades(stack)) totalCores += u.getCoresApplied(stack)[coreTier]; + private void handleCoreTransaction(EnumUpgrade upgrade, int coreTier, boolean addCoreElseRemove, IUpgradableItem upgradableItem, ItemStack stack) { + int coreSlots = upgradableItem.getUpgradeCap(stack); + int totalCores = 0; + int[] coresApplied = upgrade.getCoresApplied(stack); + for (EnumUpgrade u : upgradableItem.getUpgrades(stack)) totalCores += u.getCoresApplied(stack)[coreTier]; - if (addCoreElseRemove) - { - if (!player.inventory.hasItem(CORES_INDEX[coreTier]) || totalCores >= coreSlots || upgrade.getUpgradePoints(stack) >= upgradableItem.getMaxUpgradePoints(upgrade.index, stack)) return; - coresApplied[coreTier]++; - player.inventory.consumeInventoryItem(CORES_INDEX[coreTier]); - upgrade.setCoresApplied(stack, coresApplied); - upgrade.onAppliedToItem(stack); - } - else - { - if (coresApplied[coreTier] <= 0) return; - coresApplied[coreTier]--; - upgrade.setCoresApplied(stack, coresApplied); - upgrade.onRemovedFromItem(stack); - if (!player.inventory.addItemStackToInventory(new ItemStack(CORES_INDEX[coreTier]))) { - EntityItem entityItem = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, new ItemStack(CORES_INDEX[coreTier])); - if (!player.worldObj.isRemote) player.worldObj.spawnEntityInWorld(entityItem); - } - } - } + if (addCoreElseRemove) { + if (!player.inventory.hasItem(CORES_INDEX[coreTier]) || totalCores >= coreSlots || upgrade.getUpgradePoints(stack) >= upgradableItem.getMaxUpgradePoints(upgrade.index, stack)) + return; + coresApplied[coreTier]++; + player.inventory.consumeInventoryItem(CORES_INDEX[coreTier]); + upgrade.setCoresApplied(stack, coresApplied); + upgrade.onAppliedToItem(stack); + } else { + if (coresApplied[coreTier] <= 0) return; + coresApplied[coreTier]--; + upgrade.setCoresApplied(stack, coresApplied); + upgrade.onRemovedFromItem(stack); + if (!player.inventory.addItemStackToInventory(new ItemStack(CORES_INDEX[coreTier]))) { + EntityItem entityItem = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, new ItemStack(CORES_INDEX[coreTier])); + if (!player.worldObj.isRemote) player.worldObj.spawnEntityInWorld(entityItem); + } + } + } - public static class SlotUpgradable extends Slot { + public static class SlotUpgradable extends Slot { - public SlotUpgradable(IInventory inventory1, int slot, int x, int y) { - super(inventory1, slot, x, y); - } + public SlotUpgradable(IInventory inventory1, int slot, int x, int y) { + super(inventory1, slot, x, y); + } - //Some people think this block makes a nice display stand... And i cant disagree. - @Override - public boolean isItemValid(ItemStack stack) { - return super.isItemValid(stack); - //return stack != null && stack.getItem() instanceof IUpgradableItem; - } - } + //Some people think this block makes a nice display stand... And i cant disagree. + @Override + public boolean isItemValid(ItemStack stack) { + return super.isItemValid(stack); + //return stack != null && stack.getItem() instanceof IUpgradableItem; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerWeatherController.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerWeatherController.java index 7810a4ab..827fa14c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerWeatherController.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerWeatherController.java @@ -11,65 +11,62 @@ import net.minecraft.item.ItemStack; public class ContainerWeatherController extends Container { - private TileWeatherController tileWC; + private TileWeatherController tileWC; - public ContainerWeatherController(InventoryPlayer invPlayer, TileWeatherController tileWC) { - this.tileWC = tileWC; + public ContainerWeatherController(InventoryPlayer invPlayer, TileWeatherController tileWC) { + this.tileWC = tileWC; - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 119)); - } + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 119)); + } - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 9; x++) { - addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 61 + y * 18)); - } - } + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 61 + y * 18)); + } + } - addSlotToContainer(new SlotItemValid(tileWC, 0, 47, 15, Items.emerald)); - } + addSlotToContainer(new SlotItemValid(tileWC, 0, 47, 15, Items.emerald)); + } - @Override - public boolean canInteractWith(EntityPlayer player) - { - return tileWC.isUseableByPlayer(player); - } + @Override + public boolean canInteractWith(EntityPlayer player) { + return tileWC.isUseableByPlayer(player); + } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int i) - { - Slot slot = getSlot(i); - if (slot != null && slot.getHasStack()) - { - ItemStack stack = slot.getStack(); - ItemStack result = stack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int i) { + Slot slot = getSlot(i); - if (i >= 36){ - if (!mergeItemStack(stack, 0, 36, false)){ - return null; - } - }else if (!stack.getItem().equals(Items.emerald) || !mergeItemStack(stack, 36, 36 + tileWC.getSizeInventory(), false)){ - return null; - } + if (slot != null && slot.getHasStack()) { + ItemStack stack = slot.getStack(); + ItemStack result = stack.copy(); - if (stack.stackSize == 0) { - slot.putStack(null); - }else{ - slot.onSlotChanged(); - } + if (i >= 36) { + if (!mergeItemStack(stack, 0, 36, false)) { + return null; + } + } else if (!stack.getItem().equals(Items.emerald) || !mergeItemStack(stack, 36, 36 + tileWC.getSizeInventory(), false)) { + return null; + } - slot.onPickupFromSlot(player, stack); + if (stack.stackSize == 0) { + slot.putStack(null); + } else { + slot.onSlotChanged(); + } - return result; - } + slot.onPickupFromSlot(player, stack); - return null; - } + return result; + } - public TileWeatherController getTileWC(){ - return tileWC; - } + return null; + } + + public TileWeatherController getTileWC() { + return tileWC; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/DummyContainer.java b/src/main/java/com/brandon3055/draconicevolution/common/container/DummyContainer.java index 782e17f2..fd25b7f0 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/DummyContainer.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/DummyContainer.java @@ -8,14 +8,14 @@ import net.minecraft.item.ItemStack; * Created by Brandon on 16/09/2014. */ public class DummyContainer extends Container { - @Override - public boolean canInteractWith(EntityPlayer p_75145_1_) { - return true; - } + @Override + public boolean canInteractWith(EntityPlayer p_75145_1_) { + return true; + } - @Override - public void putStackInSlot(int p_75141_1_, ItemStack p_75141_2_) { + @Override + public void putStackInSlot(int p_75141_1_, ItemStack p_75141_2_) { - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/ChaosImplosion.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/ChaosImplosion.java index bdd67d58..98a760f4 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/entity/ChaosImplosion.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/ChaosImplosion.java @@ -13,53 +13,52 @@ import java.util.Random; */ public class ChaosImplosion implements IProcess { - public static DamageSource chaosImplosion = new DamageSource("chaosImplosion").setExplosion().setDamageBypassesArmor().setDamageIsAbsolute().setDamageAllowedInCreativeMode(); + public static DamageSource chaosImplosion = new DamageSource("chaosImplosion").setExplosion().setDamageBypassesArmor().setDamageIsAbsolute().setDamageAllowedInCreativeMode(); - private World worldObj; - private int xCoord; - private int yCoord; - private int zCoord; - private float power; - private Random random = new Random(); + private World worldObj; + private int xCoord; + private int yCoord; + private int zCoord; + private float power; + private Random random = new Random(); - private double expansion = 0; + private double expansion = 0; - public ChaosImplosion(World world, int x, int y, int z){ - this.worldObj = world; - this.xCoord = x; - this.yCoord = y; - this.zCoord = z; - this.power = 15F; - isDead = world.isRemote; - } + public ChaosImplosion(World world, int x, int y, int z) { + this.worldObj = world; + this.xCoord = x; + this.yCoord = y; + this.zCoord = z; + this.power = 15F; + isDead = world.isRemote; + } - @Override - public void updateProcess() { + @Override + public void updateProcess() { - int OD = (int) expansion; - int ID = OD - 1; - int size = (int) expansion; + int OD = (int) expansion; + int ID = OD - 1; + int size = (int) expansion; - for (int x = xCoord - size; x < xCoord + size; x++){ - for (int z = zCoord - size; z < zCoord + size; z++){ - double dist = Utills.getDistanceAtoB(x, z, xCoord, zCoord); - if (dist < OD && dist >= ID) - { - float tracePower = power - (float)(expansion/10D); - tracePower *= 1F + ((random.nextFloat() - 0.5F) * 0.2); - ProcessHandler.addProcess(new ChaosImplosionTrace(worldObj, x, yCoord, z, tracePower, random)); - } - } - } + for (int x = xCoord - size; x < xCoord + size; x++) { + for (int z = zCoord - size; z < zCoord + size; z++) { + double dist = Utills.getDistanceAtoB(x, z, xCoord, zCoord); + if (dist < OD && dist >= ID) { + float tracePower = power - (float) (expansion / 10D); + tracePower *= 1F + ((random.nextFloat() - 0.5F) * 0.2); + ProcessHandler.addProcess(new ChaosImplosionTrace(worldObj, x, yCoord, z, tracePower, random)); + } + } + } - isDead = expansion >= power * 10; - expansion += 1; - } + isDead = expansion >= power * 10; + expansion += 1; + } - private boolean isDead = false; + private boolean isDead = false; - @Override - public boolean isDead() { - return isDead; - } + @Override + public boolean isDead() { + return isDead; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/ChaosImplosionTrace.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/ChaosImplosionTrace.java index 6e86dd6f..fe91e0e6 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/entity/ChaosImplosionTrace.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/ChaosImplosionTrace.java @@ -14,56 +14,57 @@ import java.util.Random; */ public class ChaosImplosionTrace implements IProcess { - private World worldObj; - private int xCoord; - private int yCoord; - private int zCoord; - private float power; - private Random random; + private World worldObj; + private int xCoord; + private int yCoord; + private int zCoord; + private float power; + private Random random; - public ChaosImplosionTrace(World world, int x, int y, int z, float power, Random random){ - this.worldObj = world; - this.xCoord = x; - this.yCoord = y; - this.zCoord = z; - this.power = power; - this.random = random; - } + public ChaosImplosionTrace(World world, int x, int y, int z, float power, Random random) { + this.worldObj = world; + this.xCoord = x; + this.yCoord = y; + this.zCoord = z; + this.power = power; + this.random = random; + } - @Override - public void updateProcess() { + @Override + public void updateProcess() { - float energy = power * 10; + float energy = power * 10; - for (int y = yCoord; y > 0 && energy > 0; y--){ - List entities = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord, y, zCoord, xCoord+1, y+1, zCoord+1)); - for (Entity entity : entities) entity.attackEntityFrom(ChaosImplosion.chaosImplosion, power * 100); + for (int y = yCoord; y > 0 && energy > 0; y--) { + List entities = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord, y, zCoord, xCoord + 1, y + 1, zCoord + 1)); + for (Entity entity : entities) entity.attackEntityFrom(ChaosImplosion.chaosImplosion, power * 100); - //energy -= block instanceof BlockLiquid ? 10 : block.getExplosionResistance(null); + //energy -= block instanceof BlockLiquid ? 10 : block.getExplosionResistance(null); - if (energy >= 0) worldObj.setBlockToAir(xCoord, y, zCoord); - energy -= 0.5F + (0.1F * (yCoord - y)); - } + if (energy >= 0) worldObj.setBlockToAir(xCoord, y, zCoord); + energy -= 0.5F + (0.1F * (yCoord - y)); + } - energy = power * 20; - yCoord++; - for (int y = yCoord; y < 255 && energy > 0; y++){ - List entities = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord, y, zCoord, xCoord+1, y+1, zCoord+1)); - for (Entity entity : entities) entity.attackEntityFrom(ReactorExplosion.fusionExplosion, power * 100); + energy = power * 20; + yCoord++; + for (int y = yCoord; y < 255 && energy > 0; y++) { + List entities = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord, y, zCoord, xCoord + 1, y + 1, zCoord + 1)); + for (Entity entity : entities) entity.attackEntityFrom(ReactorExplosion.fusionExplosion, power * 100); - //energy -= block instanceof BlockLiquid ? 10 : block.getExplosionResistance(null); - if (energy >= 0) worldObj.setBlockToAir(xCoord, y, zCoord); + //energy -= block instanceof BlockLiquid ? 10 : block.getExplosionResistance(null); + if (energy >= 0) worldObj.setBlockToAir(xCoord, y, zCoord); - energy -= 0.5F + (0.1F * (y - yCoord)); - } + energy -= 0.5F + (0.1F * (y - yCoord)); + } - isDead = true; - } + isDead = true; + } - private boolean isDead = false; - @Override - public boolean isDead() { - return isDead; - } + private boolean isDead = false; + + @Override + public boolean isDead() { + return isDead; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosBolt.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosBolt.java index 0ebd7b20..a49b4c7b 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosBolt.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosBolt.java @@ -12,65 +12,65 @@ import net.minecraft.world.World; */ public class EntityChaosBolt extends Entity { - public double shardX; - public double shardY; - public double shardZ; - public boolean burst; + public double shardX; + public double shardY; + public double shardZ; + public boolean burst; public int ticks = 0; - private static DamageSource chaosBurst = new DamageSource("chaosBurst").setDamageBypassesArmor().setDamageIsAbsolute(); + private static DamageSource chaosBurst = new DamageSource("chaosBurst").setDamageBypassesArmor().setDamageIsAbsolute(); - public EntityChaosBolt(World world) { - this(world, 0, 0, 0, 0, 0, 0); - } + public EntityChaosBolt(World world) { + this(world, 0, 0, 0, 0, 0, 0); + } - public EntityChaosBolt(World world, double x, double y, double z, double shardX, double shardY, double shardZ) { - super(world); - this.shardX = shardX; - this.shardY = shardY; - this.shardZ = shardZ; - this.setPosition(x, y, z); - this.setSize(0.25F, 0.25F); - } + public EntityChaosBolt(World world, double x, double y, double z, double shardX, double shardY, double shardZ) { + super(world); + this.shardX = shardX; + this.shardY = shardY; + this.shardZ = shardZ; + this.setPosition(x, y, z); + this.setSize(0.25F, 0.25F); + } - @Override - public boolean isInRangeToRenderDist(double p_70112_1_) { - return false; - } + @Override + public boolean isInRangeToRenderDist(double p_70112_1_) { + return false; + } - @Override - protected void entityInit() { - burst = rand.nextInt(30) == 0; - dataWatcher.addObject(20, (float)shardX); - dataWatcher.addObject(21, (float)shardZ); - dataWatcher.addObject(22, burst ? (byte)1 : (byte)0); - } + @Override + protected void entityInit() { + burst = rand.nextInt(30) == 0; + dataWatcher.addObject(20, (float) shardX); + dataWatcher.addObject(21, (float) shardZ); + dataWatcher.addObject(22, burst ? (byte) 1 : (byte) 0); + } - @Override - public void onUpdate() { - super.onUpdate(); - if (worldObj.isRemote) { - shardX = dataWatcher.getWatchableObjectFloat(20); - shardZ = dataWatcher.getWatchableObjectFloat(21); - burst = dataWatcher.getWatchableObjectByte(22) == 1; - }else { - dataWatcher.updateObject(20, (float) shardX); - dataWatcher.updateObject(21, (float) shardZ); - dataWatcher.updateObject(22, burst ? (byte)1 : (byte)0); - } + @Override + public void onUpdate() { + super.onUpdate(); + if (worldObj.isRemote) { + shardX = dataWatcher.getWatchableObjectFloat(20); + shardZ = dataWatcher.getWatchableObjectFloat(21); + burst = dataWatcher.getWatchableObjectByte(22) == 1; + } else { + dataWatcher.updateObject(20, (float) shardX); + dataWatcher.updateObject(21, (float) shardZ); + dataWatcher.updateObject(22, burst ? (byte) 1 : (byte) 0); + } - if (ticks == 10 && !burst) { - if (worldObj.isRemote) { + if (ticks == 10 && !burst) { + if (worldObj.isRemote) { DraconicEvolution.proxy.spawnParticle(new Particles.ChaosBoltParticle(worldObj, posX, posY, posZ, shardX, shardY, shardZ, 10), 32); } - setDead(); - } - else if (ticks > 10){ - if (ticks < 25){ - for (int i = 0; i < 20; i++){ - if (worldObj.isRemote) DraconicEvolution.proxy.spawnParticle(new Particles.ChaosBoltParticle(worldObj, posX, posY, posZ, shardX, shardY, shardZ, 0), 32); - } - } - if (ticks > 40 && !worldObj.isRemote) { + setDead(); + } else if (ticks > 10) { + if (ticks < 25) { + for (int i = 0; i < 20; i++) { + if (worldObj.isRemote) + DraconicEvolution.proxy.spawnParticle(new Particles.ChaosBoltParticle(worldObj, posX, posY, posZ, shardX, shardY, shardZ, 0), 32); + } + } + if (ticks > 40 && !worldObj.isRemote) { // if (ticks % 5 == 0) // { // double dist = Utills.getDistanceAtoB(posX, posY, posZ, shardX, shardY, shardZ); @@ -84,18 +84,18 @@ public class EntityChaosBolt extends Entity { // entity.attackEntityFrom(chaosBurst, 50F); // } // } - } - } + } + } if (ticks > 60) { setDead(); } ticks++; - } + } - @Override - protected void readEntityFromNBT(NBTTagCompound compound) { + @Override + protected void readEntityFromNBT(NBTTagCompound compound) { // if (compound.hasKey("ShardPos")){ // int[] pos = compound.getIntArray("ShardPos"); // shardX = pos[0]; @@ -103,11 +103,11 @@ public class EntityChaosBolt extends Entity { // shardZ = pos[2]; // LogHelper.info("read"); // } - } + } - @Override - protected void writeEntityToNBT(NBTTagCompound compound) { + @Override + protected void writeEntityToNBT(NBTTagCompound compound) { // compound.setIntArray("ShardPos", new int[] {(int)(shardX-0.5D), (int)(shardY-0.5D), (int)(shardZ-0.5D)}); // LogHelper.info("write"); - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosCrystal.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosCrystal.java index 39c1a3a7..d27577d9 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosCrystal.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosCrystal.java @@ -24,192 +24,190 @@ import java.util.List; * Created by brandon3055 on 30/8/2015. */ public class EntityChaosCrystal extends EntityLivingBase { - public int innerRotation; - public float deathAnimation = 1F; - public int shieldTime = 0; - public EntityChaosGuardian guardian; - private int timeTillDeath = -1; - public float health = 50; + public int innerRotation; + public float deathAnimation = 1F; + public int shieldTime = 0; + public EntityChaosGuardian guardian; + private int timeTillDeath = -1; + public float health = 50; - public EntityChaosCrystal(World p_i1698_1_) { - super(p_i1698_1_); - this.preventEntitySpawning = true; - this.setSize(2.0F, 2.0F); - //this.yOffset = -2; - this.innerRotation = this.rand.nextInt(100000); - this.setHealth(getMaxHealth()); - this.ignoreFrustumCheck = true; - } + public EntityChaosCrystal(World p_i1698_1_) { + super(p_i1698_1_); + this.preventEntitySpawning = true; + this.setSize(2.0F, 2.0F); + //this.yOffset = -2; + this.innerRotation = this.rand.nextInt(100000); + this.setHealth(getMaxHealth()); + this.ignoreFrustumCheck = true; + } - @Override - protected void applyEntityAttributes() { - super.applyEntityAttributes(); - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(50F); - } + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(50F); + } - @Override - public boolean canTriggerWalking() { - return false; - } + @Override + public boolean canTriggerWalking() { + return false; + } - @Override - public void entityInit() { - super.entityInit(); - dataWatcher.addObject(20, (short)shieldTime); - dataWatcher.addObject(21, health); - } + @Override + public void entityInit() { + super.entityInit(); + dataWatcher.addObject(20, (short) shieldTime); + dataWatcher.addObject(21, health); + } - @Override - public void onUpdate() { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; + @Override + public void onUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; - if (!worldObj.isRemote){ - health = getHealth(); - dataWatcher.updateObject(20, (short)shieldTime); - dataWatcher.updateObject(21, health); - } - else { - shieldTime = (int)dataWatcher.getWatchableObjectShort(20); - health = dataWatcher.getWatchableObjectFloat(21); - } - //setHealth(0); - if (health > 0){ - if (shieldTime > 0) shieldTime--; - if (deathAnimation < 1F) deathAnimation += 0.1F; - ++this.innerRotation; + if (!worldObj.isRemote) { + health = getHealth(); + dataWatcher.updateObject(20, (short) shieldTime); + dataWatcher.updateObject(21, health); + } else { + shieldTime = (int) dataWatcher.getWatchableObjectShort(20); + health = dataWatcher.getWatchableObjectFloat(21); + } + //setHealth(0); + if (health > 0) { + if (shieldTime > 0) shieldTime--; + if (deathAnimation < 1F) deathAnimation += 0.1F; + ++this.innerRotation; - int i = MathHelper.floor_double(this.posX); - int j = MathHelper.floor_double(this.posY); - int k = MathHelper.floor_double(this.posZ); + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posY); + int k = MathHelper.floor_double(this.posZ); - if (this.worldObj.provider instanceof WorldProviderEnd && this.worldObj.getBlock(i, j, k).isBlockSolid(this.worldObj, i, j, k, 0) && this.worldObj.getBlock(i, j, k) != Blocks.fire) this.worldObj.setBlock(i, j, k, Blocks.fire); + if (this.worldObj.provider instanceof WorldProviderEnd && this.worldObj.getBlock(i, j, k).isBlockSolid(this.worldObj, i, j, k, 0) && this.worldObj.getBlock(i, j, k) != Blocks.fire) + this.worldObj.setBlock(i, j, k, Blocks.fire); - }else if (deathAnimation > 0) deathAnimation -= 0.1F; + } else if (deathAnimation > 0) deathAnimation -= 0.1F; - if (guardian != null && guardian.isDead) setDeathTimer(); - if (timeTillDeath > 0) timeTillDeath--; - if (timeTillDeath == 0 && !worldObj.isRemote){ - worldObj.addWeatherEffect(new EntityLightningBolt(worldObj, posX, posY, posZ)); - worldObj.createExplosion(this, posX, posY+2, posZ, 20, true); + if (guardian != null && guardian.isDead) setDeathTimer(); + if (timeTillDeath > 0) timeTillDeath--; + if (timeTillDeath == 0 && !worldObj.isRemote) { + worldObj.addWeatherEffect(new EntityLightningBolt(worldObj, posX, posY, posZ)); + worldObj.createExplosion(this, posX, posY + 2, posZ, 20, true); - for (int x = (int)posX - 5; x <= (int)posX + 5; x++){ - for (int y = (int)posY - 25; y <= (int)posY + 5; y++){ - for (int z = (int)posZ - 5; z <= (int)posZ + 5; z++){ - Block block = worldObj.getBlock(x, y, z); + for (int x = (int) posX - 5; x <= (int) posX + 5; x++) { + for (int y = (int) posY - 25; y <= (int) posY + 5; y++) { + for (int z = (int) posZ - 5; z <= (int) posZ + 5; z++) { + Block block = worldObj.getBlock(x, y, z); - if (block == Blocks.obsidian || block == ModBlocks.infusedObsidian){ - EntityFallingBlock fallingBlock = new EntityFallingBlock(worldObj, x, y, z, block); - fallingBlock.field_145812_b = 2; - fallingBlock.field_145813_c = false; - float motion = 2F; - fallingBlock.motionX = (rand.nextFloat()-0.5F) * motion; - fallingBlock.motionY = (rand.nextFloat()-0.5F) * motion; - fallingBlock.motionZ = (rand.nextFloat()-0.5F) * motion; - worldObj.setBlockToAir(x, y, z); - worldObj.spawnEntityInWorld(fallingBlock); - } - } - } - } - this.setDead(); - } - } + if (block == Blocks.obsidian || block == ModBlocks.infusedObsidian) { + EntityFallingBlock fallingBlock = new EntityFallingBlock(worldObj, x, y, z, block); + fallingBlock.field_145812_b = 2; + fallingBlock.field_145813_c = false; + float motion = 2F; + fallingBlock.motionX = (rand.nextFloat() - 0.5F) * motion; + fallingBlock.motionY = (rand.nextFloat() - 0.5F) * motion; + fallingBlock.motionZ = (rand.nextFloat() - 0.5F) * motion; + worldObj.setBlockToAir(x, y, z); + worldObj.spawnEntityInWorld(fallingBlock); + } + } + } + } + this.setDead(); + } + } - @Override - public boolean isEntityAlive() { - return !isDead; - } + @Override + public boolean isEntityAlive() { + return !isDead; + } - public void setDeathTimer(){ - if (timeTillDeath > 0) return; - timeTillDeath = rand.nextInt(400); - } + public void setDeathTimer() { + if (timeTillDeath > 0) return; + timeTillDeath = rand.nextInt(400); + } - @Override - public void writeEntityToNBT(NBTTagCompound compound) { - super.writeEntityToNBT(compound); - } + @Override + public void writeEntityToNBT(NBTTagCompound compound) { + super.writeEntityToNBT(compound); + } - @Override - public void readEntityFromNBT(NBTTagCompound compound) { - super.readEntityFromNBT(compound); - } + @Override + public void readEntityFromNBT(NBTTagCompound compound) { + super.readEntityFromNBT(compound); + } - @Override - @SideOnly(Side.CLIENT) - public float getShadowSize() { - return 0.0F; - } + @Override + @SideOnly(Side.CLIENT) + public float getShadowSize() { + return 0.0F; + } - @Override - public boolean canBeCollidedWith() { - return true; - } + @Override + public boolean canBeCollidedWith() { + return true; + } - @Override - public boolean attackEntityFrom(DamageSource source, float dmg) { - if (this.isEntityInvulnerable()) - { - return false; - } else if (source.getEntity() instanceof EntityPlayer) - { - if (shieldTime <= 0 && getHealth() > 0 && !this.worldObj.isRemote) - { - setHealth(getHealth() - Math.min(getHealth(), dmg)); - if (getHealth() <= 0) worldObj.createExplosion(null, this.posX, this.posY, this.posZ, 6.0F, false); - else { - shieldTime = 100 + rand.nextInt(100); - worldObj.playSoundEffect(posX + 0.5D, posY + 0.5D, posZ + 0.5D, "draconicevolution:shieldUp", 10.0F, rand.nextFloat() * 0.1F + 1.055F); - } - if (getGuardian() != null) getGuardian().onCrystalTargeted((EntityPlayer)source.getEntity(), getHealth() <= 0); - return true; - }else if (shieldTime > 0 && !this.worldObj.isRemote) shieldTime = 100 + rand.nextInt(100); - } - return false; - } + @Override + public boolean attackEntityFrom(DamageSource source, float dmg) { + if (this.isEntityInvulnerable()) { + return false; + } else if (source.getEntity() instanceof EntityPlayer) { + if (shieldTime <= 0 && getHealth() > 0 && !this.worldObj.isRemote) { + setHealth(getHealth() - Math.min(getHealth(), dmg)); + if (getHealth() <= 0) worldObj.createExplosion(null, this.posX, this.posY, this.posZ, 6.0F, false); + else { + shieldTime = 100 + rand.nextInt(100); + worldObj.playSoundEffect(posX + 0.5D, posY + 0.5D, posZ + 0.5D, "draconicevolution:shieldUp", 10.0F, rand.nextFloat() * 0.1F + 1.055F); + } + if (getGuardian() != null) + getGuardian().onCrystalTargeted((EntityPlayer) source.getEntity(), getHealth() <= 0); + return true; + } else if (shieldTime > 0 && !this.worldObj.isRemote) shieldTime = 100 + rand.nextInt(100); + } + return false; + } - private EntityChaosGuardian getGuardian(){ - if (guardian == null) { - @SuppressWarnings("unchecked") List list = worldObj.getEntitiesWithinAABB(EntityChaosGuardian.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX, posY, posZ).expand(512, 512, 512)); - if (list.size() > 0) guardian = list.get(0); - if (guardian != null && guardian.crystals != null && !guardian.crystals.contains(this)) { - guardian.crystals.add(this); - guardian.updateCrystals(); - } - } - return guardian; - } + private EntityChaosGuardian getGuardian() { + if (guardian == null) { + @SuppressWarnings("unchecked") List list = worldObj.getEntitiesWithinAABB(EntityChaosGuardian.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX, posY, posZ).expand(512, 512, 512)); + if (list.size() > 0) guardian = list.get(0); + if (guardian != null && guardian.crystals != null && !guardian.crystals.contains(this)) { + guardian.crystals.add(this); + guardian.updateCrystals(); + } + } + return guardian; + } - public void revive(){ - setHealth(getMaxHealth()); - shieldTime = 50; - worldObj.createExplosion(null, this.posX, this.posY, this.posZ, 6.0F, false); - if (getGuardian() != null) getGuardian().updateCrystals(); - } + public void revive() { + setHealth(getMaxHealth()); + shieldTime = 50; + worldObj.createExplosion(null, this.posX, this.posY, this.posZ, 6.0F, false); + if (getGuardian() != null) getGuardian().updateCrystals(); + } - public boolean isAlive() { - return getHealth() > 0F; - } + public boolean isAlive() { + return getHealth() > 0F; + } - @Override - public ItemStack getHeldItem() { - return null; - } + @Override + public ItemStack getHeldItem() { + return null; + } - @Override - public ItemStack getEquipmentInSlot(int p_71124_1_) { - return null; - } + @Override + public ItemStack getEquipmentInSlot(int p_71124_1_) { + return null; + } - @Override - public void setCurrentItemOrArmor(int p_70062_1_, ItemStack p_70062_2_) { + @Override + public void setCurrentItemOrArmor(int p_70062_1_, ItemStack p_70062_2_) { - } + } - @Override - public ItemStack[] getLastActiveItems() { - return new ItemStack[0]; - } + @Override + public ItemStack[] getLastActiveItems() { + return new ItemStack[0]; + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosDrill.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosDrill.java index d53e495b..e13e16a2 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosDrill.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosDrill.java @@ -15,83 +15,84 @@ import java.util.ArrayList; */ public class EntityChaosDrill extends Entity { - public int MAX_AGE = 300; - private int ENTITY_AGE = 0; - private EntityPlayer PLAYER; - public EntityChaosDrill(World world) { - super(world); - } + public int MAX_AGE = 300; + private int ENTITY_AGE = 0; + private EntityPlayer PLAYER; - public EntityChaosDrill(World world, EntityPlayer player){ - super(world); - this.PLAYER = player; - this.setSize(0.1F, 0.1F); - this.setPosition(player.posX, player.posY, player.posZ); - } + public EntityChaosDrill(World world) { + super(world); + } - @Override - public boolean canBePushed() { - return false; - } + public EntityChaosDrill(World world, EntityPlayer player) { + super(world); + this.PLAYER = player; + this.setSize(0.1F, 0.1F); + this.setPosition(player.posX, player.posY, player.posZ); + } - @Override - protected void entityInit() { - LogHelper.info("entityInit"); - } + @Override + public boolean canBePushed() { + return false; + } - @Override - public void onUpdate() { - //LogHelper.info("onUpdate"); - mineNextBlockInPattern(); - entityTick(); - } + @Override + protected void entityInit() { + LogHelper.info("entityInit"); + } - @Override - protected void readEntityFromNBT(NBTTagCompound p_70037_1_) { + @Override + public void onUpdate() { + //LogHelper.info("onUpdate"); + mineNextBlockInPattern(); + entityTick(); + } - } + @Override + protected void readEntityFromNBT(NBTTagCompound p_70037_1_) { - @Override - protected void writeEntityToNBT(NBTTagCompound p_70014_1_) { + } - } + @Override + protected void writeEntityToNBT(NBTTagCompound p_70014_1_) { - private void entityTick(){ - if (ENTITY_AGE >= MAX_AGE) setDead(); - ENTITY_AGE++; - } + } - private void mineNextBlockInPattern(){ - ArrayList blocks = getBlocksInSphere(5); - LogHelper.info(blocks.size()); - if (blocks.size() > 0) worldObj.setBlockToAir(blocks.get(1).getXCoord(), blocks.get(1).getYCoord(), blocks.get(1).getZCoord()); - } + private void entityTick() { + if (ENTITY_AGE >= MAX_AGE) setDead(); + ENTITY_AGE++; + } - private ArrayList getBlocksInSphere(int r){ - ArrayList blocks = new ArrayList(); - int minDist = 100; + private void mineNextBlockInPattern() { + ArrayList blocks = getBlocksInSphere(5); + LogHelper.info(blocks.size()); + if (blocks.size() > 0) + worldObj.setBlockToAir(blocks.get(1).getXCoord(), blocks.get(1).getYCoord(), blocks.get(1).getZCoord()); + } - for( int x = (int)posX-r ; x <= (int)posX+r; x++){ - for( int z = (int)posZ-r ; z <= (int)posZ+r; z++) { - for (int y = (int)posY-r; y <= (int)posY+r; y++) { - int dist = (int) (Utills.getDistanceAtoB(x, y, z, (int) posX, (int) posY, (int) posZ)); - if (dist <= r) { - if (!worldObj.isAirBlock(x, y, z)) { - if (blocks.size() <= dist) { - blocks.add(new MultiblockHelper.TileLocation(x, y, z)); - } - else { - blocks.set(dist, new MultiblockHelper.TileLocation(x, y, z)); - } - if (dist < minDist) minDist = dist; - } - } - } - } - } - LogHelper.info("dist: " + minDist); + private ArrayList getBlocksInSphere(int r) { + ArrayList blocks = new ArrayList(); + int minDist = 100; - return blocks; - } + for (int x = (int) posX - r; x <= (int) posX + r; x++) { + for (int z = (int) posZ - r; z <= (int) posZ + r; z++) { + for (int y = (int) posY - r; y <= (int) posY + r; y++) { + int dist = (int) (Utills.getDistanceAtoB(x, y, z, (int) posX, (int) posY, (int) posZ)); + if (dist <= r) { + if (!worldObj.isAirBlock(x, y, z)) { + if (blocks.size() <= dist) { + blocks.add(new MultiblockHelper.TileLocation(x, y, z)); + } else { + blocks.set(dist, new MultiblockHelper.TileLocation(x, y, z)); + } + if (dist < minDist) minDist = dist; + } + } + } + } + } + LogHelper.info("dist: " + minDist); + + return blocks; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosGuardian.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosGuardian.java index a627e142..f2a9df2a 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosGuardian.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosGuardian.java @@ -28,783 +28,795 @@ import java.util.List; */ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolution.ChaosGuardian - private Entity target; + private Entity target; - /**The spawn coordinates of this dragon*/ - public int homeX = 0; - public int homeY = -1; - public int homeZ = 0; - public boolean homeSet = false; + /** + * The spawn coordinates of this dragon + */ + public int homeX = 0; + public int homeY = -1; + public int homeZ = 0; + public boolean homeSet = false; - /**How long until the next attack sequence*/ - private int nextAttackTimer = 100; - /**The current attack. -1 = not attacking*/ - private int attackInProgress = -1; - /**How long until the current attack sequence ends*/ - private int attackTimer = 0; - /**The behaviour before the attack started (used to reset to previous behaviour after charge attacks)*/ - private EnumBehaviour previousBehaviour = EnumBehaviour.ROAMING; - /**How long until a new ignition charge can be fired*/ - private int ignitionChargeTimer = 0; + /** + * How long until the next attack sequence + */ + private int nextAttackTimer = 100; + /** + * The current attack. -1 = not attacking + */ + private int attackInProgress = -1; + /** + * How long until the current attack sequence ends + */ + private int attackTimer = 0; + /** + * The behaviour before the attack started (used to reset to previous behaviour after charge attacks) + */ + private EnumBehaviour previousBehaviour = EnumBehaviour.ROAMING; + /** + * How long until a new ignition charge can be fired + */ + private int ignitionChargeTimer = 0; - /**A list of all Chaos Crystals in range*/ - public List crystals = null; - /**Number of crystals that are still active*/ - public int activeCrystals = 0; + /** + * A list of all Chaos Crystals in range + */ + public List crystals = null; + /** + * Number of crystals that are still active + */ + public int activeCrystals = 0; - public EntityChaosCrystal healingChaosCrystal; -// public int connectedCrystalID = -1; - public int crystalX = 0; - public int crystalY = -1; - public int crystalZ = 0; + public EntityChaosCrystal healingChaosCrystal; + // public int connectedCrystalID = -1; + public int crystalX = 0; + public int crystalY = -1; + public int crystalZ = 0; - private static final int ATTACK_FIREBALL_CHARGE = 0; - private static final int ATTACK_FIREBALL_CHASER = 1; - private static final int ATTACK_ENERGY_CHASER = 2; - private static final int ATTACK_CHAOS_CHASER = 3; - private static final int ATTACK_TELEPORT = 4; + private static final int ATTACK_FIREBALL_CHARGE = 0; + private static final int ATTACK_FIREBALL_CHASER = 1; + private static final int ATTACK_ENERGY_CHASER = 2; + private static final int ATTACK_CHAOS_CHASER = 3; + private static final int ATTACK_TELEPORT = 4; - public float circlePosition = 0; - public float circleDirection = 1; + public float circlePosition = 0; + public float circleDirection = 1; - public EnumBehaviour behaviour = EnumBehaviour.ROAMING; + public EnumBehaviour behaviour = EnumBehaviour.ROAMING; - public EntityChaosGuardian(World par1World) { - super(par1World); - } + public EntityChaosGuardian(World par1World) { + super(par1World); + } - @Override - protected void entityInit() { - super.entityInit(); + @Override + protected void entityInit() { + super.entityInit(); // dataWatcher.addObject(20, connectedCrystalID); - dataWatcher.addObject(21, crystalX); - dataWatcher.addObject(22, crystalY); - dataWatcher.addObject(23, crystalZ); - } + dataWatcher.addObject(21, crystalX); + dataWatcher.addObject(22, crystalY); + dataWatcher.addObject(23, crystalZ); + } - @Override - public boolean isNoDespawnRequired() { - return true; - } + @Override + public boolean isNoDespawnRequired() { + return true; + } - @Override - protected void applyEntityAttributes() { - super.applyEntityAttributes(); - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(2000); - } + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(2000); + } - @Override - public void onLivingUpdate() { - //Set home position when spawned - if (!homeSet) { - homeX = (int) posX; - homeY = (int) posY; - homeZ = (int) posZ; + @Override + public void onLivingUpdate() { + //Set home position when spawned + if (!homeSet) { + homeX = (int) posX; + homeY = (int) posY; + homeZ = (int) posZ; - targetX = homeX; - targetZ = homeZ; - homeSet = true; - } - if (crystals == null) updateCrystals(); + targetX = homeX; + targetZ = homeZ; + homeSet = true; + } + if (crystals == null) updateCrystals(); - float f; - float f1; - float moveSpeedMultiplier = behaviour.dragonSpeed; + float f; + float f1; + float moveSpeedMultiplier = behaviour.dragonSpeed; - if (this.worldObj.isRemote) { + if (this.worldObj.isRemote) { // connectedCrystalID = dataWatcher.getWatchableObjectInt(20); - crystalX = dataWatcher.getWatchableObjectInt(21); - crystalY = dataWatcher.getWatchableObjectInt(22); - crystalZ = dataWatcher.getWatchableObjectInt(23); + crystalX = dataWatcher.getWatchableObjectInt(21); + crystalY = dataWatcher.getWatchableObjectInt(22); + crystalZ = dataWatcher.getWatchableObjectInt(23); // if (ticksExisted % 10 == 0 && connectedCrystalID != -1 && worldObj.getEntityByID(connectedCrystalID) instanceof EntityChaosCrystal) healingChaosCrystal = (EntityChaosCrystal)worldObj.getEntityByID(connectedCrystalID); // else if (connectedCrystalID == -1 && healingChaosCrystal != null) healingChaosCrystal = null; - f = MathHelper.cos(this.animTime * (float) Math.PI * 2.0F); - f1 = MathHelper.cos(this.prevAnimTime * (float) Math.PI * 2.0F); + f = MathHelper.cos(this.animTime * (float) Math.PI * 2.0F); + f1 = MathHelper.cos(this.prevAnimTime * (float) Math.PI * 2.0F); - if (f1 <= -0.3F && f >= -0.3F) { - if (deathTicks <= 0) this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.enderdragon.wings", 5.0F, 0.8F + this.rand.nextFloat() * 0.3F, false); - } - } + if (f1 <= -0.3F && f >= -0.3F) { + if (deathTicks <= 0) + this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.enderdragon.wings", 5.0F, 0.8F + this.rand.nextFloat() * 0.3F, false); + } + } - this.prevAnimTime = this.animTime; - float f2; + this.prevAnimTime = this.animTime; + float f2; - if (!worldObj.isRemote) { + if (!worldObj.isRemote) { // dataWatcher.updateObject(20, connectedCrystalID); - dataWatcher.updateObject(21, crystalX); - dataWatcher.updateObject(22, crystalY); - dataWatcher.updateObject(23, crystalZ); - updateTarget(); + dataWatcher.updateObject(21, crystalX); + dataWatcher.updateObject(22, crystalY); + dataWatcher.updateObject(23, crystalZ); + updateTarget(); - if (worldObj.getClosestPlayer(posX, posY, posZ, 500) == null && getDistance(homeX, homeY, homeZ) < 100) DragonChunkLoader.stopLoading(this); - else { - if (getHealth() > 0) DragonChunkLoader.updateLoaded(this); - } + if (worldObj.getClosestPlayer(posX, posY, posZ, 500) == null && getDistance(homeX, homeY, homeZ) < 100) + DragonChunkLoader.stopLoading(this); + else { + if (getHealth() > 0) DragonChunkLoader.updateLoaded(this); + } - if (deathTicks > 0) DragonChunkLoader.stopLoading(this); + if (deathTicks > 0) DragonChunkLoader.stopLoading(this); - customAIUpdate(); - if (behaviour == EnumBehaviour.FIREBOMB && Utills.getDistanceAtoB(posX, posY, posZ, homeX, homeY + 30, homeZ) <= 3) moveSpeedMultiplier = 0; - } + customAIUpdate(); + if (behaviour == EnumBehaviour.FIREBOMB && Utills.getDistanceAtoB(posX, posY, posZ, homeX, homeY + 30, homeZ) <= 3) + moveSpeedMultiplier = 0; + } - if (this.getHealth() <= 0.0F) { - behaviour = EnumBehaviour.DEAD; - f = (this.rand.nextFloat() - 0.5F) * 8.0F; - f1 = (this.rand.nextFloat() - 0.5F) * 4.0F; - f2 = (this.rand.nextFloat() - 0.5F) * 8.0F; - this.worldObj.spawnParticle("largeexplode", this.posX + (double) f, this.posY + 2.0D + (double) f1, this.posZ + (double) f2, 0.0D, 0.0D, 0.0D); - } - { - this.updateDragonEnderCrystal(); - f = 0.2F / (MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 10.0F + 1.0F); - f *= moveSpeedMultiplier == 0 ? 1 : moveSpeedMultiplier; - f *= (float) Math.pow(2.0D, this.motionY); + if (this.getHealth() <= 0.0F) { + behaviour = EnumBehaviour.DEAD; + f = (this.rand.nextFloat() - 0.5F) * 8.0F; + f1 = (this.rand.nextFloat() - 0.5F) * 4.0F; + f2 = (this.rand.nextFloat() - 0.5F) * 8.0F; + this.worldObj.spawnParticle("largeexplode", this.posX + (double) f, this.posY + 2.0D + (double) f1, this.posZ + (double) f2, 0.0D, 0.0D, 0.0D); + } + { + this.updateDragonEnderCrystal(); + f = 0.2F / (MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 10.0F + 1.0F); + f *= moveSpeedMultiplier == 0 ? 1 : moveSpeedMultiplier; + f *= (float) Math.pow(2.0D, this.motionY); - if (this.slowed) { - this.animTime += f * 0.5F; - } else { - this.animTime += f; - } + if (this.slowed) { + this.animTime += f * 0.5F; + } else { + this.animTime += f; + } - this.rotationYaw = MathHelper.wrapAngleTo180_float(this.rotationYaw); + this.rotationYaw = MathHelper.wrapAngleTo180_float(this.rotationYaw); - if (this.ringBufferIndex < 0) { - for (int i = 0; i < this.ringBuffer.length; ++i) { - this.ringBuffer[i][0] = (double) this.rotationYaw; - this.ringBuffer[i][1] = this.posY; - } - } + if (this.ringBufferIndex < 0) { + for (int i = 0; i < this.ringBuffer.length; ++i) { + this.ringBuffer[i][0] = (double) this.rotationYaw; + this.ringBuffer[i][1] = this.posY; + } + } - if (++this.ringBufferIndex == this.ringBuffer.length) { - this.ringBufferIndex = 0; - } + if (++this.ringBufferIndex == this.ringBuffer.length) { + this.ringBufferIndex = 0; + } - this.ringBuffer[this.ringBufferIndex][0] = (double) this.rotationYaw; - this.ringBuffer[this.ringBufferIndex][1] = this.posY; - double d0; - double d1; - double d2; - double d10; - float f12; + this.ringBuffer[this.ringBufferIndex][0] = (double) this.rotationYaw; + this.ringBuffer[this.ringBufferIndex][1] = this.posY; + double d0; + double d1; + double d2; + double d10; + float f12; - if (this.worldObj.isRemote) { - if (this.newPosRotationIncrements > 0) { - d10 = this.posX + (this.newPosX - this.posX) / (double) this.newPosRotationIncrements; - d0 = this.posY + (this.newPosY - this.posY) / (double) this.newPosRotationIncrements; - d1 = this.posZ + (this.newPosZ - this.posZ) / (double) this.newPosRotationIncrements; - d2 = MathHelper.wrapAngleTo180_double(this.newRotationYaw - (double) this.rotationYaw); - this.rotationYaw = (float) ((double) this.rotationYaw + d2 / (double) this.newPosRotationIncrements); - this.rotationPitch = (float) ((double) this.rotationPitch + (this.newRotationPitch - (double) this.rotationPitch) / (double) this.newPosRotationIncrements); - --this.newPosRotationIncrements; - this.setPosition(d10, d0, d1); - this.setRotation(this.rotationYaw, this.rotationPitch); - } - } else { + if (this.worldObj.isRemote) { + if (this.newPosRotationIncrements > 0) { + d10 = this.posX + (this.newPosX - this.posX) / (double) this.newPosRotationIncrements; + d0 = this.posY + (this.newPosY - this.posY) / (double) this.newPosRotationIncrements; + d1 = this.posZ + (this.newPosZ - this.posZ) / (double) this.newPosRotationIncrements; + d2 = MathHelper.wrapAngleTo180_double(this.newRotationYaw - (double) this.rotationYaw); + this.rotationYaw = (float) ((double) this.rotationYaw + d2 / (double) this.newPosRotationIncrements); + this.rotationPitch = (float) ((double) this.rotationPitch + (this.newRotationPitch - (double) this.rotationPitch) / (double) this.newPosRotationIncrements); + --this.newPosRotationIncrements; + this.setPosition(d10, d0, d1); + this.setRotation(this.rotationYaw, this.rotationPitch); + } + } else { - d10 = this.targetX - this.posX; - d0 = this.targetY - this.posY; - d1 = this.targetZ - this.posZ; - d2 = d10 * d10 + d0 * d0 + d1 * d1; + d10 = this.targetX - this.posX; + d0 = this.targetY - this.posY; + d1 = this.targetZ - this.posZ; + d2 = d10 * d10 + d0 * d0 + d1 * d1; - if (this.target != null) { - if (behaviour == EnumBehaviour.CIRCLE_PLAYER){ - this.targetX = this.target.posX + (int)(Math.cos(circlePosition) * 60); - this.targetZ = this.target.posZ + (int)(Math.sin(circlePosition) * 60); - moveSpeedMultiplier = 1F + Math.min(((float) Utills.getDistanceAtoB(targetX, targetZ, posX, posZ) / 50) * 3F, 3F); - }else { - this.targetX = this.target.posX; - this.targetZ = this.target.posZ; - } + if (this.target != null) { + if (behaviour == EnumBehaviour.CIRCLE_PLAYER) { + this.targetX = this.target.posX + (int) (Math.cos(circlePosition) * 60); + this.targetZ = this.target.posZ + (int) (Math.sin(circlePosition) * 60); + moveSpeedMultiplier = 1F + Math.min(((float) Utills.getDistanceAtoB(targetX, targetZ, posX, posZ) / 50) * 3F, 3F); + } else { + this.targetX = this.target.posX; + this.targetZ = this.target.posZ; + } - double d3 = this.targetX - this.posX; - double d5 = this.targetZ - this.posZ; - double d7 = Math.sqrt(d3 * d3 + d5 * d5); - double d8 = 0.4000000059604645D + d7 / 80.0D - 1.0D; + double d3 = this.targetX - this.posX; + double d5 = this.targetZ - this.posZ; + double d7 = Math.sqrt(d3 * d3 + d5 * d5); + double d8 = 0.4000000059604645D + d7 / 80.0D - 1.0D; - if (d8 > 10.0D) { - d8 = 10.0D; - } + if (d8 > 10.0D) { + d8 = 10.0D; + } - this.targetY = this.target.boundingBox.minY + d8 + (behaviour == EnumBehaviour.CIRCLE_PLAYER ? 25 : 0); - } else if (behaviour != EnumBehaviour.FIREBOMB){ - this.targetX += this.rand.nextGaussian() * 2.0D; - this.targetZ += this.rand.nextGaussian() * 2.0D; - } + this.targetY = this.target.boundingBox.minY + d8 + (behaviour == EnumBehaviour.CIRCLE_PLAYER ? 25 : 0); + } else if (behaviour != EnumBehaviour.FIREBOMB) { + this.targetX += this.rand.nextGaussian() * 2.0D; + this.targetZ += this.rand.nextGaussian() * 2.0D; + } - if (this.forceNewTarget || d2 < 100.0D || d2 > 22500.0D || this.isCollidedHorizontally || this.isCollidedVertically) this.setNewTarget(); + if (this.forceNewTarget || d2 < 100.0D || d2 > 22500.0D || this.isCollidedHorizontally || this.isCollidedVertically) + this.setNewTarget(); - d0 /= (double) MathHelper.sqrt_double(d10 * d10 + d1 * d1); - //if (isUber) f12 = 1.0F;//Verticle Motion Speed - //else - f12 = 0.6F; + d0 /= (double) MathHelper.sqrt_double(d10 * d10 + d1 * d1); + //if (isUber) f12 = 1.0F;//Verticle Motion Speed + //else + f12 = 0.6F; - if (d0 < (double) (-f12)) { - d0 = (double) (-f12); - } + if (d0 < (double) (-f12)) { + d0 = (double) (-f12); + } - if (d0 > (double) f12) { - d0 = (double) f12; - } + if (d0 > (double) f12) { + d0 = (double) f12; + } - this.motionY += d0 * 0.10000000149011612D; - this.rotationYaw = MathHelper.wrapAngleTo180_float(this.rotationYaw); - double d4 = 180.0D - Math.atan2(d10, d1) * 180.0D / Math.PI; - double d6 = MathHelper.wrapAngleTo180_double(d4 - (double) this.rotationYaw); + this.motionY += d0 * 0.10000000149011612D; + this.rotationYaw = MathHelper.wrapAngleTo180_float(this.rotationYaw); + double d4 = 180.0D - Math.atan2(d10, d1) * 180.0D / Math.PI; + double d6 = MathHelper.wrapAngleTo180_double(d4 - (double) this.rotationYaw); - if (d6 > 50.0D) { - d6 = 50.0D; - } + if (d6 > 50.0D) { + d6 = 50.0D; + } - if (d6 < -50.0D) { - d6 = -50.0D; - } + if (d6 < -50.0D) { + d6 = -50.0D; + } - Vec3 vec3 = Vec3.createVectorHelper(this.targetX - this.posX, this.targetY - this.posY, this.targetZ - this.posZ).normalize(); - Vec3 vec32 = Vec3.createVectorHelper((double) MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F), this.motionY, (double) (-MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F))).normalize(); - float f5 = (float) (vec32.dotProduct(vec3) + 0.5D) / 1.5F; + Vec3 vec3 = Vec3.createVectorHelper(this.targetX - this.posX, this.targetY - this.posY, this.targetZ - this.posZ).normalize(); + Vec3 vec32 = Vec3.createVectorHelper((double) MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F), this.motionY, (double) (-MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F))).normalize(); + float f5 = (float) (vec32.dotProduct(vec3) + 0.5D) / 1.5F; - if (f5 < 0.0F) { - f5 = 0.0F; - } + if (f5 < 0.0F) { + f5 = 0.0F; + } - this.randomYawVelocity *= 0.8F; - float f6 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0F + 1.0F; - double d9 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0D + 1.0D; + this.randomYawVelocity *= 0.8F; + float f6 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0F + 1.0F; + double d9 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0D + 1.0D; - if (d9 > 40.0D) { - d9 = 40.0D; - } + if (d9 > 40.0D) { + d9 = 40.0D; + } - this.randomYawVelocity = (float) ((double) this.randomYawVelocity + d6 * (0.699999988079071D / d9 / (double) f6)); - this.rotationYaw += this.randomYawVelocity * 0.1F; - float f7 = (float) (2.0D / (d9 + 1.0D)); - float f8 = 0.06F; - this.moveFlying(0.0F, -1.0F, f8 * (f5 * f7 + (1.0F - f7))); + this.randomYawVelocity = (float) ((double) this.randomYawVelocity + d6 * (0.699999988079071D / d9 / (double) f6)); + this.rotationYaw += this.randomYawVelocity * 0.1F; + float f7 = (float) (2.0D / (d9 + 1.0D)); + float f8 = 0.06F; + this.moveFlying(0.0F, -1.0F, f8 * (f5 * f7 + (1.0F - f7))); - if (this.slowed) { - this.moveEntity(this.motionX * 0.800000011920929D * moveSpeedMultiplier, this.motionY * 0.800000011920929D * moveSpeedMultiplier, this.motionZ * 0.800000011920929D * moveSpeedMultiplier); - } - else { - this.moveEntity(this.motionX * moveSpeedMultiplier, this.motionY * moveSpeedMultiplier, this.motionZ * moveSpeedMultiplier); - } + if (this.slowed) { + this.moveEntity(this.motionX * 0.800000011920929D * moveSpeedMultiplier, this.motionY * 0.800000011920929D * moveSpeedMultiplier, this.motionZ * 0.800000011920929D * moveSpeedMultiplier); + } else { + this.moveEntity(this.motionX * moveSpeedMultiplier, this.motionY * moveSpeedMultiplier, this.motionZ * moveSpeedMultiplier); + } - Vec3 vec31 = Vec3.createVectorHelper(this.motionX, this.motionY, this.motionZ).normalize(); - float f9 = (float) (vec31.dotProduct(vec32) + 1.0D) / 2.0F; - f9 = 0.8F + 0.15F * f9; - this.motionX *= (double) f9; - this.motionZ *= (double) f9; - this.motionY *= 0.9100000262260437D; - } + Vec3 vec31 = Vec3.createVectorHelper(this.motionX, this.motionY, this.motionZ).normalize(); + float f9 = (float) (vec31.dotProduct(vec32) + 1.0D) / 2.0F; + f9 = 0.8F + 0.15F * f9; + this.motionX *= (double) f9; + this.motionZ *= (double) f9; + this.motionY *= 0.9100000262260437D; + } - this.renderYawOffset = this.rotationYaw; - this.dragonPartHead.width = this.dragonPartHead.height = 3.0F; - this.dragonPartTail1.width = this.dragonPartTail1.height = 2.0F; - this.dragonPartTail2.width = this.dragonPartTail2.height = 2.0F; - this.dragonPartTail3.width = this.dragonPartTail3.height = 2.0F; - this.dragonPartBody.height = 3.0F; - this.dragonPartBody.width = 5.0F; - this.dragonPartWing1.height = 2.0F; - this.dragonPartWing1.width = 4.0F; - this.dragonPartWing2.height = 3.0F; - this.dragonPartWing2.width = 4.0F; - f1 = (float) (this.getMovementOffsets(5, 1.0F)[1] - this.getMovementOffsets(10, 1.0F)[1]) * 10.0F / 180.0F * (float) Math.PI; - f2 = MathHelper.cos(f1); - float f10 = -MathHelper.sin(f1); - float f3 = this.rotationYaw * (float) Math.PI / 180.0F; - float f11 = MathHelper.sin(f3); - float f4 = MathHelper.cos(f3); - this.dragonPartBody.onUpdate(); - this.dragonPartBody.setLocationAndAngles(this.posX + (double) (f11 * 0.5F), this.posY, this.posZ - (double) (f4 * 0.5F), 0.0F, 0.0F); - this.dragonPartWing1.onUpdate(); - this.dragonPartWing1.setLocationAndAngles(this.posX + (double) (f4 * 4.5F), this.posY + 2.0D, this.posZ + (double) (f11 * 4.5F), 0.0F, 0.0F); - this.dragonPartWing2.onUpdate(); - this.dragonPartWing2.setLocationAndAngles(this.posX - (double) (f4 * 4.5F), this.posY + 2.0D, this.posZ - (double) (f11 * 4.5F), 0.0F, 0.0F); + this.renderYawOffset = this.rotationYaw; + this.dragonPartHead.width = this.dragonPartHead.height = 3.0F; + this.dragonPartTail1.width = this.dragonPartTail1.height = 2.0F; + this.dragonPartTail2.width = this.dragonPartTail2.height = 2.0F; + this.dragonPartTail3.width = this.dragonPartTail3.height = 2.0F; + this.dragonPartBody.height = 3.0F; + this.dragonPartBody.width = 5.0F; + this.dragonPartWing1.height = 2.0F; + this.dragonPartWing1.width = 4.0F; + this.dragonPartWing2.height = 3.0F; + this.dragonPartWing2.width = 4.0F; + f1 = (float) (this.getMovementOffsets(5, 1.0F)[1] - this.getMovementOffsets(10, 1.0F)[1]) * 10.0F / 180.0F * (float) Math.PI; + f2 = MathHelper.cos(f1); + float f10 = -MathHelper.sin(f1); + float f3 = this.rotationYaw * (float) Math.PI / 180.0F; + float f11 = MathHelper.sin(f3); + float f4 = MathHelper.cos(f3); + this.dragonPartBody.onUpdate(); + this.dragonPartBody.setLocationAndAngles(this.posX + (double) (f11 * 0.5F), this.posY, this.posZ - (double) (f4 * 0.5F), 0.0F, 0.0F); + this.dragonPartWing1.onUpdate(); + this.dragonPartWing1.setLocationAndAngles(this.posX + (double) (f4 * 4.5F), this.posY + 2.0D, this.posZ + (double) (f11 * 4.5F), 0.0F, 0.0F); + this.dragonPartWing2.onUpdate(); + this.dragonPartWing2.setLocationAndAngles(this.posX - (double) (f4 * 4.5F), this.posY + 2.0D, this.posZ - (double) (f11 * 4.5F), 0.0F, 0.0F); - if (!this.worldObj.isRemote && this.hurtTime == 0) { - this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing1.boundingBox.expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D))); - this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing2.boundingBox.expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D))); - this.attackEntitiesInList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartHead.boundingBox.expand(1.0D, 1.0D, 1.0D))); - } + if (!this.worldObj.isRemote && this.hurtTime == 0) { + this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing1.boundingBox.expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D))); + this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing2.boundingBox.expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D))); + this.attackEntitiesInList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartHead.boundingBox.expand(1.0D, 1.0D, 1.0D))); + } - double[] adouble1 = this.getMovementOffsets(5, 1.0F); - double[] adouble = this.getMovementOffsets(0, 1.0F); - f12 = MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F - this.randomYawVelocity * 0.01F); - float f13 = MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F - this.randomYawVelocity * 0.01F); - this.dragonPartHead.onUpdate(); - this.dragonPartHead.setLocationAndAngles(this.posX + (double) (f12 * 5.5F * f2), this.posY + (adouble[1] - adouble1[1]) * 1.0D + (double) (f10 * 5.5F), this.posZ - (double) (f13 * 5.5F * f2), 0.0F, 0.0F); + double[] adouble1 = this.getMovementOffsets(5, 1.0F); + double[] adouble = this.getMovementOffsets(0, 1.0F); + f12 = MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F - this.randomYawVelocity * 0.01F); + float f13 = MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F - this.randomYawVelocity * 0.01F); + this.dragonPartHead.onUpdate(); + this.dragonPartHead.setLocationAndAngles(this.posX + (double) (f12 * 5.5F * f2), this.posY + (adouble[1] - adouble1[1]) * 1.0D + (double) (f10 * 5.5F), this.posZ - (double) (f13 * 5.5F * f2), 0.0F, 0.0F); - for (int j = 0; j < 3; ++j) { - EntityDragonPart entitydragonpart = null; + for (int j = 0; j < 3; ++j) { + EntityDragonPart entitydragonpart = null; - if (j == 0) { - entitydragonpart = this.dragonPartTail1; - } + if (j == 0) { + entitydragonpart = this.dragonPartTail1; + } - if (j == 1) { - entitydragonpart = this.dragonPartTail2; - } + if (j == 1) { + entitydragonpart = this.dragonPartTail2; + } - if (j == 2) { - entitydragonpart = this.dragonPartTail3; - } + if (j == 2) { + entitydragonpart = this.dragonPartTail3; + } - double[] adouble2 = this.getMovementOffsets(12 + j * 2, 1.0F); - float f14 = this.rotationYaw * (float) Math.PI / 180.0F + this.simplifyAngle(adouble2[0] - adouble1[0]) * (float) Math.PI / 180.0F * 1.0F; - float f15 = MathHelper.sin(f14); - float f16 = MathHelper.cos(f14); - float f17 = 1.5F; - float f18 = (float) (j + 1) * 2.0F; - entitydragonpart.onUpdate(); - entitydragonpart.setLocationAndAngles(this.posX - (double) ((f11 * f17 + f15 * f18) * f2), this.posY + (adouble2[1] - adouble1[1]) * 1.0D - (double) ((f18 + f17) * f10) + 1.5D, this.posZ + (double) ((f4 * f17 + f16 * f18) * f2), 0.0F, 0.0F); - } + double[] adouble2 = this.getMovementOffsets(12 + j * 2, 1.0F); + float f14 = this.rotationYaw * (float) Math.PI / 180.0F + this.simplifyAngle(adouble2[0] - adouble1[0]) * (float) Math.PI / 180.0F * 1.0F; + float f15 = MathHelper.sin(f14); + float f16 = MathHelper.cos(f14); + float f17 = 1.5F; + float f18 = (float) (j + 1) * 2.0F; + entitydragonpart.onUpdate(); + entitydragonpart.setLocationAndAngles(this.posX - (double) ((f11 * f17 + f15 * f18) * f2), this.posY + (adouble2[1] - adouble1[1]) * 1.0D - (double) ((f18 + f17) * f10) + 1.5D, this.posZ + (double) ((f4 * f17 + f16 * f18) * f2), 0.0F, 0.0F); + } - if (!this.worldObj.isRemote) { - this.slowed = this.destroyBlocksInAABB(this.dragonPartHead.boundingBox) | this.destroyBlocksInAABB(this.dragonPartBody.boundingBox); - } - } + if (!this.worldObj.isRemote) { + this.slowed = this.destroyBlocksInAABB(this.dragonPartHead.boundingBox) | this.destroyBlocksInAABB(this.dragonPartBody.boundingBox); + } + } - } + } - public void onCrystalTargeted(EntityPlayer player, boolean destroyed) { - if (behaviour == EnumBehaviour.DEAD) return; - target = player; - if (destroyed || behaviour == EnumBehaviour.LOW_HEALTH_STRATEGY) - { - attackInProgress = ATTACK_CHAOS_CHASER; - behaviour = EnumBehaviour.CHARGING; - nextAttackTimer = 20; - attackTimer = 100; - updateCrystals(); - }else - { - attackInProgress = ATTACK_FIREBALL_CHARGE; - previousBehaviour = behaviour; - behaviour = EnumBehaviour.CHARGING; - nextAttackTimer = 20; - attackTimer = 1000; - } - if (deathTicks <= 0) this.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "mob.enderdragon.growl", 20.0F, 0.8F + this.rand.nextFloat() * 0.3F); - } + public void onCrystalTargeted(EntityPlayer player, boolean destroyed) { + if (behaviour == EnumBehaviour.DEAD) return; + target = player; + if (destroyed || behaviour == EnumBehaviour.LOW_HEALTH_STRATEGY) { + attackInProgress = ATTACK_CHAOS_CHASER; + behaviour = EnumBehaviour.CHARGING; + nextAttackTimer = 20; + attackTimer = 100; + updateCrystals(); + } else { + attackInProgress = ATTACK_FIREBALL_CHARGE; + previousBehaviour = behaviour; + behaviour = EnumBehaviour.CHARGING; + nextAttackTimer = 20; + attackTimer = 1000; + } + if (deathTicks <= 0) + this.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "mob.enderdragon.growl", 20.0F, 0.8F + this.rand.nextFloat() * 0.3F); + } - public void updateCrystals(){ - if (crystals == null) crystals = new ArrayList(); - List list = worldObj.getEntitiesWithinAABB(EntityChaosCrystal.class, AxisAlignedBB.getBoundingBox(homeX, homeY, homeZ, homeX, homeY, homeZ).expand(200, 200, 200)); - activeCrystals = 0; - for (EntityChaosCrystal crystal : list) { - if (!crystals.contains(crystal)) crystals.add(crystal); - if (crystal.isAlive()) activeCrystals++; - } - } + public void updateCrystals() { + if (crystals == null) crystals = new ArrayList(); + List list = worldObj.getEntitiesWithinAABB(EntityChaosCrystal.class, AxisAlignedBB.getBoundingBox(homeX, homeY, homeZ, homeX, homeY, homeZ).expand(200, 200, 200)); + activeCrystals = 0; + for (EntityChaosCrystal crystal : list) { + if (!crystals.contains(crystal)) crystals.add(crystal); + if (crystal.isAlive()) activeCrystals++; + } + } - private void customAIUpdate(){ + private void customAIUpdate() { - if (getHealth() > 0 && getHealth() < getMaxHealth() * 0.2F) behaviour = EnumBehaviour.LOW_HEALTH_STRATEGY; + if (getHealth() > 0 && getHealth() < getMaxHealth() * 0.2F) behaviour = EnumBehaviour.LOW_HEALTH_STRATEGY; - if (ticksExisted % 200 == 0) { - crystals = null; - activeCrystals = 0; - crystalY = -1; + if (ticksExisted % 200 == 0) { + crystals = null; + activeCrystals = 0; + crystalY = -1; // connectedCrystalID = -1; - healingChaosCrystal = null; - updateCrystals(); - } + healingChaosCrystal = null; + updateCrystals(); + } - switch (behaviour){ - case ROAMING: - if (worldObj.getClosestVulnerablePlayer(homeX, homeY, homeZ, 200) != null) selectNewBehaviour(); - break; + switch (behaviour) { + case ROAMING: + if (worldObj.getClosestVulnerablePlayer(homeX, homeY, homeZ, 200) != null) selectNewBehaviour(); + break; - case GO_HOME: - if (Utills.getDistanceAtoB(posX, posZ, homeX, homeZ) < 70 ) selectNewBehaviour(); - break; + case GO_HOME: + if (Utills.getDistanceAtoB(posX, posZ, homeX, homeZ) < 70) selectNewBehaviour(); + break; - case GUARDING: - break; + case GUARDING: + break; - case CHARGING: - if (Utills.getDistanceAtoB(posX, posZ, homeX, homeZ) > 300) behaviour = EnumBehaviour.GO_HOME; - break; + case CHARGING: + if (Utills.getDistanceAtoB(posX, posZ, homeX, homeZ) > 300) behaviour = EnumBehaviour.GO_HOME; + break; - case CIRCLE_PLAYER: - circlePosition += (0.02F * circleDirection); - if (Utills.getDistanceAtoB(posX, posZ, homeX, homeZ) > 300 || posY > 250) behaviour = EnumBehaviour.GO_HOME; - break; + case CIRCLE_PLAYER: + circlePosition += (0.02F * circleDirection); + if (Utills.getDistanceAtoB(posX, posZ, homeX, homeZ) > 300 || posY > 250) + behaviour = EnumBehaviour.GO_HOME; + break; - case LOW_HEALTH_STRATEGY: - if (worldObj.getClosestVulnerablePlayer(targetX, targetY, targetZ, 60) != null && attackInProgress != ATTACK_TELEPORT){ - int escape = 0; - boolean flag = false; - while (!flag && escape < 50){ - targetX = homeX + ((rand.nextDouble() - 0.5D) * 220D); - targetY = homeY + 20 + rand.nextDouble() * 20D; - targetZ = homeZ + ((rand.nextDouble() - 0.5D) * 220D); - if (worldObj.getClosestVulnerablePlayer(targetX, targetY, targetZ, 60D) == null) flag = true; - escape++; - } - target = null; - } + case LOW_HEALTH_STRATEGY: + if (worldObj.getClosestVulnerablePlayer(targetX, targetY, targetZ, 60) != null && attackInProgress != ATTACK_TELEPORT) { + int escape = 0; + boolean flag = false; + while (!flag && escape < 50) { + targetX = homeX + ((rand.nextDouble() - 0.5D) * 220D); + targetY = homeY + 20 + rand.nextDouble() * 20D; + targetZ = homeZ + ((rand.nextDouble() - 0.5D) * 220D); + if (worldObj.getClosestVulnerablePlayer(targetX, targetY, targetZ, 60D) == null) flag = true; + escape++; + } + target = null; + } - break; + break; - case DEAD: - target = null; - targetX = homeX; - targetY = homeY; - targetZ = homeZ; - break; - } + case DEAD: + target = null; + targetX = homeX; + targetY = homeY; + targetZ = homeZ; + break; + } //ignitionChargeTimer = 10; - if (behaviour == EnumBehaviour.DEAD) return; + if (behaviour == EnumBehaviour.DEAD) return; - if (ticksExisted % 1000 == 0 && rand.nextBoolean()) selectNewBehaviour(); + if (ticksExisted % 1000 == 0 && rand.nextBoolean()) selectNewBehaviour(); - if (ignitionChargeTimer > 1 || (ignitionChargeTimer == 1 && ticksExisted % 20 == 0) && !ConfigHandler.disableGuardianCrystalRespawn)ignitionChargeTimer--; - if (ignitionChargeTimer <= 0 && !worldObj.isRemote){ - if ((ticksExisted - 19) % 20 == 0) ignitionChargeTimer = (behaviour == EnumBehaviour.LOW_HEALTH_STRATEGY ? 1000 : 2000) + rand.nextInt(600); + if (ignitionChargeTimer > 1 || (ignitionChargeTimer == 1 && ticksExisted % 20 == 0) && !ConfigHandler.disableGuardianCrystalRespawn) + ignitionChargeTimer--; + if (ignitionChargeTimer <= 0 && !worldObj.isRemote) { + if ((ticksExisted - 19) % 20 == 0) + ignitionChargeTimer = (behaviour == EnumBehaviour.LOW_HEALTH_STRATEGY ? 1000 : 2000) + rand.nextInt(600); - if (activeCrystals < crystals.size() && ticksExisted % 10 == 0){ - EntityChaosCrystal closest = null; - for (EntityChaosCrystal crystal : crystals) if (!crystal.isAlive() && (closest == null || getDistanceToEntity(crystal) < getDistanceToEntity(closest))) closest = crystal; - if (closest != null){ - EntityDragonProjectile charge = new EntityDragonProjectile(worldObj, EntityDragonProjectile.IGNITION_CHARGE, closest, 0, this); - charge.setPosition(dragonPartHead.posX + Math.cos((rotationYaw - 90) / 180.0F * (float)Math.PI) * 2, dragonPartHead.posY + 1.5, dragonPartHead.posZ + Math.sin((rotationYaw - 90) / 180.0F * (float)Math.PI) * 2); - worldObj.spawnEntityInWorld(charge); - } - } - } + if (activeCrystals < crystals.size() && ticksExisted % 10 == 0) { + EntityChaosCrystal closest = null; + for (EntityChaosCrystal crystal : crystals) + if (!crystal.isAlive() && (closest == null || getDistanceToEntity(crystal) < getDistanceToEntity(closest))) + closest = crystal; + if (closest != null) { + EntityDragonProjectile charge = new EntityDragonProjectile(worldObj, EntityDragonProjectile.IGNITION_CHARGE, closest, 0, this); + charge.setPosition(dragonPartHead.posX + Math.cos((rotationYaw - 90) / 180.0F * (float) Math.PI) * 2, dragonPartHead.posY + 1.5, dragonPartHead.posZ + Math.sin((rotationYaw - 90) / 180.0F * (float) Math.PI) * 2); + worldObj.spawnEntityInWorld(charge); + } + } + } - updateAttack(); - } + updateAttack(); + } - private void updateAttack(){ - if (worldObj.isRemote || behaviour == EnumBehaviour.DEAD) return; + private void updateAttack() { + if (worldObj.isRemote || behaviour == EnumBehaviour.DEAD) return; - if (behaviour == EnumBehaviour.FIREBOMB && Utills.getDistanceAtoB(posX, posY, posZ, homeX, homeY + 30, homeZ) <= 3){ - if (target == null || ticksExisted % 100 == 0) setNewTarget(); - if (target != null){ - double distance = Utills.getDistanceAtoB(target.posX, target.posZ, dragonPartHead.posX, dragonPartHead.posZ); - if (Utills.getDistanceAtoB(target.posX, target.posZ, posX, posZ) < 5) distance *= -1; - float anglePitch = (float)Math.toDegrees(Math.atan2(target.posY - dragonPartHead.posY, distance)) * -1F; - float angleYaw = (float)Math.toDegrees(Math.atan2(target.posX - dragonPartHead.posX, target.posZ - posZ)) * -1F; - rotationPitch = anglePitch; - if (Utills.getDistanceAtoB(target.posX, target.posZ, posX, posZ) > 8) rotationYaw = angleYaw + 180; + if (behaviour == EnumBehaviour.FIREBOMB && Utills.getDistanceAtoB(posX, posY, posZ, homeX, homeY + 30, homeZ) <= 3) { + if (target == null || ticksExisted % 100 == 0) setNewTarget(); + if (target != null) { + double distance = Utills.getDistanceAtoB(target.posX, target.posZ, dragonPartHead.posX, dragonPartHead.posZ); + if (Utills.getDistanceAtoB(target.posX, target.posZ, posX, posZ) < 5) distance *= -1; + float anglePitch = (float) Math.toDegrees(Math.atan2(target.posY - dragonPartHead.posY, distance)) * -1F; + float angleYaw = (float) Math.toDegrees(Math.atan2(target.posX - dragonPartHead.posX, target.posZ - posZ)) * -1F; + rotationPitch = anglePitch; + if (Utills.getDistanceAtoB(target.posX, target.posZ, posX, posZ) > 8) rotationYaw = angleYaw + 180; - if (ticksExisted % 2 == 0) - { - EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.FIREBOMB, target instanceof EntityLivingBase ? (EntityLivingBase) target : null, 5F + (rand.nextFloat() * 8F), this); - projectile.setPosition(dragonPartHead.posX + Math.cos((rotationYaw - 90) / 180.0F * (float)Math.PI) * 2, dragonPartHead.posY + 1.5, dragonPartHead.posZ + Math.sin((rotationYaw - 90) / 180.0F * (float)Math.PI) * 2); - worldObj.spawnEntityInWorld(projectile); - } - } + if (ticksExisted % 2 == 0) { + EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.FIREBOMB, target instanceof EntityLivingBase ? (EntityLivingBase) target : null, 5F + (rand.nextFloat() * 8F), this); + projectile.setPosition(dragonPartHead.posX + Math.cos((rotationYaw - 90) / 180.0F * (float) Math.PI) * 2, dragonPartHead.posY + 1.5, dragonPartHead.posZ + Math.sin((rotationYaw - 90) / 180.0F * (float) Math.PI) * 2); + worldObj.spawnEntityInWorld(projectile); + } + } - } - else if (nextAttackTimer > 0) nextAttackTimer--; - else if (nextAttackTimer == 0){ + } else if (nextAttackTimer > 0) nextAttackTimer--; + else if (nextAttackTimer == 0) { - Entity attackTarget = target; - @SuppressWarnings("unchecked") - List targets = attackTarget == null ? worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(homeX, homeY, homeZ, homeX, homeY, homeZ).expand(100, 100, 100)) : null; + Entity attackTarget = target; + @SuppressWarnings("unchecked") List targets = attackTarget == null ? worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(homeX, homeY, homeZ, homeX, homeY, homeZ).expand(100, 100, 100)) : null; - if (targets != null && targets.size() > 0){ - Iterator i = targets.iterator(); - while (i.hasNext()) { - if (i.next().capabilities.isCreativeMode) i.remove(); - } - } + if (targets != null && targets.size() > 0) { + Iterator i = targets.iterator(); + while (i.hasNext()) { + if (i.next().capabilities.isCreativeMode) i.remove(); + } + } - if (attackTarget == null && targets != null && targets.size() > 0) attackTarget = targets.get(rand.nextInt(targets.size())); - if (attackTarget == null) return; + if (attackTarget == null && targets != null && targets.size() > 0) + attackTarget = targets.get(rand.nextInt(targets.size())); + if (attackTarget == null) return; - //Select an attack - if (attackInProgress == -1){ - selectNewAttack(); - switch (attackInProgress){ - case ATTACK_FIREBALL_CHARGE: { - attackTimer = 90 + rand.nextInt(80); - previousBehaviour = behaviour; - behaviour = EnumBehaviour.CHARGING; - } break; - case ATTACK_FIREBALL_CHASER: attackTimer = 10 + rand.nextInt(80); break; - case ATTACK_ENERGY_CHASER: attackTimer = 10 + rand.nextInt(80); break; - case ATTACK_CHAOS_CHASER: attackTimer = 10 + rand.nextInt(80); break; - case ATTACK_TELEPORT: attackTimer = 90 + rand.nextInt(80); break; - } - } + //Select an attack + if (attackInProgress == -1) { + selectNewAttack(); + switch (attackInProgress) { + case ATTACK_FIREBALL_CHARGE: { + attackTimer = 90 + rand.nextInt(80); + previousBehaviour = behaviour; + behaviour = EnumBehaviour.CHARGING; + } + break; + case ATTACK_FIREBALL_CHASER: + attackTimer = 10 + rand.nextInt(80); + break; + case ATTACK_ENERGY_CHASER: + attackTimer = 10 + rand.nextInt(80); + break; + case ATTACK_CHAOS_CHASER: + attackTimer = 10 + rand.nextInt(80); + break; + case ATTACK_TELEPORT: + attackTimer = 90 + rand.nextInt(80); + break; + } + } - switch (attackInProgress){ - case ATTACK_FIREBALL_CHARGE: - if (target == null && behaviour == EnumBehaviour.CHARGING) target = attackTarget; - if (Utills.getDistanceAtoB(posX, posY, posZ, attackTarget.posX, attackTarget.posY, attackTarget.posZ) > 10) - { - if (attackTimer % 2 == 0) - { - EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.FIREBOMB, attackTarget instanceof EntityLivingBase ? (EntityLivingBase) attackTarget : null, 5F + (rand.nextFloat() * 8F), this); - projectile.setPosition(dragonPartHead.posX, dragonPartHead.posY, dragonPartHead.posZ); - worldObj.spawnEntityInWorld(projectile); - } + switch (attackInProgress) { + case ATTACK_FIREBALL_CHARGE: + if (target == null && behaviour == EnumBehaviour.CHARGING) target = attackTarget; + if (Utills.getDistanceAtoB(posX, posY, posZ, attackTarget.posX, attackTarget.posY, attackTarget.posZ) > 10) { + if (attackTimer % 2 == 0) { + EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.FIREBOMB, attackTarget instanceof EntityLivingBase ? (EntityLivingBase) attackTarget : null, 5F + (rand.nextFloat() * 8F), this); + projectile.setPosition(dragonPartHead.posX, dragonPartHead.posY, dragonPartHead.posZ); + worldObj.spawnEntityInWorld(projectile); + } - double distance = Utills.getDistanceAtoB(attackTarget.posX, attackTarget.posZ, dragonPartHead.posX, dragonPartHead.posZ); - float angle = (float)Math.toDegrees(Math.atan2(attackTarget.posY - dragonPartHead.posY, distance)) * -1F; - rotationPitch = angle; + double distance = Utills.getDistanceAtoB(attackTarget.posX, attackTarget.posZ, dragonPartHead.posX, dragonPartHead.posZ); + float angle = (float) Math.toDegrees(Math.atan2(attackTarget.posY - dragonPartHead.posY, distance)) * -1F; + rotationPitch = angle; - }else attackTimer = 0; - break; - case ATTACK_FIREBALL_CHASER: - if (attackTimer % 10 == 0) { - EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.FIRE_CHASER, attackTarget instanceof EntityLivingBase ? (EntityLivingBase)attackTarget : null, 5F + (rand.nextFloat() * 2F), this); - projectile.setPosition(dragonPartHead.posX, dragonPartHead.posY, dragonPartHead.posZ); - worldObj.spawnEntityInWorld(projectile); - } - break; - case ATTACK_ENERGY_CHASER: - if (attackTimer % 10 == 0) { - EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.ENERGY_CHASER, attackTarget instanceof EntityLivingBase ? (EntityLivingBase)attackTarget : null, 5F + (rand.nextFloat() * 10F), this); - projectile.setPosition(dragonPartHead.posX, dragonPartHead.posY, dragonPartHead.posZ); - worldObj.spawnEntityInWorld(projectile); - } - break; - case ATTACK_CHAOS_CHASER: - if (attackTimer % 10 == 0) { - EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.CHAOS_CHASER, attackTarget instanceof EntityLivingBase ? (EntityLivingBase)attackTarget : null, 5F + (rand.nextFloat() * 10F), this); - projectile.setPosition(dragonPartHead.posX, dragonPartHead.posY, dragonPartHead.posZ); - worldObj.spawnEntityInWorld(projectile); - } - break; - case ATTACK_TELEPORT: - if (target == null) target = worldObj.getClosestVulnerablePlayerToEntity(this, 100); - if (target == null){ - attackInProgress = -1; - return; - } - if (Utills.getDistanceAtoB(posX, posY, posZ, attackTarget.posX, attackTarget.posY, attackTarget.posZ) > 15) - { - if (attackTimer % 2 == 0) - { - EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.TELEPORT, attackTarget instanceof EntityLivingBase ? (EntityLivingBase) attackTarget : null, 5F + (rand.nextFloat() * 8F), this); - projectile.setPosition(dragonPartHead.posX, dragonPartHead.posY, dragonPartHead.posZ); - worldObj.spawnEntityInWorld(projectile); - } + } else attackTimer = 0; + break; + case ATTACK_FIREBALL_CHASER: + if (attackTimer % 10 == 0) { + EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.FIRE_CHASER, attackTarget instanceof EntityLivingBase ? (EntityLivingBase) attackTarget : null, 5F + (rand.nextFloat() * 2F), this); + projectile.setPosition(dragonPartHead.posX, dragonPartHead.posY, dragonPartHead.posZ); + worldObj.spawnEntityInWorld(projectile); + } + break; + case ATTACK_ENERGY_CHASER: + if (attackTimer % 10 == 0) { + EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.ENERGY_CHASER, attackTarget instanceof EntityLivingBase ? (EntityLivingBase) attackTarget : null, 5F + (rand.nextFloat() * 10F), this); + projectile.setPosition(dragonPartHead.posX, dragonPartHead.posY, dragonPartHead.posZ); + worldObj.spawnEntityInWorld(projectile); + } + break; + case ATTACK_CHAOS_CHASER: + if (attackTimer % 10 == 0) { + EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.CHAOS_CHASER, attackTarget instanceof EntityLivingBase ? (EntityLivingBase) attackTarget : null, 5F + (rand.nextFloat() * 10F), this); + projectile.setPosition(dragonPartHead.posX, dragonPartHead.posY, dragonPartHead.posZ); + worldObj.spawnEntityInWorld(projectile); + } + break; + case ATTACK_TELEPORT: + if (target == null) target = worldObj.getClosestVulnerablePlayerToEntity(this, 100); + if (target == null) { + attackInProgress = -1; + return; + } + if (Utills.getDistanceAtoB(posX, posY, posZ, attackTarget.posX, attackTarget.posY, attackTarget.posZ) > 15) { + if (attackTimer % 2 == 0) { + EntityDragonProjectile projectile = new EntityDragonProjectile(worldObj, EntityDragonProjectile.TELEPORT, attackTarget instanceof EntityLivingBase ? (EntityLivingBase) attackTarget : null, 5F + (rand.nextFloat() * 8F), this); + projectile.setPosition(dragonPartHead.posX, dragonPartHead.posY, dragonPartHead.posZ); + worldObj.spawnEntityInWorld(projectile); + } - double distance = Utills.getDistanceAtoB(attackTarget.posX, attackTarget.posZ, dragonPartHead.posX, dragonPartHead.posZ); - float angle = (float)Math.toDegrees(Math.atan2(attackTarget.posY - dragonPartHead.posY, distance)) * -1F; - rotationPitch = angle; + double distance = Utills.getDistanceAtoB(attackTarget.posX, attackTarget.posZ, dragonPartHead.posX, dragonPartHead.posZ); + float angle = (float) Math.toDegrees(Math.atan2(attackTarget.posY - dragonPartHead.posY, distance)) * -1F; + rotationPitch = angle; - }else attackTimer = 0; - break; - } + } else attackTimer = 0; + break; + } - attackTimer--; - if (attackTimer <= -1){ - if (attackInProgress == ATTACK_FIREBALL_CHARGE) behaviour = previousBehaviour; - attackInProgress = -1; - nextAttackTimer = -1; - } - } - else nextAttackTimer = behaviour == EnumBehaviour.LOW_HEALTH_STRATEGY ? 10 + rand.nextInt(50) : 60 + rand.nextInt(200); - } + attackTimer--; + if (attackTimer <= -1) { + if (attackInProgress == ATTACK_FIREBALL_CHARGE) behaviour = previousBehaviour; + attackInProgress = -1; + nextAttackTimer = -1; + } + } else + nextAttackTimer = behaviour == EnumBehaviour.LOW_HEALTH_STRATEGY ? 10 + rand.nextInt(50) : 60 + rand.nextInt(200); + } - private static final WeightedRandom.Item[] weightedAttacks = new WeightedRandom.Item[] { - new WeightedAttack(16, ATTACK_FIREBALL_CHARGE), - new WeightedAttack(14, ATTACK_FIREBALL_CHASER), - new WeightedAttack(12, ATTACK_ENERGY_CHASER), - new WeightedAttack(10, ATTACK_CHAOS_CHASER), - }; + private static final WeightedRandom.Item[] weightedAttacks = new WeightedRandom.Item[]{new WeightedAttack(16, ATTACK_FIREBALL_CHARGE), new WeightedAttack(14, ATTACK_FIREBALL_CHASER), new WeightedAttack(12, ATTACK_ENERGY_CHASER), new WeightedAttack(10, ATTACK_CHAOS_CHASER),}; - private static final WeightedRandom.Item[] weightedLowHealthAttaxks = new WeightedRandom.Item[] { - new WeightedAttack(5, ATTACK_FIREBALL_CHASER), - new WeightedAttack(5, ATTACK_TELEPORT), - new WeightedAttack(10, ATTACK_ENERGY_CHASER), - new WeightedAttack(15, ATTACK_CHAOS_CHASER), - }; + private static final WeightedRandom.Item[] weightedLowHealthAttaxks = new WeightedRandom.Item[]{new WeightedAttack(5, ATTACK_FIREBALL_CHASER), new WeightedAttack(5, ATTACK_TELEPORT), new WeightedAttack(10, ATTACK_ENERGY_CHASER), new WeightedAttack(15, ATTACK_CHAOS_CHASER),}; - private static final WeightedRandom.Item[] weightedBehaviours = new WeightedRandom.Item[] { - new WeightedBehaviour(1, EnumBehaviour.LOW_HEALTH_STRATEGY), - new WeightedBehaviour(10, EnumBehaviour.GUARDING), - new WeightedBehaviour(4, EnumBehaviour.CHARGING), - new WeightedBehaviour(12, EnumBehaviour.FIREBOMB), - new WeightedBehaviour(20, EnumBehaviour.CIRCLE_PLAYER), - }; + private static final WeightedRandom.Item[] weightedBehaviours = new WeightedRandom.Item[]{new WeightedBehaviour(1, EnumBehaviour.LOW_HEALTH_STRATEGY), new WeightedBehaviour(10, EnumBehaviour.GUARDING), new WeightedBehaviour(4, EnumBehaviour.CHARGING), new WeightedBehaviour(12, EnumBehaviour.FIREBOMB), new WeightedBehaviour(20, EnumBehaviour.CIRCLE_PLAYER),}; - private void selectNewAttack(){ - if (behaviour == EnumBehaviour.DEAD) return; - if (behaviour == EnumBehaviour.LOW_HEALTH_STRATEGY) attackInProgress = ((WeightedAttack)WeightedRandom.getRandomItem(rand, weightedLowHealthAttaxks)).attack; - else if (behaviour != EnumBehaviour.FIREBOMB) attackInProgress = ((WeightedAttack)WeightedRandom.getRandomItem(rand, weightedAttacks)).attack; - else attackInProgress = ATTACK_ENERGY_CHASER; - } + private void selectNewAttack() { + if (behaviour == EnumBehaviour.DEAD) return; + if (behaviour == EnumBehaviour.LOW_HEALTH_STRATEGY) + attackInProgress = ((WeightedAttack) WeightedRandom.getRandomItem(rand, weightedLowHealthAttaxks)).attack; + else if (behaviour != EnumBehaviour.FIREBOMB) + attackInProgress = ((WeightedAttack) WeightedRandom.getRandomItem(rand, weightedAttacks)).attack; + else attackInProgress = ATTACK_ENERGY_CHASER; + } - private void selectNewBehaviour(){ - if (worldObj.isRemote || behaviour == EnumBehaviour.DEAD) return; - EnumBehaviour newBehaviour = behaviour; - while (newBehaviour == behaviour) newBehaviour = ((WeightedBehaviour)WeightedRandom.getRandomItem(rand, weightedBehaviours)).randomBehaviour; - behaviour = newBehaviour; - previousBehaviour = behaviour; - } + private void selectNewBehaviour() { + if (worldObj.isRemote || behaviour == EnumBehaviour.DEAD) return; + EnumBehaviour newBehaviour = behaviour; + while (newBehaviour == behaviour) + newBehaviour = ((WeightedBehaviour) WeightedRandom.getRandomItem(rand, weightedBehaviours)).randomBehaviour; + behaviour = newBehaviour; + previousBehaviour = behaviour; + } - private void updateTarget(){ - switch (behaviour){ - case ROAMING: + private void updateTarget() { + switch (behaviour) { + case ROAMING: - break; - case GO_HOME: + break; + case GO_HOME: - break; - case GUARDING: + break; + case GUARDING: - break; - case CHARGING: + break; + case CHARGING: - break; - case FIREBOMB: - if (Utills.getDistanceAtoB(posX, posY, posZ, homeX, homeY + 30, homeZ) > 3){ - targetX = homeX; - targetY = homeY + 30; - targetZ = homeZ; - } + break; + case FIREBOMB: + if (Utills.getDistanceAtoB(posX, posY, posZ, homeX, homeY + 30, homeZ) > 3) { + targetX = homeX; + targetY = homeY + 30; + targetZ = homeZ; + } - break; - case CIRCLE_PLAYER: + break; + case CIRCLE_PLAYER: - break; - case LOW_HEALTH_STRATEGY: + break; + case LOW_HEALTH_STRATEGY: - break; - case DEAD: - this.targetX = homeX; - this.targetY = homeY; - this.targetZ = homeZ; - this.target = null; - break; - } - } + break; + case DEAD: + this.targetX = homeX; + this.targetY = homeY; + this.targetZ = homeZ; + this.target = null; + break; + } + } - private void setNewTarget() { - if (behaviour == EnumBehaviour.DEAD) return; - this.forceNewTarget = false; + private void setNewTarget() { + if (behaviour == EnumBehaviour.DEAD) return; + this.forceNewTarget = false; - switch (behaviour){ - case ROAMING: + switch (behaviour) { + case ROAMING: - boolean flag = false; - do { - this.targetX = homeX; - this.targetY = (double) (homeY + this.rand.nextFloat() * 50.0F); - this.targetZ = homeZ; - this.targetX += (double) (this.rand.nextFloat() * 120.0F - 60.0F); - this.targetZ += (double) (this.rand.nextFloat() * 120.0F - 60.0F); - double d0 = this.posX - this.targetX; - double d1 = this.posY - this.targetY; - double d2 = this.posZ - this.targetZ; - flag = d0 * d0 + d1 * d1 + d2 * d2 > 100.0D; - } while (!flag); - this.target = null; + boolean flag = false; + do { + this.targetX = homeX; + this.targetY = (double) (homeY + this.rand.nextFloat() * 50.0F); + this.targetZ = homeZ; + this.targetX += (double) (this.rand.nextFloat() * 120.0F - 60.0F); + this.targetZ += (double) (this.rand.nextFloat() * 120.0F - 60.0F); + double d0 = this.posX - this.targetX; + double d1 = this.posY - this.targetY; + double d2 = this.posZ - this.targetZ; + flag = d0 * d0 + d1 * d1 + d2 * d2 > 100.0D; + } while (!flag); + this.target = null; - break; - case GO_HOME: - case GUARDING: + break; + case GO_HOME: + case GUARDING: - this.targetX = homeX; - this.targetY = (double) (homeY + this.rand.nextFloat() * 50.0F); - this.targetZ = homeZ; - this.target = null; + this.targetX = homeX; + this.targetY = (double) (homeY + this.rand.nextFloat() * 50.0F); + this.targetZ = homeZ; + this.target = null; - break; - case CHARGING: - case CIRCLE_PLAYER: + break; + case CHARGING: + case CIRCLE_PLAYER: - if (worldObj.getClosestVulnerablePlayer(homeX, homeY, homeZ, 200) != null) this.target = worldObj.getClosestVulnerablePlayer(homeX, homeY, homeZ, 200); + if (worldObj.getClosestVulnerablePlayer(homeX, homeY, homeZ, 200) != null) + this.target = worldObj.getClosestVulnerablePlayer(homeX, homeY, homeZ, 200); - break; - case LOW_HEALTH_STRATEGY: + break; + case LOW_HEALTH_STRATEGY: - break; - case FIREBOMB: - @SuppressWarnings("unchecked") - List targets = worldObj.getEntitiesWithinAABB(EntityPlayer.class, boundingBox.expand(150, 150, 150)); - target = null; - while (targets.size() > 0 && target == null){ - EntityPlayer potentialTarget = targets.get(rand.nextInt(targets.size())); - if (worldObj.rayTraceBlocks(Vec3.createVectorHelper(posX, posY, posZ), Vec3.createVectorHelper(potentialTarget.posX, potentialTarget.posY, potentialTarget.posZ)) == null) target = potentialTarget; - else targets.remove(potentialTarget); - } + break; + case FIREBOMB: + @SuppressWarnings("unchecked") List targets = worldObj.getEntitiesWithinAABB(EntityPlayer.class, boundingBox.expand(150, 150, 150)); + target = null; + while (targets.size() > 0 && target == null) { + EntityPlayer potentialTarget = targets.get(rand.nextInt(targets.size())); + if (worldObj.rayTraceBlocks(Vec3.createVectorHelper(posX, posY, posZ), Vec3.createVectorHelper(potentialTarget.posX, potentialTarget.posY, potentialTarget.posZ)) == null) + target = potentialTarget; + else targets.remove(potentialTarget); + } - break; - case DEAD: + break; + case DEAD: - break; - } + break; + } - } + } - @Override - public boolean attackEntityFromPart(EntityDragonPart part, DamageSource damageSource, float dmg) { - if (behaviour == EnumBehaviour.DEAD) return false; - if (part != this.dragonPartHead) - { - dmg = dmg / 4.0F + 1.0F; - } + @Override + public boolean attackEntityFromPart(EntityDragonPart part, DamageSource damageSource, float dmg) { + if (behaviour == EnumBehaviour.DEAD) return false; + if (part != this.dragonPartHead) { + dmg = dmg / 4.0F + 1.0F; + } - if (dmg > 50) dmg -= ((dmg-50)*0.7); + if (dmg > 50) dmg -= ((dmg - 50) * 0.7); - switch (behaviour){ - case ROAMING: - break; - case GO_HOME: - break; - case GUARDING: - if (rand.nextInt(5) == 0) selectNewBehaviour(); - break; - case CHARGING: - if (rand.nextInt(6) == 0) selectNewBehaviour(); - break; - case CIRCLE_PLAYER: - if (rand.nextInt(6) == 0) selectNewBehaviour(); - else if (rand.nextInt(4) == 0) circleDirection *= -1; + switch (behaviour) { + case ROAMING: + break; + case GO_HOME: + break; + case GUARDING: + if (rand.nextInt(5) == 0) selectNewBehaviour(); + break; + case CHARGING: + if (rand.nextInt(6) == 0) selectNewBehaviour(); + break; + case CIRCLE_PLAYER: + if (rand.nextInt(6) == 0) selectNewBehaviour(); + else if (rand.nextInt(4) == 0) circleDirection *= -1; - break; - case LOW_HEALTH_STRATEGY: - if (rand.nextInt(6) == 0 && getHealth() >= getMaxHealth() * 0.2F) selectNewBehaviour(); - if (damageSource.getEntity() instanceof EntityPlayer && attackInProgress != ATTACK_TELEPORT) - { - int escape = 0; - boolean flag = false; - while (!flag && escape < 50) - { - targetX = homeX + ((rand.nextDouble() - 0.5D) * 260D); - targetY = homeY + 20 + (rand.nextDouble() - 0.5D) * 50D; - targetZ = homeZ + ((rand.nextDouble() - 0.5D) * 260D); - if (this.getDistanceToEntity(damageSource.getEntity()) >= 70 ) flag = true; - escape++; - } - target = null; - } + break; + case LOW_HEALTH_STRATEGY: + if (rand.nextInt(6) == 0 && getHealth() >= getMaxHealth() * 0.2F) selectNewBehaviour(); + if (damageSource.getEntity() instanceof EntityPlayer && attackInProgress != ATTACK_TELEPORT) { + int escape = 0; + boolean flag = false; + while (!flag && escape < 50) { + targetX = homeX + ((rand.nextDouble() - 0.5D) * 260D); + targetY = homeY + 20 + (rand.nextDouble() - 0.5D) * 50D; + targetZ = homeZ + ((rand.nextDouble() - 0.5D) * 260D); + if (this.getDistanceToEntity(damageSource.getEntity()) >= 70) flag = true; + escape++; + } + target = null; + } - break; - case FIREBOMB: - if ((target == null && Utills.getDistanceAtoB(posX, posY, posZ, homeX, homeY + 30, homeZ) <= 3) || rand.nextInt(5) == 0) selectNewBehaviour(); - if (damageSource.getEntity() instanceof EntityPlayer && damageSource.getEntity() != target && worldObj.rayTraceBlocks(Vec3.createVectorHelper(posX, posY, posZ), Vec3.createVectorHelper(damageSource.getEntity().posX, damageSource.getEntity().posY, damageSource.getEntity().posZ)) == null){ - target = damageSource.getEntity(); - } - break; - case DEAD: - break; - } + break; + case FIREBOMB: + if ((target == null && Utills.getDistanceAtoB(posX, posY, posZ, homeX, homeY + 30, homeZ) <= 3) || rand.nextInt(5) == 0) + selectNewBehaviour(); + if (damageSource.getEntity() instanceof EntityPlayer && damageSource.getEntity() != target && worldObj.rayTraceBlocks(Vec3.createVectorHelper(posX, posY, posZ), Vec3.createVectorHelper(damageSource.getEntity().posX, damageSource.getEntity().posY, damageSource.getEntity().posZ)) == null) { + target = damageSource.getEntity(); + } + break; + case DEAD: + break; + } // float f1 = this.rotationYaw * (float)Math.PI / 180.0F; // float f2 = MathHelper.sin(f1); @@ -814,55 +826,77 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio // this.targetZ = this.posZ - (double)(f3 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F); // this.target = null; - if ((damageSource.getEntity() instanceof EntityPlayer || damageSource.isExplosion()) && healingChaosCrystal == null)//tod reanable this - { - // if (getHealth() > 1F)setHealth(1F);//tod and remove this! - this.func_82195_e(damageSource, dmg); - } else if (damageSource.getEntity() instanceof EntityPlayer) ((EntityPlayer)damageSource.getEntity()).addChatComponentMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE+StatCollector.translateToLocal("msg.de.guardianAttackBlocked.txt"))); + if ((damageSource.getEntity() instanceof EntityPlayer || damageSource.isExplosion()) && healingChaosCrystal == null)//tod reanable this + { + // if (getHealth() > 1F)setHealth(1F);//tod and remove this! + this.func_82195_e(damageSource, dmg); + } else if (damageSource.getEntity() instanceof EntityPlayer) + ((EntityPlayer) damageSource.getEntity()).addChatComponentMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("msg.de.guardianAttackBlocked.txt"))); - return true; - } + return true; + } - private static enum EnumBehaviour { - /**Will roam around home until a player is spotted*/ - ROAMING(1F), - /**Will head home*/ - GO_HOME(1.3F), - /**Will will fly around above home attacking players*/ - GUARDING(0.8F), - /**Will charge players as the vanilla dragon dose*/ - CHARGING(2F), - /**Will fly to centre of island and unleash hell*/ - FIREBOMB(1.5F), - /**Will circle a player and shoot at that player*/ - CIRCLE_PLAYER(1.2F), - /**Will try to avoid players, will try to teleport players, will try to relight crystals*/ - LOW_HEALTH_STRATEGY(2F), - /**will die...*/ - DEAD(0.5F); - public float dragonSpeed; - private EnumBehaviour(float dragonSpeed) {this.dragonSpeed = dragonSpeed;} + private static enum EnumBehaviour { + /** + * Will roam around home until a player is spotted + */ + ROAMING(1F), + /** + * Will head home + */ + GO_HOME(1.3F), + /** + * Will will fly around above home attacking players + */ + GUARDING(0.8F), + /** + * Will charge players as the vanilla dragon dose + */ + CHARGING(2F), + /** + * Will fly to centre of island and unleash hell + */ + FIREBOMB(1.5F), + /** + * Will circle a player and shoot at that player + */ + CIRCLE_PLAYER(1.2F), + /** + * Will try to avoid players, will try to teleport players, will try to relight crystals + */ + LOW_HEALTH_STRATEGY(2F), + /** + * will die... + */ + DEAD(0.5F); + public float dragonSpeed; - } + private EnumBehaviour(float dragonSpeed) { + this.dragonSpeed = dragonSpeed; + } - private static class WeightedAttack extends WeightedRandom.Item { - public int attack; - public WeightedAttack(int weight, int attack) { - super(weight); - this.attack = attack; - } - } + } - private static class WeightedBehaviour extends WeightedRandom.Item { - public EnumBehaviour randomBehaviour; - public WeightedBehaviour(int weight, EnumBehaviour randomBehaviour) { - super(weight); - this.randomBehaviour = randomBehaviour; - } - } + private static class WeightedAttack extends WeightedRandom.Item { + public int attack; - @Override - protected void onDeathUpdate() { + public WeightedAttack(int weight, int attack) { + super(weight); + this.attack = attack; + } + } + + private static class WeightedBehaviour extends WeightedRandom.Item { + public EnumBehaviour randomBehaviour; + + public WeightedBehaviour(int weight, EnumBehaviour randomBehaviour) { + super(weight); + this.randomBehaviour = randomBehaviour; + } + } + + @Override + protected void onDeathUpdate() { // if (deathTicks == 0 && !isUber) // { // for (int ix = -150; ix < 150; ix++) { @@ -882,27 +916,26 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio // homeZ = ConfigHandler.dragonEggSpawnLocation[2]; // } // } - if (deathTicks == 0){ + if (deathTicks == 0) { - if (worldObj.getTileEntity(homeX, homeY, homeZ) instanceof TileChaosShard) { - ((TileChaosShard) worldObj.getTileEntity(homeX, homeY, homeZ)).setDefeated(); - } - else { - for (int x = homeX - 100; x < homeX + 100; x++){ - for (int y = homeY - 100; y < homeX + 100; y++){ - if (y < 0 || y > 255) continue; - for (int z = homeX - 100; z < homeX + 100; z++){ - if (worldObj.getTileEntity(x, y, z) instanceof TileChaosShard) { - ((TileChaosShard) worldObj.getTileEntity(x, y, z)).setDefeated(); - break; - } - } - } - } - } - } + if (worldObj.getTileEntity(homeX, homeY, homeZ) instanceof TileChaosShard) { + ((TileChaosShard) worldObj.getTileEntity(homeX, homeY, homeZ)).setDefeated(); + } else { + for (int x = homeX - 100; x < homeX + 100; x++) { + for (int y = homeY - 100; y < homeX + 100; y++) { + if (y < 0 || y > 255) continue; + for (int z = homeX - 100; z < homeX + 100; z++) { + if (worldObj.getTileEntity(x, y, z) instanceof TileChaosShard) { + ((TileChaosShard) worldObj.getTileEntity(x, y, z)).setDefeated(); + break; + } + } + } + } + } + } - ++this.deathTicks; + ++this.deathTicks; // if (worldObj.rand.nextInt(5) == 2) // { @@ -911,15 +944,15 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio // worldObj.addWeatherEffect(bolt); // } - if (this.deathTicks >= 180 && this.deathTicks <= 200) { - float f = (this.rand.nextFloat() - 0.5F) * 8.0F; - float f1 = (this.rand.nextFloat() - 0.5F) * 4.0F; - float f2 = (this.rand.nextFloat() - 0.5F) * 8.0F; - this.worldObj.spawnParticle("hugeexplosion", this.posX + (double) f, this.posY + 2.0D + (double) f1, this.posZ + (double) f2, 0.0D, 0.0D, 0.0D); - } + if (this.deathTicks >= 180 && this.deathTicks <= 200) { + float f = (this.rand.nextFloat() - 0.5F) * 8.0F; + float f1 = (this.rand.nextFloat() - 0.5F) * 4.0F; + float f2 = (this.rand.nextFloat() - 0.5F) * 8.0F; + this.worldObj.spawnParticle("hugeexplosion", this.posX + (double) f, this.posY + 2.0D + (double) f1, this.posZ + (double) f2, 0.0D, 0.0D, 0.0D); + } - int i; - int j; + int i; + int j; // if (!this.worldObj.isRemote) { // if (this.deathTicks > 150 && this.deathTicks % 5 == 0) { @@ -933,34 +966,34 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio // } // // }else - if (this.deathTicks == 1) { - this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.enderdragon.end", 50.0F, 1F, false); - //this.worldObj.playBroadcastSound(1018, (int) this.posX, (int) this.posY, (int) this.posZ, 0); - } + if (this.deathTicks == 1) { + this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.enderdragon.end", 50.0F, 1F, false); + //this.worldObj.playBroadcastSound(1018, (int) this.posX, (int) this.posY, (int) this.posZ, 0); + } - if(getDistance(homeX, homeY, homeZ) < 20 && deathTicks % 2 == 0){ - EntityLightningBolt bolt = new EntityLightningBolt(worldObj, homeX, homeY + 1, homeZ); - bolt.ignoreFrustumCheck = true; - worldObj.addWeatherEffect(bolt); - } + if (getDistance(homeX, homeY, homeZ) < 20 && deathTicks % 2 == 0) { + EntityLightningBolt bolt = new EntityLightningBolt(worldObj, homeX, homeY + 1, homeZ); + bolt.ignoreFrustumCheck = true; + worldObj.addWeatherEffect(bolt); + } - if (getDistance(homeX, homeY, homeZ) < 5 && !this.worldObj.isRemote) { - i = 200000; + if (getDistance(homeX, homeY, homeZ) < 5 && !this.worldObj.isRemote) { + i = 200000; - while (i > 0) { - j = EntityXPOrb.getXPSplit(i); - i -= j; - this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); - } + while (i > 0) { + j = EntityXPOrb.getXPSplit(i); + i -= j; + this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); + } - //spawnEgg(); - updateCrystals(); - for (EntityChaosCrystal crystal : crystals) crystal.setDeathTimer(); - setDead(); - } - } + //spawnEgg(); + updateCrystals(); + for (EntityChaosCrystal crystal : crystals) crystal.setDeathTimer(); + setDead(); + } + } - private void collideWithEntities(List par1List) { + private void collideWithEntities(List par1List) { // if (true) return; // // double d0 = (this.dragonPartBody.boundingBox.minX + this.dragonPartBody.boundingBox.maxX) / 2.0D; @@ -983,108 +1016,105 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio // entity.attackEntityFrom(new DamageSourceChaos(this), 20F); // } // } - } + } - private void attackEntitiesInList(List par1List) { - if (behaviour == EnumBehaviour.CHARGING) - { - boolean hasAttacked = false; - for (int i = 0; i < par1List.size(); ++i) - { - Entity entity = (Entity) par1List.get(i); + private void attackEntitiesInList(List par1List) { + if (behaviour == EnumBehaviour.CHARGING) { + boolean hasAttacked = false; + for (int i = 0; i < par1List.size(); ++i) { + Entity entity = (Entity) par1List.get(i); - if (entity instanceof EntityPlayer) - { - ((EntityLivingBase) entity).setLastAttacker(this); - entity.attackEntityFrom(new DamageSourceChaos(this), 50F); - hasAttacked = true; - } - } + if (entity instanceof EntityPlayer) { + ((EntityLivingBase) entity).setLastAttacker(this); + entity.attackEntityFrom(new DamageSourceChaos(this), 50F); + hasAttacked = true; + } + } - if (hasAttacked && rand.nextInt(2) == 0) behaviour = EnumBehaviour.GUARDING; - } - } + if (hasAttacked && rand.nextInt(2) == 0) behaviour = EnumBehaviour.GUARDING; + } + } - private void updateDragonEnderCrystal() { - if (worldObj.isRemote) return; + private void updateDragonEnderCrystal() { + if (worldObj.isRemote) return; - if (getHealth() <= 0) { - healingChaosCrystal = null; - crystalY = -1; + if (getHealth() <= 0) { + healingChaosCrystal = null; + crystalY = -1; // connectedCrystalID = -1; - return; - } + return; + } - if (this.healingChaosCrystal != null) { - if (!healingChaosCrystal.isAlive()){ - this.attackEntityFromPart(this.dragonPartHead, DamageSource.setExplosionSource(null), 10.0F); - healingChaosCrystal = null; - }else if (this.ticksExisted % 10 == 0 && this.getHealth() < this.getMaxHealth()) - { - this.setHealth(this.getHealth() + 2F); - } - } + if (this.healingChaosCrystal != null) { + if (!healingChaosCrystal.isAlive()) { + this.attackEntityFromPart(this.dragonPartHead, DamageSource.setExplosionSource(null), 10.0F); + healingChaosCrystal = null; + } else if (this.ticksExisted % 10 == 0 && this.getHealth() < this.getMaxHealth()) { + this.setHealth(this.getHealth() + 2F); + } + } - if (this.rand.nextInt(10) == 0) { - EntityChaosCrystal closest = null; - for (EntityChaosCrystal crystal : crystals) if (crystal.isAlive() && (closest == null || getDistanceToEntity(crystal) < getDistanceToEntity(closest))) closest = crystal; - healingChaosCrystal = closest; - if (healingChaosCrystal != null) { + if (this.rand.nextInt(10) == 0) { + EntityChaosCrystal closest = null; + for (EntityChaosCrystal crystal : crystals) + if (crystal.isAlive() && (closest == null || getDistanceToEntity(crystal) < getDistanceToEntity(closest))) + closest = crystal; + healingChaosCrystal = closest; + if (healingChaosCrystal != null) { // connectedCrystalID = healingChaosCrystal.getEntityId(); - crystalX = (int)Math.floor(healingChaosCrystal.posX); - crystalY = (int)Math.floor(healingChaosCrystal.posY); - crystalZ = (int)Math.floor(healingChaosCrystal.posZ); - } - else { - crystalY = -1; + crystalX = (int) Math.floor(healingChaosCrystal.posX); + crystalY = (int) Math.floor(healingChaosCrystal.posY); + crystalZ = (int) Math.floor(healingChaosCrystal.posZ); + } else { + crystalY = -1; // connectedCrystalID = -1; - } - } - } + } + } + } - private float simplifyAngle(double par1) { - return (float) MathHelper.wrapAngleTo180_double(par1); - } + private float simplifyAngle(double par1) { + return (float) MathHelper.wrapAngleTo180_double(par1); + } - private boolean destroyBlocksInAABB(AxisAlignedBB par1AxisAlignedBB) { - if (!ConfigHandler.dragonBreaksBlocks) return false; + private boolean destroyBlocksInAABB(AxisAlignedBB par1AxisAlignedBB) { + if (!ConfigHandler.dragonBreaksBlocks) return false; - int i = MathHelper.floor_double(par1AxisAlignedBB.minX); - int j = MathHelper.floor_double(par1AxisAlignedBB.minY); - int k = MathHelper.floor_double(par1AxisAlignedBB.minZ); - int l = MathHelper.floor_double(par1AxisAlignedBB.maxX); - int i1 = MathHelper.floor_double(par1AxisAlignedBB.maxY); - int j1 = MathHelper.floor_double(par1AxisAlignedBB.maxZ); - boolean flag = false; - boolean flag1 = false; + int i = MathHelper.floor_double(par1AxisAlignedBB.minX); + int j = MathHelper.floor_double(par1AxisAlignedBB.minY); + int k = MathHelper.floor_double(par1AxisAlignedBB.minZ); + int l = MathHelper.floor_double(par1AxisAlignedBB.maxX); + int i1 = MathHelper.floor_double(par1AxisAlignedBB.maxY); + int j1 = MathHelper.floor_double(par1AxisAlignedBB.maxZ); + boolean flag = false; + boolean flag1 = false; - for (int k1 = i; k1 <= l; ++k1) { - for (int l1 = j; l1 <= i1; ++l1) { - for (int i2 = k; i2 <= j1; ++i2) { - Block block = this.worldObj.getBlock(k1, l1, i2); + for (int k1 = i; k1 <= l; ++k1) { + for (int l1 = j; l1 <= i1; ++l1) { + for (int i2 = k; i2 <= j1; ++i2) { + Block block = this.worldObj.getBlock(k1, l1, i2); - if (!block.isAir(worldObj, k1, l1, i2)) { - if (block.canEntityDestroy(worldObj, k1, l1, i2, this) && this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")) { - flag1 = this.worldObj.setBlockToAir(k1, l1, i2) || flag1; - } else { - flag = true; - } - } - } - } - } + if (!block.isAir(worldObj, k1, l1, i2)) { + if (block.canEntityDestroy(worldObj, k1, l1, i2, this) && this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")) { + flag1 = this.worldObj.setBlockToAir(k1, l1, i2) || flag1; + } else { + flag = true; + } + } + } + } + } - if (flag1) { - double d1 = par1AxisAlignedBB.minX + (par1AxisAlignedBB.maxX - par1AxisAlignedBB.minX) * (double) this.rand.nextFloat(); - double d2 = par1AxisAlignedBB.minY + (par1AxisAlignedBB.maxY - par1AxisAlignedBB.minY) * (double) this.rand.nextFloat(); - double d0 = par1AxisAlignedBB.minZ + (par1AxisAlignedBB.maxZ - par1AxisAlignedBB.minZ) * (double) this.rand.nextFloat(); - this.worldObj.spawnParticle("largeexplode", d1, d2, d0, 0.0D, 0.0D, 0.0D); - } + if (flag1) { + double d1 = par1AxisAlignedBB.minX + (par1AxisAlignedBB.maxX - par1AxisAlignedBB.minX) * (double) this.rand.nextFloat(); + double d2 = par1AxisAlignedBB.minY + (par1AxisAlignedBB.maxY - par1AxisAlignedBB.minY) * (double) this.rand.nextFloat(); + double d0 = par1AxisAlignedBB.minZ + (par1AxisAlignedBB.maxZ - par1AxisAlignedBB.minZ) * (double) this.rand.nextFloat(); + this.worldObj.spawnParticle("largeexplode", d1, d2, d0, 0.0D, 0.0D, 0.0D); + } - return flag; - } + return flag; + } - private void spawnEgg() { + private void spawnEgg() { // if (ConfigHandler.dragonEggSpawnLocation[0] != 0 || ConfigHandler.dragonEggSpawnLocation[1] != 0 || ConfigHandler.dragonEggSpawnLocation[1] != 0 && !isUber) { // homeX = ConfigHandler.dragonEggSpawnLocation[0]; // homeY = ConfigHandler.dragonEggSpawnLocation[1]; @@ -1130,88 +1160,79 @@ public class EntityChaosGuardian extends EntityDragon {//summon DraconicEvolutio // // // BlockEndPortal.field_149948_a = false; - } + } - private void createEnderPortal(int par1, int par2) { - int b0 = homeY -3; - byte b1 = 4; + private void createEnderPortal(int par1, int par2) { + int b0 = homeY - 3; + byte b1 = 4; - for (int k = b0 - 1; k <= b0 + 32; ++k) - { - for (int l = par1 - b1; l <= par1 + b1; ++l) - { - for (int i1 = par2 - b1; i1 <= par2 + b1; ++i1) - { - double d0 = (double)(l - par1); - double d1 = (double)(i1 - par2); - double d2 = d0 * d0 + d1 * d1; + for (int k = b0 - 1; k <= b0 + 32; ++k) { + for (int l = par1 - b1; l <= par1 + b1; ++l) { + for (int i1 = par2 - b1; i1 <= par2 + b1; ++i1) { + double d0 = (double) (l - par1); + double d1 = (double) (i1 - par2); + double d2 = d0 * d0 + d1 * d1; - if (d2 <= ((double)b1 - 0.5D) * ((double)b1 - 0.5D)) - { - if (k < b0) - { - if (d2 <= ((double)(b1 - 1) - 0.5D) * ((double)(b1 - 1) - 0.5D)) - { - this.worldObj.setBlock(l, k, i1, Blocks.bedrock); - } - } - else if (k > b0) - { - this.worldObj.setBlock(l, k, i1, Blocks.air); - } - else if (d2 > ((double)(b1 - 1) - 0.5D) * ((double)(b1 - 1) - 0.5D)) - { - this.worldObj.setBlock(l, k, i1, Blocks.bedrock); - } - } - } - } - } + if (d2 <= ((double) b1 - 0.5D) * ((double) b1 - 0.5D)) { + if (k < b0) { + if (d2 <= ((double) (b1 - 1) - 0.5D) * ((double) (b1 - 1) - 0.5D)) { + this.worldObj.setBlock(l, k, i1, Blocks.bedrock); + } + } else if (k > b0) { + this.worldObj.setBlock(l, k, i1, Blocks.air); + } else if (d2 > ((double) (b1 - 1) - 0.5D) * ((double) (b1 - 1) - 0.5D)) { + this.worldObj.setBlock(l, k, i1, Blocks.bedrock); + } + } + } + } + } - this.worldObj.setBlock(par1, b0 + 0, par2, Blocks.bedrock); - this.worldObj.setBlock(par1, b0 + 1, par2, Blocks.bedrock); - this.worldObj.setBlock(par1, b0 + 2, par2, Blocks.bedrock); - this.worldObj.setBlock(par1, b0 + 3, par2, Blocks.bedrock); - } + this.worldObj.setBlock(par1, b0 + 0, par2, Blocks.bedrock); + this.worldObj.setBlock(par1, b0 + 1, par2, Blocks.bedrock); + this.worldObj.setBlock(par1, b0 + 2, par2, Blocks.bedrock); + this.worldObj.setBlock(par1, b0 + 3, par2, Blocks.bedrock); + } - @Override - public void writeToNBT(NBTTagCompound compound) { - super.writeToNBT(compound); - compound.setInteger("HomeXCoord", homeX); - compound.setInteger("HomeYCoord", homeY); - compound.setInteger("HomeZCoord", homeZ); - compound.setString("Behaviour", behaviour.name()); - compound.setBoolean("HomeSet", homeSet); - } + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setInteger("HomeXCoord", homeX); + compound.setInteger("HomeYCoord", homeY); + compound.setInteger("HomeZCoord", homeZ); + compound.setString("Behaviour", behaviour.name()); + compound.setBoolean("HomeSet", homeSet); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - super.readFromNBT(compound); - homeX = compound.getInteger("HomeXCoord"); - homeY = compound.getInteger("HomeYCoord"); - homeZ = compound.getInteger("HomeZCoord"); - if (compound.hasKey("Behaviour")) behaviour = EnumBehaviour.valueOf(compound.getString("Behaviour")); - homeSet = compound.getBoolean("HomeSet"); - targetX = homeX; - targetZ = homeZ; - } + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + homeX = compound.getInteger("HomeXCoord"); + homeY = compound.getInteger("HomeYCoord"); + homeZ = compound.getInteger("HomeZCoord"); + if (compound.hasKey("Behaviour")) behaviour = EnumBehaviour.valueOf(compound.getString("Behaviour")); + homeSet = compound.getBoolean("HomeSet"); + targetX = homeX; + targetZ = homeZ; + } - @Override - protected boolean canDespawn() { - return false; - } + @Override + protected boolean canDespawn() { + return false; + } - @Override - protected void despawnEntity() { + @Override + protected void despawnEntity() { - } + } - @Override - public boolean attackEntityFrom(DamageSource damageSource, float dmg) { + @Override + public boolean attackEntityFrom(DamageSource damageSource, float dmg) { - return super.attackEntityFrom(damageSource, dmg); - } + return super.attackEntityFrom(damageSource, dmg); + } - @Override - public void travelToDimension(int p_71027_1_) {} + @Override + public void travelToDimension(int p_71027_1_) { + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosVortex.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosVortex.java index f1144934..a6affac9 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosVortex.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityChaosVortex.java @@ -16,72 +16,74 @@ import java.util.List; * Created by brandon3055 on 3/10/2015. */ public class EntityChaosVortex extends Entity { - public EntityChaosVortex(World world) { - super(world); - this.noClip = true; - this.setSize(0F, 0F); - } + public EntityChaosVortex(World world) { + super(world); + this.noClip = true; + this.setSize(0F, 0F); + } - @Override - public boolean isInRangeToRenderDist(double p_70112_1_) { - return true; - } + @Override + public boolean isInRangeToRenderDist(double p_70112_1_) { + return true; + } - @Override - protected void entityInit() { - dataWatcher.addObject(20, ticksExisted); - } + @Override + protected void entityInit() { + dataWatcher.addObject(20, ticksExisted); + } - @Override - public void onUpdate() { - if (!worldObj.isRemote) dataWatcher.updateObject(20, ticksExisted); - else ticksExisted = dataWatcher.getWatchableObjectInt(20); + @Override + public void onUpdate() { + if (!worldObj.isRemote) dataWatcher.updateObject(20, ticksExisted); + else ticksExisted = dataWatcher.getWatchableObjectInt(20); - if (ticksExisted < 30 && ticksExisted % 5 == 0 && worldObj.isRemote) DraconicEvolution.proxy.spawnParticle(new Particles.ChaosExpansionParticle(worldObj, posX, posY, posZ, false), 512); - if (ticksExisted >= 100 && ticksExisted < 130 && ticksExisted % 5 == 0 && worldObj.isRemote) DraconicEvolution.proxy.spawnParticle(new Particles.ChaosExpansionParticle(worldObj, posX, posY, posZ, true), 512); - if (ticksExisted < 100) return; + if (ticksExisted < 30 && ticksExisted % 5 == 0 && worldObj.isRemote) + DraconicEvolution.proxy.spawnParticle(new Particles.ChaosExpansionParticle(worldObj, posX, posY, posZ, false), 512); + if (ticksExisted >= 100 && ticksExisted < 130 && ticksExisted % 5 == 0 && worldObj.isRemote) + DraconicEvolution.proxy.spawnParticle(new Particles.ChaosExpansionParticle(worldObj, posX, posY, posZ, true), 512); + if (ticksExisted < 100) return; - for (int i = 0; i < 10; i++) { - double x = posX - 18 + rand.nextDouble() * 36; - double y = posY - 8 + rand.nextDouble() * 16; - double z = posZ - 18 + rand.nextDouble() * 36; - if (worldObj.isRemote) DraconicEvolution.proxy.spawnParticle(new Particles.AdvancedSeekerParticle(worldObj, x, y, z, posX, posY, posZ, 2, 1f, 1f, 1f, 100), 128); - } + for (int i = 0; i < 10; i++) { + double x = posX - 18 + rand.nextDouble() * 36; + double y = posY - 8 + rand.nextDouble() * 16; + double z = posZ - 18 + rand.nextDouble() * 36; + if (worldObj.isRemote) + DraconicEvolution.proxy.spawnParticle(new Particles.AdvancedSeekerParticle(worldObj, x, y, z, posX, posY, posZ, 2, 1f, 1f, 1f, 100), 128); + } - if (ticksExisted > 130 && worldObj.isRemote && ticksExisted % 2 == 0) shakeScreen(); + if (ticksExisted > 130 && worldObj.isRemote && ticksExisted % 2 == 0) shakeScreen(); - if (ticksExisted == 600 && !worldObj.isRemote) { - DraconicEvolution.network.sendToAllAround(new GenericParticlePacket(GenericParticlePacket.CHAOS_IMPLOSION, posX, posY, posZ), new NetworkRegistry.TargetPoint(dimension, posX, posY, posZ, 512)); - ProcessHandler.addProcess(new ChaosImplosion(worldObj, (int) posX, (int) posY, (int) posZ)); - } + if (ticksExisted == 600 && !worldObj.isRemote) { + DraconicEvolution.network.sendToAllAround(new GenericParticlePacket(GenericParticlePacket.CHAOS_IMPLOSION, posX, posY, posZ), new NetworkRegistry.TargetPoint(dimension, posX, posY, posZ, 512)); + ProcessHandler.addProcess(new ChaosImplosion(worldObj, (int) posX, (int) posY, (int) posZ)); + } - if (ticksExisted > 620) setDead(); - } + if (ticksExisted > 620) setDead(); + } + private void shakeScreen() { + double intensity = (ticksExisted - 130) / 100D; + if (intensity > 1D) intensity = 1D; - private void shakeScreen(){ - double intensity = (ticksExisted - 130) / 100D; - if (intensity > 1D) intensity = 1D; + @SuppressWarnings("unchecked") List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, boundingBox.expand(200, 200, 200)); - @SuppressWarnings("unchecked") List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, boundingBox.expand(200, 200, 200)); + for (EntityPlayer player : players) { + double x = (rand.nextDouble() - 0.5) * 2 * intensity; + double z = (rand.nextDouble() - 0.5) * 2 * intensity; + player.moveEntity(x / 5D, 0, z / 5D); + player.rotationYaw -= x * 2; + player.rotationPitch -= z * 2; + } + } - for (EntityPlayer player : players){ - double x = (rand.nextDouble() - 0.5) * 2 * intensity; - double z = (rand.nextDouble() - 0.5) * 2 * intensity; - player.moveEntity(x/5D, 0, z/5D); - player.rotationYaw -= x*2; - player.rotationPitch -= z*2; - } - } + @Override + protected void readEntityFromNBT(NBTTagCompound p_70037_1_) { - @Override - protected void readEntityFromNBT(NBTTagCompound p_70037_1_) { + } - } + @Override + protected void writeEntityToNBT(NBTTagCompound p_70014_1_) { - @Override - protected void writeEntityToNBT(NBTTagCompound p_70014_1_) { - - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityCustomArrow.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityCustomArrow.java index aae223e5..9e4635d6 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityCustomArrow.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityCustomArrow.java @@ -29,436 +29,426 @@ import net.minecraft.world.World; import java.util.List; public class EntityCustomArrow extends EntityArrow { - private int blockX = -1; - private int blockY = -1; - private int blockZ = -1; - private Block blockHit; - private int inData; - private boolean inGround; - private int ticksInGround; - private int ticksInAir; - - //Arrow Properties - public boolean ignorSpeed = false; //old - public boolean explosive = false; //old - public int knockbackStrength = 0; - - public BowHandler.BowProperties bowProperties = new BowHandler.BowProperties(); - - public EntityCustomArrow(World p_i1753_1_) { - super(p_i1753_1_); - renderDistanceWeight = 40; - } - - public EntityCustomArrow(World p_i1754_1_, double p_i1754_2_, double p_i1754_4_, double p_i1754_6_) { - super(p_i1754_1_, p_i1754_2_, p_i1754_4_, p_i1754_6_); - renderDistanceWeight = 40; - } - - public EntityCustomArrow(World p_i1755_1_, EntityLivingBase p_i1755_2_, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_) { - super(p_i1755_1_, p_i1755_2_, p_i1755_3_, p_i1755_4_, p_i1755_5_); - renderDistanceWeight = 40; - } - - public EntityCustomArrow(World par1World, EntityLivingBase par2EntityLivingBase, float velocity) { - super(par1World, par2EntityLivingBase, velocity); - renderDistanceWeight = 40; - } - - @Override - protected void entityInit() - { - super.entityInit(); - this.dataWatcher.addObject(17, Byte.valueOf((byte) 0)); - //this.dataWatcher.updateObject(17, Byte.valueOf((byte)(bowProperties.energyBolt ? 1 : 0))); - } - - @Override - public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) - { - float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5); - par1 /= f2; - par3 /= f2; - par5 /= f2; - par1 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.0007499999832361937D * par8; - par3 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.0007499999832361937D * par8; - par5 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.0007499999832361937D * par8; - par1 *= par7; - par3 *= par7; - par5 *= par7; - this.motionX = par1; - this.motionY = par3; - this.motionZ = par5; - float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); - this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, f3) * 180.0D / Math.PI); - this.ticksInGround = 0; - } - - @SuppressWarnings("rawtypes") - @Override - public void onUpdate() - { - //region Entity Update And motion - super.onEntityUpdate(); - if (worldObj.isRemote) { - bowProperties.energyBolt = dataWatcher.getWatchableObjectByte(17) == 1; - } - else dataWatcher.updateObject(17, (byte) (bowProperties.energyBolt ? 1 : 0)); - - - if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { - float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D / Math.PI); - } - - if (this.arrowShake > 0) { - --this.arrowShake; - } - //endregion - - //region Block Collision Detection - Block block = this.worldObj.getBlock(this.blockX, this.blockY, this.blockZ); - - if (block.getMaterial() != Material.air) { - onHitAnything(); - block.setBlockBoundsBasedOnState(this.worldObj, this.blockX, this.blockY, this.blockZ); - AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.blockX, this.blockY, this.blockZ); - - if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) { - this.inGround = true; - } - } - //endregion - - if (this.inGround) { - int j = this.worldObj.getBlockMetadata(this.blockX, this.blockY, this.blockZ); - - if (block == this.blockHit && j == this.inData) { - ++this.ticksInGround; - - if (this.ticksInGround == 1200 || bowProperties.energyBolt) { //Delete the entity when it hits the ground if it is an energy bolt - this.setDead(); - } - } else { - 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.ticksInGround = 0; - this.ticksInAir = 0; - } - } else { - //region Detect Entity Hit - ++this.ticksInAir; - Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); - Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false); - vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); - vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - - if (movingobjectposition != null) { - vec3 = 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; - int i; - float f1; - - for (i = 0; i < list.size(); ++i) { - Entity entity1 = (Entity) list.get(i); - - if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) { - f1 = 0.3F; - AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f1, f1, f1); - MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); - - if (movingobjectposition1 != null) { - double d1 = vec31.distanceTo(movingobjectposition1.hitVec); - - if (d1 < d0 || d0 == 0.0D) { - entity = entity1; - d0 = d1; - } - } - } - } - - if (entity != null) { - movingobjectposition = new MovingObjectPosition(entity); - } - - if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) { - EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit; - - if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) { - movingobjectposition = null; - } - } - //endregion - - float velocity; - float f4; - - //region Process Entity Hit - if (movingobjectposition != null) { - if (movingobjectposition.entityHit != null) { - onHitAnything(); - if (isDead) return; - int actualDamage; - //Calculate Damage - velocity = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); - actualDamage = MathHelper.ceiling_double_int(velocity * bowProperties.arrowDamage); - - if (bowProperties.energyBolt) actualDamage *= 1.1F; - - if (this.getIsCritical()) { - actualDamage += this.rand.nextInt(actualDamage / 2 + 2); - } - - if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) { - movingobjectposition.entityHit.setFire(5); - } - - if (bowProperties.energyBolt) movingobjectposition.entityHit.hurtResistantTime = 0; - if (movingobjectposition.entityHit instanceof EntityDragonPart && ((EntityDragonPart)movingobjectposition.entityHit).entityDragonObj instanceof EntityDragon && bowProperties.energyBolt) - { - ((EntityDragon)((EntityDragonPart)movingobjectposition.entityHit).entityDragonObj).hurtResistantTime = 0; - } - - if (movingobjectposition.entityHit.attackEntityFrom(getDamageSource(), actualDamage)) { - if (movingobjectposition.entityHit instanceof EntityLivingBase) { - EntityLivingBase entitylivingbase = (EntityLivingBase) movingobjectposition.entityHit; - - if (!this.worldObj.isRemote) { - entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1); - } - - if (this.knockbackStrength > 0) { - f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - - if (f4 > 0.0F) { - movingobjectposition.entityHit.addVelocity(this.motionX * this.knockbackStrength * 0.6000000238418579D / f4, 0.1D, this.motionZ * this.knockbackStrength * 0.6000000238418579D / f4); - } - } - - if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase) { - EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity); - EnchantmentHelper.func_151385_b((EntityLivingBase) this.shootingEntity, entitylivingbase); - } - - if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) { - ((EntityPlayerMP) this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F)); - } - } - - this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); - this.setDead(); - - } else { - if (!(worldObj.isRemote && ticksInAir < 5)) { //Fix arrow wobble on fire due to client side collision with shooting entity - this.motionX *= -0.10000000149011612D; - this.motionY *= -0.10000000149011612D; - this.motionZ *= -0.10000000149011612D; - this.rotationYaw += 180.0F; - this.prevRotationYaw += 180.0F; - this.ticksInAir = 0; - } - } - } else { - this.blockX = movingobjectposition.blockX; - this.blockY = movingobjectposition.blockY; - this.blockZ = movingobjectposition.blockZ; - block = this.worldObj.getBlock(this.blockX, this.blockY, this.blockZ); - this.blockHit = block; - this.inData = this.worldObj.getBlockMetadata(this.blockX, this.blockY, this.blockZ); - this.motionX = ((float) (movingobjectposition.hitVec.xCoord - this.posX)); - this.motionY = ((float) (movingobjectposition.hitVec.yCoord - this.posY)); - this.motionZ = ((float) (movingobjectposition.hitVec.zCoord - this.posZ)); - velocity = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); - this.posX -= this.motionX / velocity * 0.05000000074505806D; - this.posY -= this.motionY / velocity * 0.05000000074505806D; - this.posZ -= this.motionZ / velocity * 0.05000000074505806D; - this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); - this.inGround = true; - this.arrowShake = 7; - - if (this.blockHit.getMaterial() != Material.air) { - this.blockHit.onEntityCollidedWithBlock(this.worldObj, this.blockX, this.blockY, this.blockZ, this); - } - } - } - //endregion - - //region Motion - if ((this.getIsCritical() || bowProperties.energyBolt) && worldObj.isRemote) { - for (i = 0; i < 4; ++i) { - if (bowProperties.energyBolt) { - spawnArrowParticles(); - } - else { - this.worldObj.spawnParticle("crit", this.posX + this.motionX * i / 4.0D, this.posY + this.motionY * i / 4.0D, this.posZ + this.motionZ * i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ); - } - } - } - - this.posX += this.motionX; - this.posY += this.motionY; - this.posZ += this.motionZ; - velocity = 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, velocity) * 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; - float f3 = 0.99F; - f1 = bowProperties.energyBolt ? 0.025F : 0.05F; - - if (this.isInWater()) { - for (int l = 0; l < 4; ++l) { - f4 = 0.25F; - this.worldObj.spawnParticle("bubble", this.posX - this.motionX * f4, this.posY - this.motionY * f4, this.posZ - this.motionZ * f4, this.motionX, this.motionY, this.motionZ); - } - - f3 = 0.8F; - } - - if (this.isWet()) { - this.extinguish(); - } - - this.motionX *= f3; - this.motionY *= f3; - this.motionZ *= f3; - this.motionY -= f1; - this.setPosition(this.posX, this.posY, this.posZ); - this.func_145775_I(); - //endregion - } - } - - @SideOnly(Side.CLIENT) - private void spawnArrowParticles(){ - Particles.ArrowParticle particle = new Particles.ArrowParticle(worldObj, posX - 0.25 + rand.nextDouble() * 0.5, posY + rand.nextDouble() * 0.5, posZ - 0.25 + rand.nextDouble() * 0.5, 0xff6000, 0.2F+rand.nextFloat()*0.5f); - double mm = 0.2; - particle.motionX = (rand.nextDouble() - 0.5) * mm; - particle.motionY = (rand.nextDouble() - 0.5) * mm; - particle.motionZ = (rand.nextDouble() - 0.5) * mm; - ParticleHandler.spawnCustomParticle(particle, 64); - } - - @Override - public void writeEntityToNBT(NBTTagCompound compound) - { - compound.setShort("xTile", (short) this.blockX); - compound.setShort("yTile", (short) this.blockY); - compound.setShort("zTile", (short) this.blockZ); - compound.setShort("life", (short) this.ticksInGround); - compound.setByte("inTile", (byte) Block.getIdFromBlock(this.blockHit)); - compound.setByte("inData", (byte) this.inData); - compound.setByte("shake", (byte) this.arrowShake); - compound.setByte("inGround", (byte) (this.inGround ? 1 : 0)); - compound.setByte("pickup", (byte) this.canBePickedUp); - if (bowProperties != null) bowProperties.writeToNBT(compound); - } - - @Override - public void readEntityFromNBT(NBTTagCompound compound) - { - this.blockX = compound.getShort("xTile"); - this.blockY = compound.getShort("yTile"); - this.blockZ = compound.getShort("zTile"); - this.ticksInGround = compound.getShort("life"); - this.blockHit = Block.getBlockById(compound.getByte("inTile") & 255); - this.inData = compound.getByte("inData") & 255; - this.arrowShake = compound.getByte("shake") & 255; - this.inGround = compound.getByte("inGround") == 1; - - if (compound.hasKey("pickup", 99)) { - this.canBePickedUp = compound.getByte("pickup"); - } else if (compound.hasKey("player", 99)) { - this.canBePickedUp = compound.getBoolean("player") ? 1 : 0; - } - - if (bowProperties != null) bowProperties.readFromNBT(compound); - } - - @Override - public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) - { - if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) { - - boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode; - - if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Items.arrow, 1))) { - flag = false; - } - - if (flag) { - this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); - par1EntityPlayer.onItemPickup(this, 1); - this.setDead(); - } - } - } - - public void onHitEntityLiving(EntityLivingBase entityLivingBase){ - } - - public void onHitAnything(){ - if (bowProperties.explosionPower > 0 && !worldObj.isRemote){ - worldObj.createExplosion(this, prevPosX, prevPosY, prevPosZ, bowProperties.explosionPower, true); - setDead(); - } - if (bowProperties.shockWavePower > 0 && !worldObj.isRemote){ - DraconicEvolution.network.sendToAllAround(new GenericParticlePacket(GenericParticlePacket.ARROW_SHOCK_WAVE, posX, posY, posZ, (int)(bowProperties.shockWavePower * 100)), new NetworkRegistry.TargetPoint(dimension, posX, posY, posZ, 256)); - worldObj.playSoundEffect(posX, posY, posZ, "random.explode", 4.0F, (1.0F + (this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.2F) * 0.7F); - - double range = (double)bowProperties.shockWavePower + 5; - List list = worldObj.getEntitiesWithinAABB(Entity.class, boundingBox.expand(range, range, range)); - - float damage = 40F * bowProperties.shockWavePower; - - for (Entity e : list) { - if (e instanceof EntityLivingBase) { - Entity entity = e; - float distanceModifier = 1F - (entity.getDistanceToEntity(this) / bowProperties.shockWavePower); - - if (e instanceof EntityDragon){ - entity = ((EntityDragon)entity).dragonPartBody; - distanceModifier = 1F - (entity.getDistanceToEntity(this) / (bowProperties.shockWavePower * 4)); - } - - if (distanceModifier > 0) entity.attackEntityFrom(getDamageSource(), distanceModifier * damage); - } - } - - setDead(); - } - } - - private DamageSource getDamageSource(){ - if (bowProperties.energyBolt){ - return new EntityDamageSourceIndirect("customArrowEnergy", this, shootingEntity != null ? shootingEntity : this).setProjectile().setDamageIsAbsolute(); - } - else return DamageSource.causeArrowDamage(this, shootingEntity != null ? shootingEntity : this); - } + private int blockX = -1; + private int blockY = -1; + private int blockZ = -1; + private Block blockHit; + private int inData; + private boolean inGround; + private int ticksInGround; + private int ticksInAir; + + //Arrow Properties + public boolean ignorSpeed = false; //old + public boolean explosive = false; //old + public int knockbackStrength = 0; + + public BowHandler.BowProperties bowProperties = new BowHandler.BowProperties(); + + public EntityCustomArrow(World p_i1753_1_) { + super(p_i1753_1_); + renderDistanceWeight = 40; + } + + public EntityCustomArrow(World p_i1754_1_, double p_i1754_2_, double p_i1754_4_, double p_i1754_6_) { + super(p_i1754_1_, p_i1754_2_, p_i1754_4_, p_i1754_6_); + renderDistanceWeight = 40; + } + + public EntityCustomArrow(World p_i1755_1_, EntityLivingBase p_i1755_2_, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_) { + super(p_i1755_1_, p_i1755_2_, p_i1755_3_, p_i1755_4_, p_i1755_5_); + renderDistanceWeight = 40; + } + + public EntityCustomArrow(World par1World, EntityLivingBase par2EntityLivingBase, float velocity) { + super(par1World, par2EntityLivingBase, velocity); + renderDistanceWeight = 40; + } + + @Override + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(17, Byte.valueOf((byte) 0)); + //this.dataWatcher.updateObject(17, Byte.valueOf((byte)(bowProperties.energyBolt ? 1 : 0))); + } + + @Override + public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) { + float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5); + par1 /= f2; + par3 /= f2; + par5 /= f2; + par1 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.0007499999832361937D * par8; + par3 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.0007499999832361937D * par8; + par5 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.0007499999832361937D * par8; + par1 *= par7; + par3 *= par7; + par5 *= par7; + this.motionX = par1; + this.motionY = par3; + this.motionZ = par5; + float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); + this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, f3) * 180.0D / Math.PI); + this.ticksInGround = 0; + } + + @SuppressWarnings("rawtypes") + @Override + public void onUpdate() { + //region Entity Update And motion + super.onEntityUpdate(); + if (worldObj.isRemote) { + bowProperties.energyBolt = dataWatcher.getWatchableObjectByte(17) == 1; + } else dataWatcher.updateObject(17, (byte) (bowProperties.energyBolt ? 1 : 0)); + + + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { + float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D / Math.PI); + } + + if (this.arrowShake > 0) { + --this.arrowShake; + } + //endregion + + //region Block Collision Detection + Block block = this.worldObj.getBlock(this.blockX, this.blockY, this.blockZ); + + if (block.getMaterial() != Material.air) { + onHitAnything(); + block.setBlockBoundsBasedOnState(this.worldObj, this.blockX, this.blockY, this.blockZ); + AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.blockX, this.blockY, this.blockZ); + + if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) { + this.inGround = true; + } + } + //endregion + + if (this.inGround) { + int j = this.worldObj.getBlockMetadata(this.blockX, this.blockY, this.blockZ); + + if (block == this.blockHit && j == this.inData) { + ++this.ticksInGround; + + if (this.ticksInGround == 1200 || bowProperties.energyBolt) { //Delete the entity when it hits the ground if it is an energy bolt + this.setDead(); + } + } else { + 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.ticksInGround = 0; + this.ticksInAir = 0; + } + } else { + //region Detect Entity Hit + ++this.ticksInAir; + Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false); + vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + + if (movingobjectposition != null) { + vec3 = 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; + int i; + float f1; + + for (i = 0; i < list.size(); ++i) { + Entity entity1 = (Entity) list.get(i); + + if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) { + f1 = 0.3F; + AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f1, f1, f1); + MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); + + if (movingobjectposition1 != null) { + double d1 = vec31.distanceTo(movingobjectposition1.hitVec); + + if (d1 < d0 || d0 == 0.0D) { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) { + movingobjectposition = new MovingObjectPosition(entity); + } + + if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) { + EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit; + + if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) { + movingobjectposition = null; + } + } + //endregion + + float velocity; + float f4; + + //region Process Entity Hit + if (movingobjectposition != null) { + if (movingobjectposition.entityHit != null) { + onHitAnything(); + if (isDead) return; + int actualDamage; + //Calculate Damage + velocity = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + actualDamage = MathHelper.ceiling_double_int(velocity * bowProperties.arrowDamage); + + if (bowProperties.energyBolt) actualDamage *= 1.1F; + + if (this.getIsCritical()) { + actualDamage += this.rand.nextInt(actualDamage / 2 + 2); + } + + if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) { + movingobjectposition.entityHit.setFire(5); + } + + if (bowProperties.energyBolt) movingobjectposition.entityHit.hurtResistantTime = 0; + if (movingobjectposition.entityHit instanceof EntityDragonPart && ((EntityDragonPart) movingobjectposition.entityHit).entityDragonObj instanceof EntityDragon && bowProperties.energyBolt) { + ((EntityDragon) ((EntityDragonPart) movingobjectposition.entityHit).entityDragonObj).hurtResistantTime = 0; + } + + if (movingobjectposition.entityHit.attackEntityFrom(getDamageSource(), actualDamage)) { + if (movingobjectposition.entityHit instanceof EntityLivingBase) { + EntityLivingBase entitylivingbase = (EntityLivingBase) movingobjectposition.entityHit; + + if (!this.worldObj.isRemote) { + entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1); + } + + if (this.knockbackStrength > 0) { + f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + + if (f4 > 0.0F) { + movingobjectposition.entityHit.addVelocity(this.motionX * this.knockbackStrength * 0.6000000238418579D / f4, 0.1D, this.motionZ * this.knockbackStrength * 0.6000000238418579D / f4); + } + } + + if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase) { + EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity); + EnchantmentHelper.func_151385_b((EntityLivingBase) this.shootingEntity, entitylivingbase); + } + + if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) { + ((EntityPlayerMP) this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F)); + } + } + + this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + this.setDead(); + + } else { + if (!(worldObj.isRemote && ticksInAir < 5)) { //Fix arrow wobble on fire due to client side collision with shooting entity + this.motionX *= -0.10000000149011612D; + this.motionY *= -0.10000000149011612D; + this.motionZ *= -0.10000000149011612D; + this.rotationYaw += 180.0F; + this.prevRotationYaw += 180.0F; + this.ticksInAir = 0; + } + } + } else { + this.blockX = movingobjectposition.blockX; + this.blockY = movingobjectposition.blockY; + this.blockZ = movingobjectposition.blockZ; + block = this.worldObj.getBlock(this.blockX, this.blockY, this.blockZ); + this.blockHit = block; + this.inData = this.worldObj.getBlockMetadata(this.blockX, this.blockY, this.blockZ); + this.motionX = ((float) (movingobjectposition.hitVec.xCoord - this.posX)); + this.motionY = ((float) (movingobjectposition.hitVec.yCoord - this.posY)); + this.motionZ = ((float) (movingobjectposition.hitVec.zCoord - this.posZ)); + velocity = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + this.posX -= this.motionX / velocity * 0.05000000074505806D; + this.posY -= this.motionY / velocity * 0.05000000074505806D; + this.posZ -= this.motionZ / velocity * 0.05000000074505806D; + this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + this.inGround = true; + this.arrowShake = 7; + + if (this.blockHit.getMaterial() != Material.air) { + this.blockHit.onEntityCollidedWithBlock(this.worldObj, this.blockX, this.blockY, this.blockZ, this); + } + } + } + //endregion + + //region Motion + if ((this.getIsCritical() || bowProperties.energyBolt) && worldObj.isRemote) { + for (i = 0; i < 4; ++i) { + if (bowProperties.energyBolt) { + spawnArrowParticles(); + } else { + this.worldObj.spawnParticle("crit", this.posX + this.motionX * i / 4.0D, this.posY + this.motionY * i / 4.0D, this.posZ + this.motionZ * i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ); + } + } + } + + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + velocity = 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, velocity) * 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; + float f3 = 0.99F; + f1 = bowProperties.energyBolt ? 0.025F : 0.05F; + + if (this.isInWater()) { + for (int l = 0; l < 4; ++l) { + f4 = 0.25F; + this.worldObj.spawnParticle("bubble", this.posX - this.motionX * f4, this.posY - this.motionY * f4, this.posZ - this.motionZ * f4, this.motionX, this.motionY, this.motionZ); + } + + f3 = 0.8F; + } + + if (this.isWet()) { + this.extinguish(); + } + + this.motionX *= f3; + this.motionY *= f3; + this.motionZ *= f3; + this.motionY -= f1; + this.setPosition(this.posX, this.posY, this.posZ); + this.func_145775_I(); + //endregion + } + } + + @SideOnly(Side.CLIENT) + private void spawnArrowParticles() { + Particles.ArrowParticle particle = new Particles.ArrowParticle(worldObj, posX - 0.25 + rand.nextDouble() * 0.5, posY + rand.nextDouble() * 0.5, posZ - 0.25 + rand.nextDouble() * 0.5, 0xff6000, 0.2F + rand.nextFloat() * 0.5f); + double mm = 0.2; + particle.motionX = (rand.nextDouble() - 0.5) * mm; + particle.motionY = (rand.nextDouble() - 0.5) * mm; + particle.motionZ = (rand.nextDouble() - 0.5) * mm; + ParticleHandler.spawnCustomParticle(particle, 64); + } + + @Override + public void writeEntityToNBT(NBTTagCompound compound) { + compound.setShort("xTile", (short) this.blockX); + compound.setShort("yTile", (short) this.blockY); + compound.setShort("zTile", (short) this.blockZ); + compound.setShort("life", (short) this.ticksInGround); + compound.setByte("inTile", (byte) Block.getIdFromBlock(this.blockHit)); + compound.setByte("inData", (byte) this.inData); + compound.setByte("shake", (byte) this.arrowShake); + compound.setByte("inGround", (byte) (this.inGround ? 1 : 0)); + compound.setByte("pickup", (byte) this.canBePickedUp); + if (bowProperties != null) bowProperties.writeToNBT(compound); + } + + @Override + public void readEntityFromNBT(NBTTagCompound compound) { + this.blockX = compound.getShort("xTile"); + this.blockY = compound.getShort("yTile"); + this.blockZ = compound.getShort("zTile"); + this.ticksInGround = compound.getShort("life"); + this.blockHit = Block.getBlockById(compound.getByte("inTile") & 255); + this.inData = compound.getByte("inData") & 255; + this.arrowShake = compound.getByte("shake") & 255; + this.inGround = compound.getByte("inGround") == 1; + + if (compound.hasKey("pickup", 99)) { + this.canBePickedUp = compound.getByte("pickup"); + } else if (compound.hasKey("player", 99)) { + this.canBePickedUp = compound.getBoolean("player") ? 1 : 0; + } + + if (bowProperties != null) bowProperties.readFromNBT(compound); + } + + @Override + public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) { + if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) { + + boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode; + + if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Items.arrow, 1))) { + flag = false; + } + + if (flag) { + this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + par1EntityPlayer.onItemPickup(this, 1); + this.setDead(); + } + } + } + + public void onHitEntityLiving(EntityLivingBase entityLivingBase) { + } + + public void onHitAnything() { + if (bowProperties.explosionPower > 0 && !worldObj.isRemote) { + worldObj.createExplosion(this, prevPosX, prevPosY, prevPosZ, bowProperties.explosionPower, true); + setDead(); + } + if (bowProperties.shockWavePower > 0 && !worldObj.isRemote) { + DraconicEvolution.network.sendToAllAround(new GenericParticlePacket(GenericParticlePacket.ARROW_SHOCK_WAVE, posX, posY, posZ, (int) (bowProperties.shockWavePower * 100)), new NetworkRegistry.TargetPoint(dimension, posX, posY, posZ, 256)); + worldObj.playSoundEffect(posX, posY, posZ, "random.explode", 4.0F, (1.0F + (this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.2F) * 0.7F); + + double range = (double) bowProperties.shockWavePower + 5; + List list = worldObj.getEntitiesWithinAABB(Entity.class, boundingBox.expand(range, range, range)); + + float damage = 40F * bowProperties.shockWavePower; + + for (Entity e : list) { + if (e instanceof EntityLivingBase) { + Entity entity = e; + float distanceModifier = 1F - (entity.getDistanceToEntity(this) / bowProperties.shockWavePower); + + if (e instanceof EntityDragon) { + entity = ((EntityDragon) entity).dragonPartBody; + distanceModifier = 1F - (entity.getDistanceToEntity(this) / (bowProperties.shockWavePower * 4)); + } + + if (distanceModifier > 0) entity.attackEntityFrom(getDamageSource(), distanceModifier * damage); + } + } + + setDead(); + } + } + + private DamageSource getDamageSource() { + if (bowProperties.energyBolt) { + return new EntityDamageSourceIndirect("customArrowEnergy", this, shootingEntity != null ? shootingEntity : this).setProjectile().setDamageIsAbsolute(); + } else return DamageSource.causeArrowDamage(this, shootingEntity != null ? shootingEntity : this); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityCustomDragon.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityCustomDragon.java index a9aaaa96..70e0fb3c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityCustomDragon.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityCustomDragon.java @@ -31,649 +31,633 @@ import java.util.List; */ public class EntityCustomDragon extends EntityDragon { - private Entity target; - public int portalX = 0; - public int portalY = 67; - public int portalZ = 0; - private boolean createPortal = true; - public float attackDamage = 10F; - protected boolean isUber = false; - private boolean needsRenderUpdate = true; - private boolean initialized = false; - - public EntityCustomDragon(World par1World) { - super(par1World); - } - - public EntityCustomDragon(World world, double health, float attack){ - this(world); - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(health); - this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(health); - this.attackDamage = attack; - } - - @Override - protected void entityInit() { - super.entityInit(); - this.dataWatcher.addObject(12, (isUber ? (byte)1 : (byte)0)); - } - - @Override - public boolean isNoDespawnRequired() { - return true; - } - - @Override - protected void applyEntityAttributes() { - super.applyEntityAttributes(); - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(200D); - } - - @Override - public void onLivingUpdate() { - float f; - float f1; - - if (!initialized && !worldObj.isRemote){ - this.addPotionEffect(new PotionEffect(10, 600, 10, false)); - initialized = true; - } - - if (this.worldObj.isRemote) { - f = MathHelper.cos(this.animTime * (float) Math.PI * 2.0F); - f1 = MathHelper.cos(this.prevAnimTime * (float) Math.PI * 2.0F); - - if (f1 <= -0.3F && f >= -0.3F) { - this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.enderdragon.wings", 5.0F, 0.8F + this.rand.nextFloat() * 0.3F, false); - } - } - - this.prevAnimTime = this.animTime; - float f2; - - if (this.getHealth() <= 0.0F) { - f = (this.rand.nextFloat() - 0.5F) * 8.0F; - f1 = (this.rand.nextFloat() - 0.5F) * 4.0F; - f2 = (this.rand.nextFloat() - 0.5F) * 8.0F; - this.worldObj.spawnParticle("largeexplode", this.posX + (double) f, this.posY + 2.0D + (double) f1, this.posZ + (double) f2, 0.0D, 0.0D, 0.0D); - } else { - this.updateDragonEnderCrystal(); - if (isUber) f = 0.5F / (MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 10.0F + 1.0F); //Wing Speed - else f = 0.2F / (MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 10.0F + 1.0F); - f *= (float) Math.pow(2.0D, this.motionY); - - if (this.slowed) { - this.animTime += f * 0.5F; - } else { - this.animTime += f; - } - - this.rotationYaw = MathHelper.wrapAngleTo180_float(this.rotationYaw); - - if (this.ringBufferIndex < 0) { - for (int i = 0; i < this.ringBuffer.length; ++i) { - this.ringBuffer[i][0] = (double) this.rotationYaw; - this.ringBuffer[i][1] = this.posY; - } - } - - if (++this.ringBufferIndex == this.ringBuffer.length) { - this.ringBufferIndex = 0; - } - - this.ringBuffer[this.ringBufferIndex][0] = (double) this.rotationYaw; - this.ringBuffer[this.ringBufferIndex][1] = this.posY; - double d0; - double d1; - double d2; - double d10; - float f12; - - if (this.worldObj.isRemote) { - if (this.newPosRotationIncrements > 0) { - d10 = this.posX + (this.newPosX - this.posX) / (double) this.newPosRotationIncrements; - d0 = this.posY + (this.newPosY - this.posY) / (double) this.newPosRotationIncrements; - d1 = this.posZ + (this.newPosZ - this.posZ) / (double) this.newPosRotationIncrements; - d2 = MathHelper.wrapAngleTo180_double(this.newRotationYaw - (double) this.rotationYaw); - this.rotationYaw = (float) ((double) this.rotationYaw + d2 / (double) this.newPosRotationIncrements); - this.rotationPitch = (float) ((double) this.rotationPitch + (this.newRotationPitch - (double) this.rotationPitch) / (double) this.newPosRotationIncrements); - --this.newPosRotationIncrements; - this.setPosition(d10, d0, d1); - this.setRotation(this.rotationYaw, this.rotationPitch); - } - } else { - d10 = this.targetX - this.posX; - d0 = this.targetY - this.posY; - d1 = this.targetZ - this.posZ; - d2 = d10 * d10 + d0 * d0 + d1 * d1; - - if (this.target != null) { - this.targetX = this.target.posX; - this.targetZ = this.target.posZ; - double d3 = this.targetX - this.posX; - double d5 = this.targetZ - this.posZ; - double d7 = Math.sqrt(d3 * d3 + d5 * d5); - double d8 = 0.4000000059604645D + d7 / 80.0D - 1.0D; - - if (d8 > 10.0D) { - d8 = 10.0D; - } - - this.targetY = this.target.boundingBox.minY + d8; - } else { - this.targetX += this.rand.nextGaussian() * 2.0D; - this.targetZ += this.rand.nextGaussian() * 2.0D; - } - - if (this.forceNewTarget || d2 < 100.0D || d2 > 22500.0D || this.isCollidedHorizontally || this.isCollidedVertically) { - this.setNewTarget(); - } - - d0 /= (double) MathHelper.sqrt_double(d10 * d10 + d1 * d1); - if (isUber) f12 = 1.0F;//Verticle Motion Speed - else f12 = 0.6F; - - if (d0 < (double) (-f12)) { - d0 = (double) (-f12); - } - - if (d0 > (double) f12) { - d0 = (double) f12; - } - - this.motionY += d0 * 0.10000000149011612D; - this.rotationYaw = MathHelper.wrapAngleTo180_float(this.rotationYaw); - double d4 = 180.0D - Math.atan2(d10, d1) * 180.0D / Math.PI; - double d6 = MathHelper.wrapAngleTo180_double(d4 - (double) this.rotationYaw); - - if (d6 > 50.0D) { - d6 = 50.0D; - } - - if (d6 < -50.0D) { - d6 = -50.0D; - } - - Vec3 vec3 = Vec3.createVectorHelper(this.targetX - this.posX, this.targetY - this.posY, this.targetZ - this.posZ).normalize(); - Vec3 vec32 = Vec3.createVectorHelper((double) MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F), this.motionY, (double) (-MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F))).normalize(); - float f5 = (float) (vec32.dotProduct(vec3) + 0.5D) / 1.5F; - - if (f5 < 0.0F) { - f5 = 0.0F; - } - - this.randomYawVelocity *= 0.8F; - float f6 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0F + 1.0F; - double d9 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0D + 1.0D; - - if (d9 > 40.0D) { - d9 = 40.0D; - } - - this.randomYawVelocity = (float) ((double) this.randomYawVelocity + d6 * (0.699999988079071D / d9 / (double) f6)); - this.rotationYaw += this.randomYawVelocity * 0.1F; - float f7 = (float) (2.0D / (d9 + 1.0D)); - float f8 = 0.06F; - this.moveFlying(0.0F, -1.0F, f8 * (f5 * f7 + (1.0F - f7))); - - if (this.slowed) { - this.moveEntity(this.motionX * 0.800000011920929D, this.motionY * 0.800000011920929D, this.motionZ * 0.800000011920929D); - } else if (isUber){ - this.moveEntity(this.motionX * 2.5D, this.motionY * 1.5D, this.motionZ * 2.5D); - } else { - this.moveEntity(this.motionX, this.motionY, this.motionZ); - } - - Vec3 vec31 = Vec3.createVectorHelper(this.motionX, this.motionY, this.motionZ).normalize(); - float f9 = (float) (vec31.dotProduct(vec32) + 1.0D) / 2.0F; - f9 = 0.8F + 0.15F * f9; - this.motionX *= (double) f9; - this.motionZ *= (double) f9; - this.motionY *= 0.9100000262260437D; - } - - this.renderYawOffset = this.rotationYaw; - this.dragonPartHead.width = this.dragonPartHead.height = 3.0F; - this.dragonPartTail1.width = this.dragonPartTail1.height = 2.0F; - this.dragonPartTail2.width = this.dragonPartTail2.height = 2.0F; - this.dragonPartTail3.width = this.dragonPartTail3.height = 2.0F; - this.dragonPartBody.height = 3.0F; - this.dragonPartBody.width = 5.0F; - this.dragonPartWing1.height = 2.0F; - this.dragonPartWing1.width = 4.0F; - this.dragonPartWing2.height = 3.0F; - this.dragonPartWing2.width = 4.0F; - f1 = (float) (this.getMovementOffsets(5, 1.0F)[1] - this.getMovementOffsets(10, 1.0F)[1]) * 10.0F / 180.0F * (float) Math.PI; - f2 = MathHelper.cos(f1); - float f10 = -MathHelper.sin(f1); - float f3 = this.rotationYaw * (float) Math.PI / 180.0F; - float f11 = MathHelper.sin(f3); - float f4 = MathHelper.cos(f3); - this.dragonPartBody.onUpdate(); - this.dragonPartBody.setLocationAndAngles(this.posX + (double) (f11 * 0.5F), this.posY, this.posZ - (double) (f4 * 0.5F), 0.0F, 0.0F); - this.dragonPartWing1.onUpdate(); - this.dragonPartWing1.setLocationAndAngles(this.posX + (double) (f4 * 4.5F), this.posY + 2.0D, this.posZ + (double) (f11 * 4.5F), 0.0F, 0.0F); - this.dragonPartWing2.onUpdate(); - this.dragonPartWing2.setLocationAndAngles(this.posX - (double) (f4 * 4.5F), this.posY + 2.0D, this.posZ - (double) (f11 * 4.5F), 0.0F, 0.0F); - - if (!this.worldObj.isRemote && this.hurtTime == 0) { - this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing1.boundingBox.expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D))); - this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing2.boundingBox.expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D))); - this.attackEntitiesInList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartHead.boundingBox.expand(1.0D, 1.0D, 1.0D))); - } - - double[] adouble1 = this.getMovementOffsets(5, 1.0F); - double[] adouble = this.getMovementOffsets(0, 1.0F); - f12 = MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F - this.randomYawVelocity * 0.01F); - float f13 = MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F - this.randomYawVelocity * 0.01F); - this.dragonPartHead.onUpdate(); - this.dragonPartHead.setLocationAndAngles(this.posX + (double) (f12 * 5.5F * f2), this.posY + (adouble[1] - adouble1[1]) * 1.0D + (double) (f10 * 5.5F), this.posZ - (double) (f13 * 5.5F * f2), 0.0F, 0.0F); - - for (int j = 0; j < 3; ++j) { - EntityDragonPart entitydragonpart = null; - - if (j == 0) { - entitydragonpart = this.dragonPartTail1; - } - - if (j == 1) { - entitydragonpart = this.dragonPartTail2; - } - - if (j == 2) { - entitydragonpart = this.dragonPartTail3; - } - - double[] adouble2 = this.getMovementOffsets(12 + j * 2, 1.0F); - float f14 = this.rotationYaw * (float) Math.PI / 180.0F + this.simplifyAngle(adouble2[0] - adouble1[0]) * (float) Math.PI / 180.0F * 1.0F; - float f15 = MathHelper.sin(f14); - float f16 = MathHelper.cos(f14); - float f17 = 1.5F; - float f18 = (float) (j + 1) * 2.0F; - entitydragonpart.onUpdate(); - entitydragonpart.setLocationAndAngles(this.posX - (double) ((f11 * f17 + f15 * f18) * f2), this.posY + (adouble2[1] - adouble1[1]) * 1.0D - (double) ((f18 + f17) * f10) + 1.5D, this.posZ + (double) ((f4 * f17 + f16 * f18) * f2), 0.0F, 0.0F); - } - - if (!this.worldObj.isRemote) { - this.slowed = this.destroyBlocksInAABB(this.dragonPartHead.boundingBox) | this.destroyBlocksInAABB(this.dragonPartBody.boundingBox); - } - } - - } - - @Override - protected void onDeathUpdate() { - - - if (deathTicks == 0 && !isUber) - { - for (int ix = -150; ix < 150; ix++) { - for (int iz = -150; iz < 150; iz++) { - if (worldObj.getBlock(ix, portalY, iz) == Blocks.bedrock && worldObj.getBlock(ix, portalY - 1, iz) == Blocks.bedrock) { - portalX = ix; - portalZ = iz; - createPortal = false; - break; - } - } - } - if (ConfigHandler.dragonEggSpawnLocation[0] != 0 || ConfigHandler.dragonEggSpawnLocation[1] != 0 || ConfigHandler.dragonEggSpawnLocation[1] != 0) { - createPortal = false; - portalX = ConfigHandler.dragonEggSpawnLocation[0]; - portalY = ConfigHandler.dragonEggSpawnLocation[1]; - portalZ = ConfigHandler.dragonEggSpawnLocation[2]; - } - } - - ++this.deathTicks; - - if (worldObj.rand.nextInt(5) == 2) - { - EntityLightningBolt bolt = new EntityLightningBolt(worldObj, portalX, portalY + 1, portalZ); - bolt.ignoreFrustumCheck = true; - worldObj.addWeatherEffect(bolt); - } - - if (this.deathTicks >= 180 && this.deathTicks <= 200) { - float f = (this.rand.nextFloat() - 0.5F) * 8.0F; - float f1 = (this.rand.nextFloat() - 0.5F) * 4.0F; - float f2 = (this.rand.nextFloat() - 0.5F) * 8.0F; - this.worldObj.spawnParticle("hugeexplosion", this.posX + (double) f, this.posY + 2.0D + (double) f1, this.posZ + (double) f2, 0.0D, 0.0D, 0.0D); - } - - int i; - int j; - - if (!this.worldObj.isRemote) { - if (this.deathTicks > 150 && this.deathTicks % 5 == 0) { - i = 1000; - - while (i > 0) { - j = EntityXPOrb.getXPSplit(i); - i -= j; - this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); - } - } - } - else if (this.deathTicks == 1) { - this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.enderdragon.end", 50.0F, 1F, false); - //this.worldObj.playBroadcastSound(1018, (int) this.posX, (int) this.posY, (int) this.posZ, 0); - } - - this.moveEntity(0.0D, 0.10000000149011612D, 0.0D); - this.renderYawOffset = this.rotationYaw += 20.0F; - - if (this.deathTicks == 200 && !this.worldObj.isRemote) { - i = 2000; - - while (i > 0) { - j = EntityXPOrb.getXPSplit(i); - i -= j; - this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); - } - - spawnEgg(); - setDead(); - } - } - - private void collideWithEntities(List par1List) { - double d0 = (this.dragonPartBody.boundingBox.minX + this.dragonPartBody.boundingBox.maxX) / 2.0D; - double d1 = (this.dragonPartBody.boundingBox.minZ + this.dragonPartBody.boundingBox.maxZ) / 2.0D; - Iterator iterator = par1List.iterator(); - - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); - - if (entity instanceof EntityLivingBase) { - double d2 = entity.posX - d0; - double d3 = entity.posZ - d1; - double d4 = d2 * d2 + d3 * d3; - if (rand.nextInt(isUber ? 3 : 10) == 0) entity.addVelocity(d2 / d4 * 8.0D, 5.20000000298023224D, d3 / d4 * 8.0D); - entity.velocityChanged = true; - ((EntityLivingBase)entity).setLastAttacker(this); - } - if (entity instanceof EntityLivingBase && isUber){ - ((EntityLivingBase)entity).setLastAttacker(this); - entity.attackEntityFrom(new DamageSourceChaos(this), 20F); - } - } - } - - private void attackEntitiesInList(List par1List) { - for (int i = 0; i < par1List.size(); ++i) { - Entity entity = (Entity) par1List.get(i); - - if (entity instanceof EntityLivingBase && !isUber) { - ((EntityLivingBase)entity).setLastAttacker(this); - entity.attackEntityFrom(DamageSource.causeMobDamage(this), attackDamage); - } - if (entity instanceof EntityLivingBase && isUber){ - ((EntityLivingBase)entity).setLastAttacker(this); - entity.attackEntityFrom(new DamageSourceChaos(this), 50F); - } - } - } - - private void updateDragonEnderCrystal() { - if (this.healingEnderCrystal != null) { - if (this.healingEnderCrystal.isDead) { - if (!this.worldObj.isRemote) { - this.attackEntityFromPart(this.dragonPartHead, DamageSource.setExplosionSource((Explosion) null), 10.0F); - } - - this.healingEnderCrystal = null; - } else if (this.ticksExisted % 10 == 0 && this.getHealth() < this.getMaxHealth()) { - if (isUber) this.setHealth(this.getHealth() + 10.0F); - else this.setHealth(this.getHealth() + 1.0F); - } - } - - if (this.rand.nextInt(10) == 0) { - float f = 32.0F; - List list = this.worldObj.getEntitiesWithinAABB(EntityEnderCrystal.class, this.boundingBox.expand((double) f, (double) f, (double) f)); - EntityEnderCrystal entityendercrystal = null; - double d0 = Double.MAX_VALUE; - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityEnderCrystal entityendercrystal1 = (EntityEnderCrystal) iterator.next(); - double d1 = entityendercrystal1.getDistanceSqToEntity(this); - - if (d1 < d0) { - d0 = d1; - entityendercrystal = entityendercrystal1; - } - } - - this.healingEnderCrystal = entityendercrystal; - } - } - - private void setNewTarget() { - this.forceNewTarget = false; - - if ((isUber || this.rand.nextInt(2) == 0) && (!isUber || 19 > this.rand.nextInt(20)) && !this.worldObj.playerEntities.isEmpty()) { - this.target = (Entity) this.worldObj.playerEntities.get(this.rand.nextInt(this.worldObj.playerEntities.size())); - } else { - boolean flag = false; - - do { - this.targetX = portalX; - this.targetY = (double) (70.0F + this.rand.nextFloat() * 50.0F); - this.targetZ = portalZ; - this.targetX += (double) (this.rand.nextFloat() * 120.0F - 60.0F); - this.targetZ += (double) (this.rand.nextFloat() * 120.0F - 60.0F); - double d0 = this.posX - this.targetX; - double d1 = this.posY - this.targetY; - double d2 = this.posZ - this.targetZ; - flag = d0 * d0 + d1 * d1 + d2 * d2 > 100.0D; - } while (!flag); - - this.target = null; - } - } - - private float simplifyAngle(double par1) { - return (float) MathHelper.wrapAngleTo180_double(par1); - } - - private boolean destroyBlocksInAABB(AxisAlignedBB par1AxisAlignedBB) { - if (!ConfigHandler.dragonBreaksBlocks) return false; - - int i = MathHelper.floor_double(par1AxisAlignedBB.minX); - int j = MathHelper.floor_double(par1AxisAlignedBB.minY); - int k = MathHelper.floor_double(par1AxisAlignedBB.minZ); - int l = MathHelper.floor_double(par1AxisAlignedBB.maxX); - int i1 = MathHelper.floor_double(par1AxisAlignedBB.maxY); - int j1 = MathHelper.floor_double(par1AxisAlignedBB.maxZ); - boolean flag = false; - boolean flag1 = false; - - for (int k1 = i; k1 <= l; ++k1) { - for (int l1 = j; l1 <= i1; ++l1) { - for (int i2 = k; i2 <= j1; ++i2) { - Block block = this.worldObj.getBlock(k1, l1, i2); - - if (!block.isAir(worldObj, k1, l1, i2)) { - if (block.canEntityDestroy(worldObj, k1, l1, i2, this) && this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")) { - flag1 = this.worldObj.setBlockToAir(k1, l1, i2) || flag1; - } else { - flag = true; - } - } - } - } - } - - if (flag1) { - double d1 = par1AxisAlignedBB.minX + (par1AxisAlignedBB.maxX - par1AxisAlignedBB.minX) * (double) this.rand.nextFloat(); - double d2 = par1AxisAlignedBB.minY + (par1AxisAlignedBB.maxY - par1AxisAlignedBB.minY) * (double) this.rand.nextFloat(); - double d0 = par1AxisAlignedBB.minZ + (par1AxisAlignedBB.maxZ - par1AxisAlignedBB.minZ) * (double) this.rand.nextFloat(); - this.worldObj.spawnParticle("largeexplode", d1, d2, d0, 0.0D, 0.0D, 0.0D); - } - - return flag; - } - - private void spawnEgg() - { - if (ConfigHandler.dragonEggSpawnLocation[0] != 0 || ConfigHandler.dragonEggSpawnLocation[1] != 0 || ConfigHandler.dragonEggSpawnLocation[1] != 0 && !isUber) { - portalX = ConfigHandler.dragonEggSpawnLocation[0]; - portalY = ConfigHandler.dragonEggSpawnLocation[1]; - portalZ = ConfigHandler.dragonEggSpawnLocation[2]; - } - - BlockEndPortal.field_149948_a = true; - - if (createPortal || isUber) { - createEnderPortal(portalX, portalZ); - } - LogHelper.info("spawn egg"); - if (worldObj.getBlock(portalX, portalY + 1, portalZ) == Blocks.air) { - worldObj.setBlock(portalX, portalY + 1, portalZ, Blocks.dragon_egg); - LogHelper.info("spawn egg2 " + portalX + " " + portalY + " " + portalZ); - }else { - for (int i = portalY + 1; i < 250; i++) { - if (worldObj.getBlock(portalX, i, portalZ) == Blocks.air) { - worldObj.setBlock(portalX, i, portalZ, Blocks.dragon_egg); - LogHelper.info("spawn egg3"); - break; - } - } - } - - for (int iX = portalX - 2; iX <= portalX + 2; iX++) - { - for (int iZ = portalZ - 2; iZ <= portalZ + 2; iZ++) - { - - if (worldObj.getBlock(iX, portalY - 4, iZ) == Blocks.bedrock && !(iX == portalX && iZ == portalZ)) - { - worldObj.setBlock(iX, portalY - 3, iZ, Blocks.end_portal); - } - } - } - - - worldObj.setBlock(portalX - 1, portalY - 1, portalZ, Blocks.torch); - worldObj.setBlock(portalX + 1, portalY - 1, portalZ, Blocks.torch); - worldObj.setBlock(portalX, portalY - 1, portalZ - 1, Blocks.torch); - worldObj.setBlock(portalX, portalY - 1, portalZ + 1, Blocks.torch); - - - BlockEndPortal.field_149948_a = false; - } - - private void createEnderPortal(int par1, int par2) - { - int b0 = portalY-3; - byte b1 = 4; - - for (int k = b0 - 1; k <= b0 + 32; ++k) - { - for (int l = par1 - b1; l <= par1 + b1; ++l) - { - for (int i1 = par2 - b1; i1 <= par2 + b1; ++i1) - { - double d0 = (double)(l - par1); - double d1 = (double)(i1 - par2); - double d2 = d0 * d0 + d1 * d1; - - if (d2 <= ((double)b1 - 0.5D) * ((double)b1 - 0.5D)) - { - if (k < b0) - { - if (d2 <= ((double)(b1 - 1) - 0.5D) * ((double)(b1 - 1) - 0.5D)) - { - this.worldObj.setBlock(l, k, i1, Blocks.bedrock); - } - } - else if (k > b0) - { - this.worldObj.setBlock(l, k, i1, Blocks.air); - } - else if (d2 > ((double)(b1 - 1) - 0.5D) * ((double)(b1 - 1) - 0.5D)) - { - this.worldObj.setBlock(l, k, i1, Blocks.bedrock); - } - } - } - } - } - - this.worldObj.setBlock(par1, b0 + 0, par2, Blocks.bedrock); - this.worldObj.setBlock(par1, b0 + 1, par2, Blocks.bedrock); - this.worldObj.setBlock(par1, b0 + 2, par2, Blocks.bedrock); - this.worldObj.setBlock(par1, b0 + 3, par2, Blocks.bedrock); - } - - @Override - public void writeToNBT(NBTTagCompound compound) { - super.writeToNBT(compound); - compound.setFloat("AttackDamage", attackDamage); - compound.setBoolean("IsUber", isUber); - compound.setBoolean("Initialized", initialized); - if (isUber) - { - compound.setInteger("PortalX", portalX); - compound.setInteger("PortalY", portalY); - compound.setInteger("PortalZ", portalZ); - } - } - - @Override - public void readFromNBT(NBTTagCompound compound) { - super.readFromNBT(compound); - attackDamage = compound.getFloat("AttackDamage"); - isUber = compound.getBoolean("IsUber"); - initialized = compound.getBoolean("Initialized"); - this.dataWatcher.updateObject(12, isUber ? (byte)1: (byte)0); - if (isUber) - { - portalX = compound.getInteger("PortalX"); - portalY = compound.getInteger("PortalY"); - portalZ = compound.getInteger("PortalZ"); - } - } - - @Override - protected boolean canDespawn() { - return false; - } - - @Override - protected void despawnEntity() { - - } - - public void setUber(boolean b){ - isUber = b; - this.dataWatcher.updateObject(12, b ? (byte)1: (byte)0); - } - - public boolean getIsUber(){ - return isUber; - } - - @Override - public boolean attackEntityFrom(DamageSource damageSource, float dmg) { + private Entity target; + public int portalX = 0; + public int portalY = 67; + public int portalZ = 0; + private boolean createPortal = true; + public float attackDamage = 10F; + protected boolean isUber = false; + private boolean needsRenderUpdate = true; + private boolean initialized = false; + + public EntityCustomDragon(World par1World) { + super(par1World); + } + + public EntityCustomDragon(World world, double health, float attack) { + this(world); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(health); + this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(health); + this.attackDamage = attack; + } + + @Override + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(12, (isUber ? (byte) 1 : (byte) 0)); + } + + @Override + public boolean isNoDespawnRequired() { + return true; + } + + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(200D); + } + + @Override + public void onLivingUpdate() { + float f; + float f1; + + if (!initialized && !worldObj.isRemote) { + this.addPotionEffect(new PotionEffect(10, 600, 10, false)); + initialized = true; + } + + if (this.worldObj.isRemote) { + f = MathHelper.cos(this.animTime * (float) Math.PI * 2.0F); + f1 = MathHelper.cos(this.prevAnimTime * (float) Math.PI * 2.0F); + + if (f1 <= -0.3F && f >= -0.3F) { + this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.enderdragon.wings", 5.0F, 0.8F + this.rand.nextFloat() * 0.3F, false); + } + } + + this.prevAnimTime = this.animTime; + float f2; + + if (this.getHealth() <= 0.0F) { + f = (this.rand.nextFloat() - 0.5F) * 8.0F; + f1 = (this.rand.nextFloat() - 0.5F) * 4.0F; + f2 = (this.rand.nextFloat() - 0.5F) * 8.0F; + this.worldObj.spawnParticle("largeexplode", this.posX + (double) f, this.posY + 2.0D + (double) f1, this.posZ + (double) f2, 0.0D, 0.0D, 0.0D); + } else { + this.updateDragonEnderCrystal(); + if (isUber) + f = 0.5F / (MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 10.0F + 1.0F); //Wing Speed + else + f = 0.2F / (MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 10.0F + 1.0F); + f *= (float) Math.pow(2.0D, this.motionY); + + if (this.slowed) { + this.animTime += f * 0.5F; + } else { + this.animTime += f; + } + + this.rotationYaw = MathHelper.wrapAngleTo180_float(this.rotationYaw); + + if (this.ringBufferIndex < 0) { + for (int i = 0; i < this.ringBuffer.length; ++i) { + this.ringBuffer[i][0] = (double) this.rotationYaw; + this.ringBuffer[i][1] = this.posY; + } + } + + if (++this.ringBufferIndex == this.ringBuffer.length) { + this.ringBufferIndex = 0; + } + + this.ringBuffer[this.ringBufferIndex][0] = (double) this.rotationYaw; + this.ringBuffer[this.ringBufferIndex][1] = this.posY; + double d0; + double d1; + double d2; + double d10; + float f12; + + if (this.worldObj.isRemote) { + if (this.newPosRotationIncrements > 0) { + d10 = this.posX + (this.newPosX - this.posX) / (double) this.newPosRotationIncrements; + d0 = this.posY + (this.newPosY - this.posY) / (double) this.newPosRotationIncrements; + d1 = this.posZ + (this.newPosZ - this.posZ) / (double) this.newPosRotationIncrements; + d2 = MathHelper.wrapAngleTo180_double(this.newRotationYaw - (double) this.rotationYaw); + this.rotationYaw = (float) ((double) this.rotationYaw + d2 / (double) this.newPosRotationIncrements); + this.rotationPitch = (float) ((double) this.rotationPitch + (this.newRotationPitch - (double) this.rotationPitch) / (double) this.newPosRotationIncrements); + --this.newPosRotationIncrements; + this.setPosition(d10, d0, d1); + this.setRotation(this.rotationYaw, this.rotationPitch); + } + } else { + d10 = this.targetX - this.posX; + d0 = this.targetY - this.posY; + d1 = this.targetZ - this.posZ; + d2 = d10 * d10 + d0 * d0 + d1 * d1; + + if (this.target != null) { + this.targetX = this.target.posX; + this.targetZ = this.target.posZ; + double d3 = this.targetX - this.posX; + double d5 = this.targetZ - this.posZ; + double d7 = Math.sqrt(d3 * d3 + d5 * d5); + double d8 = 0.4000000059604645D + d7 / 80.0D - 1.0D; + + if (d8 > 10.0D) { + d8 = 10.0D; + } + + this.targetY = this.target.boundingBox.minY + d8; + } else { + this.targetX += this.rand.nextGaussian() * 2.0D; + this.targetZ += this.rand.nextGaussian() * 2.0D; + } + + if (this.forceNewTarget || d2 < 100.0D || d2 > 22500.0D || this.isCollidedHorizontally || this.isCollidedVertically) { + this.setNewTarget(); + } + + d0 /= (double) MathHelper.sqrt_double(d10 * d10 + d1 * d1); + if (isUber) f12 = 1.0F;//Verticle Motion Speed + else f12 = 0.6F; + + if (d0 < (double) (-f12)) { + d0 = (double) (-f12); + } + + if (d0 > (double) f12) { + d0 = (double) f12; + } + + this.motionY += d0 * 0.10000000149011612D; + this.rotationYaw = MathHelper.wrapAngleTo180_float(this.rotationYaw); + double d4 = 180.0D - Math.atan2(d10, d1) * 180.0D / Math.PI; + double d6 = MathHelper.wrapAngleTo180_double(d4 - (double) this.rotationYaw); + + if (d6 > 50.0D) { + d6 = 50.0D; + } + + if (d6 < -50.0D) { + d6 = -50.0D; + } + + Vec3 vec3 = Vec3.createVectorHelper(this.targetX - this.posX, this.targetY - this.posY, this.targetZ - this.posZ).normalize(); + Vec3 vec32 = Vec3.createVectorHelper((double) MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F), this.motionY, (double) (-MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F))).normalize(); + float f5 = (float) (vec32.dotProduct(vec3) + 0.5D) / 1.5F; + + if (f5 < 0.0F) { + f5 = 0.0F; + } + + this.randomYawVelocity *= 0.8F; + float f6 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0F + 1.0F; + double d9 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0D + 1.0D; + + if (d9 > 40.0D) { + d9 = 40.0D; + } + + this.randomYawVelocity = (float) ((double) this.randomYawVelocity + d6 * (0.699999988079071D / d9 / (double) f6)); + this.rotationYaw += this.randomYawVelocity * 0.1F; + float f7 = (float) (2.0D / (d9 + 1.0D)); + float f8 = 0.06F; + this.moveFlying(0.0F, -1.0F, f8 * (f5 * f7 + (1.0F - f7))); + + if (this.slowed) { + this.moveEntity(this.motionX * 0.800000011920929D, this.motionY * 0.800000011920929D, this.motionZ * 0.800000011920929D); + } else if (isUber) { + this.moveEntity(this.motionX * 2.5D, this.motionY * 1.5D, this.motionZ * 2.5D); + } else { + this.moveEntity(this.motionX, this.motionY, this.motionZ); + } + + Vec3 vec31 = Vec3.createVectorHelper(this.motionX, this.motionY, this.motionZ).normalize(); + float f9 = (float) (vec31.dotProduct(vec32) + 1.0D) / 2.0F; + f9 = 0.8F + 0.15F * f9; + this.motionX *= (double) f9; + this.motionZ *= (double) f9; + this.motionY *= 0.9100000262260437D; + } + + this.renderYawOffset = this.rotationYaw; + this.dragonPartHead.width = this.dragonPartHead.height = 3.0F; + this.dragonPartTail1.width = this.dragonPartTail1.height = 2.0F; + this.dragonPartTail2.width = this.dragonPartTail2.height = 2.0F; + this.dragonPartTail3.width = this.dragonPartTail3.height = 2.0F; + this.dragonPartBody.height = 3.0F; + this.dragonPartBody.width = 5.0F; + this.dragonPartWing1.height = 2.0F; + this.dragonPartWing1.width = 4.0F; + this.dragonPartWing2.height = 3.0F; + this.dragonPartWing2.width = 4.0F; + f1 = (float) (this.getMovementOffsets(5, 1.0F)[1] - this.getMovementOffsets(10, 1.0F)[1]) * 10.0F / 180.0F * (float) Math.PI; + f2 = MathHelper.cos(f1); + float f10 = -MathHelper.sin(f1); + float f3 = this.rotationYaw * (float) Math.PI / 180.0F; + float f11 = MathHelper.sin(f3); + float f4 = MathHelper.cos(f3); + this.dragonPartBody.onUpdate(); + this.dragonPartBody.setLocationAndAngles(this.posX + (double) (f11 * 0.5F), this.posY, this.posZ - (double) (f4 * 0.5F), 0.0F, 0.0F); + this.dragonPartWing1.onUpdate(); + this.dragonPartWing1.setLocationAndAngles(this.posX + (double) (f4 * 4.5F), this.posY + 2.0D, this.posZ + (double) (f11 * 4.5F), 0.0F, 0.0F); + this.dragonPartWing2.onUpdate(); + this.dragonPartWing2.setLocationAndAngles(this.posX - (double) (f4 * 4.5F), this.posY + 2.0D, this.posZ - (double) (f11 * 4.5F), 0.0F, 0.0F); + + if (!this.worldObj.isRemote && this.hurtTime == 0) { + this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing1.boundingBox.expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D))); + this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing2.boundingBox.expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D))); + this.attackEntitiesInList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartHead.boundingBox.expand(1.0D, 1.0D, 1.0D))); + } + + double[] adouble1 = this.getMovementOffsets(5, 1.0F); + double[] adouble = this.getMovementOffsets(0, 1.0F); + f12 = MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F - this.randomYawVelocity * 0.01F); + float f13 = MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F - this.randomYawVelocity * 0.01F); + this.dragonPartHead.onUpdate(); + this.dragonPartHead.setLocationAndAngles(this.posX + (double) (f12 * 5.5F * f2), this.posY + (adouble[1] - adouble1[1]) * 1.0D + (double) (f10 * 5.5F), this.posZ - (double) (f13 * 5.5F * f2), 0.0F, 0.0F); + + for (int j = 0; j < 3; ++j) { + EntityDragonPart entitydragonpart = null; + + if (j == 0) { + entitydragonpart = this.dragonPartTail1; + } + + if (j == 1) { + entitydragonpart = this.dragonPartTail2; + } + + if (j == 2) { + entitydragonpart = this.dragonPartTail3; + } + + double[] adouble2 = this.getMovementOffsets(12 + j * 2, 1.0F); + float f14 = this.rotationYaw * (float) Math.PI / 180.0F + this.simplifyAngle(adouble2[0] - adouble1[0]) * (float) Math.PI / 180.0F * 1.0F; + float f15 = MathHelper.sin(f14); + float f16 = MathHelper.cos(f14); + float f17 = 1.5F; + float f18 = (float) (j + 1) * 2.0F; + entitydragonpart.onUpdate(); + entitydragonpart.setLocationAndAngles(this.posX - (double) ((f11 * f17 + f15 * f18) * f2), this.posY + (adouble2[1] - adouble1[1]) * 1.0D - (double) ((f18 + f17) * f10) + 1.5D, this.posZ + (double) ((f4 * f17 + f16 * f18) * f2), 0.0F, 0.0F); + } + + if (!this.worldObj.isRemote) { + this.slowed = this.destroyBlocksInAABB(this.dragonPartHead.boundingBox) | this.destroyBlocksInAABB(this.dragonPartBody.boundingBox); + } + } + + } + + @Override + protected void onDeathUpdate() { + + + if (deathTicks == 0 && !isUber) { + for (int ix = -150; ix < 150; ix++) { + for (int iz = -150; iz < 150; iz++) { + if (worldObj.getBlock(ix, portalY, iz) == Blocks.bedrock && worldObj.getBlock(ix, portalY - 1, iz) == Blocks.bedrock) { + portalX = ix; + portalZ = iz; + createPortal = false; + break; + } + } + } + if (ConfigHandler.dragonEggSpawnLocation[0] != 0 || ConfigHandler.dragonEggSpawnLocation[1] != 0 || ConfigHandler.dragonEggSpawnLocation[1] != 0) { + createPortal = false; + portalX = ConfigHandler.dragonEggSpawnLocation[0]; + portalY = ConfigHandler.dragonEggSpawnLocation[1]; + portalZ = ConfigHandler.dragonEggSpawnLocation[2]; + } + } + + ++this.deathTicks; + + if (worldObj.rand.nextInt(5) == 2) { + EntityLightningBolt bolt = new EntityLightningBolt(worldObj, portalX, portalY + 1, portalZ); + bolt.ignoreFrustumCheck = true; + worldObj.addWeatherEffect(bolt); + } + + if (this.deathTicks >= 180 && this.deathTicks <= 200) { + float f = (this.rand.nextFloat() - 0.5F) * 8.0F; + float f1 = (this.rand.nextFloat() - 0.5F) * 4.0F; + float f2 = (this.rand.nextFloat() - 0.5F) * 8.0F; + this.worldObj.spawnParticle("hugeexplosion", this.posX + (double) f, this.posY + 2.0D + (double) f1, this.posZ + (double) f2, 0.0D, 0.0D, 0.0D); + } + + int i; + int j; + + if (!this.worldObj.isRemote) { + if (this.deathTicks > 150 && this.deathTicks % 5 == 0) { + i = 1000; + + while (i > 0) { + j = EntityXPOrb.getXPSplit(i); + i -= j; + this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); + } + } + } else if (this.deathTicks == 1) { + this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.enderdragon.end", 50.0F, 1F, false); + //this.worldObj.playBroadcastSound(1018, (int) this.posX, (int) this.posY, (int) this.posZ, 0); + } + + this.moveEntity(0.0D, 0.10000000149011612D, 0.0D); + this.renderYawOffset = this.rotationYaw += 20.0F; + + if (this.deathTicks == 200 && !this.worldObj.isRemote) { + i = 2000; + + while (i > 0) { + j = EntityXPOrb.getXPSplit(i); + i -= j; + this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); + } + + spawnEgg(); + setDead(); + } + } + + private void collideWithEntities(List par1List) { + double d0 = (this.dragonPartBody.boundingBox.minX + this.dragonPartBody.boundingBox.maxX) / 2.0D; + double d1 = (this.dragonPartBody.boundingBox.minZ + this.dragonPartBody.boundingBox.maxZ) / 2.0D; + Iterator iterator = par1List.iterator(); + + while (iterator.hasNext()) { + Entity entity = (Entity) iterator.next(); + + if (entity instanceof EntityLivingBase) { + double d2 = entity.posX - d0; + double d3 = entity.posZ - d1; + double d4 = d2 * d2 + d3 * d3; + if (rand.nextInt(isUber ? 3 : 10) == 0) + entity.addVelocity(d2 / d4 * 8.0D, 5.20000000298023224D, d3 / d4 * 8.0D); + entity.velocityChanged = true; + ((EntityLivingBase) entity).setLastAttacker(this); + } + if (entity instanceof EntityLivingBase && isUber) { + ((EntityLivingBase) entity).setLastAttacker(this); + entity.attackEntityFrom(new DamageSourceChaos(this), 20F); + } + } + } + + private void attackEntitiesInList(List par1List) { + for (int i = 0; i < par1List.size(); ++i) { + Entity entity = (Entity) par1List.get(i); + + if (entity instanceof EntityLivingBase && !isUber) { + ((EntityLivingBase) entity).setLastAttacker(this); + entity.attackEntityFrom(DamageSource.causeMobDamage(this), attackDamage); + } + if (entity instanceof EntityLivingBase && isUber) { + ((EntityLivingBase) entity).setLastAttacker(this); + entity.attackEntityFrom(new DamageSourceChaos(this), 50F); + } + } + } + + private void updateDragonEnderCrystal() { + if (this.healingEnderCrystal != null) { + if (this.healingEnderCrystal.isDead) { + if (!this.worldObj.isRemote) { + this.attackEntityFromPart(this.dragonPartHead, DamageSource.setExplosionSource((Explosion) null), 10.0F); + } + + this.healingEnderCrystal = null; + } else if (this.ticksExisted % 10 == 0 && this.getHealth() < this.getMaxHealth()) { + if (isUber) this.setHealth(this.getHealth() + 10.0F); + else this.setHealth(this.getHealth() + 1.0F); + } + } + + if (this.rand.nextInt(10) == 0) { + float f = 32.0F; + List list = this.worldObj.getEntitiesWithinAABB(EntityEnderCrystal.class, this.boundingBox.expand((double) f, (double) f, (double) f)); + EntityEnderCrystal entityendercrystal = null; + double d0 = Double.MAX_VALUE; + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) { + EntityEnderCrystal entityendercrystal1 = (EntityEnderCrystal) iterator.next(); + double d1 = entityendercrystal1.getDistanceSqToEntity(this); + + if (d1 < d0) { + d0 = d1; + entityendercrystal = entityendercrystal1; + } + } + + this.healingEnderCrystal = entityendercrystal; + } + } + + private void setNewTarget() { + this.forceNewTarget = false; + + if ((isUber || this.rand.nextInt(2) == 0) && (!isUber || 19 > this.rand.nextInt(20)) && !this.worldObj.playerEntities.isEmpty()) { + this.target = (Entity) this.worldObj.playerEntities.get(this.rand.nextInt(this.worldObj.playerEntities.size())); + } else { + boolean flag = false; + + do { + this.targetX = portalX; + this.targetY = (double) (70.0F + this.rand.nextFloat() * 50.0F); + this.targetZ = portalZ; + this.targetX += (double) (this.rand.nextFloat() * 120.0F - 60.0F); + this.targetZ += (double) (this.rand.nextFloat() * 120.0F - 60.0F); + double d0 = this.posX - this.targetX; + double d1 = this.posY - this.targetY; + double d2 = this.posZ - this.targetZ; + flag = d0 * d0 + d1 * d1 + d2 * d2 > 100.0D; + } while (!flag); + + this.target = null; + } + } + + private float simplifyAngle(double par1) { + return (float) MathHelper.wrapAngleTo180_double(par1); + } + + private boolean destroyBlocksInAABB(AxisAlignedBB par1AxisAlignedBB) { + if (!ConfigHandler.dragonBreaksBlocks) return false; + + int i = MathHelper.floor_double(par1AxisAlignedBB.minX); + int j = MathHelper.floor_double(par1AxisAlignedBB.minY); + int k = MathHelper.floor_double(par1AxisAlignedBB.minZ); + int l = MathHelper.floor_double(par1AxisAlignedBB.maxX); + int i1 = MathHelper.floor_double(par1AxisAlignedBB.maxY); + int j1 = MathHelper.floor_double(par1AxisAlignedBB.maxZ); + boolean flag = false; + boolean flag1 = false; + + for (int k1 = i; k1 <= l; ++k1) { + for (int l1 = j; l1 <= i1; ++l1) { + for (int i2 = k; i2 <= j1; ++i2) { + Block block = this.worldObj.getBlock(k1, l1, i2); + + if (!block.isAir(worldObj, k1, l1, i2)) { + if (block.canEntityDestroy(worldObj, k1, l1, i2, this) && this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")) { + flag1 = this.worldObj.setBlockToAir(k1, l1, i2) || flag1; + } else { + flag = true; + } + } + } + } + } + + if (flag1) { + double d1 = par1AxisAlignedBB.minX + (par1AxisAlignedBB.maxX - par1AxisAlignedBB.minX) * (double) this.rand.nextFloat(); + double d2 = par1AxisAlignedBB.minY + (par1AxisAlignedBB.maxY - par1AxisAlignedBB.minY) * (double) this.rand.nextFloat(); + double d0 = par1AxisAlignedBB.minZ + (par1AxisAlignedBB.maxZ - par1AxisAlignedBB.minZ) * (double) this.rand.nextFloat(); + this.worldObj.spawnParticle("largeexplode", d1, d2, d0, 0.0D, 0.0D, 0.0D); + } + + return flag; + } + + private void spawnEgg() { + if (ConfigHandler.dragonEggSpawnLocation[0] != 0 || ConfigHandler.dragonEggSpawnLocation[1] != 0 || ConfigHandler.dragonEggSpawnLocation[1] != 0 && !isUber) { + portalX = ConfigHandler.dragonEggSpawnLocation[0]; + portalY = ConfigHandler.dragonEggSpawnLocation[1]; + portalZ = ConfigHandler.dragonEggSpawnLocation[2]; + } + + BlockEndPortal.field_149948_a = true; + + if (createPortal || isUber) { + createEnderPortal(portalX, portalZ); + } + LogHelper.info("spawn egg"); + if (worldObj.getBlock(portalX, portalY + 1, portalZ) == Blocks.air) { + worldObj.setBlock(portalX, portalY + 1, portalZ, Blocks.dragon_egg); + LogHelper.info("spawn egg2 " + portalX + " " + portalY + " " + portalZ); + } else { + for (int i = portalY + 1; i < 250; i++) { + if (worldObj.getBlock(portalX, i, portalZ) == Blocks.air) { + worldObj.setBlock(portalX, i, portalZ, Blocks.dragon_egg); + LogHelper.info("spawn egg3"); + break; + } + } + } + + for (int iX = portalX - 2; iX <= portalX + 2; iX++) { + for (int iZ = portalZ - 2; iZ <= portalZ + 2; iZ++) { + + if (worldObj.getBlock(iX, portalY - 4, iZ) == Blocks.bedrock && !(iX == portalX && iZ == portalZ)) { + worldObj.setBlock(iX, portalY - 3, iZ, Blocks.end_portal); + } + } + } + + + worldObj.setBlock(portalX - 1, portalY - 1, portalZ, Blocks.torch); + worldObj.setBlock(portalX + 1, portalY - 1, portalZ, Blocks.torch); + worldObj.setBlock(portalX, portalY - 1, portalZ - 1, Blocks.torch); + worldObj.setBlock(portalX, portalY - 1, portalZ + 1, Blocks.torch); + + + BlockEndPortal.field_149948_a = false; + } + + private void createEnderPortal(int par1, int par2) { + int b0 = portalY - 3; + byte b1 = 4; + + for (int k = b0 - 1; k <= b0 + 32; ++k) { + for (int l = par1 - b1; l <= par1 + b1; ++l) { + for (int i1 = par2 - b1; i1 <= par2 + b1; ++i1) { + double d0 = (double) (l - par1); + double d1 = (double) (i1 - par2); + double d2 = d0 * d0 + d1 * d1; + + if (d2 <= ((double) b1 - 0.5D) * ((double) b1 - 0.5D)) { + if (k < b0) { + if (d2 <= ((double) (b1 - 1) - 0.5D) * ((double) (b1 - 1) - 0.5D)) { + this.worldObj.setBlock(l, k, i1, Blocks.bedrock); + } + } else if (k > b0) { + this.worldObj.setBlock(l, k, i1, Blocks.air); + } else if (d2 > ((double) (b1 - 1) - 0.5D) * ((double) (b1 - 1) - 0.5D)) { + this.worldObj.setBlock(l, k, i1, Blocks.bedrock); + } + } + } + } + } + + this.worldObj.setBlock(par1, b0 + 0, par2, Blocks.bedrock); + this.worldObj.setBlock(par1, b0 + 1, par2, Blocks.bedrock); + this.worldObj.setBlock(par1, b0 + 2, par2, Blocks.bedrock); + this.worldObj.setBlock(par1, b0 + 3, par2, Blocks.bedrock); + } + + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setFloat("AttackDamage", attackDamage); + compound.setBoolean("IsUber", isUber); + compound.setBoolean("Initialized", initialized); + if (isUber) { + compound.setInteger("PortalX", portalX); + compound.setInteger("PortalY", portalY); + compound.setInteger("PortalZ", portalZ); + } + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + attackDamage = compound.getFloat("AttackDamage"); + isUber = compound.getBoolean("IsUber"); + initialized = compound.getBoolean("Initialized"); + this.dataWatcher.updateObject(12, isUber ? (byte) 1 : (byte) 0); + if (isUber) { + portalX = compound.getInteger("PortalX"); + portalY = compound.getInteger("PortalY"); + portalZ = compound.getInteger("PortalZ"); + } + } + + @Override + protected boolean canDespawn() { + return false; + } + + @Override + protected void despawnEntity() { + + } + + public void setUber(boolean b) { + isUber = b; + this.dataWatcher.updateObject(12, b ? (byte) 1 : (byte) 0); + } + + public boolean getIsUber() { + return isUber; + } + + @Override + public boolean attackEntityFrom(DamageSource damageSource, float dmg) { // if (damageSource.getEntity() != null && getDistanceToEntity(damageSource.getEntity()) > 100) { // LogHelper.info("cancel attack"); // return false; // } - return super.attackEntityFrom(damageSource, dmg); - } + return super.attackEntityFrom(damageSource, dmg); + } - @Override - public boolean attackEntityFromPart(EntityDragonPart p_70965_1_, DamageSource damageSource, float p_70965_3_) { + @Override + public boolean attackEntityFromPart(EntityDragonPart p_70965_1_, DamageSource damageSource, float p_70965_3_) { // if (damageSource.getEntity() != null && Utills.getDistanceAtoB(damageSource.getEntity().posX)getDistanceToEntity(damageSource.getEntity()) > 100) { // LogHelper.info("cancel attack"); // return false; // } - return super.attackEntityFromPart(p_70965_1_, damageSource, p_70965_3_); - } + return super.attackEntityFromPart(p_70965_1_, damageSource, p_70965_3_); + } - @Override - public void travelToDimension(int p_71027_1_) {} + @Override + public void travelToDimension(int p_71027_1_) { + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityDraconicArrow.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityDraconicArrow.java index 68ed6359..3bff0ad0 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityDraconicArrow.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityDraconicArrow.java @@ -24,471 +24,452 @@ import net.minecraft.world.World; import java.util.List; public class EntityDraconicArrow extends EntityArrow { - private int blockX = -1; - private int blockY = -1; - private int blockZ = -1; - private Block blockHit; - private int inData; - private boolean inGround; - private int ticksInGround; - private int ticksInAir; - private double damage = 2.0D; - /** The amount of knockback an arrow applies when it hits a mob. */ - private int knockbackStrength; - public boolean ignorSpeed = false; - public boolean explosive = false; - - public EntityDraconicArrow(World p_i1753_1_) - { - super(p_i1753_1_); - } - - public EntityDraconicArrow(World p_i1754_1_, double p_i1754_2_, double p_i1754_4_, double p_i1754_6_) - { - super(p_i1754_1_, p_i1754_2_, p_i1754_4_, p_i1754_6_); - } - - public EntityDraconicArrow(World p_i1755_1_, EntityLivingBase p_i1755_2_, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_) - { - super(p_i1755_1_, p_i1755_2_, p_i1755_3_, p_i1755_4_, p_i1755_5_); - } - - public EntityDraconicArrow(World par1World, EntityLivingBase par2EntityLivingBase, float par3) { - super(par1World, par2EntityLivingBase, par3); - } - - @Override - protected void entityInit() - { - super.entityInit(); - //this.dataWatcher.addObject(16, Byte.valueOf((byte) 0)); - } - - @Override - public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) - { - float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5); - par1 /= f2; - par3 /= f2; - par5 /= f2; - par1 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8; - par3 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8; - par5 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8; - par1 *= par7; - par3 *= par7; - par5 *= par7; - this.motionX = par1; - this.motionY = par3; - this.motionZ = par5; - float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); - this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, f3) * 180.0D / Math.PI); - this.ticksInGround = 0; - } - - @Override - @SideOnly(Side.CLIENT) - public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) - { - this.setPosition(par1, par3, par5); - this.setRotation(par7, par8); - } - - @Override - @SideOnly(Side.CLIENT) - public void setVelocity(double par1, double par3, double par5) - { - this.motionX = par1; - this.motionY = par3; - this.motionZ = par5; - - if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { - float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5); - this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, f) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch; - this.prevRotationYaw = this.rotationYaw; - this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); - this.ticksInGround = 0; - } - } - - @SuppressWarnings("rawtypes") - @Override - public void onUpdate() - { - //super.onUpdate(); - super.onEntityUpdate(); - if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { - float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D / Math.PI); - } - - Block block = this.worldObj.getBlock(this.blockX, this.blockY, this.blockZ); - - if (block.getMaterial() != Material.air) { - if (explosive) { - worldObj.createExplosion(this.shootingEntity, this.prevPosX, this.prevPosY, this.prevPosZ, 4, ConfigHandler.bowBlockDamage); - this.setDead(); - return; - } - block.setBlockBoundsBasedOnState(this.worldObj, this.blockX, this.blockY, this.blockZ); - AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.blockX, this.blockY, this.blockZ); - - if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) { - this.inGround = true; - } - } - - if (this.arrowShake > 0) { - --this.arrowShake; - } - - if (this.inGround) { - int j = this.worldObj.getBlockMetadata(this.blockX, this.blockY, this.blockZ); - - if (block == this.blockHit && j == this.inData) { - ++this.ticksInGround; - - if (this.ticksInGround == 1200) { - this.setDead(); - } - } else { - 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.ticksInGround = 0; - this.ticksInAir = 0; - } - } else { - ++this.ticksInAir; - Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); - Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false); - vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); - vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - - if (movingobjectposition != null) { - vec3 = 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; - int i; - float f1; - - for (i = 0; i < list.size(); ++i) { - Entity entity1 = (Entity) list.get(i); - - if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) { - f1 = 0.3F; - AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f1, f1, f1); - MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); - - if (movingobjectposition1 != null) { - double d1 = vec31.distanceTo(movingobjectposition1.hitVec); - - if (d1 < d0 || d0 == 0.0D) { - entity = entity1; - d0 = d1; - } - } - } - } - - if (entity != null) { - movingobjectposition = new MovingObjectPosition(entity); - } - - if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) { - EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit; - - if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) { - movingobjectposition = null; - } - } - - float f2; - float f4; - - if (movingobjectposition != null) { - if (movingobjectposition.entityHit != null) { - if (explosive) { - //world.createExplosion(this.shootingEntity, movingobjectposition.entityHit.posX, movingobjectposition.entityHit.posY, movingobjectposition.entityHit.posZ, 6, false); - //movingobjectposition.entityHit.hurtResistantTime = 0; - worldObj.createExplosion(this.shootingEntity, movingobjectposition.entityHit.posX, movingobjectposition.entityHit.posY, movingobjectposition.entityHit.posZ, 4, ConfigHandler.bowBlockDamage); - this.setDead(); - } - int k; - if (!ignorSpeed) { - f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); - k = MathHelper.ceiling_double_int(f2 * this.damage); - - if (this.getIsCritical()) { - k += this.rand.nextInt(k / 2 + 2); - } - } else { - k = (int) this.damage; - if (this.getIsCritical()) { - k += this.rand.nextInt(k / 2 + 2); - } - } - - DamageSource damagesource = null; - - if (this.shootingEntity == null) { - damagesource = DamageSource.causeArrowDamage(this, this); - } else { - damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity); - } - if (movingobjectposition.entityHit instanceof EntityEnderman) - damagesource = DamageSource.magic; - - if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) { - movingobjectposition.entityHit.setFire(5); - } - - movingobjectposition.entityHit.hurtResistantTime = 0; - if (movingobjectposition.entityHit instanceof EntityDragonPart && ((EntityDragonPart)movingobjectposition.entityHit).entityDragonObj instanceof EntityDragon) - { - ((EntityDragon)((EntityDragonPart)movingobjectposition.entityHit).entityDragonObj).hurtResistantTime = 0; - } - - if (movingobjectposition.entityHit.attackEntityFrom(damagesource, k)) { - if (movingobjectposition.entityHit instanceof EntityLivingBase) { - EntityLivingBase entitylivingbase = (EntityLivingBase) movingobjectposition.entityHit; - - if (!this.worldObj.isRemote) { - entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1); - } - - if (this.knockbackStrength > 0) { - f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - - if (f4 > 0.0F) { - movingobjectposition.entityHit.addVelocity(this.motionX * this.knockbackStrength * 0.6000000238418579D / f4, 0.1D, this.motionZ * this.knockbackStrength * 0.6000000238418579D / f4); - } - } - - if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase) { - EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity); - EnchantmentHelper.func_151385_b((EntityLivingBase) this.shootingEntity, entitylivingbase); - } - - if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) { - ((EntityPlayerMP) this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F)); - } - } - - this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); - - // if (!(movingobjectposition.entityHit instanceof EntityEnderman)) - //{ - this.setDead(); - //} - } else { - this.motionX *= -0.10000000149011612D; - this.motionY *= -0.10000000149011612D; - this.motionZ *= -0.10000000149011612D; - this.rotationYaw += 180.0F; - this.prevRotationYaw += 180.0F; - this.ticksInAir = 0; - } - } else { - this.blockX = movingobjectposition.blockX; - this.blockY = movingobjectposition.blockY; - this.blockZ = movingobjectposition.blockZ; - block = this.worldObj.getBlock(this.blockX, this.blockY, this.blockZ); - this.blockHit = block; - this.inData = this.worldObj.getBlockMetadata(this.blockX, this.blockY, this.blockZ); - this.motionX = ((float) (movingobjectposition.hitVec.xCoord - this.posX)); - this.motionY = ((float) (movingobjectposition.hitVec.yCoord - this.posY)); - this.motionZ = ((float) (movingobjectposition.hitVec.zCoord - this.posZ)); - f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); - this.posX -= this.motionX / f2 * 0.05000000074505806D; - this.posY -= this.motionY / f2 * 0.05000000074505806D; - this.posZ -= this.motionZ / f2 * 0.05000000074505806D; - this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); - this.inGround = true; - this.arrowShake = 7; - - if (this.blockHit.getMaterial() != Material.air) { - this.blockHit.onEntityCollidedWithBlock(this.worldObj, this.blockX, this.blockY, this.blockZ, this); - } - } - } - - if (this.getIsCritical()) { - for (i = 0; i < 4; ++i) { - this.worldObj.spawnParticle("crit", this.posX + this.motionX * i / 4.0D, this.posY + this.motionY * i / 4.0D, this.posZ + this.motionZ * i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ); - } - } - - this.posX += this.motionX; - this.posY += this.motionY; - this.posZ += this.motionZ; - f2 = 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, f2) * 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; - float f3 = 0.99F; - f1 = 0.05F; - - if (this.isInWater()) { - for (int l = 0; l < 4; ++l) { - f4 = 0.25F; - this.worldObj.spawnParticle("bubble", this.posX - this.motionX * f4, this.posY - this.motionY * f4, this.posZ - this.motionZ * f4, this.motionX, this.motionY, this.motionZ); - } - - f3 = 0.8F; - } - - if (this.isWet()) { - this.extinguish(); - } - - this.motionX *= f3; - this.motionY *= f3; - this.motionZ *= f3; - this.motionY -= f1; - this.setPosition(this.posX, this.posY, this.posZ); - this.func_145775_I(); - } - } - - @Override - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) - { - par1NBTTagCompound.setShort("xTile", (short) this.blockX); - par1NBTTagCompound.setShort("yTile", (short) this.blockY); - par1NBTTagCompound.setShort("zTile", (short) this.blockZ); - par1NBTTagCompound.setShort("life", (short) this.ticksInGround); - par1NBTTagCompound.setByte("inTile", (byte) Block.getIdFromBlock(this.blockHit)); - par1NBTTagCompound.setByte("inData", (byte) this.inData); - par1NBTTagCompound.setByte("shake", (byte) this.arrowShake); - par1NBTTagCompound.setByte("inGround", (byte) (this.inGround ? 1 : 0)); - par1NBTTagCompound.setByte("pickup", (byte) this.canBePickedUp); - par1NBTTagCompound.setDouble("damage", this.damage); - //par1NBTTagCompound.setString("shooter", getShooter() instanceof EntityPlayer ? ((EntityPlayer) getShooter()).getCommandSenderName() : ""); - } - - @Override - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) - { - this.blockX = par1NBTTagCompound.getShort("xTile"); - this.blockY = par1NBTTagCompound.getShort("yTile"); - this.blockZ = par1NBTTagCompound.getShort("zTile"); - this.ticksInGround = par1NBTTagCompound.getShort("life"); - this.blockHit = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255); - this.inData = par1NBTTagCompound.getByte("inData") & 255; - this.arrowShake = par1NBTTagCompound.getByte("shake") & 255; - this.inGround = par1NBTTagCompound.getByte("inGround") == 1; - //dataWatcher.updateObject(SHOOTER_DATAWATCHER_INDEX, par1NBTTagCompound.hasKey("shooter") ? par1NBTTagCompound.getString("shooter") : ""); - - if (par1NBTTagCompound.hasKey("damage", 99)) { - this.damage = par1NBTTagCompound.getDouble("damage"); - } - - if (par1NBTTagCompound.hasKey("pickup", 99)) { - this.canBePickedUp = par1NBTTagCompound.getByte("pickup"); - } else if (par1NBTTagCompound.hasKey("player", 99)) { - this.canBePickedUp = par1NBTTagCompound.getBoolean("player") ? 1 : 0; - } - } - - @Override - public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) - { - if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) { - - boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode; - - if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Items.arrow, 1))) { - flag = false; - } - - if (flag) { - this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); - par1EntityPlayer.onItemPickup(this, 1); - this.setDead(); - } - } - } - - @Override - protected boolean canTriggerWalking() - { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public float getShadowSize() - { - return 0.0F; - } - - @Override - public void setDamage(double par1) - { - this.damage = par1; - } - - @Override - public double getDamage() - { - return this.damage; - } - - @Override - public void setKnockbackStrength(int par1) - { - this.knockbackStrength = par1; - } - - @Override - public boolean canAttackWithItem() - { - return false; - } - - @Override - public void setIsCritical(boolean par1) - { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - - if (par1) { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 1))); - } else { - this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -2))); - } - } - - @Override - public boolean getIsCritical() - { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - return (b0 & 1) != 0; - } + private int blockX = -1; + private int blockY = -1; + private int blockZ = -1; + private Block blockHit; + private int inData; + private boolean inGround; + private int ticksInGround; + private int ticksInAir; + private double damage = 2.0D; + /** + * The amount of knockback an arrow applies when it hits a mob. + */ + private int knockbackStrength; + public boolean ignorSpeed = false; + public boolean explosive = false; + + public EntityDraconicArrow(World p_i1753_1_) { + super(p_i1753_1_); + } + + public EntityDraconicArrow(World p_i1754_1_, double p_i1754_2_, double p_i1754_4_, double p_i1754_6_) { + super(p_i1754_1_, p_i1754_2_, p_i1754_4_, p_i1754_6_); + } + + public EntityDraconicArrow(World p_i1755_1_, EntityLivingBase p_i1755_2_, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_) { + super(p_i1755_1_, p_i1755_2_, p_i1755_3_, p_i1755_4_, p_i1755_5_); + } + + public EntityDraconicArrow(World par1World, EntityLivingBase par2EntityLivingBase, float par3) { + super(par1World, par2EntityLivingBase, par3); + } + + @Override + protected void entityInit() { + super.entityInit(); + //this.dataWatcher.addObject(16, Byte.valueOf((byte) 0)); + } + + @Override + public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) { + float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5); + par1 /= f2; + par3 /= f2; + par5 /= f2; + par1 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8; + par3 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8; + par5 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8; + par1 *= par7; + par3 *= par7; + par5 *= par7; + this.motionX = par1; + this.motionY = par3; + this.motionZ = par5; + float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); + this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, f3) * 180.0D / Math.PI); + this.ticksInGround = 0; + } + + @Override + @SideOnly(Side.CLIENT) + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) { + this.setPosition(par1, par3, par5); + this.setRotation(par7, par8); + } + + @Override + @SideOnly(Side.CLIENT) + public void setVelocity(double par1, double par3, double par5) { + this.motionX = par1; + this.motionY = par3; + this.motionZ = par5; + + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { + float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5); + this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, f) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch; + this.prevRotationYaw = this.rotationYaw; + this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); + this.ticksInGround = 0; + } + } + + @SuppressWarnings("rawtypes") + @Override + public void onUpdate() { + //super.onUpdate(); + super.onEntityUpdate(); + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { + float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D / Math.PI); + } + + Block block = this.worldObj.getBlock(this.blockX, this.blockY, this.blockZ); + + if (block.getMaterial() != Material.air) { + if (explosive) { + worldObj.createExplosion(this.shootingEntity, this.prevPosX, this.prevPosY, this.prevPosZ, 4, ConfigHandler.bowBlockDamage); + this.setDead(); + return; + } + block.setBlockBoundsBasedOnState(this.worldObj, this.blockX, this.blockY, this.blockZ); + AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.blockX, this.blockY, this.blockZ); + + if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) { + this.inGround = true; + } + } + + if (this.arrowShake > 0) { + --this.arrowShake; + } + + if (this.inGround) { + int j = this.worldObj.getBlockMetadata(this.blockX, this.blockY, this.blockZ); + + if (block == this.blockHit && j == this.inData) { + ++this.ticksInGround; + + if (this.ticksInGround == 1200) { + this.setDead(); + } + } else { + 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.ticksInGround = 0; + this.ticksInAir = 0; + } + } else { + ++this.ticksInAir; + Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false); + vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + + if (movingobjectposition != null) { + vec3 = 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; + int i; + float f1; + + for (i = 0; i < list.size(); ++i) { + Entity entity1 = (Entity) list.get(i); + + if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) { + f1 = 0.3F; + AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f1, f1, f1); + MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); + + if (movingobjectposition1 != null) { + double d1 = vec31.distanceTo(movingobjectposition1.hitVec); + + if (d1 < d0 || d0 == 0.0D) { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) { + movingobjectposition = new MovingObjectPosition(entity); + } + + if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) { + EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit; + + if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) { + movingobjectposition = null; + } + } + + float f2; + float f4; + + if (movingobjectposition != null) { + if (movingobjectposition.entityHit != null) { + if (explosive) { + //world.createExplosion(this.shootingEntity, movingobjectposition.entityHit.posX, movingobjectposition.entityHit.posY, movingobjectposition.entityHit.posZ, 6, false); + //movingobjectposition.entityHit.hurtResistantTime = 0; + worldObj.createExplosion(this.shootingEntity, movingobjectposition.entityHit.posX, movingobjectposition.entityHit.posY, movingobjectposition.entityHit.posZ, 4, ConfigHandler.bowBlockDamage); + this.setDead(); + } + int k; + if (!ignorSpeed) { + f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + k = MathHelper.ceiling_double_int(f2 * this.damage); + + if (this.getIsCritical()) { + k += this.rand.nextInt(k / 2 + 2); + } + } else { + k = (int) this.damage; + if (this.getIsCritical()) { + k += this.rand.nextInt(k / 2 + 2); + } + } + + DamageSource damagesource = null; + + if (this.shootingEntity == null) { + damagesource = DamageSource.causeArrowDamage(this, this); + } else { + damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity); + } + if (movingobjectposition.entityHit instanceof EntityEnderman) damagesource = DamageSource.magic; + + if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) { + movingobjectposition.entityHit.setFire(5); + } + + movingobjectposition.entityHit.hurtResistantTime = 0; + if (movingobjectposition.entityHit instanceof EntityDragonPart && ((EntityDragonPart) movingobjectposition.entityHit).entityDragonObj instanceof EntityDragon) { + ((EntityDragon) ((EntityDragonPart) movingobjectposition.entityHit).entityDragonObj).hurtResistantTime = 0; + } + + if (movingobjectposition.entityHit.attackEntityFrom(damagesource, k)) { + if (movingobjectposition.entityHit instanceof EntityLivingBase) { + EntityLivingBase entitylivingbase = (EntityLivingBase) movingobjectposition.entityHit; + + if (!this.worldObj.isRemote) { + entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1); + } + + if (this.knockbackStrength > 0) { + f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + + if (f4 > 0.0F) { + movingobjectposition.entityHit.addVelocity(this.motionX * this.knockbackStrength * 0.6000000238418579D / f4, 0.1D, this.motionZ * this.knockbackStrength * 0.6000000238418579D / f4); + } + } + + if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase) { + EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity); + EnchantmentHelper.func_151385_b((EntityLivingBase) this.shootingEntity, entitylivingbase); + } + + if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) { + ((EntityPlayerMP) this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F)); + } + } + + this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + + // if (!(movingobjectposition.entityHit instanceof EntityEnderman)) + //{ + this.setDead(); + //} + } else { + this.motionX *= -0.10000000149011612D; + this.motionY *= -0.10000000149011612D; + this.motionZ *= -0.10000000149011612D; + this.rotationYaw += 180.0F; + this.prevRotationYaw += 180.0F; + this.ticksInAir = 0; + } + } else { + this.blockX = movingobjectposition.blockX; + this.blockY = movingobjectposition.blockY; + this.blockZ = movingobjectposition.blockZ; + block = this.worldObj.getBlock(this.blockX, this.blockY, this.blockZ); + this.blockHit = block; + this.inData = this.worldObj.getBlockMetadata(this.blockX, this.blockY, this.blockZ); + this.motionX = ((float) (movingobjectposition.hitVec.xCoord - this.posX)); + this.motionY = ((float) (movingobjectposition.hitVec.yCoord - this.posY)); + this.motionZ = ((float) (movingobjectposition.hitVec.zCoord - this.posZ)); + f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + this.posX -= this.motionX / f2 * 0.05000000074505806D; + this.posY -= this.motionY / f2 * 0.05000000074505806D; + this.posZ -= this.motionZ / f2 * 0.05000000074505806D; + this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + this.inGround = true; + this.arrowShake = 7; + + if (this.blockHit.getMaterial() != Material.air) { + this.blockHit.onEntityCollidedWithBlock(this.worldObj, this.blockX, this.blockY, this.blockZ, this); + } + } + } + + if (this.getIsCritical()) { + for (i = 0; i < 4; ++i) { + this.worldObj.spawnParticle("crit", this.posX + this.motionX * i / 4.0D, this.posY + this.motionY * i / 4.0D, this.posZ + this.motionZ * i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ); + } + } + + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + f2 = 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, f2) * 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; + float f3 = 0.99F; + f1 = 0.05F; + + if (this.isInWater()) { + for (int l = 0; l < 4; ++l) { + f4 = 0.25F; + this.worldObj.spawnParticle("bubble", this.posX - this.motionX * f4, this.posY - this.motionY * f4, this.posZ - this.motionZ * f4, this.motionX, this.motionY, this.motionZ); + } + + f3 = 0.8F; + } + + if (this.isWet()) { + this.extinguish(); + } + + this.motionX *= f3; + this.motionY *= f3; + this.motionZ *= f3; + this.motionY -= f1; + this.setPosition(this.posX, this.posY, this.posZ); + this.func_145775_I(); + } + } + + @Override + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { + par1NBTTagCompound.setShort("xTile", (short) this.blockX); + par1NBTTagCompound.setShort("yTile", (short) this.blockY); + par1NBTTagCompound.setShort("zTile", (short) this.blockZ); + par1NBTTagCompound.setShort("life", (short) this.ticksInGround); + par1NBTTagCompound.setByte("inTile", (byte) Block.getIdFromBlock(this.blockHit)); + par1NBTTagCompound.setByte("inData", (byte) this.inData); + par1NBTTagCompound.setByte("shake", (byte) this.arrowShake); + par1NBTTagCompound.setByte("inGround", (byte) (this.inGround ? 1 : 0)); + par1NBTTagCompound.setByte("pickup", (byte) this.canBePickedUp); + par1NBTTagCompound.setDouble("damage", this.damage); + //par1NBTTagCompound.setString("shooter", getShooter() instanceof EntityPlayer ? ((EntityPlayer) getShooter()).getCommandSenderName() : ""); + } + + @Override + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { + this.blockX = par1NBTTagCompound.getShort("xTile"); + this.blockY = par1NBTTagCompound.getShort("yTile"); + this.blockZ = par1NBTTagCompound.getShort("zTile"); + this.ticksInGround = par1NBTTagCompound.getShort("life"); + this.blockHit = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255); + this.inData = par1NBTTagCompound.getByte("inData") & 255; + this.arrowShake = par1NBTTagCompound.getByte("shake") & 255; + this.inGround = par1NBTTagCompound.getByte("inGround") == 1; + //dataWatcher.updateObject(SHOOTER_DATAWATCHER_INDEX, par1NBTTagCompound.hasKey("shooter") ? par1NBTTagCompound.getString("shooter") : ""); + + if (par1NBTTagCompound.hasKey("damage", 99)) { + this.damage = par1NBTTagCompound.getDouble("damage"); + } + + if (par1NBTTagCompound.hasKey("pickup", 99)) { + this.canBePickedUp = par1NBTTagCompound.getByte("pickup"); + } else if (par1NBTTagCompound.hasKey("player", 99)) { + this.canBePickedUp = par1NBTTagCompound.getBoolean("player") ? 1 : 0; + } + } + + @Override + public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) { + if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) { + + boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode; + + if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Items.arrow, 1))) { + flag = false; + } + + if (flag) { + this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + par1EntityPlayer.onItemPickup(this, 1); + this.setDead(); + } + } + } + + @Override + protected boolean canTriggerWalking() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public float getShadowSize() { + return 0.0F; + } + + @Override + public void setDamage(double par1) { + this.damage = par1; + } + + @Override + public double getDamage() { + return this.damage; + } + + @Override + public void setKnockbackStrength(int par1) { + this.knockbackStrength = par1; + } + + @Override + public boolean canAttackWithItem() { + return false; + } + + @Override + public void setIsCritical(boolean par1) { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + + if (par1) { + this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 1))); + } else { + this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -2))); + } + } + + @Override + public boolean getIsCritical() { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + return (b0 & 1) != 0; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityDragonHeart.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityDragonHeart.java index a916068f..c9cb65a8 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityDragonHeart.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityDragonHeart.java @@ -27,247 +27,243 @@ import java.util.List; */ public class EntityDragonHeart extends Entity { - public int age = 0; - public float rotation = 0f; - public float rotationInc = 0.5f; - public int opPhase = 0; - private double yStop; - private int coresConsumed = 0; - private List blocks = new ArrayList(); + public int age = 0; + public float rotation = 0f; + public float rotationInc = 0.5f; + public int opPhase = 0; + private double yStop; + private int coresConsumed = 0; + private List blocks = new ArrayList(); - public EntityDragonHeart(World world) - { - super(world); - this.setSize(0.25F, 0.25F); - } + public EntityDragonHeart(World world) { + super(world); + this.setSize(0.25F, 0.25F); + } - public EntityDragonHeart(World par1World, double x, double y, double z) { - super(par1World); - this.setPosition(x, y, z); - this.motionX = 0; - this.motionY = 0; - this.motionZ = 0; - this.setSize(0.25F, 0.25F); - this.yStop = y + 1.5D; - } + public EntityDragonHeart(World par1World, double x, double y, double z) { + super(par1World); + this.setPosition(x, y, z); + this.motionX = 0; + this.motionY = 0; + this.motionZ = 0; + this.setSize(0.25F, 0.25F); + this.yStop = y + 1.5D; + } - @Override - protected void entityInit() { - renderDistanceWeight = 10; - getDataWatcher().addObject(11, (float) yStop); - getDataWatcher().addObject(12, rotationInc); - getDataWatcher().addObject(13, coresConsumed); - getDataWatcher().addObject(14, opPhase); - } + @Override + protected void entityInit() { + renderDistanceWeight = 10; + getDataWatcher().addObject(11, (float) yStop); + getDataWatcher().addObject(12, rotationInc); + getDataWatcher().addObject(13, coresConsumed); + getDataWatcher().addObject(14, opPhase); + } - @Override - public boolean attackEntityFrom(DamageSource damageSource, float dmg) { - return false; - } + @Override + public boolean attackEntityFrom(DamageSource damageSource, float dmg) { + return false; + } - @Override - public void onUpdate() { + @Override + public void onUpdate() { - if(!worldObj.isRemote)getDataWatcher().updateObject(14, opPhase); - if(!worldObj.isRemote)getDataWatcher().updateObject(13, coresConsumed); - if(!worldObj.isRemote)getDataWatcher().updateObject(12, rotationInc); - if(!worldObj.isRemote)getDataWatcher().updateObject(11, (float)yStop); - yStop = getDataWatcher().getWatchableObjectFloat(11); - rotationInc = getDataWatcher().getWatchableObjectFloat(12); - coresConsumed = getDataWatcher().getWatchableObjectInt(13); - opPhase = getDataWatcher().getWatchableObjectInt(14); - motionX = 0; - motionZ = 0; - motionY = 0; + if (!worldObj.isRemote) getDataWatcher().updateObject(14, opPhase); + if (!worldObj.isRemote) getDataWatcher().updateObject(13, coresConsumed); + if (!worldObj.isRemote) getDataWatcher().updateObject(12, rotationInc); + if (!worldObj.isRemote) getDataWatcher().updateObject(11, (float) yStop); + yStop = getDataWatcher().getWatchableObjectFloat(11); + rotationInc = getDataWatcher().getWatchableObjectFloat(12); + coresConsumed = getDataWatcher().getWatchableObjectInt(13); + opPhase = getDataWatcher().getWatchableObjectInt(14); + motionX = 0; + motionZ = 0; + motionY = 0; - age++; - rotation += rotationInc; - super.onUpdate(); + age++; + rotation += rotationInc; + super.onUpdate(); - switch (opPhase) { - case 0: { //Rises with particle ring - motionY = 0.01f; - rotationInc+=0.1f; - if (posY > yStop){ - opPhase = 1; - motionY = 0f; - } - break; - } - case 1: { //Particle ring retracts - opPhase = 2; - break; - } - case 2: { //Particle field accepting items - if (coresConsumed == 16 || age > 1240) { - age = 1240; - opPhase = 3; - if (coresConsumed < 4){ - EntityPersistentItem item = new EntityPersistentItem(worldObj, posX, posY, posZ, new ItemStack(ModItems.dragonHeart)); - item.motionX = 0; - item.motionY = 0; - item.motionZ = 0; - item.delayBeforeCanPickup = 0; - if (!worldObj.isRemote) worldObj.spawnEntityInWorld(item); - this.worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); - this.setDead(); - } - break; - } - @SuppressWarnings("unchecked") - List items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(posX-5, posY-5, posZ-5, posX+5, posY+5, posZ+5)); - for (EntityItem item : items){ - ItemStack stack = item.getEntityItem(); - if (Utills.getDistanceAtoB(posX, posY + 0.5, posZ, item.posX, item.posY, item.posZ) < 1) { - if (coresConsumed == 16 || worldObj.isRemote) break; - if (stack.getItem() != ModItems.draconicCore) { - item.motionX=1; - item.motionY=6; - item.motionZ=1; - continue; - } - int needed = 16 - coresConsumed; - if (stack.stackSize >= needed) { - coresConsumed = 16; - stack.stackSize -= needed; - } else { - coresConsumed += stack.stackSize; - stack.stackSize = 0; - item.setDead(); - } - this.worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); - } - else{ - item.motionX = ((posX - item.posX))*0.1; - item.motionY = ((posY+0.5 - item.posY))*0.1; - item.motionZ = ((posZ - item.posZ))*0.1; - } - } - break; - } - case 3: { - rotationInc += 0.2f; - int maxBlocks = coresConsumed/4; - if(age % 10 == 0){ - blocks = new ArrayList(); - for (int x = (int)posX-5; x <= (int)posX+5; x++){ - for (int y = (int)posY-5; y <= (int)posY+5; y++){ - for (int z = (int)posZ-5; z <= (int)posZ+5; z++){ - if (worldObj.getBlock(x, y, z) instanceof DraconiumBlock && worldObj.getBlockMetadata(x, y, z) == 2){ - TileLocation block = new TileLocation(x, y, z); - if (!blocks.contains(block) && blocks.size() < maxBlocks) blocks.add(block); - } - } - } - } - } - if (age > 1600) opPhase = 4; - break; - } - case 4:{ - if (blocks.size() == 0){ - if (!worldObj.isRemote) { - EntityPersistentItem item = new EntityPersistentItem(worldObj, posX, posY, posZ, new ItemStack(ModItems.dragonHeart)); - item.motionX = 0; - item.motionY = 0; - item.motionZ = 0; - item.delayBeforeCanPickup = 0; - worldObj.spawnEntityInWorld(item); - } - this.worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); - this.setDead(); - break; - } - for (TileLocation tile : blocks) { - if (!worldObj.isRemote) worldObj.setBlock(tile.getXCoord(), tile.getYCoord(), tile.getZCoord(), ModBlocks.draconicBlock, 0, 2); - worldObj.createExplosion(null, tile.getXCoord(), tile.getYCoord(), tile.getZCoord(), 4, false); - } - worldObj.createExplosion(null, posX, posY, posZ, 4, false); - this.setDead(); - } - } + switch (opPhase) { + case 0: { //Rises with particle ring + motionY = 0.01f; + rotationInc += 0.1f; + if (posY > yStop) { + opPhase = 1; + motionY = 0f; + } + break; + } + case 1: { //Particle ring retracts + opPhase = 2; + break; + } + case 2: { //Particle field accepting items + if (coresConsumed == 16 || age > 1240) { + age = 1240; + opPhase = 3; + if (coresConsumed < 4) { + EntityPersistentItem item = new EntityPersistentItem(worldObj, posX, posY, posZ, new ItemStack(ModItems.dragonHeart)); + item.motionX = 0; + item.motionY = 0; + item.motionZ = 0; + item.delayBeforeCanPickup = 0; + if (!worldObj.isRemote) worldObj.spawnEntityInWorld(item); + this.worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + this.setDead(); + } + break; + } + @SuppressWarnings("unchecked") List items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(posX - 5, posY - 5, posZ - 5, posX + 5, posY + 5, posZ + 5)); + for (EntityItem item : items) { + ItemStack stack = item.getEntityItem(); + if (Utills.getDistanceAtoB(posX, posY + 0.5, posZ, item.posX, item.posY, item.posZ) < 1) { + if (coresConsumed == 16 || worldObj.isRemote) break; + if (stack.getItem() != ModItems.draconicCore) { + item.motionX = 1; + item.motionY = 6; + item.motionZ = 1; + continue; + } + int needed = 16 - coresConsumed; + if (stack.stackSize >= needed) { + coresConsumed = 16; + stack.stackSize -= needed; + } else { + coresConsumed += stack.stackSize; + stack.stackSize = 0; + item.setDead(); + } + this.worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + } else { + item.motionX = ((posX - item.posX)) * 0.1; + item.motionY = ((posY + 0.5 - item.posY)) * 0.1; + item.motionZ = ((posZ - item.posZ)) * 0.1; + } + } + break; + } + case 3: { + rotationInc += 0.2f; + int maxBlocks = coresConsumed / 4; + if (age % 10 == 0) { + blocks = new ArrayList(); + for (int x = (int) posX - 5; x <= (int) posX + 5; x++) { + for (int y = (int) posY - 5; y <= (int) posY + 5; y++) { + for (int z = (int) posZ - 5; z <= (int) posZ + 5; z++) { + if (worldObj.getBlock(x, y, z) instanceof DraconiumBlock && worldObj.getBlockMetadata(x, y, z) == 2) { + TileLocation block = new TileLocation(x, y, z); + if (!blocks.contains(block) && blocks.size() < maxBlocks) blocks.add(block); + } + } + } + } + } + if (age > 1600) opPhase = 4; + break; + } + case 4: { + if (blocks.size() == 0) { + if (!worldObj.isRemote) { + EntityPersistentItem item = new EntityPersistentItem(worldObj, posX, posY, posZ, new ItemStack(ModItems.dragonHeart)); + item.motionX = 0; + item.motionY = 0; + item.motionZ = 0; + item.delayBeforeCanPickup = 0; + worldObj.spawnEntityInWorld(item); + } + this.worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + this.setDead(); + break; + } + for (TileLocation tile : blocks) { + if (!worldObj.isRemote) + worldObj.setBlock(tile.getXCoord(), tile.getYCoord(), tile.getZCoord(), ModBlocks.draconicBlock, 0, 2); + worldObj.createExplosion(null, tile.getXCoord(), tile.getYCoord(), tile.getZCoord(), 4, false); + } + worldObj.createExplosion(null, posX, posY, posZ, 4, false); + this.setDead(); + } + } - if (worldObj.isRemote) spawnParticles(); - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - this.moveEntity(this.motionX, this.motionY, this.motionZ); + if (worldObj.isRemote) spawnParticles(); + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.moveEntity(this.motionX, this.motionY, this.motionZ); - } + } - @SideOnly(Side.CLIENT) - private void spawnParticles(){ - if (opPhase == 0){ - double correctY = posY + 0.5; - for (int i = 0; i < 10; i++) { - int nextFloat = rand.nextInt(); - double offsetX = Math.sin(nextFloat); - double offsetZ = Math.cos(nextFloat); - EntityFX particle = new Particles.AdvancedSeekerParticle(worldObj, posX + offsetX, correctY, posZ + offsetZ, posX, correctY, posZ, 1, 1f, 1f, 1f, 10); - ParticleHandler.spawnCustomParticle(particle, 64); - } - } - if (opPhase == 1){ - double correctY = posY + 0.5; - for (int i = 0; i < 100; i++) { - int nextFloat = rand.nextInt(); - double offsetX = Math.sin(nextFloat); - double offsetZ = Math.cos(nextFloat); - EntityFX particle = new Particles.AdvancedSeekerParticle(worldObj, posX + offsetX, correctY, posZ + offsetZ, posX, correctY, posZ, 3, 1f, 1f, 1f, 100, -100); - ParticleHandler.spawnCustomParticle(particle, 64); - } - } - if (opPhase == 2){ - double correctY = posY + 0.5; - for (int i = 0; i < 10; i++) { - int nextFloat = rand.nextInt(); - double offsetX = Math.sin(nextFloat)*(rand.nextFloat()*10); - double offsetZ = Math.cos(nextFloat)*(rand.nextFloat()*10); - EntityFX particle = new Particles.AdvancedSeekerParticle(worldObj, posX + offsetX, correctY, posZ + offsetZ, posX, correctY, posZ, 3, 1f, 1f, 1f, 100, -100); - ParticleHandler.spawnCustomParticle(particle, 64); - } - } - if (opPhase == 3){ + @SideOnly(Side.CLIENT) + private void spawnParticles() { + if (opPhase == 0) { + double correctY = posY + 0.5; + for (int i = 0; i < 10; i++) { + int nextFloat = rand.nextInt(); + double offsetX = Math.sin(nextFloat); + double offsetZ = Math.cos(nextFloat); + EntityFX particle = new Particles.AdvancedSeekerParticle(worldObj, posX + offsetX, correctY, posZ + offsetZ, posX, correctY, posZ, 1, 1f, 1f, 1f, 10); + ParticleHandler.spawnCustomParticle(particle, 64); + } + } + if (opPhase == 1) { + double correctY = posY + 0.5; + for (int i = 0; i < 100; i++) { + int nextFloat = rand.nextInt(); + double offsetX = Math.sin(nextFloat); + double offsetZ = Math.cos(nextFloat); + EntityFX particle = new Particles.AdvancedSeekerParticle(worldObj, posX + offsetX, correctY, posZ + offsetZ, posX, correctY, posZ, 3, 1f, 1f, 1f, 100, -100); + ParticleHandler.spawnCustomParticle(particle, 64); + } + } + if (opPhase == 2) { + double correctY = posY + 0.5; + for (int i = 0; i < 10; i++) { + int nextFloat = rand.nextInt(); + double offsetX = Math.sin(nextFloat) * (rand.nextFloat() * 10); + double offsetZ = Math.cos(nextFloat) * (rand.nextFloat() * 10); + EntityFX particle = new Particles.AdvancedSeekerParticle(worldObj, posX + offsetX, correctY, posZ + offsetZ, posX, correctY, posZ, 3, 1f, 1f, 1f, 100, -100); + ParticleHandler.spawnCustomParticle(particle, 64); + } + } + if (opPhase == 3) { - float colourMod = (float)(age-1240)/360f; - double correctY = posY + 0.5; - int nextFloat = rand.nextInt(); - double offsetX = Math.sin(nextFloat)*(rand.nextFloat()*10); - double offsetZ = Math.cos(nextFloat)*(rand.nextFloat()*10); - EntityFX particle = new Particles.AdvancedSeekerParticle(worldObj, posX, correctY, posZ, posX + offsetX, correctY, posZ + offsetZ, 3, 1f, 1f-colourMod, 1f-colourMod, 100, -100); - ParticleHandler.spawnCustomParticle(particle, 64); + float colourMod = (float) (age - 1240) / 360f; + double correctY = posY + 0.5; + int nextFloat = rand.nextInt(); + double offsetX = Math.sin(nextFloat) * (rand.nextFloat() * 10); + double offsetZ = Math.cos(nextFloat) * (rand.nextFloat() * 10); + EntityFX particle = new Particles.AdvancedSeekerParticle(worldObj, posX, correctY, posZ, posX + offsetX, correctY, posZ + offsetZ, 3, 1f, 1f - colourMod, 1f - colourMod, 100, -100); + ParticleHandler.spawnCustomParticle(particle, 64); - for (TileLocation tile : blocks){ - particle = new Particles.AdvancedSeekerParticle(worldObj, posX, correctY, posZ, tile.getXCoord()+rand.nextDouble(), tile.getYCoord()+rand.nextDouble(), tile.getZCoord()+rand.nextDouble(), 3, 1f, 1f-(colourMod*0.5f), 1f-colourMod, 100, -100); - ParticleHandler.spawnCustomParticle(particle, 64); - } + for (TileLocation tile : blocks) { + particle = new Particles.AdvancedSeekerParticle(worldObj, posX, correctY, posZ, tile.getXCoord() + rand.nextDouble(), tile.getYCoord() + rand.nextDouble(), tile.getZCoord() + rand.nextDouble(), 3, 1f, 1f - (colourMod * 0.5f), 1f - colourMod, 100, -100); + ParticleHandler.spawnCustomParticle(particle, 64); + } - } - } + } + } - @Override - public void onCollideWithPlayer(EntityPlayer player) { - if (age < 2000) { - age = 2000; - opPhase = 2; - } - } + @Override + public void onCollideWithPlayer(EntityPlayer player) { + if (age < 2000) { + age = 2000; + opPhase = 2; + } + } - @Override - public void writeEntityToNBT(NBTTagCompound compound) - { - compound.setInteger("Age", age); - compound.setInteger("Phase", opPhase); - compound.setFloat("RotationSpeed", rotationInc); - } + @Override + public void writeEntityToNBT(NBTTagCompound compound) { + compound.setInteger("Age", age); + compound.setInteger("Phase", opPhase); + compound.setFloat("RotationSpeed", rotationInc); + } - @Override - public void readEntityFromNBT(NBTTagCompound compound) - { - age = compound.getInteger("Age"); - opPhase = compound.getInteger("Phase"); - rotationInc = compound.getFloat("RotationSpeed"); - } + @Override + public void readEntityFromNBT(NBTTagCompound compound) { + age = compound.getInteger("Age"); + opPhase = compound.getInteger("Phase"); + rotationInc = compound.getFloat("RotationSpeed"); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityDragonProjectile.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityDragonProjectile.java index dc5af6b8..ad9d64a0 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityDragonProjectile.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityDragonProjectile.java @@ -28,321 +28,349 @@ import java.util.List; */ public class EntityDragonProjectile extends Entity { - public int type = 0; - public EntityLivingBase target; - public Entity shooter; - public float power; - public boolean isChaser; - private double lastTickTargetDistance = 100; - private float heath = 5F; - private DamageSource damageFireball = new DamageSource("de.GuardianFireball").setDamageAllowedInCreativeMode().setMagicDamage().setExplosion(); - private DamageSource damageEnergy = new DamageSource("de.GuardianEnergyBall").setDamageAllowedInCreativeMode().setDamageBypassesArmor(); - private DamageSource damageChaos = new DamageSource("de.GuardianChaosBall").setDamageAllowedInCreativeMode().setDamageBypassesArmor().setDamageIsAbsolute(); + public int type = 0; + public EntityLivingBase target; + public Entity shooter; + public float power; + public boolean isChaser; + private double lastTickTargetDistance = 100; + private float heath = 5F; + private DamageSource damageFireball = new DamageSource("de.GuardianFireball").setDamageAllowedInCreativeMode().setMagicDamage().setExplosion(); + private DamageSource damageEnergy = new DamageSource("de.GuardianEnergyBall").setDamageAllowedInCreativeMode().setDamageBypassesArmor(); + private DamageSource damageChaos = new DamageSource("de.GuardianChaosBall").setDamageAllowedInCreativeMode().setDamageBypassesArmor().setDamageIsAbsolute(); - //public static final int FIREBALL = 0; /** Generic fireball a lot more powerful then ghast fireball */ - public static final int FIREBOMB = 1; /** Large fireball with a trail and large fiery AOE */ - public static final int TELEPORT = 2; /** Ender pearl which teleports the player away if it hits. */ - public static final int FIRE_CHASER = 3; /** Fireball that chases the player it is fired at (Explodes on impact with blocks) */ - public static final int ENERGY_CHASER = 4; /** Energy gall that chases the player. (Can pass through blocks) */ - public static final int CHAOS_CHASER = 5; /** Chases player. On impact splits into mini chaos charges which lock on to other or the same player (can pass through blocks) */ - public static final int MINI_CHAOS_CHASER = 6; /** ^ */ - public static final int IGNITION_CHARGE = 7; /** Reignites Crystals */ + //public static final int FIREBALL = 0; /** Generic fireball a lot more powerful then ghast fireball */ + public static final int FIREBOMB = 1; + /** + * Large fireball with a trail and large fiery AOE + */ + public static final int TELEPORT = 2; + /** + * Ender pearl which teleports the player away if it hits. + */ + public static final int FIRE_CHASER = 3; + /** + * Fireball that chases the player it is fired at (Explodes on impact with blocks) + */ + public static final int ENERGY_CHASER = 4; + /** + * Energy gall that chases the player. (Can pass through blocks) + */ + public static final int CHAOS_CHASER = 5; + /** + * Chases player. On impact splits into mini chaos charges which lock on to other or the same player (can pass through blocks) + */ + public static final int MINI_CHAOS_CHASER = 6; + /** + * ^ + */ + public static final int IGNITION_CHARGE = 7; - public EntityDragonProjectile(World world){ - this(world, 0, null, 10, null); - } + /** + * Reignites Crystals + */ - public EntityDragonProjectile(World world, int type, EntityLivingBase target, float power, Entity shooter) { - super(world); - this.type = type; - this.target = target; - this.shooter = shooter; - this.power = power; - this.isChaser = type == FIRE_CHASER || type == ENERGY_CHASER || type == CHAOS_CHASER || type == MINI_CHAOS_CHASER || type == IGNITION_CHARGE; - this.setSize(1F, 1F); + public EntityDragonProjectile(World world) { + this(world, 0, null, 10, null); + } - if (shooter != null){ - worldObj.playSoundEffect(shooter.posX + 0.5D, shooter.posY + 0.5D, shooter.posZ + 0.5D, "mob.ghast.fireball", 10.0F, rand.nextFloat() * 0.3F + 0.85F); + public EntityDragonProjectile(World world, int type, EntityLivingBase target, float power, Entity shooter) { + super(world); + this.type = type; + this.target = target; + this.shooter = shooter; + this.power = power; + this.isChaser = type == FIRE_CHASER || type == ENERGY_CHASER || type == CHAOS_CHASER || type == MINI_CHAOS_CHASER || type == IGNITION_CHARGE; + this.setSize(1F, 1F); - this.rotationYaw = shooter instanceof EntityDragon ? shooter.rotationYaw + 180F : shooter.rotationYaw; - this.rotationPitch = shooter.rotationPitch; - if (type == FIREBOMB || type == TELEPORT){ - rotationPitch += (rand.nextFloat() - 0.5F) * 20F; - rotationYaw += (rand.nextFloat() - 0.5F) * 20F; - } - this.yOffset = 0.0F; - this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); - this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); - this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI)); - double speed = 5; - this.motionX *= speed; - this.motionY *= speed; - this.motionZ *= speed; - } - } + if (shooter != null) { + worldObj.playSoundEffect(shooter.posX + 0.5D, shooter.posY + 0.5D, shooter.posZ + 0.5D, "mob.ghast.fireball", 10.0F, rand.nextFloat() * 0.3F + 0.85F); - @SideOnly(Side.CLIENT) - public boolean isInRangeToRenderDist(double p_70112_1_) - { - double d1 = this.boundingBox.getAverageEdgeLength() * 80.0D; - d1 *= 64.0D; - return p_70112_1_ < d1 * d1; - } + this.rotationYaw = shooter instanceof EntityDragon ? shooter.rotationYaw + 180F : shooter.rotationYaw; + this.rotationPitch = shooter.rotationPitch; + if (type == FIREBOMB || type == TELEPORT) { + rotationPitch += (rand.nextFloat() - 0.5F) * 20F; + rotationYaw += (rand.nextFloat() - 0.5F) * 20F; + } + this.yOffset = 0.0F; + this.motionX = (double) (-MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI)); + this.motionZ = (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI)); + this.motionY = (double) (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI)); + double speed = 5; + this.motionX *= speed; + this.motionY *= speed; + this.motionZ *= speed; + } + } - @Override - protected void entityInit() { - if (type == ENERGY_CHASER || type == CHAOS_CHASER || type == MINI_CHAOS_CHASER || type == IGNITION_CHARGE || worldObj.isRemote) noClip = true; - dataWatcher.addObject(10, (byte) type); + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double p_70112_1_) { + double d1 = this.boundingBox.getAverageEdgeLength() * 80.0D; + d1 *= 64.0D; + return p_70112_1_ < d1 * d1; + } - } + @Override + protected void entityInit() { + if (type == ENERGY_CHASER || type == CHAOS_CHASER || type == MINI_CHAOS_CHASER || type == IGNITION_CHARGE || worldObj.isRemote) + noClip = true; + dataWatcher.addObject(10, (byte) type); - @Override - public void onUpdate() { - super.onUpdate(); - if (!worldObj.isRemote && ticksExisted == 1) dataWatcher.updateObject(10, (byte)type); - if (worldObj.isRemote) { - if (type == 0) type = dataWatcher.getWatchableObjectByte(10); - spawnParticle(); - } + } - //Check that there is still a target available and if not kills the projectile. - if (target == null){ - if (worldObj.getClosestPlayer(posX, posY, posZ, 60) != null) target = worldObj.getClosestPlayer(posX, posY, posZ, 60); - else { - if (!worldObj.isRemote)setDead(); - return; - } - } + @Override + public void onUpdate() { + super.onUpdate(); + if (!worldObj.isRemote && ticksExisted == 1) dataWatcher.updateObject(10, (byte) type); + if (worldObj.isRemote) { + if (type == 0) type = dataWatcher.getWatchableObjectByte(10); + spawnParticle(); + } - if (isChaser && !worldObj.isRemote){ - double tDist = Utills.getDistanceAtoB(target.posX, target.posY, target.posZ, posX, posY, posZ); - if (tDist <= 0) tDist = 0.1; + //Check that there is still a target available and if not kills the projectile. + if (target == null) { + if (worldObj.getClosestPlayer(posX, posY, posZ, 60) != null) + target = worldObj.getClosestPlayer(posX, posY, posZ, 60); + else { + if (!worldObj.isRemote) setDead(); + return; + } + } - double x = (target.posX - posX) / tDist; - double y = (target.posY - posY - -1) / tDist; - double z = (target.posZ - posZ) / tDist; - double speed = type == CHAOS_CHASER ? 0.15D : 0.1D; + if (isChaser && !worldObj.isRemote) { + double tDist = Utills.getDistanceAtoB(target.posX, target.posY, target.posZ, posX, posY, posZ); + if (tDist <= 0) tDist = 0.1; - motionX /= 1.1; - motionY /= 1.1; - motionZ /= 1.1; + double x = (target.posX - posX) / tDist; + double y = (target.posY - posY - -1) / tDist; + double z = (target.posZ - posZ) / tDist; + double speed = type == CHAOS_CHASER ? 0.15D : 0.1D; - motionX += x * speed; - motionY += y * speed; - motionZ += z * speed; - } - moveEntity(motionX, motionY, motionZ); - checkTargetCondition(); - } + motionX /= 1.1; + motionY /= 1.1; + motionZ /= 1.1; - private boolean checkTargetCondition(){ - if (worldObj.isRemote) return false; + motionX += x * speed; + motionY += y * speed; + motionZ += z * speed; + } + moveEntity(motionX, motionY, motionZ); + checkTargetCondition(); + } - double targetDistance = Utills.getDistanceAtoB(posX, posY, posZ, target.posX, target.posY, target.posZ); + private boolean checkTargetCondition() { + if (worldObj.isRemote) return false; - Entity entityHit = getHitEntity(); - if (entityHit instanceof EntityDragonPart) entityHit = null; + double targetDistance = Utills.getDistanceAtoB(posX, posY, posZ, target.posX, target.posY, target.posZ); - boolean genericHit = entityHit != null || targetDistance <= 1; + Entity entityHit = getHitEntity(); + if (entityHit instanceof EntityDragonPart) entityHit = null; - switch (type){ - case FIREBOMB: - if (genericHit || (targetDistance > lastTickTargetDistance && targetDistance < power) || isCollided || ticksExisted > 600 || heath <= 0){ - setDead(); - worldObj.newExplosion(shooter, this.posX, this.posY, this.posZ, 2F, true, true); - damageEntitiesInRadius(damageFireball, power, power*2); - } - break; - case TELEPORT: - if (genericHit){ - setDead(); - Entity hit = entityHit != null ? entityHit : target; - if (!(hit instanceof EntityPlayer)) break; - int r = rand.nextInt(); - if (shooter != null) new Teleporter.TeleportLocation(shooter.posX + (Math.cos(r) * 600), rand.nextInt(255), shooter.posZ + (Math.sin(r) * 600), hit.dimension).sendEntityToCoords(hit); - else new Teleporter.TeleportLocation(posX + (Math.cos(r) * 600), rand.nextInt(255), posZ + (Math.sin(r) * 600), hit.dimension).sendEntityToCoords(hit); + boolean genericHit = entityHit != null || targetDistance <= 1; - hit.attackEntityFrom(DamageSource.fall, 10F); + switch (type) { + case FIREBOMB: + if (genericHit || (targetDistance > lastTickTargetDistance && targetDistance < power) || isCollided || ticksExisted > 600 || heath <= 0) { + setDead(); + worldObj.newExplosion(shooter, this.posX, this.posY, this.posZ, 2F, true, true); + damageEntitiesInRadius(damageFireball, power, power * 2); + } + break; + case TELEPORT: + if (genericHit) { + setDead(); + Entity hit = entityHit != null ? entityHit : target; + if (!(hit instanceof EntityPlayer)) break; + int r = rand.nextInt(); + if (shooter != null) + new Teleporter.TeleportLocation(shooter.posX + (Math.cos(r) * 600), rand.nextInt(255), shooter.posZ + (Math.sin(r) * 600), hit.dimension).sendEntityToCoords(hit); + else + new Teleporter.TeleportLocation(posX + (Math.cos(r) * 600), rand.nextInt(255), posZ + (Math.sin(r) * 600), hit.dimension).sendEntityToCoords(hit); - }else if (isCollided || ticksExisted > 400 || heath <= 0) setDead(); - break; - case FIRE_CHASER: - noClip = ticksExisted < 60; - if (genericHit || (targetDistance > lastTickTargetDistance && targetDistance < power/2) || (isCollided && ticksExisted > 60) || ticksExisted > 400 || heath <= 0){ - setDead(); - worldObj.newExplosion(shooter, this.posX, this.posY, this.posZ, 2F, true, true); - damageEntitiesInRadius(damageFireball, power, power * 2); - } - break; - case ENERGY_CHASER: - if (genericHit || (targetDistance > lastTickTargetDistance && targetDistance < power) || ticksExisted > 800 || heath <= 0){ - setDead(); - DraconicEvolution.network.sendToAllAround(new GenericParticlePacket(GenericParticlePacket.ENERGY_BALL_KILL, posX, posY, posZ), new NetworkRegistry.TargetPoint(dimension, posX, posY, posZ, 128)); - damageEntitiesInRadius(damageEnergy, power, power * 3); - worldObj.playSoundEffect(posX, posY, posZ, "random.explode", 4.0F, (1.0F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F); - } - break; - case CHAOS_CHASER: + hit.attackEntityFrom(DamageSource.fall, 10F); - if (genericHit || (targetDistance > lastTickTargetDistance && targetDistance < power) || ticksExisted > 800 || heath <= 0){ - setDead(); - DraconicEvolution.network.sendToAllAround(new GenericParticlePacket(GenericParticlePacket.CHAOS_BALL_KILL, posX, posY, posZ), new NetworkRegistry.TargetPoint(dimension, posX, posY, posZ, 128)); - damageEntitiesInRadius(damageChaos, power, power * 3); - worldObj.playSoundEffect(posX, posY, posZ, "random.explode", 4.0F, (1.0F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F); - int i = 3 + rand.nextInt(3); - EntityDragonProjectile newProjectile; - @SuppressWarnings("unchecked") - List list = worldObj.getEntitiesWithinAABBExcludingEntity(shooter, boundingBox.expand(60, 60, 60), Utills.selectPlayer); - for (i=i; i > 0; i--){ - newProjectile = new EntityDragonProjectile(worldObj, MINI_CHAOS_CHASER, list.size() > 0 ? list.get(rand.nextInt(list.size())) : null, power/2F, shooter); - newProjectile.motionY = 0; - int randDir = rand.nextInt(); - double speed = 1 + rand.nextDouble() * 5; - newProjectile.motionX = Math.sin(randDir) * speed; - newProjectile.motionZ = Math.cos(randDir) * speed; - newProjectile.setPosition(posX, posY, posZ); - worldObj.spawnEntityInWorld(newProjectile); - } - } + } else if (isCollided || ticksExisted > 400 || heath <= 0) setDead(); + break; + case FIRE_CHASER: + noClip = ticksExisted < 60; + if (genericHit || (targetDistance > lastTickTargetDistance && targetDistance < power / 2) || (isCollided && ticksExisted > 60) || ticksExisted > 400 || heath <= 0) { + setDead(); + worldObj.newExplosion(shooter, this.posX, this.posY, this.posZ, 2F, true, true); + damageEntitiesInRadius(damageFireball, power, power * 2); + } + break; + case ENERGY_CHASER: + if (genericHit || (targetDistance > lastTickTargetDistance && targetDistance < power) || ticksExisted > 800 || heath <= 0) { + setDead(); + DraconicEvolution.network.sendToAllAround(new GenericParticlePacket(GenericParticlePacket.ENERGY_BALL_KILL, posX, posY, posZ), new NetworkRegistry.TargetPoint(dimension, posX, posY, posZ, 128)); + damageEntitiesInRadius(damageEnergy, power, power * 3); + worldObj.playSoundEffect(posX, posY, posZ, "random.explode", 4.0F, (1.0F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F); + } + break; + case CHAOS_CHASER: - break; - case MINI_CHAOS_CHASER: - if ((genericHit || (targetDistance > lastTickTargetDistance && targetDistance < power) || ticksExisted > 800 || heath <= 0) && ticksExisted > 5) - { - setDead(); - DraconicEvolution.network.sendToAllAround(new GenericParticlePacket(GenericParticlePacket.CHAOS_BALL_KILL, posX, posY, posZ), new NetworkRegistry.TargetPoint(dimension, posX, posY, posZ, 128)); - damageEntitiesInRadius(damageChaos, power, power * 3); - worldObj.playSoundEffect(posX, posY, posZ, "random.explode", 4.0F, (1.0F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F); - } - break; - case IGNITION_CHARGE: - if (targetDistance < 1){ - if (target instanceof EntityChaosCrystal) ((EntityChaosCrystal) target).revive(); - setDead(); - } - break; - } + if (genericHit || (targetDistance > lastTickTargetDistance && targetDistance < power) || ticksExisted > 800 || heath <= 0) { + setDead(); + DraconicEvolution.network.sendToAllAround(new GenericParticlePacket(GenericParticlePacket.CHAOS_BALL_KILL, posX, posY, posZ), new NetworkRegistry.TargetPoint(dimension, posX, posY, posZ, 128)); + damageEntitiesInRadius(damageChaos, power, power * 3); + worldObj.playSoundEffect(posX, posY, posZ, "random.explode", 4.0F, (1.0F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F); + int i = 3 + rand.nextInt(3); + EntityDragonProjectile newProjectile; + @SuppressWarnings("unchecked") List list = worldObj.getEntitiesWithinAABBExcludingEntity(shooter, boundingBox.expand(60, 60, 60), Utills.selectPlayer); + for (i = i; i > 0; i--) { + newProjectile = new EntityDragonProjectile(worldObj, MINI_CHAOS_CHASER, list.size() > 0 ? list.get(rand.nextInt(list.size())) : null, power / 2F, shooter); + newProjectile.motionY = 0; + int randDir = rand.nextInt(); + double speed = 1 + rand.nextDouble() * 5; + newProjectile.motionX = Math.sin(randDir) * speed; + newProjectile.motionZ = Math.cos(randDir) * speed; + newProjectile.setPosition(posX, posY, posZ); + worldObj.spawnEntityInWorld(newProjectile); + } + } + + break; + case MINI_CHAOS_CHASER: + if ((genericHit || (targetDistance > lastTickTargetDistance && targetDistance < power) || ticksExisted > 800 || heath <= 0) && ticksExisted > 5) { + setDead(); + DraconicEvolution.network.sendToAllAround(new GenericParticlePacket(GenericParticlePacket.CHAOS_BALL_KILL, posX, posY, posZ), new NetworkRegistry.TargetPoint(dimension, posX, posY, posZ, 128)); + damageEntitiesInRadius(damageChaos, power, power * 3); + worldObj.playSoundEffect(posX, posY, posZ, "random.explode", 4.0F, (1.0F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F); + } + break; + case IGNITION_CHARGE: + if (targetDistance < 1) { + if (target instanceof EntityChaosCrystal) ((EntityChaosCrystal) target).revive(); + setDead(); + } + break; + } + lastTickTargetDistance = targetDistance; + return false; + } - lastTickTargetDistance = targetDistance; - return false; - } + private Entity getHitEntity() { + Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - private Entity getHitEntity(){ - Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); - Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + Entity entityHit = 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; + int i; + float f1; - Entity entityHit = 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; - int i; - float f1; + for (i = 0; i < list.size(); ++i) { + Entity entity1 = (Entity) list.get(i); - for (i = 0; i < list.size(); ++i) { - Entity entity1 = (Entity) list.get(i); + if (entity1.canBeCollidedWith() && (entity1 != this.shooter || this.ticksExisted >= 5)) { + f1 = 1F; + AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f1, f1, f1); + MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); - if (entity1.canBeCollidedWith() && (entity1 != this.shooter || this.ticksExisted >= 5)) { - f1 = 1F; - AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f1, f1, f1); - MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); + if (movingobjectposition1 != null) { + double d1 = vec31.distanceTo(movingobjectposition1.hitVec); - if (movingobjectposition1 != null) { - double d1 = vec31.distanceTo(movingobjectposition1.hitVec); + if (d1 < d0 || d0 == 0.0D) { + entityHit = entity1; + d0 = d1; + } + } + } + } - if (d1 < d0 || d0 == 0.0D) { - entityHit = entity1; - d0 = d1; - } - } - } - } + return entityHit instanceof EntityDragonProjectile ? null : entityHit; + } - return entityHit instanceof EntityDragonProjectile ? null : entityHit; - } + private void damageEntitiesInRadius(DamageSource source, double radius, float damage) { + if (worldObj.isRemote) return; + @SuppressWarnings("unchecked") List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX, posY, posZ).expand(radius, radius, radius)); - private void damageEntitiesInRadius(DamageSource source, double radius, float damage){ - if (worldObj.isRemote) return; - @SuppressWarnings("unchecked") - List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX, posY, posZ).expand(radius, radius, radius)); + for (EntityLivingBase entityLivingBase : entities) { + if (entityLivingBase == shooter) continue; + entityLivingBase.hurtResistantTime = 0; + entityLivingBase.attackEntityFrom(source, damage / (float) (Utills.getDistanceAtoB(entityLivingBase.posX, entityLivingBase.posY, entityLivingBase.posZ, posX, posY, posZ) / radius)); + if (source == damageChaos && entityLivingBase instanceof EntityPlayer) { + for (ItemStack stack : ((EntityPlayer) entityLivingBase).inventory.armorInventory) { + if (stack != null && stack.getItem() instanceof IEnergyContainerItem) { + ((IEnergyContainerItem) stack.getItem()).extractEnergy(stack, 30000 + rand.nextInt(10000), false); + } + } + } + } + } - for (EntityLivingBase entityLivingBase : entities) { - if (entityLivingBase == shooter) continue; - entityLivingBase.hurtResistantTime = 0; - entityLivingBase.attackEntityFrom(source, damage / (float)(Utills.getDistanceAtoB(entityLivingBase.posX, entityLivingBase.posY, entityLivingBase.posZ, posX, posY, posZ) / radius)); - if (source == damageChaos && entityLivingBase instanceof EntityPlayer){ - for (ItemStack stack : ((EntityPlayer) entityLivingBase).inventory.armorInventory) { - if (stack != null && stack.getItem() instanceof IEnergyContainerItem){ - ((IEnergyContainerItem) stack.getItem()).extractEnergy(stack, 30000 + rand.nextInt(10000), false); - } - } - } - } - } + @Override + public boolean attackEntityFrom(DamageSource source, float dmg) { + if (heath <= 0) return false; + if ((source.getEntity() instanceof EntityPlayer || source.getEntity() instanceof EntityArrow) && ticksExisted > 5) + heath -= dmg; + if (source.getSourceOfDamage() instanceof EntityArrow) source.getSourceOfDamage().setDead(); - @Override - public boolean attackEntityFrom(DamageSource source, float dmg) { - if (heath <= 0) return false; - if ((source.getEntity() instanceof EntityPlayer || source.getEntity() instanceof EntityArrow) && ticksExisted > 5) heath -= dmg; - if (source.getSourceOfDamage() instanceof EntityArrow) source.getSourceOfDamage().setDead(); + if (heath <= 0) { + worldObj.newExplosion(this, this.posX, this.posY, this.posZ, 2F, false, false); + setDead(); + } - if (heath <= 0){ - worldObj.newExplosion(this, this.posX, this.posY, this.posZ, 2F, false, false); - setDead(); - } + return true; + } - return true; - } + @SideOnly(Side.CLIENT) + private void spawnParticle() { + if (getParticleColour() == 0) return; + Particles.DragonProjectileParticle particle = new Particles.DragonProjectileParticle(worldObj, posX - 0.25 + rand.nextDouble() * 0.5, posY + rand.nextDouble() * 0.5, posZ - 0.25 + rand.nextDouble() * 0.5, this); + double mm = 0.2; + particle.motionX = (rand.nextDouble() - 0.5) * mm; + particle.motionY = (rand.nextDouble() - 0.5) * mm; + particle.motionZ = (rand.nextDouble() - 0.5) * mm; + ParticleHandler.spawnCustomParticle(particle, 64); + } - @SideOnly(Side.CLIENT) - private void spawnParticle(){ - if (getParticleColour() == 0) return; - Particles.DragonProjectileParticle particle = new Particles.DragonProjectileParticle(worldObj, posX - 0.25 + rand.nextDouble() * 0.5, posY + rand.nextDouble() * 0.5, posZ - 0.25 + rand.nextDouble() * 0.5, this); - double mm = 0.2; - particle.motionX = (rand.nextDouble() - 0.5) * mm; - particle.motionY = (rand.nextDouble() - 0.5) * mm; - particle.motionZ = (rand.nextDouble() - 0.5) * mm; - ParticleHandler.spawnCustomParticle(particle, 64); - } + public int getParticleColour() { + switch (type) { + case FIREBOMB: + return 0xFF6600; + case TELEPORT: + return 0; + case FIRE_CHASER: + return 0xFF6600; + case ENERGY_CHASER: + return 0x00FFFF; + case CHAOS_CHASER: + return 0x440000; + case MINI_CHAOS_CHASER: + return 0x440000; + case IGNITION_CHARGE: + return 0xFFFFFF; + } + return 0; + } - public int getParticleColour(){ - switch (type){ - case FIREBOMB: return 0xFF6600; - case TELEPORT: return 0; - case FIRE_CHASER: return 0xFF6600; - case ENERGY_CHASER: return 0x00FFFF; - case CHAOS_CHASER: return 0x440000; - case MINI_CHAOS_CHASER: return 0x440000; - case IGNITION_CHARGE: return 0xFFFFFF; - } - return 0; - } + @Override + public void onEntityUpdate() { + super.onEntityUpdate(); + } - @Override - public void onEntityUpdate() { - super.onEntityUpdate(); - } + @Override + public boolean canBeCollidedWith() { + return true; + } - @Override - public boolean canBeCollidedWith() { - return true; - } + public float getCollisionBorderSize() { + return 1.0F; + } - public float getCollisionBorderSize() - { - return 1.0F; - } + @Override + protected void readEntityFromNBT(NBTTagCompound compound) { + type = compound.getInteger("Type"); + if (!worldObj.isRemote) dataWatcher.updateObject(10, (byte) type); + noClip = type == ENERGY_CHASER || type == CHAOS_CHASER || type == MINI_CHAOS_CHASER || type == IGNITION_CHARGE; + isChaser = type == FIRE_CHASER || type == ENERGY_CHASER || type == CHAOS_CHASER || type == MINI_CHAOS_CHASER || type == IGNITION_CHARGE; + } - @Override - protected void readEntityFromNBT(NBTTagCompound compound) { - type = compound.getInteger("Type"); - if (!worldObj.isRemote) dataWatcher.updateObject(10, (byte)type); - noClip = type == ENERGY_CHASER || type == CHAOS_CHASER || type == MINI_CHAOS_CHASER || type == IGNITION_CHARGE; - isChaser = type == FIRE_CHASER || type == ENERGY_CHASER || type == CHAOS_CHASER || type == MINI_CHAOS_CHASER || type == IGNITION_CHARGE; - } - - @Override - protected void writeEntityToNBT(NBTTagCompound compound) { - compound.setInteger("Type", type); - } + @Override + protected void writeEntityToNBT(NBTTagCompound compound) { + compound.setInteger("Type", type); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityEnderArrow.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityEnderArrow.java index 291600b2..ebb2b0f0 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityEnderArrow.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityEnderArrow.java @@ -18,182 +18,177 @@ import net.minecraftforge.event.entity.living.EnderTeleportEvent; import java.util.List; public class EntityEnderArrow extends EntityDraconicArrow { - private int field_145791_d = -1; - private int field_145792_e = -1; - private int field_145789_f = -1; - private Block field_145790_g; - private int inData; - private boolean inGround; - private int ticksInGround; - private int ticksInAir; - private double damage = 2.0D; - /** The amount of knockback an arrow applies when it hits a mob. */ - private int knockbackStrength; - public boolean ignorSpeed = false; - public boolean explosive = false; + private int field_145791_d = -1; + private int field_145792_e = -1; + private int field_145789_f = -1; + private Block field_145790_g; + private int inData; + private boolean inGround; + private int ticksInGround; + private int ticksInAir; + private double damage = 2.0D; + /** + * The amount of knockback an arrow applies when it hits a mob. + */ + private int knockbackStrength; + public boolean ignorSpeed = false; + public boolean explosive = false; - public EntityEnderArrow(World p_i1753_1_) - { - super(p_i1753_1_); - } + public EntityEnderArrow(World p_i1753_1_) { + super(p_i1753_1_); + } - public EntityEnderArrow(World p_i1754_1_, double p_i1754_2_, double p_i1754_4_, double p_i1754_6_) - { - super(p_i1754_1_, p_i1754_2_, p_i1754_4_, p_i1754_6_); - } + public EntityEnderArrow(World p_i1754_1_, double p_i1754_2_, double p_i1754_4_, double p_i1754_6_) { + super(p_i1754_1_, p_i1754_2_, p_i1754_4_, p_i1754_6_); + } - public EntityEnderArrow(World p_i1755_1_, EntityLivingBase p_i1755_2_, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_) - { - super(p_i1755_1_, p_i1755_2_, p_i1755_3_, p_i1755_4_, p_i1755_5_); - } + public EntityEnderArrow(World p_i1755_1_, EntityLivingBase p_i1755_2_, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_) { + super(p_i1755_1_, p_i1755_2_, p_i1755_3_, p_i1755_4_, p_i1755_5_); + } - public EntityEnderArrow(World par1World, EntityLivingBase par2EntityLivingBase, float par3) { - super(par1World, par2EntityLivingBase, par3); - } + public EntityEnderArrow(World par1World, EntityLivingBase par2EntityLivingBase, float par3) { + super(par1World, par2EntityLivingBase, par3); + } - @Override - protected void entityInit() - { - super.entityInit(); - //this.dataWatcher.addObject(16, Byte.valueOf((byte) 0)); - } + @Override + protected void entityInit() { + super.entityInit(); + //this.dataWatcher.addObject(16, Byte.valueOf((byte) 0)); + } - @Override - public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) - { - float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5); - par1 /= f2; - par3 /= f2; - par5 /= f2; - par1 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8; - par3 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8; - par5 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8; - par1 *= par7; - par3 *= par7; - par5 *= par7; - this.motionX = par1; - this.motionY = par3; - this.motionZ = par5; - float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); - this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, f3) * 180.0D / Math.PI); - this.ticksInGround = 0; - } + @Override + public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) { + float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5); + par1 /= f2; + par3 /= f2; + par5 /= f2; + par1 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8; + par3 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8; + par5 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8; + par1 *= par7; + par3 *= par7; + par5 *= par7; + this.motionX = par1; + this.motionY = par3; + this.motionZ = par5; + float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); + this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, f3) * 180.0D / Math.PI); + this.ticksInGround = 0; + } - @Override - @SideOnly(Side.CLIENT) - public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) - { - this.setPosition(par1, par3, par5); - this.setRotation(par7, par8); - } + @Override + @SideOnly(Side.CLIENT) + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) { + this.setPosition(par1, par3, par5); + this.setRotation(par7, par8); + } - @Override - @SideOnly(Side.CLIENT) - public void setVelocity(double par1, double par3, double par5) - { - this.motionX = par1; - this.motionY = par3; - this.motionZ = par5; + @Override + @SideOnly(Side.CLIENT) + public void setVelocity(double par1, double par3, double par5) { + this.motionX = par1; + this.motionY = par3; + this.motionZ = par5; - if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { - float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5); - this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, f) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch; - this.prevRotationYaw = this.rotationYaw; - this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); - this.ticksInGround = 0; - } - } + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { + float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5); + this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, f) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch; + this.prevRotationYaw = this.rotationYaw; + this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); + this.ticksInGround = 0; + } + } - @SuppressWarnings("rawtypes") - @Override - public void onUpdate() - { - for (int i=0; i < 10; i++) this.worldObj.spawnParticle("portal", this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height - 0.25D, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), (this.rand.nextDouble() - 0.5D) * 2.0D); + @SuppressWarnings("rawtypes") + @Override + public void onUpdate() { + for (int i = 0; i < 10; i++) + this.worldObj.spawnParticle("portal", this.posX + (this.rand.nextDouble() - 0.5D) * (double) this.width, this.posY + this.rand.nextDouble() * (double) this.height - 0.25D, this.posZ + (this.rand.nextDouble() - 0.5D) * (double) this.width, (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), (this.rand.nextDouble() - 0.5D) * 2.0D); - super.onEntityUpdate(); - if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { - float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D / Math.PI); - } + super.onEntityUpdate(); + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { + float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D / Math.PI); + } - Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f); + Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f); - if (block.getMaterial() != Material.air) { - onImpact(null); - block.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f); - AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f); + if (block.getMaterial() != Material.air) { + onImpact(null); + block.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f); + AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f); - if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) { - this.inGround = true; - } - } + if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) { + this.inGround = true; + } + } - if (this.arrowShake > 0) { - --this.arrowShake; - } + if (this.arrowShake > 0) { + --this.arrowShake; + } - if (this.inGround) { - this.setDead(); - } else { - ++this.ticksInAir; - Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); - Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false); - vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); - vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + if (this.inGround) { + this.setDead(); + } else { + ++this.ticksInAir; + Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false); + vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - if (movingobjectposition != null) { - vec3 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); - } + if (movingobjectposition != null) { + vec3 = 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; - int i; - float f1; + 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; + int i; + float f1; - for (i = 0; i < list.size(); ++i) { - Entity entity1 = (Entity) list.get(i); + for (i = 0; i < list.size(); ++i) { + Entity entity1 = (Entity) list.get(i); - if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) { - f1 = 0.3F; - AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f1, f1, f1); - MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); + if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) { + f1 = 0.3F; + AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f1, f1, f1); + MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); - if (movingobjectposition1 != null) { - double d1 = vec31.distanceTo(movingobjectposition1.hitVec); + if (movingobjectposition1 != null) { + double d1 = vec31.distanceTo(movingobjectposition1.hitVec); - if (d1 < d0 || d0 == 0.0D) { - entity = entity1; - d0 = d1; - } - } - } - } + if (d1 < d0 || d0 == 0.0D) { + entity = entity1; + d0 = d1; + } + } + } + } - if (entity == shootingEntity) entity = null; + if (entity == shootingEntity) entity = null; - if (entity != null) { - movingobjectposition = new MovingObjectPosition(entity); - } + if (entity != null) { + movingobjectposition = new MovingObjectPosition(entity); + } - if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) { - EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit; + if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) { + EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit; - if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) { - movingobjectposition = null; - } - } + if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) { + movingobjectposition = null; + } + } - float f2; - float f4; + float f2; + float f4; - if (movingobjectposition != null) { + if (movingobjectposition != null) { // if (movingobjectposition.entityHit != null && movingobjectposition.entityHit != shootingEntity) { // onImpact(movingobjectposition.entityHit); // int k; @@ -268,169 +263,159 @@ public class EntityEnderArrow extends EntityDraconicArrow { // this.ticksInAir = 0; // } // } else - if (movingobjectposition.entityHit == null){ - this.field_145791_d = movingobjectposition.blockX; - this.field_145792_e = movingobjectposition.blockY; - this.field_145789_f = movingobjectposition.blockZ; - this.field_145790_g = block; - this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f); - this.motionX = ((float) (movingobjectposition.hitVec.xCoord - this.posX)); - this.motionY = ((float) (movingobjectposition.hitVec.yCoord - this.posY)); - this.motionZ = ((float) (movingobjectposition.hitVec.zCoord - this.posZ)); - f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); - this.posX -= this.motionX / f2 * 0.05000000074505806D; - this.posY -= this.motionY / f2 * 0.05000000074505806D; - this.posZ -= this.motionZ / f2 * 0.05000000074505806D; - this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); - this.inGround = true; - this.arrowShake = 7; - this.setIsCritical(false); + if (movingobjectposition.entityHit == null) { + this.field_145791_d = movingobjectposition.blockX; + this.field_145792_e = movingobjectposition.blockY; + this.field_145789_f = movingobjectposition.blockZ; + this.field_145790_g = block; + this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f); + this.motionX = ((float) (movingobjectposition.hitVec.xCoord - this.posX)); + this.motionY = ((float) (movingobjectposition.hitVec.yCoord - this.posY)); + this.motionZ = ((float) (movingobjectposition.hitVec.zCoord - this.posZ)); + f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + this.posX -= this.motionX / f2 * 0.05000000074505806D; + this.posY -= this.motionY / f2 * 0.05000000074505806D; + this.posZ -= this.motionZ / f2 * 0.05000000074505806D; + this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + this.inGround = true; + this.arrowShake = 7; + this.setIsCritical(false); - if (this.field_145790_g.getMaterial() != Material.air) { - this.field_145790_g.onEntityCollidedWithBlock(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this); - } - } - } + if (this.field_145790_g.getMaterial() != Material.air) { + this.field_145790_g.onEntityCollidedWithBlock(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this); + } + } + } - this.posX += this.motionX; - this.posY += this.motionY; - this.posZ += this.motionZ; - f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + f2 = 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, f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { - ; - } + for (this.rotationPitch = (float) (Math.atan2(this.motionY, f2) * 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.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; + } - 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 f3 = 0.99F; - f1 = 0.05F; + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + float f3 = 0.99F; + f1 = 0.05F; - if (this.isInWater()) { - for (int l = 0; l < 4; ++l) { - f4 = 0.25F; - this.worldObj.spawnParticle("bubble", this.posX - this.motionX * f4, this.posY - this.motionY * f4, this.posZ - this.motionZ * f4, this.motionX, this.motionY, this.motionZ); - } + if (this.isInWater()) { + for (int l = 0; l < 4; ++l) { + f4 = 0.25F; + this.worldObj.spawnParticle("bubble", this.posX - this.motionX * f4, this.posY - this.motionY * f4, this.posZ - this.motionZ * f4, this.motionX, this.motionY, this.motionZ); + } - f3 = 0.8F; - } + f3 = 0.8F; + } - if (this.isWet()) { - this.extinguish(); - } + if (this.isWet()) { + this.extinguish(); + } - this.motionX *= f3; - this.motionY *= f3; - this.motionZ *= f3; - this.motionY -= f1; - this.setPosition(this.posX, this.posY, this.posZ); - this.func_145775_I(); - } - } + this.motionX *= f3; + this.motionY *= f3; + this.motionZ *= f3; + this.motionY -= f1; + this.setPosition(this.posX, this.posY, this.posZ); + this.func_145775_I(); + } + } - @Override - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) - { - par1NBTTagCompound.setShort("xTile", (short) this.field_145791_d); - par1NBTTagCompound.setShort("yTile", (short) this.field_145792_e); - par1NBTTagCompound.setShort("zTile", (short) this.field_145789_f); - par1NBTTagCompound.setShort("life", (short) this.ticksInGround); - par1NBTTagCompound.setByte("inTile", (byte) Block.getIdFromBlock(this.field_145790_g)); - par1NBTTagCompound.setByte("inData", (byte) this.inData); - par1NBTTagCompound.setByte("shake", (byte) this.arrowShake); - par1NBTTagCompound.setByte("inGround", (byte) (this.inGround ? 1 : 0)); - par1NBTTagCompound.setByte("pickup", (byte) this.canBePickedUp); - par1NBTTagCompound.setDouble("damage", this.damage); - //par1NBTTagCompound.setString("shooter", getShooter() instanceof EntityPlayer ? ((EntityPlayer) getShooter()).getCommandSenderName() : ""); - } + @Override + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { + par1NBTTagCompound.setShort("xTile", (short) this.field_145791_d); + par1NBTTagCompound.setShort("yTile", (short) this.field_145792_e); + par1NBTTagCompound.setShort("zTile", (short) this.field_145789_f); + par1NBTTagCompound.setShort("life", (short) this.ticksInGround); + par1NBTTagCompound.setByte("inTile", (byte) Block.getIdFromBlock(this.field_145790_g)); + par1NBTTagCompound.setByte("inData", (byte) this.inData); + par1NBTTagCompound.setByte("shake", (byte) this.arrowShake); + par1NBTTagCompound.setByte("inGround", (byte) (this.inGround ? 1 : 0)); + par1NBTTagCompound.setByte("pickup", (byte) this.canBePickedUp); + par1NBTTagCompound.setDouble("damage", this.damage); + //par1NBTTagCompound.setString("shooter", getShooter() instanceof EntityPlayer ? ((EntityPlayer) getShooter()).getCommandSenderName() : ""); + } - @Override - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) - { - this.field_145791_d = par1NBTTagCompound.getShort("xTile"); - this.field_145792_e = par1NBTTagCompound.getShort("yTile"); - this.field_145789_f = par1NBTTagCompound.getShort("zTile"); - this.ticksInGround = par1NBTTagCompound.getShort("life"); - this.field_145790_g = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255); - this.inData = par1NBTTagCompound.getByte("inData") & 255; - this.arrowShake = par1NBTTagCompound.getByte("shake") & 255; - this.inGround = par1NBTTagCompound.getByte("inGround") == 1; - //dataWatcher.updateObject(SHOOTER_DATAWATCHER_INDEX, par1NBTTagCompound.hasKey("shooter") ? par1NBTTagCompound.getString("shooter") : ""); + @Override + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { + this.field_145791_d = par1NBTTagCompound.getShort("xTile"); + this.field_145792_e = par1NBTTagCompound.getShort("yTile"); + this.field_145789_f = par1NBTTagCompound.getShort("zTile"); + this.ticksInGround = par1NBTTagCompound.getShort("life"); + this.field_145790_g = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255); + this.inData = par1NBTTagCompound.getByte("inData") & 255; + this.arrowShake = par1NBTTagCompound.getByte("shake") & 255; + this.inGround = par1NBTTagCompound.getByte("inGround") == 1; + //dataWatcher.updateObject(SHOOTER_DATAWATCHER_INDEX, par1NBTTagCompound.hasKey("shooter") ? par1NBTTagCompound.getString("shooter") : ""); - if (par1NBTTagCompound.hasKey("damage", 99)) { - this.damage = par1NBTTagCompound.getDouble("damage"); - } + if (par1NBTTagCompound.hasKey("damage", 99)) { + this.damage = par1NBTTagCompound.getDouble("damage"); + } - if (par1NBTTagCompound.hasKey("pickup", 99)) { - this.canBePickedUp = par1NBTTagCompound.getByte("pickup"); - } else if (par1NBTTagCompound.hasKey("player", 99)) { - this.canBePickedUp = par1NBTTagCompound.getBoolean("player") ? 1 : 0; - } - } + if (par1NBTTagCompound.hasKey("pickup", 99)) { + this.canBePickedUp = par1NBTTagCompound.getByte("pickup"); + } else if (par1NBTTagCompound.hasKey("player", 99)) { + this.canBePickedUp = par1NBTTagCompound.getBoolean("player") ? 1 : 0; + } + } - @Override - public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) - {} + @Override + public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) { + } - protected void onImpact(Entity entityHit) - { - if (shootingEntity == null) return; - double startX = shootingEntity.posX; - double startY = shootingEntity.posY; - double startZ = shootingEntity.posZ; + protected void onImpact(Entity entityHit) { + if (shootingEntity == null) return; + double startX = shootingEntity.posX; + double startY = shootingEntity.posY; + double startZ = shootingEntity.posZ; - for (int i = 0; i < 32; ++i) - { - this.worldObj.spawnParticle("portal", this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian()); - } + for (int i = 0; i < 32; ++i) { + this.worldObj.spawnParticle("portal", this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian()); + } - if (!(shootingEntity instanceof EntityPlayer) || shootingEntity.isDead) return; - if (entityHit != null) - { - entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.shootingEntity), 0.0F); - } + if (!(shootingEntity instanceof EntityPlayer) || shootingEntity.isDead) return; + if (entityHit != null) { + entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.shootingEntity), 0.0F); + } - if (!this.worldObj.isRemote) - { - if (this.shootingEntity != null && this.shootingEntity instanceof EntityPlayerMP) - { - EntityPlayerMP entityplayermp = (EntityPlayerMP)this.shootingEntity; + if (!this.worldObj.isRemote) { + if (this.shootingEntity != null && this.shootingEntity instanceof EntityPlayerMP) { + EntityPlayerMP entityplayermp = (EntityPlayerMP) this.shootingEntity; - if (entityplayermp.playerNetServerHandler.func_147362_b().isChannelOpen() && entityplayermp.worldObj == this.worldObj) - { - int x = (int)Math.floor(posX); - int y = (int)Math.floor(posY); - int z = (int)Math.floor(posZ); + if (entityplayermp.playerNetServerHandler.func_147362_b().isChannelOpen() && entityplayermp.worldObj == this.worldObj) { + int x = (int) Math.floor(posX); + int y = (int) Math.floor(posY); + int z = (int) Math.floor(posZ); - double travelDist = Utills.getDistanceAtoB(startX, startY, startZ, x, y, z); - float travelDmg = (float)(travelDist / 5D); - EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, x+0.5, y+0.5, z+0.5, travelDmg); - if (!MinecraftForge.EVENT_BUS.post(event)) - { - if (this.shootingEntity.isRiding()) - { - shootingEntity.mountEntity((Entity)null); - } - ((EntityPlayer)shootingEntity).setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); - shootingEntity.fallDistance = 0.0F; - shootingEntity.attackEntityFrom(DamageSource.fall, (float)(travelDist / 5D)); - } - } - } - } - this.setDead(); - } + double travelDist = Utills.getDistanceAtoB(startX, startY, startZ, x, y, z); + float travelDmg = (float) (travelDist / 5D); + EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, x + 0.5, y + 0.5, z + 0.5, travelDmg); + if (!MinecraftForge.EVENT_BUS.post(event)) { + if (this.shootingEntity.isRiding()) { + shootingEntity.mountEntity((Entity) null); + } + ((EntityPlayer) shootingEntity).setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); + shootingEntity.fallDistance = 0.0F; + shootingEntity.attackEntityFrom(DamageSource.fall, (float) (travelDist / 5D)); + } + } + } + } + this.setDead(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityPersistentItem.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityPersistentItem.java index 65e54498..c374a3a5 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityPersistentItem.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityPersistentItem.java @@ -16,164 +16,140 @@ import net.minecraftforge.event.entity.item.ItemExpireEvent; * Created by Brandon on 15/08/2014. */ public class EntityPersistentItem extends EntityItem { - public EntityPersistentItem(World par1World, double par2, double par4, double par6) - { - super(par1World, par2, par4, par6); - this.isImmuneToFire = true; - this.lifespan = 72000; - } + public EntityPersistentItem(World par1World, double par2, double par4, double par6) { + super(par1World, par2, par4, par6); + this.isImmuneToFire = true; + this.lifespan = 72000; + } - public EntityPersistentItem(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack) - { - this(par1World, par2, par4, par6); - this.setEntityItemStack(par8ItemStack); - this.lifespan = 72000; - } + public EntityPersistentItem(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack) { + this(par1World, par2, par4, par6); + this.setEntityItemStack(par8ItemStack); + this.lifespan = 72000; + } - public EntityPersistentItem(World par1World) - { - super(par1World); - this.isImmuneToFire = true; - this.lifespan = 72000; - } + public EntityPersistentItem(World par1World) { + super(par1World); + this.isImmuneToFire = true; + this.lifespan = 72000; + } - public EntityPersistentItem(World world, Entity original, ItemStack stack) - { - this(world, original.posX, original.posY, original.posZ); - if (original instanceof EntityItem) this.delayBeforeCanPickup = ((EntityItem)original).delayBeforeCanPickup; - else this.delayBeforeCanPickup = 20; - this.motionX = original.motionX; - this.motionY = original.motionY; - this.motionZ = original.motionZ; - this.setEntityItemStack(stack); - this.lifespan = 72000; - } + public EntityPersistentItem(World world, Entity original, ItemStack stack) { + this(world, original.posX, original.posY, original.posZ); + if (original instanceof EntityItem) this.delayBeforeCanPickup = ((EntityItem) original).delayBeforeCanPickup; + else this.delayBeforeCanPickup = 20; + this.motionX = original.motionX; + this.motionY = original.motionY; + this.motionZ = original.motionZ; + this.setEntityItemStack(stack); + this.lifespan = 72000; + } - @Override - public boolean attackEntityFrom (DamageSource par1DamageSource, float par2) - { - if (getEntityItem().getItem() instanceof DragonHeart && par1DamageSource.isExplosion() && par2 > 10f && !this.isDead){ - worldObj.spawnEntityInWorld(new EntityDragonHeart(worldObj, posX, posY, posZ)); - this.setDead(); - } + @Override + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { + if (getEntityItem().getItem() instanceof DragonHeart && par1DamageSource.isExplosion() && par2 > 10f && !this.isDead) { + worldObj.spawnEntityInWorld(new EntityDragonHeart(worldObj, posX, posY, posZ)); + this.setDead(); + } - return par1DamageSource.getDamageType().equals("outOfWorld"); - } + return par1DamageSource.getDamageType().equals("outOfWorld"); + } - @Override - public boolean isInRangeToRenderDist(double p_70112_1_) { - double d1 = this.boundingBox.getAverageEdgeLength(); - d1 *= 64.0D * 4; - return p_70112_1_ < d1 * d1; - } + @Override + public boolean isInRangeToRenderDist(double p_70112_1_) { + double d1 = this.boundingBox.getAverageEdgeLength(); + d1 *= 64.0D * 4; + return p_70112_1_ < d1 * d1; + } - @Override - public boolean isInRangeToRender3d(double p_145770_1_, double p_145770_3_, double p_145770_5_) { - return super.isInRangeToRender3d(p_145770_1_, p_145770_3_, p_145770_5_); - } + @Override + public boolean isInRangeToRender3d(double p_145770_1_, double p_145770_3_, double p_145770_5_) { + return super.isInRangeToRender3d(p_145770_1_, p_145770_3_, p_145770_5_); + } - @Override - public void onUpdate() { - if (age+10 >= lifespan) age = 0; - boolean flag2 = false; - if (this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY-1), MathHelper.floor_double(this.posZ)) == Blocks.end_portal) flag2 = true; - ItemStack stack = this.getDataWatcher().getWatchableObjectItemStack(10); - if (stack != null && stack.getItem() != null) - { - if (stack.getItem().onEntityItemUpdate(this)) - { - return; - } - } + @Override + public void onUpdate() { + if (age + 10 >= lifespan) age = 0; + boolean flag2 = false; + if (this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY - 1), MathHelper.floor_double(this.posZ)) == Blocks.end_portal) + flag2 = true; + ItemStack stack = this.getDataWatcher().getWatchableObjectItemStack(10); + if (stack != null && stack.getItem() != null) { + if (stack.getItem().onEntityItemUpdate(this)) { + return; + } + } - if (this.getEntityItem() == null) - { - this.setDead(); - } - else - { - super.onEntityUpdate(); + if (this.getEntityItem() == null) { + this.setDead(); + } else { + super.onEntityUpdate(); - if (this.delayBeforeCanPickup > 0) - { - --this.delayBeforeCanPickup; - } + if (this.delayBeforeCanPickup > 0) { + --this.delayBeforeCanPickup; + } - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - this.motionY -= 0.03999999910593033D; - if (flag2) - { - motionX = 0; - motionY = 0; - motionZ = 0; - } - this.noClip = this.func_145771_j(this.posX, (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D, this.posZ); - this.moveEntity(this.motionX, this.motionY, this.motionZ); - boolean flag = (int)this.prevPosX != (int)this.posX || (int)this.prevPosY != (int)this.posY || (int)this.prevPosZ != (int)this.posZ; + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY -= 0.03999999910593033D; + if (flag2) { + motionX = 0; + motionY = 0; + motionZ = 0; + } + this.noClip = this.func_145771_j(this.posX, (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D, this.posZ); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + boolean flag = (int) this.prevPosX != (int) this.posX || (int) this.prevPosY != (int) this.posY || (int) this.prevPosZ != (int) this.posZ; - if (flag || this.ticksExisted % 25 == 0) - { - if (this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)).getMaterial() == Material.lava) - { - this.motionY = 0.20000000298023224D; - this.motionX = (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F); - this.motionZ = (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F); - this.playSound("random.fizz", 0.4F, 2.0F + this.rand.nextFloat() * 0.4F); - } - } + if (flag || this.ticksExisted % 25 == 0) { + if (this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)).getMaterial() == Material.lava) { + this.motionY = 0.20000000298023224D; + this.motionX = (double) ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F); + this.motionZ = (double) ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F); + this.playSound("random.fizz", 0.4F, 2.0F + this.rand.nextFloat() * 0.4F); + } + } - float f = 0.98F; + float f = 0.98F; - if (this.onGround) - { - f = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.98F; - } + if (this.onGround) { + f = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.98F; + } - this.motionX *= (double)f; - this.motionY *= 0.9800000190734863D; - this.motionZ *= (double)f; - if (flag2) - { - motionX = 0; - motionY = 0; - motionZ = 0; - } + this.motionX *= (double) f; + this.motionY *= 0.9800000190734863D; + this.motionZ *= (double) f; + if (flag2) { + motionX = 0; + motionY = 0; + motionZ = 0; + } - if (this.onGround) - { - this.motionY *= -0.5D; - } + if (this.onGround) { + this.motionY *= -0.5D; + } - ++this.age; + ++this.age; - ItemStack item = getDataWatcher().getWatchableObjectItemStack(10); + ItemStack item = getDataWatcher().getWatchableObjectItemStack(10); - if (!this.worldObj.isRemote && this.age >= lifespan) - { - if (item != null) - { - ItemExpireEvent event = new ItemExpireEvent(this, (item.getItem() == null ? 6000 : item.getItem().getEntityLifespan(item, worldObj))); - if (MinecraftForge.EVENT_BUS.post(event)) - { - lifespan += event.extraLife; - } - else - { - this.setDead(); - } - } - else - { - this.setDead(); - } - } + if (!this.worldObj.isRemote && this.age >= lifespan) { + if (item != null) { + ItemExpireEvent event = new ItemExpireEvent(this, (item.getItem() == null ? 6000 : item.getItem().getEntityLifespan(item, worldObj))); + if (MinecraftForge.EVENT_BUS.post(event)) { + lifespan += event.extraLife; + } else { + this.setDead(); + } + } else { + this.setDead(); + } + } - if (item != null && item.stackSize <= 0) - { - this.setDead(); - } - } - } + if (item != null && item.stackSize <= 0) { + this.setDead(); + } + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/ExtendedPlayer.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/ExtendedPlayer.java index 06b317eb..76c30ee7 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/entity/ExtendedPlayer.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/ExtendedPlayer.java @@ -11,54 +11,54 @@ import net.minecraftforge.common.IExtendedEntityProperties; */ public class ExtendedPlayer implements IExtendedEntityProperties { - public final static String EXT_PROP_NAME = "DEPlayerProperties"; + public final static String EXT_PROP_NAME = "DEPlayerProperties"; - private final EntityPlayer player; - private int spawnCount; + private final EntityPlayer player; + private int spawnCount; - public ExtendedPlayer(EntityPlayer player) { - this.player = player; - this.spawnCount = 0; - } + public ExtendedPlayer(EntityPlayer player) { + this.player = player; + this.spawnCount = 0; + } - /** - * Used to register these extended properties for the player during EntityConstructing event - * This method is for convenience only; it will make your code look nicer - */ - public static void register(EntityPlayer player) { - player.registerExtendedProperties(ExtendedPlayer.EXT_PROP_NAME, new ExtendedPlayer(player)); - } + /** + * Used to register these extended properties for the player during EntityConstructing event + * This method is for convenience only; it will make your code look nicer + */ + public static void register(EntityPlayer player) { + player.registerExtendedProperties(ExtendedPlayer.EXT_PROP_NAME, new ExtendedPlayer(player)); + } - /** - * Returns ExtendedPlayer properties for player - * This method is for convenience only; it will make your code look nicer - */ - public static ExtendedPlayer get(EntityPlayer player) { - return (ExtendedPlayer) player.getExtendedProperties(EXT_PROP_NAME); - } + /** + * Returns ExtendedPlayer properties for player + * This method is for convenience only; it will make your code look nicer + */ + public static ExtendedPlayer get(EntityPlayer player) { + return (ExtendedPlayer) player.getExtendedProperties(EXT_PROP_NAME); + } - @Override - public void saveNBTData(NBTTagCompound compound) { - NBTTagCompound properties = new NBTTagCompound(); - properties.setInteger("SpawnCount", spawnCount); - compound.setTag(EXT_PROP_NAME, properties); - } + @Override + public void saveNBTData(NBTTagCompound compound) { + NBTTagCompound properties = new NBTTagCompound(); + properties.setInteger("SpawnCount", spawnCount); + compound.setTag(EXT_PROP_NAME, properties); + } - @Override - public void loadNBTData(NBTTagCompound compound) { - NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME); - spawnCount = properties.getInteger("SpawnCount"); - } + @Override + public void loadNBTData(NBTTagCompound compound) { + NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME); + spawnCount = properties.getInteger("SpawnCount"); + } - @Override - public void init(Entity entity, World world) { - } + @Override + public void init(Entity entity, World world) { + } - public int getSpawnCount() { - return spawnCount; - } + public int getSpawnCount() { + return spawnCount; + } - public void setSpawnCount(int count) { - spawnCount = count; - } + public void setSpawnCount(int count) { + spawnCount = count; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/handler/BalanceConfigHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/handler/BalanceConfigHandler.java index 0b1447cf..1e3daab4 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/handler/BalanceConfigHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/handler/BalanceConfigHandler.java @@ -10,8 +10,7 @@ import net.minecraft.init.Blocks; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; -public class BalanceConfigHandler -{ +public class BalanceConfigHandler { public static final int wyvernArmorMinShieldRecovery = 5; public static final int draconicArmorMinShieldRecovery = 5; public static final int wyvernToolsMinDigAOEUpgradePoints = 1; @@ -140,374 +139,187 @@ public class BalanceConfigHandler public static int energyStorageStructureBlockMetadata = 0; public static boolean grinderShouldUseLooting = false; private static Configuration config; - public static void init(File modConfigurationDirectory) - { - if (config == null) - { + + public static void init(File modConfigurationDirectory) { + if (config == null) { config = new Configuration(new File(modConfigurationDirectory, "DraconicEvolution.Balance.cfg")); config.load(); config.setCategoryRequiresMcRestart("tweaks", true); - config.setCategoryComment("tweaks.armor", - "Values in this category may be replaced automatically to prevent problems"); - config.setCategoryComment("tweaks.tools", - "Values in this category may be replaced automatically to prevent problems"); - config.setCategoryComment("tweaks.weapons", - "Values in this category may be replaced automatically to prevent problems"); + config.setCategoryComment("tweaks.armor", "Values in this category may be replaced automatically to prevent problems"); + config.setCategoryComment("tweaks.tools", "Values in this category may be replaced automatically to prevent problems"); + config.setCategoryComment("tweaks.weapons", "Values in this category may be replaced automatically to prevent problems"); syncConfig(); } } - private static void syncConfig() - { - wyvernArmorBaseStorage = - getInteger("energy.armor", "Wyvern Armor: Base energy storage (RF)", wyvernArmorBaseStorage); - wyvernArmorStoragePerUpgrade = - getInteger("energy.armor", "Wyvern Armor: Additional energy storage per upgrade installed (RF)", - wyvernArmorStoragePerUpgrade); - wyvernArmorMaxTransfer = - getInteger("energy.armor", "Wyvern Armor: Maximum energy transfer rate (RF/t)", wyvernArmorMaxTransfer); - wyvernArmorEnergyPerProtectionPoint = - getInteger("energy.armor", "Wyvern Armor: Amount of energy required to restore protection point (RF)", - wyvernArmorEnergyPerProtectionPoint); - draconicArmorBaseStorage = - getInteger("energy.armor", "Draconic Armor: Base energy storage (RF)", draconicArmorBaseStorage); - draconicArmorStoragePerUpgrade = - getInteger("energy.armor", "Draconic Armor: Additional energy storage per upgrade installed (RF)", - draconicArmorStoragePerUpgrade); - draconicArmorMaxTransfer = - getInteger("energy.armor", "Draconic Armor: Maximum energy transfer rate (RF/t)", draconicArmorMaxTransfer); - draconicArmorEnergyPerProtectionPoint = - getInteger("energy.armor", "Draconic Armor: Amount of energy required to restore protection point (RF)", - draconicArmorEnergyPerProtectionPoint); - draconicArmorEnergyToRemoveEffects = - getInteger("energy.armor", "Draconic Armor: Amount of energy required to remove negative effects (RF)", - draconicArmorEnergyToRemoveEffects); - wyvernToolsBaseStorage = - getInteger("energy.tools", "Wyvern Tools: Base energy storage (RF)", wyvernToolsBaseStorage); - wyvernToolsStoragePerUpgrade = - getInteger("energy.tools", "Wyvern Tools: Additional energy storage per upgrade installed (RF)", - wyvernToolsStoragePerUpgrade); - wyvernToolsMaxTransfer = - getInteger("energy.tools", "Wyvern Tools: Maximum energy transfer rate (RF/t)", wyvernToolsMaxTransfer); - wyvernToolsEnergyPerAction = - getInteger("energy.tools", "Wyvern Tools: Amount of energy required to perform action (RF)", - wyvernToolsEnergyPerAction); - draconicToolsBaseStorage = - getInteger("energy.tools", "Draconic Tools: Base energy storage (RF)", draconicToolsBaseStorage); - draconicToolsStoragePerUpgrade = - getInteger("energy.tools", "Draconic Tools: Additional energy storage per upgrade installed (RF)", - draconicToolsStoragePerUpgrade); - draconicToolsMaxTransfer = - getInteger("energy.tools", "Draconic Tools: Maximum energy transfer rate (RF/t)", draconicToolsMaxTransfer); - draconicToolsEnergyPerAction = - getInteger("energy.tools", "Draconic Tools: Amount of energy required to perform action (RF)", - draconicToolsEnergyPerAction); - wyvernCapacitorBaseStorage = - getInteger("energy.tools", "Wyvern Flux Capacitor: Base energy storage (RF)", wyvernCapacitorBaseStorage); - wyvernCapacitorStoragePerUpgrade = - getInteger("energy.tools", "Wyvern Flux Capacitor: Additional energy storage per upgrade installed (RF)", - wyvernCapacitorStoragePerUpgrade); - wyvernCapacitorMaxReceive = - getInteger("energy.tools", "Wyvern Flux Capacitor: Maximum energy reception rate (RF/t)", - wyvernCapacitorMaxReceive); - wyvernCapacitorMaxExtract = - getInteger("energy.tools", "Wyvern Flux Capacitor: Maximum energy extraction rate (RF/t)", - wyvernCapacitorMaxExtract); - draconicCapacitorBaseStorage = getInteger("energy.tools", "Draconic Flux Capacitor: Base energy storage (RF)", - draconicCapacitorBaseStorage); - draconicCapacitorStoragePerUpgrade = - getInteger("energy.tools", "Draconic Flux Capacitor: Additional energy storage per upgrade installed (RF)", - draconicCapacitorStoragePerUpgrade); - draconicCapacitorMaxReceive = - getInteger("energy.tools", "Draconic Flux Capacitor: Maximum energy reception rate (RF/t)", - draconicCapacitorMaxReceive); - draconicCapacitorMaxExtract = - getInteger("energy.tools", "Draconic Flux Capacitor: Maximum energy extraction rate (RF/t)", - draconicCapacitorMaxExtract); - wyvernWeaponsBaseStorage = - getInteger("energy.weapons", "Wyvern Weapons: Base energy storage (RF)", wyvernWeaponsBaseStorage); - wyvernWeaponsStoragePerUpgrade = - getInteger("energy.weapons", "Wyvern Weapons: Additional energy storage per upgrade installed (RF)", - wyvernWeaponsStoragePerUpgrade); - wyvernWeaponsMaxTransfer = getInteger("energy.weapons", "Wyvern Weapons: Maximum energy transfer rate (RF/t)", - wyvernWeaponsMaxTransfer); - wyvernWeaponsEnergyPerAttack = - getInteger("energy.weapons", "Wyvern Weapons: Amount of energy required to perform attack (RF)", - wyvernWeaponsEnergyPerAttack); - wyvernBowEnergyPerShot = - getInteger("energy.weapons", "Wyvern Bow: Amount of energy required to shoot (RF)", wyvernBowEnergyPerShot); - draconicWeaponsBaseStorage = - getInteger("energy.weapons", "Draconic Weapons: Base energy storage (RF)", draconicWeaponsBaseStorage); - draconicWeaponsStoragePerUpgrade = - getInteger("energy.weapons", "Draconic Weapons: Additional energy storage per upgrade installed (RF)", - draconicWeaponsStoragePerUpgrade); - draconicWeaponsMaxTransfer = - getInteger("energy.weapons", "Draconic Weapons: Maximum energy transfer rate (RF/t)", - draconicWeaponsMaxTransfer); - draconicWeaponsEnergyPerAttack = - getInteger("energy.weapons", "Draconic Weapons: Amount of energy required to perform attack (RF)", - draconicWeaponsEnergyPerAttack); - draconicBowEnergyPerShot = getInteger("energy.weapons", "Draconic Bow: Amount of energy required to shoot (RF)", - draconicBowEnergyPerShot); - draconicFireEnergyCostMultiptier = - getInteger("energy.weapons", "Arrow of Draconic Fire: Energy cost multiplier", - draconicFireEnergyCostMultiptier); - draconiumBlockEnergyToChange = - getInteger("energy.misc", "Draconium Block: Amount of energy required to charge (RF)", - draconiumBlockEnergyToChange); - draconiumBlockChargingSpeed = - getInteger("energy.misc", "Draconium Block: Maximum charging speed (RF/t)", draconiumBlockChargingSpeed); - energyInfuserStorage = - getInteger("energy.machines", "Energy Infuser: Energy buffer size (RF)", energyInfuserStorage); - energyInfuserMaxTransfer = getInteger("energy.machines", "Energy Infuser: Maximum energy transfer rate (RF/t)", - energyInfuserMaxTransfer); - energyStorageTier1Storage = - getLong("energy.machines", "Multiblock Energy Storage Tier 1: Energy buffer size (RF)", - energyStorageTier1Storage); - energyStorageTier2Storage = - getLong("energy.machines", "Multiblock Energy Storage Tier 2: Energy buffer size (RF)", - energyStorageTier2Storage); - energyStorageTier3Storage = - getLong("energy.machines", "Multiblock Energy Storage Tier 3: Energy buffer size (RF)", - energyStorageTier3Storage); - energyStorageTier4Storage = - getLong("energy.machines", "Multiblock Energy Storage Tier 4: Energy buffer size (RF)", - energyStorageTier4Storage); - energyStorageTier5Storage = - getLong("energy.machines", "Multiblock Energy Storage Tier 5: Energy buffer size (RF)", - energyStorageTier5Storage); - energyStorageTier6Storage = - getLong("energy.machines", "Multiblock Energy Storage Tier 6: Energy buffer size (RF)", - energyStorageTier6Storage); - energyStorageTier7Storage = - getLong("energy.machines", "Multiblock Energy Storage Tier 7: Energy buffer size (RF)", - energyStorageTier7Storage); - grinderInternalEnergyBufferSize = getInteger("energy.machines", "Mob Grinder: Internal energy buffer size (RF)", - grinderInternalEnergyBufferSize); - grinderExternalEnergyBufferSize = - getInteger("energy.machines", "Mob Grinder: Main energy buffer size (RF)", grinderExternalEnergyBufferSize); - grinderMaxReceive = - getInteger("energy.machines", "Mob Grinder: Maximum energy reception rate (RF/t)", grinderMaxReceive); - grinderEnergyPerKill = - getInteger("energy.machines", "Mob Grinder: Amount of energy required to kill entity (RF)", - grinderEnergyPerKill); - wyvernArmorMaxCapacityUpgradePoints = (int) Math.floor((double) (Integer.MAX_VALUE - wyvernArmorBaseStorage) / - (double) Math.max(wyvernArmorStoragePerUpgrade, 1)) * - EnumUpgrade.RF_CAPACITY.pointConversion; - wyvernArmorMaxUpgrades = - getInteger("tweaks.armor", "Wyvern Armor: Maximum amount of upgrades", wyvernArmorMaxUpgrades); - wyvernArmorMaxUpgradePoints = - getInteger("tweaks.armor", "Wyvern Armor: Maximum amount of upgrade points", wyvernArmorMaxUpgradePoints, - wyvernArmorMaxUpgrades, Integer.MAX_VALUE); - wyvernArmorMaxCapacityUpgradePoints = - Math.max(Math.min(wyvernArmorMaxUpgradePoints, wyvernArmorMaxCapacityUpgradePoints), 0); - draconicArmorMaxCapacityUpgradePoints = (int) Math.floor( - (double) (Integer.MAX_VALUE - draconicArmorBaseStorage) / Math.max(draconicArmorStoragePerUpgrade, 1)) * - EnumUpgrade.RF_CAPACITY.pointConversion; - draconicArmorMaxUpgrades = - getInteger("tweaks.armor", "Draconic Armor: Maximum amount of upgrades", draconicArmorMaxUpgrades); - draconicArmorMaxUpgradePoints = getInteger("tweaks.armor", "Draconic Armor: Maximum amount of upgrade points", - draconicArmorMaxUpgradePoints, draconicArmorMaxUpgrades, - Integer.MAX_VALUE); - draconicArmorMaxCapacityUpgradePoints = - Math.max(Math.min(draconicArmorMaxUpgradePoints, draconicArmorMaxCapacityUpgradePoints), 0); - wyvernToolsMaxCapacityUpgradePoints = (int) Math.floor((double) (Integer.MAX_VALUE - wyvernToolsBaseStorage) / - (double) Math.max(wyvernToolsStoragePerUpgrade, 1)) * - EnumUpgrade.RF_CAPACITY.pointConversion; - wyvernToolsMaxUpgrades = - getInteger("tweaks.tools", "Wyvern Tools: Maximum amount of upgrades", wyvernToolsMaxUpgrades, 0, - (wyvernToolsMaxDigAOEUpgradePoints - wyvernToolsMinDigAOEUpgradePoints) * - EnumUpgrade.DIG_AOE.pointConversion + - (wyvernToolsMaxDigSpeedUpgradePoints - wyvernToolsMinDigSpeedUpgradePoints) * - EnumUpgrade.DIG_SPEED.pointConversion + wyvernToolsMaxCapacityUpgradePoints); - wyvernToolsMaxUpgradePoints = - getInteger("tweaks.tools", "Wyvern Tools: Maximum amount of upgrade points", wyvernToolsMaxUpgradePoints, - wyvernToolsMaxUpgrades, Integer.MAX_VALUE); - wyvernToolsMaxCapacityUpgradePoints = - Math.max(Math.min(wyvernToolsMaxUpgradePoints, wyvernToolsMaxCapacityUpgradePoints), 0); - draconicToolsMaxCapacityUpgradePoints = (int) Math.floor( - (double) (Integer.MAX_VALUE - draconicToolsBaseStorage) / - (double) Math.max(draconicToolsStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; - draconicToolsMaxUpgrades = - getInteger("tweaks.tools", "Draconic Tools: Maximum amount of upgrades", draconicToolsMaxUpgrades, 0, - (draconicToolsMaxDigAOEUpgradePoints - draconicToolsMinDigAOEUpgradePoints) * - EnumUpgrade.DIG_AOE.pointConversion + - (draconicToolsMaxDigSpeedUpgradePoints - draconicToolsMinDigSpeedUpgradePoints) * - EnumUpgrade.DIG_SPEED.pointConversion + - (draconicToolsMaxDigDepthUpgradePoints - draconicToolsMinDigDepthUpgradePoints) * - EnumUpgrade.DIG_DEPTH.pointConversion + draconicToolsMaxCapacityUpgradePoints); - draconicToolsMaxUpgradePoints = getInteger("tweaks.tools", "Draconic Tools: Maximum amount of upgrade points", - draconicToolsMaxUpgradePoints, draconicToolsMaxUpgrades, - Integer.MAX_VALUE); - draconicToolsMaxCapacityUpgradePoints = - Math.max(Math.min(draconicToolsMaxUpgradePoints, draconicToolsMaxCapacityUpgradePoints), 0); - wyvernWeaponsMaxCapacityUpgradePoints = (int) Math.floor( - (double) (Integer.MAX_VALUE - wyvernWeaponsBaseStorage) / - (double) Math.max(wyvernWeaponsStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; - wyvernWeaponsMaxUpgrades = - getInteger("tweaks.weapons", "Wyvern Weapons: Maximum amount of upgrades", wyvernWeaponsMaxUpgrades, 0, - (wyvernWeaponsMaxAttackAOEUpgradePoints - wyvernWeaponsMinAttackAOEUpgradePoints) * - EnumUpgrade.ATTACK_AOE.pointConversion + - (wyvernWeaponsMaxAttackDamageUpgradePoints - wyvernWeaponsMinAttackDamageUpgradePoints) * - EnumUpgrade.ATTACK_DAMAGE.pointConversion + wyvernWeaponsMaxCapacityUpgradePoints); - wyvernWeaponsMaxUpgradePoints = getInteger("tweaks.weapons", "Wyvern Weapons: Maximum amount of upgrade points", - wyvernWeaponsMaxUpgradePoints, wyvernWeaponsMaxUpgrades, - Integer.MAX_VALUE); - wyvernWeaponsMaxCapacityUpgradePoints = - Math.max(Math.min(wyvernWeaponsMaxUpgradePoints, wyvernWeaponsMaxCapacityUpgradePoints), 0); - draconicWeaponsMaxCapacityUpgradePoints = (int) Math.floor( - (double) (Integer.MAX_VALUE - draconicWeaponsBaseStorage) / - (double) Math.max(draconicWeaponsStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; - draconicWeaponsMaxUpgrades = - getInteger("tweaks.weapons", "Draconic Weapons: Maximum amount of upgrades", draconicWeaponsMaxUpgrades, 0, - (draconicWeaponsMaxAttackAOEUpgradePoints - draconicWeaponsMinAttackAOEUpgradePoints) * - EnumUpgrade.ATTACK_AOE.pointConversion + - (draconicWeaponsMaxAttackDamageUpgradePoints - draconicWeaponsMinAttackDamageUpgradePoints) * - EnumUpgrade.ARROW_DAMAGE.pointConversion + draconicWeaponsMaxCapacityUpgradePoints); - draconicWeaponsMaxUpgradePoints = - getInteger("tweaks.weapons", "Draconic Weapons: Maximum amount of upgrade points", - draconicWeaponsMaxUpgradePoints, draconicWeaponsMaxUpgrades, Integer.MAX_VALUE); - draconicWeaponsMaxCapacityUpgradePoints = - Math.max(Math.min(draconicWeaponsMaxUpgradePoints, draconicWeaponsMaxCapacityUpgradePoints), 0); - wyvernBowMaxCapacityUpgradePoints = (int) Math.floor((double) (Integer.MAX_VALUE - wyvernWeaponsBaseStorage) / - (double) Math.max(wyvernWeaponsStoragePerUpgrade, 1)) * - EnumUpgrade.RF_CAPACITY.pointConversion; - wyvernBowMaxUpgrades = - getInteger("tweaks.weapons", "Wyvern Bow: Maximum amount of upgrades", wyvernBowMaxUpgrades, 0, - (wyvernBowMaxDrawSpeedUpgradePoints - wyvernBowMinDrawSpeedUpgradePoints) * - EnumUpgrade.DRAW_SPEED.pointConversion + - (wyvernBowMaxArrowSpeedUpgradePoints - wyvernBowMinArrowSpeedUpgradePoints) * - EnumUpgrade.ARROW_SPEED.pointConversion + - (wyvernBowMaxArrowDamageUpgradePoints - wyvernBowMinArrowDamageUpgradePoints) * - EnumUpgrade.ARROW_DAMAGE.pointConversion + wyvernBowMaxCapacityUpgradePoints); - wyvernBowMaxUpgradePoints = - getInteger("tweaks.weapons", "Wyvern Bow: Maximum amount of upgrade points", wyvernBowMaxUpgradePoints, - wyvernBowMaxUpgrades, Integer.MAX_VALUE); - wyvernBowMaxCapacityUpgradePoints = - Math.max(Math.min(wyvernBowMaxUpgradePoints, wyvernBowMaxCapacityUpgradePoints), 0); - draconicBowMaxCapacityUpgradePoints = (int) Math.floor( - (double) (Integer.MAX_VALUE - draconicWeaponsBaseStorage) / - (double) Math.max(draconicWeaponsStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; - draconicBowMaxUpgrades = - getInteger("tweaks.weapons", "Draconic Bow: Maximum amount of upgrades", draconicBowMaxUpgrades, 0, - (draconicBowMaxDrawSpeedUpgradePoints - draconicBowMinDrawSpeedUpgradePoints) * - EnumUpgrade.DRAW_SPEED.pointConversion + - (draconicBowMaxArrowSpeedUpgradePoints - draconicBowMinArrowSpeedUpgradePoints) * - EnumUpgrade.ARROW_SPEED.pointConversion + - (draconicBowMaxArrowDamageUpgradePoints - draconicBowMinArrowDamageUpgradePoints) * - EnumUpgrade.ARROW_DAMAGE.pointConversion + draconicBowMaxCapacityUpgradePoints); - draconicBowMaxUpgradePoints = - getInteger("tweaks.weapons", "Draconic Bow: Maximum amount of upgrade points", draconicBowMaxUpgradePoints, - draconicBowMaxUpgrades, Integer.MAX_VALUE); - draconicBowMaxCapacityUpgradePoints = - Math.max(Math.min(draconicBowMaxUpgradePoints, draconicBowMaxCapacityUpgradePoints), 0); - draconicStaffMaxCapacityUpgradePoints = (int) Math.floor( - (double) (Integer.MAX_VALUE - draconicToolsBaseStorage * 2 - draconicWeaponsBaseStorage) / - (double) Math.max(draconicToolsStoragePerUpgrade + draconicWeaponsStoragePerUpgrade, 1)) * - EnumUpgrade.RF_CAPACITY.pointConversion; + + private static void syncConfig() { + wyvernArmorBaseStorage = getInteger("energy.armor", "Wyvern Armor: Base energy storage (RF)", wyvernArmorBaseStorage); + wyvernArmorStoragePerUpgrade = getInteger("energy.armor", "Wyvern Armor: Additional energy storage per upgrade installed (RF)", wyvernArmorStoragePerUpgrade); + wyvernArmorMaxTransfer = getInteger("energy.armor", "Wyvern Armor: Maximum energy transfer rate (RF/t)", wyvernArmorMaxTransfer); + wyvernArmorEnergyPerProtectionPoint = getInteger("energy.armor", "Wyvern Armor: Amount of energy required to restore protection point (RF)", wyvernArmorEnergyPerProtectionPoint); + draconicArmorBaseStorage = getInteger("energy.armor", "Draconic Armor: Base energy storage (RF)", draconicArmorBaseStorage); + draconicArmorStoragePerUpgrade = getInteger("energy.armor", "Draconic Armor: Additional energy storage per upgrade installed (RF)", draconicArmorStoragePerUpgrade); + draconicArmorMaxTransfer = getInteger("energy.armor", "Draconic Armor: Maximum energy transfer rate (RF/t)", draconicArmorMaxTransfer); + draconicArmorEnergyPerProtectionPoint = getInteger("energy.armor", "Draconic Armor: Amount of energy required to restore protection point (RF)", draconicArmorEnergyPerProtectionPoint); + draconicArmorEnergyToRemoveEffects = getInteger("energy.armor", "Draconic Armor: Amount of energy required to remove negative effects (RF)", draconicArmorEnergyToRemoveEffects); + wyvernToolsBaseStorage = getInteger("energy.tools", "Wyvern Tools: Base energy storage (RF)", wyvernToolsBaseStorage); + wyvernToolsStoragePerUpgrade = getInteger("energy.tools", "Wyvern Tools: Additional energy storage per upgrade installed (RF)", wyvernToolsStoragePerUpgrade); + wyvernToolsMaxTransfer = getInteger("energy.tools", "Wyvern Tools: Maximum energy transfer rate (RF/t)", wyvernToolsMaxTransfer); + wyvernToolsEnergyPerAction = getInteger("energy.tools", "Wyvern Tools: Amount of energy required to perform action (RF)", wyvernToolsEnergyPerAction); + draconicToolsBaseStorage = getInteger("energy.tools", "Draconic Tools: Base energy storage (RF)", draconicToolsBaseStorage); + draconicToolsStoragePerUpgrade = getInteger("energy.tools", "Draconic Tools: Additional energy storage per upgrade installed (RF)", draconicToolsStoragePerUpgrade); + draconicToolsMaxTransfer = getInteger("energy.tools", "Draconic Tools: Maximum energy transfer rate (RF/t)", draconicToolsMaxTransfer); + draconicToolsEnergyPerAction = getInteger("energy.tools", "Draconic Tools: Amount of energy required to perform action (RF)", draconicToolsEnergyPerAction); + wyvernCapacitorBaseStorage = getInteger("energy.tools", "Wyvern Flux Capacitor: Base energy storage (RF)", wyvernCapacitorBaseStorage); + wyvernCapacitorStoragePerUpgrade = getInteger("energy.tools", "Wyvern Flux Capacitor: Additional energy storage per upgrade installed (RF)", wyvernCapacitorStoragePerUpgrade); + wyvernCapacitorMaxReceive = getInteger("energy.tools", "Wyvern Flux Capacitor: Maximum energy reception rate (RF/t)", wyvernCapacitorMaxReceive); + wyvernCapacitorMaxExtract = getInteger("energy.tools", "Wyvern Flux Capacitor: Maximum energy extraction rate (RF/t)", wyvernCapacitorMaxExtract); + draconicCapacitorBaseStorage = getInteger("energy.tools", "Draconic Flux Capacitor: Base energy storage (RF)", draconicCapacitorBaseStorage); + draconicCapacitorStoragePerUpgrade = getInteger("energy.tools", "Draconic Flux Capacitor: Additional energy storage per upgrade installed (RF)", draconicCapacitorStoragePerUpgrade); + draconicCapacitorMaxReceive = getInteger("energy.tools", "Draconic Flux Capacitor: Maximum energy reception rate (RF/t)", draconicCapacitorMaxReceive); + draconicCapacitorMaxExtract = getInteger("energy.tools", "Draconic Flux Capacitor: Maximum energy extraction rate (RF/t)", draconicCapacitorMaxExtract); + wyvernWeaponsBaseStorage = getInteger("energy.weapons", "Wyvern Weapons: Base energy storage (RF)", wyvernWeaponsBaseStorage); + wyvernWeaponsStoragePerUpgrade = getInteger("energy.weapons", "Wyvern Weapons: Additional energy storage per upgrade installed (RF)", wyvernWeaponsStoragePerUpgrade); + wyvernWeaponsMaxTransfer = getInteger("energy.weapons", "Wyvern Weapons: Maximum energy transfer rate (RF/t)", wyvernWeaponsMaxTransfer); + wyvernWeaponsEnergyPerAttack = getInteger("energy.weapons", "Wyvern Weapons: Amount of energy required to perform attack (RF)", wyvernWeaponsEnergyPerAttack); + wyvernBowEnergyPerShot = getInteger("energy.weapons", "Wyvern Bow: Amount of energy required to shoot (RF)", wyvernBowEnergyPerShot); + draconicWeaponsBaseStorage = getInteger("energy.weapons", "Draconic Weapons: Base energy storage (RF)", draconicWeaponsBaseStorage); + draconicWeaponsStoragePerUpgrade = getInteger("energy.weapons", "Draconic Weapons: Additional energy storage per upgrade installed (RF)", draconicWeaponsStoragePerUpgrade); + draconicWeaponsMaxTransfer = getInteger("energy.weapons", "Draconic Weapons: Maximum energy transfer rate (RF/t)", draconicWeaponsMaxTransfer); + draconicWeaponsEnergyPerAttack = getInteger("energy.weapons", "Draconic Weapons: Amount of energy required to perform attack (RF)", draconicWeaponsEnergyPerAttack); + draconicBowEnergyPerShot = getInteger("energy.weapons", "Draconic Bow: Amount of energy required to shoot (RF)", draconicBowEnergyPerShot); + draconicFireEnergyCostMultiptier = getInteger("energy.weapons", "Arrow of Draconic Fire: Energy cost multiplier", draconicFireEnergyCostMultiptier); + draconiumBlockEnergyToChange = getInteger("energy.misc", "Draconium Block: Amount of energy required to charge (RF)", draconiumBlockEnergyToChange); + draconiumBlockChargingSpeed = getInteger("energy.misc", "Draconium Block: Maximum charging speed (RF/t)", draconiumBlockChargingSpeed); + energyInfuserStorage = getInteger("energy.machines", "Energy Infuser: Energy buffer size (RF)", energyInfuserStorage); + energyInfuserMaxTransfer = getInteger("energy.machines", "Energy Infuser: Maximum energy transfer rate (RF/t)", energyInfuserMaxTransfer); + energyStorageTier1Storage = getLong("energy.machines", "Multiblock Energy Storage Tier 1: Energy buffer size (RF)", energyStorageTier1Storage); + energyStorageTier2Storage = getLong("energy.machines", "Multiblock Energy Storage Tier 2: Energy buffer size (RF)", energyStorageTier2Storage); + energyStorageTier3Storage = getLong("energy.machines", "Multiblock Energy Storage Tier 3: Energy buffer size (RF)", energyStorageTier3Storage); + energyStorageTier4Storage = getLong("energy.machines", "Multiblock Energy Storage Tier 4: Energy buffer size (RF)", energyStorageTier4Storage); + energyStorageTier5Storage = getLong("energy.machines", "Multiblock Energy Storage Tier 5: Energy buffer size (RF)", energyStorageTier5Storage); + energyStorageTier6Storage = getLong("energy.machines", "Multiblock Energy Storage Tier 6: Energy buffer size (RF)", energyStorageTier6Storage); + energyStorageTier7Storage = getLong("energy.machines", "Multiblock Energy Storage Tier 7: Energy buffer size (RF)", energyStorageTier7Storage); + grinderInternalEnergyBufferSize = getInteger("energy.machines", "Mob Grinder: Internal energy buffer size (RF)", grinderInternalEnergyBufferSize); + grinderExternalEnergyBufferSize = getInteger("energy.machines", "Mob Grinder: Main energy buffer size (RF)", grinderExternalEnergyBufferSize); + grinderMaxReceive = getInteger("energy.machines", "Mob Grinder: Maximum energy reception rate (RF/t)", grinderMaxReceive); + grinderEnergyPerKill = getInteger("energy.machines", "Mob Grinder: Amount of energy required to kill entity (RF)", grinderEnergyPerKill); + wyvernArmorMaxCapacityUpgradePoints = (int) Math.floor((double) (Integer.MAX_VALUE - wyvernArmorBaseStorage) / (double) Math.max(wyvernArmorStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; + wyvernArmorMaxUpgrades = getInteger("tweaks.armor", "Wyvern Armor: Maximum amount of upgrades", wyvernArmorMaxUpgrades); + wyvernArmorMaxUpgradePoints = getInteger("tweaks.armor", "Wyvern Armor: Maximum amount of upgrade points", wyvernArmorMaxUpgradePoints, wyvernArmorMaxUpgrades, Integer.MAX_VALUE); + wyvernArmorMaxCapacityUpgradePoints = Math.max(Math.min(wyvernArmorMaxUpgradePoints, wyvernArmorMaxCapacityUpgradePoints), 0); + draconicArmorMaxCapacityUpgradePoints = (int) Math.floor((double) (Integer.MAX_VALUE - draconicArmorBaseStorage) / Math.max(draconicArmorStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; + draconicArmorMaxUpgrades = getInteger("tweaks.armor", "Draconic Armor: Maximum amount of upgrades", draconicArmorMaxUpgrades); + draconicArmorMaxUpgradePoints = getInteger("tweaks.armor", "Draconic Armor: Maximum amount of upgrade points", draconicArmorMaxUpgradePoints, draconicArmorMaxUpgrades, Integer.MAX_VALUE); + draconicArmorMaxCapacityUpgradePoints = Math.max(Math.min(draconicArmorMaxUpgradePoints, draconicArmorMaxCapacityUpgradePoints), 0); + wyvernToolsMaxCapacityUpgradePoints = (int) Math.floor((double) (Integer.MAX_VALUE - wyvernToolsBaseStorage) / (double) Math.max(wyvernToolsStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; + wyvernToolsMaxUpgrades = getInteger("tweaks.tools", "Wyvern Tools: Maximum amount of upgrades", wyvernToolsMaxUpgrades, 0, (wyvernToolsMaxDigAOEUpgradePoints - wyvernToolsMinDigAOEUpgradePoints) * EnumUpgrade.DIG_AOE.pointConversion + + (wyvernToolsMaxDigSpeedUpgradePoints - wyvernToolsMinDigSpeedUpgradePoints) * EnumUpgrade.DIG_SPEED.pointConversion + wyvernToolsMaxCapacityUpgradePoints); + wyvernToolsMaxUpgradePoints = getInteger("tweaks.tools", "Wyvern Tools: Maximum amount of upgrade points", wyvernToolsMaxUpgradePoints, wyvernToolsMaxUpgrades, Integer.MAX_VALUE); + wyvernToolsMaxCapacityUpgradePoints = Math.max(Math.min(wyvernToolsMaxUpgradePoints, wyvernToolsMaxCapacityUpgradePoints), 0); + draconicToolsMaxCapacityUpgradePoints = (int) Math.floor((double) (Integer.MAX_VALUE - draconicToolsBaseStorage) / (double) Math.max(draconicToolsStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; + draconicToolsMaxUpgrades = getInteger("tweaks.tools", "Draconic Tools: Maximum amount of upgrades", draconicToolsMaxUpgrades, 0, (draconicToolsMaxDigAOEUpgradePoints - draconicToolsMinDigAOEUpgradePoints) * EnumUpgrade.DIG_AOE.pointConversion + + (draconicToolsMaxDigSpeedUpgradePoints - draconicToolsMinDigSpeedUpgradePoints) * EnumUpgrade.DIG_SPEED.pointConversion + + (draconicToolsMaxDigDepthUpgradePoints - draconicToolsMinDigDepthUpgradePoints) * EnumUpgrade.DIG_DEPTH.pointConversion + draconicToolsMaxCapacityUpgradePoints); + draconicToolsMaxUpgradePoints = getInteger("tweaks.tools", "Draconic Tools: Maximum amount of upgrade points", draconicToolsMaxUpgradePoints, draconicToolsMaxUpgrades, Integer.MAX_VALUE); + draconicToolsMaxCapacityUpgradePoints = Math.max(Math.min(draconicToolsMaxUpgradePoints, draconicToolsMaxCapacityUpgradePoints), 0); + wyvernWeaponsMaxCapacityUpgradePoints = (int) Math.floor((double) (Integer.MAX_VALUE - wyvernWeaponsBaseStorage) / (double) Math.max(wyvernWeaponsStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; + wyvernWeaponsMaxUpgrades = getInteger("tweaks.weapons", "Wyvern Weapons: Maximum amount of upgrades", wyvernWeaponsMaxUpgrades, 0, (wyvernWeaponsMaxAttackAOEUpgradePoints - wyvernWeaponsMinAttackAOEUpgradePoints) * EnumUpgrade.ATTACK_AOE.pointConversion + + (wyvernWeaponsMaxAttackDamageUpgradePoints - wyvernWeaponsMinAttackDamageUpgradePoints) * EnumUpgrade.ATTACK_DAMAGE.pointConversion + wyvernWeaponsMaxCapacityUpgradePoints); + wyvernWeaponsMaxUpgradePoints = getInteger("tweaks.weapons", "Wyvern Weapons: Maximum amount of upgrade points", wyvernWeaponsMaxUpgradePoints, wyvernWeaponsMaxUpgrades, Integer.MAX_VALUE); + wyvernWeaponsMaxCapacityUpgradePoints = Math.max(Math.min(wyvernWeaponsMaxUpgradePoints, wyvernWeaponsMaxCapacityUpgradePoints), 0); + draconicWeaponsMaxCapacityUpgradePoints = (int) Math.floor((double) (Integer.MAX_VALUE - draconicWeaponsBaseStorage) / (double) Math.max(draconicWeaponsStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; + draconicWeaponsMaxUpgrades = getInteger("tweaks.weapons", "Draconic Weapons: Maximum amount of upgrades", draconicWeaponsMaxUpgrades, 0, (draconicWeaponsMaxAttackAOEUpgradePoints - draconicWeaponsMinAttackAOEUpgradePoints) * EnumUpgrade.ATTACK_AOE.pointConversion + + (draconicWeaponsMaxAttackDamageUpgradePoints - draconicWeaponsMinAttackDamageUpgradePoints) * EnumUpgrade.ARROW_DAMAGE.pointConversion + draconicWeaponsMaxCapacityUpgradePoints); + draconicWeaponsMaxUpgradePoints = getInteger("tweaks.weapons", "Draconic Weapons: Maximum amount of upgrade points", draconicWeaponsMaxUpgradePoints, draconicWeaponsMaxUpgrades, Integer.MAX_VALUE); + draconicWeaponsMaxCapacityUpgradePoints = Math.max(Math.min(draconicWeaponsMaxUpgradePoints, draconicWeaponsMaxCapacityUpgradePoints), 0); + wyvernBowMaxCapacityUpgradePoints = (int) Math.floor((double) (Integer.MAX_VALUE - wyvernWeaponsBaseStorage) / (double) Math.max(wyvernWeaponsStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; + wyvernBowMaxUpgrades = getInteger("tweaks.weapons", "Wyvern Bow: Maximum amount of upgrades", wyvernBowMaxUpgrades, 0, (wyvernBowMaxDrawSpeedUpgradePoints - wyvernBowMinDrawSpeedUpgradePoints) * EnumUpgrade.DRAW_SPEED.pointConversion + + (wyvernBowMaxArrowSpeedUpgradePoints - wyvernBowMinArrowSpeedUpgradePoints) * EnumUpgrade.ARROW_SPEED.pointConversion + + (wyvernBowMaxArrowDamageUpgradePoints - wyvernBowMinArrowDamageUpgradePoints) * EnumUpgrade.ARROW_DAMAGE.pointConversion + wyvernBowMaxCapacityUpgradePoints); + wyvernBowMaxUpgradePoints = getInteger("tweaks.weapons", "Wyvern Bow: Maximum amount of upgrade points", wyvernBowMaxUpgradePoints, wyvernBowMaxUpgrades, Integer.MAX_VALUE); + wyvernBowMaxCapacityUpgradePoints = Math.max(Math.min(wyvernBowMaxUpgradePoints, wyvernBowMaxCapacityUpgradePoints), 0); + draconicBowMaxCapacityUpgradePoints = (int) Math.floor((double) (Integer.MAX_VALUE - draconicWeaponsBaseStorage) / (double) Math.max(draconicWeaponsStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; + draconicBowMaxUpgrades = getInteger("tweaks.weapons", "Draconic Bow: Maximum amount of upgrades", draconicBowMaxUpgrades, 0, (draconicBowMaxDrawSpeedUpgradePoints - draconicBowMinDrawSpeedUpgradePoints) * EnumUpgrade.DRAW_SPEED.pointConversion + + (draconicBowMaxArrowSpeedUpgradePoints - draconicBowMinArrowSpeedUpgradePoints) * EnumUpgrade.ARROW_SPEED.pointConversion + + (draconicBowMaxArrowDamageUpgradePoints - draconicBowMinArrowDamageUpgradePoints) * EnumUpgrade.ARROW_DAMAGE.pointConversion + draconicBowMaxCapacityUpgradePoints); + draconicBowMaxUpgradePoints = getInteger("tweaks.weapons", "Draconic Bow: Maximum amount of upgrade points", draconicBowMaxUpgradePoints, draconicBowMaxUpgrades, Integer.MAX_VALUE); + draconicBowMaxCapacityUpgradePoints = Math.max(Math.min(draconicBowMaxUpgradePoints, draconicBowMaxCapacityUpgradePoints), 0); + draconicStaffMaxCapacityUpgradePoints = (int) Math.floor((double) (Integer.MAX_VALUE - draconicToolsBaseStorage * 2 - draconicWeaponsBaseStorage) / (double) Math.max(draconicToolsStoragePerUpgrade + draconicWeaponsStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; draconicStaffMaxUpgrades = draconicToolsMaxUpgrades + draconicWeaponsMaxUpgrades; draconicStaffMaxUpgradePoints = draconicToolsMaxUpgradePoints + draconicWeaponsMaxUpgradePoints; - draconicStaffMaxCapacityUpgradePoints = - Math.max(Math.min(draconicStaffMaxUpgradePoints, draconicStaffMaxCapacityUpgradePoints), 0); - wyvernCapacitorMaxCapacityUpgradePoints = (int) Math.floor( - (double) (Integer.MAX_VALUE - wyvernCapacitorBaseStorage) / - (double) Math.max(wyvernCapacitorStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; - wyvernCapacitorMaxUpgrades = - getInteger("tweaks.tools", "Wyvern Flux Capacitor: Maximum amount of upgrades", wyvernCapacitorMaxUpgrades, - 0, wyvernCapacitorMaxCapacityUpgradePoints); - wyvernCapacitorMaxUpgradePoints = - getInteger("tweaks.tools", "Wyvern Flux Capacitor: Maximum amount of upgrade points", - wyvernCapacitorMaxUpgradePoints, wyvernCapacitorMaxUpgrades, Integer.MAX_VALUE); - wyvernCapacitorMaxCapacityUpgradePoints = - Math.max(Math.min(wyvernCapacitorMaxUpgradePoints, wyvernCapacitorMaxCapacityUpgradePoints), 0); - draconicCapacitorMaxCapacityUpgradePoints = (int) Math.floor( - (double) (Integer.MAX_VALUE - draconicCapacitorBaseStorage) / - (double) Math.max(draconicCapacitorStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; - draconicCapacitorMaxUpgrades = getInteger("tweaks.tools", "Draconic Flux Capacitor: Maximum amount of upgrades", - draconicCapacitorMaxUpgrades, 0, - draconicCapacitorMaxCapacityUpgradePoints); - draconicCapacitorMaxUpgradePoints = - getInteger("tweaks.tools", "Draconic Flux Capacitor: Maximum amount of upgrade points", - draconicCapacitorMaxUpgradePoints, draconicCapacitorMaxUpgrades, Integer.MAX_VALUE); - draconicCapacitorMaxCapacityUpgradePoints = - Math.max(Math.min(draconicCapacitorMaxUpgradePoints, draconicCapacitorMaxCapacityUpgradePoints), 0); - grinderShouldUseLooting = - getBoolean("tweaks.machines", "Mob Grinder: Use Looting enchantment", grinderShouldUseLooting); - if (config.hasChanged()) - { + draconicStaffMaxCapacityUpgradePoints = Math.max(Math.min(draconicStaffMaxUpgradePoints, draconicStaffMaxCapacityUpgradePoints), 0); + wyvernCapacitorMaxCapacityUpgradePoints = (int) Math.floor((double) (Integer.MAX_VALUE - wyvernCapacitorBaseStorage) / (double) Math.max(wyvernCapacitorStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; + wyvernCapacitorMaxUpgrades = getInteger("tweaks.tools", "Wyvern Flux Capacitor: Maximum amount of upgrades", wyvernCapacitorMaxUpgrades, 0, wyvernCapacitorMaxCapacityUpgradePoints); + wyvernCapacitorMaxUpgradePoints = getInteger("tweaks.tools", "Wyvern Flux Capacitor: Maximum amount of upgrade points", wyvernCapacitorMaxUpgradePoints, wyvernCapacitorMaxUpgrades, Integer.MAX_VALUE); + wyvernCapacitorMaxCapacityUpgradePoints = Math.max(Math.min(wyvernCapacitorMaxUpgradePoints, wyvernCapacitorMaxCapacityUpgradePoints), 0); + draconicCapacitorMaxCapacityUpgradePoints = (int) Math.floor((double) (Integer.MAX_VALUE - draconicCapacitorBaseStorage) / (double) Math.max(draconicCapacitorStoragePerUpgrade, 1)) * EnumUpgrade.RF_CAPACITY.pointConversion; + draconicCapacitorMaxUpgrades = getInteger("tweaks.tools", "Draconic Flux Capacitor: Maximum amount of upgrades", draconicCapacitorMaxUpgrades, 0, draconicCapacitorMaxCapacityUpgradePoints); + draconicCapacitorMaxUpgradePoints = getInteger("tweaks.tools", "Draconic Flux Capacitor: Maximum amount of upgrade points", draconicCapacitorMaxUpgradePoints, draconicCapacitorMaxUpgrades, Integer.MAX_VALUE); + draconicCapacitorMaxCapacityUpgradePoints = Math.max(Math.min(draconicCapacitorMaxUpgradePoints, draconicCapacitorMaxCapacityUpgradePoints), 0); + grinderShouldUseLooting = getBoolean("tweaks.machines", "Mob Grinder: Use Looting enchantment", grinderShouldUseLooting); + if (config.hasChanged()) { config.save(); } } + // This method should be loaded after all mods add blocks => after pre-init - public static void finishLoading() - { - if (config == null) - { + public static void finishLoading() { + if (config == null) { return; } - energyStorageStructureBlock = - getBlock("tweaks.machines", "Multiblock Energy Storage: Main block of structure", Blocks.redstone_block, - "WARNING! Changing of this value will replace blocks of all existing Energy Storage Multiblocks!"); - energyStorageStructureBlockMetadata = - getInteger("tweaks.machines", "Multiblock Energy Storage: Metadata of main block of structure", - energyStorageStructureBlockMetadata, - "WARNING! Changing of this value will replace blocks of all existing Energy Storage " + - "Multiblocks!"); - if (config.hasChanged()) - { + energyStorageStructureBlock = getBlock("tweaks.machines", "Multiblock Energy Storage: Main block of structure", Blocks.redstone_block, "WARNING! Changing of this value will replace blocks of all existing Energy Storage Multiblocks!"); + energyStorageStructureBlockMetadata = getInteger("tweaks.machines", "Multiblock Energy Storage: Metadata of main block of structure", energyStorageStructureBlockMetadata, "WARNING! Changing of this value will replace blocks of all existing Energy Storage " + "Multiblocks!"); + if (config.hasChanged()) { config.save(); } } - private static Block getBlock(String category, String propertyName, Block defaultValue, String comment) - { + + private static Block getBlock(String category, String propertyName, Block defaultValue, String comment) { String defaultName = Block.blockRegistry.getNameForObject(defaultValue); Property property = config.get(category, propertyName, defaultName, comment); String value = property.getString(); - if (value == null || !value.contains(":")) - { + if (value == null || !value.contains(":")) { property.set(defaultName); return defaultValue; } String modId = value.substring(0, value.indexOf(":")); String name = value.substring(value.indexOf(":") + 1); Block block = GameRegistry.findBlock(modId, name); - if (block == null || block instanceof ITileEntityProvider) - { + if (block == null || block instanceof ITileEntityProvider) { property.set(defaultName); return defaultValue; } return block; } - private static boolean getBoolean(String category, String propertyName, boolean defaultValue) - { + + private static boolean getBoolean(String category, String propertyName, boolean defaultValue) { return config.get(category, propertyName, defaultValue).getBoolean(defaultValue); } - private static int getInteger(String categoty, String propertyName, int defaultValue) - { + + private static int getInteger(String categoty, String propertyName, int defaultValue) { return config.get(categoty, propertyName, defaultValue).getInt(defaultValue); } - private static int getInteger(String categoty, String propertyName, int defaultValue, String comment) - { + + private static int getInteger(String categoty, String propertyName, int defaultValue, String comment) { return config.get(categoty, propertyName, defaultValue, comment).getInt(defaultValue); } - private static int getInteger(String category, String propertyName, int defaultValue, int minValue, int maxValue) - { + + private static int getInteger(String category, String propertyName, int defaultValue, int minValue, int maxValue) { Property property = config.get(category, propertyName, defaultValue, "", minValue, maxValue); int value = property.getInt(defaultValue); - if (value < minValue) - { + if (value < minValue) { property.set(minValue); return minValue; } - if (value > maxValue) - { + if (value > maxValue) { property.set(maxValue); return maxValue; } return value; } - private static long getLong(String category, String propertyName, long defaultValue) - { - return (long) config.get(category, propertyName, (double) defaultValue, "", 0D, (double) Long.MAX_VALUE) - .getDouble((double) defaultValue); + + private static long getLong(String category, String propertyName, long defaultValue) { + return (long) config.get(category, propertyName, (double) defaultValue, "", 0D, (double) Long.MAX_VALUE).getDouble((double) defaultValue); } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/handler/ConfigHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/handler/ConfigHandler.java index e13e1559..3a1bb3fb 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/handler/ConfigHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/handler/ConfigHandler.java @@ -11,142 +11,142 @@ import net.minecraftforge.common.config.Configuration; public class ConfigHandler { - public static Configuration config; + public static Configuration config; - //GENERAL - public static int teleporterUsesPerPearl; - public static int soulDropChance; - public static int passiveSoulDropChance; - public static int cometRarity; - public static int chaosIslandSeparation; - public static boolean generateEnderComets; - public static boolean generateChaosIslands; - public static boolean pigmenBloodRage; - public static boolean bowBlockDamage; - public static boolean showUnlocalizedNames; - public static boolean disableLore; - public static boolean invertDPDSB; - public static boolean disableOreSpawnEnd; - public static boolean disableOreSpawnOverworld; - public static boolean disableOreSpawnNether; - public static boolean enableVersionChecker; - public static boolean dragonBreaksBlocks; - public static boolean sumonRitualAccelerated; - public static int[] dragonEggSpawnLocation; - public static int[] oreGenDimentionBlacklist; - public static int[] hudSettings; - private static String[] disabledBlocksItems; - public static List disabledNamesList = new ArrayList(); - public static double maxPlayerSpeed; - private static int[] speedDimBlackList; - public static List speedLimitDimList = new ArrayList(); - public static boolean speedLimitops; - public static boolean rapidlyDespawnMinedItems; - public static boolean useOldArmorModel; - public static boolean useOriginal3DArmorModel; - public static boolean useOldD2DToolTextures; - public static boolean disableGuardianCrystalRespawn; + //GENERAL + public static int teleporterUsesPerPearl; + public static int soulDropChance; + public static int passiveSoulDropChance; + public static int cometRarity; + public static int chaosIslandSeparation; + public static boolean generateEnderComets; + public static boolean generateChaosIslands; + public static boolean pigmenBloodRage; + public static boolean bowBlockDamage; + public static boolean showUnlocalizedNames; + public static boolean disableLore; + public static boolean invertDPDSB; + public static boolean disableOreSpawnEnd; + public static boolean disableOreSpawnOverworld; + public static boolean disableOreSpawnNether; + public static boolean enableVersionChecker; + public static boolean dragonBreaksBlocks; + public static boolean sumonRitualAccelerated; + public static int[] dragonEggSpawnLocation; + public static int[] oreGenDimentionBlacklist; + public static int[] hudSettings; + private static String[] disabledBlocksItems; + public static List disabledNamesList = new ArrayList(); + public static double maxPlayerSpeed; + private static int[] speedDimBlackList; + public static List speedLimitDimList = new ArrayList(); + public static boolean speedLimitops; + public static boolean rapidlyDespawnMinedItems; + public static boolean useOldArmorModel; + public static boolean useOriginal3DArmorModel; + public static boolean useOldD2DToolTextures; + public static boolean disableGuardianCrystalRespawn; public static boolean disableLog; private static String[] itemDislocatorBlacklist; public static Map itemDislocatorBlacklistMap = new HashMap(); - //spawner - public static String[] spawnerList; - public static boolean spawnerListType; + //spawner + public static String[] spawnerList; + public static boolean spawnerListType; - //long range dislocator - public static int dislocator_Min_Range; - public static int dislocator_Max_Range; - public static int admin_dislocator_Min_Range; - public static int admin_dislocator_Max_Range; - public static int admin_dislocator_Detect_Range; + //long range dislocator + public static int dislocator_Min_Range; + public static int dislocator_Max_Range; + public static int admin_dislocator_Min_Range; + public static int admin_dislocator_Max_Range; + public static int admin_dislocator_Detect_Range; - //Potion IDs + //Potion IDs - //Enchantments - public static int reaperEnchantID; + //Enchantments + public static int reaperEnchantID; - //Reactor - public static boolean enableReactorBigBoom; - public static double reactorOutputMultiplier; - public static double reactorFuelUsageMultiplier; + //Reactor + public static boolean enableReactorBigBoom; + public static double reactorOutputMultiplier; + public static double reactorFuelUsageMultiplier; - private static String[] defaultSpawnerList = new String[] {"ExampleMob1", "ExampleMob2", "ExampleMob3 (these examples can be deleted)"}; + private static String[] defaultSpawnerList = new String[]{"ExampleMob1", "ExampleMob2", "ExampleMob3 (these examples can be deleted)"}; - public static void init(File confFile) { - if (config == null) { - config = new Configuration(confFile); - config.load(); - syncConfig(); - } - } + public static void init(File confFile) { + if (config == null) { + config = new Configuration(confFile); + config.load(); + syncConfig(); + } + } - public static void syncConfig() { + public static void syncConfig() { - try { - //General + try { + //General // disableSunDial = config.get(Configuration.CATEGORY_GENERAL, "Disable Sun Dial", 0, "Disable Sun Dial 0:Default, 1:Disable recipe, 2:Disable completely").getInt(0); // disableXrayBlock = config.get(Configuration.CATEGORY_GENERAL, "Disable Xray Block", 0, "Disable Distortion Flame 0:Default, 1:Disable recipe, 2:Disable completely").getInt(0); - teleporterUsesPerPearl = config.get(Configuration.CATEGORY_GENERAL, "Teleporter Uses PerPearl", 1, "Charm of Dislocation uses per Ender pearl").getInt(1); - bowBlockDamage = config.get(Configuration.CATEGORY_GENERAL, "Bow Block Damage", true, "Dose Draconic bow explosion damage blocks").getBoolean(true); - showUnlocalizedNames = config.get(Configuration.CATEGORY_GENERAL, "Show Unlocalized Names", false, "If set to true the unlocalized name of every block and item will be displayed in its tool tip").getBoolean(false); - soulDropChance = config.get(Configuration.CATEGORY_GENERAL, "soulDropChance", 1000, "Mobs have a 1 in this number chance to drop a soul", 1, Integer.MAX_VALUE).getInt(1000); - passiveSoulDropChance = config.get(Configuration.CATEGORY_GENERAL, "passiveSoulDropChance", 800, "Passive (Animals) Mobs have a 1 in this number chance to drop a soul", 1, Integer.MAX_VALUE).getInt(800); - cometRarity = config.get(Configuration.CATEGORY_GENERAL, "Ender Comet Rarity", 10000, "Ender Comet has a 1 in {this number} chance to spawn in each chunk").getInt(10000); - generateEnderComets = config.get(Configuration.CATEGORY_GENERAL, "Generate Ender Comets", true, "Should Ender comets be generated").getBoolean(true); - generateChaosIslands = config.get(Configuration.CATEGORY_GENERAL, "Generate Chaos Islands", true, "Should Chaos Islands be generated").getBoolean(true); - pigmenBloodRage = config.get(Configuration.CATEGORY_GENERAL, "Pigmen Blood Rage", true, "Is Pigmen blood rage active").getBoolean(true); - disableLore = config.get(Configuration.CATEGORY_GENERAL, "Disable Item Lore", false, "Set to true to disable all item lore").getBoolean(false); - invertDPDSB = config.get(Configuration.CATEGORY_GENERAL, "InvertDPDSB", false, "Invert Dislocator Pedestal display name shift behavior").getBoolean(false); - //First is tool hud second is armor hud - //x, y, x, y, scale, scale, fademode, fademode, rotateArmor, armorText, hudEnabled, shieldEnabled - hudSettings = config.get("Gui Stuff", "HUD Settings", new int[] { 996, 825, 69, 907, 90, 100, 3, 0, 1, 1, 1, 1}, "Used to store the position of the armor ant tool HUD's. This should not be modified", Integer.MIN_VALUE, Integer.MAX_VALUE, true, 12).getIntList(); - disableOreSpawnEnd = config.get(Configuration.CATEGORY_GENERAL, "Disable Ore Spawn (End)", false, "Set to true to prevent draconium ore from spawning in the end").getBoolean(false); - disableOreSpawnNether = config.get(Configuration.CATEGORY_GENERAL, "Disable Ore Spawn (Nether)", false, "Set to true to prevent draconium ore from spawning in the nether").getBoolean(false); - disableOreSpawnOverworld = config.get(Configuration.CATEGORY_GENERAL, "Disable Ore Spawn (Overworld)", false, "Set to true to prevent draconium ore from spawning in the overworld").getBoolean(false); - enableVersionChecker = config.get(Configuration.CATEGORY_GENERAL, "Enable version checker", true, "Set to false to disable the version checker").getBoolean(true); - dragonBreaksBlocks = config.get(Configuration.CATEGORY_GENERAL, "Can dragon break blocks", true, "Set to false to disable the DE dragons ability to break blocks (dose not effect vanilla dragon)").getBoolean(true); - dragonEggSpawnLocation = config.get(Configuration.CATEGORY_GENERAL, "Dragon egg spawn location", new int[] {0, 0, 0}, "Sets the exact location to spawn the dragon egg and disables the portal spawn (dose not effect vanilla dragon)").getIntList(); - oreGenDimentionBlacklist = config.get(Configuration.CATEGORY_GENERAL, "Ore gen dimension blacklist", new int[0], "Add the id's of dimensions you do not want draconium ore to spawn in").getIntList(); - disabledBlocksItems = config.getStringList("Disabled Blocks & Items", Configuration.CATEGORY_GENERAL, new String[0], "add the unlocalized name of a block or item to this list to disable it"); - maxPlayerSpeed = config.get(Configuration.CATEGORY_GENERAL, "Player speed cap", 10D, "Limits the max speed of players. Recommend between 0.5 - 1.0 for servers").getDouble(10D); - speedDimBlackList = config.get(Configuration.CATEGORY_GENERAL, "Speed limit Dim black lack list", new int[] {1}, "A list of dimensions the speed limit will not effect (speed limit is not so really required in the end)").getIntList(); - speedLimitops = config.get(Configuration.CATEGORY_GENERAL, "Speed limit effects ops", false, "Dose the speed limit effect ops").getBoolean(false); - rapidlyDespawnMinedItems = config.get(Configuration.CATEGORY_GENERAL, "Rapidly despawn aoe mined items", false, "If true items dropped by a tool in aoe mode will despawn after 5 seconds").getBoolean(false); - useOldArmorModel = config.get(Configuration.CATEGORY_GENERAL, "Use old armor model", false, "If true the armor will use the original vanilla 2D model instead of the new 3D models").getBoolean(false); - sumonRitualAccelerated = config.get(Configuration.CATEGORY_GENERAL, "Fast Summon Ritual", false, "If true the resurrection ritual will be a lot faster").getBoolean(false); - useOldD2DToolTextures = config.get(Configuration.CATEGORY_GENERAL, "Use old 2D tool textures", false, "If true the 3D tool models will be replaced with standard 2D textures").getBoolean(false); - chaosIslandSeparation = config.get(Configuration.CATEGORY_GENERAL, "Chaos Island Separation", 10000, "This sets how far apart the chaos islands will spawn. The islands spawn in a grid pattern.").getInt(10000); - useOriginal3DArmorModel = config.get(Configuration.CATEGORY_GENERAL, "Use the original 3D armor models", false, "If true the original 3D armor models created by Skeletonpunk will be used instead of the current ones").getBoolean(false); - disableGuardianCrystalRespawn = config.get(Configuration.CATEGORY_GENERAL, "Disable Guardian Crystal Respawn", false, "(Wuss mode) Setting this to true will disable the chaos guardians ability to respawn healing crystals. Under certain circumstances such as on a Spigot server where entity render distance is significantly lower this may be required.").getBoolean(false); - itemDislocatorBlacklist = config.getStringList("Item Dislocator Blacklist", Configuration.CATEGORY_GENERAL, new String[] {"appliedenergistics2:item.ItemCrystalSeed"}, "A list of items of items that should be ignored by the item dislocator. Use the items registry name e.g. minecraft:apple you can also add a meta value like so minecraft:wool|4"); + teleporterUsesPerPearl = config.get(Configuration.CATEGORY_GENERAL, "Teleporter Uses PerPearl", 1, "Charm of Dislocation uses per Ender pearl").getInt(1); + bowBlockDamage = config.get(Configuration.CATEGORY_GENERAL, "Bow Block Damage", true, "Dose Draconic bow explosion damage blocks").getBoolean(true); + showUnlocalizedNames = config.get(Configuration.CATEGORY_GENERAL, "Show Unlocalized Names", false, "If set to true the unlocalized name of every block and item will be displayed in its tool tip").getBoolean(false); + soulDropChance = config.get(Configuration.CATEGORY_GENERAL, "soulDropChance", 1000, "Mobs have a 1 in this number chance to drop a soul", 1, Integer.MAX_VALUE).getInt(1000); + passiveSoulDropChance = config.get(Configuration.CATEGORY_GENERAL, "passiveSoulDropChance", 800, "Passive (Animals) Mobs have a 1 in this number chance to drop a soul", 1, Integer.MAX_VALUE).getInt(800); + cometRarity = config.get(Configuration.CATEGORY_GENERAL, "Ender Comet Rarity", 10000, "Ender Comet has a 1 in {this number} chance to spawn in each chunk").getInt(10000); + generateEnderComets = config.get(Configuration.CATEGORY_GENERAL, "Generate Ender Comets", true, "Should Ender comets be generated").getBoolean(true); + generateChaosIslands = config.get(Configuration.CATEGORY_GENERAL, "Generate Chaos Islands", true, "Should Chaos Islands be generated").getBoolean(true); + pigmenBloodRage = config.get(Configuration.CATEGORY_GENERAL, "Pigmen Blood Rage", true, "Is Pigmen blood rage active").getBoolean(true); + disableLore = config.get(Configuration.CATEGORY_GENERAL, "Disable Item Lore", false, "Set to true to disable all item lore").getBoolean(false); + invertDPDSB = config.get(Configuration.CATEGORY_GENERAL, "InvertDPDSB", false, "Invert Dislocator Pedestal display name shift behavior").getBoolean(false); + //First is tool hud second is armor hud + //x, y, x, y, scale, scale, fademode, fademode, rotateArmor, armorText, hudEnabled, shieldEnabled + hudSettings = config.get("Gui Stuff", "HUD Settings", new int[]{996, 825, 69, 907, 90, 100, 3, 0, 1, 1, 1, 1}, "Used to store the position of the armor ant tool HUD's. This should not be modified", Integer.MIN_VALUE, Integer.MAX_VALUE, true, 12).getIntList(); + disableOreSpawnEnd = config.get(Configuration.CATEGORY_GENERAL, "Disable Ore Spawn (End)", false, "Set to true to prevent draconium ore from spawning in the end").getBoolean(false); + disableOreSpawnNether = config.get(Configuration.CATEGORY_GENERAL, "Disable Ore Spawn (Nether)", false, "Set to true to prevent draconium ore from spawning in the nether").getBoolean(false); + disableOreSpawnOverworld = config.get(Configuration.CATEGORY_GENERAL, "Disable Ore Spawn (Overworld)", false, "Set to true to prevent draconium ore from spawning in the overworld").getBoolean(false); + enableVersionChecker = config.get(Configuration.CATEGORY_GENERAL, "Enable version checker", true, "Set to false to disable the version checker").getBoolean(true); + dragonBreaksBlocks = config.get(Configuration.CATEGORY_GENERAL, "Can dragon break blocks", true, "Set to false to disable the DE dragons ability to break blocks (dose not effect vanilla dragon)").getBoolean(true); + dragonEggSpawnLocation = config.get(Configuration.CATEGORY_GENERAL, "Dragon egg spawn location", new int[]{0, 0, 0}, "Sets the exact location to spawn the dragon egg and disables the portal spawn (dose not effect vanilla dragon)").getIntList(); + oreGenDimentionBlacklist = config.get(Configuration.CATEGORY_GENERAL, "Ore gen dimension blacklist", new int[0], "Add the id's of dimensions you do not want draconium ore to spawn in").getIntList(); + disabledBlocksItems = config.getStringList("Disabled Blocks & Items", Configuration.CATEGORY_GENERAL, new String[0], "add the unlocalized name of a block or item to this list to disable it"); + maxPlayerSpeed = config.get(Configuration.CATEGORY_GENERAL, "Player speed cap", 10D, "Limits the max speed of players. Recommend between 0.5 - 1.0 for servers").getDouble(10D); + speedDimBlackList = config.get(Configuration.CATEGORY_GENERAL, "Speed limit Dim black lack list", new int[]{1}, "A list of dimensions the speed limit will not effect (speed limit is not so really required in the end)").getIntList(); + speedLimitops = config.get(Configuration.CATEGORY_GENERAL, "Speed limit effects ops", false, "Dose the speed limit effect ops").getBoolean(false); + rapidlyDespawnMinedItems = config.get(Configuration.CATEGORY_GENERAL, "Rapidly despawn aoe mined items", false, "If true items dropped by a tool in aoe mode will despawn after 5 seconds").getBoolean(false); + useOldArmorModel = config.get(Configuration.CATEGORY_GENERAL, "Use old armor model", false, "If true the armor will use the original vanilla 2D model instead of the new 3D models").getBoolean(false); + sumonRitualAccelerated = config.get(Configuration.CATEGORY_GENERAL, "Fast Summon Ritual", false, "If true the resurrection ritual will be a lot faster").getBoolean(false); + useOldD2DToolTextures = config.get(Configuration.CATEGORY_GENERAL, "Use old 2D tool textures", false, "If true the 3D tool models will be replaced with standard 2D textures").getBoolean(false); + chaosIslandSeparation = config.get(Configuration.CATEGORY_GENERAL, "Chaos Island Separation", 10000, "This sets how far apart the chaos islands will spawn. The islands spawn in a grid pattern.").getInt(10000); + useOriginal3DArmorModel = config.get(Configuration.CATEGORY_GENERAL, "Use the original 3D armor models", false, "If true the original 3D armor models created by Skeletonpunk will be used instead of the current ones").getBoolean(false); + disableGuardianCrystalRespawn = config.get(Configuration.CATEGORY_GENERAL, "Disable Guardian Crystal Respawn", false, "(Wuss mode) Setting this to true will disable the chaos guardians ability to respawn healing crystals. Under certain circumstances such as on a Spigot server where entity render distance is significantly lower this may be required.").getBoolean(false); + itemDislocatorBlacklist = config.getStringList("Item Dislocator Blacklist", Configuration.CATEGORY_GENERAL, new String[]{"appliedenergistics2:item.ItemCrystalSeed"}, "A list of items of items that should be ignored by the item dislocator. Use the items registry name e.g. minecraft:apple you can also add a meta value like so minecraft:wool|4"); disableLog = config.get(Configuration.CATEGORY_GENERAL, "Disable Log", false, "If you are having issued with console spam that you cant fix setting this to true will disable all log output from Draconic Evolution (Not recommended)").getBoolean(false); - //Spawner - spawnerListType = config.get("spawner", "listType", false, "Sets weather the spawner list is a white list or a black list (true = white list false = black list)").getBoolean(false); - spawnerList = config.getStringList("Spawn List", "spawner", defaultSpawnerList, "List of names that will be ether accepted or rejected by the spawner depending on the list type"); + //Spawner + spawnerListType = config.get("spawner", "listType", false, "Sets weather the spawner list is a white list or a black list (true = white list false = black list)").getBoolean(false); + spawnerList = config.getStringList("Spawn List", "spawner", defaultSpawnerList, "List of names that will be ether accepted or rejected by the spawner depending on the list type"); - //LRD - admin_dislocator_Min_Range = config.get("long range dislocator", "Dislocator Min Range", 1000).getInt(1000); - admin_dislocator_Max_Range = config.get("long range dislocator", "Dislocator Max Range", 10000).getInt(10000); - admin_dislocator_Detect_Range = config.get("long range dislocator", "Admin Dislocator Detect Range", 5).getInt(5); + //LRD + admin_dislocator_Min_Range = config.get("long range dislocator", "Dislocator Min Range", 1000).getInt(1000); + admin_dislocator_Max_Range = config.get("long range dislocator", "Dislocator Max Range", 10000).getInt(10000); + admin_dislocator_Detect_Range = config.get("long range dislocator", "Admin Dislocator Detect Range", 5).getInt(5); - //Potions + //Potions // potionFlightID = config.get("magic id's", "potionFlightID", 50).getInt(50); - //Enchantments - reaperEnchantID = config.get("magicId's", "Reaper Enchant id", 180).getInt(180); + //Enchantments + reaperEnchantID = config.get("magicId's", "Reaper Enchant id", 180).getInt(180); - //Reactor - enableReactorBigBoom = config.get("Draconic Reactor", "EnableBigExplosion", true, "Setting this to false will reduce the reactor explosion to little more then a tnt blast").getBoolean(true); - reactorFuelUsageMultiplier = config.get("Draconic Reactor", "FuelUsageMultiplier", 1, "Use this to adjust how quickly the reactor uses fuel", 0, 1000000).getDouble(1); - reactorOutputMultiplier = config.get("Draconic Reactor", "EnergyOutputMultiplier", 1, "Use this to adjust the output of the reactor", 0, 1000000).getDouble(1); + //Reactor + enableReactorBigBoom = config.get("Draconic Reactor", "EnableBigExplosion", true, "Setting this to false will reduce the reactor explosion to little more then a tnt blast").getBoolean(true); + reactorFuelUsageMultiplier = config.get("Draconic Reactor", "FuelUsageMultiplier", 1, "Use this to adjust how quickly the reactor uses fuel", 0, 1000000).getDouble(1); + reactorOutputMultiplier = config.get("Draconic Reactor", "EnergyOutputMultiplier", 1, "Use this to adjust the output of the reactor", 0, 1000000).getDouble(1); disabledNamesList.clear(); - for (String s : disabledBlocksItems) { + for (String s : disabledBlocksItems) { disabledNamesList.add(s); } @@ -156,16 +156,15 @@ public class ConfigHandler { } itemDislocatorBlacklistMap.clear(); - for (String s : itemDislocatorBlacklist){ - if (s.contains("|")){ - itemDislocatorBlacklistMap.put(s.substring(0, s.indexOf("|")), Integer.parseInt(s.substring(s.indexOf("|")+1))); - } - else{ + for (String s : itemDislocatorBlacklist) { + if (s.contains("|")) { + itemDislocatorBlacklistMap.put(s.substring(0, s.indexOf("|")), Integer.parseInt(s.substring(s.indexOf("|") + 1))); + } else { itemDislocatorBlacklistMap.put(s, -1); } } - if (disableLog){ + if (disableLog) { disableLog = false; LogHelper.warn("###########################################"); LogHelper.warn("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"); @@ -175,14 +174,14 @@ public class ConfigHandler { disableLog = true; } } - catch (Exception e) { - LogHelper.error("Unable to load Config"); - e.printStackTrace(); - } - finally { - if (config.hasChanged()) config.save(); - } - } + catch (Exception e) { + LogHelper.error("Unable to load Config"); + e.printStackTrace(); + } + finally { + if (config.hasChanged()) config.save(); + } + } } /* { diff --git a/src/main/java/com/brandon3055/draconicevolution/common/handler/ContributorHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/handler/ContributorHandler.java index 3e7e5df9..ff514fb7 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/handler/ContributorHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/handler/ContributorHandler.java @@ -29,253 +29,250 @@ import java.util.UUID; */ public class ContributorHandler { - public static Map contributors = new LinkedHashMap(); - public static boolean successfulLoad = false; - private static DLThread thread; - private static ModelContributorWings wings = new ModelContributorWings(); + public static Map contributors = new LinkedHashMap(); + public static boolean successfulLoad = false; + private static DLThread thread; + private static ModelContributorWings wings = new ModelContributorWings(); - public static void init(){ - thread = new DLThread(); - thread.start(); - } + public static void init() { + thread = new DLThread(); + thread.start(); + } - public static void render(RenderPlayerEvent.Specials event) { - if (isPlayerContributor(event.entityPlayer)){ - Contributor contributor = contributors.get(event.entityPlayer.getCommandSenderName()); + public static void render(RenderPlayerEvent.Specials event) { + if (isPlayerContributor(event.entityPlayer)) { + Contributor contributor = contributors.get(event.entityPlayer.getCommandSenderName()); - if (contributor.contributionLevel >= 1 && (contributor.contributorWingsEnabled)) renderWings(event); - if (contributor.contribution != null && contributor.contribution.toLowerCase().contains("patreon") && contributor.patreonBadgeEnabled) renderBadge(event); - } - } + if (contributor.contributionLevel >= 1 && (contributor.contributorWingsEnabled)) renderWings(event); + if (contributor.contribution != null && contributor.contribution.toLowerCase().contains("patreon") && contributor.patreonBadgeEnabled) + renderBadge(event); + } + } - public static boolean isPlayerContributor(EntityPlayer player) { - return contributors.containsKey(player.getCommandSenderName()) && contributors.get(player.getCommandSenderName()).isUserValid(player); - } + public static boolean isPlayerContributor(EntityPlayer player) { + return contributors.containsKey(player.getCommandSenderName()) && contributors.get(player.getCommandSenderName()).isUserValid(player); + } - private static void renderWings(RenderPlayerEvent event){ - ResourceHandler.bindResource("textures/models/ContributorWings.png"); - GL11.glColor4f(1F, 1F, 1F, 1F); - wings.render(event.entityPlayer, 0F, 0F, 0F, 0F, event.partialRenderTick, 1F / 16F); - } + private static void renderWings(RenderPlayerEvent event) { + ResourceHandler.bindResource("textures/models/ContributorWings.png"); + GL11.glColor4f(1F, 1F, 1F, 1F); + wings.render(event.entityPlayer, 0F, 0F, 0F, 0F, event.partialRenderTick, 1F / 16F); + } - private static void renderBadge(RenderPlayerEvent event){ - ResourceHandler.bindResource("textures/special/PatreonBadge.png"); - Tessellator tess = Tessellator.instance; - GL11.glPushMatrix(); + private static void renderBadge(RenderPlayerEvent event) { + ResourceHandler.bindResource("textures/special/PatreonBadge.png"); + Tessellator tess = Tessellator.instance; + GL11.glPushMatrix(); - if (event.entityPlayer.isSneaking()){ - GL11.glRotatef(29.0F, 1.0F, 0.0F, 0F); - } + if (event.entityPlayer.isSneaking()) { + GL11.glRotatef(29.0F, 1.0F, 0.0F, 0F); + } - double x = 0.01; - double y = 0.04; - double z = -0.13; - double xSize = 0.22; - double ySize = 0.22; + double x = 0.01; + double y = 0.04; + double z = -0.13; + double xSize = 0.22; + double ySize = 0.22; - tess.startDrawingQuads(); - tess.setColorRGBA_F(1F, 1F, 1F, 1F); - tess.addVertexWithUV(x, y, z, 0, 0); - tess.addVertexWithUV(x, y+ySize, z, 0, 1); - tess.addVertexWithUV(x+xSize, y+ySize, z, 1, 1); - tess.addVertexWithUV(x+xSize, y, z, 1, 0); - tess.draw(); + tess.startDrawingQuads(); + tess.setColorRGBA_F(1F, 1F, 1F, 1F); + tess.addVertexWithUV(x, y, z, 0, 0); + tess.addVertexWithUV(x, y + ySize, z, 0, 1); + tess.addVertexWithUV(x + xSize, y + ySize, z, 1, 1); + tess.addVertexWithUV(x + xSize, y, z, 1, 0); + tess.draw(); - GL11.glDepthFunc(GL11.GL_EQUAL); - GL11.glDisable(GL11.GL_LIGHTING); - ResourceHandler.bindTexture(ResourceHandler.getResourceWOP("textures/misc/enchanted_item_glint.png")); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); - float f11 = 0.76F; - GL11.glColor4f(0.9F * f11, 0.8F * f11, 0.1F * f11, 1.0F); - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glPushMatrix(); + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + ResourceHandler.bindTexture(ResourceHandler.getResourceWOP("textures/misc/enchanted_item_glint.png")); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + float f11 = 0.76F; + GL11.glColor4f(0.9F * f11, 0.8F * f11, 0.1F * f11, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); - float f12 = 0.125F; - GL11.glScalef(f12, f12, f12); - float f13 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; - GL11.glTranslatef(f13, 0.0F, 0.0F); - GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + float f12 = 0.125F; + GL11.glScalef(f12, f12, f12); + float f13 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f13, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); - tess.startDrawingQuads(); - tess.addVertexWithUV(x, y, z, 0, 0); - tess.addVertexWithUV(x, y+ySize, z, 0, 1); - tess.addVertexWithUV(x+xSize, y+ySize, z, 1, 1); - tess.addVertexWithUV(x+xSize, y, z, 1, 0); - tess.draw(); + tess.startDrawingQuads(); + tess.addVertexWithUV(x, y, z, 0, 0); + tess.addVertexWithUV(x, y + ySize, z, 0, 1); + tess.addVertexWithUV(x + xSize, y + ySize, z, 1, 1); + tess.addVertexWithUV(x + xSize, y, z, 1, 0); + tess.draw(); - GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glScalef(f12, f12, f12); - f13 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; - GL11.glTranslatef(-f13, 0.0F, 0.0F); - GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f12, f12, f12); + f13 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f13, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); - tess.startDrawingQuads(); - tess.addVertexWithUV(x, y, z, 0, 0); - tess.addVertexWithUV(x, y+ySize, z, 0, 1); - tess.addVertexWithUV(x+xSize, y+ySize, z, 1, 1); - tess.addVertexWithUV(x+xSize, y, z, 1, 0); - tess.draw(); + tess.startDrawingQuads(); + tess.addVertexWithUV(x, y, z, 0, 0); + tess.addVertexWithUV(x, y + ySize, z, 0, 1); + tess.addVertexWithUV(x + xSize, y + ySize, z, 1, 1); + tess.addVertexWithUV(x + xSize, y, z, 1, 0); + tess.draw(); - GL11.glPopMatrix(); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDepthFunc(GL11.GL_LEQUAL); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glPopMatrix(); + } - public static void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) { - if (event.player instanceof EntityPlayerMP) { - for (String contribName : ContributorHandler.contributors.keySet()) { - for (String name : FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames()) { - if (name.equals(contribName)) { - ContributorHandler.Contributor contributor = ContributorHandler.contributors.get(contribName); - DraconicEvolution.network.sendTo(new ContributorPacket(contribName, contributor.contributorWingsEnabled, contributor.patreonBadgeEnabled), (EntityPlayerMP) event.player); - } - } - } - } - } + public static void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) { + if (event.player instanceof EntityPlayerMP) { + for (String contribName : ContributorHandler.contributors.keySet()) { + for (String name : FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames()) { + if (name.equals(contribName)) { + ContributorHandler.Contributor contributor = ContributorHandler.contributors.get(contribName); + DraconicEvolution.network.sendTo(new ContributorPacket(contribName, contributor.contributorWingsEnabled, contributor.patreonBadgeEnabled), (EntityPlayerMP) event.player); + } + } + } + } + } - //region Reading online contributors list - private static void readFile(){ - File cFile = new File(FileHandler.configFolder, "/draconicevolution/contributors.json"); + //region Reading online contributors list + private static void readFile() { + File cFile = new File(FileHandler.configFolder, "/draconicevolution/contributors.json"); - if (!cFile.exists()){ - LogHelper.error("Could not find contributors file"); - return; - } + if (!cFile.exists()) { + LogHelper.error("Could not find contributors file"); + return; + } - try - { - JsonReader reader = new JsonReader(new FileReader(cFile)); - reader.setLenient(true); + try { + JsonReader reader = new JsonReader(new FileReader(cFile)); + reader.setLenient(true); - reader.beginArray(); + reader.beginArray(); - while (reader.hasNext()) - { - reader.beginObject(); + while (reader.hasNext()) { + reader.beginObject(); - Contributor contributor = new Contributor(); + Contributor contributor = new Contributor(); - while (reader.hasNext()) - { - String name = reader.nextName(); + while (reader.hasNext()) { + String name = reader.nextName(); - if (name.equals("name")) contributor.name = reader.nextString(); - else if (name.equals("ign")) contributor.ign = reader.nextString(); - else if (name.equals("contribution")) contributor.contribution = reader.nextString(); - else if (name.equals("details")) contributor.details = reader.nextString(); - else if (name.equals("website")) contributor.website = reader.nextString(); - else if (name.equals("contributionLevel")) contributor.contributionLevel = reader.nextInt(); - } + if (name.equals("name")) contributor.name = reader.nextString(); + else if (name.equals("ign")) contributor.ign = reader.nextString(); + else if (name.equals("contribution")) contributor.contribution = reader.nextString(); + else if (name.equals("details")) contributor.details = reader.nextString(); + else if (name.equals("website")) contributor.website = reader.nextString(); + else if (name.equals("contributionLevel")) contributor.contributionLevel = reader.nextInt(); + } - contributors.put(contributor.ign, contributor); + contributors.put(contributor.ign, contributor); - reader.endObject(); - } + reader.endObject(); + } - reader.endArray(); + reader.endArray(); - reader.close(); - cFile.delete(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } + reader.close(); + cFile.delete(); + } + catch (Exception e) { + e.printStackTrace(); + } + } - public static void tick(){ + public static void tick() { - if (thread == null) { - return; - } + if (thread == null) { + return; + } - if (thread.isFinished()){ - thread = null; - readFile(); - successfulLoad = true; - } - else if (thread.isFailed()){ - thread = null; - } - } + if (thread.isFinished()) { + thread = null; + readFile(); + successfulLoad = true; + } else if (thread.isFailed()) { + thread = null; + } + } - public static class DLThread extends Thread { + public static class DLThread extends Thread { - private boolean finished = false; - private boolean failed = false; + private boolean finished = false; + private boolean failed = false; - public DLThread(){ - super("DE Contributors DL Thread"); - } + public DLThread() { + super("DE Contributors DL Thread"); + } - @Override - public void run() { - super.run(); + @Override + public void run() { + super.run(); - try - { - URL url = new URL("http://www.brandon3055.com/json/DEContributors.json"); - File cFile = new File(FileHandler.configFolder, "/draconicevolution/contributors.json"); + try { + URL url = new URL("http://www.brandon3055.com/json/DEContributors.json"); + File cFile = new File(FileHandler.configFolder, "/draconicevolution/contributors.json"); - InputStream is = url.openStream(); - OutputStream os = new FileOutputStream(cFile); + InputStream is = url.openStream(); + OutputStream os = new FileOutputStream(cFile); - IOUtils.copy(is, os); + IOUtils.copy(is, os); - is.close(); - os.close(); - finished = true; - } - catch (Exception e) - { - LogHelper.error("Failed to download contributors list"); - failed = true; - e.printStackTrace(); - } + is.close(); + os.close(); + finished = true; + } + catch (Exception e) { + LogHelper.error("Failed to download contributors list"); + failed = true; + e.printStackTrace(); + } - } + } - public boolean isFinished() { - return finished; - } + public boolean isFinished() { + return finished; + } - public boolean isFailed() { - return failed; - } - } - //endregion + public boolean isFailed() { + return failed; + } + } + //endregion - public static class Contributor { - public String name; - public String ign; - public String contribution; - public String details; - public String website; - public int contributionLevel; - /**0=Disabled, 1=Enabled when flying, 2=Always Enabled*/ - public boolean contributorWingsEnabled = true; - public boolean patreonBadgeEnabled = true; - private boolean validated = false; - private boolean isValid; + public static class Contributor { + public String name; + public String ign; + public String contribution; + public String details; + public String website; + public int contributionLevel; + /** + * 0=Disabled, 1=Enabled when flying, 2=Always Enabled + */ + public boolean contributorWingsEnabled = true; + public boolean patreonBadgeEnabled = true; + private boolean validated = false; + private boolean isValid; - public Contributor() {} + public Contributor() { + } - public boolean isUserValid(EntityPlayer player){ - if (!validated){ - isValid = !UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getCommandSenderName()).getBytes(Charsets.UTF_8)).equals(player.getUniqueID()); - } - return isValid; - } + public boolean isUserValid(EntityPlayer player) { + if (!validated) { + isValid = !UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getCommandSenderName()).getBytes(Charsets.UTF_8)).equals(player.getUniqueID()); + } + return isValid; + } - @Override - public String toString() { - return "[Contributor: "+name+", Contribution: "+contribution+", Details: "+details+", Website: "+website+"]"; - } - } + @Override + public String toString() { + return "[Contributor: " + name + ", Contribution: " + contribution + ", Details: " + details + ", Website: " + website + "]"; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/handler/CraftingHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/handler/CraftingHandler.java index c0be1bc9..6229c5d3 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/handler/CraftingHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/handler/CraftingHandler.java @@ -16,216 +16,232 @@ import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; public class CraftingHandler { - public static void init() - { - //todo In 1.8-1.9 when the feature modals are implemented add a dependency system to automatically disable a recipe if a required component is disabled + public static void init() { + //todo In 1.8-1.9 when the feature modals are implemented add a dependency system to automatically disable a recipe if a required component is disabled - ItemStack mobSoul = new ItemStack(ModItems.mobSoul); - ItemNBTHelper.setString(mobSoul, "Name", "Any"); + ItemStack mobSoul = new ItemStack(ModItems.mobSoul); + ItemNBTHelper.setString(mobSoul, "Name", "Any"); - //Components Key[C=Corner, S=Side, M=Middle ] - addOre(ModItems.draconicCore, "CSC", "SMS", "CSC", 'C', "ingotGold", 'S', ModItems.draconiumIngot, 'M', "gemDiamond"); - add(ModItems.wyvernCore, "CSC", "SMS", "CSC", 'C', ModItems.draconiumIngot, 'S', ModItems.draconicCore, 'M', Items.nether_star); - addOre(ModItems.awakenedCore, "CSC", "SCS", "CSC", 'C', "ingotDraconiumAwakened", 'S', ModItems.wyvernCore); - addOre(ModItems.chaoticCore, "ACA", "CSC", "ACA", 'A', "ingotDraconiumAwakened", 'C', ModItems.awakenedCore, 'S', ModItems.chaosShard); - add(ModItems.wyvernEnergyCore, "CSC", "SMS", "CSC", 'C', ModItems.draconiumIngot, 'S', Blocks.redstone_block, 'M', ModItems.draconicCore); - addOre(ModItems.draconicEnergyCore, "CSC", "SMS", "CSC", 'C', "ingotDraconiumAwakened", 'S', ModItems.wyvernEnergyCore, 'M', ModItems.wyvernCore); - //addOre(ModItems.draconiumBlend, " D ", "DID", " D ", 'I', "ingotIron", 'D', ModItems.draconiumDust); + //Components Key[C=Corner, S=Side, M=Middle ] + addOre(ModItems.draconicCore, "CSC", "SMS", "CSC", 'C', "ingotGold", 'S', ModItems.draconiumIngot, 'M', "gemDiamond"); + add(ModItems.wyvernCore, "CSC", "SMS", "CSC", 'C', ModItems.draconiumIngot, 'S', ModItems.draconicCore, 'M', Items.nether_star); + addOre(ModItems.awakenedCore, "CSC", "SCS", "CSC", 'C', "ingotDraconiumAwakened", 'S', ModItems.wyvernCore); + addOre(ModItems.chaoticCore, "ACA", "CSC", "ACA", 'A', "ingotDraconiumAwakened", 'C', ModItems.awakenedCore, 'S', ModItems.chaosShard); + add(ModItems.wyvernEnergyCore, "CSC", "SMS", "CSC", 'C', ModItems.draconiumIngot, 'S', Blocks.redstone_block, 'M', ModItems.draconicCore); + addOre(ModItems.draconicEnergyCore, "CSC", "SMS", "CSC", 'C', "ingotDraconiumAwakened", 'S', ModItems.wyvernEnergyCore, 'M', ModItems.wyvernCore); + //addOre(ModItems.draconiumBlend, " D ", "DID", " D ", 'I', "ingotIron", 'D', ModItems.draconiumDust); - addShaplessOre(getStack(ModItems.draconicIngot, 9, 0), "blockDraconiumAwakened"); - addShaplessOre(getStack(ModItems.draconiumIngot, 9, 0), "blockDraconium"); - addShaplessOre(getStack(ModItems.nugget, 9, 0), "ingotDraconium"); - addShaplessOre(getStack(ModItems.nugget, 9, 1), "ingotDraconiumAwakened"); - addOre(ModItems.draconiumIngot, "III", "III", "III", 'I', "nuggetDraconium"); - addOre(ModItems.draconicIngot, "III", "III", "III", 'I', "nuggetDraconiumAwakened"); + addShaplessOre(getStack(ModItems.draconicIngot, 9, 0), "blockDraconiumAwakened"); + addShaplessOre(getStack(ModItems.draconiumIngot, 9, 0), "blockDraconium"); + addShaplessOre(getStack(ModItems.nugget, 9, 0), "ingotDraconium"); + addShaplessOre(getStack(ModItems.nugget, 9, 1), "ingotDraconiumAwakened"); + addOre(ModItems.draconiumIngot, "III", "III", "III", 'I', "nuggetDraconium"); + addOre(ModItems.draconicIngot, "III", "III", "III", 'I', "nuggetDraconiumAwakened"); - add(getStack(ModItems.chaosFragment, 1, 1), "III", "III", "III", 'I', getStack(ModItems.chaosFragment, 1, 0)); - add(getStack(ModItems.chaosFragment, 1, 2), "III", "III", "III", 'I', getStack(ModItems.chaosFragment, 1, 1)); - add(ModItems.chaosShard, "III", "III", "III", 'I', getStack(ModItems.chaosFragment, 1, 2)); + add(getStack(ModItems.chaosFragment, 1, 1), "III", "III", "III", 'I', getStack(ModItems.chaosFragment, 1, 0)); + add(getStack(ModItems.chaosFragment, 1, 2), "III", "III", "III", 'I', getStack(ModItems.chaosFragment, 1, 1)); + add(ModItems.chaosShard, "III", "III", "III", 'I', getStack(ModItems.chaosFragment, 1, 2)); - if (ModItems.isEnabled(ModItems.draconiumIngot) && ModItems.isEnabled(ModItems.draconiumBlend)) GameRegistry.addSmelting(ModItems.draconiumBlend, getStack(ModItems.draconiumIngot, 2, 0), 1.0f); - if (ModItems.isEnabled(ModItems.draconiumIngot) && ModItems.isEnabled(ModItems.draconiumDust)) GameRegistry.addSmelting(new ItemStack(ModItems.draconiumDust), getStack(ModItems.draconiumIngot, 1, 0), 1.0f); + if (ModItems.isEnabled(ModItems.draconiumIngot) && ModItems.isEnabled(ModItems.draconiumBlend)) + GameRegistry.addSmelting(ModItems.draconiumBlend, getStack(ModItems.draconiumIngot, 2, 0), 1.0f); + if (ModItems.isEnabled(ModItems.draconiumIngot) && ModItems.isEnabled(ModItems.draconiumDust)) + GameRegistry.addSmelting(new ItemStack(ModItems.draconiumDust), getStack(ModItems.draconiumIngot, 1, 0), 1.0f); - //Reactor - addOre(ModItems.partStabFrame, "III", "CD ", "III", 'I', "ingotIron", 'C', ModItems.wyvernCore, 'D', "ingotDraconiumAwakened"); - addOre(ModItems.partStabRotorInner, " ", "III", "CWW", 'I', "ingotDraconiumAwakened", 'W', "ingotDraconium", 'C', ModItems.draconicCore); - addOre(ModItems.partStabRotorOuter, " ", "III", "CWW", 'I', "gemDiamond", 'W', "ingotDraconium", 'C', ModItems.draconicCore); - addOre(ModItems.partStabRotorAssembly, " IO", "CWW", " IO", 'I', ModItems.partStabRotorInner, 'O', ModItems.partStabRotorOuter, 'C', ModItems.wyvernCore, 'W', "ingotDraconium"); - addOre(ModItems.partStabRing, "GDG", "DCD", "GDG", 'G', "ingotGold", 'D', "gemDiamond", 'C', ModItems.wyvernCore); - addOre(ModBlocks.reactorStabilizer, "ICI", "FSR", "IEI", 'I', "ingotDraconiumAwakened", 'C', ModItems.chaoticCore, 'F', ModItems.partStabFrame, 'S', ModItems.partStabRotorAssembly, 'R', ModItems.partStabRing, 'E', ModItems.draconicEnergyCore); - addOre(ModBlocks.reactorEnergyInjector, "IRI", "RCR", "IRI", 'I', "ingotDraconium", 'R', ModItems.partStabRotorInner, 'C', ModItems.wyvernCore); - addOre(ModBlocks.reactorCore, " I ", "ISI", " I ", 'I', "ingotDraconiumAwakened", 'S', ModItems.chaosShard); + //Reactor + addOre(ModItems.partStabFrame, "III", "CD ", "III", 'I', "ingotIron", 'C', ModItems.wyvernCore, 'D', "ingotDraconiumAwakened"); + addOre(ModItems.partStabRotorInner, " ", "III", "CWW", 'I', "ingotDraconiumAwakened", 'W', "ingotDraconium", 'C', ModItems.draconicCore); + addOre(ModItems.partStabRotorOuter, " ", "III", "CWW", 'I', "gemDiamond", 'W', "ingotDraconium", 'C', ModItems.draconicCore); + addOre(ModItems.partStabRotorAssembly, " IO", "CWW", " IO", 'I', ModItems.partStabRotorInner, 'O', ModItems.partStabRotorOuter, 'C', ModItems.wyvernCore, 'W', "ingotDraconium"); + addOre(ModItems.partStabRing, "GDG", "DCD", "GDG", 'G', "ingotGold", 'D', "gemDiamond", 'C', ModItems.wyvernCore); + addOre(ModBlocks.reactorStabilizer, "ICI", "FSR", "IEI", 'I', "ingotDraconiumAwakened", 'C', ModItems.chaoticCore, 'F', ModItems.partStabFrame, 'S', ModItems.partStabRotorAssembly, 'R', ModItems.partStabRing, 'E', ModItems.draconicEnergyCore); + addOre(ModBlocks.reactorEnergyInjector, "IRI", "RCR", "IRI", 'I', "ingotDraconium", 'R', ModItems.partStabRotorInner, 'C', ModItems.wyvernCore); + addOre(ModBlocks.reactorCore, " I ", "ISI", " I ", 'I', "ingotDraconiumAwakened", 'S', ModItems.chaosShard); - //Wyvern tools - add(ModItems.wyvernFluxCapacitor, "CSC", "SMS", "CSC", 'C', ModItems.draconiumIngot, 'S', ModItems.wyvernEnergyCore, 'M', ModItems.wyvernCore); - //tool - add(ModItems.wyvernPickaxe, " W ", "ITI", " E ", 'W', ModItems.wyvernCore, 'I', ModItems.draconiumIngot, 'T', Items.diamond_pickaxe, 'E', ModItems.wyvernEnergyCore); - add(ModItems.wyvernShovel, " W ", "ITI", " E ", 'W', ModItems.wyvernCore, 'I', ModItems.draconiumIngot, 'T', Items.diamond_shovel, 'E', ModItems.wyvernEnergyCore); - add(ModItems.wyvernSword, " W ", "ITI", " E ", 'W', ModItems.wyvernCore, 'I', ModItems.draconiumIngot, 'T', Items.diamond_sword, 'E', ModItems.wyvernEnergyCore); - add(ModItems.wyvernBow, " W ", "ITI", " E ", 'W', ModItems.wyvernCore, 'I', ModItems.draconiumIngot, 'T', Items.bow, 'E', ModItems.wyvernEnergyCore); - addOre(new ItemStack(ModItems.magnet, 1, 0), "RII", " C", "RII", 'R', Blocks.redstone_block, 'I', "ingotIron", 'C', ModItems.teleporterMKI); + //Wyvern tools + add(ModItems.wyvernFluxCapacitor, "CSC", "SMS", "CSC", 'C', ModItems.draconiumIngot, 'S', ModItems.wyvernEnergyCore, 'M', ModItems.wyvernCore); + //tool + add(ModItems.wyvernPickaxe, " W ", "ITI", " E ", 'W', ModItems.wyvernCore, 'I', ModItems.draconiumIngot, 'T', Items.diamond_pickaxe, 'E', ModItems.wyvernEnergyCore); + add(ModItems.wyvernShovel, " W ", "ITI", " E ", 'W', ModItems.wyvernCore, 'I', ModItems.draconiumIngot, 'T', Items.diamond_shovel, 'E', ModItems.wyvernEnergyCore); + add(ModItems.wyvernSword, " W ", "ITI", " E ", 'W', ModItems.wyvernCore, 'I', ModItems.draconiumIngot, 'T', Items.diamond_sword, 'E', ModItems.wyvernEnergyCore); + add(ModItems.wyvernBow, " W ", "ITI", " E ", 'W', ModItems.wyvernCore, 'I', ModItems.draconiumIngot, 'T', Items.bow, 'E', ModItems.wyvernEnergyCore); + addOre(new ItemStack(ModItems.magnet, 1, 0), "RII", " C", "RII", 'R', Blocks.redstone_block, 'I', "ingotIron", 'C', ModItems.teleporterMKI); - //armor - add(ModItems.wyvernHelm, "IWI", "IAI", "IEI", 'W', ModItems.wyvernCore, 'I', ModItems.draconiumIngot, 'A', Items.diamond_helmet, 'E', ModItems.wyvernEnergyCore); - add(ModItems.wyvernChest, "IWI", "IAI", "IEI", 'W', ModItems.wyvernCore, 'I', ModItems.draconiumIngot, 'A', Items.diamond_chestplate, 'E', ModItems.wyvernEnergyCore); - add(ModItems.wyvernLeggs, "IWI", "IAI", "IEI", 'W', ModItems.wyvernCore, 'I', ModItems.draconiumIngot, 'A', Items.diamond_leggings, 'E', ModItems.wyvernEnergyCore); - add(ModItems.wyvernBoots, "IWI", "IAI", "IEI", 'W', ModItems.wyvernCore, 'I', ModItems.draconiumIngot, 'A', Items.diamond_boots, 'E', ModItems.wyvernEnergyCore); + //armor + add(ModItems.wyvernHelm, "IWI", "IAI", "IEI", 'W', ModItems.wyvernCore, 'I', ModItems.draconiumIngot, 'A', Items.diamond_helmet, 'E', ModItems.wyvernEnergyCore); + add(ModItems.wyvernChest, "IWI", "IAI", "IEI", 'W', ModItems.wyvernCore, 'I', ModItems.draconiumIngot, 'A', Items.diamond_chestplate, 'E', ModItems.wyvernEnergyCore); + add(ModItems.wyvernLeggs, "IWI", "IAI", "IEI", 'W', ModItems.wyvernCore, 'I', ModItems.draconiumIngot, 'A', Items.diamond_leggings, 'E', ModItems.wyvernEnergyCore); + add(ModItems.wyvernBoots, "IWI", "IAI", "IEI", 'W', ModItems.wyvernCore, 'I', ModItems.draconiumIngot, 'A', Items.diamond_boots, 'E', ModItems.wyvernEnergyCore); - //Draconic Tools - addEnergy(ModItems.draconicFluxCapacitor, "CMC", "SPS", "CSC", 'C', "ingotDraconiumAwakened", 'S', ModItems.draconicEnergyCore, 'M', ModItems.awakenedCore, 'P', ModItems.wyvernFluxCapacitor); - //tools - addEnergy(ModItems.draconicPickaxe, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', ModItems.wyvernPickaxe, 'E', ModItems.draconicEnergyCore); - addEnergy(ModItems.draconicShovel, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', ModItems.wyvernShovel, 'E', ModItems.draconicEnergyCore); - addOre(ModItems.draconicAxe, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', Items.diamond_axe, 'E', ModItems.draconicEnergyCore); - addOre(ModItems.draconicHoe, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', Items.diamond_hoe, 'E', ModItems.draconicEnergyCore); - addEnergy(ModItems.draconicSword, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', ModItems.wyvernSword, 'E', ModItems.draconicEnergyCore); - addOre(ModItems.draconicBow, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', ModItems.wyvernBow, 'E', ModItems.draconicEnergyCore); - addEnergy(ModItems.draconicDestructionStaff, "IAI", "PIS", "IWI", 'I', "ingotDraconiumAwakened", 'A', ModItems.awakenedCore, 'P', ModItems.draconicPickaxe, 'S', ModItems.draconicShovel, 'W', ModItems.draconicSword); - addOre(new ItemStack(ModItems.magnet, 1, 1), "RII", " C", "RII", 'R', new ItemStack(ModBlocks.draconiumBlock, 1, 2), 'I', "ingotDraconiumAwakened", 'C', new ItemStack(ModItems.magnet, 1, 0)); + //Draconic Tools + addEnergy(ModItems.draconicFluxCapacitor, "CMC", "SPS", "CSC", 'C', "ingotDraconiumAwakened", 'S', ModItems.draconicEnergyCore, 'M', ModItems.awakenedCore, 'P', ModItems.wyvernFluxCapacitor); + //tools + addEnergy(ModItems.draconicPickaxe, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', ModItems.wyvernPickaxe, 'E', ModItems.draconicEnergyCore); + addEnergy(ModItems.draconicShovel, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', ModItems.wyvernShovel, 'E', ModItems.draconicEnergyCore); + addOre(ModItems.draconicAxe, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', Items.diamond_axe, 'E', ModItems.draconicEnergyCore); + addOre(ModItems.draconicHoe, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', Items.diamond_hoe, 'E', ModItems.draconicEnergyCore); + addEnergy(ModItems.draconicSword, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', ModItems.wyvernSword, 'E', ModItems.draconicEnergyCore); + addOre(ModItems.draconicBow, " C ", "ITI", " E ", 'C', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'T', ModItems.wyvernBow, 'E', ModItems.draconicEnergyCore); + addEnergy(ModItems.draconicDestructionStaff, "IAI", "PIS", "IWI", 'I', "ingotDraconiumAwakened", 'A', ModItems.awakenedCore, 'P', ModItems.draconicPickaxe, 'S', ModItems.draconicShovel, 'W', ModItems.draconicSword); + addOre(new ItemStack(ModItems.magnet, 1, 1), "RII", " C", "RII", 'R', new ItemStack(ModBlocks.draconiumBlock, 1, 2), 'I', "ingotDraconiumAwakened", 'C', new ItemStack(ModItems.magnet, 1, 0)); - //armor - addEnergy(ModItems.draconicHelm, "IWI", "IAI", "IEI", 'W', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'A', ModItems.wyvernHelm, 'E', ModItems.draconicEnergyCore); - addEnergy(ModItems.draconicChest, "IWI", "IAI", "IEI", 'W', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'A', ModItems.wyvernChest, 'E', ModItems.draconicEnergyCore); - addEnergy(ModItems.draconicLeggs, "IWI", "IAI", "IEI", 'W', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'A', ModItems.wyvernLeggs, 'E', ModItems.draconicEnergyCore); - addEnergy(ModItems.draconicBoots, "IWI", "IAI", "IEI", 'W', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'A', ModItems.wyvernBoots, 'E', ModItems.draconicEnergyCore); + //armor + addEnergy(ModItems.draconicHelm, "IWI", "IAI", "IEI", 'W', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'A', ModItems.wyvernHelm, 'E', ModItems.draconicEnergyCore); + addEnergy(ModItems.draconicChest, "IWI", "IAI", "IEI", 'W', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'A', ModItems.wyvernChest, 'E', ModItems.draconicEnergyCore); + addEnergy(ModItems.draconicLeggs, "IWI", "IAI", "IEI", 'W', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'A', ModItems.wyvernLeggs, 'E', ModItems.draconicEnergyCore); + addEnergy(ModItems.draconicBoots, "IWI", "IAI", "IEI", 'W', ModItems.awakenedCore, 'I', "ingotDraconiumAwakened", 'A', ModItems.wyvernBoots, 'E', ModItems.draconicEnergyCore); + //Blocks + //storage + addOre(ModBlocks.draconiumBlock, "III", "III", "III", 'I', "ingotDraconium"); + addOre(ModBlocks.draconicBlock, "III", "III", "III", 'I', "ingotDraconiumAwakened"); - //Blocks - //storage - addOre(ModBlocks.draconiumBlock, "III", "III", "III", 'I', "ingotDraconium"); - addOre(ModBlocks.draconicBlock, "III", "III", "III", 'I', "ingotDraconiumAwakened"); + //aesthetic + add(ModBlocks.particleGenerator, "RBR", "BCB", "RBR", 'R', Blocks.redstone_block, 'B', Items.blaze_rod, 'C', ModItems.draconicCore); + addOre(new ItemStack(ModBlocks.infusedObsidian, 4), "BOB", "ODO", "BOB", 'B', Items.blaze_powder, 'O', Blocks.obsidian, 'D', "dustDraconium"); - //aesthetic - add(ModBlocks.particleGenerator, "RBR", "BCB", "RBR", 'R', Blocks.redstone_block, 'B', Items.blaze_rod, 'C', ModItems.draconicCore); - addOre(new ItemStack(ModBlocks.infusedObsidian, 4), "BOB", "ODO", "BOB", 'B', Items.blaze_powder, 'O', Blocks.obsidian, 'D', "dustDraconium"); + //machines + addOre(ModBlocks.potentiometer, "ITI", "QCQ", "IRI", 'I', "ingotIron", 'T', Blocks.redstone_torch, 'Q', "gemQuartz", 'C', Items.comparator, 'R', Blocks.redstone_block); + addOre(ModBlocks.rainSensor, " ", "RBR", "SPS", 'R', "dustRedstone", 'B', Items.bucket, 'S', Blocks.stone_slab, 'P', Blocks.heavy_weighted_pressure_plate); + addOre(ModBlocks.teleporterStand, " P ", " S ", "HBH", 'P', Blocks.stone_pressure_plate, 'S', "stone", 'H', new ItemStack(Blocks.stone_slab, 1, 0), 'B', Items.blaze_powder); + addOre(ModBlocks.dislocatorReceptacle, "ICI", " O ", "ISI", 'I', "ingotIron", 'C', ModItems.draconicCore, 'O', ModBlocks.infusedObsidian, 'S', ModBlocks.teleporterStand); + addOre(ModBlocks.upgradeModifier, " ", "DCD", "III", 'I', "ingotIron", 'D', "ingotDraconium", 'C', ModItems.draconicCore); - //machines - addOre(ModBlocks.potentiometer, "ITI", "QCQ", "IRI", 'I', "ingotIron", 'T', Blocks.redstone_torch, 'Q', "gemQuartz", 'C', Items.comparator, 'R', Blocks.redstone_block); - addOre(ModBlocks.rainSensor, " ", "RBR", "SPS", 'R', "dustRedstone", 'B', Items.bucket, 'S', Blocks.stone_slab, 'P', Blocks.heavy_weighted_pressure_plate); - addOre(ModBlocks.teleporterStand, " P ", " S ", "HBH", 'P', Blocks.stone_pressure_plate, 'S', "stone", 'H', new ItemStack(Blocks.stone_slab, 1, 0), 'B', Items.blaze_powder); - addOre(ModBlocks.dislocatorReceptacle, "ICI", " O ", "ISI", 'I', "ingotIron", 'C', ModItems.draconicCore, 'O', ModBlocks.infusedObsidian, 'S', ModBlocks.teleporterStand); - addOre(ModBlocks.upgradeModifier, " ", "DCD", "III", 'I', "ingotIron", 'D', "ingotDraconium", 'C', ModItems.draconicCore); + //machines adv + addOre(ModBlocks.resurrectionStone, "CSC", "SMS", "CSC", 'C', mobSoul, 'S', ModItems.wyvernCore, 'M', "blockDraconium"); + addOre(ModBlocks.energyStorageCore, "CCC", "SMS", "CCC", 'C', "ingotDraconium", 'S', ModItems.wyvernEnergyCore, 'M', ModItems.wyvernCore); + addOre(ModBlocks.weatherController, "RIR", "TPT", "IEI", 'R', Items.blaze_rod, 'T', Blocks.tnt, 'P', ModItems.draconicCore, 'I', "ingotDraconium", 'E', Blocks.enchanting_table); + addOre(ModBlocks.playerDetectorAdvanced, "ISI", "EDE", "ICI", 'I', "ingotDraconium", 'E', Items.ender_eye, 'S', new ItemStack(Items.skull, 1, 1), 'C', Items.compass, 'D', ModBlocks.playerDetector); + addOre(ModBlocks.energyInfuser, "IPI", "CEC", "ICI", 'I', "ingotDraconium", 'P', ModBlocks.particleGenerator, 'C', ModItems.draconicCore, 'E', Blocks.enchanting_table); + addOre(ModBlocks.draconiumChest, "IFI", "SCS", "IWI", 'I', "ingotDraconium", 'C', ModItems.draconicCore, 'S', getChest(), 'W', Blocks.crafting_table, 'F', Blocks.furnace); + addOre(getStack(ModBlocks.energyPylon, 2, 0), "IEI", "MCM", "IDI", 'I', "ingotDraconium", 'E', Items.ender_eye, 'C', ModItems.draconicCore, 'D', "gemDiamond", 'M', "gemEmerald"); + addOre(getStack(ModBlocks.grinder, 1, 3), "IXI", "DCD", "IFI", 'I', "ingotIron", 'X', "ingotDraconium", 'D', Items.diamond_sword, 'C', ModItems.draconicCore, 'F', Blocks.furnace); + addOre(ModBlocks.playerDetector, "ITI", "CEC", "IDI", 'I', "ingotIron", 'E', Items.ender_eye, 'T', Blocks.redstone_torch, 'C', Items.comparator, 'D', ModItems.draconicCore); + addOre(getStack(ModBlocks.generator, 1, 3), "NIN", "IFI", "NCN", 'N', Items.netherbrick, 'I', "ingotIron", 'F', Blocks.furnace, 'C', ModItems.draconicCore); + addOre(ModBlocks.dissEnchanter, "PIP", "ETE", "CBC", 'P', Items.ender_eye, 'I', Items.enchanted_book, 'E', "gemEmerald", 'T', Blocks.enchanting_table, 'C', ModItems.draconicCore, 'B', Items.book); + addOre(getStack(ModBlocks.energyCrystal, 4, 0), "IDI", "DCD", "IDI", 'I', "ingotDraconium", 'D', "gemDiamond", 'C', ModItems.draconicCore); + addOre(getStack(ModBlocks.energyCrystal, 4, 1), "CRC", "RWR", "CRC", 'R', getStack(ModBlocks.energyCrystal, 1, 0), 'W', ModItems.wyvernCore, 'C', ModItems.draconicCore); + addShaplessOre(getStack(ModBlocks.energyCrystal, 1, 0), getStack(ModBlocks.energyCrystal, 1, 2), getStack(ModBlocks.energyCrystal, 1, 2)); + addShaplessOre(getStack(ModBlocks.energyCrystal, 2, 2), getStack(ModBlocks.energyCrystal, 1, 0)); + addShaplessOre(getStack(ModBlocks.energyCrystal, 1, 1), getStack(ModBlocks.energyCrystal, 1, 3), getStack(ModBlocks.energyCrystal, 1, 3)); + addShaplessOre(getStack(ModBlocks.energyCrystal, 2, 3), getStack(ModBlocks.energyCrystal, 1, 1)); + addOre(getStack(ModBlocks.energyCrystal, 1, 4), "PGP", "ECE", "PGP", 'P', Items.ender_pearl, 'G', ModBlocks.particleGenerator, 'E', Items.ender_eye, 'C', getStack(ModBlocks.energyCrystal, 1, 0)); + addOre(getStack(ModBlocks.energyCrystal, 1, 5), "PGP", "ECE", "PGP", 'P', Items.ender_pearl, 'G', ModBlocks.particleGenerator, 'E', Items.ender_eye, 'C', getStack(ModBlocks.energyCrystal, 1, 1)); - //machines adv - addOre(ModBlocks.resurrectionStone, "CSC", "SMS", "CSC", 'C', mobSoul, 'S', ModItems.wyvernCore, 'M', "blockDraconium"); - addOre(ModBlocks.energyStorageCore, "CCC", "SMS", "CCC", 'C', "ingotDraconium", 'S', ModItems.wyvernEnergyCore, 'M', ModItems.wyvernCore); - addOre(ModBlocks.weatherController, "RIR", "TPT", "IEI", 'R', Items.blaze_rod, 'T', Blocks.tnt, 'P', ModItems.draconicCore, 'I', "ingotDraconium", 'E', Blocks.enchanting_table); - addOre(ModBlocks.playerDetectorAdvanced, "ISI", "EDE", "ICI", 'I', "ingotDraconium", 'E', Items.ender_eye, 'S', new ItemStack(Items.skull, 1, 1), 'C', Items.compass, 'D', ModBlocks.playerDetector); - addOre(ModBlocks.energyInfuser, "IPI", "CEC", "ICI", 'I', "ingotDraconium", 'P', ModBlocks.particleGenerator, 'C', ModItems.draconicCore, 'E', Blocks.enchanting_table); - addOre(ModBlocks.draconiumChest, "IFI", "SCS", "IWI", 'I', "ingotDraconium", 'C', ModItems.draconicCore, 'S', getChest(), 'W', Blocks.crafting_table, 'F', Blocks.furnace); - addOre(getStack(ModBlocks.energyPylon, 2, 0), "IEI", "MCM", "IDI", 'I', "ingotDraconium", 'E', Items.ender_eye, 'C', ModItems.draconicCore, 'D', "gemDiamond", 'M', "gemEmerald"); - addOre(getStack(ModBlocks.grinder, 1, 3), "IXI", "DCD", "IFI", 'I', "ingotIron", 'X', "ingotDraconium", 'D', Items.diamond_sword, 'C', ModItems.draconicCore, 'F', Blocks.furnace); - addOre(ModBlocks.playerDetector, "ITI", "CEC", "IDI", 'I', "ingotIron", 'E', Items.ender_eye, 'T', Blocks.redstone_torch, 'C', Items.comparator, 'D', ModItems.draconicCore); - addOre(getStack(ModBlocks.generator, 1, 3), "NIN", "IFI", "NCN", 'N', Items.netherbrick, 'I', "ingotIron", 'F', Blocks.furnace, 'C', ModItems.draconicCore); - addOre(ModBlocks.dissEnchanter, "PIP", "ETE", "CBC", 'P', Items.ender_eye, 'I', Items.enchanted_book, 'E', "gemEmerald", 'T', Blocks.enchanting_table, 'C', ModItems.draconicCore, 'B', Items.book); - addOre(getStack(ModBlocks.energyCrystal, 4, 0), "IDI", "DCD", "IDI", 'I' , "ingotDraconium", 'D', "gemDiamond", 'C', ModItems.draconicCore); - addOre(getStack(ModBlocks.energyCrystal, 4, 1), "CRC", "RWR", "CRC", 'R' , getStack(ModBlocks.energyCrystal, 1, 0), 'W', ModItems.wyvernCore, 'C', ModItems.draconicCore); - addShaplessOre(getStack(ModBlocks.energyCrystal, 1, 0), getStack(ModBlocks.energyCrystal, 1, 2), getStack(ModBlocks.energyCrystal, 1, 2)); - addShaplessOre(getStack(ModBlocks.energyCrystal, 2, 2), getStack(ModBlocks.energyCrystal, 1, 0)); - addShaplessOre(getStack(ModBlocks.energyCrystal, 1, 1), getStack(ModBlocks.energyCrystal, 1, 3), getStack(ModBlocks.energyCrystal, 1, 3)); - addShaplessOre(getStack(ModBlocks.energyCrystal, 2, 3), getStack(ModBlocks.energyCrystal, 1, 1)); - addOre(getStack(ModBlocks.energyCrystal, 1, 4), "PGP", "ECE", "PGP", 'P', Items.ender_pearl, 'G', ModBlocks.particleGenerator, 'E', Items.ender_eye, 'C', getStack(ModBlocks.energyCrystal, 1, 0)); - addOre(getStack(ModBlocks.energyCrystal, 1, 5), "PGP", "ECE", "PGP", 'P', Items.ender_pearl, 'G', ModBlocks.particleGenerator, 'E', Items.ender_eye, 'C', getStack(ModBlocks.energyCrystal, 1, 1)); + if (Loader.isModLoaded("ThermalDynamics")) { + addOre(getStack(ModBlocks.flowGate, 1, 0), "ICI", "RSR", "ICI", 'I', "ingotDraconium", 'C', getStack(ModItems.draconicCore, 1, 0), 'R', Items.comparator, 'S', new ItemStack(GameRegistry.findBlock("ThermalDynamics", "ThermalDynamics_0"), 1, 1)); + addOre(getStack(ModBlocks.flowGate, 1, 6), "ICI", "RSR", "ICI", 'I', "ingotDraconium", 'C', getStack(ModItems.draconicCore, 1, 0), 'R', Items.comparator, 'S', new ItemStack(GameRegistry.findBlock("ThermalDynamics", "ThermalDynamics_16"), 1, 2)); + } else { + addOre(getStack(ModBlocks.flowGate, 1, 0), "ICI", "RSR", "ICI", 'I', "ingotDraconium", 'C', getStack(ModItems.draconicCore, 1, 0), 'R', Items.comparator, 'S', getStack(ModItems.draconiumEnergyCore, 1, 0)); + addOre(getStack(ModBlocks.flowGate, 1, 6), "ICI", "RSR", "ICI", 'I', "ingotDraconium", 'C', getStack(ModItems.draconicCore, 1, 0), 'R', Items.comparator, 'S', Items.bucket); + } - if (Loader.isModLoaded("ThermalDynamics")) { - addOre(getStack(ModBlocks.flowGate, 1, 0), "ICI", "RSR", "ICI", 'I', "ingotDraconium", 'C', getStack(ModItems.draconicCore, 1, 0), 'R', Items.comparator, 'S', new ItemStack(GameRegistry.findBlock("ThermalDynamics", "ThermalDynamics_0"), 1, 1)); - addOre(getStack(ModBlocks.flowGate, 1, 6), "ICI", "RSR", "ICI", 'I', "ingotDraconium", 'C', getStack(ModItems.draconicCore, 1, 0), 'R', Items.comparator, 'S', new ItemStack(GameRegistry.findBlock("ThermalDynamics", "ThermalDynamics_16"), 1, 2)); - }else { - addOre(getStack(ModBlocks.flowGate, 1, 0), "ICI", "RSR", "ICI", 'I', "ingotDraconium", 'C', getStack(ModItems.draconicCore, 1, 0), 'R', Items.comparator, 'S', getStack(ModItems.draconiumEnergyCore, 1, 0)); - addOre(getStack(ModBlocks.flowGate, 1, 6), "ICI", "RSR", "ICI", 'I', "ingotDraconium", 'C', getStack(ModItems.draconicCore, 1, 0), 'R', Items.comparator, 'S', Items.bucket); - } + //Tools + addOre(ModItems.teleporterMKII, "IEI", "ETE", "IWI", 'I', "ingotDraconium", 'E', Items.ender_pearl, 'T', ModItems.teleporterMKI, 'W', ModItems.wyvernCore); + addOre(ModItems.teleporterMKI, "CSC", "SMS", "CSC", 'C', Items.blaze_powder, 'S', "dustDraconium", 'M', Items.ender_eye); + addOre(getStack(ModItems.safetyMatch, 1, 1000), " O ", " S ", " ", 'O', "dyeOrange", 'S', "stickWood"); + add(ModItems.safetyMatch, "MMM", "MMM", "MMM", 'M', getStack(ModItems.safetyMatch, 1, 1000)); + addOre(ModItems.wrench, " ID", " RI", "C ", 'I', "ingotDraconium", 'D', "gemDiamond", 'R', Items.blaze_rod, 'C', ModItems.draconicCore); - //Tools - addOre(ModItems.teleporterMKII, "IEI", "ETE", "IWI", 'I', "ingotDraconium", 'E', Items.ender_pearl, 'T', ModItems.teleporterMKI, 'W', ModItems.wyvernCore); - addOre(ModItems.teleporterMKI, "CSC", "SMS", "CSC", 'C', Items.blaze_powder, 'S', "dustDraconium", 'M', Items.ender_eye); - addOre(getStack(ModItems.safetyMatch, 1, 1000), " O ", " S ", " ", 'O', "dyeOrange", 'S', "stickWood"); - add(ModItems.safetyMatch, "MMM", "MMM", "MMM", 'M', getStack(ModItems.safetyMatch, 1, 1000)); - addOre(ModItems.wrench, " ID", " RI", "C ", 'I' , "ingotDraconium", 'D', "gemDiamond", 'R', Items.blaze_rod, 'C', ModItems.draconicCore); - - //Other - addOre(ModItems.infoTablet, "SSS", "SDS", "SSS", 'S', "stone", 'D', "dustDraconium"); - addShaplessOre(getStack(ModItems.enderArrow, 1, 0), Items.arrow, Items.ender_pearl); - addShaplessOre(new ItemStack(Blocks.dirt), Item.getItemFromBlock(Blocks.sand), Items.rotten_flesh, "treeSapling", "treeSapling", "treeSapling"); - addShaplessOre(new ItemStack(Blocks.dirt), Item.getItemFromBlock(Blocks.sand), Items.rotten_flesh, "treeLeaves", "treeLeaves", "treeLeaves"); + //Other + addOre(ModItems.infoTablet, "SSS", "SDS", "SSS", 'S', "stone", 'D', "dustDraconium"); + addShaplessOre(getStack(ModItems.enderArrow, 1, 0), Items.arrow, Items.ender_pearl); + addShaplessOre(new ItemStack(Blocks.dirt), Item.getItemFromBlock(Blocks.sand), Items.rotten_flesh, "treeSapling", "treeSapling", "treeSapling"); + addShaplessOre(new ItemStack(Blocks.dirt), Item.getItemFromBlock(Blocks.sand), Items.rotten_flesh, "treeLeaves", "treeLeaves", "treeLeaves"); - //Disable able - //if(ConfigHandler.disableSunDial == 0) - addOre(ModBlocks.sunDial, "IAI", "CDC", "IEI", 'I', "ingotDraconium", 'A', ModItems.awakenedCore, 'C', ModItems.draconicCore, 'E', Blocks.enchanting_table, 'D', Blocks.dragon_egg); - //if(ConfigHandler.disableXrayBlock == 0) - addOre(getStack(ModBlocks.xRayBlock, 4, 0), "SGS", "GDG", "SGS", 'S', Items.nether_star, 'G', "blockGlassColorless", 'D', "gemDiamond"); + //Disable able + //if(ConfigHandler.disableSunDial == 0) + addOre(ModBlocks.sunDial, "IAI", "CDC", "IEI", 'I', "ingotDraconium", 'A', ModItems.awakenedCore, 'C', ModItems.draconicCore, 'E', Blocks.enchanting_table, 'D', Blocks.dragon_egg); + //if(ConfigHandler.disableXrayBlock == 0) + addOre(getStack(ModBlocks.xRayBlock, 4, 0), "SGS", "GDG", "SGS", 'S', Items.nether_star, 'G', "blockGlassColorless", 'D', "gemDiamond"); - } + } - private static ItemStack getChest(){ - if (Loader.isModLoaded("IronChest")){ - LogHelper.info("Adding Iron Chests Integration"); - return new ItemStack(GameRegistry.findBlock("IronChest", "BlockIronChest"), 1, 6); - }else + private static ItemStack getChest() { + if (Loader.isModLoaded("IronChest")) { + LogHelper.info("Adding Iron Chests Integration"); + return new ItemStack(GameRegistry.findBlock("IronChest", "BlockIronChest"), 1, 6); + } else - LogHelper.info("Iron Chests was not detected! using fallback chest recipe"); - return new ItemStack(Blocks.chest); - } + LogHelper.info("Iron Chests was not detected! using fallback chest recipe"); + return new ItemStack(Blocks.chest); + } - private static void addOre(Block result, Object... recipe){ addOre(new ItemStack(result), recipe); } - private static void addOre(Item result, Object... recipe){ addOre(new ItemStack(result), recipe); } - private static void addOre(ItemStack result, Object... recipe){ - if (result == null) return; - for (Object o : recipe) { - if (o == null) return; - String s = o instanceof Item ? ((Item) o).getUnlocalizedName() : o instanceof Block ? ((Block) o).getUnlocalizedName() : null; - if (s != null && ConfigHandler.disabledNamesList.contains(s)) return; - } + private static void addOre(Block result, Object... recipe) { + addOre(new ItemStack(result), recipe); + } - GameRegistry.addRecipe(new ShapedOreRecipe(result, recipe)); - } + private static void addOre(Item result, Object... recipe) { + addOre(new ItemStack(result), recipe); + } - private static void addShaplessOre(ItemStack result, Object... recipe){ - if (result == null) return; - for (Object o : recipe) { - if (o == null) return; - String s = o instanceof Item ? ((Item) o).getUnlocalizedName() : o instanceof Block ? ((Block) o).getUnlocalizedName() : null; - if (s != null && ConfigHandler.disabledNamesList.contains(s)) return; - } + private static void addOre(ItemStack result, Object... recipe) { + if (result == null) return; + for (Object o : recipe) { + if (o == null) return; + String s = o instanceof Item ? ((Item) o).getUnlocalizedName() : o instanceof Block ? ((Block) o).getUnlocalizedName() : null; + if (s != null && ConfigHandler.disabledNamesList.contains(s)) return; + } - GameRegistry.addRecipe(new ShapelessOreRecipe(result, recipe)); - } + GameRegistry.addRecipe(new ShapedOreRecipe(result, recipe)); + } - private static void add(Block result, Object... recipe){ add(new ItemStack(result), recipe); } - private static void add(Item result, Object... recipe){ add(new ItemStack(result), recipe); } - private static void add(ItemStack result, Object... recipe){ - if (result == null) return; - for (Object o : recipe) { - if (o == null) return; - String s = o instanceof Item ? ((Item) o).getUnlocalizedName() : o instanceof Block ? ((Block) o).getUnlocalizedName() : null; - if (s != null && ConfigHandler.disabledNamesList.contains(s)) return; - } + private static void addShaplessOre(ItemStack result, Object... recipe) { + if (result == null) return; + for (Object o : recipe) { + if (o == null) return; + String s = o instanceof Item ? ((Item) o).getUnlocalizedName() : o instanceof Block ? ((Block) o).getUnlocalizedName() : null; + if (s != null && ConfigHandler.disabledNamesList.contains(s)) return; + } - GameRegistry.addRecipe(result, recipe); - } + GameRegistry.addRecipe(new ShapelessOreRecipe(result, recipe)); + } - private static void addEnergy(Block result, Object... recipe){ addEnergy(new ItemStack(result), recipe); } - private static void addEnergy(Item result, Object... recipe){ addEnergy(new ItemStack(result), recipe); } - private static void addEnergy(ItemStack result, Object... recipe){ - if (result == null) return; - for (Object o : recipe) { - if (o == null) return; - String s = o instanceof Item ? ((Item) o).getUnlocalizedName() : o instanceof Block ? ((Block) o).getUnlocalizedName() : null; - if (s != null && ConfigHandler.disabledNamesList.contains(s)) return; - } + private static void add(Block result, Object... recipe) { + add(new ItemStack(result), recipe); + } - GameRegistry.addRecipe(new ShapedOreEnergyRecipe(result, recipe)); - } + private static void add(Item result, Object... recipe) { + add(new ItemStack(result), recipe); + } - private static ItemStack getStack(Block block, int count, int meta) - { - return ModBlocks.isEnabled(block) ? new ItemStack(block, count, meta) : null; - } + private static void add(ItemStack result, Object... recipe) { + if (result == null) return; + for (Object o : recipe) { + if (o == null) return; + String s = o instanceof Item ? ((Item) o).getUnlocalizedName() : o instanceof Block ? ((Block) o).getUnlocalizedName() : null; + if (s != null && ConfigHandler.disabledNamesList.contains(s)) return; + } - private static ItemStack getStack(Item item, int count, int meta) - { - return ModItems.isEnabled(item) ? new ItemStack(item, count, meta) : null; - } + GameRegistry.addRecipe(result, recipe); + } + + private static void addEnergy(Block result, Object... recipe) { + addEnergy(new ItemStack(result), recipe); + } + + private static void addEnergy(Item result, Object... recipe) { + addEnergy(new ItemStack(result), recipe); + } + + private static void addEnergy(ItemStack result, Object... recipe) { + if (result == null) return; + for (Object o : recipe) { + if (o == null) return; + String s = o instanceof Item ? ((Item) o).getUnlocalizedName() : o instanceof Block ? ((Block) o).getUnlocalizedName() : null; + if (s != null && ConfigHandler.disabledNamesList.contains(s)) return; + } + + GameRegistry.addRecipe(new ShapedOreEnergyRecipe(result, recipe)); + } + + private static ItemStack getStack(Block block, int count, int meta) { + return ModBlocks.isEnabled(block) ? new ItemStack(block, count, meta) : null; + } + + private static ItemStack getStack(Item item, int count, int meta) { + return ModItems.isEnabled(item) ? new ItemStack(item, count, meta) : null; + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/handler/FMLEventHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/handler/FMLEventHandler.java index f29242d5..f12a2b9f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/handler/FMLEventHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/handler/FMLEventHandler.java @@ -15,46 +15,44 @@ import net.minecraft.util.ChatComponentText; public class FMLEventHandler { - private static boolean mmGiven = false; + private static boolean mmGiven = false; - @SubscribeEvent - public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) { - if(eventArgs.modID.equalsIgnoreCase(References.MODID)) { - ConfigHandler.syncConfig(); - LogHelper.info("Config Changed"); - } - } + @SubscribeEvent + public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) { + if (eventArgs.modID.equalsIgnoreCase(References.MODID)) { + ConfigHandler.syncConfig(); + LogHelper.info("Config Changed"); + } + } - @SubscribeEvent - public void onPlayerTick(TickEvent.PlayerTickEvent event) { - if (event.phase != TickEvent.Phase.START) return; + @SubscribeEvent + public void onPlayerTick(TickEvent.PlayerTickEvent event) { + if (event.phase != TickEvent.Phase.START) return; - CustomArmorHandler.onPlayerTick(event); - } + CustomArmorHandler.onPlayerTick(event); + } - @SubscribeEvent - public void serverTickEvent(TickEvent event){ - ContributorHandler.tick(); - } + @SubscribeEvent + public void serverTickEvent(TickEvent event) { + ContributorHandler.tick(); + } - @SubscribeEvent - public void playerLogin(PlayerEvent.PlayerLoggedInEvent event) - { - if (!event.player.onGround){ - CustomArmorHandler.ArmorSummery summery = new CustomArmorHandler.ArmorSummery().getSummery(event.player); - if (summery != null && summery.flight[0]) { - event.player.capabilities.isFlying = true; - event.player.sendPlayerAbilities(); - } - } + @SubscribeEvent + public void playerLogin(PlayerEvent.PlayerLoggedInEvent event) { + if (!event.player.onGround) { + CustomArmorHandler.ArmorSummery summery = new CustomArmorHandler.ArmorSummery().getSummery(event.player); + if (summery != null && summery.flight[0]) { + event.player.capabilities.isFlying = true; + event.player.sendPlayerAbilities(); + } + } - if (!mmGiven && event.player.getCommandSenderName().toLowerCase().equals("dezil_nz")) - { - mmGiven = true; - event.player.addChatComponentMessage(new ChatComponentText("Hello Dez! Here have a Marshmallow")); - event.player.worldObj.spawnEntityInWorld(new EntityItem(event.player.worldObj, event.player.posX, event.player.posY, event.player.posZ, new ItemStack(ModItems.dezilsMarshmallow))); - } + if (!mmGiven && event.player.getCommandSenderName().toLowerCase().equals("dezil_nz")) { + mmGiven = true; + event.player.addChatComponentMessage(new ChatComponentText("Hello Dez! Here have a Marshmallow")); + event.player.worldObj.spawnEntityInWorld(new EntityItem(event.player.worldObj, event.player.posX, event.player.posY, event.player.posZ, new ItemStack(ModItems.dezilsMarshmallow))); + } - ContributorHandler.onPlayerLogin(event); - } + ContributorHandler.onPlayerLogin(event); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/handler/MinecraftForgeEventHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/handler/MinecraftForgeEventHandler.java index 7baac8d7..c3272138 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/handler/MinecraftForgeEventHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/handler/MinecraftForgeEventHandler.java @@ -67,364 +67,340 @@ import java.util.Random; @SuppressWarnings("unused") public class MinecraftForgeEventHandler { - Random random = new Random(); - private static Method becomeAngryAt; + Random random = new Random(); + private static Method becomeAngryAt; - public static double maxSpeed = 10F; - public static int ticksSinceRequest = 0; - public static boolean speedNeedsUpdating = true; + public static double maxSpeed = 10F; + public static int ticksSinceRequest = 0; + public static boolean speedNeedsUpdating = true; - private Field persistenceRequired = null; + private Field persistenceRequired = null; - public MinecraftForgeEventHandler(){ - try { - persistenceRequired = ReflectionHelper.findField(EntityLiving.class, "field_82179_bU", "persistenceRequired"); - } catch (Exception e) { - LogHelper.error("Unable to find field \"persistenceRequired\""); - } - } + public MinecraftForgeEventHandler() { + try { + persistenceRequired = ReflectionHelper.findField(EntityLiving.class, "field_82179_bU", "persistenceRequired"); + } + catch (Exception e) { + LogHelper.error("Unable to find field \"persistenceRequired\""); + } + } - @SubscribeEvent - public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) - { - EntityLivingBase entity = event.entityLiving; + @SubscribeEvent + public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) { + EntityLivingBase entity = event.entityLiving; - if (entity.getEntityData().hasKey("SpawnedByDESpawner")){ - long spawnTime = entity.getEntityData().getLong("SpawnedByDESpawner"); - long livedFor = entity.worldObj.getTotalWorldTime() - spawnTime; + if (entity.getEntityData().hasKey("SpawnedByDESpawner")) { + long spawnTime = entity.getEntityData().getLong("SpawnedByDESpawner"); + long livedFor = entity.worldObj.getTotalWorldTime() - spawnTime; - if (livedFor > 600 && persistenceRequired != null){ - try { - persistenceRequired.setBoolean(entity, false); - entity.getEntityData().removeTag("SpawnedByDESpawner"); - } catch (Exception e) { - LogHelper.warn("Error occured while resetting entity persistence: " + e); - entity.getEntityData().removeTag("SpawnedByDESpawner"); - } - } - } + if (livedFor > 600 && persistenceRequired != null) { + try { + persistenceRequired.setBoolean(entity, false); + entity.getEntityData().removeTag("SpawnedByDESpawner"); + } + catch (Exception e) { + LogHelper.warn("Error occured while resetting entity persistence: " + e); + entity.getEntityData().removeTag("SpawnedByDESpawner"); + } + } + } - if (!event.entityLiving.worldObj.isRemote || !(event.entityLiving instanceof EntityPlayerSP)) return; - EntityPlayerSP player = (EntityPlayerSP) entity; + if (!event.entityLiving.worldObj.isRemote || !(event.entityLiving instanceof EntityPlayerSP)) return; + EntityPlayerSP player = (EntityPlayerSP) entity; - double motionX = player.motionX; - double motionZ = player.motionZ; - double motion = Math.sqrt((motionX*motionX + motionZ*motionZ)); - double reduction = motion - maxSpeed; + double motionX = player.motionX; + double motionZ = player.motionZ; + double motion = Math.sqrt((motionX * motionX + motionZ * motionZ)); + double reduction = motion - maxSpeed; - if (motion > maxSpeed && (player.onGround || player.capabilities.isFlying)) - { - player.motionX -= motionX * reduction; - player.motionZ -= motionZ * reduction; - } + if (motion > maxSpeed && (player.onGround || player.capabilities.isFlying)) { + player.motionX -= motionX * reduction; + player.motionZ -= motionZ * reduction; + } - if (speedNeedsUpdating) - { - if (ticksSinceRequest == 0) { - DraconicEvolution.network.sendToServer(new SpeedRequestPacket()); - LogHelper.info("Requesting speed packet from server"); - } - ticksSinceRequest++; - if (ticksSinceRequest > 500) ticksSinceRequest = 0; - } - } + if (speedNeedsUpdating) { + if (ticksSinceRequest == 0) { + DraconicEvolution.network.sendToServer(new SpeedRequestPacket()); + LogHelper.info("Requesting speed packet from server"); + } + ticksSinceRequest++; + if (ticksSinceRequest > 500) ticksSinceRequest = 0; + } + } - @SubscribeEvent - public void onLivingHurt(LivingHurtEvent event){ - if (event.entityLiving instanceof EntityPlayer){ - CustomArmorHandler.onPlayerHurt(event); - } - } + @SubscribeEvent + public void onLivingHurt(LivingHurtEvent event) { + if (event.entityLiving instanceof EntityPlayer) { + CustomArmorHandler.onPlayerHurt(event); + } + } - @SubscribeEvent(priority = EventPriority.LOW) - public void onLivingDeath(LivingDeathEvent event){ - if (event.entityLiving instanceof EntityPlayer){ - CustomArmorHandler.onPlayerDeath(event); - } - } + @SubscribeEvent(priority = EventPriority.LOW) + public void onLivingDeath(LivingDeathEvent event) { + if (event.entityLiving instanceof EntityPlayer) { + CustomArmorHandler.onPlayerDeath(event); + } + } - @SubscribeEvent - public void onLivingJumpEvent(LivingEvent.LivingJumpEvent event) { - if (!(event.entityLiving instanceof EntityPlayer)) return; - EntityPlayer player = (EntityPlayer) event.entityLiving; - CustomArmorHandler.ArmorSummery summery = new CustomArmorHandler.ArmorSummery().getSummery(player); + @SubscribeEvent + public void onLivingJumpEvent(LivingEvent.LivingJumpEvent event) { + if (!(event.entityLiving instanceof EntityPlayer)) return; + EntityPlayer player = (EntityPlayer) event.entityLiving; + CustomArmorHandler.ArmorSummery summery = new CustomArmorHandler.ArmorSummery().getSummery(player); - if (summery != null && summery.jumpModifier > 0) - { - player.motionY += (double)(summery.jumpModifier * 0.1F); - } - } + if (summery != null && summery.jumpModifier > 0) { + player.motionY += (double) (summery.jumpModifier * 0.1F); + } + } - @SubscribeEvent(priority = EventPriority.LOW) - public void onLivingAttack(LivingAttackEvent event) { - if (!(event.entityLiving instanceof EntityPlayer)) return; + @SubscribeEvent(priority = EventPriority.LOW) + public void onLivingAttack(LivingAttackEvent event) { + if (!(event.entityLiving instanceof EntityPlayer)) return; - CustomArmorHandler.onPlayerAttacked(event); - } + CustomArmorHandler.onPlayerAttacked(event); + } - @SubscribeEvent - public void onDropEvent(LivingDropsEvent event) { - if (!event.entity.worldObj.isRemote && ((event.entity instanceof EntityDragon) || (EntityList.getEntityString(event.entity) != null && !EntityList.getEntityString(event.entity).isEmpty() && EntityList.getEntityString(event.entity).equals("HardcoreEnderExpansion.Dragon")))) - { - EntityItem item = new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, new ItemStack(ModItems.dragonHeart)); - event.entity.worldObj.spawnEntityInWorld(new EntityDragonHeart(event.entity.worldObj, ((int) event.entity.posX) + 0.5, event.entity.posY, ((int) event.entity.posZ) + 0.5)); - if (event.entity instanceof EntityCustomDragon && ((EntityCustomDragon) event.entity).getIsUber()){ + @SubscribeEvent + public void onDropEvent(LivingDropsEvent event) { + if (!event.entity.worldObj.isRemote && ((event.entity instanceof EntityDragon) || (EntityList.getEntityString(event.entity) != null && !EntityList.getEntityString(event.entity).isEmpty() && EntityList.getEntityString(event.entity).equals("HardcoreEnderExpansion.Dragon")))) { + EntityItem item = new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, new ItemStack(ModItems.dragonHeart)); + event.entity.worldObj.spawnEntityInWorld(new EntityDragonHeart(event.entity.worldObj, ((int) event.entity.posX) + 0.5, event.entity.posY, ((int) event.entity.posZ) + 0.5)); + if (event.entity instanceof EntityCustomDragon && ((EntityCustomDragon) event.entity).getIsUber()) { event.entity.worldObj.spawnEntityInWorld(new EntityDragonHeart(event.entity.worldObj, event.entity.posX, event.entity.posY + 2, event.entity.posZ)); } - for (Object o : event.entity.worldObj.playerEntities) - { - if (o instanceof EntityPlayer) ((EntityPlayer) o).addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("msg.de.dragonDeath.txt"))); - } + for (Object o : event.entity.worldObj.playerEntities) { + if (o instanceof EntityPlayer) + ((EntityPlayer) o).addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("msg.de.dragonDeath.txt"))); + } - int count = 30 + event.entity.worldObj.rand.nextInt(30); - for (int i = 0; i < count; i++) - { - float mm = 0.3F; - EntityItem item2 = new EntityItem(event.entity.worldObj, event.entity.posX - 2 + event.entity.worldObj.rand.nextInt(4), event.entity.posY - 2 + event.entity.worldObj.rand.nextInt(4), event.entity.posZ - 2 + event.entity.worldObj.rand.nextInt(4), new ItemStack(ModItems.draconiumDust)); - item.motionX = mm * ((((float) event.entity.worldObj.rand.nextInt(100)) / 100F) - 0.5F); - item.motionY = mm * ((((float) event.entity.worldObj.rand.nextInt(100)) / 100F) - 0.5F); - item.motionZ = mm * ((((float) event.entity.worldObj.rand.nextInt(100)) / 100F) - 0.5F); - event.entity.worldObj.spawnEntityInWorld(item2); - } - } + int count = 30 + event.entity.worldObj.rand.nextInt(30); + for (int i = 0; i < count; i++) { + float mm = 0.3F; + EntityItem item2 = new EntityItem(event.entity.worldObj, event.entity.posX - 2 + event.entity.worldObj.rand.nextInt(4), event.entity.posY - 2 + event.entity.worldObj.rand.nextInt(4), event.entity.posZ - 2 + event.entity.worldObj.rand.nextInt(4), new ItemStack(ModItems.draconiumDust)); + item.motionX = mm * ((((float) event.entity.worldObj.rand.nextInt(100)) / 100F) - 0.5F); + item.motionY = mm * ((((float) event.entity.worldObj.rand.nextInt(100)) / 100F) - 0.5F); + item.motionZ = mm * ((((float) event.entity.worldObj.rand.nextInt(100)) / 100F) - 0.5F); + event.entity.worldObj.spawnEntityInWorld(item2); + } + } - if (event.entity.worldObj.isRemote || !(event.source.damageType.equals("player") || event.source.damageType.equals("arrow")) || !isValidEntity(event.entityLiving)) - { - return; - } + if (event.entity.worldObj.isRemote || !(event.source.damageType.equals("player") || event.source.damageType.equals("arrow")) || !isValidEntity(event.entityLiving)) { + return; + } - EntityLivingBase entity = event.entityLiving; - Entity attacker = event.source.getEntity(); + EntityLivingBase entity = event.entityLiving; + Entity attacker = event.source.getEntity(); - if (attacker == null || !(attacker instanceof EntityPlayer)) - { - return; - } + if (attacker == null || !(attacker instanceof EntityPlayer)) { + return; + } - int dropChanceModifier = getDropChanceFromItem(((EntityPlayer) attacker).getHeldItem()); + int dropChanceModifier = getDropChanceFromItem(((EntityPlayer) attacker).getHeldItem()); - if (dropChanceModifier == 0) return; + if (dropChanceModifier == 0) return; - World world = entity.worldObj; - int rand = random.nextInt(Math.max(ConfigHandler.soulDropChance / dropChanceModifier, 1)); - int rand2 = random.nextInt(Math.max(ConfigHandler.passiveSoulDropChance / dropChanceModifier, 1)); - boolean isAnimal = entity instanceof EntityAnimal; + World world = entity.worldObj; + int rand = random.nextInt(Math.max(ConfigHandler.soulDropChance / dropChanceModifier, 1)); + int rand2 = random.nextInt(Math.max(ConfigHandler.passiveSoulDropChance / dropChanceModifier, 1)); + boolean isAnimal = entity instanceof EntityAnimal; - if ((rand == 0 && !isAnimal) || (rand2 == 0 && isAnimal)) - { - ItemStack soul = new ItemStack(ModItems.mobSoul); - String name = EntityList.getEntityString(entity); - ItemNBTHelper.setString(soul, "Name", name); - if (entity instanceof EntitySkeleton){ + if ((rand == 0 && !isAnimal) || (rand2 == 0 && isAnimal)) { + ItemStack soul = new ItemStack(ModItems.mobSoul); + String name = EntityList.getEntityString(entity); + ItemNBTHelper.setString(soul, "Name", name); + if (entity instanceof EntitySkeleton) { ItemNBTHelper.setInteger(soul, "SkeletonType", ((EntitySkeleton) entity).getSkeletonType()); } - world.spawnEntityInWorld(new EntityItem(world, entity.posX, entity.posY, entity.posZ, soul)); - Achievements.triggerAchievement((EntityPlayer) attacker, "draconicevolution.soul"); - } - } + world.spawnEntityInWorld(new EntityItem(world, entity.posX, entity.posY, entity.posZ, soul)); + Achievements.triggerAchievement((EntityPlayer) attacker, "draconicevolution.soul"); + } + } - private int getDropChanceFromItem(ItemStack stack) { - int chance = 0; - if (stack == null) return 0; - if (stack.getItem().equals(ModItems.wyvernBow) || stack.getItem().equals(ModItems.wyvernSword)) chance++; - if (stack.getItem().equals(ModItems.draconicSword) || stack.getItem().equals(ModItems.draconicBow)) chance += 2; - if (stack.getItem().equals(ModItems.draconicDestructionStaff)) chance += 3; + private int getDropChanceFromItem(ItemStack stack) { + int chance = 0; + if (stack == null) return 0; + if (stack.getItem().equals(ModItems.wyvernBow) || stack.getItem().equals(ModItems.wyvernSword)) chance++; + if (stack.getItem().equals(ModItems.draconicSword) || stack.getItem().equals(ModItems.draconicBow)) chance += 2; + if (stack.getItem().equals(ModItems.draconicDestructionStaff)) chance += 3; - chance += EnchantmentHelper.getEnchantmentLevel(ConfigHandler.reaperEnchantID, stack); - return chance; - } + chance += EnchantmentHelper.getEnchantmentLevel(ConfigHandler.reaperEnchantID, stack); + return chance; + } - private boolean isValidEntity(EntityLivingBase entity) { - if (entity instanceof IBossDisplayData) - { - return false; - } - for (int i = 0; i < ConfigHandler.spawnerList.length; i++) - { - if (ConfigHandler.spawnerList[i].equals(entity.getCommandSenderName()) && ConfigHandler.spawnerListType) - { - return true; - } else if (ConfigHandler.spawnerList[i].equals(entity.getCommandSenderName()) && !ConfigHandler.spawnerListType) - { - return false; - } - } - if (ConfigHandler.spawnerListType) - { - return false; - } else - { - return true; - } - } + private boolean isValidEntity(EntityLivingBase entity) { + if (entity instanceof IBossDisplayData) { + return false; + } + for (int i = 0; i < ConfigHandler.spawnerList.length; i++) { + if (ConfigHandler.spawnerList[i].equals(entity.getCommandSenderName()) && ConfigHandler.spawnerListType) { + return true; + } else if (ConfigHandler.spawnerList[i].equals(entity.getCommandSenderName()) && !ConfigHandler.spawnerListType) { + return false; + } + } + if (ConfigHandler.spawnerListType) { + return false; + } else { + return true; + } + } - private boolean changeBlock(ExtendedBlockStorage storage, int x, int y, int z) { + private boolean changeBlock(ExtendedBlockStorage storage, int x, int y, int z) { - if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.particleGenerator")) - return makeChange(storage, x, y, z, ModBlocks.particleGenerator); - else if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.customSpawner")) - return makeChange(storage, x, y, z, ModBlocks.customSpawner); - else if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.generator")) - return makeChange(storage, x, y, z, ModBlocks.generator); - else if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.playerDetectorAdvanced")) - return makeChange(storage, x, y, z, ModBlocks.playerDetectorAdvanced); - else if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.energyInfuser")) - return makeChange(storage, x, y, z, ModBlocks.energyInfuser); - else if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.draconiumOre")) - return makeChange(storage, x, y, z, ModBlocks.draconiumOre); - else if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.weatherController")) - return makeChange(storage, x, y, z, ModBlocks.weatherController); - else if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.longRangeDislocator")) - return makeChange(storage, x, y, z, ModBlocks.longRangeDislocator); - else if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.grinder")) - return makeChange(storage, x, y, z, ModBlocks.grinder); - return false; - } + if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.particleGenerator")) + return makeChange(storage, x, y, z, ModBlocks.particleGenerator); + else if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.customSpawner")) + return makeChange(storage, x, y, z, ModBlocks.customSpawner); + else if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.generator")) + return makeChange(storage, x, y, z, ModBlocks.generator); + else if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.playerDetectorAdvanced")) + return makeChange(storage, x, y, z, ModBlocks.playerDetectorAdvanced); + else if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.energyInfuser")) + return makeChange(storage, x, y, z, ModBlocks.energyInfuser); + else if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.draconiumOre")) + return makeChange(storage, x, y, z, ModBlocks.draconiumOre); + else if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.weatherController")) + return makeChange(storage, x, y, z, ModBlocks.weatherController); + else if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.longRangeDislocator")) + return makeChange(storage, x, y, z, ModBlocks.longRangeDislocator); + else if (storage.getBlockByExtId(x, y, z).getUnlocalizedName().equals("tile.tile.grinder")) + return makeChange(storage, x, y, z, ModBlocks.grinder); + return false; + } - private boolean makeChange(ExtendedBlockStorage storage, int x, int y, int z, Block block) { - if (block == null) return false; - LogHelper.info("Changing block at [X:" + x + " Y:" + y + " Z:" + z + "] from " + storage.getBlockByExtId(x, y, z).getUnlocalizedName() + " to " + block.getUnlocalizedName()); - storage.func_150818_a(x, y, z, block); - return true; - } + private boolean makeChange(ExtendedBlockStorage storage, int x, int y, int z, Block block) { + if (block == null) return false; + LogHelper.info("Changing block at [X:" + x + " Y:" + y + " Z:" + z + "] from " + storage.getBlockByExtId(x, y, z).getUnlocalizedName() + " to " + block.getUnlocalizedName()); + storage.func_150818_a(x, y, z, block); + return true; + } - @SubscribeEvent - public void onEntityConstructing(EntityEvent.EntityConstructing event) { - if (event.entity instanceof EntityPlayer && ExtendedPlayer.get((EntityPlayer) event.entity) == null) - ExtendedPlayer.register((EntityPlayer) event.entity); - } + @SubscribeEvent + public void onEntityConstructing(EntityEvent.EntityConstructing event) { + if (event.entity instanceof EntityPlayer && ExtendedPlayer.get((EntityPlayer) event.entity) == null) + ExtendedPlayer.register((EntityPlayer) event.entity); + } - @SubscribeEvent - public void itemTooltipEvent(ItemTooltipEvent event) { - if (ConfigHandler.showUnlocalizedNames) event.toolTip.add(event.itemStack.getUnlocalizedName()); - if (DraconicEvolution.debug && event.itemStack.hasTagCompound()){ - String s = event.itemStack.getTagCompound().toString(); - int escape = 0; - while (s.contains(",")){ - event.toolTip.add(s.substring(0, s.indexOf(",")+1)); - s = s.substring(s.indexOf(",")+1, s.length()); + @SubscribeEvent + public void itemTooltipEvent(ItemTooltipEvent event) { + if (ConfigHandler.showUnlocalizedNames) event.toolTip.add(event.itemStack.getUnlocalizedName()); + if (DraconicEvolution.debug && event.itemStack.hasTagCompound()) { + String s = event.itemStack.getTagCompound().toString(); + int escape = 0; + while (s.contains(",")) { + event.toolTip.add(s.substring(0, s.indexOf(",") + 1)); + s = s.substring(s.indexOf(",") + 1, s.length()); - if (escape++ >= 100) break; - } - event.toolTip.add(s); - } - } + if (escape++ >= 100) break; + } + event.toolTip.add(s); + } + } - @SubscribeEvent - public void stopUsingEvent(PlayerUseItemEvent.Start event) { - if (!ConfigHandler.pigmenBloodRage || event.item == null || event.item.getItem() == null) return; - if (event.item.getItem() == Items.porkchop || event.item.getItem() == Items.cooked_porkchop) - { - World world = event.entityPlayer.worldObj; - if (world.isRemote) return; - EntityPlayer player = event.entityPlayer; - List list = world.getEntitiesWithinAABB(EntityPigZombie.class, AxisAlignedBB.getBoundingBox(player.posX - 32, player.posY - 32, player.posZ - 32, player.posX + 32, player.posY + 32, player.posZ + 32)); + @SubscribeEvent + public void stopUsingEvent(PlayerUseItemEvent.Start event) { + if (!ConfigHandler.pigmenBloodRage || event.item == null || event.item.getItem() == null) return; + if (event.item.getItem() == Items.porkchop || event.item.getItem() == Items.cooked_porkchop) { + World world = event.entityPlayer.worldObj; + if (world.isRemote) return; + EntityPlayer player = event.entityPlayer; + List list = world.getEntitiesWithinAABB(EntityPigZombie.class, AxisAlignedBB.getBoundingBox(player.posX - 32, player.posY - 32, player.posZ - 32, player.posX + 32, player.posY + 32, player.posZ + 32)); - EntityZombie entityAtPlayer = new EntityPigZombie(world); - entityAtPlayer.setPosition(player.posX, player.posY, player.posZ); + EntityZombie entityAtPlayer = new EntityPigZombie(world); + entityAtPlayer.setPosition(player.posX, player.posY, player.posZ); - boolean flag = false; + boolean flag = false; - for (Object o : list) - { - if (o instanceof EntityPigZombie) - { - EntityPigZombie zombie = (EntityPigZombie) o; - if (becomeAngryAt == null) - { - becomeAngryAt = ReflectionHelper.findMethod(EntityPigZombie.class, zombie, new String[]{"becomeAngryAt", "func_70835_c"}, Entity.class); - becomeAngryAt.setAccessible(true); - } + for (Object o : list) { + if (o instanceof EntityPigZombie) { + EntityPigZombie zombie = (EntityPigZombie) o; + if (becomeAngryAt == null) { + becomeAngryAt = ReflectionHelper.findMethod(EntityPigZombie.class, zombie, new String[]{"becomeAngryAt", "func_70835_c"}, Entity.class); + becomeAngryAt.setAccessible(true); + } - try - { - becomeAngryAt.invoke(zombie, player); - } - catch (IllegalAccessException e) - { - e.printStackTrace(); - } - catch (InvocationTargetException e) - { - e.printStackTrace(); - } + try { + becomeAngryAt.invoke(zombie, player); + } + catch (IllegalAccessException e) { + e.printStackTrace(); + } + catch (InvocationTargetException e) { + e.printStackTrace(); + } - if (Math.abs(zombie.posX - player.posX) < 14 && Math.abs(zombie.posY - player.posY) < 14 && Math.abs(zombie.posZ - player.posZ) < 14) - flag = true; - zombie.addPotionEffect(new PotionEffect(5, 10000, 3)); - zombie.addPotionEffect(new PotionEffect(11, 10000, 2)); - } - } - - if (flag) player.addPotionEffect(new PotionEffect(2, 500, 3)); - } - } - - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void joinWorld(EntityJoinWorldEvent event) { - if (event.entity instanceof EntityPlayerSP) - { - speedNeedsUpdating = true; - DraconicEvolution.network.sendToServer(new MountUpdatePacket(0)); - } - } - - @SubscribeEvent(priority = EventPriority.LOW) - public void getBreakSpeed(PlayerEvent.BreakSpeed event) { - if (event.entityPlayer != null) - { - float newDigSpeed = event.originalSpeed; - CustomArmorHandler.ArmorSummery summery = new CustomArmorHandler.ArmorSummery().getSummery(event.entityPlayer); - if (summery == null) return; - - if (event.entityPlayer.isInsideOfMaterial(Material.water)) - { - if (summery.flight[0]) newDigSpeed *= 5f; - } - - if (!event.entityPlayer.onGround) - { - if (summery.flight[0]) newDigSpeed *= 5f; - } - - if (event.newSpeed > 1){ - newDigSpeed += event.newSpeed-1; + if (Math.abs(zombie.posX - player.posX) < 14 && Math.abs(zombie.posY - player.posY) < 14 && Math.abs(zombie.posZ - player.posZ) < 14) + flag = true; + zombie.addPotionEffect(new PotionEffect(5, 10000, 3)); + zombie.addPotionEffect(new PotionEffect(11, 10000, 2)); + } } - event.newSpeed = newDigSpeed; - } - } + if (flag) player.addPotionEffect(new PotionEffect(2, 500, 3)); + } + } - @SubscribeEvent - public void worldUnload(WorldEvent.Unload e) { - TileGrinder.fakePlayer = null; - } + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void joinWorld(EntityJoinWorldEvent event) { + if (event.entity instanceof EntityPlayerSP) { + speedNeedsUpdating = true; + DraconicEvolution.network.sendToServer(new MountUpdatePacket(0)); + } + } - @SubscribeEvent - public void playerInteract(PlayerInteractEvent event){ - if (event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK){ - ForgeDirection face = ForgeDirection.getOrientation(event.face); - int x = event.x + face.offsetX; - int y = event.y + face.offsetY; - int z = event.z + face.offsetZ; - if (event.world.getBlock(x, y, z) == ModBlocks.safetyFlame){ - event.world.setBlockToAir(x, y, z); - event.world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.fizz", 1F, event.world.rand.nextFloat() * 0.1F + 2F); - event.setCanceled(true); - } - } - } + @SubscribeEvent(priority = EventPriority.LOW) + public void getBreakSpeed(PlayerEvent.BreakSpeed event) { + if (event.entityPlayer != null) { + float newDigSpeed = event.originalSpeed; + CustomArmorHandler.ArmorSummery summery = new CustomArmorHandler.ArmorSummery().getSummery(event.entityPlayer); + if (summery == null) return; - @SubscribeEvent - public void entityJoinWorld(EntityJoinWorldEvent event){ - if (!event.world.isRemote && event.entity instanceof EntityEnderCrystal && event.entity.dimension == 1){ - DataUtills.XZPair location = ChaosWorldGenHandler.getClosestChaosSpawn((int)event.entity.posX/16, (int)event.entity.posZ/16); - if ((location.x != 0 || location.z != 0) && Utills.getDistanceAtoB(event.entity.posX, event.entity.posZ, location.x, location.z) < 500){ - ProcessHandler.addProcess(new ChaosWorldGenHandler.CrystalRemover(event.entity)); - } - } - } + if (event.entityPlayer.isInsideOfMaterial(Material.water)) { + if (summery.flight[0]) newDigSpeed *= 5f; + } + + if (!event.entityPlayer.onGround) { + if (summery.flight[0]) newDigSpeed *= 5f; + } + + if (event.newSpeed > 1) { + newDigSpeed += event.newSpeed - 1; + } + + event.newSpeed = newDigSpeed; + } + } + + @SubscribeEvent + public void worldUnload(WorldEvent.Unload e) { + TileGrinder.fakePlayer = null; + } + + @SubscribeEvent + public void playerInteract(PlayerInteractEvent event) { + if (event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) { + ForgeDirection face = ForgeDirection.getOrientation(event.face); + int x = event.x + face.offsetX; + int y = event.y + face.offsetY; + int z = event.z + face.offsetZ; + if (event.world.getBlock(x, y, z) == ModBlocks.safetyFlame) { + event.world.setBlockToAir(x, y, z); + event.world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.fizz", 1F, event.world.rand.nextFloat() * 0.1F + 2F); + event.setCanceled(true); + } + } + } + + @SubscribeEvent + public void entityJoinWorld(EntityJoinWorldEvent event) { + if (!event.world.isRemote && event.entity instanceof EntityEnderCrystal && event.entity.dimension == 1) { + DataUtills.XZPair location = ChaosWorldGenHandler.getClosestChaosSpawn((int) event.entity.posX / 16, (int) event.entity.posZ / 16); + if ((location.x != 0 || location.z != 0) && Utills.getDistanceAtoB(event.entity.posX, event.entity.posZ, location.x, location.z) < 500) { + ProcessHandler.addProcess(new ChaosWorldGenHandler.CrystalRemover(event.entity)); + } + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/inventory/GenericInventory.java b/src/main/java/com/brandon3055/draconicevolution/common/inventory/GenericInventory.java index c50a8b1e..e2146428 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/inventory/GenericInventory.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/inventory/GenericInventory.java @@ -9,91 +9,85 @@ import net.minecraft.item.ItemStack; */ public abstract class GenericInventory implements IInventory { - public abstract ItemStack[] getStorage(); + public abstract ItemStack[] getStorage(); - @Override - public int getSizeInventory() { - return getStorage().length; - } + @Override + public int getSizeInventory() { + return getStorage().length; + } - @Override - public ItemStack getStackInSlot(int slot) { - return slot < getStorage().length ? getStorage()[slot] : null; - } + @Override + public ItemStack getStackInSlot(int slot) { + return slot < getStorage().length ? getStorage()[slot] : null; + } - @Override - public ItemStack decrStackSize(int i, int count) { - ItemStack itemstack = getStackInSlot(i); + @Override + public ItemStack decrStackSize(int i, int count) { + ItemStack itemstack = getStackInSlot(i); - if (itemstack != null) - { - if (itemstack.stackSize <= count) - { - setInventorySlotContents(i, null); - } else - { - itemstack = itemstack.splitStack(count); - if (itemstack.stackSize == 0) - { - setInventorySlotContents(i, null); - } - } - } - return itemstack; - } + if (itemstack != null) { + if (itemstack.stackSize <= count) { + setInventorySlotContents(i, null); + } else { + itemstack = itemstack.splitStack(count); + if (itemstack.stackSize == 0) { + setInventorySlotContents(i, null); + } + } + } + return itemstack; + } - @Override - public ItemStack getStackInSlotOnClosing(int i) { - ItemStack item = getStackInSlot(i); - if (item != null) - setInventorySlotContents(i, null); - return item; - } + @Override + public ItemStack getStackInSlotOnClosing(int i) { + ItemStack item = getStackInSlot(i); + if (item != null) setInventorySlotContents(i, null); + return item; + } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - getStorage()[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - { - itemstack.stackSize = getInventoryStackLimit(); - } - } + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + getStorage()[i] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } - @Override - public String getInventoryName() - { - return ""; - } + @Override + public String getInventoryName() { + return ""; + } - @Override - public boolean hasCustomInventoryName() - { - return false; - } + @Override + public boolean hasCustomInventoryName() { + return false; + } - @Override - public int getInventoryStackLimit() - { - return 64; - } + @Override + public int getInventoryStackLimit() { + return 64; + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) - { - return true; - } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return true; + } - @Override - public void openInventory() {} + @Override + public void openInventory() { + } - @Override - public void closeInventory() {} + @Override + public void closeInventory() { + } - @Override - public void markDirty() { + @Override + public void markDirty() { - } + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { return true; } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/inventory/InventoryCraftingChest.java b/src/main/java/com/brandon3055/draconicevolution/common/inventory/InventoryCraftingChest.java index 0dc103b8..af6cd272 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/inventory/InventoryCraftingChest.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/inventory/InventoryCraftingChest.java @@ -8,164 +8,140 @@ import net.minecraft.item.ItemStack; /** * Created by Brandon on 29/10/2014. */ -public class InventoryCraftingChest extends InventoryCrafting -{ - /** the width of the crafting inventory */ - private int inventoryWidth; +public class InventoryCraftingChest extends InventoryCrafting { + /** + * the width of the crafting inventory + */ + private int inventoryWidth; - /** - * Class containing the callbacks for the events on_GUIClosed and - * on_CraftMaxtrixChanged. - */ - private Container eventHandler; - private TileDraconiumChest tile; + /** + * Class containing the callbacks for the events on_GUIClosed and + * on_CraftMaxtrixChanged. + */ + private Container eventHandler; + private TileDraconiumChest tile; - public InventoryCraftingChest(Container par1Container, int size, int height, TileDraconiumChest tile) - { - super(par1Container, size, height); - this.eventHandler = par1Container; - this.inventoryWidth = size; - this.tile = tile; - } + public InventoryCraftingChest(Container par1Container, int size, int height, TileDraconiumChest tile) { + super(par1Container, size, height); + this.eventHandler = par1Container; + this.inventoryWidth = size; + this.tile = tile; + } - /** - * Returns the number of slots in the inventory. - */ - @Override - public int getSizeInventory () - { - return 9; - } + /** + * Returns the number of slots in the inventory. + */ + @Override + public int getSizeInventory() { + return 9; + } - @Override - public ItemStack getStackInSlot (int slot) - { - // the 9 slots + 1 output slot that's not accessible, we therefore have to add 1 to the slot accessed - return slot >= getSizeInventory() ? null : tile.getStackInCraftingSlot(slot+1); - } + @Override + public ItemStack getStackInSlot(int slot) { + // the 9 slots + 1 output slot that's not accessible, we therefore have to add 1 to the slot accessed + return slot >= getSizeInventory() ? null : tile.getStackInCraftingSlot(slot + 1); + } - @Override - public ItemStack getStackInRowAndColumn (int row, int column) - { - if (row >= 0 && row < inventoryWidth) - { - int k = row + column * inventoryWidth; - return getStackInSlot(k); - } - else - { - return null; - } - } + @Override + public ItemStack getStackInRowAndColumn(int row, int column) { + if (row >= 0 && row < inventoryWidth) { + int k = row + column * inventoryWidth; + return getStackInSlot(k); + } else { + return null; + } + } - public String getInvName () - { - return ""; - } + public String getInvName() { + return ""; + } - public boolean isInvNameLocalized () - { - return false; - } + public boolean isInvNameLocalized() { + return false; + } - @Override - public ItemStack getStackInSlotOnClosing (int par1) - { - return null; - } + @Override + public ItemStack getStackInSlotOnClosing(int par1) { + return null; + } - /** - * 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 slotID, int par2) - { - ItemStack stack = tile.getStackInCraftingSlot(slotID + 1); - if (stack != null) - { - ItemStack itemstack; + /** + * 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 slotID, int par2) { + ItemStack stack = tile.getStackInCraftingSlot(slotID + 1); + if (stack != null) { + ItemStack itemstack; - if (stack.stackSize <= par2) - { - itemstack = stack.copy(); - stack = null; - tile.setInventoryCraftingSlotContents(slotID + 1, null); - eventHandler.onCraftMatrixChanged(this); - return itemstack; - } - else - { - itemstack = stack.splitStack(par2); + if (stack.stackSize <= par2) { + itemstack = stack.copy(); + stack = null; + tile.setInventoryCraftingSlotContents(slotID + 1, null); + eventHandler.onCraftMatrixChanged(this); + return itemstack; + } else { + itemstack = stack.splitStack(par2); - if (stack.stackSize == 0) - { - stack = null; - } + if (stack.stackSize == 0) { + stack = null; + } - eventHandler.onCraftMatrixChanged(this); - return itemstack; - } - } - else - { - return null; - } - } + eventHandler.onCraftMatrixChanged(this); + return itemstack; + } + } else { + return null; + } + } - /** - * Sets the given item stack to the specified slot in the inventory (can be - * crafting or armor sections). - */ - @Override - public void setInventorySlotContents (int slot, ItemStack itemstack) - { - tile.setInventoryCraftingSlotContents(slot + 1, itemstack); - eventHandler.onCraftMatrixChanged(this); - } + /** + * Sets the given item stack to the specified slot in the inventory (can be + * crafting or armor sections). + */ + @Override + public void setInventorySlotContents(int slot, ItemStack itemstack) { + tile.setInventoryCraftingSlotContents(slot + 1, itemstack); + eventHandler.onCraftMatrixChanged(this); + } - /** - * Returns the maximum stack size for a inventory slot. Seems to always be - * 64, possibly will be extended. *Isn't this more of a set than a get?* - */ - @Override - public int getInventoryStackLimit () - { - return 64; - } + /** + * Returns the maximum stack size for a inventory slot. Seems to always be + * 64, possibly will be extended. *Isn't this more of a set than a get?* + */ + @Override + public int getInventoryStackLimit() { + return 64; + } - /** - * Called when an the contents of an Inventory change, usually - */ - @Override - public void markDirty () - { - } + /** + * Called when an the contents of an Inventory change, usually + */ + @Override + public void markDirty() { + } - /** - * Do not make give this method the name canInteractWith because it clashes - * with Container - */ - @Override - public boolean isUseableByPlayer (EntityPlayer par1EntityPlayer) - { - return true; - } + /** + * Do not make give this method the name canInteractWith because it clashes + * with Container + */ + @Override + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) { + return true; + } - public void openChest () - { - } + public void openChest() { + } - public void closeChest () - { - } + public void closeChest() { + } - /** - * Returns true if automation is allowed to insert the given stack (ignoring - * stack size) into the given slot. - */ - public boolean isStackValidForSlot (int par1, ItemStack par2ItemStack) - { - return true; - } + /** + * Returns true if automation is allowed to insert the given stack (ignoring + * stack size) into the given slot. + */ + public boolean isStackValidForSlot(int par1, ItemStack par2ItemStack) { + return true; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/inventory/InventoryCraftingChestResult.java b/src/main/java/com/brandon3055/draconicevolution/common/inventory/InventoryCraftingChestResult.java index 3608c87b..01b358da 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/inventory/InventoryCraftingChestResult.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/inventory/InventoryCraftingChestResult.java @@ -8,134 +8,116 @@ import net.minecraft.item.ItemStack; /** * Created by Brandon on 29/10/2014. */ -public class InventoryCraftingChestResult extends InventoryCraftResult -{ - TileDraconiumChest tile; +public class InventoryCraftingChestResult extends InventoryCraftResult { + TileDraconiumChest tile; - public InventoryCraftingChestResult(TileDraconiumChest tile) - { - this.tile = tile; - } + public InventoryCraftingChestResult(TileDraconiumChest tile) { + this.tile = tile; + } - /** - * Returns the number of slots in the inventory. - */ - @Override - public int getSizeInventory () - { - return 1; - } + /** + * Returns the number of slots in the inventory. + */ + @Override + public int getSizeInventory() { + return 1; + } - /** - * Returns the stack in slot i - */ - @Override - public ItemStack getStackInSlot (int par1) - { - return tile.getStackInCraftingSlot(0);// this.stackResult[0]; - } + /** + * Returns the stack in slot i + */ + @Override + public ItemStack getStackInSlot(int par1) { + return tile.getStackInCraftingSlot(0);// this.stackResult[0]; + } - /** - * Returns the name of the inventory. - */ - public String getInvName () - { - return ""; - } + /** + * Returns the name of the inventory. + */ + public String getInvName() { + return ""; + } - /** - * If this returns false, the inventory name will be used as an unlocalized - * name, and translated into the player's language. Otherwise it will be - * used directly. - */ - public boolean isInvNameLocalized () - { - return false; - } + /** + * If this returns false, the inventory name will be used as an unlocalized + * name, and translated into the player's language. Otherwise it will be + * used directly. + */ + public boolean isInvNameLocalized() { + return false; + } - /** - * 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 par1, int par2) - { - ItemStack stack = tile.getStackInCraftingSlot(0); - if (stack != null) - { - ItemStack itemstack = stack; - tile.setInventoryCraftingSlotContents(0, null); - return itemstack; - } - else - { - return null; - } - } + /** + * 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 par1, int par2) { + ItemStack stack = tile.getStackInCraftingSlot(0); + if (stack != null) { + ItemStack itemstack = stack; + tile.setInventoryCraftingSlotContents(0, 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. - */ - @Override - public ItemStack getStackInSlotOnClosing (int par1) - { - 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(int par1) { + return null; + } - /** - * Sets the given item stack to the specified slot in the inventory (can be - * crafting or armor sections). - */ - @Override - public void setInventorySlotContents (int par1, ItemStack par2ItemStack) - { - tile.setInventoryCraftingSlotContents(0, par2ItemStack); - } + /** + * Sets the given item stack to the specified slot in the inventory (can be + * crafting or armor sections). + */ + @Override + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { + tile.setInventoryCraftingSlotContents(0, par2ItemStack); + } - /** - * Returns the maximum stack size for a inventory slot. Seems to always be - * 64, possibly will be extended. *Isn't this more of a set than a get?* - */ - @Override - public int getInventoryStackLimit () - { - return 64; - } + /** + * Returns the maximum stack size for a inventory slot. Seems to always be + * 64, possibly will be extended. *Isn't this more of a set than a get?* + */ + @Override + public int getInventoryStackLimit() { + return 64; + } - /** - * Called when an the contents of an Inventory change, usually - */ - @Override - public void markDirty () - { - } + /** + * Called when an the contents of an Inventory change, usually + */ + @Override + public void markDirty() { + } - /** - * Do not make give this method the name canInteractWith because it clashes - * with Container - */ - @Override - public boolean isUseableByPlayer (EntityPlayer par1EntityPlayer) - { - return true; - } + /** + * Do not make give this method the name canInteractWith because it clashes + * with Container + */ + @Override + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) { + return true; + } - public void openChest () - { - } + public void openChest() { + } - public void closeChest () - { - } + public void closeChest() { + } - /** - * Returns true if automation is allowed to insert the given stack (ignoring - * stack size) into the given slot. - */ - public boolean isStackValidForSlot (int par1, ItemStack par2ItemStack) - { - return true; - } + /** + * Returns true if automation is allowed to insert the given stack (ignoring + * stack size) into the given slot. + */ + public boolean isStackValidForSlot(int par1, ItemStack par2ItemStack) { + return true; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/inventory/InventoryTool.java b/src/main/java/com/brandon3055/draconicevolution/common/inventory/InventoryTool.java index 73ed7927..48cdd588 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/inventory/InventoryTool.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/inventory/InventoryTool.java @@ -17,186 +17,160 @@ import net.minecraft.util.StringUtils; */ public class InventoryTool implements IInventory { - public int size; - public ItemStack inventoryItem; - private ItemStack[] inventoryStacks; - private EntityPlayer player; - private ContainerAdvTool container; - private int slot = -1; + public int size; + public ItemStack inventoryItem; + private ItemStack[] inventoryStacks; + private EntityPlayer player; + private ContainerAdvTool container; + private int slot = -1; - public InventoryTool(EntityPlayer player, ItemStack stack) { - this.inventoryItem = stack; - this.player = player; - if (stack != null && stack.getItem() instanceof IInventoryTool){ - this.size = ((IInventoryTool) stack.getItem()).getInventorySlots(); - readFromNBT(ItemNBTHelper.getCompound(stack)); - } - this.inventoryStacks = new ItemStack[size + 5]; - } + public InventoryTool(EntityPlayer player, ItemStack stack) { + this.inventoryItem = stack; + this.player = player; + if (stack != null && stack.getItem() instanceof IInventoryTool) { + this.size = ((IInventoryTool) stack.getItem()).getInventorySlots(); + readFromNBT(ItemNBTHelper.getCompound(stack)); + } + this.inventoryStacks = new ItemStack[size + 5]; + } - public void setAndReadFromStack(ItemStack stack, int slot){ - this.slot = slot; - this.inventoryItem = stack; - this.size = ((IInventoryTool) stack.getItem()).getInventorySlots(); - this.inventoryStacks = new ItemStack[size + 5]; - readFromNBT(ItemNBTHelper.getCompound(inventoryItem)); - } + public void setAndReadFromStack(ItemStack stack, int slot) { + this.slot = slot; + this.inventoryItem = stack; + this.size = ((IInventoryTool) stack.getItem()).getInventorySlots(); + this.inventoryStacks = new ItemStack[size + 5]; + readFromNBT(ItemNBTHelper.getCompound(inventoryItem)); + } - public void setContainer(ContainerAdvTool container) { this.container = container; } + public void setContainer(ContainerAdvTool container) { + this.container = container; + } - @Override - public int getSizeInventory() - { - return inventoryStacks.length; - } + @Override + public int getSizeInventory() { + return inventoryStacks.length; + } - @Override - public ItemStack getStackInSlot(int i) - { - return inventoryStacks[i]; - } + @Override + public ItemStack getStackInSlot(int i) { + return inventoryStacks[i]; + } - @Override - public ItemStack decrStackSize(int i, int count) - { - ItemStack itemstack = getStackInSlot(i); + @Override + public ItemStack decrStackSize(int i, int count) { + ItemStack itemstack = getStackInSlot(i); - if (itemstack != null) - { - if (itemstack.stackSize <= count) - { - setInventorySlotContents(i, null); - } else - { - itemstack = itemstack.splitStack(count); - if (itemstack.stackSize == 0) - { - setInventorySlotContents(i, null); - } - } - } - return itemstack; - } + if (itemstack != null) { + if (itemstack.stackSize <= count) { + setInventorySlotContents(i, null); + } else { + itemstack = itemstack.splitStack(count); + if (itemstack.stackSize == 0) { + setInventorySlotContents(i, null); + } + } + } + return itemstack; + } - @Override - public ItemStack getStackInSlotOnClosing(int i) - { - ItemStack item = getStackInSlot(i); - if (item != null) - setInventorySlotContents(i, null); - return item; - } + @Override + public ItemStack getStackInSlotOnClosing(int i) { + ItemStack item = getStackInSlot(i); + if (item != null) setInventorySlotContents(i, null); + return item; + } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) - { - inventoryStacks[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - { - itemstack.stackSize = getInventoryStackLimit(); - } - } + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + inventoryStacks[i] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } - @Override - public String getInventoryName() - { - return inventoryItem != null && inventoryItem.getItem() instanceof IInventoryTool ? !StringUtils.isNullOrEmpty(((IInventoryTool) inventoryItem.getItem()).getInventoryName()) ? ((IInventoryTool) inventoryItem.getItem()).getInventoryName() : "" : ""; - } + @Override + public String getInventoryName() { + return inventoryItem != null && inventoryItem.getItem() instanceof IInventoryTool ? !StringUtils.isNullOrEmpty(((IInventoryTool) inventoryItem.getItem()).getInventoryName()) ? ((IInventoryTool) inventoryItem.getItem()).getInventoryName() : "" : ""; + } - @Override - public boolean hasCustomInventoryName() - { - return false; - } + @Override + public boolean hasCustomInventoryName() { + return false; + } - @Override - public int getInventoryStackLimit() - { - return 1; - } + @Override + public int getInventoryStackLimit() { + return 1; + } - @Override - public void markDirty() { + @Override + public void markDirty() { - for (int i = 0; i < getSizeInventory(); ++i) - { - if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) { - inventoryStacks[i] = null; - } - } + for (int i = 0; i < getSizeInventory(); ++i) { + if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) { + inventoryStacks[i] = null; + } + } - if (getItem() != null) { - writeToNBT(ItemNBTHelper.getCompound(getItem())); - readFromNBT(ItemNBTHelper.getCompound(getItem())); - } - else { - LogHelper.error("[InventoryItem] storage item == null This is not a good thing..."); - } + if (getItem() != null) { + writeToNBT(ItemNBTHelper.getCompound(getItem())); + readFromNBT(ItemNBTHelper.getCompound(getItem())); + } else { + LogHelper.error("[InventoryItem] storage item == null This is not a good thing..."); + } - container.detectAndSendChanges(); - } + container.detectAndSendChanges(); + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) - { - return true; - } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return true; + } - private ItemStack getItem(){ - if (slot != -1 && player.inventory.getStackInSlot(slot) != null && inventoryItem != null && player.inventory.getStackInSlot(slot).getItem() == inventoryItem.getItem()){ - return player.inventory.getStackInSlot(slot); - } - else { - LogHelper.error("Error getting inventory item [InventoryTool#getItem() - "+ slot +"]"); - return null; - } - } + private ItemStack getItem() { + if (slot != -1 && player.inventory.getStackInSlot(slot) != null && inventoryItem != null && player.inventory.getStackInSlot(slot).getItem() == inventoryItem.getItem()) { + return player.inventory.getStackInSlot(slot); + } else { + LogHelper.error("Error getting inventory item [InventoryTool#getItem() - " + slot + "]"); + return null; + } + } - @Override - public void openInventory() - { - } + @Override + public void openInventory() { + } - @Override - public void closeInventory() - { - } + @Override + public void closeInventory() { + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) - { - return true; - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } - public void writeToNBT(NBTTagCompound compound) - { - NBTTagCompound[] tag = new NBTTagCompound[size]; - NBTTagList enchList = new NBTTagList(); + public void writeToNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[size]; + NBTTagList enchList = new NBTTagList(); - for (int i = 0; i < getSizeInventory(); i++) - { - if (i < size) - { - tag[i] = new NBTTagCompound(); + for (int i = 0; i < getSizeInventory(); i++) { + if (i < size) { + tag[i] = new NBTTagCompound(); - if (inventoryStacks[i] != null) - { - tag[i] = inventoryStacks[i].writeToNBT(tag[i]); - } + if (inventoryStacks[i] != null) { + tag[i] = inventoryStacks[i].writeToNBT(tag[i]); + } - compound.setTag("Item" + i, tag[i]); - } - else if (inventoryStacks[i] != null) - { - if (inventoryStacks[i].getTagCompound() == null) inventoryStacks[i] = null; - else - { - enchList.appendTag(inventoryStacks[i].getTagCompound().getTagList("StoredEnchantments", 10).getCompoundTagAt(0)); - } - } - compound.setTag("ench", enchList); - } + compound.setTag("Item" + i, tag[i]); + } else if (inventoryStacks[i] != null) { + if (inventoryStacks[i].getTagCompound() == null) inventoryStacks[i] = null; + else { + enchList.appendTag(inventoryStacks[i].getTagCompound().getTagList("StoredEnchantments", 10).getCompoundTagAt(0)); + } + } + compound.setTag("ench", enchList); + } // for (int i = size; i < getSizeInventory(); i++) // { @@ -207,32 +181,27 @@ public class InventoryTool implements IInventory { // } // } - if (compound.hasKey("ench") && compound.getTagList("ench", 10).tagCount() == 0) compound.removeTag("ench"); - } + if (compound.hasKey("ench") && compound.getTagList("ench", 10).tagCount() == 0) compound.removeTag("ench"); + } - public void readFromNBT(NBTTagCompound compound) - { - NBTTagCompound[] tag = new NBTTagCompound[size]; - NBTTagList enchList = null; - if (compound.hasKey("ench")) enchList = compound.getTagList("ench", 10); + public void readFromNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[size]; + NBTTagList enchList = null; + if (compound.hasKey("ench")) enchList = compound.getTagList("ench", 10); - for (int i = 0; i < getSizeInventory(); i++) - { - inventoryStacks[i] = null; - if (i < size) - { - tag[i] = compound.getCompoundTag("Item" + i); - inventoryStacks[i] = ItemStack.loadItemStackFromNBT(tag[i]); - } - else if (enchList != null && enchList.tagCount() > i-size) - { - inventoryStacks[i] = new ItemStack(Items.enchanted_book); - inventoryStacks[i].setTagCompound(new NBTTagCompound()); - NBTTagList list = new NBTTagList(); - list.appendTag(enchList.getCompoundTagAt(i - size)); - inventoryStacks[i].getTagCompound().setTag("StoredEnchantments", list); - } - } + for (int i = 0; i < getSizeInventory(); i++) { + inventoryStacks[i] = null; + if (i < size) { + tag[i] = compound.getCompoundTag("Item" + i); + inventoryStacks[i] = ItemStack.loadItemStackFromNBT(tag[i]); + } else if (enchList != null && enchList.tagCount() > i - size) { + inventoryStacks[i] = new ItemStack(Items.enchanted_book); + inventoryStacks[i].setTagCompound(new NBTTagCompound()); + NBTTagList list = new NBTTagList(); + list.appendTag(enchList.getCompoundTagAt(i - size)); + inventoryStacks[i].getTagCompound().setTag("StoredEnchantments", list); + } + } // if (compound.hasKey("ench")) // { @@ -251,8 +220,8 @@ public class InventoryTool implements IInventory { // } // } - if (compound.hasKey("ench") && compound.getTagList("ench", 10).tagCount() == 0) compound.removeTag("ench"); + if (compound.hasKey("ench") && compound.getTagList("ench", 10).tagCount() == 0) compound.removeTag("ench"); - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/inventory/SlotChargable.java b/src/main/java/com/brandon3055/draconicevolution/common/inventory/SlotChargable.java index aaaa8fe5..0578c168 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/inventory/SlotChargable.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/inventory/SlotChargable.java @@ -9,30 +9,27 @@ import net.minecraft.item.ItemStack; public class SlotChargable extends Slot { - public SlotChargable(IInventory inventory, int id, int x, int y) { - super(inventory, id, x, y); + public SlotChargable(IInventory inventory, int id, int x, int y) { + super(inventory, id, x, y); - } + } - @Override - public boolean isItemValid(ItemStack stack) - { - if (super.isItemValid(stack)) - { - return stack != null && stack.getItem() instanceof IEnergyContainerItem; - } - return false; - } - - @Override - public int getSlotStackLimit() - { - return 1; - } + @Override + public boolean isItemValid(ItemStack stack) { + if (super.isItemValid(stack)) { + return stack != null && stack.getItem() instanceof IEnergyContainerItem; + } + return false; + } + + @Override + public int getSlotStackLimit() { + return 1; + } - @Override - public boolean func_111238_b() { - return !((TileEnergyInfuser)inventory).running; - } + @Override + public boolean func_111238_b() { + return !((TileEnergyInfuser) inventory).running; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/inventory/SlotItemValid.java b/src/main/java/com/brandon3055/draconicevolution/common/inventory/SlotItemValid.java index 80d264b8..a29259b3 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/inventory/SlotItemValid.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/inventory/SlotItemValid.java @@ -16,63 +16,52 @@ import cpw.mods.fml.common.registry.GameRegistry; public class SlotItemValid extends Slot { - private Item item; - private boolean fuel = false; + private Item item; + private boolean fuel = false; - public SlotItemValid(IInventory inventory, int id, int x, int y, Item validItem) { - super(inventory, id, x, y); + public SlotItemValid(IInventory inventory, int id, int x, int y, Item validItem) { + super(inventory, id, x, y); - this.item = validItem; - } - - public SlotItemValid(IInventory inventory, int id, int x, int y, boolean fuel) { - super(inventory, id, x, y); + this.item = validItem; + } - this.fuel = fuel; - } + public SlotItemValid(IInventory inventory, int id, int x, int y, boolean fuel) { + super(inventory, id, x, y); - @Override - public boolean isItemValid(ItemStack stack) - { - if (fuel) - return getItemBurnTime(stack) > 0; - else - return stack.isItemEqual(new ItemStack(item)); - } - - public static int getItemBurnTime(ItemStack stack) - { - if (stack == null) - { + this.fuel = fuel; + } + + @Override + public boolean isItemValid(ItemStack stack) { + if (fuel) return getItemBurnTime(stack) > 0; + else return stack.isItemEqual(new ItemStack(item)); + } + + public static int getItemBurnTime(ItemStack stack) { + if (stack == null) { return 0; - } - else - { + } else { Item item = stack.getItem(); - if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) - { + if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) { Block block = Block.getBlockFromItem(item); - if (block == Blocks.wooden_slab) - { + if (block == Blocks.wooden_slab) { return 150; } - if (block.getMaterial() == Material.wood) - { + if (block.getMaterial() == Material.wood) { return 300; } - if (block == Blocks.coal_block) - { + if (block == Blocks.coal_block) { return 16000; } } - if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return 200; - if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return 200; - if (item instanceof ItemHoe && ((ItemHoe)item).getToolMaterialName().equals("WOOD")) return 200; + if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD")) return 200; + if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD")) return 200; + if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD")) return 200; if (item == Items.stick) return 100; if (item == Items.coal) return 1600; if (item == Items.lava_bucket) return 20000; @@ -81,7 +70,7 @@ public class SlotItemValid extends Slot { return GameRegistry.getFuelValue(stack); } } - /* + /* @Override public IIcon getBackgroundIconIndex() { diff --git a/src/main/java/com/brandon3055/draconicevolution/common/inventory/SlotOpaqueBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/inventory/SlotOpaqueBlock.java index 5d0f00f1..cda99b7b 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/inventory/SlotOpaqueBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/inventory/SlotOpaqueBlock.java @@ -8,27 +8,24 @@ import net.minecraft.item.ItemStack; public class SlotOpaqueBlock extends Slot { - public SlotOpaqueBlock(IInventory inventory, int id, int x, int y) { - super(inventory, id, x, y); + public SlotOpaqueBlock(IInventory inventory, int id, int x, int y) { + super(inventory, id, x, y); + + } + + @Override + public boolean isItemValid(ItemStack stack) { + if (super.isItemValid(stack)) { + Block block = Block.getBlockFromItem(stack.getItem()); + return block.isOpaqueCube() && block.renderAsNormalBlock(); + } + return false; + } + + @Override + public int getSlotStackLimit() { + return 1; + } - } - @Override - public boolean isItemValid(ItemStack stack) - { - if (super.isItemValid(stack)) - { - Block block = Block.getBlockFromItem(stack.getItem()); - return block.isOpaqueCube() && block.renderAsNormalBlock(); - } - return false; - } - - @Override - public int getSlotStackLimit() - { - return 1; - } - - } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/inventory/SlotOutput.java b/src/main/java/com/brandon3055/draconicevolution/common/inventory/SlotOutput.java index 5219f18b..d40f7edc 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/inventory/SlotOutput.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/inventory/SlotOutput.java @@ -8,19 +8,17 @@ import net.minecraft.item.ItemStack; * Created by Brandon on 11/10/2014. */ public class SlotOutput extends Slot { - public SlotOutput(IInventory inventory, int id, int x, int y) { - super(inventory, id, x, y); - } + public SlotOutput(IInventory inventory, int id, int x, int y) { + super(inventory, id, x, y); + } - @Override - public boolean isItemValid(ItemStack stack) - { - return false; - } + @Override + public boolean isItemValid(ItemStack stack) { + return false; + } - @Override - public int getSlotStackLimit() - { - return 64; - } + @Override + public int getSlotStackLimit() { + return 64; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/AwakenedCore.java b/src/main/java/com/brandon3055/draconicevolution/common/items/AwakenedCore.java index 78c15a7d..6c3d75a2 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/AwakenedCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/AwakenedCore.java @@ -6,14 +6,14 @@ import com.brandon3055.draconicevolution.common.lib.Strings; import net.minecraft.item.ItemStack; public class AwakenedCore extends ItemDE { - public AwakenedCore() { - this.setUnlocalizedName(Strings.draconicCompoundName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModItems.register(this); - } + public AwakenedCore() { + this.setUnlocalizedName(Strings.draconicCompoundName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + ModItems.register(this); + } - @Override - public boolean hasEffect(ItemStack par1ItemStack, int pass) { - return true; - } + @Override + public boolean hasEffect(ItemStack par1ItemStack, int pass) { + return true; + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/ChaosFragment.java b/src/main/java/com/brandon3055/draconicevolution/common/items/ChaosFragment.java index a2fa6442..e5c65e32 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/ChaosFragment.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/ChaosFragment.java @@ -12,22 +12,22 @@ import java.util.List; */ public class ChaosFragment extends ItemDE { - public ChaosFragment() { - this.setUnlocalizedName("chaosFragment"); - this.setHasSubtypes(true); + public ChaosFragment() { + this.setUnlocalizedName("chaosFragment"); + this.setHasSubtypes(true); - ModItems.register(this); - } + ModItems.register(this); + } - @Override - public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { - list.add(new ItemStack(item, 1, 0)); - list.add(new ItemStack(item, 1, 1)); - list.add(new ItemStack(item, 1, 2)); - } + @Override + public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { + list.add(new ItemStack(item, 1, 0)); + list.add(new ItemStack(item, 1, 1)); + list.add(new ItemStack(item, 1, 2)); + } - @Override - public String getUnlocalizedName(ItemStack itemStack) { - return super.getUnlocalizedName(itemStack)+itemStack.getItemDamage(); - } + @Override + public String getUnlocalizedName(ItemStack itemStack) { + return super.getUnlocalizedName(itemStack) + itemStack.getItemDamage(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/ChaosShard.java b/src/main/java/com/brandon3055/draconicevolution/common/items/ChaosShard.java index 07ccece4..1668c165 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/ChaosShard.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/ChaosShard.java @@ -12,22 +12,23 @@ import net.minecraft.world.World; * Created by brandon3055 on 1/10/2015. */ public class ChaosShard extends ItemDE { - public ChaosShard(){ - this.setUnlocalizedName("chaosShard"); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModItems.register(this); - } + public ChaosShard() { + this.setUnlocalizedName("chaosShard"); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + ModItems.register(this); + } - @Override - public void registerIcons(IIconRegister iconRegister) {} + @Override + public void registerIcons(IIconRegister iconRegister) { + } - @Override - public boolean hasCustomEntity(ItemStack stack) { - return true; - } + @Override + public boolean hasCustomEntity(ItemStack stack) { + return true; + } - @Override - public Entity createEntity(World world, Entity location, ItemStack itemstack) { - return new EntityPersistentItem(world, location, itemstack); - } + @Override + public Entity createEntity(World world, Entity location, ItemStack itemstack) { + return new EntityPersistentItem(world, location, itemstack); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/ChaoticCore.java b/src/main/java/com/brandon3055/draconicevolution/common/items/ChaoticCore.java index 84527a0d..2da607da 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/ChaoticCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/ChaoticCore.java @@ -8,14 +8,14 @@ import net.minecraft.item.ItemStack; * Created by brandon3055 on 2/10/2015. */ public class ChaoticCore extends ItemDE { - public ChaoticCore() { - this.setUnlocalizedName("chaoticCore"); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModItems.register(this); - } + public ChaoticCore() { + this.setUnlocalizedName("chaoticCore"); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + ModItems.register(this); + } - @Override - public boolean hasEffect(ItemStack par1ItemStack, int pass) { - return true; - } + @Override + public boolean hasEffect(ItemStack par1ItemStack, int pass) { + return true; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/DezilsMarshmallow.java b/src/main/java/com/brandon3055/draconicevolution/common/items/DezilsMarshmallow.java index 12cbdcd5..967ff4c1 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/DezilsMarshmallow.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/DezilsMarshmallow.java @@ -14,32 +14,32 @@ import net.minecraft.world.World; * Created by Brandon on 4/15/2015. */ public class DezilsMarshmallow extends ItemFood { - public DezilsMarshmallow() { - super(100, 100F, true); - this.setUnlocalizedName("draconicevolution:dezilsMarshmallow"); - this.setAlwaysEdible(); - GameRegistry.registerItem(this, "dezilsMarshmallow"); - } + public DezilsMarshmallow() { + super(100, 100F, true); + this.setUnlocalizedName("draconicevolution:dezilsMarshmallow"); + this.setAlwaysEdible(); + GameRegistry.registerItem(this, "dezilsMarshmallow"); + } - @Override - public boolean hasEffect(ItemStack par1ItemStack, int pass) { - return true; - } + @Override + public boolean hasEffect(ItemStack par1ItemStack, int pass) { + return true; + } - @Override - protected void onFoodEaten(ItemStack p_77849_1_, World p_77849_2_, EntityPlayer player) { - player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 20*60*10, 5)); - player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 20*60*10, 5)); - player.addPotionEffect(new PotionEffect(Potion.jump.id, 20*60*10, 5)); - player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 20*60*10, 5)); - player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 20*60*10, 4)); - player.addPotionEffect(new PotionEffect(Potion.resistance.id, 20*60*10, 4)); - player.addPotionEffect(new PotionEffect(Potion.waterBreathing.id, 20*60*10, 0)); - super.onFoodEaten(p_77849_1_, p_77849_2_, player); - } + @Override + protected void onFoodEaten(ItemStack p_77849_1_, World p_77849_2_, EntityPlayer player) { + player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 20 * 60 * 10, 5)); + player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 20 * 60 * 10, 5)); + player.addPotionEffect(new PotionEffect(Potion.jump.id, 20 * 60 * 10, 5)); + player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 20 * 60 * 10, 5)); + player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 20 * 60 * 10, 4)); + player.addPotionEffect(new PotionEffect(Potion.resistance.id, 20 * 60 * 10, 4)); + player.addPotionEffect(new PotionEffect(Potion.waterBreathing.id, 20 * 60 * 10, 0)); + super.onFoodEaten(p_77849_1_, p_77849_2_, player); + } - @Override - public void registerIcons(IIconRegister iconRegister) { - itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "dezilsMarshmallow"); - } + @Override + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "dezilsMarshmallow"); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicCore.java b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicCore.java index c66de656..baea4f9b 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicCore.java @@ -19,41 +19,40 @@ import net.minecraft.world.World; import java.util.List; public class DraconicCore extends ItemDE { - public DraconicCore() { - this.setUnlocalizedName(Strings.draconicCoreName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModItems.register(this); - } + public DraconicCore() { + this.setUnlocalizedName(Strings.draconicCoreName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + ModItems.register(this); + } - @SuppressWarnings("unchecked") - @SideOnly(Side.CLIENT) - @Override - public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { - par3List.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.draconicCore.txt")); - par3List.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.draconicCore1.txt")); - } + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + par3List.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.draconicCore.txt")); + par3List.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.draconicCore1.txt")); + } - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { - if (world.getBlock(x, y, z) == Blocks.mob_spawner) - { - TileEntityMobSpawner oldSpawner = world.getTileEntity(x, y, z) instanceof TileEntityMobSpawner ? (TileEntityMobSpawner)world.getTileEntity(x, y, z) : null; - if (oldSpawner == null) return false; - String mobName = oldSpawner.func_145881_a().getEntityNameToSpawn(); - LogHelper.info(mobName); + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { + if (world.getBlock(x, y, z) == Blocks.mob_spawner) { + TileEntityMobSpawner oldSpawner = world.getTileEntity(x, y, z) instanceof TileEntityMobSpawner ? (TileEntityMobSpawner) world.getTileEntity(x, y, z) : null; + if (oldSpawner == null) return false; + String mobName = oldSpawner.func_145881_a().getEntityNameToSpawn(); + LogHelper.info(mobName); - world.setBlock(x, y, z, ModBlocks.customSpawner); - TileCustomSpawner newSpawner = world.getTileEntity(x, y, z) instanceof TileCustomSpawner ? (TileCustomSpawner)world.getTileEntity(x, y, z) : null; - if (newSpawner != null) { - newSpawner.getBaseLogic().entityName = mobName; - newSpawner.isSetToSpawn = true; - world.markBlockForUpdate(x, y, z); - } - LogHelper.info(newSpawner.getBaseLogic().entityName); + world.setBlock(x, y, z, ModBlocks.customSpawner); + TileCustomSpawner newSpawner = world.getTileEntity(x, y, z) instanceof TileCustomSpawner ? (TileCustomSpawner) world.getTileEntity(x, y, z) : null; + if (newSpawner != null) { + newSpawner.getBaseLogic().entityName = mobName; + newSpawner.isSetToSpawn = true; + world.markBlockForUpdate(x, y, z); + } + LogHelper.info(newSpawner.getBaseLogic().entityName); - stack.splitStack(1); - return true; - } - return false; - } + stack.splitStack(1); + return true; + } + return false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicIngot.java b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicIngot.java index 406df654..0c93b829 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicIngot.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicIngot.java @@ -8,9 +8,9 @@ import com.brandon3055.draconicevolution.common.lib.Strings; * Created by Brandon on 21/11/2014. */ public class DraconicIngot extends ItemDE { - public DraconicIngot() { - this.setUnlocalizedName(Strings.draconicIngotName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModItems.register(this); - } + public DraconicIngot() { + this.setUnlocalizedName(Strings.draconicIngotName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + ModItems.register(this); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumBlend.java b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumBlend.java index 6268fa66..257a7f06 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumBlend.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumBlend.java @@ -5,10 +5,10 @@ import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.lib.Strings; public class DraconiumBlend extends ItemDE { - public DraconiumBlend() { - this.setUnlocalizedName(Strings.draconiumBlendName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModItems.register(this); - } + public DraconiumBlend() { + this.setUnlocalizedName(Strings.draconiumBlendName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + ModItems.register(this); + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumDust.java b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumDust.java index 6640d7aa..dbc35466 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumDust.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumDust.java @@ -5,10 +5,10 @@ import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.lib.Strings; public class DraconiumDust extends ItemDE { - public DraconiumDust() { - this.setUnlocalizedName(Strings.draconiumDustName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModItems.register(this); - } + public DraconiumDust() { + this.setUnlocalizedName(Strings.draconiumDustName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + ModItems.register(this); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumEnergyCore.java b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumEnergyCore.java index 5f7cb6d8..c42e4a6f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumEnergyCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumEnergyCore.java @@ -17,39 +17,39 @@ import java.util.List; * Created by Brandon on 24/11/2014. */ public class DraconiumEnergyCore extends ItemDE { - IIcon[] icons = new IIcon[2]; - public DraconiumEnergyCore() - { - this.setUnlocalizedName(Strings.draconiumEnergyCoreName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setHasSubtypes(true); - ModItems.register(this); - } + IIcon[] icons = new IIcon[2]; - @SideOnly(Side.CLIENT) - @Override - public void registerIcons(IIconRegister iconRegister) { - icons[0] = iconRegister.registerIcon(getUnwrappedUnlocalizedName(super.getUnlocalizedName())+0); - icons[1] = iconRegister.registerIcon(getUnwrappedUnlocalizedName(super.getUnlocalizedName())+1); - } + public DraconiumEnergyCore() { + this.setUnlocalizedName(Strings.draconiumEnergyCoreName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setHasSubtypes(true); + ModItems.register(this); + } - @SideOnly(Side.CLIENT) - @Override - public IIcon getIconFromDamage(int damage) { - return icons[damage]; - } + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister iconRegister) { + icons[0] = iconRegister.registerIcon(getUnwrappedUnlocalizedName(super.getUnlocalizedName()) + 0); + icons[1] = iconRegister.registerIcon(getUnwrappedUnlocalizedName(super.getUnlocalizedName()) + 1); + } - @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - list.add(new ItemStack(item, 1, 0)); - list.add(new ItemStack(item, 1, 1)); + @SideOnly(Side.CLIENT) + @Override + public IIcon getIconFromDamage(int damage) { + return icons[damage]; + } - } + @SideOnly(Side.CLIENT) + @SuppressWarnings("unchecked") + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + list.add(new ItemStack(item, 1, 0)); + list.add(new ItemStack(item, 1, 1)); - @Override - public String getUnlocalizedName(ItemStack itemStack) { - return super.getUnlocalizedName(itemStack)+itemStack.getItemDamage(); - } + } + + @Override + public String getUnlocalizedName(ItemStack itemStack) { + return super.getUnlocalizedName(itemStack) + itemStack.getItemDamage(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumIngot.java b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumIngot.java index 739ba1e8..bb762f56 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumIngot.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumIngot.java @@ -5,9 +5,9 @@ import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.lib.Strings; public class DraconiumIngot extends ItemDE { - public DraconiumIngot() { - this.setUnlocalizedName(Strings.draconiumIngotName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModItems.register(this); - } + public DraconiumIngot() { + this.setUnlocalizedName(Strings.draconiumIngotName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + ModItems.register(this); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/DragonHeart.java b/src/main/java/com/brandon3055/draconicevolution/common/items/DragonHeart.java index 92374724..26da03e9 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/DragonHeart.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/DragonHeart.java @@ -10,20 +10,20 @@ import net.minecraft.world.World; public class DragonHeart extends ItemDE { - public DragonHeart() { - this.setUnlocalizedName(Strings.dragonHeartName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setMaxStackSize(1); - ModItems.register(this); - } + public DragonHeart() { + this.setUnlocalizedName(Strings.dragonHeartName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setMaxStackSize(1); + ModItems.register(this); + } - @Override - public boolean hasCustomEntity(ItemStack stack) { - return true; - } + @Override + public boolean hasCustomEntity(ItemStack stack) { + return true; + } - @Override - public Entity createEntity(World world, Entity location, ItemStack itemstack) { - return new EntityPersistentItem(world, location, itemstack); - } + @Override + public Entity createEntity(World world, Entity location, ItemStack itemstack) { + return new EntityPersistentItem(world, location, itemstack); + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/InfoTablet.java b/src/main/java/com/brandon3055/draconicevolution/common/items/InfoTablet.java index 273d7cb5..856a86eb 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/InfoTablet.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/InfoTablet.java @@ -16,22 +16,22 @@ import net.minecraft.world.World; */ public class InfoTablet extends ItemDE { - public InfoTablet() { - this.setUnlocalizedName(Strings.infoTabletName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setMaxStackSize(1); - ModItems.register(this); - //GameRegistry.registerItem(this, Strings.infoTabletName); - } + public InfoTablet() { + this.setUnlocalizedName(Strings.infoTabletName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setMaxStackSize(1); + ModItems.register(this); + //GameRegistry.registerItem(this, Strings.infoTabletName); + } - @Override - public void registerIcons(IIconRegister iconRegister) { - itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX+"stone_tablet"); - } + @Override + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "stone_tablet"); + } - @Override - public ItemStack onItemRightClick(ItemStack p_77659_1_, World world, EntityPlayer player) { - FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_MANUAL, world, (int) player.posX, (int) player.posY, (int) player.posZ); - return super.onItemRightClick(p_77659_1_, world, player); - } + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World world, EntityPlayer player) { + FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_MANUAL, world, (int) player.posX, (int) player.posY, (int) player.posZ); + return super.onItemRightClick(p_77659_1_, world, player); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/ItemDE.java b/src/main/java/com/brandon3055/draconicevolution/common/items/ItemDE.java index d290b68f..25c7a90f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/ItemDE.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/ItemDE.java @@ -1,4 +1,3 @@ - package com.brandon3055.draconicevolution.common.items; import com.brandon3055.draconicevolution.common.lib.References; @@ -9,28 +8,28 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class ItemDE extends Item { - public String getUnwrappedUnlocalizedName(final String unlocalizedName){ - return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); - } + public String getUnwrappedUnlocalizedName(final String unlocalizedName) { + return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); + } - @Override - public String getUnlocalizedName(){ - return String.format("item.%s%s", References.MODID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); - } + @Override + public String getUnlocalizedName() { + return String.format("item.%s%s", References.MODID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + } - @Override - public String getUnlocalizedName(final ItemStack itemStack){ - return getUnlocalizedName(); - } + @Override + public String getUnlocalizedName(final ItemStack itemStack) { + return getUnlocalizedName(); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(final IIconRegister iconRegister){ - this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + getUnwrappedUnlocalizedName(super.getUnlocalizedName())); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister iconRegister) { + this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + } - @Override - public boolean hasCustomEntity(ItemStack stack) { - return false; - } + @Override + public boolean hasCustomEntity(ItemStack stack) { + return false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/Key.java b/src/main/java/com/brandon3055/draconicevolution/common/items/Key.java index f12f52ff..f42c7c30 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/Key.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/Key.java @@ -17,46 +17,46 @@ import java.util.List; * Created by Brandon on 27/08/2014. */ public class Key extends ItemDE { - public Key() { - this.setUnlocalizedName(Strings.keyName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setHasSubtypes(true); - this.setMaxStackSize(1); - ModItems.register(this); - } + public Key() { + this.setUnlocalizedName(Strings.keyName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setHasSubtypes(true); + this.setMaxStackSize(1); + ModItems.register(this); + } - @SuppressWarnings("all") - @SideOnly(Side.CLIENT) - @Override - public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { - list.add(new ItemStack(item, 1, 0)); - list.add(new ItemStack(item, 1, 1)); - } + @SuppressWarnings("all") + @SideOnly(Side.CLIENT) + @Override + public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { + list.add(new ItemStack(item, 1, 0)); + list.add(new ItemStack(item, 1, 1)); + } - @SuppressWarnings("all") - @Override - public void addInformation(ItemStack key, EntityPlayer player, List list, boolean par4) { - if (!player.capabilities.isCreativeMode) return; - if (key.getItemDamage() == 1){ - list.add("Creative Master Key"); - return; - } + @SuppressWarnings("all") + @Override + public void addInformation(ItemStack key, EntityPlayer player, List list, boolean par4) { + if (!player.capabilities.isCreativeMode) return; + if (key.getItemDamage() == 1) { + list.add("Creative Master Key"); + return; + } - int keyCode = ItemNBTHelper.getInteger(key, "KeyCode", 0); - list.add(keyCode == 0 ? "Un-Bound" : "Key Code: " + String.valueOf(keyCode)); + int keyCode = ItemNBTHelper.getInteger(key, "KeyCode", 0); + list.add(keyCode == 0 ? "Un-Bound" : "Key Code: " + String.valueOf(keyCode)); - if (keyCode != 0){ - list.add("Linked to {X:"+ItemNBTHelper.getInteger(key, "X", 0)+" Y:"+ItemNBTHelper.getInteger(key, "Y", 0)+" X:"+ItemNBTHelper.getInteger(key, "Z", 0)+"}"); - if (ItemNBTHelper.getInteger(key, "LockCount", 0) == 0) return; - for (int i = 1; i <= ItemNBTHelper.getInteger(key, "LockCount", 0); i++){ - list.add("Linked to {X:"+ItemNBTHelper.getInteger(key, "X_" + i, 0)+" Y:"+ItemNBTHelper.getInteger(key, "Y_" + i, 0)+" X:"+ItemNBTHelper.getInteger(key, "Z_" + i, 0)+"}"); - } - } - } + if (keyCode != 0) { + list.add("Linked to {X:" + ItemNBTHelper.getInteger(key, "X", 0) + " Y:" + ItemNBTHelper.getInteger(key, "Y", 0) + " X:" + ItemNBTHelper.getInteger(key, "Z", 0) + "}"); + if (ItemNBTHelper.getInteger(key, "LockCount", 0) == 0) return; + for (int i = 1; i <= ItemNBTHelper.getInteger(key, "LockCount", 0); i++) { + list.add("Linked to {X:" + ItemNBTHelper.getInteger(key, "X_" + i, 0) + " Y:" + ItemNBTHelper.getInteger(key, "Y_" + i, 0) + " X:" + ItemNBTHelper.getInteger(key, "Z_" + i, 0) + "}"); + } + } + } - @Override - public boolean hasEffect(ItemStack stack, int pass) { - if (stack.getItemDamage() == 1) return true; - return ItemNBTHelper.getInteger(stack, "KeyCode", 0) != 0; - } + @Override + public boolean hasEffect(ItemStack stack, int pass) { + if (stack.getItemDamage() == 1) return true; + return ItemNBTHelper.getInteger(stack, "KeyCode", 0) != 0; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/MobSoul.java b/src/main/java/com/brandon3055/draconicevolution/common/items/MobSoul.java index 8b893545..22a70604 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/MobSoul.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/MobSoul.java @@ -21,48 +21,47 @@ import java.util.List; * Created by Brandon on 7/07/2014. */ public class MobSoul extends ItemDE { - public MobSoul() { - this.setUnlocalizedName(Strings.MobSoulName); - ModItems.register(this); - } + public MobSoul() { + this.setUnlocalizedName(Strings.MobSoulName); + ModItems.register(this); + } - @Override - public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) { - String name = ItemNBTHelper.getString(stack, "Name", "Pig"); - list.add("" + EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.mobSoul1.txt")); - list.add("" + EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.mobSoul2.txt")); - list.add("" + EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.mobSoul3.txt")); - list.add("" + EnumChatFormatting.DARK_PURPLE + name); - } + @Override + public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) { + String name = ItemNBTHelper.getString(stack, "Name", "Pig"); + list.add("" + EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.mobSoul1.txt")); + list.add("" + EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.mobSoul2.txt")); + list.add("" + EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.mobSoul3.txt")); + list.add("" + EnumChatFormatting.DARK_PURPLE + name); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister iconRegister) { + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { - } + } - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float p_77648_8_, float p_77648_9_, float p_77648_10_) { - if (!player.isSneaking()) return false; - String name = ItemNBTHelper.getString(stack, "Name", "Pig"); - Entity entity = EntityList.createEntityByName(name, world); - double sX = x + ForgeDirection.getOrientation(side).offsetX + 0.5; - double sY = y + ForgeDirection.getOrientation(side).offsetY + 0.5; - double sZ = z + ForgeDirection.getOrientation(side).offsetZ + 0.5; - if (entity == null) { - LogHelper.error("Mob Soul bound entity = null"); - return false; - } - entity.setLocationAndAngles(sX, sY, sZ, player.rotationYaw, 0F); + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float p_77648_8_, float p_77648_9_, float p_77648_10_) { + if (!player.isSneaking()) return false; + String name = ItemNBTHelper.getString(stack, "Name", "Pig"); + Entity entity = EntityList.createEntityByName(name, world); + double sX = x + ForgeDirection.getOrientation(side).offsetX + 0.5; + double sY = y + ForgeDirection.getOrientation(side).offsetY + 0.5; + double sZ = z + ForgeDirection.getOrientation(side).offsetZ + 0.5; + if (entity == null) { + LogHelper.error("Mob Soul bound entity = null"); + return false; + } + entity.setLocationAndAngles(sX, sY, sZ, player.rotationYaw, 0F); - if (entity instanceof EntityLivingBase && !world.isRemote) { - ((EntityLiving) entity).onSpawnWithEgg((IEntityLivingData) null); - world.spawnEntityInWorld(entity); - if (!player.capabilities.isCreativeMode) - { - stack.stackSize--; - } - } - return true; - } + if (entity instanceof EntityLivingBase && !world.isRemote) { + ((EntityLiving) entity).onSpawnWithEgg((IEntityLivingData) null); + world.spawnEntityInWorld(entity); + if (!player.capabilities.isCreativeMode) { + stack.stackSize--; + } + } + return true; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/Nugget.java b/src/main/java/com/brandon3055/draconicevolution/common/items/Nugget.java index a955cac6..8c15b6c2 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/Nugget.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/Nugget.java @@ -15,36 +15,36 @@ import java.util.List; * Created by brandon3055 on 8/10/2015. */ public class Nugget extends ItemDE { - private IIcon draconium; - private IIcon awakened; + private IIcon draconium; + private IIcon awakened; - public Nugget() { - this.setUnlocalizedName("nugget"); - this.setHasSubtypes(true); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); + public Nugget() { + this.setUnlocalizedName("nugget"); + this.setHasSubtypes(true); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModItems.register(this); - } + ModItems.register(this); + } - @Override - public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { - list.add(new ItemStack(item, 1, 0)); - list.add(new ItemStack(item, 1, 1)); - } + @Override + public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { + list.add(new ItemStack(item, 1, 0)); + list.add(new ItemStack(item, 1, 1)); + } - @Override - public String getUnlocalizedName(ItemStack itemStack) { - return super.getUnlocalizedName(itemStack) + (itemStack.getItemDamage() == 0 ? ".draconium" : ".awakened"); - } + @Override + public String getUnlocalizedName(ItemStack itemStack) { + return super.getUnlocalizedName(itemStack) + (itemStack.getItemDamage() == 0 ? ".draconium" : ".awakened"); + } - @Override - public void registerIcons(IIconRegister iconRegister) { - draconium = iconRegister.registerIcon(References.RESOURCESPREFIX+"nuggetDraconium"); - awakened = iconRegister.registerIcon(References.RESOURCESPREFIX+"nuggetAwakened"); - } + @Override + public void registerIcons(IIconRegister iconRegister) { + draconium = iconRegister.registerIcon(References.RESOURCESPREFIX + "nuggetDraconium"); + awakened = iconRegister.registerIcon(References.RESOURCESPREFIX + "nuggetAwakened"); + } - @Override - public IIcon getIconFromDamage(int dmg) { - return dmg == 0 ? draconium : awakened; - } + @Override + public IIcon getIconFromDamage(int dmg) { + return dmg == 0 ? draconium : awakened; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/ReactorStabiliserPart.java b/src/main/java/com/brandon3055/draconicevolution/common/items/ReactorStabiliserPart.java index e64cff38..dd01568a 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/ReactorStabiliserPart.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/ReactorStabiliserPart.java @@ -16,32 +16,34 @@ import java.util.Map; */ public class ReactorStabiliserPart extends ItemDE { - public static final Map parts = new HashMap(){{ - put(0, "frame"); - put(1, "rotorInner"); - put(2, "rotorOuter"); - put(3, "rotorAssembly"); - put(4, "stabilizerRing"); - }}; + public static final Map parts = new HashMap() {{ + put(0, "frame"); + put(1, "rotorInner"); + put(2, "rotorOuter"); + put(3, "rotorAssembly"); + put(4, "stabilizerRing"); + }}; - public ReactorStabiliserPart(){ - this.setUnlocalizedName("reactorCraftingPart"); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setHasSubtypes(true); - ModItems.register(this); - } + public ReactorStabiliserPart() { + this.setUnlocalizedName("reactorCraftingPart"); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setHasSubtypes(true); + ModItems.register(this); + } - @Override - public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { - for (Integer i : parts.keySet()) list.add(new ItemStack(item, 1, i)); - } + @Override + public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { + for (Integer i : parts.keySet()) list.add(new ItemStack(item, 1, i)); + } - @Override - public String getUnlocalizedName(ItemStack itemStack) { - if (parts.containsKey(itemStack.getItemDamage())) return super.getUnlocalizedName(itemStack) + "." + parts.get(itemStack.getItemDamage()); - else return super.getUnlocalizedName(itemStack); - } + @Override + public String getUnlocalizedName(ItemStack itemStack) { + if (parts.containsKey(itemStack.getItemDamage())) + return super.getUnlocalizedName(itemStack) + "." + parts.get(itemStack.getItemDamage()); + else return super.getUnlocalizedName(itemStack); + } - @Override - public void registerIcons(IIconRegister iconRegister) {} + @Override + public void registerIcons(IIconRegister iconRegister) { + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/SunFocus.java b/src/main/java/com/brandon3055/draconicevolution/common/items/SunFocus.java index 3eeab08b..c7f06073 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/SunFocus.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/SunFocus.java @@ -4,10 +4,10 @@ import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.lib.Strings; public class SunFocus extends ItemDE { - public SunFocus() { - this.setUnlocalizedName(Strings.sunFocusName); - //this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModItems.register(this); - } + public SunFocus() { + this.setUnlocalizedName(Strings.sunFocusName); + //this.setCreativeTab(DraconicEvolution.tabBlocksItems); + ModItems.register(this); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/Tclogo.java b/src/main/java/com/brandon3055/draconicevolution/common/items/Tclogo.java index fcedda60..a41d2a7a 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/Tclogo.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/Tclogo.java @@ -23,23 +23,20 @@ import net.minecraft.world.World; import java.util.List; public class Tclogo extends ItemDE { - public Tclogo() { - this.setUnlocalizedName(Strings.tclogoName); - //this.setCreativeTab(draconicevolution.getCreativeTab()); - ModItems.register(this); - } + public Tclogo() { + this.setUnlocalizedName(Strings.tclogoName); + //this.setCreativeTab(draconicevolution.getCreativeTab()); + ModItems.register(this); + } + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 100; + } - @Override - public int getMaxItemUseDuration(ItemStack par1ItemStack) - { - return 100; - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) - { + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { // if (entity instanceof EntityPlayerMP && !entity.onGround) { // //for (int i = 0; i < 10; i++) // EntityPlayer player = (EntityPlayer)entity; @@ -57,12 +54,11 @@ public class Tclogo extends ItemDE { // else player.motionX = 0; - // ((EntityPlayerMP) entity).playerNetServerHandler.setPlayerLocation(entity.posX + 10, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch); // ((EntityPlayerMP) entity).addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 10, 1000)); // if (entity.posX > 500) ((EntityPlayerMP) entity).destroyCurrentEquippedItem(); // } - /* + /* //if (entity.isCollidedHorizontally)// && !world.isRemote) //entity.setLocationAndAngles(entity.posX+30D, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);; /* @@ -88,54 +84,51 @@ public class Tclogo extends ItemDE { } } }*/ - } - - @Override - public EnumAction getItemUseAction(ItemStack par1ItemStack) - { - return EnumAction.block; - } - - @Override - public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) - { + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.block; + } + + @Override + public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { return par1ItemStack; } - @SideOnly(Side.CLIENT) - private void particle(World world, EntityPlayer player){ - MovingObjectPosition mop = ToolHandler.raytraceFromEntity(world, player, 10000); - if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) FMLClientHandler.instance().getClient().effectRenderer.addEffect(new Particles.ReactorExplosionParticle(world, mop.blockX, mop.blockY, mop.blockZ, 100)); + @SideOnly(Side.CLIENT) + private void particle(World world, EntityPlayer player) { + MovingObjectPosition mop = ToolHandler.raytraceFromEntity(world, player, 10000); + if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + FMLClientHandler.instance().getClient().effectRenderer.addEffect(new Particles.ReactorExplosionParticle(world, mop.blockX, mop.blockY, mop.blockZ, 100)); - } + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) - { + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - //int meta = Integer.parseInt()); - LogHelper.info("21=vserfegz".substring(0, "21=vserfegz".indexOf("="))); + //int meta = Integer.parseInt()); + LogHelper.info("21=vserfegz".substring(0, "21=vserfegz".indexOf("="))); - try - { - if (!world.isRemote) { - //ExtendedPlayer.get(player).setSpawnCount(6); - LogHelper.info(ExtendedPlayer.get(player).getSpawnCount()); - // player.getEntityData().setTag("Tag", new NBTTagCompound()); - } else LogHelper.info(ExtendedPlayer.get(player).getSpawnCount()); - //LogHelper.info(FMLCommonHandler.instance().getMinecraftServerInstance().func_152358_ax().func_152655_a(player.getCommandSenderName()).getId()); - //LogHelper.info(player.getUniqueID()); - //LogHelper.info(UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getCommandSenderName()).getBytes(Charsets.UTF_8))); - //LogHelper.info(UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getCommandSenderName()).getBytes(Charsets.UTF_8)).equals(player.getUniqueID())); - if (FMLCommonHandler.instance().getMinecraftServerInstance() instanceof IntegratedServer){ - // LogHelper.info(FMLClientHandler.instance().getClient().getSession().getToken()); - // LogHelper.info(((YggdrasilMinecraftSessionService)FMLCommonHandler.instance().getMinecraftServerInstance().func_147130_as()).getAuthenticationService().); - } - } - catch (Exception e){ - e.printStackTrace(); - } + try { + if (!world.isRemote) { + //ExtendedPlayer.get(player).setSpawnCount(6); + LogHelper.info(ExtendedPlayer.get(player).getSpawnCount()); + // player.getEntityData().setTag("Tag", new NBTTagCompound()); + } else LogHelper.info(ExtendedPlayer.get(player).getSpawnCount()); + //LogHelper.info(FMLCommonHandler.instance().getMinecraftServerInstance().func_152358_ax().func_152655_a(player.getCommandSenderName()).getId()); + //LogHelper.info(player.getUniqueID()); + //LogHelper.info(UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getCommandSenderName()).getBytes(Charsets.UTF_8))); + //LogHelper.info(UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getCommandSenderName()).getBytes(Charsets.UTF_8)).equals(player.getUniqueID())); + if (FMLCommonHandler.instance().getMinecraftServerInstance() instanceof IntegratedServer) { + // LogHelper.info(FMLClientHandler.instance().getClient().getSession().getToken()); + // LogHelper.info(((YggdrasilMinecraftSessionService)FMLCommonHandler.instance().getMinecraftServerInstance().func_147130_as()).getAuthenticationService().); + } + } + catch (Exception e) { + e.printStackTrace(); + } // LogHelper.info(Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode()); // @@ -151,7 +144,7 @@ public class Tclogo extends ItemDE { // if ((int)System.currentTimeMillis() < lts + 10) return stack; // else lts = (int)System.currentTimeMillis(); - //world.playSound(player.posX, player.posY, player.posZ, "DraconicEvolution:fusionExplosion", 1F, 1F, false); + //world.playSound(player.posX, player.posY, player.posZ, "DraconicEvolution:fusionExplosion", 1F, 1F, false); // LogHelper.info(GameRegistry.findBlock("ThermalDynamics", "ThermalDynamics_0")); // if (player.inventory.getStackInSlot(0) != null) LogHelper.info(GameRegistry.findUniqueIdentifierFor(player.inventory.getStackInSlot(0).getItem())); // @@ -166,8 +159,8 @@ public class Tclogo extends ItemDE { // if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) ProcessHandler.addProcess(new ReactorExplosion(world, mop.blockX, mop.blockY, mop.blockZ, 20F)); // } - //EntityDragonProjectile projectile = new EntityDragonProjectile(world, 6, null, 10, player); - //projectile.setPosition(player.posX, player.posY, player.posZ); + //EntityDragonProjectile projectile = new EntityDragonProjectile(world, 6, null, 10, player); + //projectile.setPosition(player.posX, player.posY, player.posZ); // @@ -201,29 +194,18 @@ public class Tclogo extends ItemDE { // + // LogHelper.info(ContributorHandler.contributors); + // ContributorHandler.init(); + // LogHelper.info(ContributorHandler.contributors); + //EntityFallingBlock fallingBlock = new EntityFallingBlock(world, (int)player.posX + 0.5, (int)player.posY + 0.5, (int)player.posZ + 0.5, Blocks.obsidian, 0); + //fallingBlock.field_145812_b = 2; - - - - - - - - - - // LogHelper.info(ContributorHandler.contributors); - // ContributorHandler.init(); - // LogHelper.info(ContributorHandler.contributors); - - //EntityFallingBlock fallingBlock = new EntityFallingBlock(world, (int)player.posX + 0.5, (int)player.posY + 0.5, (int)player.posZ + 0.5, Blocks.obsidian, 0); - //fallingBlock.field_145812_b = 2; - - float motion = 0.005F; - //fallingBlock.motionX = (rand.nextFloat()-0.5F) * motion; - //fallingBlock.motionY = (rand.nextFloat()-0.5F) * motion; - //fallingBlock.motionZ = (rand.nextFloat()-0.5F) * motion; - //world.spawnEntityInWorld(fallingBlock); + float motion = 0.005F; + //fallingBlock.motionX = (rand.nextFloat()-0.5F) * motion; + //fallingBlock.motionY = (rand.nextFloat()-0.5F) * motion; + //fallingBlock.motionZ = (rand.nextFloat()-0.5F) * motion; + //world.spawnEntityInWorld(fallingBlock); // try @@ -239,7 +221,7 @@ public class Tclogo extends ItemDE { // } // catch (Exception e) {e.printStackTrace();} - //LogHelper.info(); + //LogHelper.info(); // LogHelper.info("#########################"); @@ -261,7 +243,6 @@ public class Tclogo extends ItemDE { // LogHelper.info("Time2:"+(System.nanoTime()-u)/1000000D); - // DraconicWorldGenerator.chaosIslandGen = new WorldGenChaosIsland(); // LogHelper.info("Reinitialized"); // long u = System.nanoTime(); @@ -271,7 +252,7 @@ public class Tclogo extends ItemDE { //// // LogHelper.info("Generated in:"+(System.nanoTime()-u)+"ns, "+(System.currentTimeMillis()-m)+"ms"); - //for (float f = 0; f < 1; f+=0.01) LogHelper.info((0.5D-Math.abs(f-0.5D))*2D); + //for (float f = 0; f < 1; f+=0.01) LogHelper.info((0.5D-Math.abs(f-0.5D))*2D); // short id = (short)itemRand.nextInt(4000); // byte meta = (byte)itemRand.nextInt(16); @@ -286,7 +267,6 @@ public class Tclogo extends ItemDE { // LogHelper.info("DecodedID:"+decodedID+" DecodedMeta:"+decodedMeta); - // LogHelper.info(Integer.toBinaryString(id) + " "+Integer.toBinaryString(meta)); // LogHelper.info(Integer.toBinaryString(id >> 4) +" " +Integer.toBinaryString(id & 0xF)); // LogHelper.info(id+" "+meta); @@ -299,7 +279,6 @@ public class Tclogo extends ItemDE { // LogHelper.info("Meta: "+Integer.toBinaryString(4095)); - // for (int index = 0; index < blockId.length; index++) { // if ((index >> 1) >= addId.length) { // No corresponding AddBlocks index // blocks[index] = (short) (blockId[index] & 0xFF); @@ -313,8 +292,6 @@ public class Tclogo extends ItemDE { // } - - // long s = (652800000L * 8L) + (652800000L * 8L); // LogHelper.info((s / 1000000000D) / 8D); @@ -360,9 +337,6 @@ public class Tclogo extends ItemDE { // LogHelper.info("Time 1:"+ (System.currentTimeMillis()-l)); - - - // long l = System.currentTimeMillis(); // new WorldGenChaosIsland().initialize(world.rand); // LogHelper.info(System.currentTimeMillis() - l); @@ -370,12 +344,12 @@ public class Tclogo extends ItemDE { // - // } + // } - //List l = world.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(player.posX, player.posY, player.posZ, player.posX, player.posY, player.posZ).expand(500, 500, 500)); - //for (Entity e : l) if (!(e instanceof EntityPlayer)) e.setDead(); + //List l = world.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(player.posX, player.posY, player.posZ, player.posX, player.posY, player.posZ).expand(500, 500, 500)); + //for (Entity e : l) if (!(e instanceof EntityPlayer)) e.setDead(); - //if (1==1) return stack; + //if (1==1) return stack; /*if (player instanceof EntityPlayerMP) { for (int i = 0; i < 10; i++) ((EntityPlayerMP) player).playerNetServerHandler.setPlayerLocation(player.posX + 1, player.posY, player.posZ, player.rotationYaw, player.rotationPitch); @@ -383,7 +357,7 @@ public class Tclogo extends ItemDE { if (1==1) return stack;*/ - //Minecraft.getMinecraft().gameSettings.mouseSensitivity = -0.34F; + //Minecraft.getMinecraft().gameSettings.mouseSensitivity = -0.34F; // if (world.isRemote) // { @@ -405,33 +379,30 @@ public class Tclogo extends ItemDE { // } - if (!player.isSneaking()) - { - player.capabilities.allowFlying = true; - //player.setPosition(player.posX, player.posY+1, player.posZ); - player.onGround = false; - player.capabilities.isFlying = true; - player.noClip = !player.noClip; + if (!player.isSneaking()) { + player.capabilities.allowFlying = true; + //player.setPosition(player.posX, player.posY+1, player.posZ); + player.onGround = false; + player.capabilities.isFlying = true; + player.noClip = !player.noClip; - } - else - { - int xi = (int)player.posX; - int yi = (int)player.posY; - int zi = (int)player.posZ; - int rad = 100; + } else { + int xi = (int) player.posX; + int yi = (int) player.posY; + int zi = (int) player.posZ; + int rad = 100; - for (int x = xi-rad; x < xi+rad; x++){ - for (int y = yi-10; y < yi+30; y++){ - for (int z = zi-rad; z < zi+rad; z++){ - world.markBlockForUpdate(x, y, z); - } - } - } + for (int x = xi - rad; x < xi + rad; x++) { + for (int y = yi - 10; y < yi + 30; y++) { + for (int z = zi - rad; z < zi + rad; z++) { + world.markBlockForUpdate(x, y, z); + } + } + } - world.markBlockRangeForRenderUpdate(xi-rad, yi-20, zi-rad, xi+rad, yi+20, zi+rad); - } + world.markBlockRangeForRenderUpdate(xi - rad, yi - 20, zi - rad, xi + rad, yi + 20, zi + rad); + } // // LogHelper.info("Downloading Image"); // @@ -458,16 +429,14 @@ public class Tclogo extends ItemDE { // } - - // player.addPotionEffect(new PotionEffect(PotionHandler.potionFlight.id, 100, 0)); // player.addPotionEffect(new PotionEffect(PotionHandler.potionFireResist.id, 100, 1)); // player.addPotionEffect(new PotionEffect(PotionHandler.potionSpeed.id, 100, 1)); // player.addPotionEffect(new PotionEffect(PotionHandler.potionUpHillStep.id, 100, 1)); - int xi = (int)player.posX; - int yi = (int)player.posY; - int zi = (int)player.posZ; - int rad = 1000; + int xi = (int) player.posX; + int yi = (int) player.posY; + int zi = (int) player.posZ; + int rad = 1000; // Block block; // for (int x = xi-rad; x < xi+rad; x++){ @@ -484,41 +453,38 @@ public class Tclogo extends ItemDE { // } - //world.markBlockRangeForRenderUpdate(xi-rad, yi-rad, zi-rad, xi+rad, yi+rad, zi+rad); - //if (world.isRemote)player.displayGUIWorkbench((int)player.posX, (int)player.posY, (int)player.posZ); - //world.setBlock(0, 0, 0, Blocks.crafting_table); - //if (!world.isRemote)player.displayGUIWorkbench(0, 0, 0); + //world.markBlockRangeForRenderUpdate(xi-rad, yi-rad, zi-rad, xi+rad, yi+rad, zi+rad); + //if (world.isRemote)player.displayGUIWorkbench((int)player.posX, (int)player.posY, (int)player.posZ); + //world.setBlock(0, 0, 0, Blocks.crafting_table); + //if (!world.isRemote)player.displayGUIWorkbench(0, 0, 0); - return stack; - } - - @Override - public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer player) - { - LogHelper.info(GameRegistry.findUniqueIdentifierFor(player.worldObj.getBlock(X, Y, Z))); + return stack; + } - //player.worldObj.scheduleBlockUpdate(X, Y, Z, player.worldObj.getBlock(X, Y, Z), 10); + @Override + public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer player) { + LogHelper.info(GameRegistry.findUniqueIdentifierFor(player.worldObj.getBlock(X, Y, Z))); - return false; - } - - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) - { - System.out.println("Use Tick"); - super.onUsingTick(stack, player, count); - } - - @Override - @SideOnly(Side.CLIENT) - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) - { - list.add(EnumChatFormatting.RED + "Warning! this is an item used to test random bits of code. You should not play with it"); - list.add(EnumChatFormatting.RED + "because depending on what i used it for last it could do anything."); - list.add(EnumChatFormatting.RED + "It may even break your world"); - list.add("At the time this warning was added it created a 200x200 block smoking creator"); + //player.worldObj.scheduleBlockUpdate(X, Y, Z, player.worldObj.getBlock(X, Y, Z), 10); + + return false; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + System.out.println("Use Tick"); + super.onUsingTick(stack, player, count); + } + + @Override + @SideOnly(Side.CLIENT) + @SuppressWarnings({"unchecked", "rawtypes"}) + public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) { + list.add(EnumChatFormatting.RED + "Warning! this is an item used to test random bits of code. You should not play with it"); + list.add(EnumChatFormatting.RED + "because depending on what i used it for last it could do anything."); + list.add(EnumChatFormatting.RED + "It may even break your world"); + list.add("At the time this warning was added it created a 200x200 block smoking creator"); // list.add(EnumChatFormatting.AQUA + "AQUA"); // list.add(EnumChatFormatting.BLACK + "BLACK"); @@ -541,5 +507,5 @@ public class Tclogo extends ItemDE { // list.add(EnumChatFormatting.OBFUSCATED + "OBFUSCATED"); // list.add(EnumChatFormatting.UNDERLINE + "UNDERLINE"); // list.add(EnumChatFormatting.STRIKETHROUGH + "STRIKETHROUGH"); - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/WyvernCore.java b/src/main/java/com/brandon3055/draconicevolution/common/items/WyvernCore.java index 4c670ca0..e2032484 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/WyvernCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/WyvernCore.java @@ -5,9 +5,9 @@ import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.lib.Strings; public class WyvernCore extends ItemDE { - public WyvernCore() { - this.setUnlocalizedName(Strings.infusedCompoundName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModItems.register(this); - } + public WyvernCore() { + this.setUnlocalizedName(Strings.infusedCompoundName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + ModItems.register(this); + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/CustomArmorHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/CustomArmorHandler.java index 0da3530f..f08ee201 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/CustomArmorHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/CustomArmorHandler.java @@ -30,12 +30,12 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent; * Created by Brandon on 13/11/2014. */ public class CustomArmorHandler { - public static final UUID WALK_SPEED_UUID = UUID.fromString("0ea6ce8e-d2e8-11e5-ab30-625662870761"); - private static final DamageSource ADMIN_KILL = new DamageSource("administrative.kill").setDamageAllowedInCreativeMode().setDamageBypassesArmor().setDamageIsAbsolute(); - public static Map playersWithFlight = new WeakHashMap(); - public static List playersWithUphillStep = new ArrayList(); + public static final UUID WALK_SPEED_UUID = UUID.fromString("0ea6ce8e-d2e8-11e5-ab30-625662870761"); + private static final DamageSource ADMIN_KILL = new DamageSource("administrative.kill").setDamageAllowedInCreativeMode().setDamageBypassesArmor().setDamageIsAbsolute(); + public static Map playersWithFlight = new WeakHashMap(); + public static List playersWithUphillStep = new ArrayList(); - public static void onPlayerHurt(LivingHurtEvent event) { + public static void onPlayerHurt(LivingHurtEvent event) { // EntityPlayer player = (EntityPlayer) event.entityLiving; // ArmorSummery summery = new ArmorSummery().getSummery(player); // if (summery == null || summery.protectionPoints <= 0) return; @@ -73,356 +73,370 @@ public class CustomArmorHandler { // if (event.ammount <= 0) event.setCanceled(true); // player.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).removeModifier(new AttributeModifier(KB_ATTRIB_UUID, SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), 100, 0)); // LogHelper.info("hurt"); - } + } - public static void onPlayerAttacked(LivingAttackEvent event){ - if (event.isCanceled()){ + public static void onPlayerAttacked(LivingAttackEvent event) { + if (event.isCanceled()) { return; } - EntityPlayer player = (EntityPlayer)event.entityLiving; - ArmorSummery summery = new ArmorSummery().getSummery(player); + EntityPlayer player = (EntityPlayer) event.entityLiving; + ArmorSummery summery = new ArmorSummery().getSummery(player); float hitAmount = ModHelper.applyModDamageAdjustments(summery, event); - if (applyArmorDamageBlocking(event, summery)) { - return; - } - if (summery == null || summery.protectionPoints <= 0 || event.source == ADMIN_KILL) { - return; - } - event.setCanceled(true); - //Ensure that the /kill command can still kill the player - if (hitAmount == Float.MAX_VALUE && !event.source.damageType.equals(ADMIN_KILL.damageType)){ - player.attackEntityFrom(ADMIN_KILL, Float.MAX_VALUE); - return; - } - if ((float)player.hurtResistantTime > (float)player.maxHurtResistantTime / 2.0F) return; + if (applyArmorDamageBlocking(event, summery)) { + return; + } + if (summery == null || summery.protectionPoints <= 0 || event.source == ADMIN_KILL) { + return; + } + event.setCanceled(true); + //Ensure that the /kill command can still kill the player + if (hitAmount == Float.MAX_VALUE && !event.source.damageType.equals(ADMIN_KILL.damageType)) { + player.attackEntityFrom(ADMIN_KILL, Float.MAX_VALUE); + return; + } + if ((float) player.hurtResistantTime > (float) player.maxHurtResistantTime / 2.0F) return; float newEntropy = Math.min(summery.entropy + 1 + (hitAmount / 20), 100F); - //Divide the damage between the armor peaces based on how many of the protection points each peace has - float totalAbsorbed = 0; - int remainingPoints = 0; - for (int i = 0; i < summery.allocation.length; i++){ - if (summery.allocation[i] == 0) continue; - ItemStack armorPeace = summery.armorStacks[i]; + //Divide the damage between the armor peaces based on how many of the protection points each peace has + float totalAbsorbed = 0; + int remainingPoints = 0; + for (int i = 0; i < summery.allocation.length; i++) { + if (summery.allocation[i] == 0) continue; + ItemStack armorPeace = summery.armorStacks[i]; - float dmgShear = summery.allocation[i] / summery.protectionPoints; - float dmg = dmgShear * hitAmount; + float dmgShear = summery.allocation[i] / summery.protectionPoints; + float dmg = dmgShear * hitAmount; - float absorbed = Math.min(dmg, summery.allocation[i]); - totalAbsorbed += absorbed; - summery.allocation[i]-=absorbed; - remainingPoints += summery.allocation[i]; - ItemNBTHelper.setFloat(armorPeace, "ProtectionPoints", summery.allocation[i]); - ItemNBTHelper.setFloat(armorPeace, "ShieldEntropy", newEntropy); - } + float absorbed = Math.min(dmg, summery.allocation[i]); + totalAbsorbed += absorbed; + summery.allocation[i] -= absorbed; + remainingPoints += summery.allocation[i]; + ItemNBTHelper.setFloat(armorPeace, "ProtectionPoints", summery.allocation[i]); + ItemNBTHelper.setFloat(armorPeace, "ShieldEntropy", newEntropy); + } - if (summery.protectionPoints > 0){ - DraconicEvolution.network.sendToAllAround(new ShieldHitPacket(player, summery.protectionPoints / summery.maxProtectionPoints), new NetworkRegistry.TargetPoint(player.dimension, player.posX, player.posY, player.posZ, 64)); - player.worldObj.playSoundEffect(player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, "draconicevolution:shieldStrike", 0.9F, player.worldObj.rand.nextFloat() * 0.1F + 1.055F); - } + if (summery.protectionPoints > 0) { + DraconicEvolution.network.sendToAllAround(new ShieldHitPacket(player, summery.protectionPoints / summery.maxProtectionPoints), new NetworkRegistry.TargetPoint(player.dimension, player.posX, player.posY, player.posZ, 64)); + player.worldObj.playSoundEffect(player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, "draconicevolution:shieldStrike", 0.9F, player.worldObj.rand.nextFloat() * 0.1F + 1.055F); + } - if (remainingPoints > 0) { - player.hurtResistantTime = 20; - } - else if (hitAmount-totalAbsorbed > 0){ - player.attackEntityFrom(event.source, hitAmount-totalAbsorbed); - } - } + if (remainingPoints > 0) { + player.hurtResistantTime = 20; + } else if (hitAmount - totalAbsorbed > 0) { + player.attackEntityFrom(event.source, hitAmount - totalAbsorbed); + } + } - public static void onPlayerDeath(LivingDeathEvent event) { - if (event.isCanceled()){ + public static void onPlayerDeath(LivingDeathEvent event) { + if (event.isCanceled()) { return; } - EntityPlayer player = (EntityPlayer)event.entityLiving; - ArmorSummery summery = new ArmorSummery().getSummery(player); + EntityPlayer player = (EntityPlayer) event.entityLiving; + ArmorSummery summery = new ArmorSummery().getSummery(player); - if (summery == null || event.source == ADMIN_KILL) return; + if (summery == null || event.source == ADMIN_KILL) return; - if (summery.protectionPoints > 500){ - event.setCanceled(true); - event.entityLiving.setHealth(10); - // LogHelper.warn("Something is trying to bypass the draconic shield. [Culprit: {Damage Type=" + event.source.damageType + ", Damage Class=" + event.source.toString() + "]"); - return; - } + if (summery.protectionPoints > 500) { + event.setCanceled(true); + event.entityLiving.setHealth(10); + // LogHelper.warn("Something is trying to bypass the draconic shield. [Culprit: {Damage Type=" + event.source.damageType + ", Damage Class=" + event.source.toString() + "]"); + return; + } - if (!summery.hasDraconic) return; + if (!summery.hasDraconic) return; - int[] charge = new int[summery.armorStacks.length]; - int totalCharge = 0; - for (int i = 0; i < summery.armorStacks.length; i++){ - if (summery.armorStacks[i] != null) { - charge[i] = ((IEnergyContainerItem)summery.armorStacks[i].getItem()).getEnergyStored(summery.armorStacks[i]); - totalCharge += charge[i]; - } - } + int[] charge = new int[summery.armorStacks.length]; + int totalCharge = 0; + for (int i = 0; i < summery.armorStacks.length; i++) { + if (summery.armorStacks[i] != null) { + charge[i] = ((IEnergyContainerItem) summery.armorStacks[i].getItem()).getEnergyStored(summery.armorStacks[i]); + totalCharge += charge[i]; + } + } - if (totalCharge < BalanceConfigHandler.draconicArmorBaseStorage) return; + if (totalCharge < BalanceConfigHandler.draconicArmorBaseStorage) return; - for (int i = 0; i < summery.armorStacks.length; i++){ - if (summery.armorStacks[i] != null) { - ((IEnergyContainerItem)summery.armorStacks[i].getItem()).extractEnergy(summery.armorStacks[i], (int) ((charge[i] / (double) totalCharge) * BalanceConfigHandler.draconicArmorBaseStorage), false); - } - } + for (int i = 0; i < summery.armorStacks.length; i++) { + if (summery.armorStacks[i] != null) { + ((IEnergyContainerItem) summery.armorStacks[i].getItem()).extractEnergy(summery.armorStacks[i], (int) ((charge[i] / (double) totalCharge) * BalanceConfigHandler.draconicArmorBaseStorage), false); + } + } - player.addChatComponentMessage(new ChatComponentTranslation("msg.de.shieldDepleted.txt").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_RED))); - event.setCanceled(true); - player.setHealth(1); - } + player.addChatComponentMessage(new ChatComponentTranslation("msg.de.shieldDepleted.txt").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_RED))); + event.setCanceled(true); + player.setHealth(1); + } - public static void onPlayerTick(TickEvent.PlayerTickEvent event) { + public static void onPlayerTick(TickEvent.PlayerTickEvent event) { - EntityPlayer player = event.player; - ArmorSummery summery = new ArmorSummery().getSummery(player); + EntityPlayer player = event.player; + ArmorSummery summery = new ArmorSummery().getSummery(player); - tickShield(summery, player); - tickArmorEffects(summery, player); - } + tickShield(summery, player); + tickArmorEffects(summery, player); + } - public static void tickShield(ArmorSummery summery, EntityPlayer player){ - if (summery == null || (summery.maxProtectionPoints - summery.protectionPoints < 0.01 && summery.entropy == 0) || player.worldObj.isRemote) return; + public static void tickShield(ArmorSummery summery, EntityPlayer player) { + if (summery == null || (summery.maxProtectionPoints - summery.protectionPoints < 0.01 && summery.entropy == 0) || player.worldObj.isRemote) + return; - float totalPointsToAdd = Math.min(summery.maxProtectionPoints - summery.protectionPoints, summery.maxProtectionPoints / 60F); - totalPointsToAdd *= (1F - (summery.entropy / 100F)); - totalPointsToAdd = Math.min(totalPointsToAdd, summery.totalEnergyStored / (summery.hasDraconic ? BalanceConfigHandler.draconicArmorEnergyPerProtectionPoint : BalanceConfigHandler.wyvernArmorEnergyPerProtectionPoint)); - if (totalPointsToAdd < 0F) totalPointsToAdd = 0F; + float totalPointsToAdd = Math.min(summery.maxProtectionPoints - summery.protectionPoints, summery.maxProtectionPoints / 60F); + totalPointsToAdd *= (1F - (summery.entropy / 100F)); + totalPointsToAdd = Math.min(totalPointsToAdd, summery.totalEnergyStored / (summery.hasDraconic ? BalanceConfigHandler.draconicArmorEnergyPerProtectionPoint : BalanceConfigHandler.wyvernArmorEnergyPerProtectionPoint)); + if (totalPointsToAdd < 0F) totalPointsToAdd = 0F; - summery.entropy -= (summery.meanRecoveryPoints * 0.01F); - if (summery.entropy < 0) summery.entropy = 0; + summery.entropy -= (summery.meanRecoveryPoints * 0.01F); + if (summery.entropy < 0) summery.entropy = 0; - for (int i = 0; i < summery.armorStacks.length; i++){ - ItemStack stack = summery.armorStacks[i]; - if (stack == null || summery.totalEnergyStored <= 0) continue; - float maxForPeace = ((ICustomArmor)stack.getItem()).getProtectionPoints(stack); - int energyAmount = ((ICustomArmor)summery.armorStacks[i].getItem()).getEnergyPerProtectionPoint(); - ((IEnergyContainerItem)stack.getItem()).extractEnergy(stack, (int)(((double)summery.energyAllocation[i] / (double)summery.totalEnergyStored) * (totalPointsToAdd * energyAmount)), false); - float pointsForPeace = (summery.pointsDown[i] / Math.max(1, summery.maxProtectionPoints - summery.protectionPoints)) * totalPointsToAdd; - summery.allocation[i] += pointsForPeace; - if (summery.allocation[i] > maxForPeace || maxForPeace - summery.allocation[i] < 0.1F) summery.allocation[i] = maxForPeace; - ItemNBTHelper.setFloat(stack, "ProtectionPoints", summery.allocation[i]); - if (player.hurtResistantTime <= 0)ItemNBTHelper.setFloat(stack, "ShieldEntropy", summery.entropy); - } - } + for (int i = 0; i < summery.armorStacks.length; i++) { + ItemStack stack = summery.armorStacks[i]; + if (stack == null || summery.totalEnergyStored <= 0) continue; + float maxForPeace = ((ICustomArmor) stack.getItem()).getProtectionPoints(stack); + int energyAmount = ((ICustomArmor) summery.armorStacks[i].getItem()).getEnergyPerProtectionPoint(); + ((IEnergyContainerItem) stack.getItem()).extractEnergy(stack, (int) (((double) summery.energyAllocation[i] / (double) summery.totalEnergyStored) * (totalPointsToAdd * energyAmount)), false); + float pointsForPeace = (summery.pointsDown[i] / Math.max(1, summery.maxProtectionPoints - summery.protectionPoints)) * totalPointsToAdd; + summery.allocation[i] += pointsForPeace; + if (summery.allocation[i] > maxForPeace || maxForPeace - summery.allocation[i] < 0.1F) + summery.allocation[i] = maxForPeace; + ItemNBTHelper.setFloat(stack, "ProtectionPoints", summery.allocation[i]); + if (player.hurtResistantTime <= 0) ItemNBTHelper.setFloat(stack, "ShieldEntropy", summery.entropy); + } + } - public static void tickArmorEffects(ArmorSummery summery, EntityPlayer player){ + public static void tickArmorEffects(ArmorSummery summery, EntityPlayer player) { - //region/*----------------- Flight ------------------*/ + //region/*----------------- Flight ------------------*/ - if (summery != null && summery.flight[0]) { - playersWithFlight.put(player, true); - player.capabilities.allowFlying = true; - if (summery.flight[1]) player.capabilities.isFlying = true; + if (summery != null && summery.flight[0]) { + playersWithFlight.put(player, true); + player.capabilities.allowFlying = true; + if (summery.flight[1]) player.capabilities.isFlying = true; - if (player.worldObj.isRemote) setPlayerFlySpeed(player, 0.05F + (0.05F * summery.flightSpeedModifier)); + if (player.worldObj.isRemote) setPlayerFlySpeed(player, 0.05F + (0.05F * summery.flightSpeedModifier)); - if ((!player.onGround && player.capabilities.isFlying) && player.motionY != 0 && summery.flightVModifier > 0) - { + if ((!player.onGround && player.capabilities.isFlying) && player.motionY != 0 && summery.flightVModifier > 0) { // float percentIncrease = summery.flightVModifier; - if (BrandonsCore.proxy.isSpaceDown() && !BrandonsCore.proxy.isShiftDown()) - { - //LogHelper.info(player.motionY); - player.motionY = 0.225F * summery.flightVModifier; - } + if (BrandonsCore.proxy.isSpaceDown() && !BrandonsCore.proxy.isShiftDown()) { + //LogHelper.info(player.motionY); + player.motionY = 0.225F * summery.flightVModifier; + } - if (BrandonsCore.proxy.isShiftDown() && !BrandonsCore.proxy.isSpaceDown()) - { - player.motionY = -0.225F * summery.flightVModifier; - } - } + if (BrandonsCore.proxy.isShiftDown() && !BrandonsCore.proxy.isSpaceDown()) { + player.motionY = -0.225F * summery.flightVModifier; + } + } - if (summery.flight[2] && player.moveForward == 0 && player.moveStrafing == 0 && player.capabilities.isFlying){ - player.motionX *= 0.5; - player.motionZ *= 0.5; - } + if (summery.flight[2] && player.moveForward == 0 && player.moveStrafing == 0 && player.capabilities.isFlying) { + player.motionX *= 0.5; + player.motionZ *= 0.5; + } - } else { - if (!playersWithFlight.containsKey(player)) { - playersWithFlight.put(player, false); - } + } else { + if (!playersWithFlight.containsKey(player)) { + playersWithFlight.put(player, false); + } - if (playersWithFlight.get(player) && !player.worldObj.isRemote) { - playersWithFlight.put(player, false); + if (playersWithFlight.get(player) && !player.worldObj.isRemote) { + playersWithFlight.put(player, false); - if (!player.capabilities.isCreativeMode) { - player.capabilities.allowFlying = false; - player.capabilities.isFlying = false; - player.sendPlayerAbilities(); + if (!player.capabilities.isCreativeMode) { + player.capabilities.allowFlying = false; + player.capabilities.isFlying = false; + player.sendPlayerAbilities(); LogHelper.info("Send Disable"); - } - } + } + } - if (player.worldObj.isRemote && playersWithFlight.get(player)){ + if (player.worldObj.isRemote && playersWithFlight.get(player)) { playersWithFlight.put(player, false); player.capabilities.allowFlying = false; player.capabilities.isFlying = false; LogHelper.info("Put Client"); setPlayerFlySpeed(player, 0.05F); } - } - //endregion + } + //endregion - //region/*---------------- Swiftness ----------------*/ + //region/*---------------- Swiftness ----------------*/ - IAttribute speedAttr = SharedMonsterAttributes.movementSpeed; - if (summery != null && summery.speedModifier > 0) - { - double value = summery.speedModifier; - if (player.getEntityAttribute(speedAttr).getModifier(WALK_SPEED_UUID) == null) { - player.getEntityAttribute(speedAttr).applyModifier(new AttributeModifier(WALK_SPEED_UUID, speedAttr.getAttributeUnlocalizedName(), value, 1)); - } - else if (player.getEntityAttribute(speedAttr).getModifier(WALK_SPEED_UUID).getAmount() != value){ - player.getEntityAttribute(speedAttr).removeModifier(player.getEntityAttribute(speedAttr).getModifier(WALK_SPEED_UUID)); - player.getEntityAttribute(speedAttr).applyModifier(new AttributeModifier(WALK_SPEED_UUID, speedAttr.getAttributeUnlocalizedName(), value, 1)); - } + IAttribute speedAttr = SharedMonsterAttributes.movementSpeed; + if (summery != null && summery.speedModifier > 0) { + double value = summery.speedModifier; + if (player.getEntityAttribute(speedAttr).getModifier(WALK_SPEED_UUID) == null) { + player.getEntityAttribute(speedAttr).applyModifier(new AttributeModifier(WALK_SPEED_UUID, speedAttr.getAttributeUnlocalizedName(), value, 1)); + } else if (player.getEntityAttribute(speedAttr).getModifier(WALK_SPEED_UUID).getAmount() != value) { + player.getEntityAttribute(speedAttr).removeModifier(player.getEntityAttribute(speedAttr).getModifier(WALK_SPEED_UUID)); + player.getEntityAttribute(speedAttr).applyModifier(new AttributeModifier(WALK_SPEED_UUID, speedAttr.getAttributeUnlocalizedName(), value, 1)); + } - if (!player.onGround && player.ridingEntity == null) player.jumpMovementFactor = 0.02F + (0.02F * summery.speedModifier); - } - else if (player.getEntityAttribute(speedAttr).getModifier(WALK_SPEED_UUID) != null) - { - player.getEntityAttribute(speedAttr).removeModifier(player.getEntityAttribute(speedAttr).getModifier(WALK_SPEED_UUID)); - } + if (!player.onGround && player.ridingEntity == null) + player.jumpMovementFactor = 0.02F + (0.02F * summery.speedModifier); + } else if (player.getEntityAttribute(speedAttr).getModifier(WALK_SPEED_UUID) != null) { + player.getEntityAttribute(speedAttr).removeModifier(player.getEntityAttribute(speedAttr).getModifier(WALK_SPEED_UUID)); + } - //endregion + //endregion - //region/*---------------- HillStep -----------------*/ - if (summery != null && player.worldObj.isRemote) { - boolean highStepListed = playersWithUphillStep.contains(player.getDisplayName()) && player.stepHeight >= 1f; - boolean hasHighStep = summery.hasHillStep; + //region/*---------------- HillStep -----------------*/ + if (summery != null && player.worldObj.isRemote) { + boolean highStepListed = playersWithUphillStep.contains(player.getDisplayName()) && player.stepHeight >= 1f; + boolean hasHighStep = summery.hasHillStep; - if (hasHighStep && !highStepListed) { - playersWithUphillStep.add(player.getDisplayName()); - player.stepHeight = 1f; - } + if (hasHighStep && !highStepListed) { + playersWithUphillStep.add(player.getDisplayName()); + player.stepHeight = 1f; + } - if (!hasHighStep && highStepListed) { - playersWithUphillStep.remove(player.getDisplayName()); - player.stepHeight = 0.5F; - } - } - //endregion - } + if (!hasHighStep && highStepListed) { + playersWithUphillStep.remove(player.getDisplayName()); + player.stepHeight = 0.5F; + } + } + //endregion + } - private static void setPlayerFlySpeed(EntityPlayer player, float speed) { - player.capabilities.setFlySpeed(speed); - } + private static void setPlayerFlySpeed(EntityPlayer player, float speed) { + player.capabilities.setFlySpeed(speed); + } - private static boolean applyArmorDamageBlocking(LivingAttackEvent event, ArmorSummery summery){ - if (summery == null) return false; + private static boolean applyArmorDamageBlocking(LivingAttackEvent event, ArmorSummery summery) { + if (summery == null) return false; - if (event.source.isFireDamage() && summery.fireResistance >= 1F) - { - event.setCanceled(true); - event.entityLiving.extinguish(); - return true; - } + if (event.source.isFireDamage() && summery.fireResistance >= 1F) { + event.setCanceled(true); + event.entityLiving.extinguish(); + return true; + } - if (event.source.damageType.equals("fall") && summery.jumpModifier > 0F) - { - if (event.ammount < summery.jumpModifier * 5F) event.setCanceled(true); - return true; - } + if (event.source.damageType.equals("fall") && summery.jumpModifier > 0F) { + if (event.ammount < summery.jumpModifier * 5F) event.setCanceled(true); + return true; + } - if ((event.source.damageType.equals("inWall") || event.source.damageType.equals("drown")) && summery.armorStacks[3] != null) - { - if (event.ammount <= 2f) event.setCanceled(true); - return true; - } + if ((event.source.damageType.equals("inWall") || event.source.damageType.equals("drown")) && summery.armorStacks[3] != null) { + if (event.ammount <= 2f) event.setCanceled(true); + return true; + } - return false; - } + return false; + } - public static class ArmorSummery { - /*---- Shield ----*/ - /**Max protection points from all equipped armor peaces*/ - public float maxProtectionPoints = 0F; - /**Total protection points from all equipped armor peaces*/ - public float protectionPoints = 0F; - /**Number of quipped armor peaces*/ - public int peaces = 0; - /**Point Allocation, The number of points on each peace*/ - public float[] allocation; - /**How many points have been drained from each armor peace*/ - public float[] pointsDown; - /**The armor peaces (Index will contain null if peace is not present)*/ - public ItemStack[] armorStacks; - /**Mean Fatigue*/ - public float entropy = 0F; - /**Mean Recovery Points*/ - public int meanRecoveryPoints = 0; - /**Total RF stored in the armor*/ - public long totalEnergyStored = 0; - /**Total Max RF storage for the armor*/ - public long maxTotalEnergyStorage = 0; - /**RF stored in each armor peace*/ - public int[] energyAllocation; - /*---- Effects ----*/ - public boolean[] flight = new boolean[] {false, false, false}; - public float flightVModifier = 0F; - public float speedModifier = 0F; - public float jumpModifier = 0F; - public float fireResistance = 0F; - public float flightSpeedModifier = 0; - public boolean hasHillStep = false; - public boolean hasDraconic = false; + public static class ArmorSummery { + /*---- Shield ----*/ + /** + * Max protection points from all equipped armor peaces + */ + public float maxProtectionPoints = 0F; + /** + * Total protection points from all equipped armor peaces + */ + public float protectionPoints = 0F; + /** + * Number of quipped armor peaces + */ + public int peaces = 0; + /** + * Point Allocation, The number of points on each peace + */ + public float[] allocation; + /** + * How many points have been drained from each armor peace + */ + public float[] pointsDown; + /** + * The armor peaces (Index will contain null if peace is not present) + */ + public ItemStack[] armorStacks; + /** + * Mean Fatigue + */ + public float entropy = 0F; + /** + * Mean Recovery Points + */ + public int meanRecoveryPoints = 0; + /** + * Total RF stored in the armor + */ + public long totalEnergyStored = 0; + /** + * Total Max RF storage for the armor + */ + public long maxTotalEnergyStorage = 0; + /** + * RF stored in each armor peace + */ + public int[] energyAllocation; + /*---- Effects ----*/ + public boolean[] flight = new boolean[]{false, false, false}; + public float flightVModifier = 0F; + public float speedModifier = 0F; + public float jumpModifier = 0F; + public float fireResistance = 0F; + public float flightSpeedModifier = 0; + public boolean hasHillStep = false; + public boolean hasDraconic = false; - public ArmorSummery getSummery(EntityPlayer player){ - ItemStack[] armorSlots = player.inventory.armorInventory; - float totalEntropy = 0; - int totalRecoveryPoints = 0; + public ArmorSummery getSummery(EntityPlayer player) { + ItemStack[] armorSlots = player.inventory.armorInventory; + float totalEntropy = 0; + int totalRecoveryPoints = 0; - allocation = new float[armorSlots.length]; - armorStacks = new ItemStack[armorSlots.length]; - pointsDown = new float[armorSlots.length]; - energyAllocation = new int[armorSlots.length]; + allocation = new float[armorSlots.length]; + armorStacks = new ItemStack[armorSlots.length]; + pointsDown = new float[armorSlots.length]; + energyAllocation = new int[armorSlots.length]; - for (int i = 0; i < armorSlots.length; i++){ - ItemStack stack = armorSlots[i]; - if (stack == null || !(stack.getItem() instanceof ICustomArmor)) continue; - ICustomArmor armor = (ICustomArmor)stack.getItem(); - peaces++; - allocation[i] = ItemNBTHelper.getFloat(stack, "ProtectionPoints", 0); - protectionPoints += allocation[i]; - totalEntropy += ItemNBTHelper.getFloat(stack, "ShieldEntropy", 0); - armorStacks[i] = stack; - totalRecoveryPoints += IUpgradableItem.EnumUpgrade.SHIELD_RECOVERY.getUpgradePoints(stack); - float maxPoints = armor.getProtectionPoints(stack); - pointsDown[i] = maxPoints - allocation[i]; - maxProtectionPoints += maxPoints; - energyAllocation[i] = armor.getEnergyStored(stack); - totalEnergyStored += energyAllocation[i]; - maxTotalEnergyStorage += armor.getMaxEnergyStored(stack); - if (stack.getItem() instanceof DraconicArmor) hasDraconic = true; + for (int i = 0; i < armorSlots.length; i++) { + ItemStack stack = armorSlots[i]; + if (stack == null || !(stack.getItem() instanceof ICustomArmor)) continue; + ICustomArmor armor = (ICustomArmor) stack.getItem(); + peaces++; + allocation[i] = ItemNBTHelper.getFloat(stack, "ProtectionPoints", 0); + protectionPoints += allocation[i]; + totalEntropy += ItemNBTHelper.getFloat(stack, "ShieldEntropy", 0); + armorStacks[i] = stack; + totalRecoveryPoints += IUpgradableItem.EnumUpgrade.SHIELD_RECOVERY.getUpgradePoints(stack); + float maxPoints = armor.getProtectionPoints(stack); + pointsDown[i] = maxPoints - allocation[i]; + maxProtectionPoints += maxPoints; + energyAllocation[i] = armor.getEnergyStored(stack); + totalEnergyStored += energyAllocation[i]; + maxTotalEnergyStorage += armor.getMaxEnergyStored(stack); + if (stack.getItem() instanceof DraconicArmor) hasDraconic = true; - fireResistance += armor.getFireResistance(stack); + fireResistance += armor.getFireResistance(stack); - switch (i){ - case 2: - flight = armor.hasFlight(stack); - if (flight[0]) { - flightVModifier = armor.getFlightVModifier(stack, player); - flightSpeedModifier = armor.getFlightSpeedModifier(stack, player); - } - break; - case 1: - speedModifier = armor.getSpeedModifier(stack, player); - break; - case 0: - hasHillStep = armor.hasHillStep(stack, player); - jumpModifier = armor.getJumpModifier(stack, player); - break; - } - } + switch (i) { + case 2: + flight = armor.hasFlight(stack); + if (flight[0]) { + flightVModifier = armor.getFlightVModifier(stack, player); + flightSpeedModifier = armor.getFlightSpeedModifier(stack, player); + } + break; + case 1: + speedModifier = armor.getSpeedModifier(stack, player); + break; + case 0: + hasHillStep = armor.hasHillStep(stack, player); + jumpModifier = armor.getJumpModifier(stack, player); + break; + } + } - if (peaces == 0) return null; + if (peaces == 0) return null; - entropy = totalEntropy / peaces; - meanRecoveryPoints = totalRecoveryPoints / peaces; + entropy = totalEntropy / peaces; + meanRecoveryPoints = totalRecoveryPoints / peaces; - return this; - } - } + return this; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/DraconicArmor.java b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/DraconicArmor.java index c09ce5ff..fd45568a 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/DraconicArmor.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/DraconicArmor.java @@ -50,499 +50,477 @@ import thaumcraft.api.nodes.IRevealer; /** * Created by Brandon on 3/07/2014. */ -@Optional.InterfaceList(value = { - @Optional.Interface(iface = "thaumcraft.api.IGoggles", modid = "Thaumcraft"), - @Optional.Interface(iface = "thaumcraft.api.nodes.IRevealer", modid = "Thaumcraft") -}) +@Optional.InterfaceList(value = {@Optional.Interface(iface = "thaumcraft.api.IGoggles", modid = "Thaumcraft"), @Optional.Interface(iface = "thaumcraft.api.nodes.IRevealer", modid = "Thaumcraft")}) public class DraconicArmor extends ItemArmor implements ISpecialArmor, IConfigurableItem, IInventoryTool, IGoggles, IRevealer, IUpgradableItem, ICustomArmor {//TODO Wings - @SideOnly(Side.CLIENT) - private IIcon helmIcon; - @SideOnly(Side.CLIENT) - private IIcon chestIcon; - @SideOnly(Side.CLIENT) - private IIcon leggsIcon; - @SideOnly(Side.CLIENT) - private IIcon bootsIcon; + @SideOnly(Side.CLIENT) + private IIcon helmIcon; + @SideOnly(Side.CLIENT) + private IIcon chestIcon; + @SideOnly(Side.CLIENT) + private IIcon leggsIcon; + @SideOnly(Side.CLIENT) + private IIcon bootsIcon; - private int maxEnergy = BalanceConfigHandler.draconicArmorBaseStorage; - private int maxTransfer = BalanceConfigHandler.draconicArmorMaxTransfer; + private int maxEnergy = BalanceConfigHandler.draconicArmorBaseStorage; + private int maxTransfer = BalanceConfigHandler.draconicArmorMaxTransfer; - public DraconicArmor(ArmorMaterial material, int armorType, String name) { - super(material, 0, armorType); - this.setUnlocalizedName(name); - this.setCreativeTab(DraconicEvolution.tabToolsWeapons); - if (ModItems.isEnabled(this)) GameRegistry.registerItem(this, name); - } + public DraconicArmor(ArmorMaterial material, int armorType, String name) { + super(material, 0, armorType); + this.setUnlocalizedName(name); + this.setCreativeTab(DraconicEvolution.tabToolsWeapons); + if (ModItems.isEnabled(this)) GameRegistry.registerItem(this, name); + } - @Override - public boolean isItemTool(ItemStack p_77616_1_) { - return true; - } + @Override + public boolean isItemTool(ItemStack p_77616_1_) { + return true; + } - @SuppressWarnings("unchecked") - @Override - public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { - list.add(ItemNBTHelper.setInteger(new ItemStack(item), "Energy", 0)); - list.add(ItemNBTHelper.setInteger(new ItemStack(item), "Energy", maxEnergy)); - } + @SuppressWarnings("unchecked") + @Override + public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { + list.add(ItemNBTHelper.setInteger(new ItemStack(item), "Energy", 0)); + list.add(ItemNBTHelper.setInteger(new ItemStack(item), "Energy", maxEnergy)); + } - @Override - public String getUnlocalizedName() { + @Override + public String getUnlocalizedName() { - return String.format("item.%s%s", References.MODID.toLowerCase() + ":", super.getUnlocalizedName().substring(super.getUnlocalizedName().indexOf(".") + 1)); - } + return String.format("item.%s%s", References.MODID.toLowerCase() + ":", super.getUnlocalizedName().substring(super.getUnlocalizedName().indexOf(".") + 1)); + } - @Override - public String getUnlocalizedName(final ItemStack itemStack) { - return getUnlocalizedName(); - } + @Override + public String getUnlocalizedName(final ItemStack itemStack) { + return getUnlocalizedName(); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister iconRegister) { - helmIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_helmet"); - chestIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_chestplate"); - leggsIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_leggings"); - bootsIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_boots"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + helmIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_helmet"); + chestIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_chestplate"); + leggsIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_leggings"); + bootsIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_boots"); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { - if (stack.getItem() == ModItems.draconicHelm) return helmIcon; - else if (stack.getItem() == ModItems.draconicChest) return chestIcon; - else if (stack.getItem() == ModItems.draconicLeggs) return leggsIcon; - else return bootsIcon; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + if (stack.getItem() == ModItems.draconicHelm) return helmIcon; + else if (stack.getItem() == ModItems.draconicChest) return chestIcon; + else if (stack.getItem() == ModItems.draconicLeggs) return leggsIcon; + else return bootsIcon; + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconIndex(ItemStack stack) { - if (stack.getItem() == ModItems.draconicHelm) return helmIcon; - else if (stack.getItem() == ModItems.draconicChest) return chestIcon; - else if (stack.getItem() == ModItems.draconicLeggs) return leggsIcon; - else return bootsIcon; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconIndex(ItemStack stack) { + if (stack.getItem() == ModItems.draconicHelm) return helmIcon; + else if (stack.getItem() == ModItems.draconicChest) return chestIcon; + else if (stack.getItem() == ModItems.draconicLeggs) return leggsIcon; + else return bootsIcon; + } - @Override - @SideOnly(Side.CLIENT) - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { - if (!ConfigHandler.useOldArmorModel) return References.RESOURCESPREFIX + "textures/models/armor/armorDraconic.png"; - if (stack.getItem() == ModItems.draconicHelm || stack.getItem() == ModItems.draconicChest || stack.getItem() == ModItems.draconicBoots) { - return References.RESOURCESPREFIX + "textures/models/armor/draconic_layer_1.png"; - } else { - return References.RESOURCESPREFIX + "textures/models/armor/draconic_layer_2.png"; - } - } + @Override + @SideOnly(Side.CLIENT) + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + if (!ConfigHandler.useOldArmorModel) + return References.RESOURCESPREFIX + "textures/models/armor/armorDraconic.png"; + if (stack.getItem() == ModItems.draconicHelm || stack.getItem() == ModItems.draconicChest || stack.getItem() == ModItems.draconicBoots) { + return References.RESOURCESPREFIX + "textures/models/armor/draconic_layer_1.png"; + } else { + return References.RESOURCESPREFIX + "textures/models/armor/draconic_layer_2.png"; + } + } - @Override - public EnumRarity getRarity(ItemStack p_77613_1_) { - return EnumRarity.epic; - } + @Override + public EnumRarity getRarity(ItemStack p_77613_1_) { + return EnumRarity.epic; + } - @Override - public double getDurabilityForDisplay(ItemStack stack) { - return 1D - (double)ItemNBTHelper.getInteger(stack, "Energy", 0) / (double)getMaxEnergyStored(stack); - } + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - (double) ItemNBTHelper.getInteger(stack, "Energy", 0) / (double) getMaxEnergyStored(stack); + } - @Override - public boolean showDurabilityBar(ItemStack stack) { - return getEnergyStored(stack) < getMaxEnergyStored(stack); - } + @Override + public boolean showDurabilityBar(ItemStack stack) { + return getEnergyStored(stack) < getMaxEnergyStored(stack); + } - protected float getProtectionShare() { - switch (armorType) { - case 0: - return 0.15F; - case 1: - return 0.40F; - case 2: - return 0.30F; - case 3: - return 0.15F; - } - return 0; - } + protected float getProtectionShare() { + switch (armorType) { + case 0: + return 0.15F; + case 1: + return 0.40F; + case 2: + return 0.30F; + case 3: + return 0.15F; + } + return 0; + } - //region ISpecialArmor - @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { - if (source.isUnblockable() || source.isDamageAbsolute() || source.isMagicDamage()) return new ArmorProperties(0, damageReduceAmount / 100D, 15); - return new ArmorProperties(0, damageReduceAmount / 24.5D, 1000); - } + //region ISpecialArmor + @Override + public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { + if (source.isUnblockable() || source.isDamageAbsolute() || source.isMagicDamage()) + return new ArmorProperties(0, damageReduceAmount / 100D, 15); + return new ArmorProperties(0, damageReduceAmount / 24.5D, 1000); + } - @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { - return (int)(getProtectionShare() * 20D); - } + @Override + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + return (int) (getProtectionShare() * 20D); + } - @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { - } - //endregion + @Override + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + } + //endregion - @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { - if (stack == null) return; - if (stack.getItem() == ModItems.draconicHelm) { - if (world.isRemote) return; - if (this.getEnergyStored(stack) >= BalanceConfigHandler.draconicArmorEnergyToRemoveEffects && clearNegativeEffects(player)) - { - this.extractEnergy(stack, BalanceConfigHandler.draconicArmorEnergyToRemoveEffects, false); - } - if (player.worldObj.getBlockLightValue((int)Math.floor(player.posX), (int) player.posY + 1, (int)Math.floor(player.posZ)) < 5 && IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorNVActive", false)) - { - player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 419, 0, true)); - } - else if ( IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorNVActive", false) && IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorNVLock", true)) player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 419, 0, true)); - else if (player.isPotionActive(Potion.nightVision.id)) player.removePotionEffect(Potion.nightVision.id); + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { + if (stack == null) return; + if (stack.getItem() == ModItems.draconicHelm) { + if (world.isRemote) return; + if (this.getEnergyStored(stack) >= BalanceConfigHandler.draconicArmorEnergyToRemoveEffects && clearNegativeEffects(player)) { + this.extractEnergy(stack, BalanceConfigHandler.draconicArmorEnergyToRemoveEffects, false); + } + if (player.worldObj.getBlockLightValue((int) Math.floor(player.posX), (int) player.posY + 1, (int) Math.floor(player.posZ)) < 5 && IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorNVActive", false)) { + player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 419, 0, true)); + } else if (IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorNVActive", false) && IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorNVLock", true)) + player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 419, 0, true)); + else if (player.isPotionActive(Potion.nightVision.id)) player.removePotionEffect(Potion.nightVision.id); - } - } + } + } - @SuppressWarnings("unchecked") - @SideOnly(Side.CLIENT) - @Override - public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) { - InfoHelper.addEnergyAndLore(stack, list); - ToolBase.holdCTRLForUpgrades(list, stack); - } + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + @Override + public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) { + InfoHelper.addEnergyAndLore(stack, list); + ToolBase.holdCTRLForUpgrades(list, stack); + } - @SuppressWarnings("unchecked") - public boolean clearNegativeEffects(Entity par3Entity) { - boolean flag = false; - if (par3Entity.ticksExisted % 20 == 0) { - if (par3Entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) par3Entity; + @SuppressWarnings("unchecked") + public boolean clearNegativeEffects(Entity par3Entity) { + boolean flag = false; + if (par3Entity.ticksExisted % 20 == 0) { + if (par3Entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) par3Entity; - Collection potions = player.getActivePotionEffects(); + Collection potions = player.getActivePotionEffects(); - if (player.isBurning()) { - player.extinguish(); - /* + if (player.isBurning()) { + player.extinguish(); + /* * Wyvern Armor doesn't require energy to extinguish player => Draconic Armor shouldn't require. * See CustomArmorHandler.applyArmorDamageBlocking * */ - //flag = false; - } - for (PotionEffect potion : potions) { - int id = potion.getPotionID(); - if (ReflectionHelper.getPrivateValue(Potion.class, Potion.potionTypes[id], new String[]{"isBadEffect", "field_76418_K", "J"})) { - if (potion.getPotionID() == Potion.digSlowdown.id && ModHelper.isHoldingCleaver(player)) break; - if ((player.getHeldItem() == null || (player.getHeldItem().getItem() != ModItems.wyvernBow && player.getHeldItem().getItem() != ModItems.draconicBow)) || id != 2) { - player.removePotionEffect(id); - flag = true; - } - break; - } - } - } - } - return flag; - } + //flag = false; + } + for (PotionEffect potion : potions) { + int id = potion.getPotionID(); + if (ReflectionHelper.getPrivateValue(Potion.class, Potion.potionTypes[id], new String[]{"isBadEffect", "field_76418_K", "J"})) { + if (potion.getPotionID() == Potion.digSlowdown.id && ModHelper.isHoldingCleaver(player)) break; + if ((player.getHeldItem() == null || (player.getHeldItem().getItem() != ModItems.wyvernBow && player.getHeldItem().getItem() != ModItems.draconicBow)) || id != 2) { + player.removePotionEffect(id); + flag = true; + } + break; + } + } + } + } + return flag; + } - /* IEnergyContainerItem */ - @Override - public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { - int stored = ItemNBTHelper.getInteger(container, "Energy", 0); - int receive = Math.min(maxReceive, Math.min(getMaxEnergyStored(container) - stored, maxTransfer)); + /* IEnergyContainerItem */ + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + int stored = ItemNBTHelper.getInteger(container, "Energy", 0); + int receive = Math.min(maxReceive, Math.min(getMaxEnergyStored(container) - stored, maxTransfer)); - if (!simulate) { - stored += receive; - ItemNBTHelper.setInteger(container, "Energy", stored); - } - return receive; - } + if (!simulate) { + stored += receive; + ItemNBTHelper.setInteger(container, "Energy", stored); + } + return receive; + } - @Override - public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { - int stored = ItemNBTHelper.getInteger(container, "Energy", 0); - int extract = Math.min(maxExtract, Math.min(maxTransfer, stored)); + int stored = ItemNBTHelper.getInteger(container, "Energy", 0); + int extract = Math.min(maxExtract, Math.min(maxTransfer, stored)); - if (!simulate) { - stored -= extract; - ItemNBTHelper.setInteger(container, "Energy", stored); - } - return extract; - } + if (!simulate) { + stored -= extract; + ItemNBTHelper.setInteger(container, "Energy", stored); + } + return extract; + } - @Override - public int getEnergyStored(ItemStack container) { - return ItemNBTHelper.getInteger(container, "Energy", 0); - } + @Override + public int getEnergyStored(ItemStack container) { + return ItemNBTHelper.getInteger(container, "Energy", 0); + } - @Override - public int getMaxEnergyStored(ItemStack container) { - int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(container); - return BalanceConfigHandler.draconicArmorBaseStorage + points * BalanceConfigHandler.draconicArmorStoragePerUpgrade; - } + @Override + public int getMaxEnergyStored(ItemStack container) { + int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(container); + return BalanceConfigHandler.draconicArmorBaseStorage + points * BalanceConfigHandler.draconicArmorStoragePerUpgrade; + } - /* Misc */ - @Override - public Entity createEntity(World world, Entity location, ItemStack itemstack) { - return new EntityPersistentItem(world, location, itemstack); - } + /* Misc */ + @Override + public Entity createEntity(World world, Entity location, ItemStack itemstack) { + return new EntityPersistentItem(world, location, itemstack); + } - @Override - public boolean hasCustomEntity(ItemStack stack) { - return true; - } + @Override + public boolean hasCustomEntity(ItemStack stack) { + return true; + } - @Override - public List getFields(ItemStack stack, int slot) { - List list = new ArrayList(); - if (armorType == 0) - { - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorNVActive").readFromItem(stack, false)); - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorNVLock").readFromItem(stack, true)); - if (Loader.isModLoaded("Thaumcraft"))list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "GogglesOfRevealing").readFromItem(stack, true)); - } - else if (armorType == 1) - { - list.add(new ItemConfigField(References.FLOAT_ID, slot, "VerticalAcceleration").setMinMaxAndIncromente(0f, 8f, 0.1f).readFromItem(stack, 0F).setModifier("PLUSPERCENT")); - list.add(new ItemConfigField(References.FLOAT_ID, slot, "ArmorFlightSpeedMult").setMinMaxAndIncromente(0f, 6f, 0.1f).readFromItem(stack, 0F).setModifier("PLUSPERCENT")); - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "EffectiveOnSprint").readFromItem(stack, false)); - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorFlightLock").readFromItem(stack, false)); - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorInertiaCancellation").readFromItem(stack, false)); - } - else if (armorType == 2) - { - list.add(new ItemConfigField(References.FLOAT_ID, slot, "ArmorSpeedMult").setMinMaxAndIncromente(0f, 8f, 0.1f).readFromItem(stack, 0F).setModifier("PLUSPERCENT")); - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorSprintOnly").readFromItem(stack, false)); - } - else if (armorType == 3) - { - list.add(new ItemConfigField(References.FLOAT_ID, slot, "ArmorJumpMult").setMinMaxAndIncromente(0f, 15f, 0.1f).readFromItem(stack, 0f).setModifier("PLUSPERCENT")); - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorSprintOnly").readFromItem(stack, false)); - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorHillStep").readFromItem(stack, true)); - } - return list; - } + @Override + public List getFields(ItemStack stack, int slot) { + List list = new ArrayList(); + if (armorType == 0) { + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorNVActive").readFromItem(stack, false)); + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorNVLock").readFromItem(stack, true)); + if (Loader.isModLoaded("Thaumcraft")) + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "GogglesOfRevealing").readFromItem(stack, true)); + } else if (armorType == 1) { + list.add(new ItemConfigField(References.FLOAT_ID, slot, "VerticalAcceleration").setMinMaxAndIncromente(0f, 8f, 0.1f).readFromItem(stack, 0F).setModifier("PLUSPERCENT")); + list.add(new ItemConfigField(References.FLOAT_ID, slot, "ArmorFlightSpeedMult").setMinMaxAndIncromente(0f, 6f, 0.1f).readFromItem(stack, 0F).setModifier("PLUSPERCENT")); + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "EffectiveOnSprint").readFromItem(stack, false)); + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorFlightLock").readFromItem(stack, false)); + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorInertiaCancellation").readFromItem(stack, false)); + } else if (armorType == 2) { + list.add(new ItemConfigField(References.FLOAT_ID, slot, "ArmorSpeedMult").setMinMaxAndIncromente(0f, 8f, 0.1f).readFromItem(stack, 0F).setModifier("PLUSPERCENT")); + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorSprintOnly").readFromItem(stack, false)); + } else if (armorType == 3) { + list.add(new ItemConfigField(References.FLOAT_ID, slot, "ArmorJumpMult").setMinMaxAndIncromente(0f, 15f, 0.1f).readFromItem(stack, 0f).setModifier("PLUSPERCENT")); + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorSprintOnly").readFromItem(stack, false)); + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorHillStep").readFromItem(stack, true)); + } + return list; + } - @Override - public String getInventoryName() { - return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); - } + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); + } - @Override - public int getInventorySlots() { - return 0; - } + @Override + public int getInventorySlots() { + return 0; + } - @Override - public boolean isEnchantValid(Enchantment enchant) { - return enchant.type == EnumEnchantmentType.armor || (armorType == 0 && enchant.type == EnumEnchantmentType.armor_head) || (armorType == 1 && enchant.type == EnumEnchantmentType.armor_torso) || (armorType == 2 && enchant.type == EnumEnchantmentType.armor_legs) || (armorType == 3 && enchant.type == EnumEnchantmentType.armor_feet); - } + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.armor || (armorType == 0 && enchant.type == EnumEnchantmentType.armor_head) || (armorType == 1 && enchant.type == EnumEnchantmentType.armor_torso) || (armorType == 2 && enchant.type == EnumEnchantmentType.armor_legs) || (armorType == 3 && enchant.type == EnumEnchantmentType.armor_feet); + } - @Optional.Method(modid = "Thaumcraft") - @Override - public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) { - return IConfigurableItem.ProfileHelper.getBoolean(itemstack, "GogglesOfRevealing", true); - } + @Optional.Method(modid = "Thaumcraft") + @Override + public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) { + return IConfigurableItem.ProfileHelper.getBoolean(itemstack, "GogglesOfRevealing", true); + } - @Optional.Method(modid = "Thaumcraft") - @Override - public boolean showNodes(ItemStack itemstack, EntityLivingBase player) { - return IConfigurableItem.ProfileHelper.getBoolean(itemstack, "GogglesOfRevealing", true); - } + @Optional.Method(modid = "Thaumcraft") + @Override + public boolean showNodes(ItemStack itemstack, EntityLivingBase player) { + return IConfigurableItem.ProfileHelper.getBoolean(itemstack, "GogglesOfRevealing", true); + } - @SideOnly(Side.CLIENT) - public ModelBiped model; + @SideOnly(Side.CLIENT) + public ModelBiped model; - @SideOnly(Side.CLIENT) - @Override - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { - if (ConfigHandler.useOldArmorModel) return super.getArmorModel(entityLiving, itemStack, armorSlot); + @SideOnly(Side.CLIENT) + @Override + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { + if (ConfigHandler.useOldArmorModel) return super.getArmorModel(entityLiving, itemStack, armorSlot); - if (!ConfigHandler.useOriginal3DArmorModel) - { - if (model == null) { - if (armorType == 0) model = new ModelDraconicArmor(1.1F, true, false, false, false); - else if (armorType == 1) model = new ModelDraconicArmor(1.1F, false, true, false, false); - else if (armorType == 2) model = new ModelDraconicArmor(1.1F, false, false, true, false); - else model = new ModelDraconicArmor(1.1F, false, false, false, true); - this.model.bipedHead.showModel = (armorType == 0); - this.model.bipedHeadwear.showModel = (armorType == 0); - this.model.bipedBody.showModel = ((armorType == 1) || (armorType == 2)); - this.model.bipedLeftArm.showModel = (armorType == 1); - this.model.bipedRightArm.showModel = (armorType == 1); - this.model.bipedLeftLeg.showModel = (armorType == 2 || armorType == 3); - this.model.bipedRightLeg.showModel = (armorType == 2 || armorType == 3); - } - } - else - { - if (model == null) { - if (armorType == 0) model = new ModelDraconicArmorOld(1.1F, true, false, false, false, true); - else if (armorType == 1) model = new ModelDraconicArmorOld(1.1F, false, true, false, false, true); - else if (armorType == 2) model = new ModelDraconicArmorOld(1.1F, false, false, true, false, true); - else model = new ModelDraconicArmorOld(1.1F, false, false, false, true, true); - this.model.bipedHead.showModel = (armorType == 0); - this.model.bipedHeadwear.showModel = (armorType == 0); - this.model.bipedBody.showModel = ((armorType == 1) || (armorType == 2)); - this.model.bipedLeftArm.showModel = (armorType == 1); - this.model.bipedRightArm.showModel = (armorType == 1); - this.model.bipedLeftLeg.showModel = (armorType == 2 || armorType == 3); - this.model.bipedRightLeg.showModel = (armorType == 2 || armorType == 3); - } - } + if (!ConfigHandler.useOriginal3DArmorModel) { + if (model == null) { + if (armorType == 0) model = new ModelDraconicArmor(1.1F, true, false, false, false); + else if (armorType == 1) model = new ModelDraconicArmor(1.1F, false, true, false, false); + else if (armorType == 2) model = new ModelDraconicArmor(1.1F, false, false, true, false); + else model = new ModelDraconicArmor(1.1F, false, false, false, true); + this.model.bipedHead.showModel = (armorType == 0); + this.model.bipedHeadwear.showModel = (armorType == 0); + this.model.bipedBody.showModel = ((armorType == 1) || (armorType == 2)); + this.model.bipedLeftArm.showModel = (armorType == 1); + this.model.bipedRightArm.showModel = (armorType == 1); + this.model.bipedLeftLeg.showModel = (armorType == 2 || armorType == 3); + this.model.bipedRightLeg.showModel = (armorType == 2 || armorType == 3); + } + } else { + if (model == null) { + if (armorType == 0) model = new ModelDraconicArmorOld(1.1F, true, false, false, false, true); + else if (armorType == 1) model = new ModelDraconicArmorOld(1.1F, false, true, false, false, true); + else if (armorType == 2) model = new ModelDraconicArmorOld(1.1F, false, false, true, false, true); + else model = new ModelDraconicArmorOld(1.1F, false, false, false, true, true); + this.model.bipedHead.showModel = (armorType == 0); + this.model.bipedHeadwear.showModel = (armorType == 0); + this.model.bipedBody.showModel = ((armorType == 1) || (armorType == 2)); + this.model.bipedLeftArm.showModel = (armorType == 1); + this.model.bipedRightArm.showModel = (armorType == 1); + this.model.bipedLeftLeg.showModel = (armorType == 2 || armorType == 3); + this.model.bipedRightLeg.showModel = (armorType == 2 || armorType == 3); + } + } - if (entityLiving == null) return model; + if (entityLiving == null) return model; - this.model.isSneak = entityLiving.isSneaking(); - this.model.isRiding = entityLiving.isRiding(); - this.model.isChild = entityLiving.isChild(); - this.model.aimedBow = false; - this.model.heldItemRight = (entityLiving.getHeldItem() != null ? 1 : 0); + this.model.isSneak = entityLiving.isSneaking(); + this.model.isRiding = entityLiving.isRiding(); + this.model.isChild = entityLiving.isChild(); + this.model.aimedBow = false; + this.model.heldItemRight = (entityLiving.getHeldItem() != null ? 1 : 0); - if ((entityLiving instanceof EntityPlayer)) - { - if (((EntityPlayer) entityLiving).getItemInUseDuration() > 0) - { - EnumAction enumaction = ((EntityPlayer) entityLiving).getItemInUse().getItemUseAction(); - if (enumaction == EnumAction.block) - { - this.model.heldItemRight = 3; - } else if (enumaction == EnumAction.bow) - { - this.model.aimedBow = true; - } - } - } + if ((entityLiving instanceof EntityPlayer)) { + if (((EntityPlayer) entityLiving).getItemInUseDuration() > 0) { + EnumAction enumaction = ((EntityPlayer) entityLiving).getItemInUse().getItemUseAction(); + if (enumaction == EnumAction.block) { + this.model.heldItemRight = 3; + } else if (enumaction == EnumAction.bow) { + this.model.aimedBow = true; + } + } + } - return model; - } + return model; + } - @Override - public List getUpgrades(ItemStack itemstack) { - return new ArrayList(){{ - add(EnumUpgrade.RF_CAPACITY); - add(EnumUpgrade.SHIELD_CAPACITY); - add(EnumUpgrade.SHIELD_RECOVERY); - // if (armorType == 2) add(EnumUpgrade.MOVE_SPEED); - // if (armorType == 3) add(EnumUpgrade.JUMP_BOOST); - }}; - } + @Override + public List getUpgrades(ItemStack itemstack) { + return new ArrayList() {{ + add(EnumUpgrade.RF_CAPACITY); + add(EnumUpgrade.SHIELD_CAPACITY); + add(EnumUpgrade.SHIELD_RECOVERY); + // if (armorType == 2) add(EnumUpgrade.MOVE_SPEED); + // if (armorType == 3) add(EnumUpgrade.JUMP_BOOST); + }}; + } - @Override - public int getUpgradeCap(ItemStack itemstack) { - return BalanceConfigHandler.draconicArmorMaxUpgrades; - } + @Override + public int getUpgradeCap(ItemStack itemstack) { + return BalanceConfigHandler.draconicArmorMaxUpgrades; + } - @Override - public int getMaxTier(ItemStack itemstack) { - return 2; - } + @Override + public int getMaxTier(ItemStack itemstack) { + return 2; + } - @Override - public List getUpgradeStats(ItemStack stack) { - List strings = new ArrayList(); + @Override + public List getUpgradeStats(ItemStack stack) { + List strings = new ArrayList(); - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.RFCapacity.txt")+": "+InfoHelper.HITC()+ Utills.formatNumber(getMaxEnergyStored(stack))); - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.ShieldCapacity.txt")+": "+InfoHelper.HITC()+ (int)getProtectionPoints(stack)); - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.ShieldRecovery.txt") + ": " + InfoHelper.HITC() + Utills.round(getRecoveryPoints(stack) * 0.2D, 10)+" EPS"); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.RFCapacity.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getMaxEnergyStored(stack))); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.ShieldCapacity.txt") + ": " + InfoHelper.HITC() + (int) getProtectionPoints(stack)); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.ShieldRecovery.txt") + ": " + InfoHelper.HITC() + Utills.round(getRecoveryPoints(stack) * 0.2D, 10) + " EPS"); - return strings; - } + return strings; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { - return BalanceConfigHandler.draconicArmorMaxCapacityUpgradePoints; - } - return BalanceConfigHandler.draconicArmorMaxUpgradePoints; - } + @Override + public int getMaxUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { + return BalanceConfigHandler.draconicArmorMaxCapacityUpgradePoints; + } + return BalanceConfigHandler.draconicArmorMaxUpgradePoints; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) - { - return getMaxUpgradePoints(upgradeIndex); - } + @Override + public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) { + return getMaxUpgradePoints(upgradeIndex); + } - @Override - public int getBaseUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.SHIELD_CAPACITY.index) { - return (int)(getProtectionShare() * 25) + (armorType == 2 ? 2 : 0); - } - if (upgradeIndex == EnumUpgrade.SHIELD_RECOVERY.index) { - return BalanceConfigHandler.draconicArmorMinShieldRecovery; - } - return 0; - } + @Override + public int getBaseUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.SHIELD_CAPACITY.index) { + return (int) (getProtectionShare() * 25) + (armorType == 2 ? 2 : 0); + } + if (upgradeIndex == EnumUpgrade.SHIELD_RECOVERY.index) { + return BalanceConfigHandler.draconicArmorMinShieldRecovery; + } + return 0; + } - //region//----------------- ICustomArmor Start -----------------// + //region//----------------- ICustomArmor Start -----------------// - @Override - public float getProtectionPoints(ItemStack stack) { - return EnumUpgrade.SHIELD_CAPACITY.getUpgradePoints(stack) * 20; - } + @Override + public float getProtectionPoints(ItemStack stack) { + return EnumUpgrade.SHIELD_CAPACITY.getUpgradePoints(stack) * 20; + } - @Override - public int getRecoveryPoints(ItemStack stack) { - return EnumUpgrade.SHIELD_RECOVERY.getUpgradePoints(stack); - } + @Override + public int getRecoveryPoints(ItemStack stack) { + return EnumUpgrade.SHIELD_RECOVERY.getUpgradePoints(stack); + } - @Override - public float getSpeedModifier(ItemStack stack, EntityPlayer player) { - if (IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorSprintOnly", false)){ - return player.isSprinting() ? IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorSpeedMult", 0f) : IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorSpeedMult", 0f) / 5F; - } - else return IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorSpeedMult", 0f); - } + @Override + public float getSpeedModifier(ItemStack stack, EntityPlayer player) { + if (IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorSprintOnly", false)) { + return player.isSprinting() ? IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorSpeedMult", 0f) : IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorSpeedMult", 0f) / 5F; + } else return IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorSpeedMult", 0f); + } - @Override - public float getJumpModifier(ItemStack stack, EntityPlayer player) { - if (IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorSprintOnly", false)){ - return player.isSprinting() || BrandonsCore.proxy.isCtrlDown() ? IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorJumpMult", 0f) : IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorJumpMult", 0f) / 5F; - } - else return IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorJumpMult", 0f); - } + @Override + public float getJumpModifier(ItemStack stack, EntityPlayer player) { + if (IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorSprintOnly", false)) { + return player.isSprinting() || BrandonsCore.proxy.isCtrlDown() ? IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorJumpMult", 0f) : IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorJumpMult", 0f) / 5F; + } else return IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorJumpMult", 0f); + } - @Override - public boolean hasHillStep(ItemStack stack, EntityPlayer player) { - if (IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorSprintOnly", false)){ - return (player.isSprinting() || BrandonsCore.proxy.isCtrlDown()) && IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorHillStep", true); - } - else return IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorHillStep", true); - } + @Override + public boolean hasHillStep(ItemStack stack, EntityPlayer player) { + if (IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorSprintOnly", false)) { + return (player.isSprinting() || BrandonsCore.proxy.isCtrlDown()) && IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorHillStep", true); + } else return IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorHillStep", true); + } - @Override - public float getFireResistance(ItemStack stack) { - return 1F; - } + @Override + public float getFireResistance(ItemStack stack) { + return 1F; + } - @Override - public boolean[] hasFlight(ItemStack stack) { - return new boolean[] {true, IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorFlightLock", false), IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorInertiaCancellation", false)}; - } + @Override + public boolean[] hasFlight(ItemStack stack) { + return new boolean[]{true, IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorFlightLock", false), IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorInertiaCancellation", false)}; + } - @Override - public float getFlightSpeedModifier(ItemStack stack, EntityPlayer player) { - if (IConfigurableItem.ProfileHelper.getBoolean(stack, "EffectiveOnSprint", false)){ - return BrandonsCore.proxy.isCtrlDown() ? IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorFlightSpeedMult", 0f) : 0F; - } - else return IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorFlightSpeedMult", 0f); - } + @Override + public float getFlightSpeedModifier(ItemStack stack, EntityPlayer player) { + if (IConfigurableItem.ProfileHelper.getBoolean(stack, "EffectiveOnSprint", false)) { + return BrandonsCore.proxy.isCtrlDown() ? IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorFlightSpeedMult", 0f) : 0F; + } else return IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorFlightSpeedMult", 0f); + } - @Override - public float getFlightVModifier(ItemStack stack, EntityPlayer player) { - if (IConfigurableItem.ProfileHelper.getBoolean(stack, "EffectiveOnSprint", false)){ - return BrandonsCore.proxy.isCtrlDown() ? IConfigurableItem.ProfileHelper.getFloat(stack, "VerticalAcceleration", 0F) : 0F; - } - else return IConfigurableItem.ProfileHelper.getFloat(stack, "VerticalAcceleration", 0F); - } - @Override - public int getEnergyPerProtectionPoint() - { - return BalanceConfigHandler.draconicArmorEnergyPerProtectionPoint; - } + @Override + public float getFlightVModifier(ItemStack stack, EntityPlayer player) { + if (IConfigurableItem.ProfileHelper.getBoolean(stack, "EffectiveOnSprint", false)) { + return BrandonsCore.proxy.isCtrlDown() ? IConfigurableItem.ProfileHelper.getFloat(stack, "VerticalAcceleration", 0F) : 0F; + } else return IConfigurableItem.ProfileHelper.getFloat(stack, "VerticalAcceleration", 0F); + } - //endregion + @Override + public int getEnergyPerProtectionPoint() { + return BalanceConfigHandler.draconicArmorEnergyPerProtectionPoint; + } - @Override - public boolean hasProfiles() { - return false; - } + //endregion + + @Override + public boolean hasProfiles() { + return false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernArmor.java b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernArmor.java index b858de1c..e9a60e5d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernArmor.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernArmor.java @@ -42,407 +42,398 @@ import net.minecraftforge.common.ISpecialArmor; * Created by Brandon on 3/07/2014. */ public class WyvernArmor extends ItemArmor implements ISpecialArmor, IConfigurableItem, IInventoryTool, IUpgradableItem, ICustomArmor { - @SideOnly(Side.CLIENT) - private IIcon helmIcon; - @SideOnly(Side.CLIENT) - private IIcon chestIcon; - @SideOnly(Side.CLIENT) - private IIcon leggsIcon; - @SideOnly(Side.CLIENT) - private IIcon bootsIcon; + @SideOnly(Side.CLIENT) + private IIcon helmIcon; + @SideOnly(Side.CLIENT) + private IIcon chestIcon; + @SideOnly(Side.CLIENT) + private IIcon leggsIcon; + @SideOnly(Side.CLIENT) + private IIcon bootsIcon; - private int maxEnergy = BalanceConfigHandler.wyvernArmorBaseStorage; - private int maxTransfer = BalanceConfigHandler.wyvernArmorMaxTransfer; + private int maxEnergy = BalanceConfigHandler.wyvernArmorBaseStorage; + private int maxTransfer = BalanceConfigHandler.wyvernArmorMaxTransfer; - public WyvernArmor(ArmorMaterial material, int armorType, String name) { - super(material, 0, armorType); - this.setUnlocalizedName(name); - this.setCreativeTab(DraconicEvolution.tabToolsWeapons); - if (ModItems.isEnabled(this)) GameRegistry.registerItem(this, name); - } + public WyvernArmor(ArmorMaterial material, int armorType, String name) { + super(material, 0, armorType); + this.setUnlocalizedName(name); + this.setCreativeTab(DraconicEvolution.tabToolsWeapons); + if (ModItems.isEnabled(this)) GameRegistry.registerItem(this, name); + } - @Override - public boolean isItemTool(ItemStack p_77616_1_) { - return true; - } + @Override + public boolean isItemTool(ItemStack p_77616_1_) { + return true; + } - @SuppressWarnings("unchecked") - @Override - public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { - list.add(ItemNBTHelper.setInteger(new ItemStack(item), "Energy", 0)); - list.add(ItemNBTHelper.setInteger(new ItemStack(item), "Energy", maxEnergy)); - } + @SuppressWarnings("unchecked") + @Override + public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { + list.add(ItemNBTHelper.setInteger(new ItemStack(item), "Energy", 0)); + list.add(ItemNBTHelper.setInteger(new ItemStack(item), "Energy", maxEnergy)); + } - @Override - public String getUnlocalizedName(){ + @Override + public String getUnlocalizedName() { - return String.format("item.%s%s", References.MODID.toLowerCase() + ":", super.getUnlocalizedName().substring(super.getUnlocalizedName().indexOf(".") + 1)); - } + return String.format("item.%s%s", References.MODID.toLowerCase() + ":", super.getUnlocalizedName().substring(super.getUnlocalizedName().indexOf(".") + 1)); + } - @Override - public String getUnlocalizedName(final ItemStack itemStack){ - return getUnlocalizedName(); - } + @Override + public String getUnlocalizedName(final ItemStack itemStack) { + return getUnlocalizedName(); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister iconRegister) { - helmIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_helmet"); - chestIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_chestplate"); - leggsIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_leggings"); - bootsIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_boots"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + helmIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_helmet"); + chestIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_chestplate"); + leggsIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_leggings"); + bootsIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_boots"); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { - if (stack.getItem() == ModItems.wyvernHelm) return helmIcon; - else if (stack.getItem() == ModItems.wyvernChest) return chestIcon; - else if (stack.getItem() == ModItems.wyvernLeggs) return leggsIcon; - else return bootsIcon; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + if (stack.getItem() == ModItems.wyvernHelm) return helmIcon; + else if (stack.getItem() == ModItems.wyvernChest) return chestIcon; + else if (stack.getItem() == ModItems.wyvernLeggs) return leggsIcon; + else return bootsIcon; + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconIndex(ItemStack stack) { - if (stack.getItem() == ModItems.wyvernHelm) return helmIcon; - else if (stack.getItem() == ModItems.wyvernChest) return chestIcon; - else if (stack.getItem() == ModItems.wyvernLeggs) return leggsIcon; - else return bootsIcon; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconIndex(ItemStack stack) { + if (stack.getItem() == ModItems.wyvernHelm) return helmIcon; + else if (stack.getItem() == ModItems.wyvernChest) return chestIcon; + else if (stack.getItem() == ModItems.wyvernLeggs) return leggsIcon; + else return bootsIcon; + } - @Override - @SideOnly(Side.CLIENT) - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { - if (!ConfigHandler.useOldArmorModel) return References.RESOURCESPREFIX + "textures/models/armor/armorWyvern.png"; - if (stack.getItem() == ModItems.wyvernHelm || stack.getItem() == ModItems.wyvernChest || stack.getItem() == ModItems.wyvernBoots) { - return References.RESOURCESPREFIX + "textures/models/armor/wyvern_layer_1.png"; - } else { - return References.RESOURCESPREFIX + "textures/models/armor/wyvern_layer_2.png"; - } - } + @Override + @SideOnly(Side.CLIENT) + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + if (!ConfigHandler.useOldArmorModel) + return References.RESOURCESPREFIX + "textures/models/armor/armorWyvern.png"; + if (stack.getItem() == ModItems.wyvernHelm || stack.getItem() == ModItems.wyvernChest || stack.getItem() == ModItems.wyvernBoots) { + return References.RESOURCESPREFIX + "textures/models/armor/wyvern_layer_1.png"; + } else { + return References.RESOURCESPREFIX + "textures/models/armor/wyvern_layer_2.png"; + } + } - @Override - public EnumRarity getRarity(ItemStack p_77613_1_) { - return EnumRarity.uncommon; - } + @Override + public EnumRarity getRarity(ItemStack p_77613_1_) { + return EnumRarity.uncommon; + } - @Override - public double getDurabilityForDisplay(ItemStack stack) { - return 1D - (double)ItemNBTHelper.getInteger(stack, "Energy", 0) / (double)getMaxEnergyStored(stack); - } + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - (double) ItemNBTHelper.getInteger(stack, "Energy", 0) / (double) getMaxEnergyStored(stack); + } - @Override - public boolean showDurabilityBar(ItemStack stack) { - return getEnergyStored(stack) < getMaxEnergyStored(stack); - } + @Override + public boolean showDurabilityBar(ItemStack stack) { + return getEnergyStored(stack) < getMaxEnergyStored(stack); + } - protected float getProtectionShare() { - switch (armorType) { - case 0: - return 0.15F; - case 1: - return 0.40F; - case 2: - return 0.30F; - case 3: - return 0.15F; - } - return 0; - } + protected float getProtectionShare() { + switch (armorType) { + case 0: + return 0.15F; + case 1: + return 0.40F; + case 2: + return 0.30F; + case 3: + return 0.15F; + } + return 0; + } - //region ISpecialArmor - @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { - if (source.isUnblockable() || source.isDamageAbsolute() || source.isMagicDamage()) return new ArmorProperties(0, damageReduceAmount / 100D, 15); - return new ArmorProperties(0, damageReduceAmount / 25D, 1000); - } + //region ISpecialArmor + @Override + public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { + if (source.isUnblockable() || source.isDamageAbsolute() || source.isMagicDamage()) + return new ArmorProperties(0, damageReduceAmount / 100D, 15); + return new ArmorProperties(0, damageReduceAmount / 25D, 1000); + } - @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { - return (int)(getProtectionShare() * 20D); - } + @Override + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + return (int) (getProtectionShare() * 20D); + } - @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { - } - //endregion + @Override + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + } + //endregion - @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { - } + } - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) { - InfoHelper.addEnergyAndLore(stack, list); - ToolBase.holdCTRLForUpgrades(list, stack); - } + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) { + InfoHelper.addEnergyAndLore(stack, list); + ToolBase.holdCTRLForUpgrades(list, stack); + } - @Override - public boolean hasCustomEntity(ItemStack stack) { - return true; - } + @Override + public boolean hasCustomEntity(ItemStack stack) { + return true; + } - @Override - public Entity createEntity(World world, Entity location, ItemStack itemstack) { - return new EntityPersistentItem(world, location, itemstack); - } + @Override + public Entity createEntity(World world, Entity location, ItemStack itemstack) { + return new EntityPersistentItem(world, location, itemstack); + } - /* IEnergyContainerItem */ - @Override - public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { - int stored = ItemNBTHelper.getInteger(container, "Energy", 0); - int receive = Math.min(maxReceive, Math.min(getMaxEnergyStored(container) - stored, maxTransfer)); + /* IEnergyContainerItem */ + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + int stored = ItemNBTHelper.getInteger(container, "Energy", 0); + int receive = Math.min(maxReceive, Math.min(getMaxEnergyStored(container) - stored, maxTransfer)); - if (!simulate) { - stored += receive; - ItemNBTHelper.setInteger(container, "Energy", stored); - } - return receive; - } + if (!simulate) { + stored += receive; + ItemNBTHelper.setInteger(container, "Energy", stored); + } + return receive; + } - @Override - public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { - int stored = ItemNBTHelper.getInteger(container, "Energy", 0); - int extract = Math.min(maxExtract, Math.min(maxTransfer, stored)); + int stored = ItemNBTHelper.getInteger(container, "Energy", 0); + int extract = Math.min(maxExtract, Math.min(maxTransfer, stored)); - if (!simulate) { - stored -= extract; - ItemNBTHelper.setInteger(container, "Energy", stored); - } - return extract; - } + if (!simulate) { + stored -= extract; + ItemNBTHelper.setInteger(container, "Energy", stored); + } + return extract; + } - @Override - public int getEnergyStored(ItemStack container) { - return ItemNBTHelper.getInteger(container, "Energy", 0); - } + @Override + public int getEnergyStored(ItemStack container) { + return ItemNBTHelper.getInteger(container, "Energy", 0); + } - @Override - public int getMaxEnergyStored(ItemStack container) { - int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(container); - return BalanceConfigHandler.wyvernArmorBaseStorage + points * BalanceConfigHandler.wyvernArmorStoragePerUpgrade; - } + @Override + public int getMaxEnergyStored(ItemStack container) { + int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(container); + return BalanceConfigHandler.wyvernArmorBaseStorage + points * BalanceConfigHandler.wyvernArmorStoragePerUpgrade; + } - @Override - public List getFields(ItemStack stack, int slot) { - List list = new ArrayList(); - if (armorType == 2) - { - list.add(new ItemConfigField(References.FLOAT_ID, slot, "ArmorSpeedMult").setMinMaxAndIncromente(0f, 5f, 0.1f).readFromItem(stack, 0F).setModifier("PLUSPERCENT")); - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorSprintOnly").readFromItem(stack, false)); - } - else if (armorType == 3) - { - list.add(new ItemConfigField(References.FLOAT_ID, slot, "ArmorJumpMult").setMinMaxAndIncromente(0f, 5f, 0.1f).readFromItem(stack, 0f).setModifier("PLUSPERCENT")); - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorSprintOnly").readFromItem(stack, false)); - } - return list; - } + @Override + public List getFields(ItemStack stack, int slot) { + List list = new ArrayList(); + if (armorType == 2) { + list.add(new ItemConfigField(References.FLOAT_ID, slot, "ArmorSpeedMult").setMinMaxAndIncromente(0f, 5f, 0.1f).readFromItem(stack, 0F).setModifier("PLUSPERCENT")); + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorSprintOnly").readFromItem(stack, false)); + } else if (armorType == 3) { + list.add(new ItemConfigField(References.FLOAT_ID, slot, "ArmorJumpMult").setMinMaxAndIncromente(0f, 5f, 0.1f).readFromItem(stack, 0f).setModifier("PLUSPERCENT")); + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "ArmorSprintOnly").readFromItem(stack, false)); + } + return list; + } - @Override - public String getInventoryName() { - return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); - } + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); + } - @Override - public int getInventorySlots() { - return 0; - } + @Override + public int getInventorySlots() { + return 0; + } - @Override - public boolean isEnchantValid(Enchantment enchant) { - return enchant.type == EnumEnchantmentType.armor || (armorType == 0 && enchant.type == EnumEnchantmentType.armor_head) || (armorType == 1 && enchant.type == EnumEnchantmentType.armor_torso) || (armorType == 2 && enchant.type == EnumEnchantmentType.armor_legs) || (armorType == 3 && enchant.type == EnumEnchantmentType.armor_feet); - } + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.armor || (armorType == 0 && enchant.type == EnumEnchantmentType.armor_head) || (armorType == 1 && enchant.type == EnumEnchantmentType.armor_torso) || (armorType == 2 && enchant.type == EnumEnchantmentType.armor_legs) || (armorType == 3 && enchant.type == EnumEnchantmentType.armor_feet); + } - @SideOnly(Side.CLIENT) - private ModelBiped model; + @SideOnly(Side.CLIENT) + private ModelBiped model; - @SideOnly(Side.CLIENT) - @Override - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { - if (ConfigHandler.useOldArmorModel) return super.getArmorModel(entityLiving, itemStack, armorSlot); + @SideOnly(Side.CLIENT) + @Override + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { + if (ConfigHandler.useOldArmorModel) return super.getArmorModel(entityLiving, itemStack, armorSlot); - if (!ConfigHandler.useOriginal3DArmorModel) { - if (model == null) { - if (armorType == 0) model = new ModelWyvernArmor(1.0F, true, false, false, false); - else if (armorType == 1) model = new ModelWyvernArmor(1F, false, true, false, false); - else if (armorType == 2) model = new ModelWyvernArmor(1F, false, false, true, false); - else model = new ModelWyvernArmor(1F, false, false, false, true); - this.model.bipedHead.showModel = (armorType == 0); - this.model.bipedHeadwear.showModel = (armorType == 0); - this.model.bipedBody.showModel = ((armorType == 1) || (armorType == 2)); - this.model.bipedLeftArm.showModel = (armorType == 1); - this.model.bipedRightArm.showModel = (armorType == 1); - this.model.bipedLeftLeg.showModel = (armorType == 2 || armorType == 3); - this.model.bipedRightLeg.showModel = (armorType == 2 || armorType == 3); - } - } - else { - if (model == null) { - if (armorType == 0) model = new ModelDraconicArmorOld(1.0F, true, false, false, false, false); - else if (armorType == 1) model = new ModelDraconicArmorOld(1F, false, true, false, false, false); - else if (armorType == 2) model = new ModelDraconicArmorOld(1F, false, false, true, false, false); - else model = new ModelDraconicArmorOld(1F, false, false, false, true, false); + if (!ConfigHandler.useOriginal3DArmorModel) { + if (model == null) { + if (armorType == 0) model = new ModelWyvernArmor(1.0F, true, false, false, false); + else if (armorType == 1) model = new ModelWyvernArmor(1F, false, true, false, false); + else if (armorType == 2) model = new ModelWyvernArmor(1F, false, false, true, false); + else model = new ModelWyvernArmor(1F, false, false, false, true); + this.model.bipedHead.showModel = (armorType == 0); + this.model.bipedHeadwear.showModel = (armorType == 0); + this.model.bipedBody.showModel = ((armorType == 1) || (armorType == 2)); + this.model.bipedLeftArm.showModel = (armorType == 1); + this.model.bipedRightArm.showModel = (armorType == 1); + this.model.bipedLeftLeg.showModel = (armorType == 2 || armorType == 3); + this.model.bipedRightLeg.showModel = (armorType == 2 || armorType == 3); + } + } else { + if (model == null) { + if (armorType == 0) model = new ModelDraconicArmorOld(1.0F, true, false, false, false, false); + else if (armorType == 1) model = new ModelDraconicArmorOld(1F, false, true, false, false, false); + else if (armorType == 2) model = new ModelDraconicArmorOld(1F, false, false, true, false, false); + else model = new ModelDraconicArmorOld(1F, false, false, false, true, false); - this.model.bipedHead.showModel = (armorType == 0); - this.model.bipedHeadwear.showModel = (armorType == 0); - this.model.bipedBody.showModel = ((armorType == 1) || (armorType == 2)); - this.model.bipedLeftArm.showModel = (armorType == 1); - this.model.bipedRightArm.showModel = (armorType == 1); - this.model.bipedLeftLeg.showModel = (armorType == 2 || armorType == 3); - this.model.bipedRightLeg.showModel = (armorType == 2 || armorType == 3); - } - } + this.model.bipedHead.showModel = (armorType == 0); + this.model.bipedHeadwear.showModel = (armorType == 0); + this.model.bipedBody.showModel = ((armorType == 1) || (armorType == 2)); + this.model.bipedLeftArm.showModel = (armorType == 1); + this.model.bipedRightArm.showModel = (armorType == 1); + this.model.bipedLeftLeg.showModel = (armorType == 2 || armorType == 3); + this.model.bipedRightLeg.showModel = (armorType == 2 || armorType == 3); + } + } - if (entityLiving == null) return model; + if (entityLiving == null) return model; - this.model.isSneak = entityLiving.isSneaking(); - this.model.isRiding = entityLiving.isRiding(); - this.model.isChild = entityLiving.isChild(); - this.model.aimedBow = false; - this.model.heldItemRight = (entityLiving.getHeldItem() != null ? 1 : 0); + this.model.isSneak = entityLiving.isSneaking(); + this.model.isRiding = entityLiving.isRiding(); + this.model.isChild = entityLiving.isChild(); + this.model.aimedBow = false; + this.model.heldItemRight = (entityLiving.getHeldItem() != null ? 1 : 0); - if ((entityLiving instanceof EntityPlayer)) - { - if (((EntityPlayer) entityLiving).getItemInUseDuration() > 0) - { - EnumAction enumaction = ((EntityPlayer) entityLiving).getItemInUse().getItemUseAction(); - if (enumaction == EnumAction.block) - { - this.model.heldItemRight = 3; - } else if (enumaction == EnumAction.bow) - { - this.model.aimedBow = true; - } - } - } + if ((entityLiving instanceof EntityPlayer)) { + if (((EntityPlayer) entityLiving).getItemInUseDuration() > 0) { + EnumAction enumaction = ((EntityPlayer) entityLiving).getItemInUse().getItemUseAction(); + if (enumaction == EnumAction.block) { + this.model.heldItemRight = 3; + } else if (enumaction == EnumAction.bow) { + this.model.aimedBow = true; + } + } + } - return model; - } + return model; + } - @Override - public List getUpgrades(ItemStack itemstack) { - return new ArrayList(){{ - add(EnumUpgrade.RF_CAPACITY); - add(EnumUpgrade.SHIELD_CAPACITY); - add(EnumUpgrade.SHIELD_RECOVERY); - // if (armorType == 2) add(EnumUpgrade.MOVE_SPEED); - // if (armorType == 3) add(EnumUpgrade.JUMP_BOOST); - }}; - } + @Override + public List getUpgrades(ItemStack itemstack) { + return new ArrayList() {{ + add(EnumUpgrade.RF_CAPACITY); + add(EnumUpgrade.SHIELD_CAPACITY); + add(EnumUpgrade.SHIELD_RECOVERY); + // if (armorType == 2) add(EnumUpgrade.MOVE_SPEED); + // if (armorType == 3) add(EnumUpgrade.JUMP_BOOST); + }}; + } - @Override - public int getUpgradeCap(ItemStack itemstack) { - return BalanceConfigHandler.wyvernArmorMaxUpgrades; - } + @Override + public int getUpgradeCap(ItemStack itemstack) { + return BalanceConfigHandler.wyvernArmorMaxUpgrades; + } - @Override - public int getMaxTier(ItemStack itemstack) { - return 1; - } + @Override + public int getMaxTier(ItemStack itemstack) { + return 1; + } - @Override - public List getUpgradeStats(ItemStack stack) { - List strings = new ArrayList(); + @Override + public List getUpgradeStats(ItemStack stack) { + List strings = new ArrayList(); - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.RFCapacity.txt")+": "+InfoHelper.HITC()+ Utills.formatNumber(getMaxEnergyStored(stack))); - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.ShieldCapacity.txt")+": "+InfoHelper.HITC()+ (int)getProtectionPoints(stack)); - strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.ShieldRecovery.txt") + ": " + InfoHelper.HITC() + Utills.round(getRecoveryPoints(stack) * 0.2D, 10)+" EPS"); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.RFCapacity.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getMaxEnergyStored(stack))); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.ShieldCapacity.txt") + ": " + InfoHelper.HITC() + (int) getProtectionPoints(stack)); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.ShieldRecovery.txt") + ": " + InfoHelper.HITC() + Utills.round(getRecoveryPoints(stack) * 0.2D, 10) + " EPS"); - return strings; - } + return strings; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { - return BalanceConfigHandler.wyvernArmorMaxCapacityUpgradePoints; - } - return BalanceConfigHandler.wyvernArmorMaxUpgradePoints; - } + @Override + public int getMaxUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { + return BalanceConfigHandler.wyvernArmorMaxCapacityUpgradePoints; + } + return BalanceConfigHandler.wyvernArmorMaxUpgradePoints; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) - { - return getMaxUpgradePoints(upgradeIndex); - } + @Override + public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) { + return getMaxUpgradePoints(upgradeIndex); + } - @Override - public int getBaseUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.SHIELD_CAPACITY.index) { - return (int)(getProtectionShare() * 10) + (armorType == 2 ? 1 : 0); - } - if (upgradeIndex == EnumUpgrade.SHIELD_RECOVERY.index) { - return BalanceConfigHandler.wyvernArmorMinShieldRecovery; - } - return 0; - } + @Override + public int getBaseUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.SHIELD_CAPACITY.index) { + return (int) (getProtectionShare() * 10) + (armorType == 2 ? 1 : 0); + } + if (upgradeIndex == EnumUpgrade.SHIELD_RECOVERY.index) { + return BalanceConfigHandler.wyvernArmorMinShieldRecovery; + } + return 0; + } - //region//----------------- ICustomArmor Start -----------------// - @Override - public float getProtectionPoints(ItemStack stack) { - return EnumUpgrade.SHIELD_CAPACITY.getUpgradePoints(stack) * 20F; - } + //region//----------------- ICustomArmor Start -----------------// + @Override + public float getProtectionPoints(ItemStack stack) { + return EnumUpgrade.SHIELD_CAPACITY.getUpgradePoints(stack) * 20F; + } - @Override - public int getRecoveryPoints(ItemStack stack) { - return EnumUpgrade.SHIELD_RECOVERY.getUpgradePoints(stack); - } + @Override + public int getRecoveryPoints(ItemStack stack) { + return EnumUpgrade.SHIELD_RECOVERY.getUpgradePoints(stack); + } - @Override - public float getSpeedModifier(ItemStack stack, EntityPlayer player) { - if (IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorSprintOnly", false)){ - return player.isSprinting() ? IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorSpeedMult", 0f) : IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorSpeedMult", 0f) / 5F; - } - else return IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorSpeedMult", 0f); - } + @Override + public float getSpeedModifier(ItemStack stack, EntityPlayer player) { + if (IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorSprintOnly", false)) { + return player.isSprinting() ? IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorSpeedMult", 0f) : IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorSpeedMult", 0f) / 5F; + } else return IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorSpeedMult", 0f); + } - @Override - public float getJumpModifier(ItemStack stack, EntityPlayer player) { - if (IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorSprintOnly", false)){ - return player.isSprinting() || BrandonsCore.proxy.isCtrlDown() ? IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorJumpMult", 0f) : IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorJumpMult", 0f) / 5F; - } - else return IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorJumpMult", 0f); - } + @Override + public float getJumpModifier(ItemStack stack, EntityPlayer player) { + if (IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorSprintOnly", false)) { + return player.isSprinting() || BrandonsCore.proxy.isCtrlDown() ? IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorJumpMult", 0f) : IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorJumpMult", 0f) / 5F; + } else return IConfigurableItem.ProfileHelper.getFloat(stack, "ArmorJumpMult", 0f); + } - @Override - public boolean hasHillStep(ItemStack stack, EntityPlayer player) { - return false; - } + @Override + public boolean hasHillStep(ItemStack stack, EntityPlayer player) { + return false; + } - @Override - public float getFireResistance(ItemStack stack) { - return getProtectionShare(); - } + @Override + public float getFireResistance(ItemStack stack) { + return getProtectionShare(); + } - @Override - public boolean[] hasFlight(ItemStack stack) { - return new boolean[] {false, false, false}; - } + @Override + public boolean[] hasFlight(ItemStack stack) { + return new boolean[]{false, false, false}; + } - @Override - public float getFlightSpeedModifier(ItemStack stack, EntityPlayer player) { - return 0; - } + @Override + public float getFlightSpeedModifier(ItemStack stack, EntityPlayer player) { + return 0; + } - @Override - public float getFlightVModifier(ItemStack stack, EntityPlayer player) { - return 0; - } - @Override - public int getEnergyPerProtectionPoint() - { - return BalanceConfigHandler.wyvernArmorEnergyPerProtectionPoint; - } + @Override + public float getFlightVModifier(ItemStack stack, EntityPlayer player) { + return 0; + } - //endregion + @Override + public int getEnergyPerProtectionPoint() { + return BalanceConfigHandler.wyvernArmorEnergyPerProtectionPoint; + } - @Override - public boolean hasProfiles() { - return false; - } + //endregion + + @Override + public boolean hasProfiles() { + return false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/AdminSpawnEgg.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/AdminSpawnEgg.java index 92da09d0..9d5284cd 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/AdminSpawnEgg.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/AdminSpawnEgg.java @@ -25,87 +25,88 @@ import java.util.List; * Created by Brandon on 25/09/2014. */ public class AdminSpawnEgg extends ItemDE { - public AdminSpawnEgg() { - this.setUnlocalizedName(Strings.adminSpawnEggName); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - ModItems.register(this); - } + public AdminSpawnEgg() { + this.setUnlocalizedName(Strings.adminSpawnEggName); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + ModItems.register(this); + } - public String getItemStackDisplayName(ItemStack stack) { - NBTTagCompound compound = (NBTTagCompound)ItemNBTHelper.getCompound(stack).copy(); - if (compound == null) return null; - String name = compound.getString("EntityName"); - return "Spawn " + name; - } + public String getItemStackDisplayName(ItemStack stack) { + NBTTagCompound compound = (NBTTagCompound) ItemNBTHelper.getCompound(stack).copy(); + if (compound == null) return null; + String name = compound.getString("EntityName"); + return "Spawn " + name; + } - @Override - public void registerIcons(IIconRegister iconRegister) { - itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX+"admin_egg"); - } + @Override + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "admin_egg"); + } - @Override - public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) { - ItemStack stack1 = player.getHeldItem(); - if (stack1 == null) return false; - if (ItemNBTHelper.getBoolean(stack1, "IsSet", false)) return false; - NBTTagCompound compound = ItemNBTHelper.getCompound(stack1); - entity.writeToNBT(compound); - compound.setString("EntityName", EntityList.getEntityString(entity)); - stack1.setTagCompound(compound); - ItemNBTHelper.setBoolean(stack1, "IsSet", true); - return true; - } + @Override + public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) { + ItemStack stack1 = player.getHeldItem(); + if (stack1 == null) return false; + if (ItemNBTHelper.getBoolean(stack1, "IsSet", false)) return false; + NBTTagCompound compound = ItemNBTHelper.getCompound(stack1); + entity.writeToNBT(compound); + compound.setString("EntityName", EntityList.getEntityString(entity)); + stack1.setTagCompound(compound); + ItemNBTHelper.setBoolean(stack1, "IsSet", true); + return true; + } - @Override - public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { - ItemStack stack1 = player.getHeldItem(); - if (stack1 == null) return true; - if (ItemNBTHelper.getBoolean(stack1, "IsSet", false)) return true; - NBTTagCompound compound = ItemNBTHelper.getCompound(stack1); - entity.writeToNBT(compound); - if (EntityList.getEntityString(entity) != null)compound.setString("EntityName", EntityList.getEntityString(entity)); - stack1.setTagCompound(compound); - ItemNBTHelper.setBoolean(stack1, "IsSet", true); - entity.setDead(); - return true; - } + @Override + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { + ItemStack stack1 = player.getHeldItem(); + if (stack1 == null) return true; + if (ItemNBTHelper.getBoolean(stack1, "IsSet", false)) return true; + NBTTagCompound compound = ItemNBTHelper.getCompound(stack1); + entity.writeToNBT(compound); + if (EntityList.getEntityString(entity) != null) + compound.setString("EntityName", EntityList.getEntityString(entity)); + stack1.setTagCompound(compound); + ItemNBTHelper.setBoolean(stack1, "IsSet", true); + entity.setDead(); + return true; + } - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float p_77648_8_, float p_77648_9_, float p_77648_10_) { - NBTTagCompound compound = (NBTTagCompound)ItemNBTHelper.getCompound(stack).copy(); + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float p_77648_8_, float p_77648_9_, float p_77648_10_) { + NBTTagCompound compound = (NBTTagCompound) ItemNBTHelper.getCompound(stack).copy(); - if (compound == null) return false; + if (compound == null) return false; - String name = compound.getString("EntityName"); + String name = compound.getString("EntityName"); - Entity entity = EntityList.createEntityByName(name, world); - compound.removeTag("EntityName"); - compound.removeTag("IsSet"); - if (entity instanceof EntityLivingBase) ((EntityLivingBase)entity).readFromNBT(compound); - double sX = x + ForgeDirection.getOrientation(side).offsetX + 0.5; - double sY = y + ForgeDirection.getOrientation(side).offsetY + 0.5; - double sZ = z + ForgeDirection.getOrientation(side).offsetZ + 0.5; - if (entity == null) { - LogHelper.error("bound entity = null"); - return false; - } - entity.setLocationAndAngles(sX, sY, sZ, player.rotationYaw, 0F); + Entity entity = EntityList.createEntityByName(name, world); + compound.removeTag("EntityName"); + compound.removeTag("IsSet"); + if (entity instanceof EntityLivingBase) ((EntityLivingBase) entity).readFromNBT(compound); + double sX = x + ForgeDirection.getOrientation(side).offsetX + 0.5; + double sY = y + ForgeDirection.getOrientation(side).offsetY + 0.5; + double sZ = z + ForgeDirection.getOrientation(side).offsetZ + 0.5; + if (entity == null) { + LogHelper.error("bound entity = null"); + return false; + } + entity.setLocationAndAngles(sX, sY, sZ, player.rotationYaw, 0F); - if (entity instanceof EntityLivingBase && !world.isRemote) { - world.spawnEntityInWorld(entity); - if (!player.capabilities.isCreativeMode) - { - stack.stackSize--; - } - } - return true; - } + if (entity instanceof EntityLivingBase && !world.isRemote) { + world.spawnEntityInWorld(entity); + if (!player.capabilities.isCreativeMode) { + stack.stackSize--; + } + } + return true; + } - @SuppressWarnings("unchecked") - @SideOnly(Side.CLIENT) - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean p_77624_4_) { - if (ItemNBTHelper.getBoolean(stack, "IsSet", false)) list.add(ItemNBTHelper.getString(stack, "EntityName", "null")); - else list.add("Unset"); - } + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean p_77624_4_) { + if (ItemNBTHelper.getBoolean(stack, "IsSet", false)) + list.add(ItemNBTHelper.getString(stack, "EntityName", "null")); + else list.add("Unset"); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/CreativeStructureSpawner.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/CreativeStructureSpawner.java index 7746d7a0..b2e98ab0 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/CreativeStructureSpawner.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/CreativeStructureSpawner.java @@ -21,112 +21,112 @@ import java.util.Random; * Created by Brandon on 29/08/2014. */ public class CreativeStructureSpawner extends ItemDE { - public CreativeStructureSpawner() { - this.setUnlocalizedName(Strings.creativeStructureSpawnerName); - this.hasSubtypes = true; - ModItems.register(this); - } + public CreativeStructureSpawner() { + this.setUnlocalizedName(Strings.creativeStructureSpawnerName); + this.hasSubtypes = true; + ModItems.register(this); + } - @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - @Override - public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { - list.add(new ItemStack(item, 1, 0)); - list.add(new ItemStack(item, 1, 1)); - } + @SideOnly(Side.CLIENT) + @SuppressWarnings("unchecked") + @Override + public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { + list.add(new ItemStack(item, 1, 0)); + list.add(new ItemStack(item, 1, 1)); + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) - { - if (world.isRemote) return stack; + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (world.isRemote) return stack; - switch (stack.getItemDamage()){ - case 0: - new WorldGenEnderComet().generate(world, new Random(), (int)player.posX, (int)player.posY + 10, (int)player.posZ); - break; - case 1: - //new WorldGenEnderIsland().generate(world, new Random(), (int)player.posX, (int)player.posY + 10, (int)player.posZ); - break; - case 2: + switch (stack.getItemDamage()) { + case 0: + new WorldGenEnderComet().generate(world, new Random(), (int) player.posX, (int) player.posY + 10, (int) player.posZ); + break; + case 1: + //new WorldGenEnderIsland().generate(world, new Random(), (int)player.posX, (int)player.posY + 10, (int)player.posZ); + break; + case 2: - break; - case 3: - break; - } - return stack; - } + break; + case 3: + break; + } + return stack; + } - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { - if (world.isRemote) return false; + if (world.isRemote) return false; - switch (stack.getItemDamage()){ - case 0: - break; - case 1: - break; - case 2: - world.setBlock(x, y, z, ModBlocks.chaosCrystal); - TileChaosShard tileChaosShard = (TileChaosShard)world.getTileEntity(x, y, z); - tileChaosShard.locationHash = tileChaosShard.getLocationHash(x, y, z, player.dimension); - tileChaosShard.guardianDefeated = true; - world.markBlockForUpdate(x, y, z); - break; - case 3: - break; - } - return false; - } + switch (stack.getItemDamage()) { + case 0: + break; + case 1: + break; + case 2: + world.setBlock(x, y, z, ModBlocks.chaosCrystal); + TileChaosShard tileChaosShard = (TileChaosShard) world.getTileEntity(x, y, z); + tileChaosShard.locationHash = tileChaosShard.getLocationHash(x, y, z, player.dimension); + tileChaosShard.guardianDefeated = true; + world.markBlockForUpdate(x, y, z); + break; + case 3: + break; + } + return false; + } - @Override - public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) { - if (player.worldObj.getBlock(x, y, z) == ModBlocks.chaosCrystal) { - player.worldObj.removeTileEntity(x, y, z); - player.worldObj.setBlockToAir(x, y, z); - } - return true; - } + @Override + public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) { + if (player.worldObj.getBlock(x, y, z) == ModBlocks.chaosCrystal) { + player.worldObj.removeTileEntity(x, y, z); + player.worldObj.setBlockToAir(x, y, z); + } + return true; + } - @Override - public String getUnlocalizedName(ItemStack itemStack) { - String name = "null"; - switch (itemStack.getItemDamage()){ - case 0: - name = "Comet"; - break; - case 1: - name = "EnderIsland"; - break; - case 2: - name = "ChaosCrystal"; - break; - case 3: - break; - } - return super.getUnlocalizedName(itemStack)+name; - } + @Override + public String getUnlocalizedName(ItemStack itemStack) { + String name = "null"; + switch (itemStack.getItemDamage()) { + case 0: + name = "Comet"; + break; + case 1: + name = "EnderIsland"; + break; + case 2: + name = "ChaosCrystal"; + break; + case 3: + break; + } + return super.getUnlocalizedName(itemStack) + name; + } - @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - @Override - public void addInformation(ItemStack stack, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { - if (stack.getItemDamage() == 1) list.add("This nolonger works due to some changes to the island generation code"); - String name = "null"; - switch (stack.getItemDamage()) { - case 0: - name = "Comet"; - break; - case 1: - name = "EnderIsland"; - break; - case 2: - name = "ChaosCrystal"; - break; - case 3: - break; - } - list.add("Spawns: "+name); - list.add("This item can safely delete chaos crystals"); - } + @SideOnly(Side.CLIENT) + @SuppressWarnings("unchecked") + @Override + public void addInformation(ItemStack stack, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { + if (stack.getItemDamage() == 1) + list.add("This nolonger works due to some changes to the island generation code"); + String name = "null"; + switch (stack.getItemDamage()) { + case 0: + name = "Comet"; + break; + case 1: + name = "EnderIsland"; + break; + case 2: + name = "ChaosCrystal"; + break; + case 3: + break; + } + list.add("Spawns: " + name); + list.add("This item can safely delete chaos crystals"); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicAxe.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicAxe.java index 625d09a9..5bdd8e11 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicAxe.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicAxe.java @@ -24,108 +24,109 @@ import org.lwjgl.opengl.GL11; public class DraconicAxe extends MiningTool implements IInventoryTool, IRenderTweak { - public DraconicAxe() { - super(ModItems.WYVERN); - this.setHarvestLevel("axe", 10); - this.setUnlocalizedName(Strings.draconicAxeName); - this.setCapacity(BalanceConfigHandler.draconicToolsBaseStorage); - this.setMaxExtract(BalanceConfigHandler.draconicToolsMaxTransfer); - this.setMaxReceive(BalanceConfigHandler.draconicToolsMaxTransfer); - this.energyPerOperation = BalanceConfigHandler.draconicToolsEnergyPerAction; - ModItems.register(this); - } + public DraconicAxe() { + super(ModItems.WYVERN); + this.setHarvestLevel("axe", 10); + this.setUnlocalizedName(Strings.draconicAxeName); + this.setCapacity(BalanceConfigHandler.draconicToolsBaseStorage); + this.setMaxExtract(BalanceConfigHandler.draconicToolsMaxTransfer); + this.setMaxReceive(BalanceConfigHandler.draconicToolsMaxTransfer); + this.energyPerOperation = BalanceConfigHandler.draconicToolsEnergyPerAction; + ModItems.register(this); + } - @Override - public List getFields(ItemStack stack, int slot) { - List list = super.getFields(stack, slot); + @Override + public List getFields(ItemStack stack, int slot) { + List list = super.getFields(stack, slot); - list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, EnumUpgrade.DIG_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 0).setModifier("AOE")); - list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_DEPTH).setMinMaxAndIncromente(1, EnumUpgrade.DIG_DEPTH.getUpgradePoints(stack), 1).readFromItem(stack, 1)); - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, References.TREE_MODE).readFromItem(stack, false)); - return list; - } + list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, EnumUpgrade.DIG_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 0).setModifier("AOE")); + list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_DEPTH).setMinMaxAndIncromente(1, EnumUpgrade.DIG_DEPTH.getUpgradePoints(stack), 1).readFromItem(stack, 1)); + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, References.TREE_MODE).readFromItem(stack, false)); + return list; + } - @Override - public String getInventoryName() { - return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); - } + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); + } - @Override - public int getInventorySlots() { - return 0; - } + @Override + public int getInventorySlots() { + return 0; + } - @Override - public boolean isEnchantValid(Enchantment enchant) { - return enchant.type == EnumEnchantmentType.digger; - } + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.digger; + } - @Override - public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { - if (IConfigurableItem.ProfileHelper.getBoolean(stack, References.TREE_MODE, false) && isTree(player.worldObj, x, y, z)) { - trimLeavs(x, y, z, player, player.worldObj, stack); - for (int i = 0; i < 9; i++) player.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(player.worldObj.getBlock(x, y, z)) + (player.worldObj.getBlockMetadata(x, y, z) << 12)); - chopTree(x, y, z, player, player.worldObj, stack); - return false; - } + @Override + public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { + if (IConfigurableItem.ProfileHelper.getBoolean(stack, References.TREE_MODE, false) && isTree(player.worldObj, x, y, z)) { + trimLeavs(x, y, z, player, player.worldObj, stack); + for (int i = 0; i < 9; i++) + player.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(player.worldObj.getBlock(x, y, z)) + (player.worldObj.getBlockMetadata(x, y, z) << 12)); + chopTree(x, y, z, player, player.worldObj, stack); + return false; + } - return super.onBlockStartBreak(stack, x, y, z, player); - } + return super.onBlockStartBreak(stack, x, y, z, player); + } - @Override - public int getUpgradeCap(ItemStack itemstack) { - return BalanceConfigHandler.draconicToolsMaxUpgrades; - } + @Override + public int getUpgradeCap(ItemStack itemstack) { + return BalanceConfigHandler.draconicToolsMaxUpgrades; + } - @Override - public int getMaxTier(ItemStack itemstack) { - return 2; - } + @Override + public int getMaxTier(ItemStack itemstack) { + return 2; + } - @Override - public List getUpgradeStats(ItemStack stack) { - return super.getUpgradeStats(stack); - } + @Override + public List getUpgradeStats(ItemStack stack) { + return super.getUpgradeStats(stack); + } - @Override - public int getCapacity(ItemStack stack){ - int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); - return BalanceConfigHandler.draconicToolsBaseStorage + points * BalanceConfigHandler.draconicToolsStoragePerUpgrade; - } + @Override + public int getCapacity(ItemStack stack) { + int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); + return BalanceConfigHandler.draconicToolsBaseStorage + points * BalanceConfigHandler.draconicToolsStoragePerUpgrade; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { - return BalanceConfigHandler.draconicToolsMaxCapacityUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { - return BalanceConfigHandler.draconicToolsMaxDigAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_DEPTH.index) { - return BalanceConfigHandler.draconicToolsMaxDigDepthUpgradePoints + 2; - } - if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { - return BalanceConfigHandler.draconicToolsMaxDigSpeedUpgradePoints; - } - return BalanceConfigHandler.draconicToolsMaxUpgradePoints; - } + @Override + public int getMaxUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { + return BalanceConfigHandler.draconicToolsMaxCapacityUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { + return BalanceConfigHandler.draconicToolsMaxDigAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_DEPTH.index) { + return BalanceConfigHandler.draconicToolsMaxDigDepthUpgradePoints + 2; + } + if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { + return BalanceConfigHandler.draconicToolsMaxDigSpeedUpgradePoints; + } + return BalanceConfigHandler.draconicToolsMaxUpgradePoints; + } - @Override - public int getBaseUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { - return BalanceConfigHandler.draconicToolsMinDigAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_DEPTH.index) { - return BalanceConfigHandler.draconicToolsMinDigDepthUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { - return BalanceConfigHandler.draconicToolsMinDigSpeedUpgradePoints; - } - return 0; - } + @Override + public int getBaseUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { + return BalanceConfigHandler.draconicToolsMinDigAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_DEPTH.index) { + return BalanceConfigHandler.draconicToolsMinDigDepthUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { + return BalanceConfigHandler.draconicToolsMinDigSpeedUpgradePoints; + } + return 0; + } - // @Override + // @Override // public boolean onBlockStartBreak(ItemStack stack, int X, int Y, int Z, EntityPlayer player) { // World world = player.worldObj; // boolean tree = isTree(world, X, Y, Z); @@ -152,94 +153,93 @@ public class DraconicAxe extends MiningTool implements IInventoryTool, IRenderTw // return true; // } // - private boolean isTree(World world, int X, int Y, int Z) { - final Block wood = world.getBlock(X, Y, Z); - if (wood == null || !wood.isWood(world, X, Y, Z)) { - return false; - } else { - int top = Y; - for (int y = Y; y <= Y + 50; y++) { - if (!world.getBlock(X, y, Z).isWood(world, X, y, Z) && !world.getBlock(X, y, Z).isLeaves(world, X, y, Z)) { - top += y; - break; - } - } + private boolean isTree(World world, int X, int Y, int Z) { + final Block wood = world.getBlock(X, Y, Z); + if (wood == null || !wood.isWood(world, X, Y, Z)) { + return false; + } else { + int top = Y; + for (int y = Y; y <= Y + 50; y++) { + if (!world.getBlock(X, y, Z).isWood(world, X, y, Z) && !world.getBlock(X, y, Z).isLeaves(world, X, y, Z)) { + top += y; + break; + } + } - int leaves = 0; - for (int xPos = X - 1; xPos <= X + 1; xPos++) { - for (int yPos = Y; yPos <= top; yPos++) { - for (int zPos = Z - 1; zPos <= Z + 1; zPos++) { - if (world.getBlock(xPos, yPos, zPos).isLeaves(world, xPos, yPos, zPos)) leaves++; - } - } - } - if (leaves >= 3) return true; - } + int leaves = 0; + for (int xPos = X - 1; xPos <= X + 1; xPos++) { + for (int yPos = Y; yPos <= top; yPos++) { + for (int zPos = Z - 1; zPos <= Z + 1; zPos++) { + if (world.getBlock(xPos, yPos, zPos).isLeaves(world, xPos, yPos, zPos)) leaves++; + } + } + } + if (leaves >= 3) return true; + } - return false; - } + return false; + } - void chopTree(int X, int Y, int Z, EntityPlayer player, World world, ItemStack stack) { - for (int xPos = X - 1; xPos <= X + 1; xPos++) { - for (int yPos = Y; yPos <= Y + 1; yPos++) { - for (int zPos = Z - 1; zPos <= Z + 1; zPos++) { - Block block = world.getBlock(xPos, yPos, zPos); - int meta = world.getBlockMetadata(xPos, yPos, zPos); - if (block.isWood(world, xPos, yPos, zPos)) { - world.setBlockToAir(xPos, yPos, zPos); - if (!player.capabilities.isCreativeMode) { - if (block.removedByPlayer(world, player, xPos, yPos, zPos, false)) { - block.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, meta); - } - block.harvestBlock(world, player, xPos, yPos, zPos, meta); - block.onBlockHarvested(world, xPos, yPos, zPos, meta, player); - onBlockDestroyed(stack, world, block, xPos, yPos, zPos, player); - } - chopTree(xPos, yPos, zPos, player, world, stack); - }//else - //trimLeavs(xPos, yPos, zPos, player, world, stack); - } - } - } - } + void chopTree(int X, int Y, int Z, EntityPlayer player, World world, ItemStack stack) { + for (int xPos = X - 1; xPos <= X + 1; xPos++) { + for (int yPos = Y; yPos <= Y + 1; yPos++) { + for (int zPos = Z - 1; zPos <= Z + 1; zPos++) { + Block block = world.getBlock(xPos, yPos, zPos); + int meta = world.getBlockMetadata(xPos, yPos, zPos); + if (block.isWood(world, xPos, yPos, zPos)) { + world.setBlockToAir(xPos, yPos, zPos); + if (!player.capabilities.isCreativeMode) { + if (block.removedByPlayer(world, player, xPos, yPos, zPos, false)) { + block.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, meta); + } + block.harvestBlock(world, player, xPos, yPos, zPos, meta); + block.onBlockHarvested(world, xPos, yPos, zPos, meta, player); + onBlockDestroyed(stack, world, block, xPos, yPos, zPos, player); + } + chopTree(xPos, yPos, zPos, player, world, stack); + }//else + //trimLeavs(xPos, yPos, zPos, player, world, stack); + } + } + } + } - @SuppressWarnings("all") - void trimLeavs(int X, int Y, int Z, EntityPlayer player, World world, ItemStack stack) { - scedualUpdates(X, Y, Z, player, world, stack); - } + @SuppressWarnings("all") + void trimLeavs(int X, int Y, int Z, EntityPlayer player, World world, ItemStack stack) { + scedualUpdates(X, Y, Z, player, world, stack); + } - @SuppressWarnings("all") - void scedualUpdates(int X, int Y, int Z, EntityPlayer player, World world, ItemStack stack) { - for (int xPos = X - 15; xPos <= X + 15; xPos++) { - for (int yPos = Y; yPos <= Y + 50; yPos++) { - for (int zPos = Z - 15; zPos <= Z + 15; zPos++) { - Block block = world.getBlock(xPos, yPos, zPos); - if (block.isLeaves(world, xPos, yPos, zPos)) { - world.scheduleBlockUpdate(xPos, yPos, zPos, block, 2 + world.rand.nextInt(10)); - } - } - } - } - } + @SuppressWarnings("all") + void scedualUpdates(int X, int Y, int Z, EntityPlayer player, World world, ItemStack stack) { + for (int xPos = X - 15; xPos <= X + 15; xPos++) { + for (int yPos = Y; yPos <= Y + 50; yPos++) { + for (int zPos = Z - 15; zPos <= Z + 15; zPos++) { + Block block = world.getBlock(xPos, yPos, zPos); + if (block.isLeaves(world, xPos, yPos, zPos)) { + world.scheduleBlockUpdate(xPos, yPos, zPos, block, 2 + world.rand.nextInt(10)); + } + } + } + } + } - @Override - public void tweakRender(IItemRenderer.ItemRenderType type) { - GL11.glTranslated(0.34, 0.69, 0.1); - GL11.glRotatef(90, 1, 0, 0); - GL11.glRotatef(140, 0, -1, 0); - GL11.glRotatef(180, 0, 0, 1); - GL11.glScaled(0.7, 0.7, 0.7); + @Override + public void tweakRender(IItemRenderer.ItemRenderType type) { + GL11.glTranslated(0.34, 0.69, 0.1); + GL11.glRotatef(90, 1, 0, 0); + GL11.glRotatef(140, 0, -1, 0); + GL11.glRotatef(180, 0, 0, 1); + GL11.glScaled(0.7, 0.7, 0.7); - if (type == IItemRenderer.ItemRenderType.INVENTORY){ - GL11.glScalef(11, 11, 11); - GL11.glRotatef(180, 0, 1, 0); - GL11.glTranslated(-1.3, 0, -0.45); - } - else if (type == IItemRenderer.ItemRenderType.ENTITY){ - GL11.glRotatef(90.5F, 0, 1, 0); - GL11.glTranslated(0, 0, -0.9); - } - } + if (type == IItemRenderer.ItemRenderType.INVENTORY) { + GL11.glScalef(11, 11, 11); + GL11.glRotatef(180, 0, 1, 0); + GL11.glTranslated(-1.3, 0, -0.45); + } else if (type == IItemRenderer.ItemRenderType.ENTITY) { + GL11.glRotatef(90.5F, 0, 1, 0); + GL11.glTranslated(0, 0, -0.9); + } + } // @SuppressWarnings({"rawtypes", "unchecked"}) diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicDistructionStaff.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicDistructionStaff.java index 0a65a8ea..b1089927 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicDistructionStaff.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicDistructionStaff.java @@ -31,168 +31,166 @@ import org.lwjgl.opengl.GL11; public class DraconicDistructionStaff extends MiningTool implements IInventoryTool, IRenderTweak, IEnergyContainerWeaponItem { - public DraconicDistructionStaff() { - super(ModItems.CHAOTIC); - this.setUnlocalizedName(Strings.draconicDStaffName); - this.setHarvestLevel("pickaxe", 10); - this.setHarvestLevel("shovel", 10); - this.setHarvestLevel("axe", 10); - this.setCapacity(BalanceConfigHandler.draconicToolsBaseStorage * 2 + BalanceConfigHandler.draconicWeaponsBaseStorage); - this.setMaxExtract(BalanceConfigHandler.draconicToolsMaxTransfer * 2 + BalanceConfigHandler.draconicWeaponsMaxTransfer); - this.setMaxReceive(BalanceConfigHandler.draconicToolsMaxTransfer * 2 + BalanceConfigHandler.draconicWeaponsMaxTransfer); - this.energyPerOperation = BalanceConfigHandler.draconicToolsEnergyPerAction; - ModItems.register(this); - } + public DraconicDistructionStaff() { + super(ModItems.CHAOTIC); + this.setUnlocalizedName(Strings.draconicDStaffName); + this.setHarvestLevel("pickaxe", 10); + this.setHarvestLevel("shovel", 10); + this.setHarvestLevel("axe", 10); + this.setCapacity(BalanceConfigHandler.draconicToolsBaseStorage * 2 + BalanceConfigHandler.draconicWeaponsBaseStorage); + this.setMaxExtract(BalanceConfigHandler.draconicToolsMaxTransfer * 2 + BalanceConfigHandler.draconicWeaponsMaxTransfer); + this.setMaxReceive(BalanceConfigHandler.draconicToolsMaxTransfer * 2 + BalanceConfigHandler.draconicWeaponsMaxTransfer); + this.energyPerOperation = BalanceConfigHandler.draconicToolsEnergyPerAction; + ModItems.register(this); + } - @Override - public float func_150893_a(ItemStack stack, Block block) { - return this.getEfficiency(stack); - } + @Override + public float func_150893_a(ItemStack stack, Block block) { + return this.getEfficiency(stack); + } - @Override - public List getFields(ItemStack stack, int slot) { - List list = super.getFields(stack, slot); - list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, EnumUpgrade.DIG_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 0).setModifier("AOE")); - list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_DEPTH).setMinMaxAndIncromente(1, EnumUpgrade.DIG_DEPTH.getUpgradePoints(stack), 1).readFromItem(stack, 1)); - list.add(new ItemConfigField(References.INT_ID, slot, References.ATTACK_AOE).setMinMaxAndIncromente(0, EnumUpgrade.ATTACK_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 1).setModifier("AOE")); - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, References.OBLITERATE).readFromItem(stack, false)); - return list; - } + @Override + public List getFields(ItemStack stack, int slot) { + List list = super.getFields(stack, slot); + list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, EnumUpgrade.DIG_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 0).setModifier("AOE")); + list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_DEPTH).setMinMaxAndIncromente(1, EnumUpgrade.DIG_DEPTH.getUpgradePoints(stack), 1).readFromItem(stack, 1)); + list.add(new ItemConfigField(References.INT_ID, slot, References.ATTACK_AOE).setMinMaxAndIncromente(0, EnumUpgrade.ATTACK_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 1).setModifier("AOE")); + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, References.OBLITERATE).readFromItem(stack, false)); + return list; + } - @Override - public String getInventoryName() { - return StatCollector.translateToLocal("info.de.toolInventoryOblit.txt"); - } + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryOblit.txt"); + } - @Override - public int getInventorySlots() { - return 9; - } + @Override + public int getInventorySlots() { + return 9; + } - @Override - public boolean isEnchantValid(Enchantment enchant) { - return enchant.type == EnumEnchantmentType.digger || enchant.type == EnumEnchantmentType.weapon; - } + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.digger || enchant.type == EnumEnchantmentType.weapon; + } - @Override - public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { + @Override + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { entity.hurtResistantTime = 0; - ToolHandler.damageEntityBasedOnHealth(entity, player, 0.3F); - ToolHandler.AOEAttack(player, entity, stack, IConfigurableItem.ProfileHelper.getInteger(stack, References.ATTACK_AOE, 0)); - return true; - } + ToolHandler.damageEntityBasedOnHealth(entity, player, 0.3F); + ToolHandler.AOEAttack(player, entity, stack, IConfigurableItem.ProfileHelper.getInteger(stack, References.ATTACK_AOE, 0)); + return true; + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - return super.onItemRightClick(stack, world, player); - } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + return super.onItemRightClick(stack, world, player); + } - @SuppressWarnings("unchecked") - @SideOnly(Side.CLIENT) - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean extended) { - super.addInformation(stack, player, list, extended); + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean extended) { + super.addInformation(stack, player, list, extended); - list.add(""); - list.add(EnumChatFormatting.BLUE + "+" + ToolHandler.getBaseAttackDamage(stack) + " " + StatCollector.translateToLocal("info.de.attackDamage.txt")); - list.add(EnumChatFormatting.BLUE + "+30%" + " " + StatCollector.translateToLocal("info.de.bonusHealthDamage.txt")); - } + list.add(""); + list.add(EnumChatFormatting.BLUE + "+" + ToolHandler.getBaseAttackDamage(stack) + " " + StatCollector.translateToLocal("info.de.attackDamage.txt")); + list.add(EnumChatFormatting.BLUE + "+30%" + " " + StatCollector.translateToLocal("info.de.bonusHealthDamage.txt")); + } - @Override - public void tweakRender(IItemRenderer.ItemRenderType type) { - GL11.glTranslated(0.77, 0.19, -0.15); - GL11.glRotatef(90, 1, 0, 0); - GL11.glRotatef(-35, 0, -1, 0); - GL11.glScaled(0.7, 0.7, 0.7); + @Override + public void tweakRender(IItemRenderer.ItemRenderType type) { + GL11.glTranslated(0.77, 0.19, -0.15); + GL11.glRotatef(90, 1, 0, 0); + GL11.glRotatef(-35, 0, -1, 0); + GL11.glScaled(0.7, 0.7, 0.7); - if (type == IItemRenderer.ItemRenderType.INVENTORY){ - GL11.glScalef(6F, 6F, 6F); - GL11.glRotatef(145, 0, 1, 0); - GL11.glTranslated(-1.7, 0, 1.8); - } - else if (type == IItemRenderer.ItemRenderType.ENTITY){ - GL11.glRotatef(-34.5F, 0, 1, 0); - GL11.glTranslated(-1.1, 0, -0.2); - } - else if (type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) { - GL11.glTranslated(0, 0.4, 0); - } - } + if (type == IItemRenderer.ItemRenderType.INVENTORY) { + GL11.glScalef(6F, 6F, 6F); + GL11.glRotatef(145, 0, 1, 0); + GL11.glTranslated(-1.7, 0, 1.8); + } else if (type == IItemRenderer.ItemRenderType.ENTITY) { + GL11.glRotatef(-34.5F, 0, 1, 0); + GL11.glTranslated(-1.1, 0, -0.2); + } else if (type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glTranslated(0, 0.4, 0); + } + } - @Override - public int getUpgradeCap(ItemStack itemstack) { - return BalanceConfigHandler.draconicStaffMaxUpgrades; - } + @Override + public int getUpgradeCap(ItemStack itemstack) { + return BalanceConfigHandler.draconicStaffMaxUpgrades; + } - @Override - public int getMaxTier(ItemStack itemstack) { - return 2; - } + @Override + public int getMaxTier(ItemStack itemstack) { + return 2; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { - return BalanceConfigHandler.draconicStaffMaxCapacityUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { - return BalanceConfigHandler.draconicStaffMaxDigAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_DEPTH.index) { - return BalanceConfigHandler.draconicStaffMaxDigDepthUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ATTACK_AOE.index) { - return BalanceConfigHandler.draconicStaffMaxAttackAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ATTACK_DAMAGE.index) { - return BalanceConfigHandler.draconicStaffMaxAttackDamageUpgradePoints; - } - return BalanceConfigHandler.draconicStaffMaxUpgradePoints; - } + @Override + public int getMaxUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { + return BalanceConfigHandler.draconicStaffMaxCapacityUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { + return BalanceConfigHandler.draconicStaffMaxDigAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_DEPTH.index) { + return BalanceConfigHandler.draconicStaffMaxDigDepthUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ATTACK_AOE.index) { + return BalanceConfigHandler.draconicStaffMaxAttackAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ATTACK_DAMAGE.index) { + return BalanceConfigHandler.draconicStaffMaxAttackDamageUpgradePoints; + } + return BalanceConfigHandler.draconicStaffMaxUpgradePoints; + } - @Override - public int getBaseUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { - return BalanceConfigHandler.draconicStaffMinDigAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_DEPTH.index) { - return BalanceConfigHandler.draconicStaffMinDigDepthUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ATTACK_AOE.index) { - return BalanceConfigHandler.draconicStaffMinAttackAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ATTACK_DAMAGE.index) { - return BalanceConfigHandler.draconicStaffMinAttackDamageUpgradePoints; - } - return 0; - } + @Override + public int getBaseUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { + return BalanceConfigHandler.draconicStaffMinDigAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_DEPTH.index) { + return BalanceConfigHandler.draconicStaffMinDigDepthUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ATTACK_AOE.index) { + return BalanceConfigHandler.draconicStaffMinAttackAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ATTACK_DAMAGE.index) { + return BalanceConfigHandler.draconicStaffMinAttackDamageUpgradePoints; + } + return 0; + } - @Override - public int getCapacity(ItemStack stack) { - int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); - return BalanceConfigHandler.draconicToolsBaseStorage * 2 + BalanceConfigHandler.draconicWeaponsBaseStorage + - points * (BalanceConfigHandler.draconicToolsStoragePerUpgrade + BalanceConfigHandler.draconicWeaponsStoragePerUpgrade); - } + @Override + public int getCapacity(ItemStack stack) { + int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); + return BalanceConfigHandler.draconicToolsBaseStorage * 2 + BalanceConfigHandler.draconicWeaponsBaseStorage + + points * (BalanceConfigHandler.draconicToolsStoragePerUpgrade + BalanceConfigHandler.draconicWeaponsStoragePerUpgrade); + } - @Override - public List getUpgrades(ItemStack itemstack) { - List list = super.getUpgrades(itemstack); - list.add(EnumUpgrade.ATTACK_AOE); - list.add(EnumUpgrade.ATTACK_DAMAGE); - list.remove(EnumUpgrade.DIG_SPEED); + @Override + public List getUpgrades(ItemStack itemstack) { + List list = super.getUpgrades(itemstack); + list.add(EnumUpgrade.ATTACK_AOE); + list.add(EnumUpgrade.ATTACK_DAMAGE); + list.remove(EnumUpgrade.DIG_SPEED); - return list; - } + return list; + } - @Override - public List getUpgradeStats(ItemStack stack) { - List list = super.getUpgradeStats(stack); - list.add(InfoHelper.ITC()+StatCollector.translateToLocal("info.de.attackDamage.txt")+": "+ InfoHelper.HITC()+ToolHandler.getBaseAttackDamage(stack)); - return list; - } - @Override - public int getEnergyPerAttack() - { - return BalanceConfigHandler.draconicWeaponsEnergyPerAttack; - } + @Override + public List getUpgradeStats(ItemStack stack) { + List list = super.getUpgradeStats(stack); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.attackDamage.txt") + ": " + InfoHelper.HITC() + ToolHandler.getBaseAttackDamage(stack)); + return list; + } + + @Override + public int getEnergyPerAttack() { + return BalanceConfigHandler.draconicWeaponsEnergyPerAttack; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicHoe.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicHoe.java index ee460c80..7ef4845f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicHoe.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicHoe.java @@ -41,312 +41,310 @@ import org.lwjgl.opengl.GL11; public class DraconicHoe extends ItemHoe implements IEnergyContainerItem, IRenderTweak, IUpgradableItem, IConfigurableItem, IHudDisplayItem { - protected int capacity = BalanceConfigHandler.draconicToolsBaseStorage; - protected int maxReceive = BalanceConfigHandler.draconicToolsMaxTransfer; - protected int maxExtract = BalanceConfigHandler.draconicToolsMaxTransfer; + protected int capacity = BalanceConfigHandler.draconicToolsBaseStorage; + protected int maxReceive = BalanceConfigHandler.draconicToolsMaxTransfer; + protected int maxExtract = BalanceConfigHandler.draconicToolsMaxTransfer; - public DraconicHoe() { - super(ModItems.WYVERN); - this.setUnlocalizedName(Strings.draconicHoeName); - this.setCreativeTab(DraconicEvolution.tabToolsWeapons); - if (ModItems.isEnabled(this)) GameRegistry.registerItem(this, Strings.draconicHoeName); - } + public DraconicHoe() { + super(ModItems.WYVERN); + this.setUnlocalizedName(Strings.draconicHoeName); + this.setCreativeTab(DraconicEvolution.tabToolsWeapons); + if (ModItems.isEnabled(this)) GameRegistry.registerItem(this, Strings.draconicHoeName); + } - @Override - public int getItemEnchantability() { - return theToolMaterial.getEnchantability(); - } + @Override + public int getItemEnchantability() { + return theToolMaterial.getEnchantability(); + } - @Override - public List getFields(ItemStack stack, int slot) { - List list = new ArrayList(); - list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, EnumUpgrade.DIG_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 0).setModifier("AOE")); - return list; - } + @Override + public List getFields(ItemStack stack, int slot) { + List list = new ArrayList(); + list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, EnumUpgrade.DIG_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 0).setModifier("AOE")); + return list; + } - @Override - public boolean isItemTool(ItemStack p_77616_1_) { - return true; - } + @Override + public boolean isItemTool(ItemStack p_77616_1_) { + return true; + } - @SideOnly(Side.CLIENT) - @SuppressWarnings("all") - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", 0)); - list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", capacity)); - } + @SideOnly(Side.CLIENT) + @SuppressWarnings("all") + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", 0)); + list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", capacity)); + } - @Override - public String getUnlocalizedName(){ + @Override + public String getUnlocalizedName() { - return String.format("item.%s%s", References.MODID.toLowerCase() + ":", super.getUnlocalizedName().substring(super.getUnlocalizedName().indexOf(".") + 1)); - } + return String.format("item.%s%s", References.MODID.toLowerCase() + ":", super.getUnlocalizedName().substring(super.getUnlocalizedName().indexOf(".") + 1)); + } - @Override - public String getUnlocalizedName(final ItemStack itemStack){ - return getUnlocalizedName(); - } + @Override + public String getUnlocalizedName(final ItemStack itemStack) { + return getUnlocalizedName(); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(final IIconRegister iconRegister) { - this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_hoe"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister iconRegister) { + this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_hoe"); + } - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { - boolean successfull = false; - Block clicked = world.getBlock(x, y, z); - if (!player.isSneaking() && player.canPlayerEdit(x, y, z, par7, stack) && (clicked == Blocks.dirt || clicked == Blocks.grass || clicked == Blocks.farmland) && par7 == 1) { - int size = IConfigurableItem.ProfileHelper.getInteger(stack, References.DIG_AOE, 0); - LogHelper.info(size); - for (int x1 = -size; x1 <= size; x1++) { - for (int z1 = -size; z1 <= size; z1++) { - if (!(stack.getItem() instanceof IEnergyContainerItem) || ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack) < BalanceConfigHandler.draconicToolsEnergyPerAction) { - if (!player.capabilities.isCreativeMode) - return false; - } - Block topBlock = world.getBlock(x + x1, y + 1, z + z1); - if (topBlock.isReplaceable(world, x + x1, y + 1, z + z1)) { - world.setBlockToAir(x + x1, y + 1, z + z1); - } - Block topBlock2 = world.getBlock(x + x1, y + 2, z + z1); - if (topBlock2.isReplaceable(world, x + x1, y + 2, z + z1)) { - world.setBlockToAir(x + x1, y + 2, z + z1); - } - Block block = world.getBlock(x + x1, y, z + z1); - if (block.isReplaceable(world, x + x1, y, z + z1) && !block.getMaterial().equals(Material.water)) { - world.setBlockToAir(x + x1, y, z + z1); - } + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { + boolean successfull = false; + Block clicked = world.getBlock(x, y, z); + if (!player.isSneaking() && player.canPlayerEdit(x, y, z, par7, stack) && (clicked == Blocks.dirt || clicked == Blocks.grass || clicked == Blocks.farmland) && par7 == 1) { + int size = IConfigurableItem.ProfileHelper.getInteger(stack, References.DIG_AOE, 0); + LogHelper.info(size); + for (int x1 = -size; x1 <= size; x1++) { + for (int z1 = -size; z1 <= size; z1++) { + if (!(stack.getItem() instanceof IEnergyContainerItem) || ((IEnergyContainerItem) stack.getItem()).getEnergyStored(stack) < BalanceConfigHandler.draconicToolsEnergyPerAction) { + if (!player.capabilities.isCreativeMode) return false; + } + Block topBlock = world.getBlock(x + x1, y + 1, z + z1); + if (topBlock.isReplaceable(world, x + x1, y + 1, z + z1)) { + world.setBlockToAir(x + x1, y + 1, z + z1); + } + Block topBlock2 = world.getBlock(x + x1, y + 2, z + z1); + if (topBlock2.isReplaceable(world, x + x1, y + 2, z + z1)) { + world.setBlockToAir(x + x1, y + 2, z + z1); + } + Block block = world.getBlock(x + x1, y, z + z1); + if (block.isReplaceable(world, x + x1, y, z + z1) && !block.getMaterial().equals(Material.water)) { + world.setBlockToAir(x + x1, y, z + z1); + } - if (world.getBlock(x + x1, y, z + z1) == Blocks.air && world.getBlock(x + x1, y - 1, z + z1).isBlockSolid(world, x, y, z, 1)) { - if (player.inventory.hasItem(Item.getItemFromBlock(Blocks.dirt)) || player.capabilities.isCreativeMode) { - world.setBlock(x + x1, y, z + z1, Blocks.dirt); - player.inventory.consumeInventoryItem(Item.getItemFromBlock(Blocks.dirt)); - } - } + if (world.getBlock(x + x1, y, z + z1) == Blocks.air && world.getBlock(x + x1, y - 1, z + z1).isBlockSolid(world, x, y, z, 1)) { + if (player.inventory.hasItem(Item.getItemFromBlock(Blocks.dirt)) || player.capabilities.isCreativeMode) { + world.setBlock(x + x1, y, z + z1, Blocks.dirt); + player.inventory.consumeInventoryItem(Item.getItemFromBlock(Blocks.dirt)); + } + } - if ((world.getBlock(x + x1, y + 1, z + z1) == Blocks.dirt || world.getBlock(x + x1, y + 1, z + z1) == Blocks.grass || world.getBlock(x + x1, y + 1, z + z1) == Blocks.farmland) && world.getBlock(x + x1, y + 2, z + z1) == Blocks.air) { - if (!world.isRemote) - world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, new ItemStack(Item.getItemFromBlock(Blocks.dirt)))); - world.setBlock(x + x1, y + 1, z + z1, Blocks.air); - } + if ((world.getBlock(x + x1, y + 1, z + z1) == Blocks.dirt || world.getBlock(x + x1, y + 1, z + z1) == Blocks.grass || world.getBlock(x + x1, y + 1, z + z1) == Blocks.farmland) && world.getBlock(x + x1, y + 2, z + z1) == Blocks.air) { + if (!world.isRemote) + world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, new ItemStack(Item.getItemFromBlock(Blocks.dirt)))); + world.setBlock(x + x1, y + 1, z + z1, Blocks.air); + } - if (hoe(stack, player, world, x + x1, y, z + z1, par7)) successfull = true; - } - } - } else successfull = hoe(stack, player, world, x, y, z, par7); - Block block1 = Blocks.farmland; - if (successfull) - world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F); - return successfull; - } + if (hoe(stack, player, world, x + x1, y, z + z1, par7)) successfull = true; + } + } + } else successfull = hoe(stack, player, world, x, y, z, par7); + Block block1 = Blocks.farmland; + if (successfull) + world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F); + return successfull; + } - private boolean hoe(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7) { - if (!(stack.getItem() instanceof IEnergyContainerItem) || ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack) < BalanceConfigHandler.draconicToolsEnergyPerAction) { - if (!player.capabilities.isCreativeMode) - return false; - } else { - if (!player.capabilities.isCreativeMode) - ((IEnergyContainerItem) stack.getItem()).extractEnergy(stack, BalanceConfigHandler.draconicToolsEnergyPerAction, false); - } - if (!player.canPlayerEdit(x, y, z, par7, stack)) { - return false; - } else { - UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z); - if (MinecraftForge.EVENT_BUS.post(event)) { - return false; - } + private boolean hoe(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7) { + if (!(stack.getItem() instanceof IEnergyContainerItem) || ((IEnergyContainerItem) stack.getItem()).getEnergyStored(stack) < BalanceConfigHandler.draconicToolsEnergyPerAction) { + if (!player.capabilities.isCreativeMode) return false; + } else { + if (!player.capabilities.isCreativeMode) + ((IEnergyContainerItem) stack.getItem()).extractEnergy(stack, BalanceConfigHandler.draconicToolsEnergyPerAction, false); + } + if (!player.canPlayerEdit(x, y, z, par7, stack)) { + return false; + } else { + UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z); + if (MinecraftForge.EVENT_BUS.post(event)) { + return false; + } - if (event.getResult() == Result.ALLOW) { - stack.damageItem(1, player); - return true; - } + if (event.getResult() == Result.ALLOW) { + stack.damageItem(1, player); + return true; + } - Block block = world.getBlock(x, y, z); + Block block = world.getBlock(x, y, z); - if (par7 != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt)) { - Block block1 = Blocks.farmland; + if (par7 != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt)) { + Block block1 = Blocks.farmland; - if (world.isRemote) { - return true; - } else { - world.setBlock(x, y, z, block1); - stack.damageItem(1, player); - return true; - } - } else { - return false; - } - } - } + if (world.isRemote) { + return true; + } else { + world.setBlock(x, y, z, block1); + stack.damageItem(1, player); + return true; + } + } else { + return false; + } + } + } - @SuppressWarnings({"rawtypes", "unchecked"}) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) { - InfoHelper.addEnergyInfo(stack, list); - ToolBase.holdCTRLForUpgrades(list, stack); - InfoHelper.addLore(stack, list); - } + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) { + InfoHelper.addEnergyInfo(stack, list); + ToolBase.holdCTRLForUpgrades(list, stack); + InfoHelper.addLore(stack, list); + } - @Override - public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { - if (container.stackTagCompound == null) { - container.stackTagCompound = new NBTTagCompound(); - } - int energy = container.stackTagCompound.getInteger("Energy"); - int energyReceived = Math.min(getMaxEnergyStored(container) - energy, Math.min(this.maxReceive, maxReceive)); + if (container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyReceived = Math.min(getMaxEnergyStored(container) - energy, Math.min(this.maxReceive, maxReceive)); - if (!simulate) { - energy += energyReceived; - container.stackTagCompound.setInteger("Energy", energy); - } - return energyReceived; - } + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("Energy", energy); + } + return energyReceived; + } - @Override - public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - int energy = container.stackTagCompound.getInteger("Energy"); - int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + return 0; + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - if (!simulate) { - energy -= energyExtracted; - container.stackTagCompound.setInteger("Energy", energy); - } - return energyExtracted; - } + if (!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("Energy", energy); + } + return energyExtracted; + } - @Override - public int getEnergyStored(ItemStack container) { - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - return container.stackTagCompound.getInteger("Energy"); - } + @Override + public int getEnergyStored(ItemStack container) { + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + return 0; + } + return container.stackTagCompound.getInteger("Energy"); + } - @Override - public int getMaxEnergyStored(ItemStack container) { - int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(container); - return BalanceConfigHandler.draconicToolsBaseStorage + points * BalanceConfigHandler.draconicToolsStoragePerUpgrade; - } + @Override + public int getMaxEnergyStored(ItemStack container) { + int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(container); + return BalanceConfigHandler.draconicToolsBaseStorage + points * BalanceConfigHandler.draconicToolsStoragePerUpgrade; + } - @Override - public boolean showDurabilityBar(ItemStack stack) { - return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); - } + @Override + public boolean showDurabilityBar(ItemStack stack) { + return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); + } - @Override - public double getDurabilityForDisplay(ItemStack stack) { - return 1D - ((double)getEnergyStored(stack) / (double)getMaxEnergyStored(stack)); - } + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - ((double) getEnergyStored(stack) / (double) getMaxEnergyStored(stack)); + } - @Override - public boolean hasCustomEntity(ItemStack stack) { - return true; - } + @Override + public boolean hasCustomEntity(ItemStack stack) { + return true; + } - @Override - public Entity createEntity(World world, Entity location, ItemStack itemstack) { - return new EntityPersistentItem(world, location, itemstack); - } + @Override + public Entity createEntity(World world, Entity location, ItemStack itemstack) { + return new EntityPersistentItem(world, location, itemstack); + } - @Override - public void tweakRender(IItemRenderer.ItemRenderType type) { - GL11.glTranslated(0.4, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - GL11.glRotatef(140, 0, -1, 0); - GL11.glRotatef(-90, 0, 0, 1); - GL11.glScaled(0.6, 0.6, 0.6); + @Override + public void tweakRender(IItemRenderer.ItemRenderType type) { + GL11.glTranslated(0.4, 1, 0); + GL11.glRotatef(90, 1, 0, 0); + GL11.glRotatef(140, 0, -1, 0); + GL11.glRotatef(-90, 0, 0, 1); + GL11.glScaled(0.6, 0.6, 0.6); - if (type == IItemRenderer.ItemRenderType.INVENTORY){ - GL11.glScalef(12F, 12F, 12F); - GL11.glRotatef(180, 0, 1, 0); - GL11.glRotatef(90, 0, 0, 1); - GL11.glTranslated(-1.4, 0, -0.1); - } - else if (type == IItemRenderer.ItemRenderType.ENTITY){ - GL11.glRotatef(90.5F, 1, 0, 0); - GL11.glRotatef(90F, 0, 0, -1); - GL11.glTranslated(0.35, -0.4, -1); - } - } + if (type == IItemRenderer.ItemRenderType.INVENTORY) { + GL11.glScalef(12F, 12F, 12F); + GL11.glRotatef(180, 0, 1, 0); + GL11.glRotatef(90, 0, 0, 1); + GL11.glTranslated(-1.4, 0, -0.1); + } else if (type == IItemRenderer.ItemRenderType.ENTITY) { + GL11.glRotatef(90.5F, 1, 0, 0); + GL11.glRotatef(90F, 0, 0, -1); + GL11.glTranslated(0.35, -0.4, -1); + } + } - @Override - public List getUpgrades(ItemStack itemstack) { - return new ArrayList(){{ - add(EnumUpgrade.RF_CAPACITY); - add(EnumUpgrade.DIG_AOE); - }}; - } + @Override + public List getUpgrades(ItemStack itemstack) { + return new ArrayList() {{ + add(EnumUpgrade.RF_CAPACITY); + add(EnumUpgrade.DIG_AOE); + }}; + } - @Override - public int getUpgradeCap(ItemStack itemstack) { - return BalanceConfigHandler.draconicToolsMaxUpgrades; - } + @Override + public int getUpgradeCap(ItemStack itemstack) { + return BalanceConfigHandler.draconicToolsMaxUpgrades; + } - @Override - public int getMaxTier(ItemStack itemstack) { - return 2; - } + @Override + public int getMaxTier(ItemStack itemstack) { + return 2; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { - return BalanceConfigHandler.draconicToolsMaxCapacityUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { - return BalanceConfigHandler.draconicToolsMaxDigAOEUpgradePoints + 1; - } - return BalanceConfigHandler.draconicToolsMaxUpgradePoints; - } + @Override + public int getMaxUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { + return BalanceConfigHandler.draconicToolsMaxCapacityUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { + return BalanceConfigHandler.draconicToolsMaxDigAOEUpgradePoints + 1; + } + return BalanceConfigHandler.draconicToolsMaxUpgradePoints; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) - { - return getMaxUpgradePoints(upgradeIndex); - } + @Override + public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) { + return getMaxUpgradePoints(upgradeIndex); + } - @Override - public int getBaseUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { - return BalanceConfigHandler.draconicToolsMinDigAOEUpgradePoints + 1; - } - return 0; - } + @Override + public int getBaseUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { + return BalanceConfigHandler.draconicToolsMinDigAOEUpgradePoints + 1; + } + return 0; + } - @Override - public List getUpgradeStats(ItemStack itemstack) { - List strings = new ArrayList(); + @Override + public List getUpgradeStats(ItemStack itemstack) { + List strings = new ArrayList(); - int digaoe = 0; - for (ItemConfigField field : getFields(itemstack, 0)) if (field.name.equals(References.DIG_AOE)) digaoe = 1 + ((Integer) field.max * 2); + int digaoe = 0; + for (ItemConfigField field : getFields(itemstack, 0)) + if (field.name.equals(References.DIG_AOE)) digaoe = 1 + ((Integer) field.max * 2); - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.RFCapacity.txt")+": "+InfoHelper.HITC()+Utills.formatNumber(getMaxEnergyStored(itemstack))); - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.max.txt")+" "+StatCollector.translateToLocal("gui.de.DigAOE.txt")+": "+InfoHelper.HITC()+digaoe+"x"+digaoe); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.RFCapacity.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getMaxEnergyStored(itemstack))); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.max.txt") + " " + StatCollector.translateToLocal("gui.de.DigAOE.txt") + ": " + InfoHelper.HITC() + digaoe + "x" + digaoe); - return strings; - } + return strings; + } - @Override - public boolean hasProfiles() { - return false; - } + @Override + public boolean hasProfiles() { + return false; + } - @Override - public List getDisplayData(ItemStack stack) { - List list = new ArrayList(); + @Override + public List getDisplayData(ItemStack stack) { + List list = new ArrayList(); - for (ItemConfigField field : getFields(stack, 0)) list.add(field.getTooltipInfo());//list.add(field.getLocalizedName() + ": " + field.getFormattedValue()); - list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getEnergyStored(stack)) + " / " + Utills.formatNumber(capacity)); + for (ItemConfigField field : getFields(stack, 0)) + list.add(field.getTooltipInfo());//list.add(field.getLocalizedName() + ": " + field.getFormattedValue()); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getEnergyStored(stack)) + " / " + Utills.formatNumber(capacity)); - return list; - } + return list; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicPickaxe.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicPickaxe.java index fbc64e99..78c6d7d9 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicPickaxe.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicPickaxe.java @@ -21,112 +21,111 @@ import org.lwjgl.opengl.GL11; public class DraconicPickaxe extends MiningTool implements IInventoryTool, IRenderTweak { - public DraconicPickaxe() { - super(ModItems.AWAKENED); - this.setHarvestLevel("pickaxe", 10); - this.setUnlocalizedName(Strings.draconicPickaxeName); - this.setCapacity(BalanceConfigHandler.draconicToolsBaseStorage); - this.setMaxExtract(BalanceConfigHandler.draconicToolsMaxTransfer); - this.setMaxReceive(BalanceConfigHandler.draconicToolsMaxTransfer); - this.energyPerOperation = BalanceConfigHandler.draconicToolsEnergyPerAction; - ModItems.register(this); - } + public DraconicPickaxe() { + super(ModItems.AWAKENED); + this.setHarvestLevel("pickaxe", 10); + this.setUnlocalizedName(Strings.draconicPickaxeName); + this.setCapacity(BalanceConfigHandler.draconicToolsBaseStorage); + this.setMaxExtract(BalanceConfigHandler.draconicToolsMaxTransfer); + this.setMaxReceive(BalanceConfigHandler.draconicToolsMaxTransfer); + this.energyPerOperation = BalanceConfigHandler.draconicToolsEnergyPerAction; + ModItems.register(this); + } - @Override - public List getFields(ItemStack stack, int slot) { - List list = super.getFields(stack, slot); - list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, EnumUpgrade.DIG_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 0).setModifier("AOE")); - list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_DEPTH).setMinMaxAndIncromente(1, EnumUpgrade.DIG_DEPTH.getUpgradePoints(stack), 1).readFromItem(stack, 1)); - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, References.OBLITERATE).readFromItem(stack, false)); - return list; - } + @Override + public List getFields(ItemStack stack, int slot) { + List list = super.getFields(stack, slot); + list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, EnumUpgrade.DIG_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 0).setModifier("AOE")); + list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_DEPTH).setMinMaxAndIncromente(1, EnumUpgrade.DIG_DEPTH.getUpgradePoints(stack), 1).readFromItem(stack, 1)); + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, References.OBLITERATE).readFromItem(stack, false)); + return list; + } - @Override - public String getInventoryName() { - return StatCollector.translateToLocal("info.de.toolInventoryOblit.txt"); - } + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryOblit.txt"); + } - @Override - public int getInventorySlots() { - return 9; - } + @Override + public int getInventorySlots() { + return 9; + } - @Override - public boolean isEnchantValid(Enchantment enchant) { - return enchant.type == EnumEnchantmentType.digger; - } + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.digger; + } - @Override - public void tweakRender(IItemRenderer.ItemRenderType type) { - GL11.glTranslated(0.34, 0.69, 0.1); - GL11.glRotatef(90, 1, 0, 0); - GL11.glRotatef(140, 0, -1, 0); - GL11.glRotatef(180, 0, 0, 1); - GL11.glScaled(0.7, 0.7, 0.7); + @Override + public void tweakRender(IItemRenderer.ItemRenderType type) { + GL11.glTranslated(0.34, 0.69, 0.1); + GL11.glRotatef(90, 1, 0, 0); + GL11.glRotatef(140, 0, -1, 0); + GL11.glRotatef(180, 0, 0, 1); + GL11.glScaled(0.7, 0.7, 0.7); - if (type == IItemRenderer.ItemRenderType.INVENTORY){ - GL11.glScalef(11.8F, 11.8F, 11.8F); - GL11.glRotatef(180, 0, 1, 0); - GL11.glTranslated(-1.2, 0, -0.35); - } - else if (type == IItemRenderer.ItemRenderType.ENTITY){ - GL11.glRotatef(90.5F, 0, 1, 0); - GL11.glTranslated(0, 0, -0.9); - } - } + if (type == IItemRenderer.ItemRenderType.INVENTORY) { + GL11.glScalef(11.8F, 11.8F, 11.8F); + GL11.glRotatef(180, 0, 1, 0); + GL11.glTranslated(-1.2, 0, -0.35); + } else if (type == IItemRenderer.ItemRenderType.ENTITY) { + GL11.glRotatef(90.5F, 0, 1, 0); + GL11.glTranslated(0, 0, -0.9); + } + } - @Override - public int getUpgradeCap(ItemStack itemstack) { - return BalanceConfigHandler.draconicToolsMaxUpgrades; - } + @Override + public int getUpgradeCap(ItemStack itemstack) { + return BalanceConfigHandler.draconicToolsMaxUpgrades; + } - @Override - public int getMaxTier(ItemStack itemstack) { - return 2; - } + @Override + public int getMaxTier(ItemStack itemstack) { + return 2; + } - @Override - public List getUpgradeStats(ItemStack stack) { - return super.getUpgradeStats(stack); - } + @Override + public List getUpgradeStats(ItemStack stack) { + return super.getUpgradeStats(stack); + } - @Override - public int getCapacity(ItemStack stack) { - int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); - return BalanceConfigHandler.draconicToolsBaseStorage + points * BalanceConfigHandler.draconicToolsStoragePerUpgrade; - } + @Override + public int getCapacity(ItemStack stack) { + int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); + return BalanceConfigHandler.draconicToolsBaseStorage + points * BalanceConfigHandler.draconicToolsStoragePerUpgrade; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { - return BalanceConfigHandler.draconicToolsMaxCapacityUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { - return BalanceConfigHandler.draconicToolsMaxDigAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_DEPTH.index) { - return BalanceConfigHandler.draconicToolsMaxDigDepthUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { - return BalanceConfigHandler.draconicToolsMaxDigSpeedUpgradePoints; - } - return BalanceConfigHandler.draconicToolsMaxUpgradePoints; - } + @Override + public int getMaxUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { + return BalanceConfigHandler.draconicToolsMaxCapacityUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { + return BalanceConfigHandler.draconicToolsMaxDigAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_DEPTH.index) { + return BalanceConfigHandler.draconicToolsMaxDigDepthUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { + return BalanceConfigHandler.draconicToolsMaxDigSpeedUpgradePoints; + } + return BalanceConfigHandler.draconicToolsMaxUpgradePoints; + } - @Override - public int getBaseUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { - return BalanceConfigHandler.draconicToolsMinDigAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_DEPTH.index) { - return BalanceConfigHandler.draconicToolsMinDigDepthUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { - return BalanceConfigHandler.draconicToolsMinDigSpeedUpgradePoints; - } - return 0; - } + @Override + public int getBaseUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { + return BalanceConfigHandler.draconicToolsMinDigAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_DEPTH.index) { + return BalanceConfigHandler.draconicToolsMinDigDepthUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { + return BalanceConfigHandler.draconicToolsMinDigSpeedUpgradePoints; + } + return 0; + } // @Override // public boolean isItemTool(ItemStack p_77616_1_) { diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicShovel.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicShovel.java index 2d8d6374..3a2789b1 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicShovel.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicShovel.java @@ -23,114 +23,112 @@ public class DraconicShovel extends MiningTool implements IInventoryTool, IRende // public IIcon itemIcon1; // public IIcon itemIcon2; - public DraconicShovel() { - super(ModItems.AWAKENED); - this.setHarvestLevel("shovel", 10); - this.setUnlocalizedName(Strings.draconicShovelName); - this.setCapacity(BalanceConfigHandler.draconicToolsBaseStorage); - this.setMaxExtract(BalanceConfigHandler.draconicToolsMaxTransfer); - this.setMaxReceive(BalanceConfigHandler.draconicToolsMaxTransfer); - this.energyPerOperation = BalanceConfigHandler.draconicToolsEnergyPerAction; - ModItems.register(this); - } + public DraconicShovel() { + super(ModItems.AWAKENED); + this.setHarvestLevel("shovel", 10); + this.setUnlocalizedName(Strings.draconicShovelName); + this.setCapacity(BalanceConfigHandler.draconicToolsBaseStorage); + this.setMaxExtract(BalanceConfigHandler.draconicToolsMaxTransfer); + this.setMaxReceive(BalanceConfigHandler.draconicToolsMaxTransfer); + this.energyPerOperation = BalanceConfigHandler.draconicToolsEnergyPerAction; + ModItems.register(this); + } - @Override - public List getFields(ItemStack stack, int slot) { - List list = super.getFields(stack, slot); - list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, EnumUpgrade.DIG_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 0).setModifier("AOE")); - list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_DEPTH).setMinMaxAndIncromente(1, EnumUpgrade.DIG_DEPTH.getUpgradePoints(stack), 1).readFromItem(stack, 1)); - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, References.OBLITERATE).readFromItem(stack, false)); - return list; - } + @Override + public List getFields(ItemStack stack, int slot) { + List list = super.getFields(stack, slot); + list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, EnumUpgrade.DIG_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 0).setModifier("AOE")); + list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_DEPTH).setMinMaxAndIncromente(1, EnumUpgrade.DIG_DEPTH.getUpgradePoints(stack), 1).readFromItem(stack, 1)); + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, References.OBLITERATE).readFromItem(stack, false)); + return list; + } - @Override - public String getInventoryName() { - return StatCollector.translateToLocal("info.de.toolInventoryOblit.txt"); - } + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryOblit.txt"); + } - @Override - public int getInventorySlots() { - return 9; - } + @Override + public int getInventorySlots() { + return 9; + } - @Override - public boolean isEnchantValid(Enchantment enchant) { - return enchant.type == EnumEnchantmentType.digger; - } + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.digger; + } - @Override - public void tweakRender(IItemRenderer.ItemRenderType type) { - GL11.glTranslated(0.15, 0.9, -0.12); - GL11.glRotatef(90, 1, 0, 0); - GL11.glRotatef(140, 0, -1, 0); - GL11.glScaled(0.7, 0.7, 0.7); - if (type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) { - GL11.glRotatef(180, 0, 0, 1); - GL11.glTranslated(0, -0.4, 0); - } - else if (type == IItemRenderer.ItemRenderType.INVENTORY){ - GL11.glRotatef(180, 0, 0, 1); - GL11.glScalef(10, 10, 10); - GL11.glRotatef(180, 0, 1, 0); - GL11.glTranslated(-1.45, 0, -0.15); - } - else if (type == IItemRenderer.ItemRenderType.ENTITY){ - GL11.glRotatef(-90.5F, 0, 1, 0); - GL11.glTranslated(-0.38, 0, -0.6); - } - } + @Override + public void tweakRender(IItemRenderer.ItemRenderType type) { + GL11.glTranslated(0.15, 0.9, -0.12); + GL11.glRotatef(90, 1, 0, 0); + GL11.glRotatef(140, 0, -1, 0); + GL11.glScaled(0.7, 0.7, 0.7); + if (type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glRotatef(180, 0, 0, 1); + GL11.glTranslated(0, -0.4, 0); + } else if (type == IItemRenderer.ItemRenderType.INVENTORY) { + GL11.glRotatef(180, 0, 0, 1); + GL11.glScalef(10, 10, 10); + GL11.glRotatef(180, 0, 1, 0); + GL11.glTranslated(-1.45, 0, -0.15); + } else if (type == IItemRenderer.ItemRenderType.ENTITY) { + GL11.glRotatef(-90.5F, 0, 1, 0); + GL11.glTranslated(-0.38, 0, -0.6); + } + } - @Override - public int getUpgradeCap(ItemStack itemstack) { - return BalanceConfigHandler.draconicToolsMaxUpgrades; - } + @Override + public int getUpgradeCap(ItemStack itemstack) { + return BalanceConfigHandler.draconicToolsMaxUpgrades; + } - @Override - public int getMaxTier(ItemStack itemstack) { - return 2; - } + @Override + public int getMaxTier(ItemStack itemstack) { + return 2; + } - @Override - public List getUpgradeStats(ItemStack stack) { - return super.getUpgradeStats(stack); - } + @Override + public List getUpgradeStats(ItemStack stack) { + return super.getUpgradeStats(stack); + } - @Override - public int getCapacity(ItemStack stack) { - int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); - return BalanceConfigHandler.draconicToolsBaseStorage + points * BalanceConfigHandler.draconicToolsStoragePerUpgrade; - } + @Override + public int getCapacity(ItemStack stack) { + int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); + return BalanceConfigHandler.draconicToolsBaseStorage + points * BalanceConfigHandler.draconicToolsStoragePerUpgrade; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { - return BalanceConfigHandler.draconicToolsMaxCapacityUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { - return BalanceConfigHandler.draconicToolsMaxDigAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_DEPTH.index) { - return BalanceConfigHandler.draconicToolsMaxDigDepthUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { - return BalanceConfigHandler.draconicToolsMaxDigSpeedUpgradePoints; - } - return BalanceConfigHandler.draconicToolsMaxUpgradePoints; - } + @Override + public int getMaxUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { + return BalanceConfigHandler.draconicToolsMaxCapacityUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { + return BalanceConfigHandler.draconicToolsMaxDigAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_DEPTH.index) { + return BalanceConfigHandler.draconicToolsMaxDigDepthUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { + return BalanceConfigHandler.draconicToolsMaxDigSpeedUpgradePoints; + } + return BalanceConfigHandler.draconicToolsMaxUpgradePoints; + } - @Override - public int getBaseUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { - return BalanceConfigHandler.draconicToolsMinDigAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_DEPTH.index) { - return BalanceConfigHandler.draconicToolsMinDigDepthUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { - return BalanceConfigHandler.draconicToolsMinDigSpeedUpgradePoints; - } - return 0; - } + @Override + public int getBaseUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { + return BalanceConfigHandler.draconicToolsMinDigAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_DEPTH.index) { + return BalanceConfigHandler.draconicToolsMinDigDepthUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { + return BalanceConfigHandler.draconicToolsMinDigSpeedUpgradePoints; + } + return 0; + } // @Override // public boolean isItemTool(ItemStack p_77616_1_) { // return true; diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconiumFluxCapacitor.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconiumFluxCapacitor.java index e1f067cd..b5a3b783 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconiumFluxCapacitor.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconiumFluxCapacitor.java @@ -31,198 +31,171 @@ import net.minecraft.world.World; * Created by Brandon on 24/11/2014. */ public class DraconiumFluxCapacitor extends RFItemBase implements IUpgradableItem { - IIcon[] icons = new IIcon[2]; + IIcon[] icons = new IIcon[2]; - public DraconiumFluxCapacitor() - { - this.setUnlocalizedName(Strings.draconiumFluxCapacitorName); - this.setCreativeTab(DraconicEvolution.tabToolsWeapons); - this.setHasSubtypes(true); - this.setMaxStackSize(1); - ModItems.register(this); - } - - @SideOnly(Side.CLIENT) - @Override - public void registerIcons(IIconRegister iconRegister) { - icons[0] = iconRegister.registerIcon(getUnwrappedUnlocalizedName(super.getUnlocalizedName())+0); - icons[1] = iconRegister.registerIcon(getUnwrappedUnlocalizedName(super.getUnlocalizedName())+1); - } - - @SideOnly(Side.CLIENT) - @Override - public IIcon getIconFromDamage(int damage) { - return icons[damage]; - } - - @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", 0)); - list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", - BalanceConfigHandler.wyvernCapacitorBaseStorage)); - list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 1), "Energy", 0)); - list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 1), "Energy", - BalanceConfigHandler.draconicCapacitorBaseStorage)); - } - - @Override - public String getUnlocalizedName(ItemStack itemStack) { - return super.getUnlocalizedName(itemStack)+itemStack.getItemDamage(); - } - - @Override - public int getCapacity(ItemStack stack){ - int points = EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); - return stack.getItemDamage() == 0 ? - BalanceConfigHandler.wyvernCapacitorBaseStorage + - points * BalanceConfigHandler.wyvernCapacitorStoragePerUpgrade : - stack.getItemDamage() == 1 ? - BalanceConfigHandler.draconicCapacitorBaseStorage + - points * BalanceConfigHandler.draconicCapacitorStoragePerUpgrade : 0; + public DraconiumFluxCapacitor() { + this.setUnlocalizedName(Strings.draconiumFluxCapacitorName); + this.setCreativeTab(DraconicEvolution.tabToolsWeapons); + this.setHasSubtypes(true); + this.setMaxStackSize(1); + ModItems.register(this); } - @Override - public int getMaxExtract(ItemStack stack){ - return stack.getItemDamage() == 0 ? - BalanceConfigHandler.wyvernCapacitorMaxExtract : - stack.getItemDamage() == 1 ? - BalanceConfigHandler.draconicCapacitorMaxExtract : 0; - } + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister iconRegister) { + icons[0] = iconRegister.registerIcon(getUnwrappedUnlocalizedName(super.getUnlocalizedName()) + 0); + icons[1] = iconRegister.registerIcon(getUnwrappedUnlocalizedName(super.getUnlocalizedName()) + 1); + } - @Override - public int getMaxReceive(ItemStack stack){ - return stack.getItemDamage() == 0 ? - BalanceConfigHandler.wyvernCapacitorMaxReceive : - stack.getItemDamage() == 1 ? - BalanceConfigHandler.draconicCapacitorMaxReceive: 0; - } + @SideOnly(Side.CLIENT) + @Override + public IIcon getIconFromDamage(int damage) { + return icons[damage]; + } - @Override - public void onUpdate(ItemStack container, World world, Entity entity, int var1, boolean b) { - if (!(entity instanceof EntityPlayer)) return; - EntityPlayer player = (EntityPlayer) entity; + @SideOnly(Side.CLIENT) + @SuppressWarnings("unchecked") + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", 0)); + list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", BalanceConfigHandler.wyvernCapacitorBaseStorage)); + list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 1), "Energy", 0)); + list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 1), "Energy", BalanceConfigHandler.draconicCapacitorBaseStorage)); + } - int mode = ItemNBTHelper.getShort(container, "Mode", (short)0); + @Override + public String getUnlocalizedName(ItemStack itemStack) { + return super.getUnlocalizedName(itemStack) + itemStack.getItemDamage(); + } - if (mode == 1 || mode == 3){ //Charge Hotbar - for (int i = 0; i < 9; i++){ - int max = Math.min(getEnergyStored(container), getMaxExtract(container)); - ItemStack stack = player.inventory.getStackInSlot(i); + @Override + public int getCapacity(ItemStack stack) { + int points = EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); + return stack.getItemDamage() == 0 ? BalanceConfigHandler.wyvernCapacitorBaseStorage + points * BalanceConfigHandler.wyvernCapacitorStoragePerUpgrade : stack.getItemDamage() == 1 ? BalanceConfigHandler.draconicCapacitorBaseStorage + points * BalanceConfigHandler.draconicCapacitorStoragePerUpgrade : 0; + } - if (stack != null && stack.getItem() instanceof IEnergyContainerItem && stack.getItem() != ModItems.draconiumFluxCapacitor) { - IEnergyContainerItem item = (IEnergyContainerItem)stack.getItem(); - extractEnergy(container, item.receiveEnergy(stack, max, false), false); - } - } - } + @Override + public int getMaxExtract(ItemStack stack) { + return stack.getItemDamage() == 0 ? BalanceConfigHandler.wyvernCapacitorMaxExtract : stack.getItemDamage() == 1 ? BalanceConfigHandler.draconicCapacitorMaxExtract : 0; + } - if (mode == 2 || mode == 3){ //Charge Armor and held item - for (int i = mode == 3 ? 1 : 0; i < 5; i++){ - int max = Math.min(getEnergyStored(container), getMaxExtract(container)); - ItemStack stack = player.getEquipmentInSlot(i); + @Override + public int getMaxReceive(ItemStack stack) { + return stack.getItemDamage() == 0 ? BalanceConfigHandler.wyvernCapacitorMaxReceive : stack.getItemDamage() == 1 ? BalanceConfigHandler.draconicCapacitorMaxReceive : 0; + } - if (stack != null && stack.getItem() instanceof IEnergyContainerItem && stack.getItem() != ModItems.draconiumFluxCapacitor) { - IEnergyContainerItem item = (IEnergyContainerItem)stack.getItem(); - extractEnergy(container, item.receiveEnergy(stack, max, false), false); - } - } - } - } + @Override + public void onUpdate(ItemStack container, World world, Entity entity, int var1, boolean b) { + if (!(entity instanceof EntityPlayer)) return; + EntityPlayer player = (EntityPlayer) entity; - @Override - public boolean hasEffect(ItemStack stack, int pass) { - return ItemNBTHelper.getShort(stack, "Mode", (short)0) > 0; - } + int mode = ItemNBTHelper.getShort(container, "Mode", (short) 0); + + if (mode == 1 || mode == 3) { //Charge Hotbar + for (int i = 0; i < 9; i++) { + int max = Math.min(getEnergyStored(container), getMaxExtract(container)); + ItemStack stack = player.inventory.getStackInSlot(i); + + if (stack != null && stack.getItem() instanceof IEnergyContainerItem && stack.getItem() != ModItems.draconiumFluxCapacitor) { + IEnergyContainerItem item = (IEnergyContainerItem) stack.getItem(); + extractEnergy(container, item.receiveEnergy(stack, max, false), false); + } + } + } + + if (mode == 2 || mode == 3) { //Charge Armor and held item + for (int i = mode == 3 ? 1 : 0; i < 5; i++) { + int max = Math.min(getEnergyStored(container), getMaxExtract(container)); + ItemStack stack = player.getEquipmentInSlot(i); + + if (stack != null && stack.getItem() instanceof IEnergyContainerItem && stack.getItem() != ModItems.draconiumFluxCapacitor) { + IEnergyContainerItem item = (IEnergyContainerItem) stack.getItem(); + extractEnergy(container, item.receiveEnergy(stack, max, false), false); + } + } + } + } + + @Override + public boolean hasEffect(ItemStack stack, int pass) { + return ItemNBTHelper.getShort(stack, "Mode", (short) 0) > 0; + } @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (player.isSneaking()){ - int mode = ItemNBTHelper.getShort(stack, "Mode", (short)0); + if (player.isSneaking()) { + int mode = ItemNBTHelper.getShort(stack, "Mode", (short) 0); int newMode = mode == 3 ? 0 : mode + 1; ItemNBTHelper.setShort(stack, "Mode", (short) newMode); - if (world.isRemote) player.addChatComponentMessage(new ChatComponentTranslation(InfoHelper.ITC()+StatCollector.translateToLocal("info.de.capacitorMode.txt")+": "+InfoHelper.HITC()+StatCollector.translateToLocal("info.de.capacitorMode"+ItemNBTHelper.getShort(stack, "Mode", (short)0)+".txt"))); + if (world.isRemote) + player.addChatComponentMessage(new ChatComponentTranslation(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.capacitorMode.txt") + ": " + InfoHelper.HITC() + StatCollector.translateToLocal("info.de.capacitorMode" + ItemNBTHelper.getShort(stack, "Mode", (short) 0) + ".txt"))); } return stack; } - @Override - @SideOnly(Side.CLIENT) - @SuppressWarnings({"rawtypes", "unchecked"}) - public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) - { - if (InfoHelper.holdShiftForDetails(list)){ + @Override + @SideOnly(Side.CLIENT) + @SuppressWarnings({"rawtypes", "unchecked"}) + public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) { + if (InfoHelper.holdShiftForDetails(list)) { - list.add(StatCollector.translateToLocal("info.de.changwMode.txt")); - list.add(InfoHelper.ITC()+StatCollector.translateToLocal("info.de.capacitorMode.txt")+": "+InfoHelper.HITC()+StatCollector.translateToLocal("info.de.capacitorMode"+ItemNBTHelper.getShort(stack, "Mode", (short)0)+".txt")); - //InfoHelper.addLore(stack, list); - } - ToolBase.holdCTRLForUpgrades(list, stack); - InfoHelper.addEnergyInfo(stack, list); - } + list.add(StatCollector.translateToLocal("info.de.changwMode.txt")); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.capacitorMode.txt") + ": " + InfoHelper.HITC() + StatCollector.translateToLocal("info.de.capacitorMode" + ItemNBTHelper.getShort(stack, "Mode", (short) 0) + ".txt")); + //InfoHelper.addLore(stack, list); + } + ToolBase.holdCTRLForUpgrades(list, stack); + InfoHelper.addEnergyInfo(stack, list); + } - @Override - public boolean hasProfiles() { - return false; - } + @Override + public boolean hasProfiles() { + return false; + } - @Override - public List getUpgrades(ItemStack itemstack) { - return new ArrayList(){{ - add(EnumUpgrade.RF_CAPACITY); - }}; - } + @Override + public List getUpgrades(ItemStack itemstack) { + return new ArrayList() {{ + add(EnumUpgrade.RF_CAPACITY); + }}; + } - @Override - public int getUpgradeCap(ItemStack stack) { - return stack.getItemDamage() == 0 ? - BalanceConfigHandler.wyvernCapacitorMaxUpgrades : - stack.getItemDamage() == 1 ? - BalanceConfigHandler.draconicCapacitorMaxUpgrades : 0; - } + @Override + public int getUpgradeCap(ItemStack stack) { + return stack.getItemDamage() == 0 ? BalanceConfigHandler.wyvernCapacitorMaxUpgrades : stack.getItemDamage() == 1 ? BalanceConfigHandler.draconicCapacitorMaxUpgrades : 0; + } - @Override - public int getMaxTier(ItemStack stack) { - return stack.getItemDamage() == 0 ? 1 : 2; - } + @Override + public int getMaxTier(ItemStack stack) { + return stack.getItemDamage() == 0 ? 1 : 2; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex) { - return Math.max(BalanceConfigHandler.wyvernCapacitorMaxUpgradePoints, BalanceConfigHandler.draconicCapacitorMaxUpgradePoints); - } + @Override + public int getMaxUpgradePoints(int upgradeIndex) { + return Math.max(BalanceConfigHandler.wyvernCapacitorMaxUpgradePoints, BalanceConfigHandler.draconicCapacitorMaxUpgradePoints); + } - @Override - public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) - { - if (stack == null) - { - return getMaxUpgradePoints(upgradeIndex); - } - if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { - return stack.getItemDamage() == 0 ? - BalanceConfigHandler.wyvernCapacitorMaxCapacityUpgradePoints : - stack.getItemDamage() == 1 ? - BalanceConfigHandler.draconicCapacitorMaxCapacityUpgradePoints : - getMaxUpgradePoints(upgradeIndex); - } - return stack.getItemDamage() == 0 ? - BalanceConfigHandler.wyvernCapacitorMaxUpgradePoints : - stack.getItemDamage() == 1 ? - BalanceConfigHandler.draconicCapacitorMaxUpgradePoints : - getMaxUpgradePoints(upgradeIndex); - } + @Override + public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) { + if (stack == null) { + return getMaxUpgradePoints(upgradeIndex); + } + if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { + return stack.getItemDamage() == 0 ? BalanceConfigHandler.wyvernCapacitorMaxCapacityUpgradePoints : stack.getItemDamage() == 1 ? BalanceConfigHandler.draconicCapacitorMaxCapacityUpgradePoints : getMaxUpgradePoints(upgradeIndex); + } + return stack.getItemDamage() == 0 ? BalanceConfigHandler.wyvernCapacitorMaxUpgradePoints : stack.getItemDamage() == 1 ? BalanceConfigHandler.draconicCapacitorMaxUpgradePoints : getMaxUpgradePoints(upgradeIndex); + } - @Override - public int getBaseUpgradePoints(int upgradeIndex) { - return 0; - } + @Override + public int getBaseUpgradePoints(int upgradeIndex) { + return 0; + } - @Override - public List getUpgradeStats(ItemStack stack) { - List strings = new ArrayList(); - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.RFCapacity.txt")+": "+InfoHelper.HITC()+ Utills.formatNumber(getMaxEnergyStored(stack))); - return strings; - } + @Override + public List getUpgradeStats(ItemStack stack) { + List strings = new ArrayList(); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.RFCapacity.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getMaxEnergyStored(stack))); + return strings; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/EnderArrow.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/EnderArrow.java index 78518b1b..94d50bf7 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/EnderArrow.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/EnderArrow.java @@ -17,23 +17,23 @@ import java.util.List; * Created by Brandon on 15/08/2014. */ public class EnderArrow extends ItemDE { - public EnderArrow(){ - this.setUnlocalizedName(Strings.enderArrowName); - this.setCreativeTab(DraconicEvolution.tabToolsWeapons); - ModItems.register(this); - } + public EnderArrow() { + this.setUnlocalizedName(Strings.enderArrowName); + this.setCreativeTab(DraconicEvolution.tabToolsWeapons); + ModItems.register(this); + } - @Override - public void registerIcons(IIconRegister iconRegister) { - itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "ender_arrow"); - } + @Override + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "ender_arrow"); + } - @SuppressWarnings("unchecked") - @Override - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { - list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.arrowInfo.txt")); - list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.arrowInfo0.txt")); - } + @SuppressWarnings("unchecked") + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { + list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.arrowInfo.txt")); + list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.arrowInfo0.txt")); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/Magnet.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/Magnet.java index 9249c840..a422f308 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/Magnet.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/Magnet.java @@ -30,62 +30,62 @@ import java.util.List; * Created by brandon3055 on 9/3/2016. */ public class Magnet extends ItemDE { - private IIcon draconium; - private IIcon awakened; + private IIcon draconium; + private IIcon awakened; - public Magnet(){ - this.setUnlocalizedName("magnet"); - this.setCreativeTab(DraconicEvolution.tabBlocksItems); - this.setMaxStackSize(1); - ModItems.register(this); - } + public Magnet() { + this.setUnlocalizedName("magnet"); + this.setCreativeTab(DraconicEvolution.tabBlocksItems); + this.setMaxStackSize(1); + ModItems.register(this); + } - @Override - public void registerIcons(IIconRegister iconRegister) { - draconium = iconRegister.registerIcon(References.RESOURCESPREFIX+"magnetWyvern"); - awakened = iconRegister.registerIcon(References.RESOURCESPREFIX+"magnetDraconic"); - } + @Override + public void registerIcons(IIconRegister iconRegister) { + draconium = iconRegister.registerIcon(References.RESOURCESPREFIX + "magnetWyvern"); + awakened = iconRegister.registerIcon(References.RESOURCESPREFIX + "magnetDraconic"); + } - @Override - public IIcon getIconFromDamage(int dmg) { - return dmg == 0 ? draconium : awakened; - } + @Override + public IIcon getIconFromDamage(int dmg) { + return dmg == 0 ? draconium : awakened; + } - @Override - public boolean getHasSubtypes() { - return true; - } + @Override + public boolean getHasSubtypes() { + return true; + } - @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - @Override - public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { - list.add(new ItemStack(item, 1, 0)); - list.add(new ItemStack(item, 1, 1)); - } + @SideOnly(Side.CLIENT) + @SuppressWarnings("unchecked") + @Override + public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { + list.add(new ItemStack(item, 1, 0)); + list.add(new ItemStack(item, 1, 1)); + } - @Override - public String getUnlocalizedName(ItemStack itemStack) { - return super.getUnlocalizedName(itemStack)+(itemStack.getItemDamage() == 0 ? ".wyvern" : ".draconic"); - } + @Override + public String getUnlocalizedName(ItemStack itemStack) { + return super.getUnlocalizedName(itemStack) + (itemStack.getItemDamage() == 0 ? ".wyvern" : ".draconic"); + } - @SideOnly(Side.CLIENT) - @Override - public boolean hasEffect(ItemStack stack, int pass) { - return ItemNBTHelper.getBoolean(stack, "MagnetEnabled", false); - } + @SideOnly(Side.CLIENT) + @Override + public boolean hasEffect(ItemStack stack, int pass) { + return ItemNBTHelper.getBoolean(stack, "MagnetEnabled", false); + } - @SuppressWarnings("unchecked") - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean hotbar) { - if (!entity.isSneaking() && entity.ticksExisted % 5 == 0 && ItemNBTHelper.getBoolean(stack, "MagnetEnabled", false) && entity instanceof EntityPlayer){ - int range = stack.getItemDamage() == 0 ? 8 : 32; + @SuppressWarnings("unchecked") + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean hotbar) { + if (!entity.isSneaking() && entity.ticksExisted % 5 == 0 && ItemNBTHelper.getBoolean(stack, "MagnetEnabled", false) && entity instanceof EntityPlayer) { + int range = stack.getItemDamage() == 0 ? 8 : 32; - List items = world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(entity.posX, entity.posY, entity.posZ, entity.posX, entity.posY, entity.posZ).expand(range, range, range)); + List items = world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(entity.posX, entity.posY, entity.posZ, entity.posX, entity.posY, entity.posZ).expand(range, range, range)); - boolean flag = false; + boolean flag = false; - for (EntityItem item : items) { + for (EntityItem item : items) { if (item.getEntityItem() == null) { continue; } @@ -96,43 +96,43 @@ public class Magnet extends ItemDE { } flag = true; - if (item.delayBeforeCanPickup > 0) item.delayBeforeCanPickup = 0; - item.motionX = item.motionY = item.motionZ = 0; - item.setPosition(entity.posX-0.2+(world.rand.nextDouble()*0.4), entity.posY-0.6, entity.posZ-0.2+(world.rand.nextDouble()*0.4)); - } - if (flag) world.playSoundAtEntity(entity, "random.orb", 0.1F, 0.5F * ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 2F)); + if (item.delayBeforeCanPickup > 0) item.delayBeforeCanPickup = 0; + item.motionX = item.motionY = item.motionZ = 0; + item.setPosition(entity.posX - 0.2 + (world.rand.nextDouble() * 0.4), entity.posY - 0.6, entity.posZ - 0.2 + (world.rand.nextDouble() * 0.4)); + } + if (flag) + world.playSoundAtEntity(entity, "random.orb", 0.1F, 0.5F * ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 2F)); - List xp = world.getEntitiesWithinAABB(EntityXPOrb.class, AxisAlignedBB.getBoundingBox(entity.posX, entity.posY, entity.posZ, entity.posX, entity.posY, entity.posZ).expand(4, 4, 4)); + List xp = world.getEntitiesWithinAABB(EntityXPOrb.class, AxisAlignedBB.getBoundingBox(entity.posX, entity.posY, entity.posZ, entity.posX, entity.posY, entity.posZ).expand(4, 4, 4)); - EntityPlayer player = (EntityPlayer)entity; + EntityPlayer player = (EntityPlayer) entity; - for (EntityXPOrb orb : xp){ - if (!world.isRemote) - { - if (orb.field_70532_c == 0) - { - if (MinecraftForge.EVENT_BUS.post(new PlayerPickupXpEvent(player, orb))) continue; - world.playSoundAtEntity(player, "random.orb", 0.1F, 0.5F * ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.8F)); - player.onItemPickup(orb, 1); - player.addExperience(orb.xpValue); - orb.setDead(); - } - } - } - } - } + for (EntityXPOrb orb : xp) { + if (!world.isRemote) { + if (orb.field_70532_c == 0) { + if (MinecraftForge.EVENT_BUS.post(new PlayerPickupXpEvent(player, orb))) continue; + world.playSoundAtEntity(player, "random.orb", 0.1F, 0.5F * ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.8F)); + player.onItemPickup(orb, 1); + player.addExperience(orb.xpValue); + orb.setDead(); + } + } + } + } + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (player.isSneaking()) ItemNBTHelper.setBoolean(stack, "MagnetEnabled", !ItemNBTHelper.getBoolean(stack, "MagnetEnabled", false)); - return stack; - } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (player.isSneaking()) + ItemNBTHelper.setBoolean(stack, "MagnetEnabled", !ItemNBTHelper.getBoolean(stack, "MagnetEnabled", false)); + return stack; + } - @SuppressWarnings("unchecked") - @Override - public void addInformation(ItemStack stack, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { - list.add(StatCollector.translateToLocal("info.de.shiftRightClickToActivate.txt")); - int range = stack.getItemDamage() == 0 ? 8 : 32; - list.add(InfoHelper.HITC()+range+InfoHelper.ITC()+" "+StatCollector.translateToLocal("info.de.blockRange.txt")); - } + @SuppressWarnings("unchecked") + @Override + public void addInformation(ItemStack stack, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { + list.add(StatCollector.translateToLocal("info.de.shiftRightClickToActivate.txt")); + int range = stack.getItemDamage() == 0 ? 8 : 32; + list.add(InfoHelper.HITC() + range + InfoHelper.ITC() + " " + StatCollector.translateToLocal("info.de.blockRange.txt")); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/ObliterationCatalyst.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/ObliterationCatalyst.java index 540eae91..71126ba8 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/ObliterationCatalyst.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/ObliterationCatalyst.java @@ -15,51 +15,51 @@ import net.minecraft.world.World; * Created by Brandon on 14/09/2014. */ public class ObliterationCatalyst extends ItemDE { - public ObliterationCatalyst(){ - this.setUnlocalizedName(Strings.obliterationCatalystName); - this.setCreativeTab(DraconicEvolution.tabToolsWeapons); - this.setMaxStackSize(1); - ModItems.register(this); - } + public ObliterationCatalyst() { + this.setUnlocalizedName(Strings.obliterationCatalystName); + this.setCreativeTab(DraconicEvolution.tabToolsWeapons); + this.setMaxStackSize(1); + ModItems.register(this); + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - LogHelper.info("onItemRightClick"); - player.setItemInUse(stack, getMaxItemUseDuration(stack)); - if (!world.isRemote) world.spawnEntityInWorld(new EntityChaosDrill(world, player)); - return stack; - } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + LogHelper.info("onItemRightClick"); + player.setItemInUse(stack, getMaxItemUseDuration(stack)); + if (!world.isRemote) world.spawnEntityInWorld(new EntityChaosDrill(world, player)); + return stack; + } - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int i1, int i2, int i3, int i4, float f1, float f2, float f3) { - //LogHelper.info("onItemUse"); - return false; - } + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int i1, int i2, int i3, int i4, float f1, float f2, float f3) { + //LogHelper.info("onItemUse"); + return false; + } - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int i1, boolean b1) { - } + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int i1, boolean b1) { + } - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - //LogHelper.info("onUsingTick"); + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + //LogHelper.info("onUsingTick"); - super.onUsingTick(stack, player, count); - } + super.onUsingTick(stack, player, count); + } - @Override - public int getMaxItemUseDuration(ItemStack p_77626_1_) { - //LogHelper.info("getMaxItemUseDuration"); - return 70000; - } + @Override + public int getMaxItemUseDuration(ItemStack p_77626_1_) { + //LogHelper.info("getMaxItemUseDuration"); + return 70000; + } - @Override - public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int meta) { - //LogHelper.info("onPlayerStoppedUsing"); - } + @Override + public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int meta) { + //LogHelper.info("onPlayerStoppedUsing"); + } - @Override - public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { - return stack; - } + @Override + public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { + return stack; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/SafetyMatch.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/SafetyMatch.java index 06ccacf0..eaaccf70 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/SafetyMatch.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/SafetyMatch.java @@ -25,112 +25,101 @@ import java.util.List; */ public class SafetyMatch extends ItemDE { - IIcon boxIcon; - public SafetyMatch() - { - this.setUnlocalizedName(Strings.safetyMatchName); - this.setCreativeTab(DraconicEvolution.tabToolsWeapons); - this.setHasSubtypes(true); - ModItems.register(this); - } + IIcon boxIcon; - @Override - public String getUnlocalizedName(ItemStack itemStack) { - if (itemStack.getItemDamage() == 1000) return super.getUnlocalizedName(itemStack); - else return super.getUnlocalizedName(itemStack) + "Box"; - } + public SafetyMatch() { + this.setUnlocalizedName(Strings.safetyMatchName); + this.setCreativeTab(DraconicEvolution.tabToolsWeapons); + this.setHasSubtypes(true); + ModItems.register(this); + } - @SuppressWarnings("ALL") - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { - list.add(new ItemStack(item, 1, 0)); - list.add(new ItemStack(item, 1, 1000)); - } + @Override + public String getUnlocalizedName(ItemStack itemStack) { + if (itemStack.getItemDamage() == 1000) return super.getUnlocalizedName(itemStack); + else return super.getUnlocalizedName(itemStack) + "Box"; + } - @Override - public int getItemStackLimit(ItemStack stack) { - return stack.getItemDamage() == 1000 ? 16 : 1; - } + @SuppressWarnings("ALL") + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) { + list.add(new ItemStack(item, 1, 0)); + list.add(new ItemStack(item, 1, 1000)); + } - @Override - public int getMaxDamage(ItemStack stack) { - return stack.getItemDamage() == 1000 ? 1000 : 20; - } + @Override + public int getItemStackLimit(ItemStack stack) { + return stack.getItemDamage() == 1000 ? 16 : 1; + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister iconRegister) { - itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "safety_match"); - boxIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "box_of_matches"); - } + @Override + public int getMaxDamage(ItemStack stack) { + return stack.getItemDamage() == 1000 ? 1000 : 20; + } - @Override - public boolean showDurabilityBar(ItemStack stack) { - return stack.getItemDamage() != 1000 && stack.getItemDamage() != 0; - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "safety_match"); + boxIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "box_of_matches"); + } - @Override - public IIcon getIconFromDamage(int damage) { - return damage == 1000 ? itemIcon : boxIcon; - } + @Override + public boolean showDurabilityBar(ItemStack stack) { + return stack.getItemDamage() != 1000 && stack.getItemDamage() != 0; + } - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) - { - if (p_77648_7_ == 0) - { - --y; - } + @Override + public IIcon getIconFromDamage(int damage) { + return damage == 1000 ? itemIcon : boxIcon; + } - if (p_77648_7_ == 1) - { - ++y; - } + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { + if (p_77648_7_ == 0) { + --y; + } - if (p_77648_7_ == 2) - { - --z; - } + if (p_77648_7_ == 1) { + ++y; + } - if (p_77648_7_ == 3) - { - ++z; - } + if (p_77648_7_ == 2) { + --z; + } - if (p_77648_7_ == 4) - { - --x; - } + if (p_77648_7_ == 3) { + ++z; + } - if (p_77648_7_ == 5) - { - ++x; - } + if (p_77648_7_ == 4) { + --x; + } - if (!player.canPlayerEdit(x, y, z, p_77648_7_, stack)) - { - return false; - } - else - { - if (world.isAirBlock(x, y, z)) - { - world.playSoundEffect((double) x + 0.5D, (double) y + 0.5D, (double) z + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); - world.setBlock(x, y, z, ModBlocks.safetyFlame); - } + if (p_77648_7_ == 5) { + ++x; + } - if (!player.capabilities.isCreativeMode) { - if (stack.getItemDamage() == 1000) stack.stackSize--; - else stack.damageItem(1, player); - } - return true; - } - } + if (!player.canPlayerEdit(x, y, z, p_77648_7_, stack)) { + return false; + } else { + if (world.isAirBlock(x, y, z)) { + world.playSoundEffect((double) x + 0.5D, (double) y + 0.5D, (double) z + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); + world.setBlock(x, y, z, ModBlocks.safetyFlame); + } - @SuppressWarnings("ALL") - @SideOnly(Side.CLIENT) - @Override - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { - list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.safetyMatch.txt")); - } + if (!player.capabilities.isCreativeMode) { + if (stack.getItemDamage() == 1000) stack.stackSize--; + else stack.damageItem(1, player); + } + return true; + } + } + + @SuppressWarnings("ALL") + @SideOnly(Side.CLIENT) + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.safetyMatch.txt")); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKI.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKI.java index c8153d82..b2c1a03d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKI.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKI.java @@ -28,137 +28,126 @@ import java.util.List; public class TeleporterMKI extends ItemDE { - public TeleporterMKI(boolean MKII) { - } + public TeleporterMKI(boolean MKII) { + } - public TeleporterMKI() { - this.setUnlocalizedName(Strings.teleporterMKIName); - this.setCreativeTab(DraconicEvolution.tabToolsWeapons); - this.setMaxDamage(19); - this.setMaxStackSize(1); - ModItems.register(this); - } + public TeleporterMKI() { + this.setUnlocalizedName(Strings.teleporterMKIName); + this.setCreativeTab(DraconicEvolution.tabToolsWeapons); + this.setMaxDamage(19); + this.setMaxStackSize(1); + ModItems.register(this); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(final IIconRegister iconRegister) { - this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + Strings.teleporterMKIName); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister iconRegister) { + this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + Strings.teleporterMKIName); + } - @Override - public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { - if (getLocation(stack) == null) - { - if (player.worldObj.isRemote) - player.addChatMessage(new ChatComponentTranslation("msg.teleporterUnSet.txt")); - return true; - } + @Override + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { + if (getLocation(stack) == null) { + if (player.worldObj.isRemote) + player.addChatMessage(new ChatComponentTranslation("msg.teleporterUnSet.txt")); + return true; + } - if (entity instanceof EntityPlayer) - { - if (player.worldObj.isRemote) player.addChatMessage(new ChatComponentTranslation("msg.teleporterPlayerT1.txt")); - return true; - } + if (entity instanceof EntityPlayer) { + if (player.worldObj.isRemote) + player.addChatMessage(new ChatComponentTranslation("msg.teleporterPlayerT1.txt")); + return true; + } - if (entity instanceof IBossDisplayData || !(entity instanceof EntityLiving)) return true; + if (entity instanceof IBossDisplayData || !(entity instanceof EntityLiving)) return true; - if (player.getHealth() > 2 || player.capabilities.isCreativeMode) - { - stack.damageItem(1, player); - if (!player.capabilities.isCreativeMode) player.setHealth(player.getHealth() - 2); - getLocation(stack).sendEntityToCoords(entity); - if (player.worldObj.isRemote) player.addChatMessage(new ChatComponentText(new ChatComponentTranslation("msg.teleporterSentMob.txt").getFormattedText() + " x:" + (int) getLocation(stack).getXCoord() + " y:" + (int) getLocation(stack).getYCoord() + " z:" + (int) getLocation(stack).getZCoord() + " Dimension: " + getLocation(stack).getDimensionName())); - } - else if (player.worldObj.isRemote) - player.addChatMessage(new ChatComponentTranslation("msg.teleporterLowHealth.txt")); + if (player.getHealth() > 2 || player.capabilities.isCreativeMode) { + stack.damageItem(1, player); + if (!player.capabilities.isCreativeMode) player.setHealth(player.getHealth() - 2); + getLocation(stack).sendEntityToCoords(entity); + if (player.worldObj.isRemote) + player.addChatMessage(new ChatComponentText(new ChatComponentTranslation("msg.teleporterSentMob.txt").getFormattedText() + " x:" + (int) getLocation(stack).getXCoord() + " y:" + (int) getLocation(stack).getYCoord() + " z:" + (int) getLocation(stack).getZCoord() + " Dimension: " + getLocation(stack).getDimensionName())); + } else if (player.worldObj.isRemote) + player.addChatMessage(new ChatComponentTranslation("msg.teleporterLowHealth.txt")); - return true; - } + return true; + } - @Override - public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) { - if (player.isSneaking()) - { - if (getLocation(stack) == null) - { - if (world.isRemote) - { - player.addChatMessage(new ChatComponentText(new ChatComponentTranslation("msg.teleporterBound.txt").getFormattedText() + "{X:" + (int) player.posX + " Y:" + (int) player.posY + " Z:" + (int) player.posZ + " Dim:" + player.worldObj.provider.getDimensionName() + "}")); - }else - { - ItemNBTHelper.setDouble(stack, "X", player.posX); - ItemNBTHelper.setDouble(stack, "Y", player.posY); - ItemNBTHelper.setDouble(stack, "Z", player.posZ); - ItemNBTHelper.setFloat(stack, "Yaw", player.rotationYaw); - ItemNBTHelper.setFloat(stack, "Pitch", player.rotationPitch); - ItemNBTHelper.setInteger(stack, "Dimension", player.dimension); - ItemNBTHelper.setBoolean(stack, "IsSet", true); - ItemNBTHelper.setString(stack, "DimentionName", BrandonsCore.proxy.getMCServer().worldServerForDimension(player.dimension).provider.getDimensionName()); - } - return stack; - } else if (world.isRemote) - player.addChatMessage(new ChatComponentTranslation("msg.teleporterAlreadySet.txt")); + @Override + public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) { + if (player.isSneaking()) { + if (getLocation(stack) == null) { + if (world.isRemote) { + player.addChatMessage(new ChatComponentText(new ChatComponentTranslation("msg.teleporterBound.txt").getFormattedText() + "{X:" + (int) player.posX + " Y:" + (int) player.posY + " Z:" + (int) player.posZ + " Dim:" + player.worldObj.provider.getDimensionName() + "}")); + } else { + ItemNBTHelper.setDouble(stack, "X", player.posX); + ItemNBTHelper.setDouble(stack, "Y", player.posY); + ItemNBTHelper.setDouble(stack, "Z", player.posZ); + ItemNBTHelper.setFloat(stack, "Yaw", player.rotationYaw); + ItemNBTHelper.setFloat(stack, "Pitch", player.rotationPitch); + ItemNBTHelper.setInteger(stack, "Dimension", player.dimension); + ItemNBTHelper.setBoolean(stack, "IsSet", true); + ItemNBTHelper.setString(stack, "DimentionName", BrandonsCore.proxy.getMCServer().worldServerForDimension(player.dimension).provider.getDimensionName()); + } + return stack; + } else if (world.isRemote) + player.addChatMessage(new ChatComponentTranslation("msg.teleporterAlreadySet.txt")); - return stack; - } else - { - if (getLocation(stack) == null) - { - if (world.isRemote) player.addChatMessage(new ChatComponentTranslation("msg.teleporterUnSet.txt")); - return stack; - } + return stack; + } else { + if (getLocation(stack) == null) { + if (world.isRemote) player.addChatMessage(new ChatComponentTranslation("msg.teleporterUnSet.txt")); + return stack; + } - if (player.getHealth() > 2 || player.capabilities.isCreativeMode) - { - getLocation(stack).sendEntityToCoords(player); - stack.damageItem(1, player); - if (!player.capabilities.isCreativeMode) player.setHealth(player.getHealth() - 2); - } else if (world.isRemote) - player.addChatMessage(new ChatComponentTranslation("msg.teleporterLowHealth.txt")); - return stack; - } + if (player.getHealth() > 2 || player.capabilities.isCreativeMode) { + getLocation(stack).sendEntityToCoords(player); + stack.damageItem(1, player); + if (!player.capabilities.isCreativeMode) player.setHealth(player.getHealth() - 2); + } else if (world.isRemote) + player.addChatMessage(new ChatComponentTranslation("msg.teleporterLowHealth.txt")); + return stack; + } - } + } - @SuppressWarnings({"rawtypes", "unchecked"}) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) { - if (!ItemNBTHelper.getBoolean(stack, "IsSet", false)) - { - list.add(EnumChatFormatting.RED + StatCollector.translateToLocal("info.teleporterInfUnset1.txt")); - list.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.teleporterInfUnset2.txt")); - list.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.teleporterInfUnset3.txt")); - list.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.teleporterInfUnset4.txt")); - list.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.teleporterInfUnset5.txt")); - } else - { - list.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("info.teleporterInfSet1.txt")); - list.add(EnumChatFormatting.WHITE + "{x:" + (int) ItemNBTHelper.getDouble(stack, "X", 0) + " y:" + (int) ItemNBTHelper.getDouble(stack, "Y", 0) + " z:" + (int) ItemNBTHelper.getDouble(stack, "Z", 0) + " Dim:" + getLocation(stack).getDimensionName() + "}"); - list.add(EnumChatFormatting.BLUE + String.valueOf(stack.getMaxDamage() - stack.getItemDamage() + 1) + " " + StatCollector.translateToLocal("info.teleporterInfSet2.txt")); - } - } + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) { + if (!ItemNBTHelper.getBoolean(stack, "IsSet", false)) { + list.add(EnumChatFormatting.RED + StatCollector.translateToLocal("info.teleporterInfUnset1.txt")); + list.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.teleporterInfUnset2.txt")); + list.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.teleporterInfUnset3.txt")); + list.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.teleporterInfUnset4.txt")); + list.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.teleporterInfUnset5.txt")); + } else { + list.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("info.teleporterInfSet1.txt")); + list.add(EnumChatFormatting.WHITE + "{x:" + (int) ItemNBTHelper.getDouble(stack, "X", 0) + " y:" + (int) ItemNBTHelper.getDouble(stack, "Y", 0) + " z:" + (int) ItemNBTHelper.getDouble(stack, "Z", 0) + " Dim:" + getLocation(stack).getDimensionName() + "}"); + list.add(EnumChatFormatting.BLUE + String.valueOf(stack.getMaxDamage() - stack.getItemDamage() + 1) + " " + StatCollector.translateToLocal("info.teleporterInfSet2.txt")); + } + } - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.uncommon; - } + @Override + public EnumRarity getRarity(ItemStack stack) { + return EnumRarity.uncommon; + } - @Override - public boolean hasCustomEntity(ItemStack stack) { - return true; - } + @Override + public boolean hasCustomEntity(ItemStack stack) { + return true; + } - @Override - public Entity createEntity(World world, Entity location, ItemStack itemstack) { - return new EntityPersistentItem(world, location, itemstack); - } + @Override + public Entity createEntity(World world, Entity location, ItemStack itemstack) { + return new EntityPersistentItem(world, location, itemstack); + } - public TeleportLocation getLocation(ItemStack stack) { - if (!ItemNBTHelper.getBoolean(stack, "IsSet", false)) return null; + public TeleportLocation getLocation(ItemStack stack) { + if (!ItemNBTHelper.getBoolean(stack, "IsSet", false)) return null; - TeleportLocation location = new TeleportLocation(); - location.readFromNBT(stack.getTagCompound()); + TeleportLocation location = new TeleportLocation(); + location.readFromNBT(stack.getTagCompound()); - return location; - } + return location; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKII.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKII.java index 4a83b230..6a6b21e4 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKII.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKII.java @@ -29,167 +29,157 @@ import net.minecraft.world.World; import java.util.ArrayList; import java.util.List; -public class TeleporterMKII extends TeleporterMKI implements IHudDisplayItem -{ +public class TeleporterMKII extends TeleporterMKI implements IHudDisplayItem { - public TeleporterMKII() { - super(true); - this.setUnlocalizedName(Strings.teleporterMKIIName); - this.setCreativeTab(DraconicEvolution.tabToolsWeapons); - this.setMaxStackSize(1); - ModItems.register(this); - } + public TeleporterMKII() { + super(true); + this.setUnlocalizedName(Strings.teleporterMKIIName); + this.setCreativeTab(DraconicEvolution.tabToolsWeapons); + this.setMaxStackSize(1); + ModItems.register(this); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(final IIconRegister iconRegister) - { - this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + Strings.teleporterMKIIName); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister iconRegister) { + this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + Strings.teleporterMKIIName); + } - @Override - public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) - { - World world = player.worldObj; - int fuel = ItemNBTHelper.getInteger(stack, "Fuel", 0); + @Override + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { + World world = player.worldObj; + int fuel = ItemNBTHelper.getInteger(stack, "Fuel", 0); - if (getLocation(stack) == null) { - if (world.isRemote) - FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_TELEPORTER, world, (int) player.posX, (int) player.posY, (int) player.posZ); - return true; - } + if (getLocation(stack) == null) { + if (world.isRemote) + FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_TELEPORTER, world, (int) player.posX, (int) player.posY, (int) player.posZ); + return true; + } - if (!player.capabilities.isCreativeMode && fuel <= 0) { - if (world.isRemote) player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfFuel.txt")); - return true; - } + if (!player.capabilities.isCreativeMode && fuel <= 0) { + if (world.isRemote) player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfFuel.txt")); + return true; + } - if (entity instanceof EntityPlayer){ - if (entity.isSneaking()){ - getLocation(stack).sendEntityToCoords(entity); - if (!player.capabilities.isCreativeMode && fuel > 0) ItemNBTHelper.setInteger(stack, "Fuel", fuel - 1); - }else{ - if (world.isRemote) player.addChatMessage(new ChatComponentTranslation("msg.teleporterPlayerConsent.txt")); - } - return true; - }else if (entity instanceof EntityLiving){ - getLocation(stack).sendEntityToCoords(entity); - if (!player.capabilities.isCreativeMode && fuel > 0) ItemNBTHelper.setInteger(stack, "Fuel", fuel - 1); - } + if (entity instanceof EntityPlayer) { + if (entity.isSneaking()) { + getLocation(stack).sendEntityToCoords(entity); + if (!player.capabilities.isCreativeMode && fuel > 0) ItemNBTHelper.setInteger(stack, "Fuel", fuel - 1); + } else { + if (world.isRemote) + player.addChatMessage(new ChatComponentTranslation("msg.teleporterPlayerConsent.txt")); + } + return true; + } else if (entity instanceof EntityLiving) { + getLocation(stack).sendEntityToCoords(entity); + if (!player.capabilities.isCreativeMode && fuel > 0) ItemNBTHelper.setInteger(stack, "Fuel", fuel - 1); + } - return true; - } + return true; + } - @Override - public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) - { - int fuel = ItemNBTHelper.getInteger(stack, "Fuel", 0); + @Override + public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) { + int fuel = ItemNBTHelper.getInteger(stack, "Fuel", 0); - if (player.isSneaking()) - { - if (world.isRemote) - { - FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_TELEPORTER, world, (int) player.posX, (int) player.posY, (int) player.posZ); - } - } else - { + if (player.isSneaking()) { + if (world.isRemote) { + FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_TELEPORTER, world, (int) player.posX, (int) player.posY, (int) player.posZ); + } + } else { - if (getLocation(stack) == null){ - if (world.isRemote) FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_TELEPORTER, world, (int) player.posX, (int) player.posY, (int) player.posZ); - return stack; - } + if (getLocation(stack) == null) { + if (world.isRemote) + FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_TELEPORTER, world, (int) player.posX, (int) player.posY, (int) player.posZ); + return stack; + } - if (!player.capabilities.isCreativeMode && fuel <= 0) - { - if (world.isRemote) player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfFuel.txt")); - return stack; - } + if (!player.capabilities.isCreativeMode && fuel <= 0) { + if (world.isRemote) player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfFuel.txt")); + return stack; + } - if (!player.capabilities.isCreativeMode && fuel > 0) ItemNBTHelper.setInteger(stack, "Fuel", fuel - 1); + if (!player.capabilities.isCreativeMode && fuel > 0) ItemNBTHelper.setInteger(stack, "Fuel", fuel - 1); - getLocation(stack).sendEntityToCoords(player); - } + getLocation(stack).sendEntityToCoords(player); + } - return stack; - } + return stack; + } - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void addInformation(final ItemStack teleporter, final EntityPlayer player, final List list2, final boolean extraInformation) - { - short selected = ItemNBTHelper.getShort(teleporter, "Selection", (short) 0); - int selrctionOffset = ItemNBTHelper.getInteger(teleporter, "SelectionOffset", 0); - NBTTagCompound compound = teleporter.getTagCompound(); - if(compound == null) compound = new NBTTagCompound(); - NBTTagList list = (NBTTagList)compound.getTag("Locations"); - if (list == null) list = new NBTTagList(); - String selectedDest = list.getCompoundTagAt(selected+selrctionOffset).getString("Name"); + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void addInformation(final ItemStack teleporter, final EntityPlayer player, final List list2, final boolean extraInformation) { + short selected = ItemNBTHelper.getShort(teleporter, "Selection", (short) 0); + int selrctionOffset = ItemNBTHelper.getInteger(teleporter, "SelectionOffset", 0); + NBTTagCompound compound = teleporter.getTagCompound(); + if (compound == null) compound = new NBTTagCompound(); + NBTTagList list = (NBTTagList) compound.getTag("Locations"); + if (list == null) list = new NBTTagList(); + String selectedDest = list.getCompoundTagAt(selected + selrctionOffset).getString("Name"); - list2.add(EnumChatFormatting.GOLD + "" + selectedDest); - if (InfoHelper.holdShiftForDetails(list2)) - { - list2.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.teleporterInfFuel.txt") + " " + ItemNBTHelper.getInteger(teleporter, "Fuel", 0)); - list2.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.teleporterInfGUI.txt")); - list2.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.teleporterInfScroll.txt")); - } - } + list2.add(EnumChatFormatting.GOLD + "" + selectedDest); + if (InfoHelper.holdShiftForDetails(list2)) { + list2.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.teleporterInfFuel.txt") + " " + ItemNBTHelper.getInteger(teleporter, "Fuel", 0)); + list2.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.teleporterInfGUI.txt")); + list2.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.teleporterInfScroll.txt")); + } + } - @Override - public EnumRarity getRarity(ItemStack stack) - { - return EnumRarity.rare; - } + @Override + public EnumRarity getRarity(ItemStack stack) { + return EnumRarity.rare; + } - @Override - public boolean hasCustomEntity(ItemStack stack) { - return true; - } + @Override + public boolean hasCustomEntity(ItemStack stack) { + return true; + } - @Override - public Entity createEntity(World world, Entity location, ItemStack itemstack) { - return new EntityPersistentItem(world, location, itemstack); - } + @Override + public Entity createEntity(World world, Entity location, ItemStack itemstack) { + return new EntityPersistentItem(world, location, itemstack); + } - @SideOnly(Side.CLIENT) - @Override - public String getItemStackDisplayName(ItemStack teleporter) { - return super.getItemStackDisplayName(teleporter); - } + @SideOnly(Side.CLIENT) + @Override + public String getItemStackDisplayName(ItemStack teleporter) { + return super.getItemStackDisplayName(teleporter); + } - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int p_77663_4_, boolean p_77663_5_) { + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int p_77663_4_, boolean p_77663_5_) { // if (world.isRemote && entity instanceof EntityPlayer && ((EntityPlayer) entity).getHeldItem() != null && ((EntityPlayer) entity).getHeldItem().getItem() instanceof TeleporterMKII){ // if (getLocation(((EntityPlayer) entity).getHeldItem()) != null) HudHandler.setTooltip(getLocation(((EntityPlayer) entity).getHeldItem()).getName()); // } - } + } - @Override - public TeleportLocation getLocation(ItemStack stack) { - short selected = ItemNBTHelper.getShort(stack, "Selection", (short) 0); - int selrctionOffset = ItemNBTHelper.getInteger(stack, "SelectionOffset", 0); - NBTTagCompound compound = stack.getTagCompound(); - if(compound == null) return null; - NBTTagList list = (NBTTagList)compound.getTag("Locations"); - if (list == null) return null; + @Override + public TeleportLocation getLocation(ItemStack stack) { + short selected = ItemNBTHelper.getShort(stack, "Selection", (short) 0); + int selrctionOffset = ItemNBTHelper.getInteger(stack, "SelectionOffset", 0); + NBTTagCompound compound = stack.getTagCompound(); + if (compound == null) return null; + NBTTagList list = (NBTTagList) compound.getTag("Locations"); + if (list == null) return null; - TeleportLocation destination = new TeleportLocation(); - destination.readFromNBT(list.getCompoundTagAt(selected+selrctionOffset)); - if (destination.getName().isEmpty()) return null; + TeleportLocation destination = new TeleportLocation(); + destination.readFromNBT(list.getCompoundTagAt(selected + selrctionOffset)); + if (destination.getName().isEmpty()) return null; - return destination; - } + return destination; + } - @Override - public List getDisplayData(ItemStack stack) { - List list = new ArrayList(); - TeleportLocation location = getLocation(stack); - if (location != null) - { - list.add(location.getName()); - } - list.add(StatCollector.translateToLocal("info.teleporterInfFuel.txt") + " " + ItemNBTHelper.getInteger(stack, "Fuel", 0)); + @Override + public List getDisplayData(ItemStack stack) { + List list = new ArrayList(); + TeleportLocation location = getLocation(stack); + if (location != null) { + list.add(location.getName()); + } + list.add(StatCollector.translateToLocal("info.teleporterInfFuel.txt") + " " + ItemNBTHelper.getInteger(stack, "Fuel", 0)); - return list; - } + return list; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/Wrench.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/Wrench.java index 24b5f689..c95cb31c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/Wrench.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/Wrench.java @@ -29,110 +29,107 @@ import java.util.List; */ public class Wrench extends ItemDE implements IHudDisplayItem { - public static final String BIND_MODE = "bind"; - public static final String UNBIND_MODE = "unBind"; - public static final String CLEAR_BINDINGS = "unBindAll"; - public static final String MODE_SWITCH = "modeSwitch"; + public static final String BIND_MODE = "bind"; + public static final String UNBIND_MODE = "unBind"; + public static final String CLEAR_BINDINGS = "unBindAll"; + public static final String MODE_SWITCH = "modeSwitch"; - public Wrench() { - this.setUnlocalizedName(Strings.wrenchName); - this.setCreativeTab(DraconicEvolution.tabToolsWeapons); - this.setMaxStackSize(1); + public Wrench() { + this.setUnlocalizedName(Strings.wrenchName); + this.setCreativeTab(DraconicEvolution.tabToolsWeapons); + this.setMaxStackSize(1); - ModItems.register(this); - } + ModItems.register(this); + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - //if (world.isRemote)FMLCommonHandler.instance().bus().register(new UpdateChecker()); - //player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.BLUE + "[Draconic Evolution]" + EnumChatFormatting.RESET + " New version available:")); + //if (world.isRemote)FMLCommonHandler.instance().bus().register(new UpdateChecker()); + //player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.BLUE + "[Draconic Evolution]" + EnumChatFormatting.RESET + " New version available:")); - if (player.isSneaking()) cycleMode(stack, world, player); - else if (ItemNBTHelper.getCompound(stack).hasKey("LinkData") && ItemNBTHelper.getCompound(stack).getCompoundTag("LinkData").getBoolean("Bound")) - ItemNBTHelper.getCompound(stack).getCompoundTag("LinkData").setBoolean("Bound", false); - return super.onItemRightClick(stack, world, player); - } + if (player.isSneaking()) cycleMode(stack, world, player); + else if (ItemNBTHelper.getCompound(stack).hasKey("LinkData") && ItemNBTHelper.getCompound(stack).getCompoundTag("LinkData").getBoolean("Bound")) + ItemNBTHelper.getCompound(stack).getCompoundTag("LinkData").setBoolean("Bound", false); + return super.onItemRightClick(stack, world, player); + } - static final String[] modes = new String[]{BIND_MODE, UNBIND_MODE, CLEAR_BINDINGS, MODE_SWITCH}; + static final String[] modes = new String[]{BIND_MODE, UNBIND_MODE, CLEAR_BINDINGS, MODE_SWITCH}; - private static void cycleMode(ItemStack stack, World world, EntityPlayer player) { - String currentMode = ItemNBTHelper.getString(stack, "Mode", "bind"); - int mode = 0; - for (String s : modes) - { - if (s.equals(currentMode)) - { - if (mode + 1 >= modes.length) currentMode = modes[0]; - else currentMode = modes[mode + 1]; - break; - } - mode++; - } - ItemNBTHelper.setString(stack, "Mode", currentMode); - if (world.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.de.wrenchMode." + currentMode + ".txt")); - } + private static void cycleMode(ItemStack stack, World world, EntityPlayer player) { + String currentMode = ItemNBTHelper.getString(stack, "Mode", "bind"); + int mode = 0; + for (String s : modes) { + if (s.equals(currentMode)) { + if (mode + 1 >= modes.length) currentMode = modes[0]; + else currentMode = modes[mode + 1]; + break; + } + mode++; + } + ItemNBTHelper.setString(stack, "Mode", currentMode); + if (world.isRemote) + player.addChatComponentMessage(new ChatComponentTranslation("msg.de.wrenchMode." + currentMode + ".txt")); + } - @SuppressWarnings("unchecked") - @SideOnly(Side.CLIENT) - @Override - public void addInformation(ItemStack stack, EntityPlayer p_77624_2_, List list, boolean bool) { - list.add(StatCollector.translateToLocal("msg.de.wrenchMode." + ItemNBTHelper.getString(stack, "Mode", "bind") + ".txt")); - NBTTagCompound linkDat = null; - if (stack.hasTagCompound() && stack.getTagCompound().hasKey("LinkData")) linkDat = stack.getTagCompound().getCompoundTag("LinkData"); - if (linkDat != null && linkDat.getBoolean("Bound")) - { - list.add(StatCollector.translateToLocal("msg.de.boundTo.txt") + ": [X:" + linkDat.getInteger("XCoord") + ", Y:" + linkDat.getInteger("YCoord") + ", Z:" + linkDat.getInteger("ZCoord") + "]"); - list.add(StatCollector.translateToLocal("msg.de.rightClickUnbind.txt")); - } - } + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + @Override + public void addInformation(ItemStack stack, EntityPlayer p_77624_2_, List list, boolean bool) { + list.add(StatCollector.translateToLocal("msg.de.wrenchMode." + ItemNBTHelper.getString(stack, "Mode", "bind") + ".txt")); + NBTTagCompound linkDat = null; + if (stack.hasTagCompound() && stack.getTagCompound().hasKey("LinkData")) + linkDat = stack.getTagCompound().getCompoundTag("LinkData"); + if (linkDat != null && linkDat.getBoolean("Bound")) { + list.add(StatCollector.translateToLocal("msg.de.boundTo.txt") + ": [X:" + linkDat.getInteger("XCoord") + ", Y:" + linkDat.getInteger("YCoord") + ", Z:" + linkDat.getInteger("ZCoord") + "]"); + list.add(StatCollector.translateToLocal("msg.de.rightClickUnbind.txt")); + } + } - @Override - public List getDisplayData(ItemStack stack) { - List list = new ArrayList(); - list.add(StatCollector.translateToLocal("msg.de.wrenchMode." + ItemNBTHelper.getString(stack, "Mode", "bind") + ".txt")); - NBTTagCompound linkDat = null; - if (stack.hasTagCompound() && stack.getTagCompound().hasKey("LinkData")) linkDat = stack.getTagCompound().getCompoundTag("LinkData"); - if (linkDat != null && linkDat.getBoolean("Bound")) - { - list.add(StatCollector.translateToLocal("msg.de.boundTo.txt") + ": [X:" + linkDat.getInteger("XCoord") + ", Y:" + linkDat.getInteger("YCoord") + ", Z:" + linkDat.getInteger("ZCoord") + "]"); - list.add(StatCollector.translateToLocal("msg.de.rightClickUnbind.txt")); - } - return list; - } + @Override + public List getDisplayData(ItemStack stack) { + List list = new ArrayList(); + list.add(StatCollector.translateToLocal("msg.de.wrenchMode." + ItemNBTHelper.getString(stack, "Mode", "bind") + ".txt")); + NBTTagCompound linkDat = null; + if (stack.hasTagCompound() && stack.getTagCompound().hasKey("LinkData")) + linkDat = stack.getTagCompound().getCompoundTag("LinkData"); + if (linkDat != null && linkDat.getBoolean("Bound")) { + list.add(StatCollector.translateToLocal("msg.de.boundTo.txt") + ": [X:" + linkDat.getInteger("XCoord") + ", Y:" + linkDat.getInteger("YCoord") + ", Z:" + linkDat.getInteger("ZCoord") + "]"); + list.add(StatCollector.translateToLocal("msg.de.rightClickUnbind.txt")); + } + return list; + } - public static String getMode(ItemStack stack) { - return ItemNBTHelper.getString(stack, "Mode", "bind"); - } + public static String getMode(ItemStack stack) { + return ItemNBTHelper.getString(stack, "Mode", "bind"); + } - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { - Block clicked = world.getBlock(x, y, z); - if (getMode(stack).equals(MODE_SWITCH) && clicked.rotateBlock(world, x, y, z, ForgeDirection.getOrientation(side)) && !world.isRemote) return true; + @Override + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { + Block clicked = world.getBlock(x, y, z); + if (getMode(stack).equals(MODE_SWITCH) && clicked.rotateBlock(world, x, y, z, ForgeDirection.getOrientation(side)) && !world.isRemote) + return true; - if (world.isRemote) return false; + if (world.isRemote) return false; - TileEntity tileClicked = world.getTileEntity(x, y, z); - if (tileClicked instanceof TileRemoteEnergyBase) return false; - else if (!(tileClicked instanceof IEnergyReceiver)) return false; - if (stack.hasTagCompound() && stack.getTagCompound().hasKey("LinkData")) - { - NBTTagCompound linkData = stack.getTagCompound().getCompoundTag("LinkData"); - if (!linkData.getBoolean("Bound")) return false; - int xCoord = linkData.getInteger("XCoord"); - int yCoord = linkData.getInteger("YCoord"); - int zCoord = linkData.getInteger("ZCoord"); + TileEntity tileClicked = world.getTileEntity(x, y, z); + if (tileClicked instanceof TileRemoteEnergyBase) return false; + else if (!(tileClicked instanceof IEnergyReceiver)) return false; + if (stack.hasTagCompound() && stack.getTagCompound().hasKey("LinkData")) { + NBTTagCompound linkData = stack.getTagCompound().getCompoundTag("LinkData"); + if (!linkData.getBoolean("Bound")) return false; + int xCoord = linkData.getInteger("XCoord"); + int yCoord = linkData.getInteger("YCoord"); + int zCoord = linkData.getInteger("ZCoord"); - if (world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileWirelessEnergyTransceiver) - { - ((TileWirelessEnergyTransceiver)world.getTileEntity(xCoord, yCoord, zCoord)).linkDevice(x, y, z, side, player, ItemNBTHelper.getString(stack, "Mode", "bind")); + if (world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileWirelessEnergyTransceiver) { + ((TileWirelessEnergyTransceiver) world.getTileEntity(xCoord, yCoord, zCoord)).linkDevice(x, y, z, side, player, ItemNBTHelper.getString(stack, "Mode", "bind")); - //linkData.setBoolean("Bound", false); - return true; - } - else return false; - } + //linkData.setBoolean("Bound", false); + return true; + } else return false; + } - return false; - } + return false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernPickaxe.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernPickaxe.java index 39dcd7a9..d7c335ca 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernPickaxe.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernPickaxe.java @@ -20,114 +20,113 @@ import org.lwjgl.opengl.GL11; public class WyvernPickaxe extends MiningTool implements IInventoryTool, IRenderTweak { - public WyvernPickaxe() { - super(ModItems.WYVERN); - this.setUnlocalizedName(Strings.wyvernPickaxeName); - this.setHarvestLevel("pickaxe", 10); - this.setCapacity(BalanceConfigHandler.wyvernToolsBaseStorage); - this.setMaxExtract(BalanceConfigHandler.wyvernToolsMaxTransfer); - this.setMaxReceive(BalanceConfigHandler.wyvernToolsMaxTransfer); - this.energyPerOperation = BalanceConfigHandler.wyvernToolsEnergyPerAction; - ModItems.register(this); - } + public WyvernPickaxe() { + super(ModItems.WYVERN); + this.setUnlocalizedName(Strings.wyvernPickaxeName); + this.setHarvestLevel("pickaxe", 10); + this.setCapacity(BalanceConfigHandler.wyvernToolsBaseStorage); + this.setMaxExtract(BalanceConfigHandler.wyvernToolsMaxTransfer); + this.setMaxReceive(BalanceConfigHandler.wyvernToolsMaxTransfer); + this.energyPerOperation = BalanceConfigHandler.wyvernToolsEnergyPerAction; + ModItems.register(this); + } - @Override - public List getFields(ItemStack stack, int slot) { - List list = super.getFields(stack, slot); - list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, EnumUpgrade.DIG_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 0).setModifier("AOE")); - return list; - } + @Override + public List getFields(ItemStack stack, int slot) { + List list = super.getFields(stack, slot); + list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, EnumUpgrade.DIG_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 0).setModifier("AOE")); + return list; + } - @Override - public String getInventoryName() { - return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); - } + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); + } - @Override - public int getInventorySlots() { - return 0; - } + @Override + public int getInventorySlots() { + return 0; + } - @Override - public boolean isEnchantValid(Enchantment enchant) { - return enchant.type == EnumEnchantmentType.digger; - } + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.digger; + } - @Override - public void tweakRender(IItemRenderer.ItemRenderType type) { + @Override + public void tweakRender(IItemRenderer.ItemRenderType type) { - GL11.glTranslated(0.4, 0.65, 0.1); + GL11.glTranslated(0.4, 0.65, 0.1); - GL11.glRotatef(90, 1, 0, 0); - GL11.glRotatef(140, 0, -1, 0); - GL11.glRotatef(180, 0, 0, 1); - GL11.glScaled(0.6, 0.6, 0.6); + GL11.glRotatef(90, 1, 0, 0); + GL11.glRotatef(140, 0, -1, 0); + GL11.glRotatef(180, 0, 0, 1); + GL11.glScaled(0.6, 0.6, 0.6); - if (type == IItemRenderer.ItemRenderType.INVENTORY){ - GL11.glScalef(13.8F, 13.8F, 13.8F); - GL11.glRotatef(180, 0, 1, 0); - GL11.glTranslated(-1.2, 0, -0.35); - } - else if (type == IItemRenderer.ItemRenderType.ENTITY){ - GL11.glRotatef(90.5F, 0, 1, 0); - GL11.glTranslated(-0.1, 0, -0.9); - } - } + if (type == IItemRenderer.ItemRenderType.INVENTORY) { + GL11.glScalef(13.8F, 13.8F, 13.8F); + GL11.glRotatef(180, 0, 1, 0); + GL11.glTranslated(-1.2, 0, -0.35); + } else if (type == IItemRenderer.ItemRenderType.ENTITY) { + GL11.glRotatef(90.5F, 0, 1, 0); + GL11.glTranslated(-0.1, 0, -0.9); + } + } - @Override - public int getUpgradeCap(ItemStack itemstack) { - return BalanceConfigHandler.wyvernToolsMaxUpgrades; - } + @Override + public int getUpgradeCap(ItemStack itemstack) { + return BalanceConfigHandler.wyvernToolsMaxUpgrades; + } - @Override - public int getMaxTier(ItemStack itemstack) { - return 1; - } + @Override + public int getMaxTier(ItemStack itemstack) { + return 1; + } - @Override - public List getUpgradeStats(ItemStack stack) { - return super.getUpgradeStats(stack); - } + @Override + public List getUpgradeStats(ItemStack stack) { + return super.getUpgradeStats(stack); + } - @Override - public int getCapacity(ItemStack stack) { - int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); - return BalanceConfigHandler.wyvernToolsBaseStorage + points * BalanceConfigHandler.wyvernToolsStoragePerUpgrade; - } + @Override + public int getCapacity(ItemStack stack) { + int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); + return BalanceConfigHandler.wyvernToolsBaseStorage + points * BalanceConfigHandler.wyvernToolsStoragePerUpgrade; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { - return BalanceConfigHandler.wyvernToolsMaxCapacityUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { - return BalanceConfigHandler.wyvernToolsMaxDigAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { - return BalanceConfigHandler.wyvernToolsMaxDigSpeedUpgradePoints; - } - return BalanceConfigHandler.wyvernToolsMaxUpgradePoints; - } + @Override + public int getMaxUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { + return BalanceConfigHandler.wyvernToolsMaxCapacityUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { + return BalanceConfigHandler.wyvernToolsMaxDigAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { + return BalanceConfigHandler.wyvernToolsMaxDigSpeedUpgradePoints; + } + return BalanceConfigHandler.wyvernToolsMaxUpgradePoints; + } - @Override - public int getBaseUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { - return BalanceConfigHandler.wyvernToolsMinDigAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { - return BalanceConfigHandler.wyvernToolsMinDigSpeedUpgradePoints; - } - return 0; - } + @Override + public int getBaseUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { + return BalanceConfigHandler.wyvernToolsMinDigAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { + return BalanceConfigHandler.wyvernToolsMinDigSpeedUpgradePoints; + } + return 0; + } - @Override - public List getUpgrades(ItemStack itemstack) { - List list = super.getUpgrades(itemstack); - list.remove(EnumUpgrade.DIG_DEPTH); - return list; - } + @Override + public List getUpgrades(ItemStack itemstack) { + List list = super.getUpgrades(itemstack); + list.remove(EnumUpgrade.DIG_DEPTH); + return list; + } - // @Override + // @Override // public boolean isItemTool(ItemStack p_77616_1_) { // return true; // } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernShovel.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernShovel.java index fcc7a216..40e92693 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernShovel.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernShovel.java @@ -21,112 +21,110 @@ import org.lwjgl.opengl.GL11; public class WyvernShovel extends MiningTool implements IInventoryTool, IRenderTweak { - public WyvernShovel() { - super(ModItems.WYVERN); - this.setHarvestLevel("shovel", 10); - this.setUnlocalizedName(Strings.wyvernShovelName); - this.setCapacity(BalanceConfigHandler.wyvernToolsBaseStorage); - this.setMaxExtract(BalanceConfigHandler.wyvernToolsMaxTransfer); - this.setMaxReceive(BalanceConfigHandler.wyvernToolsMaxTransfer); - this.energyPerOperation = BalanceConfigHandler.wyvernToolsEnergyPerAction; - ModItems.register(this); - } + public WyvernShovel() { + super(ModItems.WYVERN); + this.setHarvestLevel("shovel", 10); + this.setUnlocalizedName(Strings.wyvernShovelName); + this.setCapacity(BalanceConfigHandler.wyvernToolsBaseStorage); + this.setMaxExtract(BalanceConfigHandler.wyvernToolsMaxTransfer); + this.setMaxReceive(BalanceConfigHandler.wyvernToolsMaxTransfer); + this.energyPerOperation = BalanceConfigHandler.wyvernToolsEnergyPerAction; + ModItems.register(this); + } - @Override - public List getFields(ItemStack stack, int slot) { - List list = super.getFields(stack, slot); - list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, EnumUpgrade.DIG_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 0).setModifier("AOE")); - return list; - } + @Override + public List getFields(ItemStack stack, int slot) { + List list = super.getFields(stack, slot); + list.add(new ItemConfigField(References.INT_ID, slot, References.DIG_AOE).setMinMaxAndIncromente(0, EnumUpgrade.DIG_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 0).setModifier("AOE")); + return list; + } - @Override - public String getInventoryName() { - return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); - } + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); + } - @Override - public int getInventorySlots() { - return 0; - } + @Override + public int getInventorySlots() { + return 0; + } - @Override - public boolean isEnchantValid(Enchantment enchant) { - return enchant.type == EnumEnchantmentType.digger; - } + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.digger; + } - @Override - public void tweakRender(IItemRenderer.ItemRenderType type) { - GL11.glTranslated(0.23, 0.85, -0.1); - GL11.glRotatef(90, 1, 0, 0); - GL11.glRotatef(140, 0, -1, 0); - GL11.glScaled(0.6, 0.6, 0.6); - if (type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) { - GL11.glRotatef(180, 0, 0, 1); - GL11.glTranslated(0, -0.4, 0); - } - else if (type == IItemRenderer.ItemRenderType.INVENTORY){ - GL11.glRotatef(180, 0, 0, 1); - GL11.glScalef(12.5F, 12.5F, 12.5F); - GL11.glRotatef(180, 0, 1, 0); - GL11.glTranslated(-1.35, 0, -0.05); - } - else if (type == IItemRenderer.ItemRenderType.ENTITY){ - GL11.glRotatef(-90.5F, 0, 1, 0); - GL11.glTranslated(-0.3, 0, -0.6); - } - } + @Override + public void tweakRender(IItemRenderer.ItemRenderType type) { + GL11.glTranslated(0.23, 0.85, -0.1); + GL11.glRotatef(90, 1, 0, 0); + GL11.glRotatef(140, 0, -1, 0); + GL11.glScaled(0.6, 0.6, 0.6); + if (type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glRotatef(180, 0, 0, 1); + GL11.glTranslated(0, -0.4, 0); + } else if (type == IItemRenderer.ItemRenderType.INVENTORY) { + GL11.glRotatef(180, 0, 0, 1); + GL11.glScalef(12.5F, 12.5F, 12.5F); + GL11.glRotatef(180, 0, 1, 0); + GL11.glTranslated(-1.35, 0, -0.05); + } else if (type == IItemRenderer.ItemRenderType.ENTITY) { + GL11.glRotatef(-90.5F, 0, 1, 0); + GL11.glTranslated(-0.3, 0, -0.6); + } + } - @Override - public int getUpgradeCap(ItemStack itemstack) { - return BalanceConfigHandler.wyvernToolsMaxUpgrades; - } + @Override + public int getUpgradeCap(ItemStack itemstack) { + return BalanceConfigHandler.wyvernToolsMaxUpgrades; + } - @Override - public int getMaxTier(ItemStack itemstack) { - return 1; - } + @Override + public int getMaxTier(ItemStack itemstack) { + return 1; + } - @Override - public List getUpgradeStats(ItemStack stack) { - return super.getUpgradeStats(stack); - } + @Override + public List getUpgradeStats(ItemStack stack) { + return super.getUpgradeStats(stack); + } - public int getCapacity(ItemStack stack) { - int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); - return BalanceConfigHandler.wyvernToolsBaseStorage + points * BalanceConfigHandler.wyvernToolsStoragePerUpgrade; - } + public int getCapacity(ItemStack stack) { + int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); + return BalanceConfigHandler.wyvernToolsBaseStorage + points * BalanceConfigHandler.wyvernToolsStoragePerUpgrade; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { - return BalanceConfigHandler.wyvernToolsMaxCapacityUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { - return BalanceConfigHandler.wyvernToolsMaxDigAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { - return BalanceConfigHandler.wyvernToolsMaxDigSpeedUpgradePoints; - } - return BalanceConfigHandler.wyvernToolsMaxUpgradePoints; - } + @Override + public int getMaxUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { + return BalanceConfigHandler.wyvernToolsMaxCapacityUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { + return BalanceConfigHandler.wyvernToolsMaxDigAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { + return BalanceConfigHandler.wyvernToolsMaxDigSpeedUpgradePoints; + } + return BalanceConfigHandler.wyvernToolsMaxUpgradePoints; + } - @Override - public int getBaseUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { - return BalanceConfigHandler.wyvernToolsMinDigAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { - return BalanceConfigHandler.wyvernToolsMinDigSpeedUpgradePoints; - } - return 0; - } + @Override + public int getBaseUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.DIG_AOE.index) { + return BalanceConfigHandler.wyvernToolsMinDigAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DIG_SPEED.index) { + return BalanceConfigHandler.wyvernToolsMinDigSpeedUpgradePoints; + } + return 0; + } - @Override - public List getUpgrades(ItemStack itemstack) { - List list = super.getUpgrades(itemstack); - list.remove(EnumUpgrade.DIG_DEPTH); - return list; - } + @Override + public List getUpgrades(ItemStack itemstack) { + List list = super.getUpgrades(itemstack); + list.remove(EnumUpgrade.DIG_DEPTH); + return list; + } // @Override // public boolean isItemTool(ItemStack p_77616_1_) { diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/MiningTool.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/MiningTool.java index ca951076..b6a51c7f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/MiningTool.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/MiningTool.java @@ -41,291 +41,275 @@ import net.minecraftforge.event.world.BlockEvent; public abstract class MiningTool extends ToolBase implements IUpgradableItem { - public MiningTool(ToolMaterial material) { - super(0, material, null); - } + public MiningTool(ToolMaterial material) { + super(0, material, null); + } - public Map getObliterationList(ItemStack stack){ - Map blockMap = new HashMap(); + public Map getObliterationList(ItemStack stack) { + Map blockMap = new HashMap(); - NBTTagCompound compound = ItemNBTHelper.getCompound(stack); + NBTTagCompound compound = ItemNBTHelper.getCompound(stack); - if (compound.hasNoTags()) return blockMap; - for (int i = 0; i < 9; i++) - { - NBTTagCompound tag = new NBTTagCompound(); - if (compound.hasKey("Item" + i)) tag = compound.getCompoundTag("Item" + i); + if (compound.hasNoTags()) return blockMap; + for (int i = 0; i < 9; i++) { + NBTTagCompound tag = new NBTTagCompound(); + if (compound.hasKey("Item" + i)) tag = compound.getCompoundTag("Item" + i); - if (tag.hasNoTags()) continue; + if (tag.hasNoTags()) continue; - ItemStack stack1 = ItemStack.loadItemStackFromNBT(tag); + ItemStack stack1 = ItemStack.loadItemStackFromNBT(tag); - if (stack1 != null && stack1.getItem() instanceof ItemBlock) blockMap.put(Block.getBlockFromItem(stack1.getItem()), stack1.getItemDamage()); - } + if (stack1 != null && stack1.getItem() instanceof ItemBlock) + blockMap.put(Block.getBlockFromItem(stack1.getItem()), stack1.getItemDamage()); + } - return blockMap; - } + return blockMap; + } - @Override - public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { - int radius = IConfigurableItem.ProfileHelper.getInteger(stack, References.DIG_AOE, 0); - int depth = IConfigurableItem.ProfileHelper.getInteger(stack, References.DIG_DEPTH, 1) - 1; + @Override + public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { + int radius = IConfigurableItem.ProfileHelper.getInteger(stack, References.DIG_AOE, 0); + int depth = IConfigurableItem.ProfileHelper.getInteger(stack, References.DIG_DEPTH, 1) - 1; - return getEnergyStored(stack) >= energyPerOperation && (radius > 0) ? breakAOEBlocks(stack, x, y, z, radius, depth, player) : super.onBlockStartBreak(stack, x, y, z, player); - } + return getEnergyStored(stack) >= energyPerOperation && (radius > 0) ? breakAOEBlocks(stack, x, y, z, radius, depth, player) : super.onBlockStartBreak(stack, x, y, z, player); + } - @Override - public boolean onBlockDestroyed(ItemStack stack, World p_150894_2_, Block p_150894_3_, int p_150894_4_, int p_150894_5_, int p_150894_6_, EntityLivingBase p_150894_7_) { - if (IConfigurableItem.ProfileHelper.getInteger(stack, References.DIG_AOE, 0) == 0) extractEnergy(stack, energyPerOperation, false); - return super.onBlockDestroyed(stack, p_150894_2_, p_150894_3_, p_150894_4_, p_150894_5_, p_150894_6_, p_150894_7_); - } + @Override + public boolean onBlockDestroyed(ItemStack stack, World p_150894_2_, Block p_150894_3_, int p_150894_4_, int p_150894_5_, int p_150894_6_, EntityLivingBase p_150894_7_) { + if (IConfigurableItem.ProfileHelper.getInteger(stack, References.DIG_AOE, 0) == 0) + extractEnergy(stack, energyPerOperation, false); + return super.onBlockDestroyed(stack, p_150894_2_, p_150894_3_, p_150894_4_, p_150894_5_, p_150894_6_, p_150894_7_); + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - ToolHandler.updateGhostBlocks(player, world); - return super.onItemRightClick(stack, world, player); - } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + ToolHandler.updateGhostBlocks(player, world); + return super.onItemRightClick(stack, world, player); + } - public boolean breakAOEBlocks(ItemStack stack, int x, int y, int z, int breakRadius, int breakDepth, EntityPlayer player) - { - Map blockMap = IConfigurableItem.ProfileHelper.getBoolean(stack, References.OBLITERATE, false) ? getObliterationList(stack) : new HashMap(); - Block block = player.worldObj.getBlock(x,y,z); - int meta = player.worldObj.getBlockMetadata(x,y,z); - boolean effective = false; + public boolean breakAOEBlocks(ItemStack stack, int x, int y, int z, int breakRadius, int breakDepth, EntityPlayer player) { + Map blockMap = IConfigurableItem.ProfileHelper.getBoolean(stack, References.OBLITERATE, false) ? getObliterationList(stack) : new HashMap(); + Block block = player.worldObj.getBlock(x, y, z); + int meta = player.worldObj.getBlockMetadata(x, y, z); + boolean effective = false; - if(block != null) - { - for (String s : getToolClasses(stack)) - { - if (block.isToolEffective(s, meta) || func_150893_a(stack, block) > 1F) effective = true; - } - } + if (block != null) { + for (String s : getToolClasses(stack)) { + if (block.isToolEffective(s, meta) || func_150893_a(stack, block) > 1F) effective = true; + } + } - if (!effective) return true; + if (!effective) return true; - float refStrength = ForgeHooks.blockStrength(block, player, player.worldObj, x, y, z); + float refStrength = ForgeHooks.blockStrength(block, player, player.worldObj, x, y, z); - MovingObjectPosition mop = ToolHandler.raytraceFromEntity(player.worldObj, player, 4.5d); - if(mop == null) - { - ToolHandler.updateGhostBlocks(player, player.worldObj); - return true; - } - int sideHit = mop.sideHit; + MovingObjectPosition mop = ToolHandler.raytraceFromEntity(player.worldObj, player, 4.5d); + if (mop == null) { + ToolHandler.updateGhostBlocks(player, player.worldObj); + return true; + } + int sideHit = mop.sideHit; - int xMax = breakRadius; - int xMin = breakRadius; - int yMax = breakRadius; - int yMin = breakRadius; - int zMax = breakRadius; - int zMin = breakRadius; - int yOffset = 0; + int xMax = breakRadius; + int xMin = breakRadius; + int yMax = breakRadius; + int yMin = breakRadius; + int zMax = breakRadius; + int zMin = breakRadius; + int yOffset = 0; - switch (sideHit) { - case 0: - yMax = breakDepth; - yMin = 0; - zMax = breakRadius; - break; - case 1: - yMin = breakDepth; - yMax = 0; - zMax = breakRadius; - break; - case 2: - xMax = breakRadius; - zMin = 0; - zMax = breakDepth; - yOffset = breakRadius - 1; - break; - case 3: - xMax = breakRadius; - zMax = 0; - zMin = breakDepth; - yOffset = breakRadius - 1; - break; - case 4: - xMax = breakDepth; - xMin = 0; - zMax = breakRadius; - yOffset = breakRadius - 1; - break; - case 5: - xMin = breakDepth; - xMax = 0; - zMax = breakRadius; - yOffset = breakRadius - 1; - break; - } + switch (sideHit) { + case 0: + yMax = breakDepth; + yMin = 0; + zMax = breakRadius; + break; + case 1: + yMin = breakDepth; + yMax = 0; + zMax = breakRadius; + break; + case 2: + xMax = breakRadius; + zMin = 0; + zMax = breakDepth; + yOffset = breakRadius - 1; + break; + case 3: + xMax = breakRadius; + zMax = 0; + zMin = breakDepth; + yOffset = breakRadius - 1; + break; + case 4: + xMax = breakDepth; + xMin = 0; + zMax = breakRadius; + yOffset = breakRadius - 1; + break; + case 5: + xMin = breakDepth; + xMax = 0; + zMax = breakRadius; + yOffset = breakRadius - 1; + break; + } - if (IConfigurableItem.ProfileHelper.getBoolean(stack, References.BASE_SAFE_AOE, false)) - { - for (int xPos = x - xMin; xPos <= x + xMax; xPos++) - { - for (int yPos = y + yOffset - yMin; yPos <= y + yOffset + yMax; yPos++) - { - for (int zPos = z - zMin; zPos <= z + zMax; zPos++) - { - if (player.worldObj.getTileEntity(xPos, yPos, zPos) != null) { - if (player.worldObj.isRemote) { - player.addChatComponentMessage(new ChatComponentTranslation("msg.de.baseSafeAOW.txt")); - } - else ((EntityPlayerMP)player).playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, ((EntityPlayerMP)player).worldObj)); - return true; - } - } - } - } - } + if (IConfigurableItem.ProfileHelper.getBoolean(stack, References.BASE_SAFE_AOE, false)) { + for (int xPos = x - xMin; xPos <= x + xMax; xPos++) { + for (int yPos = y + yOffset - yMin; yPos <= y + yOffset + yMax; yPos++) { + for (int zPos = z - zMin; zPos <= z + zMax; zPos++) { + if (player.worldObj.getTileEntity(xPos, yPos, zPos) != null) { + if (player.worldObj.isRemote) { + player.addChatComponentMessage(new ChatComponentTranslation("msg.de.baseSafeAOW.txt")); + } else + ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, ((EntityPlayerMP) player).worldObj)); + return true; + } + } + } + } + } - for (int xPos = x - xMin; xPos <= x + xMax; xPos++) - { - for (int yPos = y + yOffset - yMin; yPos <= y + yOffset + yMax; yPos++) - { - for (int zPos = z - zMin; zPos <= z + zMax; zPos++) - { - breakExtraBlock(stack, player.worldObj, xPos, yPos, zPos, breakRadius * ((breakDepth / 2) + 1) , player, refStrength, Math.abs(x - xPos) <= 1 && Math.abs(y - yPos) <= 1 && Math.abs(z - zPos) <= 1, blockMap); - } - } - } + for (int xPos = x - xMin; xPos <= x + xMax; xPos++) { + for (int yPos = y + yOffset - yMin; yPos <= y + yOffset + yMax; yPos++) { + for (int zPos = z - zMin; zPos <= z + zMax; zPos++) { + breakExtraBlock(stack, player.worldObj, xPos, yPos, zPos, breakRadius * ((breakDepth / 2) + 1), player, refStrength, Math.abs(x - xPos) <= 1 && Math.abs(y - yPos) <= 1 && Math.abs(z - zPos) <= 1, blockMap); + } + } + } - @SuppressWarnings("unchecked") - List items = player.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - xMin, y + yOffset - yMin, z - zMin, x + xMax + 1, y + yOffset + yMax + 1, z + zMax + 1)); - for (EntityItem item : items){ - if (!player.worldObj.isRemote) - { - item.setLocationAndAngles(player.posX, player.posY, player.posZ, 0, 0); - ((EntityPlayerMP)player).playerNetServerHandler.sendPacket(new S18PacketEntityTeleport(item)); - item.delayBeforeCanPickup = 0; - if (ConfigHandler.rapidlyDespawnMinedItems) item.lifespan = 100; - } - } + @SuppressWarnings("unchecked") List items = player.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - xMin, y + yOffset - yMin, z - zMin, x + xMax + 1, y + yOffset + yMax + 1, z + zMax + 1)); + for (EntityItem item : items) { + if (!player.worldObj.isRemote) { + item.setLocationAndAngles(player.posX, player.posY, player.posZ, 0, 0); + ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S18PacketEntityTeleport(item)); + item.delayBeforeCanPickup = 0; + if (ConfigHandler.rapidlyDespawnMinedItems) item.lifespan = 100; + } + } - return true; - } + return true; + } - protected void breakExtraBlock(ItemStack stack, World world, int x, int y, int z, int totalSize, EntityPlayer player, float refStrength, boolean breakSound, Map blockMap) - { - if (world.isAirBlock(x, y, z)) return; + protected void breakExtraBlock(ItemStack stack, World world, int x, int y, int z, int totalSize, EntityPlayer player, float refStrength, boolean breakSound, Map blockMap) { + if (world.isAirBlock(x, y, z)) return; - Block block = world.getBlock(x, y, z); - if (block.getMaterial() instanceof MaterialLiquid || (block.getBlockHardness(world, x, y, x) == -1 && !player.capabilities.isCreativeMode)) return; + Block block = world.getBlock(x, y, z); + if (block.getMaterial() instanceof MaterialLiquid || (block.getBlockHardness(world, x, y, x) == -1 && !player.capabilities.isCreativeMode)) + return; - int meta = world.getBlockMetadata(x, y, z); + int meta = world.getBlockMetadata(x, y, z); - boolean effective = false; + boolean effective = false; - for (String s : getToolClasses(stack)) - { - if (block.isToolEffective(s, meta) || func_150893_a(stack, block) > 1F) effective = true; - } + for (String s : getToolClasses(stack)) { + if (block.isToolEffective(s, meta) || func_150893_a(stack, block) > 1F) effective = true; + } - if (!effective) return; + if (!effective) return; - float strength = ForgeHooks.blockStrength(block, player, world, x,y,z); + float strength = ForgeHooks.blockStrength(block, player, world, x, y, z); - if (!player.canHarvestBlock(block) || !ForgeHooks.canHarvestBlock(block, player, meta) || refStrength/strength > 10f && !player.capabilities.isCreativeMode) - return; + if (!player.canHarvestBlock(block) || !ForgeHooks.canHarvestBlock(block, player, meta) || refStrength / strength > 10f && !player.capabilities.isCreativeMode) + return; - if (!world.isRemote) - { - BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, world.getWorldInfo().getGameType(), (EntityPlayerMP) player, x, y, z); - if (event.isCanceled()) { - ((EntityPlayerMP)player).playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); - return; - } - } + if (!world.isRemote) { + BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, world.getWorldInfo().getGameType(), (EntityPlayerMP) player, x, y, z); + if (event.isCanceled()) { + ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); + return; + } + } - int scaledPower = energyPerOperation + (totalSize * (energyPerOperation / 10)); + int scaledPower = energyPerOperation + (totalSize * (energyPerOperation / 10)); - if (player.capabilities.isCreativeMode || (blockMap.containsKey(block) && blockMap.get(block) == meta)) { + if (player.capabilities.isCreativeMode || (blockMap.containsKey(block) && blockMap.get(block) == meta)) { - block.onBlockHarvested(world, x, y, z, meta, player); - if (block.removedByPlayer(world, player, x, y, z, false)) - block.onBlockDestroyedByPlayer(world, x, y, z, meta); + block.onBlockHarvested(world, x, y, z, meta, player); + if (block.removedByPlayer(world, player, x, y, z, false)) + block.onBlockDestroyedByPlayer(world, x, y, z, meta); - if (!world.isRemote) { - ((EntityPlayerMP)player).playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); - } + if (!world.isRemote) { + ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); + } - if ((blockMap.containsKey(block) && blockMap.get(block) == meta)) extractEnergy(stack, scaledPower, false); - if (breakSound) world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); - return; - } + if ((blockMap.containsKey(block) && blockMap.get(block) == meta)) extractEnergy(stack, scaledPower, false); + if (breakSound) world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); + return; + } - extractEnergy(stack, scaledPower, false); + extractEnergy(stack, scaledPower, false); - if (!world.isRemote) { + if (!world.isRemote) { - block.onBlockHarvested(world, x, y, z, meta, player); + block.onBlockHarvested(world, x, y, z, meta, player); - if(block.removedByPlayer(world, player, x,y,z, true)) - { - block.onBlockDestroyedByPlayer(world, x,y,z, meta); - block.harvestBlock(world, player, x,y,z, meta); - player.addExhaustion(-0.025F); - if (block.getExpDrop(world, meta, EnchantmentHelper.getFortuneModifier(player)) > 0) player.addExperience(block.getExpDrop(world, meta, EnchantmentHelper.getFortuneModifier(player))); - } + if (block.removedByPlayer(world, player, x, y, z, true)) { + block.onBlockDestroyedByPlayer(world, x, y, z, meta); + block.harvestBlock(world, player, x, y, z, meta); + player.addExhaustion(-0.025F); + if (block.getExpDrop(world, meta, EnchantmentHelper.getFortuneModifier(player)) > 0) + player.addExperience(block.getExpDrop(world, meta, EnchantmentHelper.getFortuneModifier(player))); + } - EntityPlayerMP mpPlayer = (EntityPlayerMP) player; - mpPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); - } - else - { - if (breakSound) world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); - if(block.removedByPlayer(world, player, x,y,z, true)) - { - block.onBlockDestroyedByPlayer(world, x,y,z, meta); - } + EntityPlayerMP mpPlayer = (EntityPlayerMP) player; + mpPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); + } else { + if (breakSound) world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); + if (block.removedByPlayer(world, player, x, y, z, true)) { + block.onBlockDestroyedByPlayer(world, x, y, z, meta); + } - Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x,y,z, Minecraft.getMinecraft().objectMouseOver.sideHit)); - } - } + Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x, y, z, Minecraft.getMinecraft().objectMouseOver.sideHit)); + } + } - @Override - public List getUpgrades(ItemStack itemstack) { - return new ArrayList(){{ - add(EnumUpgrade.RF_CAPACITY); - add(EnumUpgrade.DIG_SPEED); - add(EnumUpgrade.DIG_AOE); - add(EnumUpgrade.DIG_DEPTH); - }}; - } + @Override + public List getUpgrades(ItemStack itemstack) { + return new ArrayList() {{ + add(EnumUpgrade.RF_CAPACITY); + add(EnumUpgrade.DIG_SPEED); + add(EnumUpgrade.DIG_AOE); + add(EnumUpgrade.DIG_DEPTH); + }}; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) - { - return getMaxUpgradePoints(upgradeIndex); - } + @Override + public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) { + return getMaxUpgradePoints(upgradeIndex); + } - @Override - public float getEfficiency(ItemStack stack) { - int i = EnumUpgrade.DIG_SPEED.getUpgradePoints(stack); - if (i == 0) return super.getEfficiency(stack); - else return (float) i * 3F; - } + @Override + public float getEfficiency(ItemStack stack) { + int i = EnumUpgrade.DIG_SPEED.getUpgradePoints(stack); + if (i == 0) return super.getEfficiency(stack); + else return (float) i * 3F; + } - @Override - public List getUpgradeStats(ItemStack stack) { - List strings = new ArrayList(); - int digaoe = 0; - int depth = 0; - int attackaoe = 0; - for (ItemConfigField field : getFields(stack, 0)){ - if (field.name.equals(References.DIG_AOE)) digaoe = 1 + ((Integer) field.max * 2); - else if (field.name.equals(References.DIG_DEPTH)) depth = (Integer) field.max; - else if (field.name.equals(References.ATTACK_AOE)) attackaoe = 1 + ((Integer) field.max * 2); - } + @Override + public List getUpgradeStats(ItemStack stack) { + List strings = new ArrayList(); + int digaoe = 0; + int depth = 0; + int attackaoe = 0; + for (ItemConfigField field : getFields(stack, 0)) { + if (field.name.equals(References.DIG_AOE)) digaoe = 1 + ((Integer) field.max * 2); + else if (field.name.equals(References.DIG_DEPTH)) depth = (Integer) field.max; + else if (field.name.equals(References.ATTACK_AOE)) attackaoe = 1 + ((Integer) field.max * 2); + } - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.RFCapacity.txt")+": "+InfoHelper.HITC()+Utills.formatNumber(getMaxEnergyStored(stack))); - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.max.txt")+" "+StatCollector.translateToLocal("gui.de.DigAOE.txt")+": "+InfoHelper.HITC()+digaoe+"x"+digaoe); - if (depth > 0) strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.max.txt")+" "+StatCollector.translateToLocal("gui.de.DigDepth.txt")+": "+InfoHelper.HITC()+depth); - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.max.txt")+" "+StatCollector.translateToLocal("gui.de.DigSpeed.txt")+": "+InfoHelper.HITC()+getEfficiency(stack)); - if (attackaoe > 0) strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.max.txt")+" "+StatCollector.translateToLocal("gui.de.AttackAOE.txt")+": "+InfoHelper.HITC()+attackaoe+"x"+attackaoe); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.RFCapacity.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getMaxEnergyStored(stack))); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.max.txt") + " " + StatCollector.translateToLocal("gui.de.DigAOE.txt") + ": " + InfoHelper.HITC() + digaoe + "x" + digaoe); + if (depth > 0) + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.max.txt") + " " + StatCollector.translateToLocal("gui.de.DigDepth.txt") + ": " + InfoHelper.HITC() + depth); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.max.txt") + " " + StatCollector.translateToLocal("gui.de.DigSpeed.txt") + ": " + InfoHelper.HITC() + getEfficiency(stack)); + if (attackaoe > 0) + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.max.txt") + " " + StatCollector.translateToLocal("gui.de.AttackAOE.txt") + ": " + InfoHelper.HITC() + attackaoe + "x" + attackaoe); - return strings; - } + return strings; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/RFItemBase.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/RFItemBase.java index 85c35da3..f64acc70 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/RFItemBase.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/RFItemBase.java @@ -27,120 +27,138 @@ import net.minecraft.world.World; * Created by Brandon on 8/01/2015. */ public class RFItemBase extends ItemDE implements IEnergyContainerItem, IConfigurableItem, IHudDisplayItem { - protected int capacity = 0; - /**Max Receive*/ - protected int maxReceive = 0; - /**Max Extract*/ - protected int maxExtract = 0; + protected int capacity = 0; + /** + * Max Receive + */ + protected int maxReceive = 0; + /** + * Max Extract + */ + protected int maxExtract = 0; - public RFItemBase(){ - this.setMaxStackSize(1); - this.setCreativeTab(DraconicEvolution.tabToolsWeapons); - } + public RFItemBase() { + this.setMaxStackSize(1); + this.setCreativeTab(DraconicEvolution.tabToolsWeapons); + } - @Override - public boolean hasCustomEntity(ItemStack stack) { - return true; - } + @Override + public boolean hasCustomEntity(ItemStack stack) { + return true; + } - @Override - public Entity createEntity(World world, Entity location, ItemStack itemstack) { - return new EntityPersistentItem(world, location, itemstack); - } + @Override + public Entity createEntity(World world, Entity location, ItemStack itemstack) { + return new EntityPersistentItem(world, location, itemstack); + } /* Energy */ - public void setCapacity(int capacity){ this.capacity = capacity;} + public void setCapacity(int capacity) { + this.capacity = capacity; + } - public void setMaxReceive(int maxReceive){ this.maxReceive = maxReceive;} + public void setMaxReceive(int maxReceive) { + this.maxReceive = maxReceive; + } - public void setMaxExtract(int maxExtract){ this.maxExtract = maxExtract;} + public void setMaxExtract(int maxExtract) { + this.maxExtract = maxExtract; + } - public int getCapacity(ItemStack stack){ return capacity; } + public int getCapacity(ItemStack stack) { + return capacity; + } - public int getMaxExtract(ItemStack stack){ return maxExtract; } + public int getMaxExtract(ItemStack stack) { + return maxExtract; + } - public int getMaxReceive(ItemStack stack){ return maxReceive; } + public int getMaxReceive(ItemStack stack) { + return maxReceive; + } - @Override - public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { - int energy = ItemNBTHelper.getInteger(container, "Energy", 0); - int energyReceived = Math.min(getCapacity(container) - energy, Math.min(getMaxReceive(container), maxReceive)); + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + int energy = ItemNBTHelper.getInteger(container, "Energy", 0); + int energyReceived = Math.min(getCapacity(container) - energy, Math.min(getMaxReceive(container), maxReceive)); - if (!simulate) { - energy += energyReceived; - ItemNBTHelper.setInteger(container, "Energy", energy); - } - return energyReceived; - } + if (!simulate) { + energy += energyReceived; + ItemNBTHelper.setInteger(container, "Energy", energy); + } + return energyReceived; + } - @Override - public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { - int energy = ItemNBTHelper.getInteger(container, "Energy", 0); - int energyExtracted = Math.min(energy, Math.min(getMaxExtract(container), maxExtract)); + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + int energy = ItemNBTHelper.getInteger(container, "Energy", 0); + int energyExtracted = Math.min(energy, Math.min(getMaxExtract(container), maxExtract)); - if (!simulate) { - energy -= energyExtracted; - ItemNBTHelper.setInteger(container, "Energy", energy); - } - return energyExtracted; - } + if (!simulate) { + energy -= energyExtracted; + ItemNBTHelper.setInteger(container, "Energy", energy); + } + return energyExtracted; + } - @Override - public int getEnergyStored(ItemStack container) { - return ItemNBTHelper.getInteger(container, "Energy", 0); - } + @Override + public int getEnergyStored(ItemStack container) { + return ItemNBTHelper.getInteger(container, "Energy", 0); + } - @Override - public int getMaxEnergyStored(ItemStack container) { - return getCapacity(container); - } + @Override + public int getMaxEnergyStored(ItemStack container) { + return getCapacity(container); + } - @Override - public boolean showDurabilityBar(ItemStack stack) { - return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); - } + @Override + public boolean showDurabilityBar(ItemStack stack) { + return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); + } - @Override - public double getDurabilityForDisplay(ItemStack stack) { - return 1D - ((double)getEnergyStored(stack) / (double)getMaxEnergyStored(stack)); - } + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - ((double) getEnergyStored(stack) / (double) getMaxEnergyStored(stack)); + } - @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", 0)); - if (capacity > 0)list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", capacity)); - } + @SideOnly(Side.CLIENT) + @SuppressWarnings("unchecked") + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", 0)); + if (capacity > 0) list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", capacity)); + } - @Override - public boolean getHasSubtypes() { - return capacity > 0; - } + @Override + public boolean getHasSubtypes() { + return capacity > 0; + } /* IConfigurableItem */ - @Override - public List getFields(ItemStack stack, int slot) { - return new ArrayList(); - } + @Override + public List getFields(ItemStack stack, int slot) { + return new ArrayList(); + } - @Override - public List getDisplayData(ItemStack stack) { - List list = new ArrayList(); - if (hasProfiles()) { - int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); - list.add(EnumChatFormatting.DARK_PURPLE+StatCollector.translateToLocal("info.de.capacitorMode.txt")+": "+ItemNBTHelper.getString(stack, "ProfileName"+preset, "Profile "+preset)); - } - for (ItemConfigField field : getFields(stack, 0)) list.add(field.getTooltipInfo());//list.add(field.getLocalizedName() + ": " + field.getFormattedValue()); - if (capacity > 0) list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getEnergyStored(stack)) + " / " + Utills.formatNumber(capacity)); + @Override + public List getDisplayData(ItemStack stack) { + List list = new ArrayList(); + if (hasProfiles()) { + int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); + list.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("info.de.capacitorMode.txt") + ": " + ItemNBTHelper.getString(stack, "ProfileName" + preset, "Profile " + preset)); + } + for (ItemConfigField field : getFields(stack, 0)) + list.add(field.getTooltipInfo());//list.add(field.getLocalizedName() + ": " + field.getFormattedValue()); + if (capacity > 0) + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getEnergyStored(stack)) + " / " + Utills.formatNumber(capacity)); - return list; - } + return list; + } - @Override - public boolean hasProfiles() { - return true; - } + @Override + public boolean hasProfiles() { + return true; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/ToolBase.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/ToolBase.java index 34f8d380..6d05b5f8 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/ToolBase.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/ToolBase.java @@ -38,224 +38,210 @@ import java.util.Set; */ public class ToolBase extends RFItemBase { - private static final Set SHOVEL_OVERRIDES = Sets.newHashSet(Blocks.grass, Blocks.dirt, Blocks.sand, Blocks.gravel, Blocks.snow_layer, Blocks.snow, Blocks.clay, Blocks.farmland, Blocks.soul_sand, Blocks.mycelium, Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay); - private static final Set PICKAXE_OVERRIDES = Sets.newHashSet(Blocks.cobblestone, Blocks.double_stone_slab, Blocks.stone_slab, Blocks.stone, Blocks.sandstone, Blocks.mossy_cobblestone, Blocks.iron_ore, Blocks.iron_block, Blocks.coal_ore, Blocks.gold_block, Blocks.gold_ore, Blocks.diamond_ore, Blocks.diamond_block, Blocks.ice, Blocks.netherrack, Blocks.lapis_ore, Blocks.lapis_block, Blocks.redstone_ore, Blocks.lit_redstone_ore, Blocks.rail, Blocks.detector_rail, Blocks.golden_rail, Blocks.activator_rail, Material.iron, Material.anvil, Material.rock, Material.glass, Material.ice, Material.packedIce); - private static final Set AXE_OVERRIDES = Sets.newHashSet(Blocks.planks, Blocks.bookshelf, Blocks.log, Blocks.log2, Blocks.chest, Blocks.pumpkin, Blocks.lit_pumpkin, Material.wood, Material.leaves, Material.coral, Material.cactus, Material.plants, Material.vine); + private static final Set SHOVEL_OVERRIDES = Sets.newHashSet(Blocks.grass, Blocks.dirt, Blocks.sand, Blocks.gravel, Blocks.snow_layer, Blocks.snow, Blocks.clay, Blocks.farmland, Blocks.soul_sand, Blocks.mycelium, Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay); + private static final Set PICKAXE_OVERRIDES = Sets.newHashSet(Blocks.cobblestone, Blocks.double_stone_slab, Blocks.stone_slab, Blocks.stone, Blocks.sandstone, Blocks.mossy_cobblestone, Blocks.iron_ore, Blocks.iron_block, Blocks.coal_ore, Blocks.gold_block, Blocks.gold_ore, Blocks.diamond_ore, Blocks.diamond_block, Blocks.ice, Blocks.netherrack, Blocks.lapis_ore, Blocks.lapis_block, Blocks.redstone_ore, Blocks.lit_redstone_ore, Blocks.rail, Blocks.detector_rail, Blocks.golden_rail, Blocks.activator_rail, Material.iron, Material.anvil, Material.rock, Material.glass, Material.ice, Material.packedIce); + private static final Set AXE_OVERRIDES = Sets.newHashSet(Blocks.planks, Blocks.bookshelf, Blocks.log, Blocks.log2, Blocks.chest, Blocks.pumpkin, Blocks.lit_pumpkin, Material.wood, Material.leaves, Material.coral, Material.cactus, Material.plants, Material.vine); - /** A list of blocks this tool can mine that are not covered by the tool class. */ - private Set blockOverrides; - private float efficiencyOnProperMaterial = 4.0F; - /** Damage versus entities. */ - public float damageVsEntity; - /** The material this tool is made from. */ - protected Item.ToolMaterial toolMaterial; - /** The amount of energy required to dig one block, damage a mob. */ - public int energyPerOperation = 0; + /** + * A list of blocks this tool can mine that are not covered by the tool class. + */ + private Set blockOverrides; + private float efficiencyOnProperMaterial = 4.0F; + /** + * Damage versus entities. + */ + public float damageVsEntity; + /** + * The material this tool is made from. + */ + protected Item.ToolMaterial toolMaterial; + /** + * The amount of energy required to dig one block, damage a mob. + */ + public int energyPerOperation = 0; - protected ToolBase(float baseDamage, Item.ToolMaterial material, Set blockOverrides) - { - this.toolMaterial = material; - this.blockOverrides = blockOverrides == null ? new HashSet() : blockOverrides; - this.maxStackSize = 1; - this.setMaxDamage(material.getMaxUses()); - this.efficiencyOnProperMaterial = material.getEfficiencyOnProperMaterial(); - this.damageVsEntity = baseDamage + material.getDamageVsEntity(); - this.setCreativeTab(DraconicEvolution.tabToolsWeapons); - } + protected ToolBase(float baseDamage, Item.ToolMaterial material, Set blockOverrides) { + this.toolMaterial = material; + this.blockOverrides = blockOverrides == null ? new HashSet() : blockOverrides; + this.maxStackSize = 1; + this.setMaxDamage(material.getMaxUses()); + this.efficiencyOnProperMaterial = material.getEfficiencyOnProperMaterial(); + this.damageVsEntity = baseDamage + material.getDamageVsEntity(); + this.setCreativeTab(DraconicEvolution.tabToolsWeapons); + } - public float getEfficiency(ItemStack stack) { - return efficiencyOnProperMaterial; - } + public float getEfficiency(ItemStack stack) { + return efficiencyOnProperMaterial; + } - @SuppressWarnings("unchecked") - @Override - public void setHarvestLevel(String toolClass, int level) { - if (toolClass.equals("pickaxe")) blockOverrides.addAll(PICKAXE_OVERRIDES); - if (toolClass.equals("shovel")) blockOverrides.addAll(SHOVEL_OVERRIDES); - if (toolClass.equals("axe")) blockOverrides.addAll(AXE_OVERRIDES); - super.setHarvestLevel(toolClass, level); - } + @SuppressWarnings("unchecked") + @Override + public void setHarvestLevel(String toolClass, int level) { + if (toolClass.equals("pickaxe")) blockOverrides.addAll(PICKAXE_OVERRIDES); + if (toolClass.equals("shovel")) blockOverrides.addAll(SHOVEL_OVERRIDES); + if (toolClass.equals("axe")) blockOverrides.addAll(AXE_OVERRIDES); + super.setHarvestLevel(toolClass, level); + } - /** - * Get strength vs block - */ - @Override - public float func_150893_a(ItemStack stack, Block block) - { - return blockOverrides.contains(block) || blockOverrides.contains(block.getMaterial()) ? getEfficiency(stack) : 1.0F; - } + /** + * Get strength vs block + */ + @Override + public float func_150893_a(ItemStack stack, Block block) { + return blockOverrides.contains(block) || blockOverrides.contains(block.getMaterial()) ? getEfficiency(stack) : 1.0F; + } - /** - * Can Harvest Block - */ - @Override - public boolean func_150897_b(Block block) - { - if (getToolClasses(null).contains("pickaxe")) return true; - return blockOverrides.contains(block) || blockOverrides.contains(block.getMaterial()); - } + /** + * Can Harvest Block + */ + @Override + public boolean func_150897_b(Block block) { + if (getToolClasses(null).contains("pickaxe")) return true; + return blockOverrides.contains(block) || blockOverrides.contains(block.getMaterial()); + } - @SideOnly(Side.CLIENT) - @Override - public boolean isFull3D() - { - return true; - } + @SideOnly(Side.CLIENT) + @Override + public boolean isFull3D() { + return true; + } - @Override - public int getItemEnchantability() - { - return this.toolMaterial.getEnchantability(); - } + @Override + public int getItemEnchantability() { + return this.toolMaterial.getEnchantability(); + } - @Override - public float getDigSpeed(ItemStack stack, Block block, int meta) - { - float speed; - if (ForgeHooks.isToolEffective(stack, block, meta)) - { - speed = getEfficiency(stack); - } - else - { - speed = super.getDigSpeed(stack, block, meta); - } + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta) { + float speed; + if (ForgeHooks.isToolEffective(stack, block, meta)) { + speed = getEfficiency(stack); + } else { + speed = super.getDigSpeed(stack, block, meta); + } - if (getEnergyStored(stack) >= energyPerOperation) - { - float f = IConfigurableItem.ProfileHelper.getFloat(stack, References.DIG_SPEED_MULTIPLIER, 1f); - if (speed > 50f) f *= f; - return f * speed; - } - else - { - return 0.5f; - } - } + if (getEnergyStored(stack) >= energyPerOperation) { + float f = IConfigurableItem.ProfileHelper.getFloat(stack, References.DIG_SPEED_MULTIPLIER, 1f); + if (speed > 50f) f *= f; + return f * speed; + } else { + return 0.5f; + } + } - @Override - public List getFields(ItemStack stack, int slot) { - List list = super.getFields(stack, slot); - if (!getToolClasses(stack).isEmpty()) list.add(new ItemConfigField(References.FLOAT_ID, slot, References.DIG_SPEED_MULTIPLIER).setMinMaxAndIncromente(0f, 1f, 0.01f).readFromItem(stack, 1f).setModifier("PERCENT")); - if (!getToolClasses(stack).isEmpty()) list.add(new ItemConfigField(References.BOOLEAN_ID, slot, References.BASE_SAFE_AOE).readFromItem(stack, false)); - return list; - } + @Override + public List getFields(ItemStack stack, int slot) { + List list = super.getFields(stack, slot); + if (!getToolClasses(stack).isEmpty()) + list.add(new ItemConfigField(References.FLOAT_ID, slot, References.DIG_SPEED_MULTIPLIER).setMinMaxAndIncromente(0f, 1f, 0.01f).readFromItem(stack, 1f).setModifier("PERCENT")); + if (!getToolClasses(stack).isEmpty()) + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, References.BASE_SAFE_AOE).readFromItem(stack, false)); + return list; + } - @SideOnly(Side.CLIENT) - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean extended) { - boolean show = InfoHelper.holdShiftForDetails(list); - if (show){ - if (hasProfiles()) { - int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); - list.add(EnumChatFormatting.DARK_PURPLE+StatCollector.translateToLocal("info.de.capacitorMode.txt")+": "+ItemNBTHelper.getString(stack, "ProfileName"+preset, "Profile "+preset)); - } - List l = getFields(stack, 0); - for (ItemConfigField f : l) list.add(f.getTooltipInfo()); - // if (getCapacity(stack) > 0) list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getEnergyStored(stack)) + " / " + Utills.formatNumber(getCapacity(stack))); - } - holdCTRLForUpgrades(list, stack); + @SideOnly(Side.CLIENT) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean extended) { + boolean show = InfoHelper.holdShiftForDetails(list); + if (show) { + if (hasProfiles()) { + int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); + list.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("info.de.capacitorMode.txt") + ": " + ItemNBTHelper.getString(stack, "ProfileName" + preset, "Profile " + preset)); + } + List l = getFields(stack, 0); + for (ItemConfigField f : l) list.add(f.getTooltipInfo()); + // if (getCapacity(stack) > 0) list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getEnergyStored(stack)) + " / " + Utills.formatNumber(getCapacity(stack))); + } + holdCTRLForUpgrades(list, stack); - addAditionalInformation(stack, player, list, extended); - InfoHelper.addEnergyInfo(stack, list); - if (show && !ConfigHandler.disableLore) InfoHelper.addLore(stack, list, true); - } + addAditionalInformation(stack, player, list, extended); + InfoHelper.addEnergyInfo(stack, list); + if (show && !ConfigHandler.disableLore) InfoHelper.addLore(stack, list, true); + } - @SideOnly(Side.CLIENT) - public void addAditionalInformation(ItemStack stack, EntityPlayer player, List list, boolean extended) { - String key; - if (KeyBindings.toolConfig.getKeyCode() >= 0 && KeyBindings.toolConfig.getKeyCode() < Keyboard.KEYBOARD_SIZE) key = Keyboard.getKeyName(KeyBindings.toolConfig.getKeyCode()); - else key = Mouse.getButtonName(KeyBindings.toolConfig.getKeyCode()+101); + @SideOnly(Side.CLIENT) + public void addAditionalInformation(ItemStack stack, EntityPlayer player, List list, boolean extended) { + String key; + if (KeyBindings.toolConfig.getKeyCode() >= 0 && KeyBindings.toolConfig.getKeyCode() < Keyboard.KEYBOARD_SIZE) + key = Keyboard.getKeyName(KeyBindings.toolConfig.getKeyCode()); + else key = Mouse.getButtonName(KeyBindings.toolConfig.getKeyCode() + 101); - list.add(StatCollector.translateToLocal("info.de.press.txt") + " " + key + " " + StatCollector.translateToLocal("info.de.toOpenConfigGUI.txt")); - } + list.add(StatCollector.translateToLocal("info.de.press.txt") + " " + key + " " + StatCollector.translateToLocal("info.de.toOpenConfigGUI.txt")); + } - @Override - public EnumRarity getRarity(ItemStack stack) { - if (stack.getUnlocalizedName().contains(":wyvern")) return EnumRarity.rare; - if (stack.getUnlocalizedName().contains(":draconic")) return EnumRarity.epic; - return EnumRarity.uncommon; - } + @Override + public EnumRarity getRarity(ItemStack stack) { + if (stack.getUnlocalizedName().contains(":wyvern")) return EnumRarity.rare; + if (stack.getUnlocalizedName().contains(":draconic")) return EnumRarity.epic; + return EnumRarity.uncommon; + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (!world.isRemote && !BrandonsCore.proxy.isDedicatedServer()) - { - handleModeChange(stack, player, InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown()); - } - else if (world.isRemote && BrandonsCore.proxy.getMCServer() == null) - { - handleModeChange(stack, player, InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown()); - DraconicEvolution.network.sendToServer(new ToolModePacket(InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown())); - } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (!world.isRemote && !BrandonsCore.proxy.isDedicatedServer()) { + handleModeChange(stack, player, InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown()); + } else if (world.isRemote && BrandonsCore.proxy.getMCServer() == null) { + handleModeChange(stack, player, InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown()); + DraconicEvolution.network.sendToServer(new ToolModePacket(InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown())); + } - return super.onItemRightClick(stack, world, player); - } + return super.onItemRightClick(stack, world, player); + } - public static void handleModeChange(ItemStack stack, EntityPlayer player, boolean shift, boolean ctrl) - { - if (stack == null || !(stack.getItem() instanceof IConfigurableItem)) return; - IConfigurableItem item = (IConfigurableItem)stack.getItem(); + public static void handleModeChange(ItemStack stack, EntityPlayer player, boolean shift, boolean ctrl) { + if (stack == null || !(stack.getItem() instanceof IConfigurableItem)) return; + IConfigurableItem item = (IConfigurableItem) stack.getItem(); - if (shift && !ctrl) - { - List fields = item.getFields(stack, player.inventory.currentItem); - for (ItemConfigField field : fields) - { - if (field.name.equals(References.DIG_AOE)) - { - int aoe = (Integer) field.value; - aoe++; - if (aoe > (Integer) field.max) aoe = (Integer) field.min; - field.value = aoe; - DataUtills.writeObjectToCompound(IConfigurableItem.ProfileHelper.getProfileCompound(stack), field.value, field.datatype, field.name); - } - } - } - else if (ctrl && !shift) - { - List fields = item.getFields(stack, player.inventory.currentItem); - for (ItemConfigField field : fields) - { - if (field.name.equals(References.DIG_DEPTH)) { - int aoe = (Integer) field.value; - aoe++; - if (aoe > (Integer) field.max) aoe = (Integer) field.min; - field.value = aoe; - DataUtills.writeObjectToCompound(IConfigurableItem.ProfileHelper.getProfileCompound(stack), field.value, field.datatype, field.name); - } - } - } - else if (ctrl && shift) - { - List fields = item.getFields(stack, player.inventory.currentItem); - for (ItemConfigField field : fields) - { - if (field.name.equals(References.ATTACK_AOE)) { - int aoe = (Integer) field.value; - aoe++; - if (aoe > (Integer) field.max) aoe = (Integer) field.min; - field.value = aoe; - DataUtills.writeObjectToCompound(IConfigurableItem.ProfileHelper.getProfileCompound(stack), field.value, field.datatype, field.name); - } - } - } - } + if (shift && !ctrl) { + List fields = item.getFields(stack, player.inventory.currentItem); + for (ItemConfigField field : fields) { + if (field.name.equals(References.DIG_AOE)) { + int aoe = (Integer) field.value; + aoe++; + if (aoe > (Integer) field.max) aoe = (Integer) field.min; + field.value = aoe; + DataUtills.writeObjectToCompound(IConfigurableItem.ProfileHelper.getProfileCompound(stack), field.value, field.datatype, field.name); + } + } + } else if (ctrl && !shift) { + List fields = item.getFields(stack, player.inventory.currentItem); + for (ItemConfigField field : fields) { + if (field.name.equals(References.DIG_DEPTH)) { + int aoe = (Integer) field.value; + aoe++; + if (aoe > (Integer) field.max) aoe = (Integer) field.min; + field.value = aoe; + DataUtills.writeObjectToCompound(IConfigurableItem.ProfileHelper.getProfileCompound(stack), field.value, field.datatype, field.name); + } + } + } else if (ctrl && shift) { + List fields = item.getFields(stack, player.inventory.currentItem); + for (ItemConfigField field : fields) { + if (field.name.equals(References.ATTACK_AOE)) { + int aoe = (Integer) field.value; + aoe++; + if (aoe > (Integer) field.max) aoe = (Integer) field.min; + field.value = aoe; + DataUtills.writeObjectToCompound(IConfigurableItem.ProfileHelper.getProfileCompound(stack), field.value, field.datatype, field.name); + } + } + } + } - public ToolMaterial getToolMaterial() - { - return toolMaterial; - } + public ToolMaterial getToolMaterial() { + return toolMaterial; + } - @SuppressWarnings("unchecked") - public static void holdCTRLForUpgrades(List list, ItemStack stack){ - if (stack == null || !(stack.getItem() instanceof IUpgradableItem)) return; - if (!InfoHelper.isCtrlKeyDown()) list.add(StatCollector.translateToLocal("info.de.hold.txt")+" "+ EnumChatFormatting.AQUA + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.de.ctrl.txt") + EnumChatFormatting.RESET + " " + EnumChatFormatting.GRAY + StatCollector.translateToLocal("info.de.forUpgrades.txt")); - else { - list.addAll(((IUpgradableItem)stack.getItem()).getUpgradeStats(stack)); - list.add(EnumChatFormatting.GOLD+""+EnumChatFormatting.ITALIC+StatCollector.translateToLocal("info.de.useUpgradeModifier.txt")); - } - } + @SuppressWarnings("unchecked") + public static void holdCTRLForUpgrades(List list, ItemStack stack) { + if (stack == null || !(stack.getItem() instanceof IUpgradableItem)) return; + if (!InfoHelper.isCtrlKeyDown()) + list.add(StatCollector.translateToLocal("info.de.hold.txt") + " " + EnumChatFormatting.AQUA + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.de.ctrl.txt") + EnumChatFormatting.RESET + " " + EnumChatFormatting.GRAY + StatCollector.translateToLocal("info.de.forUpgrades.txt")); + else { + list.addAll(((IUpgradableItem) stack.getItem()).getUpgradeStats(stack)); + list.add(EnumChatFormatting.GOLD + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.de.useUpgradeModifier.txt")); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/ToolHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/ToolHandler.java index c2188988..cec0c2af 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/ToolHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/ToolHandler.java @@ -135,204 +135,199 @@ public class ToolHandler { // } // } - public static void damageEntityBasedOnHealth(Entity entity, EntityPlayer player, float dmgMult) { - ItemStack stack = player.getCurrentEquippedItem(); - if (stack == null || !(stack.getItem() instanceof IEnergyContainerWeaponItem)){ - LogHelper.error("[ToolHandler.java:147] WTF? I don't get it... Player "+player.getCommandSenderName()+" whacked something with a DE weapon but that they are not holding? Ok someone is messing with my shit..."); - return; - } + public static void damageEntityBasedOnHealth(Entity entity, EntityPlayer player, float dmgMult) { + ItemStack stack = player.getCurrentEquippedItem(); + if (stack == null || !(stack.getItem() instanceof IEnergyContainerWeaponItem)) { + LogHelper.error("[ToolHandler.java:147] WTF? I don't get it... Player " + player.getCommandSenderName() + " whacked something with a DE weapon but that they are not holding? Ok someone is messing with my shit..."); + return; + } - IEnergyContainerWeaponItem item = (IEnergyContainerWeaponItem) stack.getItem(); - float baseAttack = getDamageAgainstEntity(stack, entity); + IEnergyContainerWeaponItem item = (IEnergyContainerWeaponItem) stack.getItem(); + float baseAttack = getDamageAgainstEntity(stack, entity); - if (entity instanceof EntityLivingBase) - { - float entHealth = ((EntityLivingBase) entity).getHealth(); - baseAttack += (entHealth * dmgMult); - } + if (entity instanceof EntityLivingBase) { + float entHealth = ((EntityLivingBase) entity).getHealth(); + baseAttack += (entHealth * dmgMult); + } - if (entity instanceof EntityDragonPart) - { - List list = player.worldObj.getEntitiesWithinAABB(EntityDragon.class, entity.boundingBox.expand(10, 10, 10)); - if (!list.isEmpty() && list.get(0) instanceof EntityDragon){ - EntityDragon dragon = list.get(0); - float entHealth = dragon.getHealth(); - baseAttack += (entHealth * dmgMult); - } - } + if (entity instanceof EntityDragonPart) { + List list = player.worldObj.getEntitiesWithinAABB(EntityDragon.class, entity.boundingBox.expand(10, 10, 10)); + if (!list.isEmpty() && list.get(0) instanceof EntityDragon) { + EntityDragon dragon = list.get(0); + float entHealth = dragon.getHealth(); + baseAttack += (entHealth * dmgMult); + } + } - int rf = (int)baseAttack * item.getEnergyPerAttack(); - if (rf > item.getEnergyStored(stack)) { - baseAttack = item.getEnergyStored(stack) / item.getEnergyPerAttack(); - rf = item.getEnergyStored(stack); - } - if (baseAttack <= 0) baseAttack = 1; + int rf = (int) baseAttack * item.getEnergyPerAttack(); + if (rf > item.getEnergyStored(stack)) { + baseAttack = item.getEnergyStored(stack) / item.getEnergyPerAttack(); + rf = item.getEnergyStored(stack); + } + if (baseAttack <= 0) baseAttack = 1; - entity.attackEntityFrom(DamageSource.causePlayerDamage(player), baseAttack); - if (EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, stack) > 0) entity.setFire(EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, stack) * 15); + entity.attackEntityFrom(DamageSource.causePlayerDamage(player), baseAttack); + if (EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, stack) > 0) + entity.setFire(EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, stack) * 15); - if (!player.capabilities.isCreativeMode) item.extractEnergy(stack, rf, false); + if (!player.capabilities.isCreativeMode) item.extractEnergy(stack, rf, false); - if (entity instanceof EntityLivingBase) { - EntityLivingBase entityLivingBase = (EntityLivingBase)entity; - double d1 = player.posX - entityLivingBase.posX; - double d0; + if (entity instanceof EntityLivingBase) { + EntityLivingBase entityLivingBase = (EntityLivingBase) entity; + double d1 = player.posX - entityLivingBase.posX; + double d0; - for (d0 = player.posZ - entityLivingBase.posZ; d1 * d1 + d0 * d0 < 1.0E-4D; d0 = (Math.random() - Math.random()) * 0.01D) - { - d1 = (Math.random() - Math.random()) * 0.01D; - } - entityLivingBase.attackedAtYaw = (float)(Math.atan2(d0, d1) * 180.0D / Math.PI) - entityLivingBase.rotationYaw; + for (d0 = player.posZ - entityLivingBase.posZ; d1 * d1 + d0 * d0 < 1.0E-4D; d0 = (Math.random() - Math.random()) * 0.01D) { + d1 = (Math.random() - Math.random()) * 0.01D; + } + entityLivingBase.attackedAtYaw = (float) (Math.atan2(d0, d1) * 180.0D / Math.PI) - entityLivingBase.rotationYaw; - if (entityLivingBase.worldObj.rand.nextDouble() >= entityLivingBase.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).getAttributeValue()) - { - entityLivingBase.isAirBorne = true; - float f1 = MathHelper.sqrt_double(d1 * d1 + d0 * d0); - float f2 = 0.1F + EnchantmentHelper.getKnockbackModifier(player, entityLivingBase) * 0.4F; - entityLivingBase.motionX /= 2.0D; - entityLivingBase.motionY /= 2.0D; - entityLivingBase.motionZ /= 2.0D; - entityLivingBase.motionX -= d1 / (double)f1 * (double)f2; - entityLivingBase.motionY += (double)f2; - entityLivingBase.motionZ -= d0 / (double)f1 * (double)f2; + if (entityLivingBase.worldObj.rand.nextDouble() >= entityLivingBase.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).getAttributeValue()) { + entityLivingBase.isAirBorne = true; + float f1 = MathHelper.sqrt_double(d1 * d1 + d0 * d0); + float f2 = 0.1F + EnchantmentHelper.getKnockbackModifier(player, entityLivingBase) * 0.4F; + entityLivingBase.motionX /= 2.0D; + entityLivingBase.motionY /= 2.0D; + entityLivingBase.motionZ /= 2.0D; + entityLivingBase.motionX -= d1 / (double) f1 * (double) f2; + entityLivingBase.motionY += (double) f2; + entityLivingBase.motionZ -= d0 / (double) f1 * (double) f2; - if (entityLivingBase.motionY > 0.4000000059604645D) - { - entityLivingBase.motionY = 0.4000000059604645D; - } - } - } - } + if (entityLivingBase.motionY > 0.4000000059604645D) { + entityLivingBase.motionY = 0.4000000059604645D; + } + } + } + } - @SuppressWarnings({"rawtypes", "unused"}) - public static void AOEAttack(EntityPlayer player, Entity entity, ItemStack stack, int range) { - World world = player.worldObj; - AxisAlignedBB box = AxisAlignedBB.getBoundingBox(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range).expand(1.0D, 1.0D, 1.0D); - List list = world.getEntitiesWithinAABBExcludingEntity(player, box); - if (range == 0) return; - IEnergyContainerWeaponItem item = (IEnergyContainerWeaponItem)stack.getItem(); + @SuppressWarnings({"rawtypes", "unused"}) + public static void AOEAttack(EntityPlayer player, Entity entity, ItemStack stack, int range) { + World world = player.worldObj; + AxisAlignedBB box = AxisAlignedBB.getBoundingBox(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range).expand(1.0D, 1.0D, 1.0D); + List list = world.getEntitiesWithinAABBExcludingEntity(player, box); + if (range == 0) return; + IEnergyContainerWeaponItem item = (IEnergyContainerWeaponItem) stack.getItem(); - for (Object entityObject : list) { - if (item.getEnergyStored(stack) < item.getEnergyPerAttack()) break; - if (entityObject instanceof EntityLivingBase) { - EntityLivingBase entityLivingBase = (EntityLivingBase) entityObject; - if (entityLivingBase.getEntityId() == entity.getEntityId()) continue; + for (Object entityObject : list) { + if (item.getEnergyStored(stack) < item.getEnergyPerAttack()) break; + if (entityObject instanceof EntityLivingBase) { + EntityLivingBase entityLivingBase = (EntityLivingBase) entityObject; + if (entityLivingBase.getEntityId() == entity.getEntityId()) continue; - float dmg = getDamageAgainstEntity(stack, entityLivingBase); - int rf = (int)dmg * item.getEnergyPerAttack(); - if (rf > item.getEnergyStored(stack)) { - dmg = item.getEnergyStored(stack) / item.getEnergyPerAttack(); - rf = item.getEnergyStored(stack); - } + float dmg = getDamageAgainstEntity(stack, entityLivingBase); + int rf = (int) dmg * item.getEnergyPerAttack(); + if (rf > item.getEnergyStored(stack)) { + dmg = item.getEnergyStored(stack) / item.getEnergyPerAttack(); + rf = item.getEnergyStored(stack); + } - entityLivingBase.attackEntityFrom(DamageSource.causePlayerDamage(player), dmg); - item.extractEnergy(stack, rf, false); - if (EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, stack) > 0) entityLivingBase.setFire(EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, stack) * 15); + entityLivingBase.attackEntityFrom(DamageSource.causePlayerDamage(player), dmg); + item.extractEnergy(stack, rf, false); + if (EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, stack) > 0) + entityLivingBase.setFire(EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, stack) * 15); - double d1 = player.posX - entityLivingBase.posX; - double d0; + double d1 = player.posX - entityLivingBase.posX; + double d0; - for (d0 = player.posZ - entityLivingBase.posZ; d1 * d1 + d0 * d0 < 1.0E-4D; d0 = (Math.random() - Math.random()) * 0.01D) { - d1 = (Math.random() - Math.random()) * 0.01D; - } + for (d0 = player.posZ - entityLivingBase.posZ; d1 * d1 + d0 * d0 < 1.0E-4D; d0 = (Math.random() - Math.random()) * 0.01D) { + d1 = (Math.random() - Math.random()) * 0.01D; + } - if (entityLivingBase.worldObj.rand.nextDouble() >= entityLivingBase.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).getAttributeValue()) { - entityLivingBase.isAirBorne = true; - float f1 = MathHelper.sqrt_double(d1 * d1 + d0 * d0); - float f2 = 0.1F + (EnchantmentHelper.getKnockbackModifier(player, entityLivingBase) * 0.4F); - entityLivingBase.motionX /= 2.0D; - entityLivingBase.motionY /= 2.0D; - entityLivingBase.motionZ /= 2.0D; - entityLivingBase.motionX -= d1 / (double) f1 * (double) f2; - entityLivingBase.motionY += (double) f2; - entityLivingBase.motionZ -= d0 / (double) f1 * (double) f2; + if (entityLivingBase.worldObj.rand.nextDouble() >= entityLivingBase.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).getAttributeValue()) { + entityLivingBase.isAirBorne = true; + float f1 = MathHelper.sqrt_double(d1 * d1 + d0 * d0); + float f2 = 0.1F + (EnchantmentHelper.getKnockbackModifier(player, entityLivingBase) * 0.4F); + entityLivingBase.motionX /= 2.0D; + entityLivingBase.motionY /= 2.0D; + entityLivingBase.motionZ /= 2.0D; + entityLivingBase.motionX -= d1 / (double) f1 * (double) f2; + entityLivingBase.motionY += (double) f2; + entityLivingBase.motionZ -= d0 / (double) f1 * (double) f2; - if (entityLivingBase.motionY > 0.4000000059604645D) { - entityLivingBase.motionY = 0.4000000059604645D; - } - } - entityLivingBase.attackTime = 0; - } - else if (entityObject instanceof EntityDragonProjectile) { - float dmg = getDamageAgainstEntity(stack, ((Entity)entityObject)); - int rf = (int)dmg * item.getEnergyPerAttack(); - if (rf > item.getEnergyStored(stack)) { - dmg = item.getEnergyStored(stack) / item.getEnergyPerAttack(); - rf = item.getEnergyStored(stack); - } + if (entityLivingBase.motionY > 0.4000000059604645D) { + entityLivingBase.motionY = 0.4000000059604645D; + } + } + entityLivingBase.attackTime = 0; + } else if (entityObject instanceof EntityDragonProjectile) { + float dmg = getDamageAgainstEntity(stack, ((Entity) entityObject)); + int rf = (int) dmg * item.getEnergyPerAttack(); + if (rf > item.getEnergyStored(stack)) { + dmg = item.getEnergyStored(stack) / item.getEnergyPerAttack(); + rf = item.getEnergyStored(stack); + } - ((Entity)entityObject).attackEntityFrom(DamageSource.causePlayerDamage(player), dmg); - item.extractEnergy(stack, rf, false); - } - } + ((Entity) entityObject).attackEntityFrom(DamageSource.causePlayerDamage(player), dmg); + item.extractEnergy(stack, rf, false); + } + } - } + } - public static MovingObjectPosition raytraceFromEntity(World world, Entity player, double range) {//todo move to core and make the range work as expected - float f = 1.0F; - float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; - float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f; - double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f; - double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f; - if (!world.isRemote && player instanceof EntityPlayer) d1 += 1.62D; - double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f; - Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2); - float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); - float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); - float f5 = -MathHelper.cos(-f1 * 0.017453292F); - float f6 = MathHelper.sin(-f1 * 0.017453292F); - float f7 = f4 * f5; - float f8 = f3 * f5; - double d3 = range; - if (player instanceof EntityPlayerMP && range < 10) { - d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance(); - } - Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); - return world.rayTraceBlocks(vec3, vec31); - } + public static MovingObjectPosition raytraceFromEntity(World world, Entity player, double range) {//todo move to core and make the range work as expected + float f = 1.0F; + float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; + float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f; + double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f; + double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f; + if (!world.isRemote && player instanceof EntityPlayer) d1 += 1.62D; + double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f; + Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2); + float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); + float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); + float f5 = -MathHelper.cos(-f1 * 0.017453292F); + float f6 = MathHelper.sin(-f1 * 0.017453292F); + float f7 = f4 * f5; + float f8 = f3 * f5; + double d3 = range; + if (player instanceof EntityPlayerMP && range < 10) { + d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance(); + } + Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); + return world.rayTraceBlocks(vec3, vec31); + } - public static void updateGhostBlocks(EntityPlayer player, World world) { - if (world.isRemote) return; - int xPos = (int) player.posX; - int yPos = (int) player.posY; - int zPos = (int) player.posZ; + public static void updateGhostBlocks(EntityPlayer player, World world) { + if (world.isRemote) return; + int xPos = (int) player.posX; + int yPos = (int) player.posY; + int zPos = (int) player.posZ; - for (int x = xPos - 6; x < xPos + 6; x++) { - for (int y = yPos - 6; y < yPos + 6; y++) { - for (int z = zPos - 6; z < zPos + 6; z++) { - ((EntityPlayerMP)player).playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); - //world.markBlockForUpdate(x, y, z); - } - } - } - } + for (int x = xPos - 6; x < xPos + 6; x++) { + for (int y = yPos - 6; y < yPos + 6; y++) { + for (int z = zPos - 6; z < zPos + 6; z++) { + ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); + //world.markBlockForUpdate(x, y, z); + } + } + } + } - public static float getBaseAttackDamage(ItemStack stack) - { - float dmg = 0; - if (stack == null) return 1; + public static float getBaseAttackDamage(ItemStack stack) { + float dmg = 0; + if (stack == null) return 1; - float sharpMod = (float)EnchantmentHelper.getEnchantmentLevel(Enchantment.sharpness.effectId, stack) * 4F; + float sharpMod = (float) EnchantmentHelper.getEnchantmentLevel(Enchantment.sharpness.effectId, stack) * 4F; - if (stack.getItem() == ModItems.draconicDestructionStaff) dmg = (ModItems.CHAOTIC.getDamageVsEntity()) + sharpMod; - else if (stack.getItem() instanceof ItemSword) dmg = (((ItemSword)stack.getItem()).func_150931_i()) + sharpMod; + if (stack.getItem() == ModItems.draconicDestructionStaff) + dmg = (ModItems.CHAOTIC.getDamageVsEntity()) + sharpMod; + else if (stack.getItem() instanceof ItemSword) dmg = (((ItemSword) stack.getItem()).func_150931_i()) + sharpMod; - dmg += (IUpgradableItem.EnumUpgrade.ATTACK_DAMAGE.getUpgradePoints(stack) * 5); + dmg += (IUpgradableItem.EnumUpgrade.ATTACK_DAMAGE.getUpgradePoints(stack) * 5); - return dmg; - } + return dmg; + } - public static float getDamageAgainstEntity(ItemStack stack, Entity entity) - { - float baseAttack = getBaseAttackDamage(stack); - float smiteMod = EnchantmentHelper.getEnchantmentLevel(Enchantment.smite.effectId ,stack) * 6F; - float athropodsMod = EnchantmentHelper.getEnchantmentLevel(Enchantment.baneOfArthropods.effectId ,stack) * 6F; + public static float getDamageAgainstEntity(ItemStack stack, Entity entity) { + float baseAttack = getBaseAttackDamage(stack); + float smiteMod = EnchantmentHelper.getEnchantmentLevel(Enchantment.smite.effectId, stack) * 6F; + float athropodsMod = EnchantmentHelper.getEnchantmentLevel(Enchantment.baneOfArthropods.effectId, stack) * 6F; - if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).isEntityUndead()) baseAttack += smiteMod; - if (entity instanceof EntitySpider) baseAttack += athropodsMod; + if (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isEntityUndead()) baseAttack += smiteMod; + if (entity instanceof EntitySpider) baseAttack += athropodsMod; - return baseAttack; - } + return baseAttack; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/BowHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/BowHandler.java index c1f3097c..f525631d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/BowHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/BowHandler.java @@ -23,225 +23,213 @@ import net.minecraftforge.event.entity.player.ArrowNockEvent; public class BowHandler { - public static ItemStack onBowRightClick(Item bow, ItemStack stack, World world, EntityPlayer player){ - BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, player); - if (properties.canFire()){ - ArrowNockEvent event = new ArrowNockEvent(player, stack); - MinecraftForge.EVENT_BUS.post(event); - if (event.isCanceled()) { - return event.result; - } + public static ItemStack onBowRightClick(Item bow, ItemStack stack, World world, EntityPlayer player) { + BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, player); + if (properties.canFire()) { + ArrowNockEvent event = new ArrowNockEvent(player, stack); + MinecraftForge.EVENT_BUS.post(event); + if (event.isCanceled()) { + return event.result; + } - player.setItemInUse(stack, bow.getMaxItemUseDuration(stack)); - } + player.setItemInUse(stack, bow.getMaxItemUseDuration(stack)); + } - return stack; - } + return stack; + } - public static void onBowUsingTick(ItemStack stack, EntityPlayer player, int count){ - BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, player); - int j = 72000 - count; - if (properties.autoFire && j >= properties.getDrawTicks()) player.stopUsingItem(); - } + public static void onBowUsingTick(ItemStack stack, EntityPlayer player, int count) { + BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, player); + int j = 72000 - count; + if (properties.autoFire && j >= properties.getDrawTicks()) player.stopUsingItem(); + } - public static void onPlayerStoppedUsingBow(ItemStack stack, World world, EntityPlayer player, int count){ - BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, player); - if (!properties.canFire() || !(stack.getItem() instanceof IEnergyContainerItem)) return; + public static void onPlayerStoppedUsingBow(ItemStack stack, World world, EntityPlayer player, int count) { + BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, player); + if (!properties.canFire() || !(stack.getItem() instanceof IEnergyContainerItem)) return; - int j = 72000 - count; - ArrowLooseEvent event = new ArrowLooseEvent(player, stack, j); - MinecraftForge.EVENT_BUS.post(event); + int j = 72000 - count; + ArrowLooseEvent event = new ArrowLooseEvent(player, stack, j); + MinecraftForge.EVENT_BUS.post(event); - if (event.isCanceled()) - { - return; - } + if (event.isCanceled()) { + return; + } - j = event.charge; + j = event.charge; - float drawArrowSpeedModifier = Math.min((float) j / (float) properties.getDrawTicks(), 1F); + float drawArrowSpeedModifier = Math.min((float) j / (float) properties.getDrawTicks(), 1F); - if (drawArrowSpeedModifier < 0.1) - { - return; - } + if (drawArrowSpeedModifier < 0.1) { + return; + } - float velocity = properties.arrowSpeed * drawArrowSpeedModifier * 2F; //2F is the speed of a vanilla arrow + float velocity = properties.arrowSpeed * drawArrowSpeedModifier * 2F; //2F is the speed of a vanilla arrow - EntityCustomArrow customArrow = new EntityCustomArrow(world, player, velocity); - customArrow.bowProperties = properties; + EntityCustomArrow customArrow = new EntityCustomArrow(world, player, velocity); + customArrow.bowProperties = properties; - if (drawArrowSpeedModifier == 1.0F) - { - customArrow.setIsCritical(true); - } + if (drawArrowSpeedModifier == 1.0F) { + customArrow.setIsCritical(true); + } - if (properties.consumeArrowAndEnergy()) - { - customArrow.canBePickedUp = 1; - } - else - { - customArrow.canBePickedUp = 2; - } + if (properties.consumeArrowAndEnergy()) { + customArrow.canBePickedUp = 1; + } else { + customArrow.canBePickedUp = 2; + } - if (!world.isRemote) world.spawnEntityInWorld(customArrow); + if (!world.isRemote) world.spawnEntityInWorld(customArrow); - world.playSoundAtEntity(player, "random.bow", 1.0F, (1.0F / (world.rand.nextFloat() * 0.4F + 1.2F) + (drawArrowSpeedModifier + (velocity / 40F)) * 0.5F)); - } + world.playSoundAtEntity(player, "random.bow", 1.0F, (1.0F / (world.rand.nextFloat() * 0.4F + 1.2F) + (drawArrowSpeedModifier + (velocity / 40F)) * 0.5F)); + } - public static void enderShot(ItemStack stack, World world, EntityPlayer player, int count, Random itemRand, float pullSpeedModifier, float speedModifier, float soundPitchModifier, int minRelease) - { - int j = 72000 - count; - ArrowLooseEvent event = new ArrowLooseEvent(player, stack, j); - MinecraftForge.EVENT_BUS.post(event); - if (event.isCanceled()) { - return; - } - j = event.charge; + public static void enderShot(ItemStack stack, World world, EntityPlayer player, int count, Random itemRand, float pullSpeedModifier, float speedModifier, float soundPitchModifier, int minRelease) { + int j = 72000 - count; + ArrowLooseEvent event = new ArrowLooseEvent(player, stack, j); + MinecraftForge.EVENT_BUS.post(event); + if (event.isCanceled()) { + return; + } + j = event.charge; - if (player.inventory.hasItem(ModItems.enderArrow)) { - float f = j / pullSpeedModifier; - f = (f * f + f * 2.0F) / 3.0F; + if (player.inventory.hasItem(ModItems.enderArrow)) { + float f = j / pullSpeedModifier; + f = (f * f + f * 2.0F) / 3.0F; - if ((j < minRelease) || f < 0.1D) - return; + if ((j < minRelease) || f < 0.1D) return; - if (f > 1.0F) - f = 1.0F; + if (f > 1.0F) f = 1.0F; - f *= speedModifier; + f *= speedModifier; - EntityEnderArrow entityArrow = new EntityEnderArrow(world, player, f * 2.0F); + EntityEnderArrow entityArrow = new EntityEnderArrow(world, player, f * 2.0F); - stack.damageItem(1, player); // - world.playSoundAtEntity(player, "random.bow", 1.0F, soundPitchModifier * (1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.3F)); + stack.damageItem(1, player); // + world.playSoundAtEntity(player, "random.bow", 1.0F, soundPitchModifier * (1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.3F)); - if (player.inventory.hasItem(ModItems.enderArrow)) player.inventory.consumeInventoryItem(ModItems.enderArrow); + if (player.inventory.hasItem(ModItems.enderArrow)) + player.inventory.consumeInventoryItem(ModItems.enderArrow); - if (!world.isRemote) { - world.spawnEntityInWorld(entityArrow); - player.mountEntity(entityArrow); - } + if (!world.isRemote) { + world.spawnEntityInWorld(entityArrow); + player.mountEntity(entityArrow); + } - } - } + } + } - public static class BowProperties { - public ItemStack bow; - public EntityPlayer player; + public static class BowProperties { + public ItemStack bow; + public EntityPlayer player; - public float arrowDamage = 0F; - public float arrowSpeed = 0F; - public float explosionPower = 0F; - public float shockWavePower = 0F; - public float zoomModifier = 0F; - private int drawTimeReduction = 0; - public boolean autoFire = false; - public boolean energyBolt = false; + public float arrowDamage = 0F; + public float arrowSpeed = 0F; + public float explosionPower = 0F; + public float shockWavePower = 0F; + public float zoomModifier = 0F; + private int drawTimeReduction = 0; + public boolean autoFire = false; + public boolean energyBolt = false; - public String cantFireMessage = null; + public String cantFireMessage = null; - public BowProperties(){ - this.bow = new ItemStack(ModItems.wyvernBow); - this.player = null; - } + public BowProperties() { + this.bow = new ItemStack(ModItems.wyvernBow); + this.player = null; + } - public BowProperties(ItemStack bow, EntityPlayer player){ - this.bow = bow; - this.player = player; - updateValues(); - } + public BowProperties(ItemStack bow, EntityPlayer player) { + this.bow = bow; + this.player = player; + updateValues(); + } - public int calculateEnergyCost(){ - updateValues(); - double rfCost = (bow.getItem() instanceof IEnergyContainerWeaponItem) ? - ((IEnergyContainerWeaponItem) bow.getItem()).getEnergyPerAttack() : 80; + public int calculateEnergyCost() { + updateValues(); + double rfCost = (bow.getItem() instanceof IEnergyContainerWeaponItem) ? ((IEnergyContainerWeaponItem) bow.getItem()).getEnergyPerAttack() : 80; - rfCost *= 1 + arrowDamage; - rfCost *= (1 + arrowSpeed) * (1 + arrowSpeed) * (1 + arrowSpeed); - rfCost *= 1 + explosionPower * 20; - rfCost *= 1 + shockWavePower * 10; - if (energyBolt) rfCost *= BalanceConfigHandler.draconicFireEnergyCostMultiptier; + rfCost *= 1 + arrowDamage; + rfCost *= (1 + arrowSpeed) * (1 + arrowSpeed) * (1 + arrowSpeed); + rfCost *= 1 + explosionPower * 20; + rfCost *= 1 + shockWavePower * 10; + if (energyBolt) rfCost *= BalanceConfigHandler.draconicFireEnergyCostMultiptier; - return (int)rfCost; - } + return (int) rfCost; + } - public boolean canFire(){ - updateValues(); + public boolean canFire() { + updateValues(); - if (player == null) return false; - if (!(bow.getItem() instanceof IEnergyContainerWeaponItem)){ - cantFireMessage = "[Error] This bow is not a valid energy container (This is a bug, Please report on the Draconic Evolution github)"; - return false; - } - else if (!energyBolt && shockWavePower > 0){ - cantFireMessage = "msg.de.shockWaveForEnergyBoltsOnly.txt"; - return false; - } - else if (energyBolt && explosionPower > 0){ - cantFireMessage = "msg.de.explosiveNotForEnergyBolts.txt"; - return false; - } - else if (calculateEnergyCost() > ((IEnergyContainerWeaponItem)bow.getItem()).getEnergyStored(bow) && !player.capabilities.isCreativeMode){ - cantFireMessage = "msg.de.insufficientPowerToFire.txt"; - return false; - } - else if (!energyBolt && !player.inventory.hasItem(Items.arrow) && EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, bow) == 0 && !player.capabilities.isCreativeMode){ - cantFireMessage = "msg.de.outOfArrows.txt"; - return false; - } + if (player == null) return false; + if (!(bow.getItem() instanceof IEnergyContainerWeaponItem)) { + cantFireMessage = "[Error] This bow is not a valid energy container (This is a bug, Please report on the Draconic Evolution github)"; + return false; + } else if (!energyBolt && shockWavePower > 0) { + cantFireMessage = "msg.de.shockWaveForEnergyBoltsOnly.txt"; + return false; + } else if (energyBolt && explosionPower > 0) { + cantFireMessage = "msg.de.explosiveNotForEnergyBolts.txt"; + return false; + } else if (calculateEnergyCost() > ((IEnergyContainerWeaponItem) bow.getItem()).getEnergyStored(bow) && !player.capabilities.isCreativeMode) { + cantFireMessage = "msg.de.insufficientPowerToFire.txt"; + return false; + } else if (!energyBolt && !player.inventory.hasItem(Items.arrow) && EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, bow) == 0 && !player.capabilities.isCreativeMode) { + cantFireMessage = "msg.de.outOfArrows.txt"; + return false; + } - cantFireMessage = null; - return true; - } + cantFireMessage = null; + return true; + } - private void updateValues(){ - arrowDamage = IConfigurableItem.ProfileHelper.getFloat(bow, "BowArrowDamage", IUpgradableItem.EnumUpgrade.ARROW_DAMAGE.getUpgradePoints(bow)); - arrowSpeed = 1F + IConfigurableItem.ProfileHelper.getFloat(bow, "BowArrowSpeedModifier", 0F); - explosionPower = IConfigurableItem.ProfileHelper.getFloat(bow, "BowExplosionPower", 0F); - shockWavePower = IConfigurableItem.ProfileHelper.getFloat(bow, "BowShockWavePower", 0F); - drawTimeReduction = IUpgradableItem.EnumUpgrade.DRAW_SPEED.getUpgradePoints(bow); - zoomModifier = IConfigurableItem.ProfileHelper.getFloat(bow, "BowZoomModifier", 0F); - autoFire = IConfigurableItem.ProfileHelper.getBoolean(bow, "BowAutoFire", false); - energyBolt = IConfigurableItem.ProfileHelper.getBoolean(bow, "BowEnergyBolt", false); - } + private void updateValues() { + arrowDamage = IConfigurableItem.ProfileHelper.getFloat(bow, "BowArrowDamage", IUpgradableItem.EnumUpgrade.ARROW_DAMAGE.getUpgradePoints(bow)); + arrowSpeed = 1F + IConfigurableItem.ProfileHelper.getFloat(bow, "BowArrowSpeedModifier", 0F); + explosionPower = IConfigurableItem.ProfileHelper.getFloat(bow, "BowExplosionPower", 0F); + shockWavePower = IConfigurableItem.ProfileHelper.getFloat(bow, "BowShockWavePower", 0F); + drawTimeReduction = IUpgradableItem.EnumUpgrade.DRAW_SPEED.getUpgradePoints(bow); + zoomModifier = IConfigurableItem.ProfileHelper.getFloat(bow, "BowZoomModifier", 0F); + autoFire = IConfigurableItem.ProfileHelper.getBoolean(bow, "BowAutoFire", false); + energyBolt = IConfigurableItem.ProfileHelper.getBoolean(bow, "BowEnergyBolt", false); + } - public int getDrawTicks(){ - return Math.max(62 - (drawTimeReduction * 10), 1); - } + public int getDrawTicks() { + return Math.max(62 - (drawTimeReduction * 10), 1); + } /** * Consumes energy for the shot and also consumes an arrow if the bow dose not have infinity * Returns true if an arrow was consumed. - * */ - public boolean consumeArrowAndEnergy(){ + */ + public boolean consumeArrowAndEnergy() { - if (!player.capabilities.isCreativeMode)((IEnergyContainerWeaponItem)bow.getItem()).extractEnergy(bow, calculateEnergyCost(), false); + if (!player.capabilities.isCreativeMode) + ((IEnergyContainerWeaponItem) bow.getItem()).extractEnergy(bow, calculateEnergyCost(), false); - if (!energyBolt && EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, bow) == 0 && !player.capabilities.isCreativeMode) { - player.inventory.consumeInventoryItem(Items.arrow); - return true; - } + if (!energyBolt && EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, bow) == 0 && !player.capabilities.isCreativeMode) { + player.inventory.consumeInventoryItem(Items.arrow); + return true; + } - return false; - } + return false; + } - public void writeToNBT(NBTTagCompound compound){ - compound.setFloat("ArrowDamage", arrowDamage); - compound.setFloat("ArrowExplosive", explosionPower); - compound.setFloat("ArrowShock", shockWavePower); - compound.setBoolean("ArrowEnergy", energyBolt); - } + public void writeToNBT(NBTTagCompound compound) { + compound.setFloat("ArrowDamage", arrowDamage); + compound.setFloat("ArrowExplosive", explosionPower); + compound.setFloat("ArrowShock", shockWavePower); + compound.setBoolean("ArrowEnergy", energyBolt); + } - public void readFromNBT(NBTTagCompound compound){ - arrowDamage = compound.getFloat("ArrowDamage"); - explosionPower = compound.getFloat("ArrowExplosive"); - shockWavePower = compound.getFloat("ArrowShock"); - energyBolt = compound.getBoolean("ArrowEnergy"); - } - } + public void readFromNBT(NBTTagCompound compound) { + arrowDamage = compound.getFloat("ArrowDamage"); + explosionPower = compound.getFloat("ArrowExplosive"); + shockWavePower = compound.getFloat("ArrowShock"); + energyBolt = compound.getBoolean("ArrowEnergy"); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicBow.java b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicBow.java index 858557b1..11263332 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicBow.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicBow.java @@ -36,337 +36,328 @@ import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -public class DraconicBow extends ItemBow implements IInventoryTool, IUpgradableItem, IEnergyContainerWeaponItem, IHudDisplayItem -{ - public static final String[] bowPullIconNameArray = new String[] { "pulling_0", "pulling_1", "pulling_2" }; +public class DraconicBow extends ItemBow implements IInventoryTool, IUpgradableItem, IEnergyContainerWeaponItem, IHudDisplayItem { + public static final String[] bowPullIconNameArray = new String[]{"pulling_0", "pulling_1", "pulling_2"}; - protected int capacity = BalanceConfigHandler.draconicWeaponsBaseStorage; - protected int maxReceive = BalanceConfigHandler.draconicWeaponsMaxTransfer; - protected int maxExtract = BalanceConfigHandler.draconicWeaponsMaxTransfer; - @SideOnly(Side.CLIENT) - private IIcon[] iconArray; + protected int capacity = BalanceConfigHandler.draconicWeaponsBaseStorage; + protected int maxReceive = BalanceConfigHandler.draconicWeaponsMaxTransfer; + protected int maxExtract = BalanceConfigHandler.draconicWeaponsMaxTransfer; + @SideOnly(Side.CLIENT) + private IIcon[] iconArray; - public DraconicBow() { - this.maxStackSize = 1; - this.setMaxDamage(-1); - this.setCreativeTab(DraconicEvolution.tabToolsWeapons); - this.setUnlocalizedName(Strings.draconicBowName); - if (ModItems.isEnabled(this)) GameRegistry.registerItem(this, Strings.draconicBowName); - } + public DraconicBow() { + this.maxStackSize = 1; + this.setMaxDamage(-1); + this.setCreativeTab(DraconicEvolution.tabToolsWeapons); + this.setUnlocalizedName(Strings.draconicBowName); + if (ModItems.isEnabled(this)) GameRegistry.registerItem(this, Strings.draconicBowName); + } - //region Regular Item Stuff + //region Regular Item Stuff - @Override - public boolean isItemTool(ItemStack p_77616_1_) { - return true; - } + @Override + public boolean isItemTool(ItemStack p_77616_1_) { + return true; + } - @Override - public String getUnlocalizedName(){ + @Override + public String getUnlocalizedName() { - return String.format("item.%s%s", References.MODID.toLowerCase() + ":", super.getUnlocalizedName().substring(super.getUnlocalizedName().indexOf(".") + 1)); - } + return String.format("item.%s%s", References.MODID.toLowerCase() + ":", super.getUnlocalizedName().substring(super.getUnlocalizedName().indexOf(".") + 1)); + } - @Override - public String getUnlocalizedName(final ItemStack itemStack){ - return getUnlocalizedName(); - } + @Override + public String getUnlocalizedName(final ItemStack itemStack) { + return getUnlocalizedName(); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister iconRegister) - { - this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_bow" + "_standby"); - this.iconArray = new IIcon[bowPullIconNameArray.length]; + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_bow" + "_standby"); + this.iconArray = new IIcon[bowPullIconNameArray.length]; - for (int i = 0; i < this.iconArray.length; ++i) - { - this.iconArray[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_bow" + "_" + bowPullIconNameArray[i]); - } - } + for (int i = 0; i < this.iconArray.length; ++i) { + this.iconArray[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_bow" + "_" + bowPullIconNameArray[i]); + } + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) - { - float j = (float)stack.getMaxItemUseDuration() - (float)useRemaining; - if (usingItem == null) { - return this.itemIcon; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + float j = (float) stack.getMaxItemUseDuration() - (float) useRemaining; + if (usingItem == null) { + return this.itemIcon; + } - BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, player); + BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, player); - if (j > properties.getDrawTicks()) j = properties.getDrawTicks(); + if (j > properties.getDrawTicks()) j = properties.getDrawTicks(); - j /= (float)properties.getDrawTicks(); - int j2 = (int)(j * 2F); + j /= (float) properties.getDrawTicks(); + int j2 = (int) (j * 2F); - if (j2 < 0) j2 = 0; - else if (j2 > 2) j2 = 2; + if (j2 < 0) j2 = 0; + else if (j2 > 2) j2 = 2; - return getItemIconForUseDuration(j2); - } + return getItemIconForUseDuration(j2); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getItemIconForUseDuration(int par1) - { - return this.iconArray[par1]; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getItemIconForUseDuration(int par1) { + return this.iconArray[par1]; + } - @Override - @SideOnly(Side.CLIENT) - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) - { - boolean show = InfoHelper.holdShiftForDetails(list); - if (show){ - int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); - list.add(EnumChatFormatting.DARK_PURPLE+StatCollector.translateToLocal("info.de.capacitorMode.txt")+": "+ItemNBTHelper.getString(stack, "ProfileName"+preset, "Profile "+preset)); - List l = getFields(stack, 0); - for (ItemConfigField f : l) list.add(f.getTooltipInfo()); - } - ToolBase.holdCTRLForUpgrades(list, stack); - InfoHelper.addEnergyInfo(stack, list); - if (show && !ConfigHandler.disableLore) InfoHelper.addLore(stack, list, true); - } + @Override + @SideOnly(Side.CLIENT) + @SuppressWarnings({"unchecked", "rawtypes"}) + public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) { + boolean show = InfoHelper.holdShiftForDetails(list); + if (show) { + int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); + list.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("info.de.capacitorMode.txt") + ": " + ItemNBTHelper.getString(stack, "ProfileName" + preset, "Profile " + preset)); + List l = getFields(stack, 0); + for (ItemConfigField f : l) list.add(f.getTooltipInfo()); + } + ToolBase.holdCTRLForUpgrades(list, stack); + InfoHelper.addEnergyInfo(stack, list); + if (show && !ConfigHandler.disableLore) InfoHelper.addLore(stack, list, true); + } - @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", 0)); - list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", capacity)); - } + @SideOnly(Side.CLIENT) + @SuppressWarnings("unchecked") + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", 0)); + list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", capacity)); + } - @Override - public boolean getHasSubtypes() { - return true; - } + @Override + public boolean getHasSubtypes() { + return true; + } - @Override - public boolean showDurabilityBar(ItemStack stack) { - return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); - } + @Override + public boolean showDurabilityBar(ItemStack stack) { + return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); + } - @Override - public double getDurabilityForDisplay(ItemStack stack) { - return 1D - ((double) getEnergyStored(stack) / (double) getMaxEnergyStored(stack)); - } + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - ((double) getEnergyStored(stack) / (double) getMaxEnergyStored(stack)); + } - @Override - public boolean hasCustomEntity(ItemStack stack) { - return true; - } + @Override + public boolean hasCustomEntity(ItemStack stack) { + return true; + } - @Override - public Entity createEntity(World world, Entity location, ItemStack itemstack) { - return new EntityPersistentItem(world, location, itemstack); - } + @Override + public Entity createEntity(World world, Entity location, ItemStack itemstack) { + return new EntityPersistentItem(world, location, itemstack); + } - //endregion + //endregion - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) - { - return BowHandler.onBowRightClick(this, stack, world, player); - } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + return BowHandler.onBowRightClick(this, stack, world, player); + } - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) - { - BowHandler.onBowUsingTick(stack, player, count); - } + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + BowHandler.onBowUsingTick(stack, player, count); + } - @Override - public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int count) - { - BowHandler.onPlayerStoppedUsingBow(stack, world, player, count); - } + @Override + public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int count) { + BowHandler.onPlayerStoppedUsingBow(stack, world, player, count); + } - //region Interfaces + //region Interfaces - @Override - public String getInventoryName() { - return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); - } + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); + } - @Override - public int getInventorySlots() { - return 0; - } + @Override + public int getInventorySlots() { + return 0; + } - @Override - public boolean isEnchantValid(Enchantment enchant) { - return enchant.type == EnumEnchantmentType.bow || enchant.effectId == DraconicEvolution.reaperEnchant.effectId; - } + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.bow || enchant.effectId == DraconicEvolution.reaperEnchant.effectId; + } - @Override - public List getFields(ItemStack stack, int slot) { - List list = new ArrayList(); + @Override + public List getFields(ItemStack stack, int slot) { + List list = new ArrayList(); - list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowArrowDamage").setMinMaxAndIncromente((float)getBaseUpgradePoints(EnumUpgrade.ARROW_DAMAGE.index), (float)EnumUpgrade.ARROW_DAMAGE.getUpgradePoints(stack), 0.1F).readFromItem(stack, (float) EnumUpgrade.ARROW_DAMAGE.getUpgradePoints(stack))); - list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowArrowSpeedModifier").setMinMaxAndIncromente(0F, (float)EnumUpgrade.ARROW_SPEED.getUpgradePoints(stack), 0.01F).readFromItem(stack, 0F).setModifier("PLUSPERCENT")); - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "BowAutoFire").readFromItem(stack, false)); - list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowExplosionPower").setMinMaxAndIncromente(0F, 6F, 0.1F).readFromItem(stack, 0F)); - list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowShockWavePower").setMinMaxAndIncromente(0F, 10F, 0.1F).readFromItem(stack, 0F)); - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "BowEnergyBolt").readFromItem(stack, false)); - list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowZoomModifier").setMinMaxAndIncromente(0F, 6F, 0.01F).readFromItem(stack, 0F).setModifier("PLUSPERCENT")); + list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowArrowDamage").setMinMaxAndIncromente((float) getBaseUpgradePoints(EnumUpgrade.ARROW_DAMAGE.index), (float) EnumUpgrade.ARROW_DAMAGE.getUpgradePoints(stack), 0.1F).readFromItem(stack, (float) EnumUpgrade.ARROW_DAMAGE.getUpgradePoints(stack))); + list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowArrowSpeedModifier").setMinMaxAndIncromente(0F, (float) EnumUpgrade.ARROW_SPEED.getUpgradePoints(stack), 0.01F).readFromItem(stack, 0F).setModifier("PLUSPERCENT")); + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "BowAutoFire").readFromItem(stack, false)); + list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowExplosionPower").setMinMaxAndIncromente(0F, 6F, 0.1F).readFromItem(stack, 0F)); + list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowShockWavePower").setMinMaxAndIncromente(0F, 10F, 0.1F).readFromItem(stack, 0F)); + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "BowEnergyBolt").readFromItem(stack, false)); + list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowZoomModifier").setMinMaxAndIncromente(0F, 6F, 0.01F).readFromItem(stack, 0F).setModifier("PLUSPERCENT")); - return list; - } + return list; + } - @Override - public List getUpgrades(ItemStack itemstack) { - return new ArrayList(){{ - add(EnumUpgrade.RF_CAPACITY); - add(EnumUpgrade.DRAW_SPEED); - add(EnumUpgrade.ARROW_SPEED); - add(EnumUpgrade.ARROW_DAMAGE); - }}; - } + @Override + public List getUpgrades(ItemStack itemstack) { + return new ArrayList() {{ + add(EnumUpgrade.RF_CAPACITY); + add(EnumUpgrade.DRAW_SPEED); + add(EnumUpgrade.ARROW_SPEED); + add(EnumUpgrade.ARROW_DAMAGE); + }}; + } - @Override - public int getUpgradeCap(ItemStack itemstack) { - return BalanceConfigHandler.draconicBowMaxUpgrades; - } + @Override + public int getUpgradeCap(ItemStack itemstack) { + return BalanceConfigHandler.draconicBowMaxUpgrades; + } - @Override - public int getMaxTier(ItemStack itemstack) { - return 2; - } + @Override + public int getMaxTier(ItemStack itemstack) { + return 2; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { - return BalanceConfigHandler.draconicBowMaxCapacityUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DRAW_SPEED.index) { - return BalanceConfigHandler.draconicBowMaxDrawSpeedUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ARROW_SPEED.index) { - return BalanceConfigHandler.draconicBowMaxArrowSpeedUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ARROW_DAMAGE.index) { - return BalanceConfigHandler.draconicBowMaxArrowDamageUpgradePoints; - } - return BalanceConfigHandler.draconicBowMaxUpgradePoints; - } + @Override + public int getMaxUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { + return BalanceConfigHandler.draconicBowMaxCapacityUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DRAW_SPEED.index) { + return BalanceConfigHandler.draconicBowMaxDrawSpeedUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ARROW_SPEED.index) { + return BalanceConfigHandler.draconicBowMaxArrowSpeedUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ARROW_DAMAGE.index) { + return BalanceConfigHandler.draconicBowMaxArrowDamageUpgradePoints; + } + return BalanceConfigHandler.draconicBowMaxUpgradePoints; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) - { - return getMaxUpgradePoints(upgradeIndex); - } + @Override + public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) { + return getMaxUpgradePoints(upgradeIndex); + } - @Override - public int getBaseUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.DRAW_SPEED.index) { - return BalanceConfigHandler.draconicBowMinDrawSpeedUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ARROW_SPEED.index) { - return BalanceConfigHandler.draconicBowMinArrowSpeedUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ARROW_DAMAGE.index) { - return BalanceConfigHandler.draconicBowMinArrowDamageUpgradePoints; - } - return 0; - } + @Override + public int getBaseUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.DRAW_SPEED.index) { + return BalanceConfigHandler.draconicBowMinDrawSpeedUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ARROW_SPEED.index) { + return BalanceConfigHandler.draconicBowMinArrowSpeedUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ARROW_DAMAGE.index) { + return BalanceConfigHandler.draconicBowMinArrowDamageUpgradePoints; + } + return 0; + } - @Override - public List getUpgradeStats(ItemStack stack) { - BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, null); - List list = new ArrayList(); - list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.RFCapacity.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getMaxEnergyStored(stack))); - list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.max.txt") + " " + StatCollector.translateToLocal("gui.de.ArrowSpeed.txt") + ": " + InfoHelper.HITC() + "+"+EnumUpgrade.ARROW_SPEED.getUpgradePoints(stack)*100+"%"); - list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.max.txt") + " " + StatCollector.translateToLocal("gui.de.ArrowDamage.txt") + ": " + InfoHelper.HITC() + EnumUpgrade.ARROW_DAMAGE.getUpgradePoints(stack) + ""); - list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.DrawSpeed.txt") + ": " + InfoHelper.HITC() + properties.getDrawTicks()/20D + "s"); + @Override + public List getUpgradeStats(ItemStack stack) { + BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, null); + List list = new ArrayList(); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.RFCapacity.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getMaxEnergyStored(stack))); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.max.txt") + " " + StatCollector.translateToLocal("gui.de.ArrowSpeed.txt") + ": " + InfoHelper.HITC() + "+" + EnumUpgrade.ARROW_SPEED.getUpgradePoints(stack) * 100 + "%"); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.max.txt") + " " + StatCollector.translateToLocal("gui.de.ArrowDamage.txt") + ": " + InfoHelper.HITC() + EnumUpgrade.ARROW_DAMAGE.getUpgradePoints(stack) + ""); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.DrawSpeed.txt") + ": " + InfoHelper.HITC() + properties.getDrawTicks() / 20D + "s"); - return list; - } + return list; + } - @Override - public boolean hasProfiles() { - return true; - } + @Override + public boolean hasProfiles() { + return true; + } - @Override - public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - int energy = ItemNBTHelper.getInteger(container, "Energy", 0); - int energyReceived = Math.min(getMaxEnergyStored(container) - energy, Math.min(this.maxReceive, maxReceive)); + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + return 0; + } + int energy = ItemNBTHelper.getInteger(container, "Energy", 0); + int energyReceived = Math.min(getMaxEnergyStored(container) - energy, Math.min(this.maxReceive, maxReceive)); - if (!simulate) { - energy += energyReceived; - ItemNBTHelper.setInteger(container, "Energy", energy); - } - return energyReceived; - } + if (!simulate) { + energy += energyReceived; + ItemNBTHelper.setInteger(container, "Energy", energy); + } + return energyReceived; + } - @Override - public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - int energy = ItemNBTHelper.getInteger(container, "Energy", 0); - int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + return 0; + } + int energy = ItemNBTHelper.getInteger(container, "Energy", 0); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - if (!simulate) { - energy -= energyExtracted; - ItemNBTHelper.setInteger(container, "Energy", energy); - } - return energyExtracted; - } + if (!simulate) { + energy -= energyExtracted; + ItemNBTHelper.setInteger(container, "Energy", energy); + } + return energyExtracted; + } - @Override - public int getEnergyStored(ItemStack container) { - return ItemNBTHelper.getInteger(container, "Energy", 0); - } + @Override + public int getEnergyStored(ItemStack container) { + return ItemNBTHelper.getInteger(container, "Energy", 0); + } - @Override - public int getMaxEnergyStored(ItemStack stack) { - int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); - return BalanceConfigHandler.draconicWeaponsBaseStorage + points * BalanceConfigHandler.draconicWeaponsStoragePerUpgrade; - } + @Override + public int getMaxEnergyStored(ItemStack stack) { + int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); + return BalanceConfigHandler.draconicWeaponsBaseStorage + points * BalanceConfigHandler.draconicWeaponsStoragePerUpgrade; + } - @Override - public List getDisplayData(ItemStack stack) { - List list = new ArrayList(); + @Override + public List getDisplayData(ItemStack stack) { + List list = new ArrayList(); - if (BrandonsCore.proxy.getClientPlayer() != null && BrandonsCore.proxy.getClientPlayer().getItemInUse() != null && BrandonsCore.proxy.getClientPlayer().getItemInUseDuration() > 2){ - EntityPlayer player = BrandonsCore.proxy.getClientPlayer(); - BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, player); - int power = (int)Math.min(((float) player.getItemInUseDuration() / (float)properties.getDrawTicks() * 100F), 100F); - list.add(InfoHelper.ITC()+StatCollector.translateToLocal("info.de.power.txt")+": "+InfoHelper.HITC()+power+"%"); - } - else { - int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); - list.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("info.de.capacitorMode.txt") + ": " + ItemNBTHelper.getString(stack, "ProfileName" + preset, "Profile " + preset)); + if (BrandonsCore.proxy.getClientPlayer() != null && BrandonsCore.proxy.getClientPlayer().getItemInUse() != null && BrandonsCore.proxy.getClientPlayer().getItemInUseDuration() > 2) { + EntityPlayer player = BrandonsCore.proxy.getClientPlayer(); + BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, player); + int power = (int) Math.min(((float) player.getItemInUseDuration() / (float) properties.getDrawTicks() * 100F), 100F); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.power.txt") + ": " + InfoHelper.HITC() + power + "%"); + } else { + int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); + list.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("info.de.capacitorMode.txt") + ": " + ItemNBTHelper.getString(stack, "ProfileName" + preset, "Profile " + preset)); - for (ItemConfigField field : getFields(stack, 0)) { - if ((field.datatype == References.FLOAT_ID && (Float)field.value > 0) || (field.datatype == References.BOOLEAN_ID && (Boolean)field.value)) list.add(field.getTooltipInfo()); - } + for (ItemConfigField field : getFields(stack, 0)) { + if ((field.datatype == References.FLOAT_ID && (Float) field.value > 0) || (field.datatype == References.BOOLEAN_ID && (Boolean) field.value)) + list.add(field.getTooltipInfo()); + } - list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getEnergyStored(stack)) + " / " + Utills.formatNumber(getMaxEnergyStored(stack))); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getEnergyStored(stack)) + " / " + Utills.formatNumber(getMaxEnergyStored(stack))); - if (BrandonsCore.proxy.getClientPlayer() != null) { - BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, BrandonsCore.proxy.getClientPlayer()); - list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.rfPerShot.txt") + ": " + InfoHelper.HITC() + Utills.addCommas(properties.calculateEnergyCost())); - if (!properties.canFire() && properties.cantFireMessage != null) list.add(EnumChatFormatting.DARK_RED+StatCollector.translateToLocal(properties.cantFireMessage)); - } - } - return list; - } - @Override - public int getEnergyPerAttack() - { - return BalanceConfigHandler.draconicBowEnergyPerShot; - } + if (BrandonsCore.proxy.getClientPlayer() != null) { + BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, BrandonsCore.proxy.getClientPlayer()); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.rfPerShot.txt") + ": " + InfoHelper.HITC() + Utills.addCommas(properties.calculateEnergyCost())); + if (!properties.canFire() && properties.cantFireMessage != null) + list.add(EnumChatFormatting.DARK_RED + StatCollector.translateToLocal(properties.cantFireMessage)); + } + } + return list; + } - //endregion + @Override + public int getEnergyPerAttack() { + return BalanceConfigHandler.draconicBowEnergyPerShot; + } + + //endregion } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicSword.java b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicSword.java index 94a8e9cd..f82a6a70 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicSword.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicSword.java @@ -40,291 +40,282 @@ import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; public class DraconicSword extends ItemSword implements IEnergyContainerWeaponItem, IInventoryTool, IRenderTweak, IUpgradableItem, IHudDisplayItem { - protected int capacity = BalanceConfigHandler.draconicWeaponsBaseStorage; - protected int maxReceive = BalanceConfigHandler.draconicWeaponsMaxTransfer; - protected int maxExtract = BalanceConfigHandler.draconicWeaponsMaxTransfer; + protected int capacity = BalanceConfigHandler.draconicWeaponsBaseStorage; + protected int maxReceive = BalanceConfigHandler.draconicWeaponsMaxTransfer; + protected int maxExtract = BalanceConfigHandler.draconicWeaponsMaxTransfer; - public DraconicSword() { - super(ModItems.AWAKENED); - this.setUnlocalizedName(Strings.draconicSwordName); - this.setCreativeTab(DraconicEvolution.tabToolsWeapons); - if (ModItems.isEnabled(this)) GameRegistry.registerItem(this, Strings.draconicSwordName); - } + public DraconicSword() { + super(ModItems.AWAKENED); + this.setUnlocalizedName(Strings.draconicSwordName); + this.setCreativeTab(DraconicEvolution.tabToolsWeapons); + if (ModItems.isEnabled(this)) GameRegistry.registerItem(this, Strings.draconicSwordName); + } - @Override - public boolean isItemTool(ItemStack p_77616_1_) { - return true; - } + @Override + public boolean isItemTool(ItemStack p_77616_1_) { + return true; + } - @SuppressWarnings("all") - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", 0)); - list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", capacity)); - } + @SuppressWarnings("all") + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", 0)); + list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", capacity)); + } - @Override - public String getUnlocalizedName(){ + @Override + public String getUnlocalizedName() { - return String.format("item.%s%s", References.MODID.toLowerCase() + ":", super.getUnlocalizedName().substring(super.getUnlocalizedName().indexOf(".") + 1)); - } + return String.format("item.%s%s", References.MODID.toLowerCase() + ":", super.getUnlocalizedName().substring(super.getUnlocalizedName().indexOf(".") + 1)); + } - @Override - public String getUnlocalizedName(final ItemStack itemStack){ - return getUnlocalizedName(); - } + @Override + public String getUnlocalizedName(final ItemStack itemStack) { + return getUnlocalizedName(); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(final IIconRegister iconRegister) - { - this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_sword"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister iconRegister) { + this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_sword"); + } - @Override - public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) - { + @Override + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { entity.hurtResistantTime = 0; - ToolHandler.AOEAttack(player, entity, stack, IConfigurableItem.ProfileHelper.getInteger(stack, References.ATTACK_AOE, 0)); - ToolHandler.damageEntityBasedOnHealth(entity, player, 0.2F); - return true; - } + ToolHandler.AOEAttack(player, entity, stack, IConfigurableItem.ProfileHelper.getInteger(stack, References.ATTACK_AOE, 0)); + ToolHandler.damageEntityBasedOnHealth(entity, player, 0.2F); + return true; + } - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) - { - if (InfoHelper.holdShiftForDetails(list)) { - List l = getFields(stack, 0); - for (ItemConfigField f : l) list.add(f.getTooltipInfo()); - list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.sword.txt")); - InfoHelper.addLore(stack, list); - } - ToolBase.holdCTRLForUpgrades(list, stack); - InfoHelper.addEnergyInfo(stack, list); - list.add(""); - list.add(EnumChatFormatting.BLUE + "+" + ToolHandler.getBaseAttackDamage(stack) + " " + StatCollector.translateToLocal("info.de.attackDamage.txt")); - list.add(EnumChatFormatting.BLUE + "+20%" + " " + StatCollector.translateToLocal("info.de.bonusHealthDamage.txt")); - } + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) { + if (InfoHelper.holdShiftForDetails(list)) { + List l = getFields(stack, 0); + for (ItemConfigField f : l) list.add(f.getTooltipInfo()); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.sword.txt")); + InfoHelper.addLore(stack, list); + } + ToolBase.holdCTRLForUpgrades(list, stack); + InfoHelper.addEnergyInfo(stack, list); + list.add(""); + list.add(EnumChatFormatting.BLUE + "+" + ToolHandler.getBaseAttackDamage(stack) + " " + StatCollector.translateToLocal("info.de.attackDamage.txt")); + list.add(EnumChatFormatting.BLUE + "+20%" + " " + StatCollector.translateToLocal("info.de.bonusHealthDamage.txt")); + } - @Override - public EnumRarity getRarity(ItemStack stack) - { - return EnumRarity.rare; - } + @Override + public EnumRarity getRarity(ItemStack stack) { + return EnumRarity.rare; + } - @Override - public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { - if (container.stackTagCompound == null) { - container.stackTagCompound = new NBTTagCompound(); - } - int energy = container.stackTagCompound.getInteger("Energy"); - int energyReceived = Math.min(getMaxEnergyStored(container) - energy, Math.min(this.maxReceive, maxReceive)); + if (container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyReceived = Math.min(getMaxEnergyStored(container) - energy, Math.min(this.maxReceive, maxReceive)); - if (!simulate) { - energy += energyReceived; - container.stackTagCompound.setInteger("Energy", energy); - } - return energyReceived; - } + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("Energy", energy); + } + return energyReceived; + } - @Override - public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - int energy = container.stackTagCompound.getInteger("Energy"); - int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + return 0; + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - if (!simulate) { - energy -= energyExtracted; - container.stackTagCompound.setInteger("Energy", energy); - } - return energyExtracted; - } + if (!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("Energy", energy); + } + return energyExtracted; + } - @Override - public int getEnergyStored(ItemStack container) { - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - return container.stackTagCompound.getInteger("Energy"); - } + @Override + public int getEnergyStored(ItemStack container) { + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + return 0; + } + return container.stackTagCompound.getInteger("Energy"); + } - @Override - public int getMaxEnergyStored(ItemStack container) { - int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(container); - return BalanceConfigHandler.draconicWeaponsBaseStorage + points * BalanceConfigHandler.draconicWeaponsStoragePerUpgrade; - } + @Override + public int getMaxEnergyStored(ItemStack container) { + int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(container); + return BalanceConfigHandler.draconicWeaponsBaseStorage + points * BalanceConfigHandler.draconicWeaponsStoragePerUpgrade; + } - @Override - public boolean showDurabilityBar(ItemStack stack) { - return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); - } + @Override + public boolean showDurabilityBar(ItemStack stack) { + return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); + } - @Override - public double getDurabilityForDisplay(ItemStack stack) { - return 1D - ((double)getEnergyStored(stack) / (double)getMaxEnergyStored(stack)); - } + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - ((double) getEnergyStored(stack) / (double) getMaxEnergyStored(stack)); + } - @Override - public boolean hasCustomEntity(ItemStack stack) { - return true; - } + @Override + public boolean hasCustomEntity(ItemStack stack) { + return true; + } - @Override - public Entity createEntity(World world, Entity location, ItemStack itemstack) { - return new EntityPersistentItem(world, location, itemstack); - } + @Override + public Entity createEntity(World world, Entity location, ItemStack itemstack) { + return new EntityPersistentItem(world, location, itemstack); + } - @Override - public String getInventoryName() { - return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); - } + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); + } - @Override - public int getInventorySlots() { - return 0; - } + @Override + public int getInventorySlots() { + return 0; + } - @Override - public boolean isEnchantValid(Enchantment enchant) { - return enchant.type == EnumEnchantmentType.weapon; - } + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.weapon; + } - @Override - public List getFields(ItemStack stack, int slot) { - List list = new ArrayList(); - list.add(new ItemConfigField(References.INT_ID, slot, References.ATTACK_AOE).setMinMaxAndIncromente(0, EnumUpgrade.ATTACK_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 1).setModifier("AOE")); - return list; - } + @Override + public List getFields(ItemStack stack, int slot) { + List list = new ArrayList(); + list.add(new ItemConfigField(References.INT_ID, slot, References.ATTACK_AOE).setMinMaxAndIncromente(0, EnumUpgrade.ATTACK_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 1).setModifier("AOE")); + return list; + } - @Override - public Multimap getAttributeModifiers(ItemStack stack) { - Multimap map = super.getAttributeModifiers(stack); - map.clear(); - return map; - } + @Override + public Multimap getAttributeModifiers(ItemStack stack) { + Multimap map = super.getAttributeModifiers(stack); + map.clear(); + return map; + } - @Override - public void tweakRender(IItemRenderer.ItemRenderType type) { + @Override + public void tweakRender(IItemRenderer.ItemRenderType type) { - GL11.glTranslated(-0.01, 1.11, -0.15); - GL11.glRotatef(90, 1, 0, 0); - GL11.glRotatef(140, 0, -1, 0); - GL11.glScaled(0.7, 0.7, 0.7); + GL11.glTranslated(-0.01, 1.11, -0.15); + GL11.glRotatef(90, 1, 0, 0); + GL11.glRotatef(140, 0, -1, 0); + GL11.glScaled(0.7, 0.7, 0.7); - if (type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) { - GL11.glRotatef(180, 0, 0, 1); - GL11.glTranslated(0, -0.4, 0); - } - else if (type == IItemRenderer.ItemRenderType.INVENTORY){ - GL11.glScalef(8, 8, 8); - GL11.glRotatef(180, 0, 1, 0); - GL11.glTranslated(1.9, 0, 0); - } - else if (type == IItemRenderer.ItemRenderType.ENTITY){ - GL11.glRotatef(-90.5F, 0, 1, 0); - GL11.glTranslated(-0.8, 0, 0); - } - } + if (type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glRotatef(180, 0, 0, 1); + GL11.glTranslated(0, -0.4, 0); + } else if (type == IItemRenderer.ItemRenderType.INVENTORY) { + GL11.glScalef(8, 8, 8); + GL11.glRotatef(180, 0, 1, 0); + GL11.glTranslated(1.9, 0, 0); + } else if (type == IItemRenderer.ItemRenderType.ENTITY) { + GL11.glRotatef(-90.5F, 0, 1, 0); + GL11.glTranslated(-0.8, 0, 0); + } + } - @Override - public List getUpgrades(ItemStack itemstack) { - return new ArrayList(){{ - add(EnumUpgrade.RF_CAPACITY); - add(EnumUpgrade.ATTACK_AOE); - add(EnumUpgrade.ATTACK_DAMAGE); - }}; - } + @Override + public List getUpgrades(ItemStack itemstack) { + return new ArrayList() {{ + add(EnumUpgrade.RF_CAPACITY); + add(EnumUpgrade.ATTACK_AOE); + add(EnumUpgrade.ATTACK_DAMAGE); + }}; + } - @Override - public int getUpgradeCap(ItemStack itemstack) { - return BalanceConfigHandler.draconicWeaponsMaxUpgrades; - } + @Override + public int getUpgradeCap(ItemStack itemstack) { + return BalanceConfigHandler.draconicWeaponsMaxUpgrades; + } - @Override - public int getMaxTier(ItemStack itemstack) { - return 2; - } + @Override + public int getMaxTier(ItemStack itemstack) { + return 2; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { - return BalanceConfigHandler.draconicWeaponsMaxCapacityUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ATTACK_AOE.index) { - return BalanceConfigHandler.draconicWeaponsMaxAttackAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ATTACK_DAMAGE.index) { - return BalanceConfigHandler.draconicWeaponsMaxAttackDamageUpgradePoints; - } - return BalanceConfigHandler.draconicWeaponsMaxUpgradePoints; - } + @Override + public int getMaxUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { + return BalanceConfigHandler.draconicWeaponsMaxCapacityUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ATTACK_AOE.index) { + return BalanceConfigHandler.draconicWeaponsMaxAttackAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ATTACK_DAMAGE.index) { + return BalanceConfigHandler.draconicWeaponsMaxAttackDamageUpgradePoints; + } + return BalanceConfigHandler.draconicWeaponsMaxUpgradePoints; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) - { - return getMaxUpgradePoints(upgradeIndex); - } + @Override + public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) { + return getMaxUpgradePoints(upgradeIndex); + } - @Override - public int getBaseUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.ATTACK_AOE.index) { - return BalanceConfigHandler.draconicWeaponsMinAttackAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ARROW_DAMAGE.index) - { - return BalanceConfigHandler.draconicWeaponsMinAttackDamageUpgradePoints; - } - return 0; - } + @Override + public int getBaseUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.ATTACK_AOE.index) { + return BalanceConfigHandler.draconicWeaponsMinAttackAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ARROW_DAMAGE.index) { + return BalanceConfigHandler.draconicWeaponsMinAttackDamageUpgradePoints; + } + return 0; + } - @Override - public List getUpgradeStats(ItemStack stack) { - List strings = new ArrayList(); + @Override + public List getUpgradeStats(ItemStack stack) { + List strings = new ArrayList(); - int attackaoe = 0; - for (ItemConfigField field : getFields(stack, 0)) if (field.name.equals(References.ATTACK_AOE)) attackaoe = 1 + ((Integer) field.max * 2); + int attackaoe = 0; + for (ItemConfigField field : getFields(stack, 0)) + if (field.name.equals(References.ATTACK_AOE)) attackaoe = 1 + ((Integer) field.max * 2); - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.RFCapacity.txt")+": "+InfoHelper.HITC()+Utills.formatNumber(getMaxEnergyStored(stack))); - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("info.de.attackDamage.txt")+": "+ InfoHelper.HITC()+ToolHandler.getBaseAttackDamage(stack)); - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.max.txt")+" "+StatCollector.translateToLocal("gui.de.AttackAOE.txt")+": "+InfoHelper.HITC()+attackaoe+"x"+attackaoe); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.RFCapacity.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getMaxEnergyStored(stack))); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.attackDamage.txt") + ": " + InfoHelper.HITC() + ToolHandler.getBaseAttackDamage(stack)); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.max.txt") + " " + StatCollector.translateToLocal("gui.de.AttackAOE.txt") + ": " + InfoHelper.HITC() + attackaoe + "x" + attackaoe); - return strings; - } + return strings; + } - @Override - public List getDisplayData(ItemStack stack) { - List list = new ArrayList(); - for (ItemConfigField field : getFields(stack, 0)) list.add(field.getTooltipInfo());//list.add(field.getLocalizedName() + ": " + field.getFormattedValue()); - return list; - } + @Override + public List getDisplayData(ItemStack stack) { + List list = new ArrayList(); + for (ItemConfigField field : getFields(stack, 0)) + list.add(field.getTooltipInfo());//list.add(field.getLocalizedName() + ": " + field.getFormattedValue()); + return list; + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (!world.isRemote && !BrandonsCore.proxy.isDedicatedServer()) - { - ToolBase.handleModeChange(stack, player, InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown()); - } - else if (world.isRemote && BrandonsCore.proxy.getMCServer() == null) - { - ToolBase.handleModeChange(stack, player, InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown()); - DraconicEvolution.network.sendToServer(new ToolModePacket(InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown())); - } - return super.onItemRightClick(stack, world, player); - } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (!world.isRemote && !BrandonsCore.proxy.isDedicatedServer()) { + ToolBase.handleModeChange(stack, player, InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown()); + } else if (world.isRemote && BrandonsCore.proxy.getMCServer() == null) { + ToolBase.handleModeChange(stack, player, InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown()); + DraconicEvolution.network.sendToServer(new ToolModePacket(InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown())); + } + return super.onItemRightClick(stack, world, player); + } - @Override - public boolean hasProfiles() { - return true; - } - @Override - public int getEnergyPerAttack() - { - return BalanceConfigHandler.draconicWeaponsEnergyPerAttack; - } + @Override + public boolean hasProfiles() { + return true; + } + + @Override + public int getEnergyPerAttack() { + return BalanceConfigHandler.draconicWeaponsEnergyPerAttack; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/IEnergyContainerWeaponItem.java b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/IEnergyContainerWeaponItem.java index 562c59b7..f65de351 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/IEnergyContainerWeaponItem.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/IEnergyContainerWeaponItem.java @@ -2,7 +2,6 @@ package com.brandon3055.draconicevolution.common.items.weapons; import cofh.api.energy.IEnergyContainerItem; -public interface IEnergyContainerWeaponItem extends IEnergyContainerItem -{ +public interface IEnergyContainerWeaponItem extends IEnergyContainerItem { int getEnergyPerAttack(); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernBow.java b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernBow.java index c127f821..2758b838 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernBow.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernBow.java @@ -38,332 +38,325 @@ import net.minecraft.world.World; public class WyvernBow extends ItemBow implements IInventoryTool, IUpgradableItem, IEnergyContainerWeaponItem, IHudDisplayItem { - public static final String[] bowPullIconNameArray = new String[] { "pulling_0", "pulling_1", "pulling_2" }; + public static final String[] bowPullIconNameArray = new String[]{"pulling_0", "pulling_1", "pulling_2"}; - protected int capacity = BalanceConfigHandler.wyvernWeaponsBaseStorage; - protected int maxReceive = BalanceConfigHandler.wyvernWeaponsMaxTransfer; - protected int maxExtract = BalanceConfigHandler.wyvernWeaponsMaxTransfer; - @SideOnly(Side.CLIENT) - private IIcon[] iconArray; + protected int capacity = BalanceConfigHandler.wyvernWeaponsBaseStorage; + protected int maxReceive = BalanceConfigHandler.wyvernWeaponsMaxTransfer; + protected int maxExtract = BalanceConfigHandler.wyvernWeaponsMaxTransfer; + @SideOnly(Side.CLIENT) + private IIcon[] iconArray; - public WyvernBow() { - this.maxStackSize = 1; - this.setMaxDamage(-1); - this.setCreativeTab(DraconicEvolution.tabToolsWeapons); - this.setUnlocalizedName(Strings.wyvernBowName); - if (ModItems.isEnabled(this)) GameRegistry.registerItem(this, Strings.wyvernBowName); - } + public WyvernBow() { + this.maxStackSize = 1; + this.setMaxDamage(-1); + this.setCreativeTab(DraconicEvolution.tabToolsWeapons); + this.setUnlocalizedName(Strings.wyvernBowName); + if (ModItems.isEnabled(this)) GameRegistry.registerItem(this, Strings.wyvernBowName); + } - //region Regular Item Stuff - @Override - public boolean isItemTool(ItemStack p_77616_1_) { - return true; - } + //region Regular Item Stuff + @Override + public boolean isItemTool(ItemStack p_77616_1_) { + return true; + } - @Override - public String getUnlocalizedName(){ + @Override + public String getUnlocalizedName() { - return String.format("item.%s%s", References.MODID.toLowerCase() + ":", super.getUnlocalizedName().substring(super.getUnlocalizedName().indexOf(".") + 1)); - } + return String.format("item.%s%s", References.MODID.toLowerCase() + ":", super.getUnlocalizedName().substring(super.getUnlocalizedName().indexOf(".") + 1)); + } - @Override - public String getUnlocalizedName(final ItemStack itemStack){ - return getUnlocalizedName(); - } + @Override + public String getUnlocalizedName(final ItemStack itemStack) { + return getUnlocalizedName(); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister iconRegister) - { - this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_bow" + "_standby"); - this.iconArray = new IIcon[bowPullIconNameArray.length]; + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_bow" + "_standby"); + this.iconArray = new IIcon[bowPullIconNameArray.length]; - for (int i = 0; i < this.iconArray.length; ++i) { - this.iconArray[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_bow" + "_" + bowPullIconNameArray[i]); - } - } + for (int i = 0; i < this.iconArray.length; ++i) { + this.iconArray[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_bow" + "_" + bowPullIconNameArray[i]); + } + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) - { - float j = (float)stack.getMaxItemUseDuration() - (float)useRemaining; - if (usingItem == null) { - return this.itemIcon; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + float j = (float) stack.getMaxItemUseDuration() - (float) useRemaining; + if (usingItem == null) { + return this.itemIcon; + } - BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, player); + BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, player); - if (j > properties.getDrawTicks()) j = properties.getDrawTicks(); + if (j > properties.getDrawTicks()) j = properties.getDrawTicks(); - j /= (float)properties.getDrawTicks(); - int j2 = (int)(j * 2F); + j /= (float) properties.getDrawTicks(); + int j2 = (int) (j * 2F); - if (j2 < 0) j2 = 0; - else if (j2 > 2) j2 = 2; + if (j2 < 0) j2 = 0; + else if (j2 > 2) j2 = 2; - return getItemIconForUseDuration(j2); - } + return getItemIconForUseDuration(j2); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getItemIconForUseDuration(int par1) - { - return this.iconArray[par1]; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getItemIconForUseDuration(int par1) { + return this.iconArray[par1]; + } - @Override - public boolean hasCustomEntity(ItemStack stack) { - return true; - } + @Override + public boolean hasCustomEntity(ItemStack stack) { + return true; + } - @Override - public Entity createEntity(World world, Entity location, ItemStack itemstack) { - return new EntityPersistentItem(world, location, itemstack); - } + @Override + public Entity createEntity(World world, Entity location, ItemStack itemstack) { + return new EntityPersistentItem(world, location, itemstack); + } - @Override - @SideOnly(Side.CLIENT) - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) - { - boolean show = InfoHelper.holdShiftForDetails(list); - if (show){ - int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); - list.add(EnumChatFormatting.DARK_PURPLE+StatCollector.translateToLocal("info.de.capacitorMode.txt")+": "+ItemNBTHelper.getString(stack, "ProfileName"+preset, "Profile "+preset)); - List l = getFields(stack, 0); - for (ItemConfigField f : l) list.add(f.getTooltipInfo()); - } - ToolBase.holdCTRLForUpgrades(list, stack); - InfoHelper.addEnergyInfo(stack, list); - if (show && !ConfigHandler.disableLore) InfoHelper.addLore(stack, list, true); - } + @Override + @SideOnly(Side.CLIENT) + @SuppressWarnings({"unchecked", "rawtypes"}) + public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) { + boolean show = InfoHelper.holdShiftForDetails(list); + if (show) { + int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); + list.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("info.de.capacitorMode.txt") + ": " + ItemNBTHelper.getString(stack, "ProfileName" + preset, "Profile " + preset)); + List l = getFields(stack, 0); + for (ItemConfigField f : l) list.add(f.getTooltipInfo()); + } + ToolBase.holdCTRLForUpgrades(list, stack); + InfoHelper.addEnergyInfo(stack, list); + if (show && !ConfigHandler.disableLore) InfoHelper.addLore(stack, list, true); + } - @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", 0)); - list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", capacity)); - } + @SideOnly(Side.CLIENT) + @SuppressWarnings("unchecked") + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", 0)); + list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", capacity)); + } - @Override - public boolean getHasSubtypes() { - return true; - } + @Override + public boolean getHasSubtypes() { + return true; + } - @Override - public boolean showDurabilityBar(ItemStack stack) { - return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); - } + @Override + public boolean showDurabilityBar(ItemStack stack) { + return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); + } - @Override - public double getDurabilityForDisplay(ItemStack stack) { - return 1D - ((double) getEnergyStored(stack) / (double) getMaxEnergyStored(stack)); - } - //endregion + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - ((double) getEnergyStored(stack) / (double) getMaxEnergyStored(stack)); + } + //endregion - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) - { - return BowHandler.onBowRightClick(this, stack, world, player); - } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + return BowHandler.onBowRightClick(this, stack, world, player); + } - @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) - { - BowHandler.onBowUsingTick(stack, player, count); - } + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + BowHandler.onBowUsingTick(stack, player, count); + } - @Override - public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int count) - { - BowHandler.onPlayerStoppedUsingBow(stack, world, player, count); - } + @Override + public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int count) { + BowHandler.onPlayerStoppedUsingBow(stack, world, player, count); + } - //region Interfaces - @Override - public String getInventoryName() { - return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); - } + //region Interfaces + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); + } - @Override - public int getInventorySlots() { - return 0; - } + @Override + public int getInventorySlots() { + return 0; + } - @Override - public boolean isEnchantValid(Enchantment enchant) { - return enchant.type == EnumEnchantmentType.bow || enchant.effectId == DraconicEvolution.reaperEnchant.effectId; - } + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.bow || enchant.effectId == DraconicEvolution.reaperEnchant.effectId; + } - @Override - public List getFields(ItemStack stack, int slot) { - List list = new ArrayList(); + @Override + public List getFields(ItemStack stack, int slot) { + List list = new ArrayList(); - list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowArrowDamage").setMinMaxAndIncromente((float)getBaseUpgradePoints(EnumUpgrade.ARROW_DAMAGE.index), (float)EnumUpgrade.ARROW_DAMAGE.getUpgradePoints(stack), 0.1F).readFromItem(stack, (float)EnumUpgrade.ARROW_DAMAGE.getUpgradePoints(stack))); - list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowArrowSpeedModifier").setMinMaxAndIncromente(0F, (float)EnumUpgrade.ARROW_SPEED.getUpgradePoints(stack), 0.01F).readFromItem(stack, 0F).setModifier("PLUSPERCENT")); - list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "BowAutoFire").readFromItem(stack, false)); - list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowExplosionPower").setMinMaxAndIncromente(0F, 4F, 0.1F).readFromItem(stack, 0F)); - // list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowShockWavePower").setMinMaxAndIncromente(0F, 4F, 0.1F).readFromItem(stack, 0F)); - // list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "BowEnergyBolt").readFromItem(stack, false)); - list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowZoomModifier").setMinMaxAndIncromente(0F, 3F, 0.01F).readFromItem(stack, 0F).setModifier("PLUSPERCENT")); + list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowArrowDamage").setMinMaxAndIncromente((float) getBaseUpgradePoints(EnumUpgrade.ARROW_DAMAGE.index), (float) EnumUpgrade.ARROW_DAMAGE.getUpgradePoints(stack), 0.1F).readFromItem(stack, (float) EnumUpgrade.ARROW_DAMAGE.getUpgradePoints(stack))); + list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowArrowSpeedModifier").setMinMaxAndIncromente(0F, (float) EnumUpgrade.ARROW_SPEED.getUpgradePoints(stack), 0.01F).readFromItem(stack, 0F).setModifier("PLUSPERCENT")); + list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "BowAutoFire").readFromItem(stack, false)); + list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowExplosionPower").setMinMaxAndIncromente(0F, 4F, 0.1F).readFromItem(stack, 0F)); + // list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowShockWavePower").setMinMaxAndIncromente(0F, 4F, 0.1F).readFromItem(stack, 0F)); + // list.add(new ItemConfigField(References.BOOLEAN_ID, slot, "BowEnergyBolt").readFromItem(stack, false)); + list.add(new ItemConfigField(References.FLOAT_ID, slot, "BowZoomModifier").setMinMaxAndIncromente(0F, 3F, 0.01F).readFromItem(stack, 0F).setModifier("PLUSPERCENT")); - return list; - } + return list; + } - @Override - public boolean hasProfiles() { - return true; - } + @Override + public boolean hasProfiles() { + return true; + } - @Override - public List getUpgrades(ItemStack itemstack) { - return new ArrayList() {{ - add(EnumUpgrade.RF_CAPACITY); - add(EnumUpgrade.DRAW_SPEED); - add(EnumUpgrade.ARROW_SPEED); - add(EnumUpgrade.ARROW_DAMAGE); - }}; - } + @Override + public List getUpgrades(ItemStack itemstack) { + return new ArrayList() {{ + add(EnumUpgrade.RF_CAPACITY); + add(EnumUpgrade.DRAW_SPEED); + add(EnumUpgrade.ARROW_SPEED); + add(EnumUpgrade.ARROW_DAMAGE); + }}; + } - @Override - public int getUpgradeCap(ItemStack itemstack) { - return BalanceConfigHandler.wyvernBowMaxUpgrades; - } + @Override + public int getUpgradeCap(ItemStack itemstack) { + return BalanceConfigHandler.wyvernBowMaxUpgrades; + } - @Override - public int getMaxTier(ItemStack itemstack) { - return 1; - } + @Override + public int getMaxTier(ItemStack itemstack) { + return 1; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { - return BalanceConfigHandler.wyvernBowMaxCapacityUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.DRAW_SPEED.index) { - return BalanceConfigHandler.wyvernBowMaxDrawSpeedUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ARROW_SPEED.index) { - return BalanceConfigHandler.wyvernBowMaxArrowSpeedUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ARROW_DAMAGE.index) { - return BalanceConfigHandler.wyvernBowMaxArrowDamageUpgradePoints; - } - return BalanceConfigHandler.wyvernBowMaxUpgradePoints; - } + @Override + public int getMaxUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { + return BalanceConfigHandler.wyvernBowMaxCapacityUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.DRAW_SPEED.index) { + return BalanceConfigHandler.wyvernBowMaxDrawSpeedUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ARROW_SPEED.index) { + return BalanceConfigHandler.wyvernBowMaxArrowSpeedUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ARROW_DAMAGE.index) { + return BalanceConfigHandler.wyvernBowMaxArrowDamageUpgradePoints; + } + return BalanceConfigHandler.wyvernBowMaxUpgradePoints; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) - { - return getMaxUpgradePoints(upgradeIndex); - } + @Override + public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) { + return getMaxUpgradePoints(upgradeIndex); + } - @Override - public int getBaseUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.DRAW_SPEED.index) { - return BalanceConfigHandler.wyvernBowMinDrawSpeedUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ARROW_SPEED.index) { - return BalanceConfigHandler.wyvernBowMinArrowSpeedUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ARROW_DAMAGE.index) { - return BalanceConfigHandler.wyvernBowMinArrowDamageUpgradePoints; - } - return 0; - } + @Override + public int getBaseUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.DRAW_SPEED.index) { + return BalanceConfigHandler.wyvernBowMinDrawSpeedUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ARROW_SPEED.index) { + return BalanceConfigHandler.wyvernBowMinArrowSpeedUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ARROW_DAMAGE.index) { + return BalanceConfigHandler.wyvernBowMinArrowDamageUpgradePoints; + } + return 0; + } - @Override - public List getUpgradeStats(ItemStack stack) { - BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, null); - List list = new ArrayList(); - list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.RFCapacity.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getMaxEnergyStored(stack))); - list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.max.txt") + " " + StatCollector.translateToLocal("gui.de.ArrowSpeed.txt") + ": " + InfoHelper.HITC() + "+"+EnumUpgrade.ARROW_SPEED.getUpgradePoints(stack)*100+"%"); - list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.ArrowDamage.txt") + ": " + InfoHelper.HITC() + properties.arrowDamage + ""); - list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.DrawSpeed.txt") + ": " + InfoHelper.HITC() + properties.getDrawTicks()/20D + "s"); + @Override + public List getUpgradeStats(ItemStack stack) { + BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, null); + List list = new ArrayList(); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.RFCapacity.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getMaxEnergyStored(stack))); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.max.txt") + " " + StatCollector.translateToLocal("gui.de.ArrowSpeed.txt") + ": " + InfoHelper.HITC() + "+" + EnumUpgrade.ARROW_SPEED.getUpgradePoints(stack) * 100 + "%"); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.ArrowDamage.txt") + ": " + InfoHelper.HITC() + properties.arrowDamage + ""); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.DrawSpeed.txt") + ": " + InfoHelper.HITC() + properties.getDrawTicks() / 20D + "s"); - return list; - } + return list; + } - @Override - public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - int energy = ItemNBTHelper.getInteger(container, "Energy", 0); - int energyReceived = Math.min(getMaxEnergyStored(container) - energy, Math.min(this.maxReceive, maxReceive)); + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + return 0; + } + int energy = ItemNBTHelper.getInteger(container, "Energy", 0); + int energyReceived = Math.min(getMaxEnergyStored(container) - energy, Math.min(this.maxReceive, maxReceive)); - if (!simulate) { - energy += energyReceived; - ItemNBTHelper.setInteger(container, "Energy", energy); - } - return energyReceived; - } + if (!simulate) { + energy += energyReceived; + ItemNBTHelper.setInteger(container, "Energy", energy); + } + return energyReceived; + } - @Override - public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - int energy = ItemNBTHelper.getInteger(container, "Energy", 0); - int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + return 0; + } + int energy = ItemNBTHelper.getInteger(container, "Energy", 0); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - if (!simulate) { - energy -= energyExtracted; - ItemNBTHelper.setInteger(container, "Energy", energy); - } - return energyExtracted; - } + if (!simulate) { + energy -= energyExtracted; + ItemNBTHelper.setInteger(container, "Energy", energy); + } + return energyExtracted; + } - @Override - public int getEnergyStored(ItemStack container) { - return ItemNBTHelper.getInteger(container, "Energy", 0); - } + @Override + public int getEnergyStored(ItemStack container) { + return ItemNBTHelper.getInteger(container, "Energy", 0); + } - @Override - public int getMaxEnergyStored(ItemStack stack) { - int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); - return BalanceConfigHandler.wyvernWeaponsBaseStorage + points * BalanceConfigHandler.wyvernWeaponsStoragePerUpgrade; - } + @Override + public int getMaxEnergyStored(ItemStack stack) { + int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(stack); + return BalanceConfigHandler.wyvernWeaponsBaseStorage + points * BalanceConfigHandler.wyvernWeaponsStoragePerUpgrade; + } - @Override - public List getDisplayData(ItemStack stack) { - List list = new ArrayList(); + @Override + public List getDisplayData(ItemStack stack) { + List list = new ArrayList(); - if (BrandonsCore.proxy.getClientPlayer() != null && BrandonsCore.proxy.getClientPlayer().getItemInUse() != null){ - EntityPlayer player = BrandonsCore.proxy.getClientPlayer(); - BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, player); - int power = (int)Math.min(((float) player.getItemInUseDuration() / (float)properties.getDrawTicks() * 100F), 100F); - list.add(InfoHelper.ITC()+StatCollector.translateToLocal("info.de.power.txt")+": "+InfoHelper.HITC()+power+"%"); - } - else { - int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); - list.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("info.de.capacitorMode.txt") + ": " + ItemNBTHelper.getString(stack, "ProfileName" + preset, "Profile " + preset)); + if (BrandonsCore.proxy.getClientPlayer() != null && BrandonsCore.proxy.getClientPlayer().getItemInUse() != null) { + EntityPlayer player = BrandonsCore.proxy.getClientPlayer(); + BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, player); + int power = (int) Math.min(((float) player.getItemInUseDuration() / (float) properties.getDrawTicks() * 100F), 100F); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.power.txt") + ": " + InfoHelper.HITC() + power + "%"); + } else { + int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); + list.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("info.de.capacitorMode.txt") + ": " + ItemNBTHelper.getString(stack, "ProfileName" + preset, "Profile " + preset)); - for (ItemConfigField field : getFields(stack, 0)) { - if ((field.datatype == References.FLOAT_ID && (Float)field.value > 0) || (field.datatype == References.BOOLEAN_ID && (Boolean)field.value)) list.add(field.getTooltipInfo()); - } + for (ItemConfigField field : getFields(stack, 0)) { + if ((field.datatype == References.FLOAT_ID && (Float) field.value > 0) || (field.datatype == References.BOOLEAN_ID && (Boolean) field.value)) + list.add(field.getTooltipInfo()); + } - list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getEnergyStored(stack)) + " / " + Utills.formatNumber(getMaxEnergyStored(stack))); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getEnergyStored(stack)) + " / " + Utills.formatNumber(getMaxEnergyStored(stack))); - if (BrandonsCore.proxy.getClientPlayer() != null) { - BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, BrandonsCore.proxy.getClientPlayer()); - list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.rfPerShot.txt") + ": " + InfoHelper.HITC() + Utills.addCommas(properties.calculateEnergyCost())); - if (!properties.canFire() && properties.cantFireMessage != null) list.add(EnumChatFormatting.DARK_RED+StatCollector.translateToLocal(properties.cantFireMessage)); - } + if (BrandonsCore.proxy.getClientPlayer() != null) { + BowHandler.BowProperties properties = new BowHandler.BowProperties(stack, BrandonsCore.proxy.getClientPlayer()); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.rfPerShot.txt") + ": " + InfoHelper.HITC() + Utills.addCommas(properties.calculateEnergyCost())); + if (!properties.canFire() && properties.cantFireMessage != null) + list.add(EnumChatFormatting.DARK_RED + StatCollector.translateToLocal(properties.cantFireMessage)); + } - } - return list; - } - @Override - public int getEnergyPerAttack() - { - return BalanceConfigHandler.wyvernBowEnergyPerShot; - } - //endregion + } + return list; + } + + @Override + public int getEnergyPerAttack() { + return BalanceConfigHandler.wyvernBowEnergyPerShot; + } + //endregion } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernSword.java b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernSword.java index 7611b6d3..44003a06 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernSword.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernSword.java @@ -40,297 +40,288 @@ import net.minecraft.world.World; import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; -public class WyvernSword extends ItemSword implements IEnergyContainerWeaponItem, IInventoryTool, IRenderTweak, IUpgradableItem, IHudDisplayItem{ +public class WyvernSword extends ItemSword implements IEnergyContainerWeaponItem, IInventoryTool, IRenderTweak, IUpgradableItem, IHudDisplayItem { - protected int capacity = BalanceConfigHandler.wyvernWeaponsBaseStorage; - protected int maxReceive = BalanceConfigHandler.wyvernWeaponsMaxTransfer; - protected int maxExtract = BalanceConfigHandler.wyvernWeaponsMaxTransfer; + protected int capacity = BalanceConfigHandler.wyvernWeaponsBaseStorage; + protected int maxReceive = BalanceConfigHandler.wyvernWeaponsMaxTransfer; + protected int maxExtract = BalanceConfigHandler.wyvernWeaponsMaxTransfer; - public WyvernSword() { - super(ModItems.WYVERN); - this.setUnlocalizedName(Strings.wyvernSwordName); - this.setCreativeTab(DraconicEvolution.tabToolsWeapons); - if (ModItems.isEnabled(this)) GameRegistry.registerItem(this, Strings.wyvernSwordName); - } + public WyvernSword() { + super(ModItems.WYVERN); + this.setUnlocalizedName(Strings.wyvernSwordName); + this.setCreativeTab(DraconicEvolution.tabToolsWeapons); + if (ModItems.isEnabled(this)) GameRegistry.registerItem(this, Strings.wyvernSwordName); + } - @Override - public boolean isItemTool(ItemStack p_77616_1_) { - return true; - } + @Override + public boolean isItemTool(ItemStack p_77616_1_) { + return true; + } - @SuppressWarnings("unchecked") - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", 0)); - list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", capacity)); - } + @SuppressWarnings("unchecked") + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", 0)); + list.add(ItemNBTHelper.setInteger(new ItemStack(item, 1, 0), "Energy", capacity)); + } - @Override - public String getUnlocalizedName(){ + @Override + public String getUnlocalizedName() { - return String.format("item.%s%s", References.MODID.toLowerCase() + ":", super.getUnlocalizedName().substring(super.getUnlocalizedName().indexOf(".") + 1)); - } + return String.format("item.%s%s", References.MODID.toLowerCase() + ":", super.getUnlocalizedName().substring(super.getUnlocalizedName().indexOf(".") + 1)); + } - @Override - public String getUnlocalizedName(final ItemStack itemStack){ - return getUnlocalizedName(); - } + @Override + public String getUnlocalizedName(final ItemStack itemStack) { + return getUnlocalizedName(); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(final IIconRegister iconRegister) - { - this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "sword_wyvern"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister iconRegister) { + this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "sword_wyvern"); + } - @Override - public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) - { - ToolHandler.AOEAttack(player, entity, stack, IConfigurableItem.ProfileHelper.getInteger(stack, References.ATTACK_AOE, 0)); - ToolHandler.damageEntityBasedOnHealth(entity, player, 0.1F); - return true; - } + @Override + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { + ToolHandler.AOEAttack(player, entity, stack, IConfigurableItem.ProfileHelper.getInteger(stack, References.ATTACK_AOE, 0)); + ToolHandler.damageEntityBasedOnHealth(entity, player, 0.1F); + return true; + } - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) - { - if (InfoHelper.holdShiftForDetails(list)) { - List l = getFields(stack, 0); - for (ItemConfigField f : l) list.add(f.getTooltipInfo()); - list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.sword.txt")); - InfoHelper.addLore(stack, list); - } - ToolBase.holdCTRLForUpgrades(list, stack); - InfoHelper.addEnergyInfo(stack, list); - list.add(""); - list.add(EnumChatFormatting.BLUE + "+" + ToolHandler.getBaseAttackDamage(stack) + " " + StatCollector.translateToLocal("info.de.attackDamage.txt")); - list.add(EnumChatFormatting.BLUE + "+10%" + " " + StatCollector.translateToLocal("info.de.bonusHealthDamage.txt")); - } + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) { + if (InfoHelper.holdShiftForDetails(list)) { + List l = getFields(stack, 0); + for (ItemConfigField f : l) list.add(f.getTooltipInfo()); + list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.sword.txt")); + InfoHelper.addLore(stack, list); + } + ToolBase.holdCTRLForUpgrades(list, stack); + InfoHelper.addEnergyInfo(stack, list); + list.add(""); + list.add(EnumChatFormatting.BLUE + "+" + ToolHandler.getBaseAttackDamage(stack) + " " + StatCollector.translateToLocal("info.de.attackDamage.txt")); + list.add(EnumChatFormatting.BLUE + "+10%" + " " + StatCollector.translateToLocal("info.de.bonusHealthDamage.txt")); + } - @Override - public EnumRarity getRarity(ItemStack stack) - { - return EnumRarity.uncommon; - } + @Override + public EnumRarity getRarity(ItemStack stack) { + return EnumRarity.uncommon; + } - @Override - public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) - { - return super.hitEntity(par1ItemStack, par2EntityLivingBase, par3EntityLivingBase); - } + @Override + public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) { + return super.hitEntity(par1ItemStack, par2EntityLivingBase, par3EntityLivingBase); + } - @Override - public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { - if (container.stackTagCompound == null) { - container.stackTagCompound = new NBTTagCompound(); - } - int energy = container.stackTagCompound.getInteger("Energy"); - int energyReceived = Math.min(getMaxEnergyStored(container) - energy, Math.min(this.maxReceive, maxReceive)); + if (container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyReceived = Math.min(getMaxEnergyStored(container) - energy, Math.min(this.maxReceive, maxReceive)); - if (!simulate) { - energy += energyReceived; - container.stackTagCompound.setInteger("Energy", energy); - } - return energyReceived; - } + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("Energy", energy); + } + return energyReceived; + } - @Override - public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - int energy = container.stackTagCompound.getInteger("Energy"); - int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + return 0; + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - if (!simulate) { - energy -= energyExtracted; - container.stackTagCompound.setInteger("Energy", energy); - } - return energyExtracted; - } + if (!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("Energy", energy); + } + return energyExtracted; + } - @Override - public int getEnergyStored(ItemStack container) { - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - return container.stackTagCompound.getInteger("Energy"); - } + @Override + public int getEnergyStored(ItemStack container) { + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + return 0; + } + return container.stackTagCompound.getInteger("Energy"); + } - @Override - public int getMaxEnergyStored(ItemStack container) { - int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(container); - return BalanceConfigHandler.wyvernWeaponsBaseStorage + points * BalanceConfigHandler.wyvernWeaponsStoragePerUpgrade; - } + @Override + public int getMaxEnergyStored(ItemStack container) { + int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(container); + return BalanceConfigHandler.wyvernWeaponsBaseStorage + points * BalanceConfigHandler.wyvernWeaponsStoragePerUpgrade; + } - @Override - public boolean showDurabilityBar(ItemStack stack) { - return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); - } + @Override + public boolean showDurabilityBar(ItemStack stack) { + return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); + } - @Override - public double getDurabilityForDisplay(ItemStack stack) { - return 1D - ((double)getEnergyStored(stack) / (double)getMaxEnergyStored(stack)); - } + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - ((double) getEnergyStored(stack) / (double) getMaxEnergyStored(stack)); + } - @Override - public boolean hasCustomEntity(ItemStack stack) { - return true; - } + @Override + public boolean hasCustomEntity(ItemStack stack) { + return true; + } - @Override - public Entity createEntity(World world, Entity location, ItemStack itemstack) { - return new EntityPersistentItem(world, location, itemstack); - } + @Override + public Entity createEntity(World world, Entity location, ItemStack itemstack) { + return new EntityPersistentItem(world, location, itemstack); + } - @Override - public String getInventoryName() { - return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); - } + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); + } - @Override - public int getInventorySlots() { - return 0; - } + @Override + public int getInventorySlots() { + return 0; + } - @Override - public boolean isEnchantValid(Enchantment enchant) { - return enchant.type == EnumEnchantmentType.weapon; - } + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.weapon; + } - @Override - public List getFields(ItemStack stack, int slot) { - List list = new ArrayList(); - list.add(new ItemConfigField(References.INT_ID, slot, References.ATTACK_AOE).setMinMaxAndIncromente(0, EnumUpgrade.ATTACK_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 1).setModifier("AOE")); - return list; - } + @Override + public List getFields(ItemStack stack, int slot) { + List list = new ArrayList(); + list.add(new ItemConfigField(References.INT_ID, slot, References.ATTACK_AOE).setMinMaxAndIncromente(0, EnumUpgrade.ATTACK_AOE.getUpgradePoints(stack), 1).readFromItem(stack, 1).setModifier("AOE")); + return list; + } - @Override - public Multimap getAttributeModifiers(ItemStack stack) { - Multimap map = super.getAttributeModifiers(stack); - map.clear(); - return map; - } + @Override + public Multimap getAttributeModifiers(ItemStack stack) { + Multimap map = super.getAttributeModifiers(stack); + map.clear(); + return map; + } - @Override - public void tweakRender(IItemRenderer.ItemRenderType type) { - GL11.glTranslated(0.25, 0.8, 0.05); - GL11.glRotatef(90, 1, 0, 0); - GL11.glRotatef(140, 0, -1, 0); - GL11.glRotatef(180, 0, 0, 1); - GL11.glScaled(0.6, 0.6, 0.6); + @Override + public void tweakRender(IItemRenderer.ItemRenderType type) { + GL11.glTranslated(0.25, 0.8, 0.05); + GL11.glRotatef(90, 1, 0, 0); + GL11.glRotatef(140, 0, -1, 0); + GL11.glRotatef(180, 0, 0, 1); + GL11.glScaled(0.6, 0.6, 0.6); - if (type == IItemRenderer.ItemRenderType.INVENTORY){ - GL11.glScalef(11.8F, 11.8F, 11.8F); - GL11.glRotatef(180, 0, 1, 0); - GL11.glTranslated(-1.5, 0, -0.1); - } - else if (type == IItemRenderer.ItemRenderType.ENTITY){ - GL11.glRotatef(90.5F, 0, 1, 0); - GL11.glTranslated(0.2, 0, -0.8); - } - } + if (type == IItemRenderer.ItemRenderType.INVENTORY) { + GL11.glScalef(11.8F, 11.8F, 11.8F); + GL11.glRotatef(180, 0, 1, 0); + GL11.glTranslated(-1.5, 0, -0.1); + } else if (type == IItemRenderer.ItemRenderType.ENTITY) { + GL11.glRotatef(90.5F, 0, 1, 0); + GL11.glTranslated(0.2, 0, -0.8); + } + } - @Override - public List getUpgrades(ItemStack itemstack) { - return new ArrayList(){{ - add(EnumUpgrade.RF_CAPACITY); - add(EnumUpgrade.ATTACK_AOE); - add(EnumUpgrade.ATTACK_DAMAGE); - }}; - } + @Override + public List getUpgrades(ItemStack itemstack) { + return new ArrayList() {{ + add(EnumUpgrade.RF_CAPACITY); + add(EnumUpgrade.ATTACK_AOE); + add(EnumUpgrade.ATTACK_DAMAGE); + }}; + } - @Override - public int getUpgradeCap(ItemStack itemstack) { - return BalanceConfigHandler.wyvernWeaponsMaxUpgrades; - } + @Override + public int getUpgradeCap(ItemStack itemstack) { + return BalanceConfigHandler.wyvernWeaponsMaxUpgrades; + } - @Override - public int getMaxTier(ItemStack itemstack) { - return 1; - } + @Override + public int getMaxTier(ItemStack itemstack) { + return 1; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { - return BalanceConfigHandler.wyvernWeaponsMaxCapacityUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ATTACK_AOE.index) { - return BalanceConfigHandler.wyvernWeaponsMaxAttackAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ARROW_DAMAGE.index) - { - return BalanceConfigHandler.wyvernWeaponsMaxAttackDamageUpgradePoints; - } - return BalanceConfigHandler.wyvernWeaponsMaxUpgradePoints; - } + @Override + public int getMaxUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) { + return BalanceConfigHandler.wyvernWeaponsMaxCapacityUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ATTACK_AOE.index) { + return BalanceConfigHandler.wyvernWeaponsMaxAttackAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ARROW_DAMAGE.index) { + return BalanceConfigHandler.wyvernWeaponsMaxAttackDamageUpgradePoints; + } + return BalanceConfigHandler.wyvernWeaponsMaxUpgradePoints; + } - @Override - public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) - { - return getMaxUpgradePoints(upgradeIndex); - } + @Override + public int getMaxUpgradePoints(int upgradeIndex, ItemStack stack) { + return getMaxUpgradePoints(upgradeIndex); + } - @Override - public int getBaseUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.ATTACK_AOE.index) { - return BalanceConfigHandler.wyvernWeaponsMinAttackAOEUpgradePoints; - } - if (upgradeIndex == EnumUpgrade.ARROW_DAMAGE.index) { - return BalanceConfigHandler.wyvernWeaponsMinAttackDamageUpgradePoints; - } - return 0; - } + @Override + public int getBaseUpgradePoints(int upgradeIndex) { + if (upgradeIndex == EnumUpgrade.ATTACK_AOE.index) { + return BalanceConfigHandler.wyvernWeaponsMinAttackAOEUpgradePoints; + } + if (upgradeIndex == EnumUpgrade.ARROW_DAMAGE.index) { + return BalanceConfigHandler.wyvernWeaponsMinAttackDamageUpgradePoints; + } + return 0; + } - @Override - public List getUpgradeStats(ItemStack stack) { - List strings = new ArrayList(); + @Override + public List getUpgradeStats(ItemStack stack) { + List strings = new ArrayList(); - int attackaoe = 0; - for (ItemConfigField field : getFields(stack, 0)) if (field.name.equals(References.ATTACK_AOE)) attackaoe = 1 + ((Integer) field.max * 2); + int attackaoe = 0; + for (ItemConfigField field : getFields(stack, 0)) + if (field.name.equals(References.ATTACK_AOE)) attackaoe = 1 + ((Integer) field.max * 2); - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.RFCapacity.txt")+": "+InfoHelper.HITC()+Utills.formatNumber(getMaxEnergyStored(stack))); - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("info.de.attackDamage.txt")+": "+ InfoHelper.HITC()+ToolHandler.getBaseAttackDamage(stack)); - strings.add(InfoHelper.ITC()+StatCollector.translateToLocal("gui.de.max.txt")+" "+StatCollector.translateToLocal("gui.de.AttackAOE.txt")+": "+InfoHelper.HITC()+attackaoe+"x"+attackaoe); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.RFCapacity.txt") + ": " + InfoHelper.HITC() + Utills.formatNumber(getMaxEnergyStored(stack))); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.attackDamage.txt") + ": " + InfoHelper.HITC() + ToolHandler.getBaseAttackDamage(stack)); + strings.add(InfoHelper.ITC() + StatCollector.translateToLocal("gui.de.max.txt") + " " + StatCollector.translateToLocal("gui.de.AttackAOE.txt") + ": " + InfoHelper.HITC() + attackaoe + "x" + attackaoe); - return strings; - } + return strings; + } - @Override - public List getDisplayData(ItemStack stack) { - List list = new ArrayList(); - for (ItemConfigField field : getFields(stack, 0)) list.add(field.getTooltipInfo());//list.add(field.getLocalizedName() + ": " + field.getFormattedValue()); - return list; - } + @Override + public List getDisplayData(ItemStack stack) { + List list = new ArrayList(); + for (ItemConfigField field : getFields(stack, 0)) + list.add(field.getTooltipInfo());//list.add(field.getLocalizedName() + ": " + field.getFormattedValue()); + return list; + } - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (!world.isRemote && !BrandonsCore.proxy.isDedicatedServer()) - { - ToolBase.handleModeChange(stack, player, InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown()); - } - else if (world.isRemote && BrandonsCore.proxy.getMCServer() == null) - { - ToolBase.handleModeChange(stack, player, InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown()); - DraconicEvolution.network.sendToServer(new ToolModePacket(InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown())); - } - return super.onItemRightClick(stack, world, player); - } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (!world.isRemote && !BrandonsCore.proxy.isDedicatedServer()) { + ToolBase.handleModeChange(stack, player, InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown()); + } else if (world.isRemote && BrandonsCore.proxy.getMCServer() == null) { + ToolBase.handleModeChange(stack, player, InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown()); + DraconicEvolution.network.sendToServer(new ToolModePacket(InfoHelper.isShiftKeyDown(), InfoHelper.isCtrlKeyDown())); + } + return super.onItemRightClick(stack, world, player); + } - @Override - public boolean hasProfiles() { - return true; - } - @Override - public int getEnergyPerAttack() - { - return BalanceConfigHandler.wyvernWeaponsEnergyPerAttack; - } + @Override + public boolean hasProfiles() { + return true; + } + + @Override + public int getEnergyPerAttack() { + return BalanceConfigHandler.wyvernWeaponsEnergyPerAttack; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/lib/OreDoublingRegistry.java b/src/main/java/com/brandon3055/draconicevolution/common/lib/OreDoublingRegistry.java index d62a9593..33b927c9 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/lib/OreDoublingRegistry.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/lib/OreDoublingRegistry.java @@ -17,52 +17,51 @@ import java.util.Map; * Created by Brandon on 2/11/2014. */ public class OreDoublingRegistry { - private static Map oreResults = new HashMap(); - private static String[] names = {"oreGold", "oreIron", "oreAluminum", "oreCopper", "oreLead", "oreSilver", "oreTin", "oreUranium", "orePlatinum", "oreNickel", "oreMithril", "oreCobalt", "oreArdite"}; - public static Map resultOverrides = new HashMap(); + private static Map oreResults = new HashMap(); + private static String[] names = {"oreGold", "oreIron", "oreAluminum", "oreCopper", "oreLead", "oreSilver", "oreTin", "oreUranium", "orePlatinum", "oreNickel", "oreMithril", "oreCobalt", "oreArdite"}; + public static Map resultOverrides = new HashMap(); - public static void init(){ + public static void init() { - for (String oreName : names) { - String ingotName = "ingot" + oreName.substring(oreName.indexOf("ore")+3); + for (String oreName : names) { + String ingotName = "ingot" + oreName.substring(oreName.indexOf("ore") + 3); - ItemStack resultIngot = GameRegistry.findItemStack("ThermalFoundation", ingotName, 1); + ItemStack resultIngot = GameRegistry.findItemStack("ThermalFoundation", ingotName, 1); - if (resultIngot == null && OreDictionary.getOres(ingotName).size() > 0) resultIngot = OreDictionary.getOres(ingotName).get(0); + if (resultIngot == null && OreDictionary.getOres(ingotName).size() > 0) + resultIngot = OreDictionary.getOres(ingotName).get(0); - oreResults.put(oreName, resultIngot); - } + oreResults.put(oreName, resultIngot); + } - } + } - public static ItemStack getOreResult(ItemStack stack) - { - if (stack == null) return null; - if (resultOverrides.containsKey(stack.getItem().getUnlocalizedName(stack))) return resultOverrides.get(stack.getItem().getUnlocalizedName(stack)).copy(); - if (FurnaceRecipes.smelting().getSmeltingResult(stack) == null) return null; - if (stack.getItem() instanceof DraconiumBlend) return new ItemStack(ModItems.draconiumIngot, 4); - else if (stack.getItem() == Item.getItemFromBlock(Blocks.cobblestone)) return new ItemStack(Blocks.stone, 2); - else if (stack.getItem() == Item.getItemFromBlock(Blocks.sand)) return new ItemStack(Blocks.glass, 2); - else if (stack.getItem() == Item.getItemFromBlock(Blocks.cactus)) return new ItemStack(Items.dye, 2, 2); - else if (stack.getItem() == Items.clay_ball) return new ItemStack(Items.brick, 2); + public static ItemStack getOreResult(ItemStack stack) { + if (stack == null) return null; + if (resultOverrides.containsKey(stack.getItem().getUnlocalizedName(stack))) + return resultOverrides.get(stack.getItem().getUnlocalizedName(stack)).copy(); + if (FurnaceRecipes.smelting().getSmeltingResult(stack) == null) return null; + if (stack.getItem() instanceof DraconiumBlend) return new ItemStack(ModItems.draconiumIngot, 4); + else if (stack.getItem() == Item.getItemFromBlock(Blocks.cobblestone)) return new ItemStack(Blocks.stone, 2); + else if (stack.getItem() == Item.getItemFromBlock(Blocks.sand)) return new ItemStack(Blocks.glass, 2); + else if (stack.getItem() == Item.getItemFromBlock(Blocks.cactus)) return new ItemStack(Items.dye, 2, 2); + else if (stack.getItem() == Items.clay_ball) return new ItemStack(Items.brick, 2); - int[] ids = OreDictionary.getOreIDs(stack); - String name; - ItemStack resultStack = null; + int[] ids = OreDictionary.getOreIDs(stack); + String name; + ItemStack resultStack = null; - if (ids.length > 0) - { - name = OreDictionary.getOreName(ids[0]); - resultStack = oreResults.get(name); - } + if (ids.length > 0) { + name = OreDictionary.getOreName(ids[0]); + resultStack = oreResults.get(name); + } - if (resultStack != null) - { - ItemStack doubledStack = resultStack.copy(); - doubledStack.stackSize = FurnaceRecipes.smelting().getSmeltingResult(stack).stackSize * 2; - return doubledStack; - } + if (resultStack != null) { + ItemStack doubledStack = resultStack.copy(); + doubledStack.stackSize = FurnaceRecipes.smelting().getSmeltingResult(stack).stackSize * 2; + return doubledStack; + } - return null; - } + return null; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/lib/References.java b/src/main/java/com/brandon3055/draconicevolution/common/lib/References.java index b087d4fc..09db54fc 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/lib/References.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/lib/References.java @@ -1,40 +1,40 @@ package com.brandon3055.draconicevolution.common.lib; public final class References { - public static final String MODID = "DraconicEvolution"; - public static final String MODNAME = "Draconic Evolution"; - public static final String VERSION = VersionHandler.FULL_VERSION; - public static final String MCVERSION = VersionHandler.MCVERSION; - public static final String CLIENTPROXYLOCATION = "com.brandon3055.draconicevolution.client.ClientProxy"; - public static final String SERVERPROXYLOCATION = "com.brandon3055.draconicevolution.common.CommonProxy"; - public static final String GUIFACTORY = "com.brandon3055.draconicevolution.client.gui.DEGUIFactory"; - public static final String RESOURCESPREFIX = MODID.toLowerCase() + ":"; + public static final String MODID = "DraconicEvolution"; + public static final String MODNAME = "Draconic Evolution"; + public static final String VERSION = VersionHandler.FULL_VERSION; + public static final String MCVERSION = VersionHandler.MCVERSION; + public static final String CLIENTPROXYLOCATION = "com.brandon3055.draconicevolution.client.ClientProxy"; + public static final String SERVERPROXYLOCATION = "com.brandon3055.draconicevolution.common.CommonProxy"; + public static final String GUIFACTORY = "com.brandon3055.draconicevolution.client.gui.DEGUIFactory"; + public static final String RESOURCESPREFIX = MODID.toLowerCase() + ":"; - //======================Render IDs========================// - public static int idTeleporterStand = -1; - public static int idPortal = -1; + //======================Render IDs========================// + public static int idTeleporterStand = -1; + public static int idPortal = -1; - //======================Data Types========================// + //======================Data Types========================// - public static final byte BYTE_ID = 0; - public static final byte SHORT_ID = 1; - public static final byte INT_ID = 2; - public static final byte LONG_ID = 3; - public static final byte FLOAT_ID = 4; - public static final byte DOUBLE_ID = 5; - public static final byte BOOLEAN_ID = 6; - public static final byte CHAR_ID = 7; - public static final byte STRING_ID = 8; - public static final byte INT_PAIR_ID = 9; + public static final byte BYTE_ID = 0; + public static final byte SHORT_ID = 1; + public static final byte INT_ID = 2; + public static final byte LONG_ID = 3; + public static final byte FLOAT_ID = 4; + public static final byte DOUBLE_ID = 5; + public static final byte BOOLEAN_ID = 6; + public static final byte CHAR_ID = 7; + public static final byte STRING_ID = 8; + public static final byte INT_PAIR_ID = 9; - //======================Tags========================// + //======================Tags========================// - public static final String DIG_SPEED_MULTIPLIER = "ToolDigMultiplier"; - public static final String DIG_AOE = "ToolDigAOE"; - public static final String DIG_DEPTH = "ToolDigDepth"; - public static final String ATTACK_AOE = "WeaponAttackAOE"; - public static final String OBLITERATE = "ToolVoidJunk"; - public static final String TREE_MODE = "AxeTreeMode"; - public static final String BASE_SAFE_AOE = "BaseSafeAOE"; + public static final String DIG_SPEED_MULTIPLIER = "ToolDigMultiplier"; + public static final String DIG_AOE = "ToolDigAOE"; + public static final String DIG_DEPTH = "ToolDigDepth"; + public static final String ATTACK_AOE = "WeaponAttackAOE"; + public static final String OBLITERATE = "ToolVoidJunk"; + public static final String TREE_MODE = "AxeTreeMode"; + public static final String BASE_SAFE_AOE = "BaseSafeAOE"; } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/lib/Strings.java b/src/main/java/com/brandon3055/draconicevolution/common/lib/Strings.java index 15635028..ced143e0 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/lib/Strings.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/lib/Strings.java @@ -1,73 +1,73 @@ package com.brandon3055.draconicevolution.common.lib; public class Strings {// public static Block name - public static final String blockWeatherControllerName = "weatherController"; - public static final String tclogoName = "tclogo"; - public static final String xrayBlockName = "xRayBlock"; - public static final String blockSunDialName = "sunDial"; - public static final String sunFocusName = "sunFocus"; - public static final String draconicCoreName = "draconicCore"; - public static final String draconicPickaxeName = "draconicPickaxe"; - public static final String draconicSwordName = "draconicSword"; - public static final String infusedCompoundName = "wyvernCore"; - public static final String draconiumDustName = "draconiumDust"; - public static final String draconiumIngotName = "draconiumIngot"; - public static final String draconiumBlendName = "draconiumBlend"; - public static final String dragonHeartName = "dragonHeart"; - public static final String draconicShovelName = "draconicShovel"; - public static final String wyvernShovelName = "wyvernShovel"; - public static final String wyvernPickaxeName = "wyvernPickaxe"; - public static final String draconicDStaffName = "draconicDistructionStaff"; - public static final String draconicCompoundName = "awakenedCore"; - public static final String wyvernSwordName = "wyvernSword"; - public static final String wyvernBowName = "wyvernBow"; - public static final String draconicBowName = "draconicBow"; - public static final String draconiumOreName = "draconiumOre"; - public static final String teleporterMKIName = "teleporterMKI"; - public static final String draconicHoeName = "draconicHoe"; - public static final String draconicAxeName = "draconicAxe"; - public static final String teleporterMKIIName = "teleporterMKII"; - public static final String grinderName = "grinder"; - public static final String potentiometerName = "potentiometer"; - public static final String rainSensorName = "rainSensor"; - public static final String particleGeneratorName = "particleGenerator"; - public static final String playerDetectorName = "playerDetector"; - public static final String playerDetectorAdvancedName = "playerDetectorAdvanced"; - public static final String energyInfuserName = "energyInfuser"; - public static final String draconicHelmName = "draconicHelm"; - public static final String draconicChestName = "draconicChest"; - public static final String draconicLeggsName = "draconicLeggs"; - public static final String draconicBootsName = "draconicBoots"; - public static final String wyvernHelmName = "wyvernHelm"; - public static final String wyvernChestName = "wyvernChest"; - public static final String wyvernLeggsName = "wyvernLeggs"; - public static final String wyvernBootsName = "wyvernBoots"; - public static final String customSpawnerName = "customSpawner"; - public static final String MobSoulName = "mobSoul"; - public static final String longRangeDislocatorName = "longRangeDislocator"; - public static final String generatorName = "generator"; - public static final String energyStorageCoreName = "energyStorageCore"; - public static final String draconiumBlockName = "draconium"; - public static final String invisibleMultiblockName = "invisibleMultiblock"; - public static final String energyPylonName = "energyPylon"; - public static final String placedItemName = "placedItem"; - public static final String enderArrowName = "enderArrow"; - public static final String safetyFlameName = "safetyFlame"; - public static final String safetyMatchName = "safetyMatch"; - public static final String cKeyStoneName = "cKeyStone"; - public static final String keyName = "key"; - public static final String creativeStructureSpawnerName = "creativeStructureSpawner"; - public static final String obliterationCatalystName = "obliterationCatalyst"; - public static final String adminSpawnEggName = "adminSpawnEgg"; - public static final String infoTabletName = "infoTablet"; - public static final String containerTemplateName = "containerTemplate"; - public static final String dissEnchanterName = "dissEnchanter"; - public static final String teleporterStandName = "teleporterStand"; - public static final String draconiumChestName = "draconiumChest"; - public static final String draconicIngotName = "draconicIngot"; - public static final String draconicBlockName = "draconicBlock"; - public static final String draconiumEnergyCoreName = "draconiumEnergyCore"; - public static final String draconiumFluxCapacitorName = "draconiumFluxCapacitor"; - public static final String energyCrystalName = "energyCrystal"; - public static final String wrenchName = "wrench"; + public static final String blockWeatherControllerName = "weatherController"; + public static final String tclogoName = "tclogo"; + public static final String xrayBlockName = "xRayBlock"; + public static final String blockSunDialName = "sunDial"; + public static final String sunFocusName = "sunFocus"; + public static final String draconicCoreName = "draconicCore"; + public static final String draconicPickaxeName = "draconicPickaxe"; + public static final String draconicSwordName = "draconicSword"; + public static final String infusedCompoundName = "wyvernCore"; + public static final String draconiumDustName = "draconiumDust"; + public static final String draconiumIngotName = "draconiumIngot"; + public static final String draconiumBlendName = "draconiumBlend"; + public static final String dragonHeartName = "dragonHeart"; + public static final String draconicShovelName = "draconicShovel"; + public static final String wyvernShovelName = "wyvernShovel"; + public static final String wyvernPickaxeName = "wyvernPickaxe"; + public static final String draconicDStaffName = "draconicDistructionStaff"; + public static final String draconicCompoundName = "awakenedCore"; + public static final String wyvernSwordName = "wyvernSword"; + public static final String wyvernBowName = "wyvernBow"; + public static final String draconicBowName = "draconicBow"; + public static final String draconiumOreName = "draconiumOre"; + public static final String teleporterMKIName = "teleporterMKI"; + public static final String draconicHoeName = "draconicHoe"; + public static final String draconicAxeName = "draconicAxe"; + public static final String teleporterMKIIName = "teleporterMKII"; + public static final String grinderName = "grinder"; + public static final String potentiometerName = "potentiometer"; + public static final String rainSensorName = "rainSensor"; + public static final String particleGeneratorName = "particleGenerator"; + public static final String playerDetectorName = "playerDetector"; + public static final String playerDetectorAdvancedName = "playerDetectorAdvanced"; + public static final String energyInfuserName = "energyInfuser"; + public static final String draconicHelmName = "draconicHelm"; + public static final String draconicChestName = "draconicChest"; + public static final String draconicLeggsName = "draconicLeggs"; + public static final String draconicBootsName = "draconicBoots"; + public static final String wyvernHelmName = "wyvernHelm"; + public static final String wyvernChestName = "wyvernChest"; + public static final String wyvernLeggsName = "wyvernLeggs"; + public static final String wyvernBootsName = "wyvernBoots"; + public static final String customSpawnerName = "customSpawner"; + public static final String MobSoulName = "mobSoul"; + public static final String longRangeDislocatorName = "longRangeDislocator"; + public static final String generatorName = "generator"; + public static final String energyStorageCoreName = "energyStorageCore"; + public static final String draconiumBlockName = "draconium"; + public static final String invisibleMultiblockName = "invisibleMultiblock"; + public static final String energyPylonName = "energyPylon"; + public static final String placedItemName = "placedItem"; + public static final String enderArrowName = "enderArrow"; + public static final String safetyFlameName = "safetyFlame"; + public static final String safetyMatchName = "safetyMatch"; + public static final String cKeyStoneName = "cKeyStone"; + public static final String keyName = "key"; + public static final String creativeStructureSpawnerName = "creativeStructureSpawner"; + public static final String obliterationCatalystName = "obliterationCatalyst"; + public static final String adminSpawnEggName = "adminSpawnEgg"; + public static final String infoTabletName = "infoTablet"; + public static final String containerTemplateName = "containerTemplate"; + public static final String dissEnchanterName = "dissEnchanter"; + public static final String teleporterStandName = "teleporterStand"; + public static final String draconiumChestName = "draconiumChest"; + public static final String draconicIngotName = "draconicIngot"; + public static final String draconicBlockName = "draconicBlock"; + public static final String draconiumEnergyCoreName = "draconiumEnergyCore"; + public static final String draconiumFluxCapacitorName = "draconiumFluxCapacitor"; + public static final String energyCrystalName = "energyCrystal"; + public static final String wrenchName = "wrench"; } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/lib/VersionHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/lib/VersionHandler.java index d03db854..2ec9d8ab 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/lib/VersionHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/lib/VersionHandler.java @@ -3,13 +3,12 @@ package com.brandon3055.draconicevolution.common.lib; /** * Created by Brandon on 24/02/2015. */ -public class VersionHandler -{ - public static final String VERSION = "1.0.2e"; - public static final int SNAPSHOT = 0; - public static final String MCVERSION = "1.7.10"; +public class VersionHandler { + public static final String VERSION = "1.0.2e"; + public static final int SNAPSHOT = 0; + public static final String MCVERSION = "1.7.10"; - public static final String FULL_VERSION = VERSION + (SNAPSHOT > 0 ? "-snapshot_" + SNAPSHOT : ""); + public static final String FULL_VERSION = VERSION + (SNAPSHOT > 0 ? "-snapshot_" + SNAPSHOT : ""); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/magic/EnchantmentReaper.java b/src/main/java/com/brandon3055/draconicevolution/common/magic/EnchantmentReaper.java index 4dee7d89..c4515590 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/magic/EnchantmentReaper.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/magic/EnchantmentReaper.java @@ -7,23 +7,23 @@ import net.minecraft.enchantment.EnumEnchantmentType; * Created by Brandon on 17/11/2014. */ public class EnchantmentReaper extends Enchantment { - public EnchantmentReaper(int id) { - super(id, 2, EnumEnchantmentType.weapon); - setName("draconicevolution.reaperEnchant"); - } + public EnchantmentReaper(int id) { + super(id, 2, EnumEnchantmentType.weapon); + setName("draconicevolution.reaperEnchant"); + } - @Override - public int getMaxLevel() { - return 5; - } + @Override + public int getMaxLevel() { + return 5; + } - @Override - public int getMinEnchantability(int level) { - return 1 + 10 * (level - 1); - } + @Override + public int getMinEnchantability(int level) { + return 1 + 10 * (level - 1); + } - @Override - public int getMaxEnchantability(int level) { - return super.getMinEnchantability(level) + 50; - } + @Override + public int getMaxEnchantability(int level) { + return super.getMinEnchantability(level) + 50; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/magic/PotionHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/magic/PotionHandler.java index e7fab852..3d0b4119 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/magic/PotionHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/magic/PotionHandler.java @@ -10,24 +10,23 @@ import net.minecraft.potion.PotionEffect; public class PotionHandler { - public static void init(){ + public static void init() { - } + } - public static class PotionBase extends Potion { + public static class PotionBase extends Potion { - public PotionBase(int id, boolean isBad, int colour) - { - super(id, isBad, colour); - } + public PotionBase(int id, boolean isBad, int colour) { + super(id, isBad, colour); + } - @Override - public boolean shouldRenderInvText(PotionEffect effect) { - return false; - } + @Override + public boolean shouldRenderInvText(PotionEffect effect) { + return false; + } - @Override - public void renderInventoryEffect(int x, int y, PotionEffect effect, Minecraft mc) { + @Override + public void renderInventoryEffect(int x, int y, PotionEffect effect, Minecraft mc) { // mc.fontRenderer.drawString(StatCollector.translateToLocal("magic.de.effect.txt"), x+7, y+6, 0xffffff); // if (effect.getPotionID() == potionFlight.id) // mc.fontRenderer.drawString(StatCollector.translateToLocal("magic.de.flight.txt"), x+7, y+17, 0x00ff00); @@ -40,8 +39,8 @@ public class PotionHandler { // else if (effect.getPotionID() == potionJumpBoost.id) // mc.fontRenderer.drawString(StatCollector.translateToLocal("magic.de.jumpBoost.txt"), x+7, y+17, 0x00ff00); // if (effect.getAmplifier() > 0)mc.fontRenderer.drawString("lvl: "+(effect.getAmplifier()+1), x+86, y+12, 0xff0000); - } - } + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/network/BlockUpdatePacket.java b/src/main/java/com/brandon3055/draconicevolution/common/network/BlockUpdatePacket.java index 19060cfc..e54caac8 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/network/BlockUpdatePacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/network/BlockUpdatePacket.java @@ -6,38 +6,38 @@ import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import net.minecraft.network.play.server.S23PacketBlockChange; -public class BlockUpdatePacket implements IMessage -{ - int x, y, z; +public class BlockUpdatePacket implements IMessage { + int x, y, z; - public BlockUpdatePacket() {} + public BlockUpdatePacket() { + } - public BlockUpdatePacket(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } + public BlockUpdatePacket(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } - @Override - public void fromBytes(ByteBuf bytes) { - this.x = bytes.readInt(); - this.y = bytes.readInt(); - this.z = bytes.readInt(); - } + @Override + public void fromBytes(ByteBuf bytes) { + this.x = bytes.readInt(); + this.y = bytes.readInt(); + this.z = bytes.readInt(); + } - @Override - public void toBytes(ByteBuf bytes){ - bytes.writeInt(x); - bytes.writeInt(y); - bytes.writeInt(z); - } + @Override + public void toBytes(ByteBuf bytes) { + bytes.writeInt(x); + bytes.writeInt(y); + bytes.writeInt(z); + } - public static class Handler implements IMessageHandler { + public static class Handler implements IMessageHandler { - @Override - public IMessage onMessage(BlockUpdatePacket message, MessageContext ctx) { - ctx.getServerHandler().playerEntity.playerNetServerHandler.sendPacket(new S23PacketBlockChange(message.x, message.y, message.z, ctx.getServerHandler().playerEntity.worldObj)); - return null; - } - } + @Override + public IMessage onMessage(BlockUpdatePacket message, MessageContext ctx) { + ctx.getServerHandler().playerEntity.playerNetServerHandler.sendPacket(new S23PacketBlockChange(message.x, message.y, message.z, ctx.getServerHandler().playerEntity.worldObj)); + return null; + } + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/network/ButtonPacket.java b/src/main/java/com/brandon3055/draconicevolution/common/network/ButtonPacket.java index 9a3ab13a..a7ff0116 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/network/ButtonPacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/network/ButtonPacket.java @@ -17,127 +17,118 @@ import io.netty.buffer.ByteBuf; import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; -public class ButtonPacket implements IMessage -{ - public static final byte ID_WEATHERCONTROLLER = 0; - public static final byte ID_DISSENCHANTER = 1; - public static final byte ID_DRACONIUMCHEST0 = 2; - public static final byte ID_DRACONIUMCHEST1 = 3; - public static final byte ID_DRACONIUMCHEST2 = 4; - public static final byte ID_DRACONIUMCHEST3 = 5; - public static final byte ID_TOOLCONFIG = 7; - public static final byte ID_DRACONIUMCHEST4 = 8; - public static final byte ID_TOOL_PROFILE_CHANGE = 9; - byte buttonId = 0; - boolean state = false; - - public ButtonPacket() {} +public class ButtonPacket implements IMessage { + public static final byte ID_WEATHERCONTROLLER = 0; + public static final byte ID_DISSENCHANTER = 1; + public static final byte ID_DRACONIUMCHEST0 = 2; + public static final byte ID_DRACONIUMCHEST1 = 3; + public static final byte ID_DRACONIUMCHEST2 = 4; + public static final byte ID_DRACONIUMCHEST3 = 5; + public static final byte ID_TOOLCONFIG = 7; + public static final byte ID_DRACONIUMCHEST4 = 8; + public static final byte ID_TOOL_PROFILE_CHANGE = 9; + byte buttonId = 0; + boolean state = false; - public ButtonPacket(byte buttonId, boolean state) { - this.buttonId = buttonId; - this.state = state; - } + public ButtonPacket() { + } - @Override - public void fromBytes(ByteBuf bytes){ - this.buttonId = bytes.readByte(); - this.state = bytes.readBoolean(); - } + public ButtonPacket(byte buttonId, boolean state) { + this.buttonId = buttonId; + this.state = state; + } - @Override - public void toBytes(ByteBuf bytes){ - bytes.writeByte(buttonId); - bytes.writeBoolean(state); - } + @Override + public void fromBytes(ByteBuf bytes) { + this.buttonId = bytes.readByte(); + this.state = bytes.readBoolean(); + } - public static class Handler implements IMessageHandler { + @Override + public void toBytes(ByteBuf bytes) { + bytes.writeByte(buttonId); + bytes.writeBoolean(state); + } - @Override - public IMessage onMessage(ButtonPacket message, MessageContext ctx) { - switch (message.buttonId) { - case ID_WEATHERCONTROLLER: - { - Container container = ctx.getServerHandler().playerEntity.openContainer; - if (container != null && container instanceof ContainerWeatherController){ - TileWeatherController tileWC = ((ContainerWeatherController) container).getTileWC(); - tileWC.reciveButtonEvent(message.buttonId); - } - break; - } - case ID_DISSENCHANTER: - { - Container container = ctx.getServerHandler().playerEntity.openContainer; - if (container != null && container instanceof ContainerDissEnchanter){ - TileDissEnchanter tile = ((ContainerDissEnchanter) container).getTile(); - tile.buttonClick(ctx.getServerHandler().playerEntity); - } - break; - } - case ID_DRACONIUMCHEST0: - { - Container container = ctx.getServerHandler().playerEntity.openContainer; - if (container != null && container instanceof ContainerDraconiumChest){ - TileDraconiumChest tile = ((ContainerDraconiumChest) container).getTile(); - tile.setAutoFeed(0); - } - break; - } - case ID_DRACONIUMCHEST1: - { - Container container = ctx.getServerHandler().playerEntity.openContainer; - if (container != null && container instanceof ContainerDraconiumChest){ - TileDraconiumChest tile = ((ContainerDraconiumChest) container).getTile(); - tile.setAutoFeed(1); - } - break; - } - case ID_DRACONIUMCHEST2: - { - Container container = ctx.getServerHandler().playerEntity.openContainer; - if (container != null && container instanceof ContainerDraconiumChest){ - TileDraconiumChest tile = ((ContainerDraconiumChest) container).getTile(); - tile.setAutoFeed(2); - } - break; - } - case ID_DRACONIUMCHEST3: - { - Container container = ctx.getServerHandler().playerEntity.openContainer; - if (container != null && container instanceof ContainerDraconiumChest){ - TileDraconiumChest tile = ((ContainerDraconiumChest) container).getTile(); - tile.setAutoFeed(3); - } - break; - } - case ID_DRACONIUMCHEST4: - { - Container container = ctx.getServerHandler().playerEntity.openContainer; - if (container != null && container instanceof ContainerDraconiumChest){ - TileDraconiumChest tile = ((ContainerDraconiumChest) container).getTile(); - tile.lockOutputSlots = ! tile.lockOutputSlots; - } - break; - } - case ID_TOOLCONFIG: - { - ctx.getServerHandler().playerEntity.openGui(DraconicEvolution.instance, GuiHandler.GUIID_TOOL_CONFIG, ctx.getServerHandler().playerEntity.worldObj, (int)ctx.getServerHandler().playerEntity.posX, (int)ctx.getServerHandler().playerEntity.posY, (int)ctx.getServerHandler().playerEntity.posZ); - break; - } - case ID_TOOL_PROFILE_CHANGE: - { - ItemStack stack = ctx.getServerHandler().playerEntity.getHeldItem(); - if (stack != null && stack.getItem() instanceof IConfigurableItem && ((IConfigurableItem)stack.getItem()).hasProfiles()){ - int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); - if (++preset >= 5) preset = 0; - ItemNBTHelper.setInteger(stack, "ConfigProfile", preset); - } - break; - } + public static class Handler implements IMessageHandler { - default: - break; - } - return null; - } - } + @Override + public IMessage onMessage(ButtonPacket message, MessageContext ctx) { + switch (message.buttonId) { + case ID_WEATHERCONTROLLER: { + Container container = ctx.getServerHandler().playerEntity.openContainer; + if (container != null && container instanceof ContainerWeatherController) { + TileWeatherController tileWC = ((ContainerWeatherController) container).getTileWC(); + tileWC.reciveButtonEvent(message.buttonId); + } + break; + } + case ID_DISSENCHANTER: { + Container container = ctx.getServerHandler().playerEntity.openContainer; + if (container != null && container instanceof ContainerDissEnchanter) { + TileDissEnchanter tile = ((ContainerDissEnchanter) container).getTile(); + tile.buttonClick(ctx.getServerHandler().playerEntity); + } + break; + } + case ID_DRACONIUMCHEST0: { + Container container = ctx.getServerHandler().playerEntity.openContainer; + if (container != null && container instanceof ContainerDraconiumChest) { + TileDraconiumChest tile = ((ContainerDraconiumChest) container).getTile(); + tile.setAutoFeed(0); + } + break; + } + case ID_DRACONIUMCHEST1: { + Container container = ctx.getServerHandler().playerEntity.openContainer; + if (container != null && container instanceof ContainerDraconiumChest) { + TileDraconiumChest tile = ((ContainerDraconiumChest) container).getTile(); + tile.setAutoFeed(1); + } + break; + } + case ID_DRACONIUMCHEST2: { + Container container = ctx.getServerHandler().playerEntity.openContainer; + if (container != null && container instanceof ContainerDraconiumChest) { + TileDraconiumChest tile = ((ContainerDraconiumChest) container).getTile(); + tile.setAutoFeed(2); + } + break; + } + case ID_DRACONIUMCHEST3: { + Container container = ctx.getServerHandler().playerEntity.openContainer; + if (container != null && container instanceof ContainerDraconiumChest) { + TileDraconiumChest tile = ((ContainerDraconiumChest) container).getTile(); + tile.setAutoFeed(3); + } + break; + } + case ID_DRACONIUMCHEST4: { + Container container = ctx.getServerHandler().playerEntity.openContainer; + if (container != null && container instanceof ContainerDraconiumChest) { + TileDraconiumChest tile = ((ContainerDraconiumChest) container).getTile(); + tile.lockOutputSlots = !tile.lockOutputSlots; + } + break; + } + case ID_TOOLCONFIG: { + ctx.getServerHandler().playerEntity.openGui(DraconicEvolution.instance, GuiHandler.GUIID_TOOL_CONFIG, ctx.getServerHandler().playerEntity.worldObj, (int) ctx.getServerHandler().playerEntity.posX, (int) ctx.getServerHandler().playerEntity.posY, (int) ctx.getServerHandler().playerEntity.posZ); + break; + } + case ID_TOOL_PROFILE_CHANGE: { + ItemStack stack = ctx.getServerHandler().playerEntity.getHeldItem(); + if (stack != null && stack.getItem() instanceof IConfigurableItem && ((IConfigurableItem) stack.getItem()).hasProfiles()) { + int preset = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); + if (++preset >= 5) preset = 0; + ItemNBTHelper.setInteger(stack, "ConfigProfile", preset); + } + break; + } + + default: + break; + } + return null; + } + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/network/ContributorPacket.java b/src/main/java/com/brandon3055/draconicevolution/common/network/ContributorPacket.java index 28d77989..0ab20957 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/network/ContributorPacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/network/ContributorPacket.java @@ -11,59 +11,59 @@ import cpw.mods.fml.relauncher.Side; import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; -public class ContributorPacket implements IMessage -{ - public String contributor; - public boolean wings; - public boolean badge; +public class ContributorPacket implements IMessage { + public String contributor; + public boolean wings; + public boolean badge; - public ContributorPacket() {} + public ContributorPacket() { + } - public ContributorPacket(String contributor, boolean wings, boolean badge) { - this.contributor = contributor; - this.wings = wings; - this.badge = badge; - } + public ContributorPacket(String contributor, boolean wings, boolean badge) { + this.contributor = contributor; + this.wings = wings; + this.badge = badge; + } - @Override - public void fromBytes(ByteBuf bytes){ - this.contributor = ByteBufUtils.readUTF8String(bytes); - this.wings = bytes.readBoolean(); - this.badge = bytes.readBoolean(); - } + @Override + public void fromBytes(ByteBuf bytes) { + this.contributor = ByteBufUtils.readUTF8String(bytes); + this.wings = bytes.readBoolean(); + this.badge = bytes.readBoolean(); + } - @Override - public void toBytes(ByteBuf bytes){ - ByteBufUtils.writeUTF8String(bytes, contributor); - bytes.writeBoolean(wings); - bytes.writeBoolean(badge); - } + @Override + public void toBytes(ByteBuf bytes) { + ByteBufUtils.writeUTF8String(bytes, contributor); + bytes.writeBoolean(wings); + bytes.writeBoolean(badge); + } - public static class Handler implements IMessageHandler { + public static class Handler implements IMessageHandler { - @Override - public IMessage onMessage(ContributorPacket message, MessageContext ctx) { - if (ContributorHandler.contributors.containsKey(message.contributor)){ - ContributorHandler.Contributor contributor1 = ContributorHandler.contributors.get(message.contributor); + @Override + public IMessage onMessage(ContributorPacket message, MessageContext ctx) { + if (ContributorHandler.contributors.containsKey(message.contributor)) { + ContributorHandler.Contributor contributor1 = ContributorHandler.contributors.get(message.contributor); - if (ctx.side == Side.SERVER){ - if (!contributor1.isUserValid(ctx.getServerHandler().playerEntity)) return null; + if (ctx.side == Side.SERVER) { + if (!contributor1.isUserValid(ctx.getServerHandler().playerEntity)) return null; - contributor1.contributorWingsEnabled = message.wings; - contributor1.patreonBadgeEnabled = message.badge; + contributor1.contributorWingsEnabled = message.wings; + contributor1.patreonBadgeEnabled = message.badge; - DraconicEvolution.network.sendToAll(message); - } - else { - EntityPlayer player = BrandonsCore.proxy.getClientPlayer(); - if (!contributor1.isUserValid(player) || message.contributor.equals(player.getCommandSenderName())) return null; + DraconicEvolution.network.sendToAll(message); + } else { + EntityPlayer player = BrandonsCore.proxy.getClientPlayer(); + if (!contributor1.isUserValid(player) || message.contributor.equals(player.getCommandSenderName())) + return null; - contributor1.contributorWingsEnabled = message.wings; - contributor1.patreonBadgeEnabled = message.badge; - } - } + contributor1.contributorWingsEnabled = message.wings; + contributor1.patreonBadgeEnabled = message.badge; + } + } - return null; - } - } + return null; + } + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/network/GenericParticlePacket.java b/src/main/java/com/brandon3055/draconicevolution/common/network/GenericParticlePacket.java index 8ff8dff4..49836007 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/network/GenericParticlePacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/network/GenericParticlePacket.java @@ -10,122 +10,113 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; -public class GenericParticlePacket implements IMessage -{ - public static final byte ENERGY_BALL_KILL = 0; - public static final byte CHAOS_BALL_KILL = 1; - public static final byte CHAOS_IMPLOSION = 3; - public static final byte ARROW_SHOCK_WAVE = 4; +public class GenericParticlePacket implements IMessage { + public static final byte ENERGY_BALL_KILL = 0; + public static final byte CHAOS_BALL_KILL = 1; + public static final byte CHAOS_IMPLOSION = 3; + public static final byte ARROW_SHOCK_WAVE = 4; - private byte particleId = 0; - private double posX; - private double posY; - private double posZ; - private int additionalData; + private byte particleId = 0; + private double posX; + private double posY; + private double posZ; + private int additionalData; - public GenericParticlePacket() {} + public GenericParticlePacket() { + } - public GenericParticlePacket(byte particleId, double posX, double posY, double posZ) { - this.particleId = particleId; - this.posX = posX; - this.posY = posY; - this.posZ = posZ; - } + public GenericParticlePacket(byte particleId, double posX, double posY, double posZ) { + this.particleId = particleId; + this.posX = posX; + this.posY = posY; + this.posZ = posZ; + } - public GenericParticlePacket(byte particleId, double posX, double posY, double posZ, int aditionalData) { - this.particleId = particleId; - this.posX = posX; - this.posY = posY; - this.posZ = posZ; - this.additionalData = aditionalData; - } + public GenericParticlePacket(byte particleId, double posX, double posY, double posZ, int aditionalData) { + this.particleId = particleId; + this.posX = posX; + this.posY = posY; + this.posZ = posZ; + this.additionalData = aditionalData; + } - @Override - public void fromBytes(ByteBuf bytes){ - this.particleId = bytes.readByte(); - this.posX = (double)bytes.readFloat(); - this.posY = (double)bytes.readFloat(); - this.posZ = (double)bytes.readFloat(); + @Override + public void fromBytes(ByteBuf bytes) { + this.particleId = bytes.readByte(); + this.posX = (double) bytes.readFloat(); + this.posY = (double) bytes.readFloat(); + this.posZ = (double) bytes.readFloat(); - if (particleId == ARROW_SHOCK_WAVE) { - this.additionalData = bytes.readInt(); - } - } + if (particleId == ARROW_SHOCK_WAVE) { + this.additionalData = bytes.readInt(); + } + } - @Override - public void toBytes(ByteBuf bytes){ - bytes.writeByte(particleId); - bytes.writeFloat((float)posX); - bytes.writeFloat((float)posY); - bytes.writeFloat((float)posZ); + @Override + public void toBytes(ByteBuf bytes) { + bytes.writeByte(particleId); + bytes.writeFloat((float) posX); + bytes.writeFloat((float) posY); + bytes.writeFloat((float) posZ); - if (particleId == ARROW_SHOCK_WAVE) { - bytes.writeInt(additionalData); - } - } + if (particleId == ARROW_SHOCK_WAVE) { + bytes.writeInt(additionalData); + } + } - public static class Handler implements IMessageHandler { + public static class Handler implements IMessageHandler { - @SideOnly(Side.CLIENT) - @Override - public IMessage onMessage(GenericParticlePacket message, MessageContext ctx) { - switch (message.particleId) { - case ENERGY_BALL_KILL: - { - Particles.DragonProjectileParticle particle; - for (int i = 0; i < 100; i++){ - particle = new Particles.DragonProjectileParticle(BrandonsCore.proxy.getClientWorld(), message.posX, message.posY, message.posZ, 0x00FFFF); - double m = 0.5D; - particle.motionX = (particle.worldObj.rand.nextDouble() - 0.5) * m; - particle.motionY = (particle.worldObj.rand.nextDouble() - 0.5) * m; - particle.motionZ = (particle.worldObj.rand.nextDouble() - 0.5) * m; - ParticleHandler.spawnCustomParticle(particle); - } - break; - } - case CHAOS_BALL_KILL: - { - Particles.DragonProjectileParticle particle; - for (int i = 0; i < 100; i++){ - particle = new Particles.DragonProjectileParticle(BrandonsCore.proxy.getClientWorld(), message.posX, message.posY, message.posZ, 0x440000); - double m = 0.5D; - particle.motionX = (particle.worldObj.rand.nextDouble() - 0.5) * m; - particle.motionY = (particle.worldObj.rand.nextDouble() - 0.5) * m; - particle.motionZ = (particle.worldObj.rand.nextDouble() - 0.5) * m; - ParticleHandler.spawnCustomParticle(particle); - } - break; - } - case CHAOS_IMPLOSION: - { - ParticleHandler.spawnCustomParticle(new Particles.ChaosImplosionParticle(BrandonsCore.proxy.getClientWorld(), message.posX, message.posY, message.posZ, 200F), 512); - break; - } - case ARROW_SHOCK_WAVE: - { - ParticleHandler.spawnCustomParticle(new Particles.ArrowShockParticle(BrandonsCore.proxy.getClientWorld(), message.posX, message.posY, message.posZ, message.additionalData), 256); - for (int i = 0; i < 100; i++){ - Particles.ArrowParticle particle = new Particles.ArrowParticle(BrandonsCore.proxy.getClientWorld(), - message.posX - 0.25 + BrandonsCore.proxy.getClientWorld().rand.nextDouble() * 0.5, - message.posY + BrandonsCore.proxy.getClientWorld().rand.nextDouble() * 0.5, - message.posZ - 0.25 + BrandonsCore.proxy.getClientWorld().rand.nextDouble() * 0.5, - 0xff6000, - 0.2F+BrandonsCore.proxy.getClientWorld().rand.nextFloat()*10f); + @SideOnly(Side.CLIENT) + @Override + public IMessage onMessage(GenericParticlePacket message, MessageContext ctx) { + switch (message.particleId) { + case ENERGY_BALL_KILL: { + Particles.DragonProjectileParticle particle; + for (int i = 0; i < 100; i++) { + particle = new Particles.DragonProjectileParticle(BrandonsCore.proxy.getClientWorld(), message.posX, message.posY, message.posZ, 0x00FFFF); + double m = 0.5D; + particle.motionX = (particle.worldObj.rand.nextDouble() - 0.5) * m; + particle.motionY = (particle.worldObj.rand.nextDouble() - 0.5) * m; + particle.motionZ = (particle.worldObj.rand.nextDouble() - 0.5) * m; + ParticleHandler.spawnCustomParticle(particle); + } + break; + } + case CHAOS_BALL_KILL: { + Particles.DragonProjectileParticle particle; + for (int i = 0; i < 100; i++) { + particle = new Particles.DragonProjectileParticle(BrandonsCore.proxy.getClientWorld(), message.posX, message.posY, message.posZ, 0x440000); + double m = 0.5D; + particle.motionX = (particle.worldObj.rand.nextDouble() - 0.5) * m; + particle.motionY = (particle.worldObj.rand.nextDouble() - 0.5) * m; + particle.motionZ = (particle.worldObj.rand.nextDouble() - 0.5) * m; + ParticleHandler.spawnCustomParticle(particle); + } + break; + } + case CHAOS_IMPLOSION: { + ParticleHandler.spawnCustomParticle(new Particles.ChaosImplosionParticle(BrandonsCore.proxy.getClientWorld(), message.posX, message.posY, message.posZ, 200F), 512); + break; + } + case ARROW_SHOCK_WAVE: { + ParticleHandler.spawnCustomParticle(new Particles.ArrowShockParticle(BrandonsCore.proxy.getClientWorld(), message.posX, message.posY, message.posZ, message.additionalData), 256); + for (int i = 0; i < 100; i++) { + Particles.ArrowParticle particle = new Particles.ArrowParticle(BrandonsCore.proxy.getClientWorld(), message.posX - 0.25 + BrandonsCore.proxy.getClientWorld().rand.nextDouble() * 0.5, message.posY + BrandonsCore.proxy.getClientWorld().rand.nextDouble() * 0.5, message.posZ - 0.25 + BrandonsCore.proxy.getClientWorld().rand.nextDouble() * 0.5, 0xff6000, 0.2F + BrandonsCore.proxy.getClientWorld().rand.nextFloat() * 10f); - double mm = 2; - particle.motionX = (BrandonsCore.proxy.getClientWorld().rand.nextDouble() - 0.5) * mm; - particle.motionY = (BrandonsCore.proxy.getClientWorld().rand.nextDouble() - 0.5) * mm; - particle.motionZ = (BrandonsCore.proxy.getClientWorld().rand.nextDouble() - 0.5) * mm; - ParticleHandler.spawnCustomParticle(particle, 64); - } - break; - } + double mm = 2; + particle.motionX = (BrandonsCore.proxy.getClientWorld().rand.nextDouble() - 0.5) * mm; + particle.motionY = (BrandonsCore.proxy.getClientWorld().rand.nextDouble() - 0.5) * mm; + particle.motionZ = (BrandonsCore.proxy.getClientWorld().rand.nextDouble() - 0.5) * mm; + ParticleHandler.spawnCustomParticle(particle, 64); + } + break; + } - default: - break; - } - return null; - } - } + default: + break; + } + return null; + } + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/network/ItemConfigPacket.java b/src/main/java/com/brandon3055/draconicevolution/common/network/ItemConfigPacket.java index 98f1a1ca..420fa3e7 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/network/ItemConfigPacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/network/ItemConfigPacket.java @@ -15,80 +15,80 @@ import net.minecraft.item.ItemStack; import java.util.List; -public class ItemConfigPacket implements IMessage -{ - public byte datatype; - public int slot; - public Object value; - public String name; - public boolean renameProfile = false; +public class ItemConfigPacket implements IMessage { + public byte datatype; + public int slot; + public Object value; + public String name; + public boolean renameProfile = false; - public ItemConfigPacket() {} + public ItemConfigPacket() { + } - public ItemConfigPacket(ItemConfigField field) { - this.datatype = (byte)field.datatype; - this.slot = field.slot; - this.value = field.value; - this.name = field.name; - } + public ItemConfigPacket(ItemConfigField field) { + this.datatype = (byte) field.datatype; + this.slot = field.slot; + this.value = field.value; + this.name = field.name; + } - public ItemConfigPacket(int slot, String name) { - this.datatype = References.BOOLEAN_ID; - this.slot = slot; - this.value = false; - this.name = name; - this.renameProfile = true; - } + public ItemConfigPacket(int slot, String name) { + this.datatype = References.BOOLEAN_ID; + this.slot = slot; + this.value = false; + this.name = name; + this.renameProfile = true; + } - @Override - public void fromBytes(ByteBuf bytes){ - this.datatype = bytes.readByte(); - this.slot = bytes.readInt(); - this.name = ByteBufUtils.readUTF8String(bytes); - this.value = DataUtills.instance.readObjectFromBytes(bytes, datatype); - this.renameProfile = bytes.readBoolean(); - } + @Override + public void fromBytes(ByteBuf bytes) { + this.datatype = bytes.readByte(); + this.slot = bytes.readInt(); + this.name = ByteBufUtils.readUTF8String(bytes); + this.value = DataUtills.instance.readObjectFromBytes(bytes, datatype); + this.renameProfile = bytes.readBoolean(); + } - @Override - public void toBytes(ByteBuf bytes){ - bytes.writeByte(datatype); - bytes.writeInt(slot); - ByteBufUtils.writeUTF8String(bytes, name); - DataUtills.instance.writeObjectToBytes(bytes, datatype, value); - bytes.writeBoolean(renameProfile); - } + @Override + public void toBytes(ByteBuf bytes) { + bytes.writeByte(datatype); + bytes.writeInt(slot); + ByteBufUtils.writeUTF8String(bytes, name); + DataUtills.instance.writeObjectToBytes(bytes, datatype, value); + bytes.writeBoolean(renameProfile); + } - public static class Handler implements IMessageHandler { + public static class Handler implements IMessageHandler { - @Override - public IMessage onMessage(ItemConfigPacket message, MessageContext ctx) { - EntityPlayer player = ctx.getServerHandler().playerEntity; + @Override + public IMessage onMessage(ItemConfigPacket message, MessageContext ctx) { + EntityPlayer player = ctx.getServerHandler().playerEntity; - if (message.slot >= player.inventory.getSizeInventory() || message.slot < 0) return null; + if (message.slot >= player.inventory.getSizeInventory() || message.slot < 0) return null; - ItemStack stack = player.inventory.getStackInSlot(message.slot); + ItemStack stack = player.inventory.getStackInSlot(message.slot); - if (stack != null && stack.getItem() instanceof IConfigurableItem) { + if (stack != null && stack.getItem() instanceof IConfigurableItem) { - if (message.renameProfile){ - ItemNBTHelper.setString(stack, "ProfileName" + ItemNBTHelper.getInteger(stack, "ConfigProfile", 0), message.name); - return null; - } + if (message.renameProfile) { + ItemNBTHelper.setString(stack, "ProfileName" + ItemNBTHelper.getInteger(stack, "ConfigProfile", 0), message.name); + return null; + } - IConfigurableItem item = (IConfigurableItem) stack.getItem(); - List fields = item.getFields(stack, message.slot); + IConfigurableItem item = (IConfigurableItem) stack.getItem(); + List fields = item.getFields(stack, message.slot); - for (ItemConfigField field : fields){ - if (field.name.equals(message.name) && message.datatype == field.datatype){ - ItemConfigField newValue = new ItemConfigField(message.datatype, message.value, message.slot, message.name); + for (ItemConfigField field : fields) { + if (field.name.equals(message.name) && message.datatype == field.datatype) { + ItemConfigField newValue = new ItemConfigField(message.datatype, message.value, message.slot, message.name); - if (newValue.castToDouble() <= field.castMaxToDouble() && newValue.castToDouble() >= field.castMinToDouble()){ - DataUtills.writeObjectToCompound(IConfigurableItem.ProfileHelper.getProfileCompound(stack), message.value, message.datatype, message.name); - } - } - } - } - return null; - } - } + if (newValue.castToDouble() <= field.castMaxToDouble() && newValue.castToDouble() >= field.castMinToDouble()) { + DataUtills.writeObjectToCompound(IConfigurableItem.ProfileHelper.getProfileCompound(stack), message.value, message.datatype, message.name); + } + } + } + } + return null; + } + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/network/MountUpdatePacket.java b/src/main/java/com/brandon3055/draconicevolution/common/network/MountUpdatePacket.java index 8a088649..2392cd94 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/network/MountUpdatePacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/network/MountUpdatePacket.java @@ -12,41 +12,41 @@ import io.netty.buffer.ByteBuf; */ public class MountUpdatePacket implements IMessage { - public int entityID; + public int entityID; - public MountUpdatePacket(){} + public MountUpdatePacket() { + } - public MountUpdatePacket(int id){ - this.entityID = id; - } + public MountUpdatePacket(int id) { + this.entityID = id; + } - @Override - public void toBytes(ByteBuf buf) { - buf.writeInt(entityID); - } + @Override + public void toBytes(ByteBuf buf) { + buf.writeInt(entityID); + } - @Override - public void fromBytes(ByteBuf buf) { - entityID = buf.readInt(); - } + @Override + public void fromBytes(ByteBuf buf) { + entityID = buf.readInt(); + } - public static class Handler implements IMessageHandler { + public static class Handler implements IMessageHandler { - @Override - public IMessage onMessage(MountUpdatePacket message, MessageContext ctx) { - if (ctx.side.equals(Side.SERVER)){ - if (message.entityID == -1){ - ctx.getServerHandler().playerEntity.mountEntity(null); - return null; - } - else if (ctx.getServerHandler().playerEntity.ridingEntity != null){ - return new MountUpdatePacket(ctx.getServerHandler().playerEntity.ridingEntity.getEntityId()); - } - return null; - } + @Override + public IMessage onMessage(MountUpdatePacket message, MessageContext ctx) { + if (ctx.side.equals(Side.SERVER)) { + if (message.entityID == -1) { + ctx.getServerHandler().playerEntity.mountEntity(null); + return null; + } else if (ctx.getServerHandler().playerEntity.ridingEntity != null) { + return new MountUpdatePacket(ctx.getServerHandler().playerEntity.ridingEntity.getEntityId()); + } + return null; + } - ClientEventHandler.tryRepositionPlayerOnMount(message.entityID); - return null; - } - } + ClientEventHandler.tryRepositionPlayerOnMount(message.entityID); + return null; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/network/ParticleGenPacket.java b/src/main/java/com/brandon3055/draconicevolution/common/network/ParticleGenPacket.java index a28ac011..7a6efedb 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/network/ParticleGenPacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/network/ParticleGenPacket.java @@ -14,308 +14,304 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; -public class ParticleGenPacket implements IMessage -{ - byte buttonId = 0; - short value = 0; - int tileX = 0; - int tileY = 0; - int tileZ = 0; +public class ParticleGenPacket implements IMessage { + byte buttonId = 0; + short value = 0; + int tileX = 0; + int tileY = 0; + int tileZ = 0; - public ParticleGenPacket() {} + public ParticleGenPacket() { + } - public ParticleGenPacket(byte buttonId, short value, int x, int y, int z) { - this.buttonId = buttonId; - this.value = value; - this.tileX = x; - this.tileY = y; - this.tileZ = z; - } + public ParticleGenPacket(byte buttonId, short value, int x, int y, int z) { + this.buttonId = buttonId; + this.value = value; + this.tileX = x; + this.tileY = y; + this.tileZ = z; + } - @Override - public void toBytes(ByteBuf bytes){ - bytes.writeByte(buttonId); - bytes.writeShort(value); - bytes.writeInt(tileX); - bytes.writeInt(tileY); - bytes.writeInt(tileZ); - } + @Override + public void toBytes(ByteBuf bytes) { + bytes.writeByte(buttonId); + bytes.writeShort(value); + bytes.writeInt(tileX); + bytes.writeInt(tileY); + bytes.writeInt(tileZ); + } - @Override - public void fromBytes(ByteBuf bytes){ - this.buttonId = bytes.readByte(); - this.value = bytes.readShort(); - this.tileX = bytes.readInt(); - this.tileY = bytes.readInt(); - this.tileZ = bytes.readInt(); - } + @Override + public void fromBytes(ByteBuf bytes) { + this.buttonId = bytes.readByte(); + this.value = bytes.readShort(); + this.tileX = bytes.readInt(); + this.tileY = bytes.readInt(); + this.tileZ = bytes.readInt(); + } - public static class Handler implements IMessageHandler { + public static class Handler implements IMessageHandler { - @Override - public IMessage onMessage(ParticleGenPacket message, MessageContext ctx) { - TileEntity tile = ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.tileX, message.tileY, message.tileZ); - TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator)tile : null; - if (gen != null) - { - //System.out.println(buttonId + " " + value); - switch (message.buttonId) { - case 0://red - gen.red = (int) message.value; - break; - case 1://green - gen.green = (int) message.value; - break; - case 2://blue - gen.blue = (int) message.value; - break; - case 3://mx - gen.motion_x = (float) message.value / 1000F; - break; - case 4://my - gen.motion_y = (float) message.value / 1000F; - break; - case 5://mz - gen.motion_z = (float) message.value / 1000F; - break; - case 6://ged - gen.red = (int) message.value; - break; - case 7://green - gen.green = (int) message.value; - break; - case 8://blue - gen.blue = (int) message.value; - break; - case 9://mx - gen.motion_x = (float) message.value / 1000F; - break; - case 10://my - gen.motion_y = (float) message.value / 1000F; - break; - case 11://mz - gen.motion_z = (float) message.value / 1000F; - break; - case 12://red - gen.random_red = (int) message.value; - break; - case 13://green - gen.random_green = (int) message.value; - break; - case 14://blue - gen.random_blue = (int) message.value; - break; - case 15://mx - gen.random_motion_x = (float) message.value / 1000F; - break; - case 16://my - gen.random_motion_y = (float) message.value / 1000F; - break; - case 17://mz - gen.random_motion_z = (float) message.value / 1000F; - break; - case 18://ged - gen.random_red = (int) message.value; - break; - case 19://green - gen.random_green = (int) message.value; - break; - case 20://blue - gen.random_blue = (int) message.value; - break; - case 21://mx - gen.random_motion_x = (float) message.value / 1000F; - break; - case 22://my - gen.random_motion_y = (float) message.value / 1000F; - break; - case 23://mz - gen.random_motion_z = (float) message.value / 1000F; - break; - case 24://Life + - gen.life = (int) message.value; - break; - case 25://Life - - gen.life = (int) message.value; - break; - case 26://RLife + - gen.random_life = (int) message.value; - break; - case 27://RLife - - gen.random_life = (int) message.value; - break; - case 28://Size + - gen.scale = (float) message.value / 100F; - break; - case 29://Size - - gen.scale = (float) message.value / 100F; - break; - case 30://RSize + - gen.random_scale = (float) message.value / 100F; - break; - case 31://RSize - - gen.random_scale = (float) message.value / 100F; - break; - case 32://SX + - gen.page = (int) message.value; - break; - case 33://SX - - gen.page = (int) message.value; - break; - case 34://SX + - gen.spawn_x = (float) message.value / 100F; - break; - case 35://SX - - gen.spawn_x = (float) message.value / 100F; - break; - case 36://RSX + - gen.random_spawn_x = (float) message.value / 100F; - break; - case 37://RSX - - gen.random_spawn_x = (float) message.value / 100F; - break; - case 38://SY + - gen.spawn_y = (float) message.value / 100F; - break; - case 39://SY - - gen.spawn_y = (float) message.value / 100F; - break; - case 40://RSY + - gen.random_spawn_y = (float) message.value / 100F; - break; - case 41://RSY - - gen.random_spawn_y = (float) message.value / 100F; - break; - case 42://SZ + - gen.spawn_z = (float) message.value / 100F; - break; - case 43://SZ - - gen.spawn_z = (float) message.value / 100F; - break; - case 44://RSZ + - gen.random_spawn_z = (float) message.value / 100F; - break; - case 45://RSZ - - gen.random_spawn_z = (float) message.value / 100F; - break; - case 46://Delay - - gen.spawn_rate = (int) message.value; - break; - case 47://Delay - - gen.spawn_rate = (int) message.value; - break; - case 48://Fade - - gen.fade = (int) message.value; - break; - case 49://Fade - - gen.fade = (int) message.value; - break; - case 50://Collision - - gen.collide = message.value == 0 ? false : true; - break; - case 51://Particle Selected - - gen.selected_particle = (int) message.value; - break; - case 52://Gravity + - gen.gravity = (float) message.value / 1000F; - break; - case 53://Gravity - - gen.gravity = (float) message.value / 1000F; - break; - case 54://Info Page (3) - gen.page = (int) message.value; - break; - case 55://Back - gen.page = (int) message.value; - break; - case 58://Back - LogHelper.info(message.value); - gen.particles_enabled = message.value == 1; - break; + @Override + public IMessage onMessage(ParticleGenPacket message, MessageContext ctx) { + TileEntity tile = ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.tileX, message.tileY, message.tileZ); + TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator) tile : null; + if (gen != null) { + //System.out.println(buttonId + " " + value); + switch (message.buttonId) { + case 0://red + gen.red = (int) message.value; + break; + case 1://green + gen.green = (int) message.value; + break; + case 2://blue + gen.blue = (int) message.value; + break; + case 3://mx + gen.motion_x = (float) message.value / 1000F; + break; + case 4://my + gen.motion_y = (float) message.value / 1000F; + break; + case 5://mz + gen.motion_z = (float) message.value / 1000F; + break; + case 6://ged + gen.red = (int) message.value; + break; + case 7://green + gen.green = (int) message.value; + break; + case 8://blue + gen.blue = (int) message.value; + break; + case 9://mx + gen.motion_x = (float) message.value / 1000F; + break; + case 10://my + gen.motion_y = (float) message.value / 1000F; + break; + case 11://mz + gen.motion_z = (float) message.value / 1000F; + break; + case 12://red + gen.random_red = (int) message.value; + break; + case 13://green + gen.random_green = (int) message.value; + break; + case 14://blue + gen.random_blue = (int) message.value; + break; + case 15://mx + gen.random_motion_x = (float) message.value / 1000F; + break; + case 16://my + gen.random_motion_y = (float) message.value / 1000F; + break; + case 17://mz + gen.random_motion_z = (float) message.value / 1000F; + break; + case 18://ged + gen.random_red = (int) message.value; + break; + case 19://green + gen.random_green = (int) message.value; + break; + case 20://blue + gen.random_blue = (int) message.value; + break; + case 21://mx + gen.random_motion_x = (float) message.value / 1000F; + break; + case 22://my + gen.random_motion_y = (float) message.value / 1000F; + break; + case 23://mz + gen.random_motion_z = (float) message.value / 1000F; + break; + case 24://Life + + gen.life = (int) message.value; + break; + case 25://Life - + gen.life = (int) message.value; + break; + case 26://RLife + + gen.random_life = (int) message.value; + break; + case 27://RLife - + gen.random_life = (int) message.value; + break; + case 28://Size + + gen.scale = (float) message.value / 100F; + break; + case 29://Size - + gen.scale = (float) message.value / 100F; + break; + case 30://RSize + + gen.random_scale = (float) message.value / 100F; + break; + case 31://RSize - + gen.random_scale = (float) message.value / 100F; + break; + case 32://SX + + gen.page = (int) message.value; + break; + case 33://SX - + gen.page = (int) message.value; + break; + case 34://SX + + gen.spawn_x = (float) message.value / 100F; + break; + case 35://SX - + gen.spawn_x = (float) message.value / 100F; + break; + case 36://RSX + + gen.random_spawn_x = (float) message.value / 100F; + break; + case 37://RSX - + gen.random_spawn_x = (float) message.value / 100F; + break; + case 38://SY + + gen.spawn_y = (float) message.value / 100F; + break; + case 39://SY - + gen.spawn_y = (float) message.value / 100F; + break; + case 40://RSY + + gen.random_spawn_y = (float) message.value / 100F; + break; + case 41://RSY - + gen.random_spawn_y = (float) message.value / 100F; + break; + case 42://SZ + + gen.spawn_z = (float) message.value / 100F; + break; + case 43://SZ - + gen.spawn_z = (float) message.value / 100F; + break; + case 44://RSZ + + gen.random_spawn_z = (float) message.value / 100F; + break; + case 45://RSZ - + gen.random_spawn_z = (float) message.value / 100F; + break; + case 46://Delay - + gen.spawn_rate = (int) message.value; + break; + case 47://Delay - + gen.spawn_rate = (int) message.value; + break; + case 48://Fade - + gen.fade = (int) message.value; + break; + case 49://Fade - + gen.fade = (int) message.value; + break; + case 50://Collision - + gen.collide = message.value == 0 ? false : true; + break; + case 51://Particle Selected - + gen.selected_particle = (int) message.value; + break; + case 52://Gravity + + gen.gravity = (float) message.value / 1000F; + break; + case 53://Gravity - + gen.gravity = (float) message.value / 1000F; + break; + case 54://Info Page (3) + gen.page = (int) message.value; + break; + case 55://Back + gen.page = (int) message.value; + break; + case 58://Back + LogHelper.info(message.value); + gen.particles_enabled = message.value == 1; + break; - case 100: //beam red + - gen.beam_red = message.value; - break; - case 101: //beam green + - gen.beam_green = message.value; - break; - case 102: //beam blue + - gen.beam_blue = message.value; - break; - case 103: //beam pitch + - gen.beam_pitch = (float) message.value / 100F; - break; - case 104: //beam yaw + - gen.beam_yaw = (float) message.value / 100F; - break; - case 105: //beam length + - gen.beam_length = (float) message.value / 100F; - break; - case 106: //beam rotation + - gen.beam_rotation = (float) message.value / 100F; - break; - case 107: //beam scale + - gen.beam_scale = (float) message.value / 100F; - break; - case 108: //beam red - - gen.beam_red = message.value; - break; - case 109: //beam green - - gen.beam_green = message.value; - break; - case 110: //beam blue - - gen.beam_blue = message.value; - break; - case 111: //beam pitch - - gen.beam_pitch = (float) message.value / 100F; - break; - case 112: //beam yaw - - gen.beam_yaw = (float) message.value / 100F; - break; - case 113: //beam length - - gen.beam_length = (float) message.value / 100F; - break; - case 114: //beam rotation - - gen.beam_rotation = (float) message.value / 100F; - break; - case 115: //beam scale - - gen.beam_scale = (float) message.value / 100F; - break; - case 116: //beam enabled - gen.beam_enabled = message.value == 1; - break; - case 117: //beam enabled - gen.render_core = message.value == 1; - break; - } + case 100: //beam red + + gen.beam_red = message.value; + break; + case 101: //beam green + + gen.beam_green = message.value; + break; + case 102: //beam blue + + gen.beam_blue = message.value; + break; + case 103: //beam pitch + + gen.beam_pitch = (float) message.value / 100F; + break; + case 104: //beam yaw + + gen.beam_yaw = (float) message.value / 100F; + break; + case 105: //beam length + + gen.beam_length = (float) message.value / 100F; + break; + case 106: //beam rotation + + gen.beam_rotation = (float) message.value / 100F; + break; + case 107: //beam scale + + gen.beam_scale = (float) message.value / 100F; + break; + case 108: //beam red - + gen.beam_red = message.value; + break; + case 109: //beam green - + gen.beam_green = message.value; + break; + case 110: //beam blue - + gen.beam_blue = message.value; + break; + case 111: //beam pitch - + gen.beam_pitch = (float) message.value / 100F; + break; + case 112: //beam yaw - + gen.beam_yaw = (float) message.value / 100F; + break; + case 113: //beam length - + gen.beam_length = (float) message.value / 100F; + break; + case 114: //beam rotation - + gen.beam_rotation = (float) message.value / 100F; + break; + case 115: //beam scale - + gen.beam_scale = (float) message.value / 100F; + break; + case 116: //beam enabled + gen.beam_enabled = message.value == 1; + break; + case 117: //beam enabled + gen.render_core = message.value == 1; + break; + } - if (message.buttonId == 127) - { - if (ctx.getServerHandler().playerEntity.capabilities.isCreativeMode || ctx.getServerHandler().playerEntity.inventory.hasItem(Items.paper)) { - giveNote(message, ctx); - } - else ctx.getServerHandler().playerEntity.addChatComponentMessage(new ChatComponentText("You need paper in your inventory to do that")); - } + if (message.buttonId == 127) { + if (ctx.getServerHandler().playerEntity.capabilities.isCreativeMode || ctx.getServerHandler().playerEntity.inventory.hasItem(Items.paper)) { + giveNote(message, ctx); + } else + ctx.getServerHandler().playerEntity.addChatComponentMessage(new ChatComponentText("You need paper in your inventory to do that")); + } - ctx.getServerHandler().playerEntity.worldObj.markBlockForUpdate(message.tileX, message.tileY, message.tileZ); - } - return null; - } + ctx.getServerHandler().playerEntity.worldObj.markBlockForUpdate(message.tileX, message.tileY, message.tileZ); + } + return null; + } - private void giveNote(ParticleGenPacket message, MessageContext ctx) - { - EntityPlayer player = ctx.getServerHandler().playerEntity; - if (!player.capabilities.isCreativeMode) player.inventory.consumeInventoryItem(Items.paper); - ItemStack stack = new ItemStack(Items.paper); - stack.setTagCompound(new NBTTagCompound()); - TileEntity tile = ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.tileX, message.tileY, message.tileZ); - TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator)tile : null; - if (gen != null) - { - gen.getBlockNBT(stack.getTagCompound()); - stack.setStackDisplayName("Saved Particle Gen Settings"); - player.worldObj.spawnEntityInWorld(new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, stack)); - } - } - } + private void giveNote(ParticleGenPacket message, MessageContext ctx) { + EntityPlayer player = ctx.getServerHandler().playerEntity; + if (!player.capabilities.isCreativeMode) player.inventory.consumeInventoryItem(Items.paper); + ItemStack stack = new ItemStack(Items.paper); + stack.setTagCompound(new NBTTagCompound()); + TileEntity tile = ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.tileX, message.tileY, message.tileZ); + TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator) tile : null; + if (gen != null) { + gen.getBlockNBT(stack.getTagCompound()); + stack.setStackDisplayName("Saved Particle Gen Settings"); + player.worldObj.spawnEntityInWorld(new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, stack)); + } + } + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/network/PlacedItemPacket.java b/src/main/java/com/brandon3055/draconicevolution/common/network/PlacedItemPacket.java index 45ab2eb6..e1c592a0 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/network/PlacedItemPacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/network/PlacedItemPacket.java @@ -17,71 +17,72 @@ import net.minecraftforge.event.world.BlockEvent; /** * Created by Brandon on 14/08/2014. */ -public class PlacedItemPacket implements IMessage -{ - byte side = 0; - int blockX = 0; - int blockY = 0; - int blockZ = 0; +public class PlacedItemPacket implements IMessage { + byte side = 0; + int blockX = 0; + int blockY = 0; + int blockZ = 0; - public PlacedItemPacket() {} + public PlacedItemPacket() { + } - public PlacedItemPacket(byte side, int x, int y, int z) { - this.side = side; - this.blockX = x; - this.blockY = y; - this.blockZ = z; - } + public PlacedItemPacket(byte side, int x, int y, int z) { + this.side = side; + this.blockX = x; + this.blockY = y; + this.blockZ = z; + } - @Override - public void toBytes(ByteBuf bytes){ - bytes.writeByte(side); - bytes.writeInt(blockX); - bytes.writeInt(blockY); - bytes.writeInt(blockZ); - } + @Override + public void toBytes(ByteBuf bytes) { + bytes.writeByte(side); + bytes.writeInt(blockX); + bytes.writeInt(blockY); + bytes.writeInt(blockZ); + } - @Override - public void fromBytes(ByteBuf bytes){ - this.side = bytes.readByte(); - this.blockX = bytes.readInt(); - this.blockY = bytes.readInt(); - this.blockZ = bytes.readInt(); - } + @Override + public void fromBytes(ByteBuf bytes) { + this.side = bytes.readByte(); + this.blockX = bytes.readInt(); + this.blockY = bytes.readInt(); + this.blockZ = bytes.readInt(); + } - public static class Handler implements IMessageHandler { + public static class Handler implements IMessageHandler { - @Override - public IMessage onMessage(PlacedItemPacket message, MessageContext ctx) { - ForgeDirection dir = ForgeDirection.getOrientation(message.side); - int x = message.blockX+dir.offsetX; - int y = message.blockY+dir.offsetY; - int z = message.blockZ+dir.offsetZ; - World world = ctx.getServerHandler().playerEntity.worldObj; - EntityPlayer player = ctx.getServerHandler().playerEntity; + @Override + public IMessage onMessage(PlacedItemPacket message, MessageContext ctx) { + ForgeDirection dir = ForgeDirection.getOrientation(message.side); + int x = message.blockX + dir.offsetX; + int y = message.blockY + dir.offsetY; + int z = message.blockZ + dir.offsetZ; + World world = ctx.getServerHandler().playerEntity.worldObj; + EntityPlayer player = ctx.getServerHandler().playerEntity; - if (!world.isAirBlock(x, y, z) || player.getHeldItem() == null || !ModBlocks.isEnabled(ModBlocks.placedItem)) return null; + if (!world.isAirBlock(x, y, z) || player.getHeldItem() == null || !ModBlocks.isEnabled(ModBlocks.placedItem)) + return null; BlockEvent.PlaceEvent event = new BlockEvent.PlaceEvent(new BlockSnapshot(world, x, y, z, ModBlocks.placedItem, 0), world.getBlock(message.blockX, message.blockY, message.blockZ), player); MinecraftForge.EVENT_BUS.post(event); - if (event.isCanceled()){ + if (event.isCanceled()) { return null; } - ItemStack stack = player.getHeldItem(); + ItemStack stack = player.getHeldItem(); - world.setBlock(x, y, z, ModBlocks.placedItem, message.side, 2); - TilePlacedItem tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TilePlacedItem) ? (TilePlacedItem) world.getTileEntity(x, y, z) : null; + world.setBlock(x, y, z, ModBlocks.placedItem, message.side, 2); + TilePlacedItem tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TilePlacedItem) ? (TilePlacedItem) world.getTileEntity(x, y, z) : null; - if (tile == null){ - world.setBlockToAir(x, y, z); - return null; - } + if (tile == null) { + world.setBlockToAir(x, y, z); + return null; + } - tile.setStack(stack.copy()); - player.destroyCurrentEquippedItem(); - return null; - } - } + tile.setStack(stack.copy()); + player.destroyCurrentEquippedItem(); + return null; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/network/PlayerDetectorButtonPacket.java b/src/main/java/com/brandon3055/draconicevolution/common/network/PlayerDetectorButtonPacket.java index f085a067..a53e87a2 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/network/PlayerDetectorButtonPacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/network/PlayerDetectorButtonPacket.java @@ -8,54 +8,52 @@ import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -public class PlayerDetectorButtonPacket implements IMessage -{ - private short index = 0; - private short value = 0; - - public PlayerDetectorButtonPacket() {} +public class PlayerDetectorButtonPacket implements IMessage { + private short index = 0; + private short value = 0; - public PlayerDetectorButtonPacket(byte index, short value) { - this.index = index; - this.value = value; - } + public PlayerDetectorButtonPacket() { + } - @Override - public void toBytes(ByteBuf bytes){ - bytes.writeByte(index); - bytes.writeByte(value); - } - - @Override - public void fromBytes(ByteBuf bytes){ - index = bytes.readByte(); - value = bytes.readByte(); - } + public PlayerDetectorButtonPacket(byte index, short value) { + this.index = index; + this.value = value; + } - public static class Handler implements IMessageHandler { + @Override + public void toBytes(ByteBuf bytes) { + bytes.writeByte(index); + bytes.writeByte(value); + } - @Override - public IMessage onMessage(PlayerDetectorButtonPacket message, MessageContext ctx) { - ContainerPlayerDetector container = (ctx.getServerHandler().playerEntity.openContainer instanceof ContainerPlayerDetector) ? (ContainerPlayerDetector)ctx.getServerHandler().playerEntity.openContainer : null; - TilePlayerDetectorAdvanced tile = (container != null) ? ((ContainerPlayerDetector)container).getTileDetector() : null; + @Override + public void fromBytes(ByteBuf bytes) { + index = bytes.readByte(); + value = bytes.readByte(); + } - if (tile != null) - { - switch (message.index) - { - case 0: - tile.range = message.value; - break; - case 1: - tile.whiteList = message.value == 1; - break; - case 2: - tile.outputInverted = message.value == 1; - break; - } - ctx.getServerHandler().playerEntity.worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord); - } - return null; - } - } + public static class Handler implements IMessageHandler { + + @Override + public IMessage onMessage(PlayerDetectorButtonPacket message, MessageContext ctx) { + ContainerPlayerDetector container = (ctx.getServerHandler().playerEntity.openContainer instanceof ContainerPlayerDetector) ? (ContainerPlayerDetector) ctx.getServerHandler().playerEntity.openContainer : null; + TilePlayerDetectorAdvanced tile = (container != null) ? ((ContainerPlayerDetector) container).getTileDetector() : null; + + if (tile != null) { + switch (message.index) { + case 0: + tile.range = message.value; + break; + case 1: + tile.whiteList = message.value == 1; + break; + case 2: + tile.outputInverted = message.value == 1; + break; + } + ctx.getServerHandler().playerEntity.worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord); + } + return null; + } + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/network/PlayerDetectorStringPacket.java b/src/main/java/com/brandon3055/draconicevolution/common/network/PlayerDetectorStringPacket.java index 37faa54c..dbdd83e6 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/network/PlayerDetectorStringPacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/network/PlayerDetectorStringPacket.java @@ -9,43 +9,42 @@ import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -public class PlayerDetectorStringPacket implements IMessage -{ - private int index = 0; - private String name = ""; - - public PlayerDetectorStringPacket() {} +public class PlayerDetectorStringPacket implements IMessage { + private int index = 0; + private String name = ""; - public PlayerDetectorStringPacket(byte index, String name) { - this.index = index; - this.name = name; - } + public PlayerDetectorStringPacket() { + } - @Override - public void toBytes(ByteBuf bytes){ - bytes.writeByte(index); - ByteBufUtils.writeUTF8String(bytes, name); - } - - @Override - public void fromBytes(ByteBuf bytes){ - index = bytes.readByte(); - name = ByteBufUtils.readUTF8String(bytes); - } + public PlayerDetectorStringPacket(byte index, String name) { + this.index = index; + this.name = name; + } - public static class Handler implements IMessageHandler { + @Override + public void toBytes(ByteBuf bytes) { + bytes.writeByte(index); + ByteBufUtils.writeUTF8String(bytes, name); + } - @Override - public IMessage onMessage(PlayerDetectorStringPacket message, MessageContext ctx) { - ContainerPlayerDetector container = (ctx.getServerHandler().playerEntity.openContainer instanceof ContainerPlayerDetector) ? (ContainerPlayerDetector)ctx.getServerHandler().playerEntity.openContainer : null; - TilePlayerDetectorAdvanced tile = (container != null) ? container.getTileDetector() : null; + @Override + public void fromBytes(ByteBuf bytes) { + index = bytes.readByte(); + name = ByteBufUtils.readUTF8String(bytes); + } - if (tile != null) - { - tile.names[message.index] = message.name; - ctx.getServerHandler().playerEntity.worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord); - } - return null; - } - } + public static class Handler implements IMessageHandler { + + @Override + public IMessage onMessage(PlayerDetectorStringPacket message, MessageContext ctx) { + ContainerPlayerDetector container = (ctx.getServerHandler().playerEntity.openContainer instanceof ContainerPlayerDetector) ? (ContainerPlayerDetector) ctx.getServerHandler().playerEntity.openContainer : null; + TilePlayerDetectorAdvanced tile = (container != null) ? container.getTileDetector() : null; + + if (tile != null) { + tile.names[message.index] = message.name; + ctx.getServerHandler().playerEntity.worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord); + } + return null; + } + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/network/ShieldHitPacket.java b/src/main/java/com/brandon3055/draconicevolution/common/network/ShieldHitPacket.java index 4be1b01f..d2fca0af 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/network/ShieldHitPacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/network/ShieldHitPacket.java @@ -13,39 +13,40 @@ import net.minecraft.entity.player.EntityPlayer; /** * Created by brandon3055 on 15/2/2016. */ -public class ShieldHitPacket implements IMessage -{ - public int playerID; - public byte shieldPowerB; - public float shieldPowerF; +public class ShieldHitPacket implements IMessage { + public int playerID; + public byte shieldPowerB; + public float shieldPowerF; - public ShieldHitPacket() {} + public ShieldHitPacket() { + } - public ShieldHitPacket(EntityPlayer playerHit, float shieldPower) { - this.playerID = playerHit.getEntityId(); - this.shieldPowerB = (byte)(shieldPower * (float)Byte.MAX_VALUE); - } + public ShieldHitPacket(EntityPlayer playerHit, float shieldPower) { + this.playerID = playerHit.getEntityId(); + this.shieldPowerB = (byte) (shieldPower * (float) Byte.MAX_VALUE); + } - @Override - public void fromBytes(ByteBuf bytes){ - playerID = bytes.readInt(); - shieldPowerB = bytes.readByte(); - shieldPowerF = (float)shieldPowerB / (float)Byte.MAX_VALUE; - } + @Override + public void fromBytes(ByteBuf bytes) { + playerID = bytes.readInt(); + shieldPowerB = bytes.readByte(); + shieldPowerF = (float) shieldPowerB / (float) Byte.MAX_VALUE; + } - @Override - public void toBytes(ByteBuf bytes){ - bytes.writeInt(playerID); - bytes.writeByte(shieldPowerB); - } + @Override + public void toBytes(ByteBuf bytes) { + bytes.writeInt(playerID); + bytes.writeByte(shieldPowerB); + } - public static class Handler implements IMessageHandler { + public static class Handler implements IMessageHandler { - @Override - public IMessage onMessage(ShieldHitPacket message, MessageContext ctx) { - Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(message.playerID); - if (entity instanceof EntityPlayer) ClientEventHandler.playerShieldStatus.put((EntityPlayer)entity, new DataUtills.XZPair(message.shieldPowerF, ClientEventHandler.elapsedTicks)); - return null; - } - } + @Override + public IMessage onMessage(ShieldHitPacket message, MessageContext ctx) { + Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(message.playerID); + if (entity instanceof EntityPlayer) + ClientEventHandler.playerShieldStatus.put((EntityPlayer) entity, new DataUtills.XZPair(message.shieldPowerF, ClientEventHandler.elapsedTicks)); + return null; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/network/SpeedRequestPacket.java b/src/main/java/com/brandon3055/draconicevolution/common/network/SpeedRequestPacket.java index 9acad073..b9e6ae59 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/network/SpeedRequestPacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/network/SpeedRequestPacket.java @@ -13,42 +13,41 @@ import io.netty.buffer.ByteBuf; /** * Created by Brandon on 26/03/2015. */ -public class SpeedRequestPacket implements IMessage -{ - double speed = 0F; +public class SpeedRequestPacket implements IMessage { + double speed = 0F; - public SpeedRequestPacket() {} + public SpeedRequestPacket() { + } - public SpeedRequestPacket(double speed) { - this.speed = speed; - } + public SpeedRequestPacket(double speed) { + this.speed = speed; + } - @Override - public void toBytes(ByteBuf bytes){ - bytes.writeDouble(speed); - } + @Override + public void toBytes(ByteBuf bytes) { + bytes.writeDouble(speed); + } - @Override - public void fromBytes(ByteBuf bytes){ - this.speed = bytes.readDouble(); - } + @Override + public void fromBytes(ByteBuf bytes) { + this.speed = bytes.readDouble(); + } - public static class Handler implements IMessageHandler { + public static class Handler implements IMessageHandler { - @Override - public IMessage onMessage(SpeedRequestPacket message, MessageContext ctx) { - if (ctx.side == Side.SERVER) - { - if (ConfigHandler.speedLimitDimList.contains(ctx.getServerHandler().playerEntity.dimension) || (BrandonsCore.proxy.isOp(ctx.getServerHandler().playerEntity.getCommandSenderName()) && !ConfigHandler.speedLimitops)) return new SpeedRequestPacket(20F); - return new SpeedRequestPacket(ConfigHandler.maxPlayerSpeed); - } - else { - MinecraftForgeEventHandler.maxSpeed = message.speed; - MinecraftForgeEventHandler.ticksSinceRequest = 0; - MinecraftForgeEventHandler.speedNeedsUpdating = false; - LogHelper.info("Server speed is set to " + message.speed); - } - return null; - } - } + @Override + public IMessage onMessage(SpeedRequestPacket message, MessageContext ctx) { + if (ctx.side == Side.SERVER) { + if (ConfigHandler.speedLimitDimList.contains(ctx.getServerHandler().playerEntity.dimension) || (BrandonsCore.proxy.isOp(ctx.getServerHandler().playerEntity.getCommandSenderName()) && !ConfigHandler.speedLimitops)) + return new SpeedRequestPacket(20F); + return new SpeedRequestPacket(ConfigHandler.maxPlayerSpeed); + } else { + MinecraftForgeEventHandler.maxSpeed = message.speed; + MinecraftForgeEventHandler.ticksSinceRequest = 0; + MinecraftForgeEventHandler.speedNeedsUpdating = false; + LogHelper.info("Server speed is set to " + message.speed); + } + return null; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/network/TeleporterPacket.java b/src/main/java/com/brandon3055/draconicevolution/common/network/TeleporterPacket.java index e35d785b..49276b7f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/network/TeleporterPacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/network/TeleporterPacket.java @@ -15,250 +15,245 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class TeleporterPacket implements IMessage -{ - public static final int ADDDESTINATION = 0; - public static final int REMOVEDESTINATION = 1; - public static final int UPDATENAME = 2; - public static final int UPDATELOCK = 3; - public static final int CHANGESELECTION = 4; - public static final int UPDATEOFFSET = 5; - public static final int ADDFUEL = 6; - public static final int UPDATEDESTINATION = 7; - public static final int TELEPORT = 8; - public static final int SCROLL = 9; - public static final int MOVELOCATION = 10; +public class TeleporterPacket implements IMessage { + public static final int ADDDESTINATION = 0; + public static final int REMOVEDESTINATION = 1; + public static final int UPDATENAME = 2; + public static final int UPDATELOCK = 3; + public static final int CHANGESELECTION = 4; + public static final int UPDATEOFFSET = 5; + public static final int ADDFUEL = 6; + public static final int UPDATEDESTINATION = 7; + public static final int TELEPORT = 8; + public static final int SCROLL = 9; + public static final int MOVELOCATION = 10; - private int data = 0; - private boolean dataB; - private byte function = -1; - private TeleportLocation location; + private int data = 0; + private boolean dataB; + private byte function = -1; + private TeleportLocation location; - public TeleporterPacket() { - } + public TeleporterPacket() { + } - public TeleporterPacket(int function, int data, boolean b) { - this.data = data; - this.function = (byte) function; - this.dataB = b; - } + public TeleporterPacket(int function, int data, boolean b) { + this.data = data; + this.function = (byte) function; + this.dataB = b; + } - public TeleporterPacket(TeleportLocation location, int function) { - this.location = location; - this.function = (byte) function; - } + public TeleporterPacket(TeleportLocation location, int function) { + this.location = location; + this.function = (byte) function; + } - public TeleporterPacket(TeleportLocation location, int function, int data) { - this.data = data; - this.location = location; - this.function = (byte) function; - } + public TeleporterPacket(TeleportLocation location, int function, int data) { + this.data = data; + this.location = location; + this.function = (byte) function; + } - @Override - public void toBytes(ByteBuf bytes){ - bytes.writeByte(function); - if (function == ADDDESTINATION || function == UPDATEDESTINATION){ - bytes.writeDouble(location.getXCoord()); - bytes.writeDouble(location.getYCoord()); - bytes.writeDouble(location.getZCoord()); - bytes.writeInt(location.getDimension()); - bytes.writeFloat(location.getPitch()); - bytes.writeFloat(location.getYaw()); - ByteBufUtils.writeUTF8String(bytes, location.getName()); - //ByteBufUtils.writeUTF8String(bytes, location.getDimensionName()); - if (function == UPDATEDESTINATION) bytes.writeInt(data); - } + @Override + public void toBytes(ByteBuf bytes) { + bytes.writeByte(function); + if (function == ADDDESTINATION || function == UPDATEDESTINATION) { + bytes.writeDouble(location.getXCoord()); + bytes.writeDouble(location.getYCoord()); + bytes.writeDouble(location.getZCoord()); + bytes.writeInt(location.getDimension()); + bytes.writeFloat(location.getPitch()); + bytes.writeFloat(location.getYaw()); + ByteBufUtils.writeUTF8String(bytes, location.getName()); + //ByteBufUtils.writeUTF8String(bytes, location.getDimensionName()); + if (function == UPDATEDESTINATION) bytes.writeInt(data); + } - if (function == UPDATELOCK || function == MOVELOCATION){ - bytes.writeInt(data); - bytes.writeBoolean(dataB); - } + if (function == UPDATELOCK || function == MOVELOCATION) { + bytes.writeInt(data); + bytes.writeBoolean(dataB); + } - if (function == UPDATEOFFSET || function == CHANGESELECTION || function == REMOVEDESTINATION || function == ADDFUEL || function == SCROLL){ - bytes.writeInt(data); - } + if (function == UPDATEOFFSET || function == CHANGESELECTION || function == REMOVEDESTINATION || function == ADDFUEL || function == SCROLL) { + bytes.writeInt(data); + } - if (function == UPDATENAME){ - ByteBufUtils.writeUTF8String(bytes, location.getName()); - bytes.writeInt(data); - } + if (function == UPDATENAME) { + ByteBufUtils.writeUTF8String(bytes, location.getName()); + bytes.writeInt(data); + } - if (function == TELEPORT){ - bytes.writeInt(data); - } - } + if (function == TELEPORT) { + bytes.writeInt(data); + } + } - @Override - public void fromBytes(ByteBuf bytes){ - function = bytes.readByte(); - if (function == ADDDESTINATION || function == UPDATEDESTINATION){ - location = new TeleportLocation(); - location.setXCoord(bytes.readDouble()); - location.setYCoord(bytes.readDouble()); - location.setZCoord(bytes.readDouble()); - location.setDimension(bytes.readInt()); - location.setPitch(bytes.readFloat()); - location.setYaw(bytes.readFloat()); - location.setName(ByteBufUtils.readUTF8String(bytes)); - //location.setDimentionName(ByteBufUtils.readUTF8String(bytes)); - if (function == UPDATEDESTINATION) data = bytes.readInt(); - } + @Override + public void fromBytes(ByteBuf bytes) { + function = bytes.readByte(); + if (function == ADDDESTINATION || function == UPDATEDESTINATION) { + location = new TeleportLocation(); + location.setXCoord(bytes.readDouble()); + location.setYCoord(bytes.readDouble()); + location.setZCoord(bytes.readDouble()); + location.setDimension(bytes.readInt()); + location.setPitch(bytes.readFloat()); + location.setYaw(bytes.readFloat()); + location.setName(ByteBufUtils.readUTF8String(bytes)); + //location.setDimentionName(ByteBufUtils.readUTF8String(bytes)); + if (function == UPDATEDESTINATION) data = bytes.readInt(); + } - if (function == UPDATELOCK || function == MOVELOCATION){ - data = bytes.readInt(); - dataB = bytes.readBoolean(); - } + if (function == UPDATELOCK || function == MOVELOCATION) { + data = bytes.readInt(); + dataB = bytes.readBoolean(); + } - if (function == UPDATEOFFSET || function == CHANGESELECTION || function == REMOVEDESTINATION || function == ADDFUEL || function == SCROLL){ - data = bytes.readInt(); - } + if (function == UPDATEOFFSET || function == CHANGESELECTION || function == REMOVEDESTINATION || function == ADDFUEL || function == SCROLL) { + data = bytes.readInt(); + } - if (function == UPDATENAME){ - location = new TeleportLocation(); - location.setName(ByteBufUtils.readUTF8String(bytes)); - data = bytes.readInt(); - } + if (function == UPDATENAME) { + location = new TeleportLocation(); + location.setName(ByteBufUtils.readUTF8String(bytes)); + data = bytes.readInt(); + } - if (function == TELEPORT){ - data = bytes.readInt(); - } - } + if (function == TELEPORT) { + data = bytes.readInt(); + } + } - public static class Handler implements IMessageHandler { + public static class Handler implements IMessageHandler { - @Override - public IMessage onMessage(TeleporterPacket message, MessageContext ctx) { - ItemStack teleporter = ctx.getServerHandler().playerEntity.getHeldItem(); - if (teleporter == null || teleporter.getItem() != ModItems.teleporterMKII) return null; + @Override + public IMessage onMessage(TeleporterPacket message, MessageContext ctx) { + ItemStack teleporter = ctx.getServerHandler().playerEntity.getHeldItem(); + if (teleporter == null || teleporter.getItem() != ModItems.teleporterMKII) return null; - NBTTagCompound compound = teleporter.getTagCompound(); - if(compound == null) compound = new NBTTagCompound(); - NBTTagList list = (NBTTagList)compound.getTag("Locations"); - if (list == null) list = new NBTTagList(); + NBTTagCompound compound = teleporter.getTagCompound(); + if (compound == null) compound = new NBTTagCompound(); + NBTTagList list = (NBTTagList) compound.getTag("Locations"); + if (list == null) list = new NBTTagList(); - if (message.function == ADDDESTINATION){ - NBTTagCompound tag = new NBTTagCompound(); - message.location.setDimentionName(BrandonsCore.proxy.getMCServer().worldServerForDimension(message.location.getDimension()).provider.getDimensionName()); - message.location.writeToNBT(tag); - list.appendTag(tag); - compound.setTag("Locations", list); - teleporter.setTagCompound(compound); - } + if (message.function == ADDDESTINATION) { + NBTTagCompound tag = new NBTTagCompound(); + message.location.setDimentionName(BrandonsCore.proxy.getMCServer().worldServerForDimension(message.location.getDimension()).provider.getDimensionName()); + message.location.writeToNBT(tag); + list.appendTag(tag); + compound.setTag("Locations", list); + teleporter.setTagCompound(compound); + } - if (message.function == SCROLL){ - int selected = ItemNBTHelper.getShort(teleporter, "Selection", (short) 0); - int selectionOffset = ItemNBTHelper.getInteger(teleporter, "SelectionOffset", 0); - int maxSelect = Math.min(list.tagCount()-1, 11); - int maxOffset = Math.max(list.tagCount() - 12, 0); + if (message.function == SCROLL) { + int selected = ItemNBTHelper.getShort(teleporter, "Selection", (short) 0); + int selectionOffset = ItemNBTHelper.getInteger(teleporter, "SelectionOffset", 0); + int maxSelect = Math.min(list.tagCount() - 1, 11); + int maxOffset = Math.max(list.tagCount() - 12, 0); - if(message.data > 0 && selected < maxSelect) { - ItemNBTHelper.setShort(teleporter, "Selection", (short) (selected + 1)); - return null; - } - if(message.data > 0 && selectionOffset < maxOffset) { - ItemNBTHelper.setInteger(teleporter, "SelectionOffset", selectionOffset + 1); - return null; - } - if(message.data < 0 && selected > 0) { - ItemNBTHelper.setShort(teleporter, "Selection", (short)(selected-1)); - return null; - } - if(message.data < 0 && selectionOffset > 0) { - ItemNBTHelper.setInteger(teleporter, "SelectionOffset", selectionOffset - 1); - return null; - } + if (message.data > 0 && selected < maxSelect) { + ItemNBTHelper.setShort(teleporter, "Selection", (short) (selected + 1)); + return null; + } + if (message.data > 0 && selectionOffset < maxOffset) { + ItemNBTHelper.setInteger(teleporter, "SelectionOffset", selectionOffset + 1); + return null; + } + if (message.data < 0 && selected > 0) { + ItemNBTHelper.setShort(teleporter, "Selection", (short) (selected - 1)); + return null; + } + if (message.data < 0 && selectionOffset > 0) { + ItemNBTHelper.setInteger(teleporter, "SelectionOffset", selectionOffset - 1); + return null; + } - } + } - if (message.function == UPDATEDESTINATION){ - NBTTagCompound tag = list.getCompoundTagAt(message.data); - message.location.setDimentionName(BrandonsCore.proxy.getMCServer().worldServerForDimension(message.location.getDimension()).provider.getDimensionName()); - message.location.writeToNBT(tag); - list.func_150304_a(message.data, tag); - compound.setTag("Locations", list); - teleporter.setTagCompound(compound); - } + if (message.function == UPDATEDESTINATION) { + NBTTagCompound tag = list.getCompoundTagAt(message.data); + message.location.setDimentionName(BrandonsCore.proxy.getMCServer().worldServerForDimension(message.location.getDimension()).provider.getDimensionName()); + message.location.writeToNBT(tag); + list.func_150304_a(message.data, tag); + compound.setTag("Locations", list); + teleporter.setTagCompound(compound); + } - if (message.function == UPDATELOCK){ - list.getCompoundTagAt(message.data).setBoolean("WP", message.dataB); - compound.setTag("Locations", list); - teleporter.setTagCompound(compound); - } + if (message.function == UPDATELOCK) { + list.getCompoundTagAt(message.data).setBoolean("WP", message.dataB); + compound.setTag("Locations", list); + teleporter.setTagCompound(compound); + } - if (message.function == REMOVEDESTINATION){ - list.removeTag(message.data); - compound.setTag("Locations", list); - teleporter.setTagCompound(compound); - } + if (message.function == REMOVEDESTINATION) { + list.removeTag(message.data); + compound.setTag("Locations", list); + teleporter.setTagCompound(compound); + } - if (message.function == UPDATENAME){ - list.getCompoundTagAt(message.data).setString("Name", message.location.getName()); - compound.setTag("Locations", list); - teleporter.setTagCompound(compound); - } + if (message.function == UPDATENAME) { + list.getCompoundTagAt(message.data).setString("Name", message.location.getName()); + compound.setTag("Locations", list); + teleporter.setTagCompound(compound); + } - if (message.function == TELEPORT){ - int fuel = ItemNBTHelper.getInteger(teleporter, "Fuel", 0); - if (!ctx.getServerHandler().playerEntity.capabilities.isCreativeMode)ItemNBTHelper.setInteger(teleporter, "Fuel", fuel - 1); - TeleportLocation destination = new TeleportLocation(); - destination.readFromNBT(list.getCompoundTagAt(message.data)); - destination.sendEntityToCoords(ctx.getServerHandler().playerEntity); - } + if (message.function == TELEPORT) { + int fuel = ItemNBTHelper.getInteger(teleporter, "Fuel", 0); + if (!ctx.getServerHandler().playerEntity.capabilities.isCreativeMode) + ItemNBTHelper.setInteger(teleporter, "Fuel", fuel - 1); + TeleportLocation destination = new TeleportLocation(); + destination.readFromNBT(list.getCompoundTagAt(message.data)); + destination.sendEntityToCoords(ctx.getServerHandler().playerEntity); + } - if (message.function == MOVELOCATION) - { - int selected = ItemNBTHelper.getShort(teleporter, "Selection", (short) 0); - int selectionOffset = ItemNBTHelper.getInteger(teleporter, "SelectionOffset", 0); - int maxSelect = Math.min(list.tagCount()-1, 11); - int maxOffset = Math.max(list.tagCount() - 12, 0); + if (message.function == MOVELOCATION) { + int selected = ItemNBTHelper.getShort(teleporter, "Selection", (short) 0); + int selectionOffset = ItemNBTHelper.getInteger(teleporter, "SelectionOffset", 0); + int maxSelect = Math.min(list.tagCount() - 1, 11); + int maxOffset = Math.max(list.tagCount() - 12, 0); - if (message.dataB) //up - { - if (selected > 0) - { - NBTTagCompound temp = list.getCompoundTagAt(selected+selectionOffset); - list.func_150304_a(selected+selectionOffset, list.getCompoundTagAt(selected+selectionOffset - 1)); - list.func_150304_a(selected+selectionOffset - 1, temp); - compound.setTag("Locations", list); - teleporter.setTagCompound(compound); - ItemNBTHelper.setShort(teleporter, "Selection", (short) (ItemNBTHelper.getShort(teleporter, "Selection", (short) 0) - 1)); - } - } - else //down - { - if (selected < maxSelect) - { - NBTTagCompound temp = list.getCompoundTagAt(selected+selectionOffset); - list.func_150304_a(selected+selectionOffset, list.getCompoundTagAt(selected+selectionOffset + 1)); - list.func_150304_a(selected+selectionOffset + 1, temp); - compound.setTag("Locations", list); - teleporter.setTagCompound(compound); - ItemNBTHelper.setShort(teleporter, "Selection", (short) (ItemNBTHelper.getShort(teleporter, "Selection", (short) 0) + 1)); - } - } - } + if (message.dataB) //up + { + if (selected > 0) { + NBTTagCompound temp = list.getCompoundTagAt(selected + selectionOffset); + list.func_150304_a(selected + selectionOffset, list.getCompoundTagAt(selected + selectionOffset - 1)); + list.func_150304_a(selected + selectionOffset - 1, temp); + compound.setTag("Locations", list); + teleporter.setTagCompound(compound); + ItemNBTHelper.setShort(teleporter, "Selection", (short) (ItemNBTHelper.getShort(teleporter, "Selection", (short) 0) - 1)); + } + } else //down + { + if (selected < maxSelect) { + NBTTagCompound temp = list.getCompoundTagAt(selected + selectionOffset); + list.func_150304_a(selected + selectionOffset, list.getCompoundTagAt(selected + selectionOffset + 1)); + list.func_150304_a(selected + selectionOffset + 1, temp); + compound.setTag("Locations", list); + teleporter.setTagCompound(compound); + ItemNBTHelper.setShort(teleporter, "Selection", (short) (ItemNBTHelper.getShort(teleporter, "Selection", (short) 0) + 1)); + } + } + } - if (message.function == ADDFUEL){ - int fuel = ItemNBTHelper.getInteger(teleporter, "Fuel", 0); - int count = 0; - for (int i = 0; i < message.data; i++) - { - if (ctx.getServerHandler().playerEntity.inventory.hasItem(Items.ender_pearl)) { - ctx.getServerHandler().playerEntity.inventory.consumeInventoryItem(Items.ender_pearl); - count++; - }else break; - } - ItemNBTHelper.setInteger(teleporter, "Fuel", fuel + (ConfigHandler.teleporterUsesPerPearl * count)); - } + if (message.function == ADDFUEL) { + int fuel = ItemNBTHelper.getInteger(teleporter, "Fuel", 0); + int count = 0; + for (int i = 0; i < message.data; i++) { + if (ctx.getServerHandler().playerEntity.inventory.hasItem(Items.ender_pearl)) { + ctx.getServerHandler().playerEntity.inventory.consumeInventoryItem(Items.ender_pearl); + count++; + } else break; + } + ItemNBTHelper.setInteger(teleporter, "Fuel", fuel + (ConfigHandler.teleporterUsesPerPearl * count)); + } - if (message.function == CHANGESELECTION){ - ItemNBTHelper.setShort(teleporter, "Selection", (short)message.data); - } + if (message.function == CHANGESELECTION) { + ItemNBTHelper.setShort(teleporter, "Selection", (short) message.data); + } - if (message.function == UPDATEOFFSET){ - ItemNBTHelper.setInteger(teleporter, "SelectionOffset", message.data); - } - return null; - } - } + if (message.function == UPDATEOFFSET) { + ItemNBTHelper.setInteger(teleporter, "SelectionOffset", message.data); + } + return null; + } + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/network/TileObjectPacket.java b/src/main/java/com/brandon3055/draconicevolution/common/network/TileObjectPacket.java index ee798f88..a7b763b6 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/network/TileObjectPacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/network/TileObjectPacket.java @@ -13,97 +13,93 @@ import net.minecraft.client.Minecraft; /** * Created by Brandon on 14/11/2014. */ -public class TileObjectPacket implements IMessage{ +public class TileObjectPacket implements IMessage { - int x; - int y; - int z; - short index; - short dataType = -1; - Object object; - boolean isContainerPacket; + int x; + int y; + int z; + short index; + short dataType = -1; + Object object; + boolean isContainerPacket; - /**Used for Tile and Container synchronization*/ - public TileObjectPacket() {} + /** + * Used for Tile and Container synchronization + */ + public TileObjectPacket() { + } - public TileObjectPacket(TileObjectSync tile, byte dataType, int index, Object object) { - this.isContainerPacket = tile == null; - if (!isContainerPacket) { - this.x = tile.xCoord; - this.y = tile.yCoord; - this.z = tile.zCoord; - } - this.dataType = dataType; - this.object = object; - this.index = (short)index; - } + public TileObjectPacket(TileObjectSync tile, byte dataType, int index, Object object) { + this.isContainerPacket = tile == null; + if (!isContainerPacket) { + this.x = tile.xCoord; + this.y = tile.yCoord; + this.z = tile.zCoord; + } + this.dataType = dataType; + this.object = object; + this.index = (short) index; + } - @Override - public void toBytes(ByteBuf bytes){ - bytes.writeBoolean(isContainerPacket); + @Override + public void toBytes(ByteBuf bytes) { + bytes.writeBoolean(isContainerPacket); - if (!isContainerPacket) { - bytes.writeInt(x); - bytes.writeInt(y); - bytes.writeInt(z); - } + if (!isContainerPacket) { + bytes.writeInt(x); + bytes.writeInt(y); + bytes.writeInt(z); + } - bytes.writeByte(dataType); - bytes.writeShort(index); + bytes.writeByte(dataType); + bytes.writeShort(index); - DataUtills.instance.writeObjectToBytes(bytes, dataType, object); + DataUtills.instance.writeObjectToBytes(bytes, dataType, object); - } + } - @Override - public void fromBytes(ByteBuf bytes){ - isContainerPacket = bytes.readBoolean(); + @Override + public void fromBytes(ByteBuf bytes) { + isContainerPacket = bytes.readBoolean(); - if (!isContainerPacket) { - x = bytes.readInt(); - y = bytes.readInt(); - z = bytes.readInt(); - } + if (!isContainerPacket) { + x = bytes.readInt(); + y = bytes.readInt(); + z = bytes.readInt(); + } - dataType = bytes.readByte(); - index = bytes.readShort(); + dataType = bytes.readByte(); + index = bytes.readShort(); - object = DataUtills.instance.readObjectFromBytes(bytes, dataType); - } + object = DataUtills.instance.readObjectFromBytes(bytes, dataType); + } - public static class Handler implements IMessageHandler { + public static class Handler implements IMessageHandler { - @Override - public IMessage onMessage(TileObjectPacket message, MessageContext ctx) { - if (ctx.side == Side.CLIENT) - { - if (message.isContainerPacket) - { - ContainerDataSync container = Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerDataSync ? (ContainerDataSync) Minecraft.getMinecraft().thePlayer.openContainer : null; - if (container == null) return null; - container.receiveSyncData(message.index, (Integer) message.object); - } else - { - if (!(Minecraft.getMinecraft().theWorld.getTileEntity(message.x, message.y, message.z) instanceof TileObjectSync)) - return null; - ((TileObjectSync) Minecraft.getMinecraft().theWorld.getTileEntity(message.x, message.y, message.z)).receiveObjectFromServer(message.index, message.object); - } - } - else - { - if (message.isContainerPacket) - { - ContainerDataSync container = ctx.getServerHandler().playerEntity.openContainer instanceof ContainerDataSync ? (ContainerDataSync) ctx.getServerHandler().playerEntity.openContainer : null; - if (container == null) return null; - container.receiveSyncData(message.index, (Integer) message.object); - } else - { - if (!(ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z) instanceof TileObjectSync)) - return null; - ((TileObjectSync) ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z)).receiveObjectFromClient(message.index, message.object); - } - } - return null; - } - } + @Override + public IMessage onMessage(TileObjectPacket message, MessageContext ctx) { + if (ctx.side == Side.CLIENT) { + if (message.isContainerPacket) { + ContainerDataSync container = Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerDataSync ? (ContainerDataSync) Minecraft.getMinecraft().thePlayer.openContainer : null; + if (container == null) return null; + container.receiveSyncData(message.index, (Integer) message.object); + } else { + if (!(Minecraft.getMinecraft().theWorld.getTileEntity(message.x, message.y, message.z) instanceof TileObjectSync)) + return null; + ((TileObjectSync) Minecraft.getMinecraft().theWorld.getTileEntity(message.x, message.y, message.z)).receiveObjectFromServer(message.index, message.object); + } + } else { + if (message.isContainerPacket) { + ContainerDataSync container = ctx.getServerHandler().playerEntity.openContainer instanceof ContainerDataSync ? (ContainerDataSync) ctx.getServerHandler().playerEntity.openContainer : null; + if (container == null) return null; + container.receiveSyncData(message.index, (Integer) message.object); + } else { + if (!(ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z) instanceof TileObjectSync)) + return null; + ((TileObjectSync) ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z)).receiveObjectFromClient(message.index, message.object); + } + } + return null; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/network/ToolModePacket.java b/src/main/java/com/brandon3055/draconicevolution/common/network/ToolModePacket.java index ca2ed0f4..d57dcd4e 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/network/ToolModePacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/network/ToolModePacket.java @@ -11,35 +11,34 @@ import io.netty.buffer.ByteBuf; */ public class ToolModePacket implements IMessage { - public boolean shift; - public boolean ctrl; + public boolean shift; + public boolean ctrl; - public ToolModePacket() { - } + public ToolModePacket() { + } - public ToolModePacket(boolean shift, boolean ctrl) { - this.shift = shift; - this.ctrl = ctrl; - } + public ToolModePacket(boolean shift, boolean ctrl) { + this.shift = shift; + this.ctrl = ctrl; + } - @Override - public void toBytes(ByteBuf buf) { - buf.writeBoolean(shift); - buf.writeBoolean(ctrl); - } + @Override + public void toBytes(ByteBuf buf) { + buf.writeBoolean(shift); + buf.writeBoolean(ctrl); + } - @Override - public void fromBytes(ByteBuf buf) { - shift = buf.readBoolean(); - ctrl = buf.readBoolean(); - } + @Override + public void fromBytes(ByteBuf buf) { + shift = buf.readBoolean(); + ctrl = buf.readBoolean(); + } - public static class Handler implements IMessageHandler - { - @Override - public IMessage onMessage(ToolModePacket message, MessageContext ctx) { - ToolBase.handleModeChange(ctx.getServerHandler().playerEntity.getHeldItem(), ctx.getServerHandler().playerEntity, message.shift, message.ctrl); - return null; - } - } + public static class Handler implements IMessageHandler { + @Override + public IMessage onMessage(ToolModePacket message, MessageContext ctx) { + ToolBase.handleModeChange(ctx.getServerHandler().playerEntity.getHeldItem(), ctx.getServerHandler().playerEntity, message.shift, message.ctrl); + return null; + } + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/CustomSpawnerBaseLogic.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/CustomSpawnerBaseLogic.java index 3810010d..b57e4a4a 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/CustomSpawnerBaseLogic.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/CustomSpawnerBaseLogic.java @@ -22,270 +22,270 @@ import net.minecraft.world.World; import java.util.Arrays; public abstract class CustomSpawnerBaseLogic { - /** - * The delay to spawn. - */ - public int spawnDelay = 20; - /** - * The entity theis spawner will spawn. - */ - public String entityName = ""; + /** + * The delay to spawn. + */ + public int spawnDelay = 20; + /** + * The entity theis spawner will spawn. + */ + public String entityName = ""; - public double renderRotation0; - public double renderRotation1; - private int minSpawnDelay = 400; - private int maxSpawnDelay = 600; - /** - * A counter for spawn tries. - */ - private int spawnCount = 6; - private Entity renderedEntity; - private int maxNearbyEntities = 20; - /** - * Is receiving a redstone signal - */ - public boolean powered = false; - public boolean ltPowered = false; - /** - * Dose the spawner require a player nearby - */ - public boolean requiresPlayer = true; - /** - * Ignore Mob Spawn Requirements - */ - public boolean ignoreSpawnRequirements = false; - /** - * Spawn Speed - */ - public int spawnSpeed = 1; - /** - * The distance from which a player activates the spawner. - */ - private int activatingRangeFromPlayer = 24; - /** - * The range coefficient for spawning entities around. - */ - private int spawnRange = 4; - public int skeletonType = 0; - /** - * Gets the entity name that should be spawned. - */ - public String getEntityNameToSpawn() { - return this.entityName; - } + public double renderRotation0; + public double renderRotation1; + private int minSpawnDelay = 400; + private int maxSpawnDelay = 600; + /** + * A counter for spawn tries. + */ + private int spawnCount = 6; + private Entity renderedEntity; + private int maxNearbyEntities = 20; + /** + * Is receiving a redstone signal + */ + public boolean powered = false; + public boolean ltPowered = false; + /** + * Dose the spawner require a player nearby + */ + public boolean requiresPlayer = true; + /** + * Ignore Mob Spawn Requirements + */ + public boolean ignoreSpawnRequirements = false; + /** + * Spawn Speed + */ + public int spawnSpeed = 1; + /** + * The distance from which a player activates the spawner. + */ + private int activatingRangeFromPlayer = 24; + /** + * The range coefficient for spawning entities around. + */ + private int spawnRange = 4; + public int skeletonType = 0; - public void setEntityName(String name) { - this.entityName = name; - } + /** + * Gets the entity name that should be spawned. + */ + public String getEntityNameToSpawn() { + return this.entityName; + } - /** - * Returns true if there's a player close enough to this mob spawner to activate it. - */ - public boolean isActivated() { - if (!requiresPlayer) - return true; - else - return this.getSpawnerWorld().getClosestPlayer((double) this.getSpawnerX() + 0.5D, (double) this.getSpawnerY() + 0.5D, (double) this.getSpawnerZ() + 0.5D, (double) this.activatingRangeFromPlayer) != null; - } + public void setEntityName(String name) { + this.entityName = name; + } - public void updateSpawner() { - if (isActivated() && !powered) { - double d2; + /** + * Returns true if there's a player close enough to this mob spawner to activate it. + */ + public boolean isActivated() { + if (!requiresPlayer) return true; + else + return this.getSpawnerWorld().getClosestPlayer((double) this.getSpawnerX() + 0.5D, (double) this.getSpawnerY() + 0.5D, (double) this.getSpawnerZ() + 0.5D, (double) this.activatingRangeFromPlayer) != null; + } - if (this.getSpawnerWorld().isRemote) { - double d0 = (double) ((float) this.getSpawnerX() + this.getSpawnerWorld().rand.nextFloat()); - double d1 = (double) ((float) this.getSpawnerY() + this.getSpawnerWorld().rand.nextFloat()); - d2 = (double) ((float) this.getSpawnerZ() + this.getSpawnerWorld().rand.nextFloat()); - this.getSpawnerWorld().spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); - this.getSpawnerWorld().spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); + public void updateSpawner() { + if (isActivated() && !powered) { + double d2; - if (this.spawnDelay > 0) { - --this.spawnDelay; - } + if (this.getSpawnerWorld().isRemote) { + double d0 = (double) ((float) this.getSpawnerX() + this.getSpawnerWorld().rand.nextFloat()); + double d1 = (double) ((float) this.getSpawnerY() + this.getSpawnerWorld().rand.nextFloat()); + d2 = (double) ((float) this.getSpawnerZ() + this.getSpawnerWorld().rand.nextFloat()); + this.getSpawnerWorld().spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); + this.getSpawnerWorld().spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); - this.renderRotation1 = this.renderRotation0; - this.renderRotation0 = (this.renderRotation0 + (double) (1000.0F / ((float) this.spawnDelay + 200.0F))) % 360.0D; - } else { - if (this.spawnDelay == -1) { - this.resetTimer(); - } + if (this.spawnDelay > 0) { + --this.spawnDelay; + } - if (this.spawnDelay > 0) { - --this.spawnDelay; - return; - } + this.renderRotation1 = this.renderRotation0; + this.renderRotation0 = (this.renderRotation0 + (double) (1000.0F / ((float) this.spawnDelay + 200.0F))) % 360.0D; + } else { + if (this.spawnDelay == -1) { + this.resetTimer(); + } - boolean flag = false; + if (this.spawnDelay > 0) { + --this.spawnDelay; + return; + } - for (int i = 0; i < this.spawnCount; ++i) { - Entity entity = EntityList.createEntityByName(this.getEntityNameToSpawn(), this.getSpawnerWorld()); + boolean flag = false; - if (entity == null) { - return; - } + for (int i = 0; i < this.spawnCount; ++i) { + Entity entity = EntityList.createEntityByName(this.getEntityNameToSpawn(), this.getSpawnerWorld()); - int j = this.getSpawnerWorld().getEntitiesWithinAABB(entity.getClass(), AxisAlignedBB.getBoundingBox((double) this.getSpawnerX(), (double) this.getSpawnerY(), (double) this.getSpawnerZ(), (double) (this.getSpawnerX() + 1), (double) (this.getSpawnerY() + 1), (double) (this.getSpawnerZ() + 1)).expand((double) (this.spawnRange * 2), 4.0D, (double) (this.spawnRange * 2))).size(); + if (entity == null) { + return; + } - if (j >= this.maxNearbyEntities) { - this.resetTimer(); - return; - } + int j = this.getSpawnerWorld().getEntitiesWithinAABB(entity.getClass(), AxisAlignedBB.getBoundingBox((double) this.getSpawnerX(), (double) this.getSpawnerY(), (double) this.getSpawnerZ(), (double) (this.getSpawnerX() + 1), (double) (this.getSpawnerY() + 1), (double) (this.getSpawnerZ() + 1)).expand((double) (this.spawnRange * 2), 4.0D, (double) (this.spawnRange * 2))).size(); - int x = this.getSpawnerX() + (int)((this.getSpawnerWorld().rand.nextDouble() - this.getSpawnerWorld().rand.nextDouble()) * (double) this.spawnRange); - int y = this.getSpawnerY() + this.getSpawnerWorld().rand.nextInt(3) - 1; - int z = this.getSpawnerZ() + (int)((this.getSpawnerWorld().rand.nextDouble() - this.getSpawnerWorld().rand.nextDouble()) * (double) this.spawnRange); - EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving) entity : null; - entity.setLocationAndAngles(x + 0.5, y + 0.5, z + 0.5, this.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F); + if (j >= this.maxNearbyEntities) { + this.resetTimer(); + return; + } - if (entityliving == null || (entityliving.getCanSpawnHere() || ignoreSpawnRequirements && getSpawnerWorld().getBlock(x, y, z) == Blocks.air)) { - this.spawnEntity(entity); - this.getSpawnerWorld().playAuxSFX(2004, this.getSpawnerX(), this.getSpawnerY(), this.getSpawnerZ(), 0); + int x = this.getSpawnerX() + (int) ((this.getSpawnerWorld().rand.nextDouble() - this.getSpawnerWorld().rand.nextDouble()) * (double) this.spawnRange); + int y = this.getSpawnerY() + this.getSpawnerWorld().rand.nextInt(3) - 1; + int z = this.getSpawnerZ() + (int) ((this.getSpawnerWorld().rand.nextDouble() - this.getSpawnerWorld().rand.nextDouble()) * (double) this.spawnRange); + EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving) entity : null; + entity.setLocationAndAngles(x + 0.5, y + 0.5, z + 0.5, this.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F); - if (entityliving != null) { - entityliving.spawnExplosionParticle(); - } + if (entityliving == null || (entityliving.getCanSpawnHere() || ignoreSpawnRequirements && getSpawnerWorld().getBlock(x, y, z) == Blocks.air)) { + this.spawnEntity(entity); + this.getSpawnerWorld().playAuxSFX(2004, this.getSpawnerX(), this.getSpawnerY(), this.getSpawnerZ(), 0); - flag = true; + if (entityliving != null) { + entityliving.spawnExplosionParticle(); + } - } - } + flag = true; - if (flag) { - this.resetTimer(); - } - } - } - } + } + } - public Entity spawnEntity(Entity par1Entity) { + if (flag) { + this.resetTimer(); + } + } + } + } - if (par1Entity instanceof EntityLivingBase && par1Entity.worldObj != null) { - if (par1Entity instanceof EntitySkeleton) { - ((EntitySkeleton)par1Entity).setSkeletonType(skeletonType); - if (skeletonType == 1) { - par1Entity.setCurrentItemOrArmor(0, new ItemStack(Items.stone_sword)); - ((EntitySkeleton) par1Entity).setEquipmentDropChance(0, 0f); - }else{ - par1Entity.setCurrentItemOrArmor(0, new ItemStack(Items.bow)); - } - } else ((EntityLiving) par1Entity).onSpawnWithEgg(null); + public Entity spawnEntity(Entity par1Entity) { - if (!requiresPlayer) { - ((EntityLiving)par1Entity).func_110163_bv(); - par1Entity.getEntityData().setLong("SpawnedByDESpawner", getSpawnerWorld().getTotalWorldTime()); - } + if (par1Entity instanceof EntityLivingBase && par1Entity.worldObj != null) { + if (par1Entity instanceof EntitySkeleton) { + ((EntitySkeleton) par1Entity).setSkeletonType(skeletonType); + if (skeletonType == 1) { + par1Entity.setCurrentItemOrArmor(0, new ItemStack(Items.stone_sword)); + ((EntitySkeleton) par1Entity).setEquipmentDropChance(0, 0f); + } else { + par1Entity.setCurrentItemOrArmor(0, new ItemStack(Items.bow)); + } + } else ((EntityLiving) par1Entity).onSpawnWithEgg(null); - if (!getSpawnerWorld().isRemote) this.getSpawnerWorld().spawnEntityInWorld(par1Entity); - } + if (!requiresPlayer) { + ((EntityLiving) par1Entity).func_110163_bv(); + par1Entity.getEntityData().setLong("SpawnedByDESpawner", getSpawnerWorld().getTotalWorldTime()); + } - return par1Entity; - } + if (!getSpawnerWorld().isRemote) this.getSpawnerWorld().spawnEntityInWorld(par1Entity); + } - private void resetTimer() { - if (this.maxSpawnDelay <= this.minSpawnDelay) { - this.spawnDelay = this.minSpawnDelay; - } else { - int i = this.maxSpawnDelay - this.minSpawnDelay; - this.spawnDelay = this.minSpawnDelay + this.getSpawnerWorld().rand.nextInt(i); - } + return par1Entity; + } - this.blockEvent(1); - } + private void resetTimer() { + if (this.maxSpawnDelay <= this.minSpawnDelay) { + this.spawnDelay = this.minSpawnDelay; + } else { + int i = this.maxSpawnDelay - this.minSpawnDelay; + this.spawnDelay = this.minSpawnDelay + this.getSpawnerWorld().rand.nextInt(i); + } - public void readFromNBT(NBTTagCompound par1NBTTagCompound) { - this.entityName = par1NBTTagCompound.getString("EntityId"); - this.spawnDelay = par1NBTTagCompound.getShort("Delay"); - if ((!ConfigHandler.spawnerListType && Arrays.asList(ConfigHandler.spawnerList).contains(this.entityName)) || (ConfigHandler.spawnerListType && !Arrays.asList(ConfigHandler.spawnerList).contains(this.entityName))) { - this.entityName = "Pig"; - par1NBTTagCompound.setBoolean("Running", false); - } + this.blockEvent(1); + } - powered = par1NBTTagCompound.getBoolean("Powered"); - spawnSpeed = par1NBTTagCompound.getShort("Speed"); - requiresPlayer = par1NBTTagCompound.getBoolean("RequiresPlayer"); - ignoreSpawnRequirements = par1NBTTagCompound.getBoolean("IgnoreSpawnRequirements"); - skeletonType = par1NBTTagCompound.getInteger("SkeletonType"); + public void readFromNBT(NBTTagCompound par1NBTTagCompound) { + this.entityName = par1NBTTagCompound.getString("EntityId"); + this.spawnDelay = par1NBTTagCompound.getShort("Delay"); + if ((!ConfigHandler.spawnerListType && Arrays.asList(ConfigHandler.spawnerList).contains(this.entityName)) || (ConfigHandler.spawnerListType && !Arrays.asList(ConfigHandler.spawnerList).contains(this.entityName))) { + this.entityName = "Pig"; + par1NBTTagCompound.setBoolean("Running", false); + } - this.minSpawnDelay = par1NBTTagCompound.getShort("MinSpawnDelay"); - this.maxSpawnDelay = par1NBTTagCompound.getShort("MaxSpawnDelay"); - this.spawnCount = par1NBTTagCompound.getShort("SpawnCount"); + powered = par1NBTTagCompound.getBoolean("Powered"); + spawnSpeed = par1NBTTagCompound.getShort("Speed"); + requiresPlayer = par1NBTTagCompound.getBoolean("RequiresPlayer"); + ignoreSpawnRequirements = par1NBTTagCompound.getBoolean("IgnoreSpawnRequirements"); + skeletonType = par1NBTTagCompound.getInteger("SkeletonType"); - if (par1NBTTagCompound.hasKey("MaxNearbyEntities", 99)) { - this.maxNearbyEntities = par1NBTTagCompound.getShort("MaxNearbyEntities"); - this.activatingRangeFromPlayer = par1NBTTagCompound.getShort("RequiredPlayerRange"); - } + this.minSpawnDelay = par1NBTTagCompound.getShort("MinSpawnDelay"); + this.maxSpawnDelay = par1NBTTagCompound.getShort("MaxSpawnDelay"); + this.spawnCount = par1NBTTagCompound.getShort("SpawnCount"); - if (par1NBTTagCompound.hasKey("SpawnRange", 99)) { - this.spawnRange = par1NBTTagCompound.getShort("SpawnRange"); - } + if (par1NBTTagCompound.hasKey("MaxNearbyEntities", 99)) { + this.maxNearbyEntities = par1NBTTagCompound.getShort("MaxNearbyEntities"); + this.activatingRangeFromPlayer = par1NBTTagCompound.getShort("RequiredPlayerRange"); + } - if (this.getSpawnerWorld() != null && this.getSpawnerWorld().isRemote) { - this.renderedEntity = null; - } - } + if (par1NBTTagCompound.hasKey("SpawnRange", 99)) { + this.spawnRange = par1NBTTagCompound.getShort("SpawnRange"); + } - public void writeToNBT(NBTTagCompound par1NBTTagCompound) { - par1NBTTagCompound.setString("EntityId", getEntityNameToSpawn()); - par1NBTTagCompound.setShort("Delay", (short) spawnDelay); - par1NBTTagCompound.setShort("MinSpawnDelay", (short) minSpawnDelay); - par1NBTTagCompound.setShort("MaxSpawnDelay", (short) maxSpawnDelay); - par1NBTTagCompound.setShort("SpawnCount", (short) spawnCount); - par1NBTTagCompound.setShort("MaxNearbyEntities", (short) maxNearbyEntities); - par1NBTTagCompound.setShort("RequiredPlayerRange", (short) activatingRangeFromPlayer); - par1NBTTagCompound.setShort("SpawnRange", (short) spawnRange); - par1NBTTagCompound.setBoolean("Powered", powered); - par1NBTTagCompound.setShort("Speed", (short) spawnSpeed); - par1NBTTagCompound.setBoolean("RequiresPlayer", requiresPlayer); - par1NBTTagCompound.setBoolean("IgnoreSpawnRequirements", ignoreSpawnRequirements); - par1NBTTagCompound.setInteger("SkeletonType", skeletonType); - } + if (this.getSpawnerWorld() != null && this.getSpawnerWorld().isRemote) { + this.renderedEntity = null; + } + } - /** - * Sets the delay to minDelay if parameter given is 1, else return false. - */ - public boolean setDelayToMin(int par1) { - if (par1 == 1 && this.getSpawnerWorld().isRemote) { - this.spawnDelay = this.minSpawnDelay; - return true; - } else { - return false; - } - } + public void writeToNBT(NBTTagCompound par1NBTTagCompound) { + par1NBTTagCompound.setString("EntityId", getEntityNameToSpawn()); + par1NBTTagCompound.setShort("Delay", (short) spawnDelay); + par1NBTTagCompound.setShort("MinSpawnDelay", (short) minSpawnDelay); + par1NBTTagCompound.setShort("MaxSpawnDelay", (short) maxSpawnDelay); + par1NBTTagCompound.setShort("SpawnCount", (short) spawnCount); + par1NBTTagCompound.setShort("MaxNearbyEntities", (short) maxNearbyEntities); + par1NBTTagCompound.setShort("RequiredPlayerRange", (short) activatingRangeFromPlayer); + par1NBTTagCompound.setShort("SpawnRange", (short) spawnRange); + par1NBTTagCompound.setBoolean("Powered", powered); + par1NBTTagCompound.setShort("Speed", (short) spawnSpeed); + par1NBTTagCompound.setBoolean("RequiresPlayer", requiresPlayer); + par1NBTTagCompound.setBoolean("IgnoreSpawnRequirements", ignoreSpawnRequirements); + par1NBTTagCompound.setInteger("SkeletonType", skeletonType); + } - @SideOnly(Side.CLIENT) - public Entity getEntityForRenderer() { - if (this.renderedEntity == null) { - Entity entity = EntityList.createEntityByName(this.getEntityNameToSpawn(), getSpawnerWorld()); - entity = this.spawnEntity(entity); - if (entity instanceof EntitySkeleton) ((EntitySkeleton)entity).setSkeletonType(skeletonType); - this.renderedEntity = entity; - } + /** + * Sets the delay to minDelay if parameter given is 1, else return false. + */ + public boolean setDelayToMin(int par1) { + if (par1 == 1 && this.getSpawnerWorld().isRemote) { + this.spawnDelay = this.minSpawnDelay; + return true; + } else { + return false; + } + } - return this.renderedEntity; - } + @SideOnly(Side.CLIENT) + public Entity getEntityForRenderer() { + if (this.renderedEntity == null) { + Entity entity = EntityList.createEntityByName(this.getEntityNameToSpawn(), getSpawnerWorld()); + entity = this.spawnEntity(entity); + if (entity instanceof EntitySkeleton) ((EntitySkeleton) entity).setSkeletonType(skeletonType); + this.renderedEntity = entity; + } - public abstract void blockEvent(int var1); + return this.renderedEntity; + } - public abstract World getSpawnerWorld(); + public abstract void blockEvent(int var1); - public abstract int getSpawnerX(); + public abstract World getSpawnerWorld(); - public abstract int getSpawnerY(); + public abstract int getSpawnerX(); - public abstract int getSpawnerZ(); + public abstract int getSpawnerY(); - public void setSpawnRate(int i){ - spawnSpeed = i; - minSpawnDelay = 400 - (i * 150); - maxSpawnDelay = 600 - (i * 200); - spawnCount = 4 + (i*2); - if (i == 3){ - minSpawnDelay = 40; - maxSpawnDelay = 40; - spawnCount = 12; - } - if (minSpawnDelay < 0) minSpawnDelay = 0; - if (maxSpawnDelay < 1) maxSpawnDelay = 1; - resetTimer(); - } + public abstract int getSpawnerZ(); + + public void setSpawnRate(int i) { + spawnSpeed = i; + minSpawnDelay = 400 - (i * 150); + maxSpawnDelay = 600 - (i * 200); + spawnCount = 4 + (i * 2); + if (i == 3) { + minSpawnDelay = 40; + maxSpawnDelay = 40; + spawnCount = 12; + } + if (minSpawnDelay < 0) minSpawnDelay = 0; + if (maxSpawnDelay < 1) maxSpawnDelay = 1; + resetTimer(); + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileCKeyStone.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileCKeyStone.java index 0bab32b4..d577780b 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileCKeyStone.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileCKeyStone.java @@ -17,157 +17,160 @@ import net.minecraft.util.ChatComponentTranslation; */ public class TileCKeyStone extends TileEntity { - public boolean isActivated = false; - private int keyCode = 0; - private int activeTicks = 0; - public int delay = 5; + public boolean isActivated = false; + private int keyCode = 0; + private int activeTicks = 0; + public int delay = 5; - @Override - public void updateEntity() { - if (isActivated && (getMeta() == 1 || getMeta() == 3)) { - activeTicks++; - if (activeTicks >= delay){ - activeTicks = 0; - isActivated = false; - updateBlocks(); - worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.click", 0.3F, 0.5F); - } - } - } + @Override + public void updateEntity() { + if (isActivated && (getMeta() == 1 || getMeta() == 3)) { + activeTicks++; + if (activeTicks >= delay) { + activeTicks = 0; + isActivated = false; + updateBlocks(); + worldObj.playSoundEffect((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D, "random.click", 0.3F, 0.5F); + } + } + } - public boolean onActivated(ItemStack stack, EntityPlayer player){ - if (stack == null || stack.getItem() != ModItems.key) { - if(player.capabilities.isCreativeMode && stack == null && player.isSneaking() && (getMeta() == 1 || getMeta() == 3)) delay+=5; - if(player.capabilities.isCreativeMode && stack == null) giveInformation(player); - return false; - } - if (isMasterKey(stack)) return true; - if (setKey(stack)) return true; - if(!isKeyValid(stack, player)) return false; + public boolean onActivated(ItemStack stack, EntityPlayer player) { + if (stack == null || stack.getItem() != ModItems.key) { + if (player.capabilities.isCreativeMode && stack == null && player.isSneaking() && (getMeta() == 1 || getMeta() == 3)) + delay += 5; + if (player.capabilities.isCreativeMode && stack == null) giveInformation(player); + return false; + } + if (isMasterKey(stack)) return true; + if (setKey(stack)) return true; + if (!isKeyValid(stack, player)) return false; - switch (getMeta()){ - case 0: //Permanent Activation - isActivated = true; - player.destroyCurrentEquippedItem(); - worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.click", 0.3F, 0.6F); - break; - case 1: //Button Activation - isActivated = true; - worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.click", 0.3F, 0.6F); - break; - case 2: //Toggle Activation - if (!isActivated) - worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.click", 0.3F, 0.6F); - else - worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.click", 0.3F, 0.5F); - isActivated = !isActivated; - break; - case 3: //Button Activation (Consume Key) - isActivated = true; - player.destroyCurrentEquippedItem(); - worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.click", 0.3F, 0.6F); - break; - case 4: - break; - } + switch (getMeta()) { + case 0: //Permanent Activation + isActivated = true; + player.destroyCurrentEquippedItem(); + worldObj.playSoundEffect((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D, "random.click", 0.3F, 0.6F); + break; + case 1: //Button Activation + isActivated = true; + worldObj.playSoundEffect((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D, "random.click", 0.3F, 0.6F); + break; + case 2: //Toggle Activation + if (!isActivated) + worldObj.playSoundEffect((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D, "random.click", 0.3F, 0.6F); + else + worldObj.playSoundEffect((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D, "random.click", 0.3F, 0.5F); + isActivated = !isActivated; + break; + case 3: //Button Activation (Consume Key) + isActivated = true; + player.destroyCurrentEquippedItem(); + worldObj.playSoundEffect((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D, "random.click", 0.3F, 0.6F); + break; + case 4: + break; + } - updateBlocks(); - return true; - } + updateBlocks(); + return true; + } - private void giveInformation(EntityPlayer player){ - if (worldObj.isRemote){ - player.addChatComponentMessage(new ChatComponentTranslation("msg.cKeyStoneType"+getMeta()+".txt")); - player.addChatComponentMessage(new ChatComponentText("Key: "+keyCode)); - if(getMeta() == 1 || getMeta() == 3)player.addChatComponentMessage(new ChatComponentText("Delay: "+delay +"t ("+(((double)delay)/20D)+"s)")); - } - } + private void giveInformation(EntityPlayer player) { + if (worldObj.isRemote) { + player.addChatComponentMessage(new ChatComponentTranslation("msg.cKeyStoneType" + getMeta() + ".txt")); + player.addChatComponentMessage(new ChatComponentText("Key: " + keyCode)); + if (getMeta() == 1 || getMeta() == 3) + player.addChatComponentMessage(new ChatComponentText("Delay: " + delay + "t (" + (((double) delay) / 20D) + "s)")); + } + } - private boolean isMasterKey(ItemStack key){ - if (key.getItemDamage() == 1){ - if (!isActivated) - worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.click", 0.3F, 0.6F); - else - worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.click", 0.3F, 0.5F); - isActivated = !isActivated; - updateBlocks(); - return true; - } - return false; - } + private boolean isMasterKey(ItemStack key) { + if (key.getItemDamage() == 1) { + if (!isActivated) + worldObj.playSoundEffect((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D, "random.click", 0.3F, 0.6F); + else + worldObj.playSoundEffect((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D, "random.click", 0.3F, 0.5F); + isActivated = !isActivated; + updateBlocks(); + return true; + } + return false; + } - private boolean setKey(ItemStack key){ - if (keyCode == 0 && ItemNBTHelper.getInteger(key, "KeyCode", 0) == 0){ - keyCode = worldObj.rand.nextInt(); - ItemNBTHelper.setInteger(key, "KeyCode", keyCode); - ItemNBTHelper.setInteger(key, "X", xCoord); - ItemNBTHelper.setInteger(key, "Y", yCoord); - ItemNBTHelper.setInteger(key, "Z", zCoord); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - return true; - }else if (keyCode == 0 && ItemNBTHelper.getInteger(key, "KeyCode", 0) != 0){ - keyCode = ItemNBTHelper.getInteger(key, "KeyCode", 0); - ItemNBTHelper.setInteger(key, "LockCount", ItemNBTHelper.getInteger(key, "LockCount", 0) + 1); - ItemNBTHelper.setInteger(key, "X_" + ItemNBTHelper.getInteger(key, "LockCount", 0), xCoord); - ItemNBTHelper.setInteger(key, "Y_" + ItemNBTHelper.getInteger(key, "LockCount", 0), yCoord); - ItemNBTHelper.setInteger(key, "Z_" + ItemNBTHelper.getInteger(key, "LockCount", 0), zCoord); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - return true; - } - return false; - } + private boolean setKey(ItemStack key) { + if (keyCode == 0 && ItemNBTHelper.getInteger(key, "KeyCode", 0) == 0) { + keyCode = worldObj.rand.nextInt(); + ItemNBTHelper.setInteger(key, "KeyCode", keyCode); + ItemNBTHelper.setInteger(key, "X", xCoord); + ItemNBTHelper.setInteger(key, "Y", yCoord); + ItemNBTHelper.setInteger(key, "Z", zCoord); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return true; + } else if (keyCode == 0 && ItemNBTHelper.getInteger(key, "KeyCode", 0) != 0) { + keyCode = ItemNBTHelper.getInteger(key, "KeyCode", 0); + ItemNBTHelper.setInteger(key, "LockCount", ItemNBTHelper.getInteger(key, "LockCount", 0) + 1); + ItemNBTHelper.setInteger(key, "X_" + ItemNBTHelper.getInteger(key, "LockCount", 0), xCoord); + ItemNBTHelper.setInteger(key, "Y_" + ItemNBTHelper.getInteger(key, "LockCount", 0), yCoord); + ItemNBTHelper.setInteger(key, "Z_" + ItemNBTHelper.getInteger(key, "LockCount", 0), zCoord); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return true; + } + return false; + } - private boolean isKeyValid(ItemStack key, EntityPlayer player){ - if (ItemNBTHelper.getInteger(key, "KeyCode", 0) != keyCode) { - if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.wrongKey.txt")); - return false; - } - return true; - } + private boolean isKeyValid(ItemStack key, EntityPlayer player) { + if (ItemNBTHelper.getInteger(key, "KeyCode", 0) != keyCode) { + if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.wrongKey.txt")); + return false; + } + return true; + } - private int getMeta(){return worldObj.getBlockMetadata(xCoord, yCoord, zCoord);} + private int getMeta() { + return worldObj.getBlockMetadata(xCoord, yCoord, zCoord); + } - public int getKeyCode(){return keyCode;} + public int getKeyCode() { + return keyCode; + } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound tagCompound = new NBTTagCompound(); - this.writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + this.writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - @Override - public void writeToNBT(NBTTagCompound compound) - { - compound.setBoolean("IsActivated", isActivated); - compound.setInteger("KeyCode", keyCode); - compound.setInteger("Delay", delay); - super.writeToNBT(compound); - } + @Override + public void writeToNBT(NBTTagCompound compound) { + compound.setBoolean("IsActivated", isActivated); + compound.setInteger("KeyCode", keyCode); + compound.setInteger("Delay", delay); + super.writeToNBT(compound); + } - @Override - public void readFromNBT(NBTTagCompound compound) - { - isActivated = compound.getBoolean("IsActivated"); - keyCode = compound.getInteger("KeyCode"); - delay = compound.getInteger("Delay"); - super.readFromNBT(compound); - } + @Override + public void readFromNBT(NBTTagCompound compound) { + isActivated = compound.getBoolean("IsActivated"); + keyCode = compound.getInteger("KeyCode"); + delay = compound.getInteger("Delay"); + super.readFromNBT(compound); + } - public void updateBlocks() - { - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord - 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord + 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord + 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord - 1, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord + 1, worldObj.getBlock(xCoord, yCoord, zCoord)); - } + public void updateBlocks() { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord - 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord + 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord + 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord - 1, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord + 1, worldObj.getBlock(xCoord, yCoord, zCoord)); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileChaosShard.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileChaosShard.java index c220c18a..7ca13b29 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileChaosShard.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileChaosShard.java @@ -14,77 +14,79 @@ import net.minecraft.util.AxisAlignedBB; */ public class TileChaosShard extends TileEntity { - public int tick = 0; - public boolean guardianDefeated = false; - private int soundTimer; - public int locationHash = 0; + public int tick = 0; + public boolean guardianDefeated = false; + private int soundTimer; + public int locationHash = 0; - @Override - public void updateEntity() { - tick++; + @Override + public void updateEntity() { + tick++; - if (tick > 1 && !worldObj.isRemote && locationHash != getLocationHash(xCoord, yCoord, zCoord, worldObj.provider.dimensionId)) worldObj.setBlockToAir(xCoord, yCoord, zCoord); + if (tick > 1 && !worldObj.isRemote && locationHash != getLocationHash(xCoord, yCoord, zCoord, worldObj.provider.dimensionId)) + worldObj.setBlockToAir(xCoord, yCoord, zCoord); - if (worldObj.isRemote && soundTimer-- <= 0){ - soundTimer = 3600 + worldObj.rand.nextInt(1200); - worldObj.playSound(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:chaosChamberAmbient", 1.5F, worldObj.rand.nextFloat() * 0.4F + 0.8F, false); - } + if (worldObj.isRemote && soundTimer-- <= 0) { + soundTimer = 3600 + worldObj.rand.nextInt(1200); + worldObj.playSound(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:chaosChamberAmbient", 1.5F, worldObj.rand.nextFloat() * 0.4F + 0.8F, false); + } - if (!worldObj.isRemote && guardianDefeated && worldObj.rand.nextInt(50) == 0) { - int x = 5 - worldObj.rand.nextInt(11); - int z = 5 - worldObj.rand.nextInt(11); - EntityLightningBolt bolt = new EntityLightningBolt(worldObj, xCoord+x, worldObj.getTopSolidOrLiquidBlock(xCoord+x, zCoord+z), zCoord+z); - bolt.ignoreFrustumCheck = true; - worldObj.addWeatherEffect(bolt); - } - } + if (!worldObj.isRemote && guardianDefeated && worldObj.rand.nextInt(50) == 0) { + int x = 5 - worldObj.rand.nextInt(11); + int z = 5 - worldObj.rand.nextInt(11); + EntityLightningBolt bolt = new EntityLightningBolt(worldObj, xCoord + x, worldObj.getTopSolidOrLiquidBlock(xCoord + x, zCoord + z), zCoord + z); + bolt.ignoreFrustumCheck = true; + worldObj.addWeatherEffect(bolt); + } + } - public void detonate(){ - if (!worldObj.isRemote && locationHash != getLocationHash(xCoord, yCoord, zCoord, worldObj.provider.dimensionId)) worldObj.setBlockToAir(xCoord, yCoord, zCoord); - else { - EntityChaosVortex vortex = new EntityChaosVortex(worldObj); - vortex.setPosition(xCoord+0.5, yCoord+0.5, zCoord+0.5); - worldObj.spawnEntityInWorld(vortex); - } - } + public void detonate() { + if (!worldObj.isRemote && locationHash != getLocationHash(xCoord, yCoord, zCoord, worldObj.provider.dimensionId)) + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + else { + EntityChaosVortex vortex = new EntityChaosVortex(worldObj); + vortex.setPosition(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + worldObj.spawnEntityInWorld(vortex); + } + } - public void setDefeated(){ - guardianDefeated = true; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } + public void setDefeated() { + guardianDefeated = true; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } - @Override - public void writeToNBT(NBTTagCompound compound) { - super.writeToNBT(compound); - compound.setBoolean("GuardianDefeated", guardianDefeated); - compound.setInteger("LocationHash", locationHash); - } + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setBoolean("GuardianDefeated", guardianDefeated); + compound.setInteger("LocationHash", locationHash); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - super.readFromNBT(compound); - guardianDefeated = compound.getBoolean("GuardianDefeated"); - locationHash = compound.getInteger("LocationHash"); - } + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + guardianDefeated = compound.getBoolean("GuardianDefeated"); + locationHash = compound.getInteger("LocationHash"); + } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound tagCompound = new NBTTagCompound(); - writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - @Override - public AxisAlignedBB getRenderBoundingBox() { - return super.getRenderBoundingBox().expand(1, 3, 1); - } + @Override + public AxisAlignedBB getRenderBoundingBox() { + return super.getRenderBoundingBox().expand(1, 3, 1); + } - public int getLocationHash(int xCoord, int yCoord, int zCoord, int dimension){ - return (String.valueOf(xCoord)+String.valueOf(yCoord)+String.valueOf(zCoord)+String.valueOf(dimension)).hashCode(); - } + public int getLocationHash(int xCoord, int yCoord, int zCoord, int dimension) { + return (String.valueOf(xCoord) + String.valueOf(yCoord) + String.valueOf(zCoord) + String.valueOf(dimension)).hashCode(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileContainerTemplate.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileContainerTemplate.java index ee2717ca..5f1a6943 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileContainerTemplate.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileContainerTemplate.java @@ -12,152 +12,149 @@ import net.minecraft.tileentity.TileEntity; /** * Created by Brandon on 27/06/2014. */ -public class TileContainerTemplate extends TileEntity implements ISidedInventory { - ItemStack[] items = new ItemStack[9]; +public class TileContainerTemplate extends TileEntity implements ISidedInventory { + ItemStack[] items = new ItemStack[9]; - //==============================================LOGIC=======================================================// + //==============================================LOGIC=======================================================// - @Override - public void updateEntity() { + @Override + public void updateEntity() { - } + } - //==========================================SYNCHRONIZATION==================================================// + //==========================================SYNCHRONIZATION==================================================// - @Override - public Packet getDescriptionPacket() { - NBTTagCompound tagCompound = new NBTTagCompound(); - this.writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + this.writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - //==============================================INVENTORY====================================================// + //==============================================INVENTORY====================================================// - @Override - public int getSizeInventory() { - return items.length; - } + @Override + public int getSizeInventory() { + return items.length; + } - @Override - public ItemStack getStackInSlot(int i) { - return items[i]; - } + @Override + public ItemStack getStackInSlot(int i) { + return items[i]; + } - @Override - public ItemStack decrStackSize(int i, int count) { - ItemStack itemstack = getStackInSlot(i); + @Override + public ItemStack decrStackSize(int i, int count) { + ItemStack itemstack = getStackInSlot(i); - if (itemstack != null) { - if (itemstack.stackSize <= count) { - setInventorySlotContents(i, null); - } else { - itemstack = itemstack.splitStack(count); - if (itemstack.stackSize == 0) { - setInventorySlotContents(i, null); - } - } - } - return itemstack; - } + if (itemstack != null) { + if (itemstack.stackSize <= count) { + setInventorySlotContents(i, null); + } else { + itemstack = itemstack.splitStack(count); + if (itemstack.stackSize == 0) { + setInventorySlotContents(i, null); + } + } + } + return itemstack; + } - @Override - public ItemStack getStackInSlotOnClosing(int i) { - ItemStack item = getStackInSlot(i); - if (item != null) setInventorySlotContents(i, null); - return item; - } + @Override + public ItemStack getStackInSlotOnClosing(int i) { + ItemStack item = getStackInSlot(i); + if (item != null) setInventorySlotContents(i, null); + return item; + } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - items[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); - } - } + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + items[i] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } - @Override - public String getInventoryName() { - return ""; - } + @Override + public String getInventoryName() { + return ""; + } - @Override - public boolean hasCustomInventoryName() { - return false; - } + @Override + public boolean hasCustomInventoryName() { + return false; + } - @Override - public int getInventoryStackLimit() { - return 64; - } + @Override + public int getInventoryStackLimit() { + return 64; + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; - } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; + } - @Override - public void openInventory() {} + @Override + public void openInventory() { + } - @Override - public void closeInventory() {} + @Override + public void closeInventory() { + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } - @Override - public int[] getAccessibleSlotsFromSide(int var1) { - return new int[] {0,1,2,3,4,5,6,7,8}; - } + @Override + public int[] getAccessibleSlotsFromSide(int var1) { + return new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8}; + } - @Override - public boolean canInsertItem(int slot, ItemStack item, int side) { - return true; - } + @Override + public boolean canInsertItem(int slot, ItemStack item, int side) { + return true; + } - @Override - public boolean canExtractItem(int slot, ItemStack item, int side) { - return true; - } + @Override + public boolean canExtractItem(int slot, ItemStack item, int side) { + return true; + } - //===========================================================================================================// + //===========================================================================================================// - @Override - public void writeToNBT(NBTTagCompound compound) - { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void writeToNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) - { - tag[i] = new NBTTagCompound(); + for (int i = 0; i < items.length; i++) { + tag[i] = new NBTTagCompound(); - if (items[i] != null) - { - tag[i] = items[i].writeToNBT(tag[i]); - } + if (items[i] != null) { + tag[i] = items[i].writeToNBT(tag[i]); + } - compound.setTag("Item" + i, tag[i]); - } - super.writeToNBT(compound); - } + compound.setTag("Item" + i, tag[i]); + } + super.writeToNBT(compound); + } - @Override - public void readFromNBT(NBTTagCompound compound) - { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void readFromNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) - { - tag[i] = compound.getCompoundTag("Item" + i); - items[i] = ItemStack.loadItemStackFromNBT(tag[i]); - } - super.readFromNBT(compound); - } + for (int i = 0; i < items.length; i++) { + tag[i] = compound.getCompoundTag("Item" + i); + items[i] = ItemStack.loadItemStackFromNBT(tag[i]); + } + super.readFromNBT(compound); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileCustomSpawner.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileCustomSpawner.java index 5955f316..a3ba2084 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileCustomSpawner.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileCustomSpawner.java @@ -9,39 +9,37 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class TileCustomSpawner extends TileEntity -{ - public boolean isSetToSpawn = false; - public EntityPlayer owner; +public class TileCustomSpawner extends TileEntity { + public boolean isSetToSpawn = false; + public EntityPlayer owner; - private final CustomSpawnerBaseLogic spawnerBaseLogic = new CustomSpawnerBaseLogic(){ - public void blockEvent(int par1) - { - worldObj.addBlockEvent(xCoord, yCoord, zCoord, Blocks.mob_spawner, par1, 0); - } - public World getSpawnerWorld() - { - return worldObj; - } - public int getSpawnerX() - { - return xCoord; - } - public int getSpawnerY() - { - return yCoord; - } - public int getSpawnerZ() - { - return zCoord; - } - }; + private final CustomSpawnerBaseLogic spawnerBaseLogic = new CustomSpawnerBaseLogic() { + public void blockEvent(int par1) { + worldObj.addBlockEvent(xCoord, yCoord, zCoord, Blocks.mob_spawner, par1, 0); + } - public void updateEntity(){ - if (isSetToSpawn) { - spawnerBaseLogic.updateSpawner(); - } - /* + public World getSpawnerWorld() { + return worldObj; + } + + public int getSpawnerX() { + return xCoord; + } + + public int getSpawnerY() { + return yCoord; + } + + public int getSpawnerZ() { + return zCoord; + } + }; + + public void updateEntity() { + if (isSetToSpawn) { + spawnerBaseLogic.updateSpawner(); + } + /* else if (trySet && owner != null){ if (worldObj.isRemote) spawnParticles(false); @@ -81,34 +79,33 @@ public class TileCustomSpawner extends TileEntity trySet = false; } */ - } + } - public void writeToNBT(NBTTagCompound tagCompound){ - super.writeToNBT(tagCompound); - spawnerBaseLogic.writeToNBT(tagCompound); - tagCompound.setBoolean("Running", isSetToSpawn); - } + public void writeToNBT(NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + spawnerBaseLogic.writeToNBT(tagCompound); + tagCompound.setBoolean("Running", isSetToSpawn); + } - public void readFromNBT(NBTTagCompound tagCompound){ - super.readFromNBT(tagCompound); - spawnerBaseLogic.readFromNBT(tagCompound); - isSetToSpawn = tagCompound.getBoolean("Running"); - } + public void readFromNBT(NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + spawnerBaseLogic.readFromNBT(tagCompound); + isSetToSpawn = tagCompound.getBoolean("Running"); + } - @Override - public Packet getDescriptionPacket(){ - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeToNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - public CustomSpawnerBaseLogic getBaseLogic() - { - return spawnerBaseLogic; - } + public CustomSpawnerBaseLogic getBaseLogic() { + return spawnerBaseLogic; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileDissEnchanter.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileDissEnchanter.java index 48743560..da0f805e 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileDissEnchanter.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileDissEnchanter.java @@ -21,267 +21,258 @@ import java.util.Map; /** * Created by Brandon on 27/06/2014. */ -public class TileDissEnchanter extends TileEntity implements ISidedInventory { - ItemStack[] items = new ItemStack[3]; - public boolean isValidRecipe = false; - public int dissenchantCost = 0; - public int timer = 0; - public float bookPower = 0f; +public class TileDissEnchanter extends TileEntity implements ISidedInventory { + ItemStack[] items = new ItemStack[3]; + public boolean isValidRecipe = false; + public int dissenchantCost = 0; + public int timer = 0; + public float bookPower = 0f; - //==============================================LOGIC=======================================================// + //==============================================LOGIC=======================================================// - @Override - public void updateEntity() { - timer ++; - if (worldObj.isRemote && isValidRecipe && worldObj.rand.nextFloat() > 0.5f){ - worldObj.spawnParticle("enchantmenttable", xCoord + 0.3 + (worldObj.rand.nextDouble()*0.4), yCoord + 0.7 + (worldObj.rand.nextDouble()*0.5), zCoord + 0.3 + (worldObj.rand.nextDouble()*0.4), 0D, 0.3D, 0D); - } - } + @Override + public void updateEntity() { + timer++; + if (worldObj.isRemote && isValidRecipe && worldObj.rand.nextFloat() > 0.5f) { + worldObj.spawnParticle("enchantmenttable", xCoord + 0.3 + (worldObj.rand.nextDouble() * 0.4), yCoord + 0.7 + (worldObj.rand.nextDouble() * 0.5), zCoord + 0.3 + (worldObj.rand.nextDouble() * 0.4), 0D, 0.3D, 0D); + } + } - public void onInventoryChanged(){ - boolean flag = true; - if (items[2] != null || items[1] == null || items[0] == null){ - flag = false; - dissenchantCost = 0; - }else { - if (items[1].getItem() != Items.book || EnchantmentHelper.getEnchantments(items[0]).size() == 0) flag = false; - } - if (items[0] != null) dissenchantCost = ItemNBTHelper.getInteger(items[0], "RepairCost", 0); - //if (flag) dissenchantCost = ItemNBTHelper.getInteger(items[0], "RepairCost", 0); - //else dissenchantCost = 0; - isValidRecipe = flag; + public void onInventoryChanged() { + boolean flag = true; + if (items[2] != null || items[1] == null || items[0] == null) { + flag = false; + dissenchantCost = 0; + } else { + if (items[1].getItem() != Items.book || EnchantmentHelper.getEnchantments(items[0]).size() == 0) + flag = false; + } + if (items[0] != null) dissenchantCost = ItemNBTHelper.getInteger(items[0], "RepairCost", 0); + //if (flag) dissenchantCost = ItemNBTHelper.getInteger(items[0], "RepairCost", 0); + //else dissenchantCost = 0; + isValidRecipe = flag; - if (!this.worldObj.isRemote) - { - int j; - bookPower = 0; + if (!this.worldObj.isRemote) { + int j; + bookPower = 0; - for (j = -1; j <= 1; ++j) - { - for (int k = -1; k <= 1; ++k) - { - if ((j != 0 || k != 0) && this.worldObj.isAirBlock(this.xCoord + k, this.yCoord, this.zCoord + j) && this.worldObj.isAirBlock(this.xCoord + k, this.yCoord + 1, this.zCoord + j)) - { - bookPower += ForgeHooks.getEnchantPower(worldObj, xCoord + k * 2, yCoord, zCoord + j * 2); - bookPower += ForgeHooks.getEnchantPower(worldObj, xCoord + k * 2, yCoord + 1, zCoord + j * 2); + for (j = -1; j <= 1; ++j) { + for (int k = -1; k <= 1; ++k) { + if ((j != 0 || k != 0) && this.worldObj.isAirBlock(this.xCoord + k, this.yCoord, this.zCoord + j) && this.worldObj.isAirBlock(this.xCoord + k, this.yCoord + 1, this.zCoord + j)) { + bookPower += ForgeHooks.getEnchantPower(worldObj, xCoord + k * 2, yCoord, zCoord + j * 2); + bookPower += ForgeHooks.getEnchantPower(worldObj, xCoord + k * 2, yCoord + 1, zCoord + j * 2); - if (k != 0 && j != 0) - { - bookPower += ForgeHooks.getEnchantPower(worldObj, xCoord + k * 2, yCoord, zCoord + j ); - bookPower += ForgeHooks.getEnchantPower(worldObj, xCoord + k * 2, yCoord + 1, zCoord + j ); - bookPower += ForgeHooks.getEnchantPower(worldObj, xCoord + k, yCoord, zCoord + j * 2); - bookPower += ForgeHooks.getEnchantPower(worldObj, xCoord + k, yCoord + 1, zCoord + j * 2); - } - } - } - } - } - bookPower = bookPower*2; - if (bookPower > 40) bookPower = 40; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } + if (k != 0 && j != 0) { + bookPower += ForgeHooks.getEnchantPower(worldObj, xCoord + k * 2, yCoord, zCoord + j); + bookPower += ForgeHooks.getEnchantPower(worldObj, xCoord + k * 2, yCoord + 1, zCoord + j); + bookPower += ForgeHooks.getEnchantPower(worldObj, xCoord + k, yCoord, zCoord + j * 2); + bookPower += ForgeHooks.getEnchantPower(worldObj, xCoord + k, yCoord + 1, zCoord + j * 2); + } + } + } + } + } + bookPower = bookPower * 2; + if (bookPower > 40) bookPower = 40; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } - @SuppressWarnings("unchecked") - public void buttonClick(EntityPlayer player){ - if (!isValidRecipe) return; - if (player.experienceLevel < dissenchantCost && !player.capabilities.isCreativeMode) return; - ItemStack input = items[0]; - ItemStack enchantedBook = new ItemStack(Items.enchanted_book); - Map enchants = EnchantmentHelper.getEnchantments(input); - Object id = null; - Object level = null; - String tagName = "ench"; - if (input.getItem() == Items.enchanted_book) tagName = "StoredEnchantments"; - Iterator i = enchants.keySet().iterator(); - if (i.hasNext()) id = i.next(); - if (id == null) return; - level = enchants.get(id); - if (level == null) return; - Map enchant = new HashMap(); - enchant.put(id, level); - EnchantmentHelper.setEnchantments(enchant, enchantedBook); - setInventorySlotContents(2, enchantedBook); - NBTTagCompound compound = input.getTagCompound(); - NBTTagList list = new NBTTagList(); - if (compound.getTag(tagName) instanceof NBTTagList) list = (NBTTagList)compound.getTag(tagName); - if (list == null) return; - for (int j = 0; j < list.tagCount(); j++){ - if (list.getCompoundTagAt(j).getShort("id") == id.hashCode()){ - list.removeTag(j); - } - } + @SuppressWarnings("unchecked") + public void buttonClick(EntityPlayer player) { + if (!isValidRecipe) return; + if (player.experienceLevel < dissenchantCost && !player.capabilities.isCreativeMode) return; + ItemStack input = items[0]; + ItemStack enchantedBook = new ItemStack(Items.enchanted_book); + Map enchants = EnchantmentHelper.getEnchantments(input); + Object id = null; + Object level = null; + String tagName = "ench"; + if (input.getItem() == Items.enchanted_book) tagName = "StoredEnchantments"; + Iterator i = enchants.keySet().iterator(); + if (i.hasNext()) id = i.next(); + if (id == null) return; + level = enchants.get(id); + if (level == null) return; + Map enchant = new HashMap(); + enchant.put(id, level); + EnchantmentHelper.setEnchantments(enchant, enchantedBook); + setInventorySlotContents(2, enchantedBook); + NBTTagCompound compound = input.getTagCompound(); + NBTTagList list = new NBTTagList(); + if (compound.getTag(tagName) instanceof NBTTagList) list = (NBTTagList) compound.getTag(tagName); + if (list == null) return; + for (int j = 0; j < list.tagCount(); j++) { + if (list.getCompoundTagAt(j).getShort("id") == id.hashCode()) { + list.removeTag(j); + } + } - compound.removeTag(tagName); - if (list.tagCount() > 0) input.setTagInfo(tagName, list); - if (input.getItem() == Items.enchanted_book && list.tagCount() == 0) setInventorySlotContents(0, null); - if (!player.capabilities.isCreativeMode) player.addExperienceLevel(-dissenchantCost); - if (items[0] != null && ItemNBTHelper.getInteger(items[0], "RepairCost", 0) > 0)ItemNBTHelper.setInteger(items[0], "RepairCost", ItemNBTHelper.getInteger(items[0], "RepairCost", 0) - Math.min(2, ItemNBTHelper.getInteger(items[0], "RepairCost", 0))); - if (!player.capabilities.isCreativeMode) decrStackSize(1, 1); - int maxDamage = items[0] != null ? items[0].getMaxDamage() : 0; - float damageF = (40f - bookPower)/100f; - int damage = (int)(damageF*(float)maxDamage); - int damageResult = items[0] != null ? items[0].getItemDamage() + damage : 0; + compound.removeTag(tagName); + if (list.tagCount() > 0) input.setTagInfo(tagName, list); + if (input.getItem() == Items.enchanted_book && list.tagCount() == 0) setInventorySlotContents(0, null); + if (!player.capabilities.isCreativeMode) player.addExperienceLevel(-dissenchantCost); + if (items[0] != null && ItemNBTHelper.getInteger(items[0], "RepairCost", 0) > 0) + ItemNBTHelper.setInteger(items[0], "RepairCost", ItemNBTHelper.getInteger(items[0], "RepairCost", 0) - Math.min(2, ItemNBTHelper.getInteger(items[0], "RepairCost", 0))); + if (!player.capabilities.isCreativeMode) decrStackSize(1, 1); + int maxDamage = items[0] != null ? items[0].getMaxDamage() : 0; + float damageF = (40f - bookPower) / 100f; + int damage = (int) (damageF * (float) maxDamage); + int damageResult = items[0] != null ? items[0].getItemDamage() + damage : 0; - if (!player.capabilities.isCreativeMode && damageResult > maxDamage && maxDamage > 0) { - setInventorySlotContents(0, null); - }else if (!player.capabilities.isCreativeMode && maxDamage > 0 && items[0] != null){ - items[0].setItemDamage(damageResult); - } - onInventoryChanged(); - } + if (!player.capabilities.isCreativeMode && damageResult > maxDamage && maxDamage > 0) { + setInventorySlotContents(0, null); + } else if (!player.capabilities.isCreativeMode && maxDamage > 0 && items[0] != null) { + items[0].setItemDamage(damageResult); + } + onInventoryChanged(); + } - //==========================================SYNCHRONIZATION==============================================e====// + //==========================================SYNCHRONIZATION==============================================e====// - @Override - public Packet getDescriptionPacket() { - NBTTagCompound tagCompound = new NBTTagCompound(); - this.writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + this.writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - //==============================================INVENTORY====================================================// + //==============================================INVENTORY====================================================// - @Override - public int getSizeInventory() { - return items.length; - } + @Override + public int getSizeInventory() { + return items.length; + } - @Override - public ItemStack getStackInSlot(int i) { - return items[i]; - } + @Override + public ItemStack getStackInSlot(int i) { + return items[i]; + } - @Override - public ItemStack decrStackSize(int i, int count) { - ItemStack itemstack = getStackInSlot(i); + @Override + public ItemStack decrStackSize(int i, int count) { + ItemStack itemstack = getStackInSlot(i); - if (itemstack != null) { - if (itemstack.stackSize <= count) { - setInventorySlotContents(i, null); - } else { - itemstack = itemstack.splitStack(count); - if (itemstack.stackSize == 0) { - setInventorySlotContents(i, null); - } - } - } - return itemstack; - } + if (itemstack != null) { + if (itemstack.stackSize <= count) { + setInventorySlotContents(i, null); + } else { + itemstack = itemstack.splitStack(count); + if (itemstack.stackSize == 0) { + setInventorySlotContents(i, null); + } + } + } + return itemstack; + } - @Override - public ItemStack getStackInSlotOnClosing(int i) { - ItemStack item = getStackInSlot(i); - if (item != null) setInventorySlotContents(i, null); - return item; - } + @Override + public ItemStack getStackInSlotOnClosing(int i) { + ItemStack item = getStackInSlot(i); + if (item != null) setInventorySlotContents(i, null); + return item; + } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - items[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); - } - } + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + items[i] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } - @Override - public String getInventoryName() { - return ""; - } + @Override + public String getInventoryName() { + return ""; + } - @Override - public boolean hasCustomInventoryName() { - return false; - } + @Override + public boolean hasCustomInventoryName() { + return false; + } - @Override - public int getInventoryStackLimit() { - return 64; - } + @Override + public int getInventoryStackLimit() { + return 64; + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) - { - if (worldObj == null) - { - return true; - } - if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) - { - return false; - } - return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; - } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + if (worldObj == null) { + return true; + } + if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { + return false; + } + return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; + } - @Override - public void openInventory() {} + @Override + public void openInventory() { + } - @Override - public void closeInventory() {} + @Override + public void closeInventory() { + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack){ - if (i == 1 && itemstack.getItem().equals(Items.book)) return true; - return false; - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + if (i == 1 && itemstack.getItem().equals(Items.book)) return true; + return false; + } - @Override - public int[] getAccessibleSlotsFromSide(int var1) { - return new int[] {1}; - } + @Override + public int[] getAccessibleSlotsFromSide(int var1) { + return new int[]{1}; + } - @Override - public boolean canInsertItem(int slot, ItemStack item, int side) { - return true; - } + @Override + public boolean canInsertItem(int slot, ItemStack item, int side) { + return true; + } - @Override - public boolean canExtractItem(int slot, ItemStack item, int side) { - return true; - } + @Override + public boolean canExtractItem(int slot, ItemStack item, int side) { + return true; + } - //===========================================================================================================// + //===========================================================================================================// - @Override - public void writeToNBT(NBTTagCompound compound) - { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void writeToNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) - { - tag[i] = new NBTTagCompound(); + for (int i = 0; i < items.length; i++) { + tag[i] = new NBTTagCompound(); - if (items[i] != null) - { - tag[i] = items[i].writeToNBT(tag[i]); - } + if (items[i] != null) { + tag[i] = items[i].writeToNBT(tag[i]); + } - compound.setTag("Item" + i, tag[i]); - } - compound.setBoolean("IsValid", isValidRecipe); - compound.setInteger("Cost", dissenchantCost); - compound.setFloat("ServivalChance", bookPower); - super.writeToNBT(compound); - } + compound.setTag("Item" + i, tag[i]); + } + compound.setBoolean("IsValid", isValidRecipe); + compound.setInteger("Cost", dissenchantCost); + compound.setFloat("ServivalChance", bookPower); + super.writeToNBT(compound); + } - @Override - public void readFromNBT(NBTTagCompound compound) - { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void readFromNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) - { - tag[i] = compound.getCompoundTag("Item" + i); - items[i] = ItemStack.loadItemStackFromNBT(tag[i]); - } - isValidRecipe = compound.getBoolean("IsValid"); - dissenchantCost = compound.getInteger("Cost"); - bookPower = compound.getFloat("ServivalChance"); - super.readFromNBT(compound); - } + for (int i = 0; i < items.length; i++) { + tag[i] = compound.getCompoundTag("Item" + i); + items[i] = ItemStack.loadItemStackFromNBT(tag[i]); + } + isValidRecipe = compound.getBoolean("IsValid"); + dissenchantCost = compound.getInteger("Cost"); + bookPower = compound.getFloat("ServivalChance"); + super.readFromNBT(compound); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileDraconiumChest.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileDraconiumChest.java index 5dd6d7ef..d90b5411 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileDraconiumChest.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileDraconiumChest.java @@ -29,632 +29,620 @@ import java.util.List; * Created by Brandon on 27/06/2014. */ public class TileDraconiumChest extends TileEntity implements ISidedInventory, IEnergyReceiver, ICustomItemData { - ItemStack[] items = new ItemStack[240]; - ItemStack[] itemsCrafting = new ItemStack[10]; - private int ticksSinceSync = -1; - public float prevLidAngle; - public float lidAngle; - private int numUsingPlayers; - private int facing; - public int red = 100; - public int green = 0; - public int blue = 150; - public boolean editMode = false; - public boolean lockOutputSlots = false; - private String customName; - public EnergyStorage energy = new EnergyStorage(1000000, 10000, 0); + ItemStack[] items = new ItemStack[240]; + ItemStack[] itemsCrafting = new ItemStack[10]; + private int ticksSinceSync = -1; + public float prevLidAngle; + public float lidAngle; + private int numUsingPlayers; + private int facing; + public int red = 100; + public int green = 0; + public int blue = 150; + public boolean editMode = false; + public boolean lockOutputSlots = false; + private String customName; + public EnergyStorage energy = new EnergyStorage(1000000, 10000, 0); - /** - * Current smelting progress. Ranges from 0 to 1000 - */ - public int smeltingProgressTime; - /** - * How fast the furnace is smelting (used by flame animation) range:0 - 100 - */ - public int smeltingBurnSpeed; - public final int smeltingMaxBurnSpeed = 50; - public final int smeltingCompleateTime = 1600; - public int smeltingAutoFeed = 0; - public int tick; - private boolean inTick = false; - private boolean requiresUpdate = false; + /** + * Current smelting progress. Ranges from 0 to 1000 + */ + public int smeltingProgressTime; + /** + * How fast the furnace is smelting (used by flame animation) range:0 - 100 + */ + public int smeltingBurnSpeed; + public final int smeltingMaxBurnSpeed = 50; + public final int smeltingCompleateTime = 1600; + public int smeltingAutoFeed = 0; + public int tick; + private boolean inTick = false; + private boolean requiresUpdate = false; - @Override - public void updateEntity() { - // Resynchronize clients with the server state - if (worldObj != null && !this.worldObj.isRemote && this.numUsingPlayers != 0 && (this.ticksSinceSync + this.xCoord + this.yCoord + this.zCoord) % 200 == 0) { - this.numUsingPlayers = 0; - float var1 = 5.0F; - @SuppressWarnings("unchecked") List var2 = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox((double) ((float) this.xCoord - var1), (double) ((float) this.yCoord - var1), (double) ((float) this.zCoord - var1), (double) ((float) (this.xCoord + 1) + var1), (double) ((float) (this.yCoord + 1) + var1), (double) ((float) (this.zCoord + 1) + var1))); + @Override + public void updateEntity() { + // Resynchronize clients with the server state + if (worldObj != null && !this.worldObj.isRemote && this.numUsingPlayers != 0 && (this.ticksSinceSync + this.xCoord + this.yCoord + this.zCoord) % 200 == 0) { + this.numUsingPlayers = 0; + float var1 = 5.0F; + @SuppressWarnings("unchecked") List var2 = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox((double) ((float) this.xCoord - var1), (double) ((float) this.yCoord - var1), (double) ((float) this.zCoord - var1), (double) ((float) (this.xCoord + 1) + var1), (double) ((float) (this.yCoord + 1) + var1), (double) ((float) (this.zCoord + 1) + var1))); - for (EntityPlayer var4 : var2) { - if (var4.openContainer instanceof ContainerDraconiumChest) { - ++this.numUsingPlayers; - } - } - } + for (EntityPlayer var4 : var2) { + if (var4.openContainer instanceof ContainerDraconiumChest) { + ++this.numUsingPlayers; + } + } + } - if (worldObj != null && !worldObj.isRemote && ticksSinceSync < 0) { - worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.draconiumChest, 3, ((numUsingPlayers << 3) & 0xF8) | (facing & 0x7)); - } + if (worldObj != null && !worldObj.isRemote && ticksSinceSync < 0) { + worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.draconiumChest, 3, ((numUsingPlayers << 3) & 0xF8) | (facing & 0x7)); + } - this.ticksSinceSync++; - prevLidAngle = lidAngle; - float f = 0.1F; - if (numUsingPlayers > 0 && lidAngle == 0.0F) { - double d = (double) xCoord + 0.5D; - double d1 = (double) zCoord + 0.5D; - worldObj.playSoundEffect(d, (double) yCoord + 0.5D, d1, "random.chestopen", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F); - } - if (numUsingPlayers == 0 && lidAngle > 0.0F || numUsingPlayers > 0 && lidAngle < 1.0F) { - float f1 = lidAngle; - if (numUsingPlayers > 0) { - lidAngle += f; - } else { - lidAngle -= f; - } - if (lidAngle > 1.0F) { - lidAngle = 1.0F; - } - float f2 = 0.5F; - if (lidAngle < f2 && f1 >= f2) { - double d2 = (double) xCoord + 0.5D; - double d3 = (double) zCoord + 0.5D; - worldObj.playSoundEffect(d2, (double) yCoord + 0.5D, d3, "random.chestclosed", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F); - } - if (lidAngle < 0.0F) { - lidAngle = 0.0F; - } - } - updateFurnace(); - updateEnergy(); - } + this.ticksSinceSync++; + prevLidAngle = lidAngle; + float f = 0.1F; + if (numUsingPlayers > 0 && lidAngle == 0.0F) { + double d = (double) xCoord + 0.5D; + double d1 = (double) zCoord + 0.5D; + worldObj.playSoundEffect(d, (double) yCoord + 0.5D, d1, "random.chestopen", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + if (numUsingPlayers == 0 && lidAngle > 0.0F || numUsingPlayers > 0 && lidAngle < 1.0F) { + float f1 = lidAngle; + if (numUsingPlayers > 0) { + lidAngle += f; + } else { + lidAngle -= f; + } + if (lidAngle > 1.0F) { + lidAngle = 1.0F; + } + float f2 = 0.5F; + if (lidAngle < f2 && f1 >= f2) { + double d2 = (double) xCoord + 0.5D; + double d3 = (double) zCoord + 0.5D; + worldObj.playSoundEffect(d2, (double) yCoord + 0.5D, d3, "random.chestclosed", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + if (lidAngle < 0.0F) { + lidAngle = 0.0F; + } + } + updateFurnace(); + updateEnergy(); + } - public void updateEnergy() {//todo if no charging item wait a sec before checking again - if (energy.getEnergyStored() < energy.getMaxEnergyStored() && getStackInSlot(239) != null && getStackInSlot(239).getItem() instanceof IEnergyContainerItem) { - IEnergyContainerItem item = (IEnergyContainerItem) getStackInSlot(239).getItem(); - item.extractEnergy(getStackInSlot(239), receiveEnergy(ForgeDirection.DOWN, item.extractEnergy(getStackInSlot(239), energy.getMaxReceive(), true), false), false); - } - } + public void updateEnergy() {//todo if no charging item wait a sec before checking again + if (energy.getEnergyStored() < energy.getMaxEnergyStored() && getStackInSlot(239) != null && getStackInSlot(239).getItem() instanceof IEnergyContainerItem) { + IEnergyContainerItem item = (IEnergyContainerItem) getStackInSlot(239).getItem(); + item.extractEnergy(getStackInSlot(239), receiveEnergy(ForgeDirection.DOWN, item.extractEnergy(getStackInSlot(239), energy.getMaxReceive(), true), false), false); + } + } - private boolean smeltInProgress = false; - private boolean updateSuspended = false; + private boolean smeltInProgress = false; + private boolean updateSuspended = false; - public void updateFurnace() { - if (worldObj.isRemote) return; - tick++; + public void updateFurnace() { + if (worldObj.isRemote) return; + tick++; - if (requiresUpdate && numUsingPlayers > 0) - { - if (!smeltInProgress && !updateSuspended) { - if (getFill() || getLock() || getAll()) feedNextItem(); - smeltInProgress = canFurnaceRun(); - } - requiresUpdate = false; - } + if (requiresUpdate && numUsingPlayers > 0) { + if (!smeltInProgress && !updateSuspended) { + if (getFill() || getLock() || getAll()) feedNextItem(); + smeltInProgress = canFurnaceRun(); + } + requiresUpdate = false; + } - //LogHelper.info("S.I.P: " + smeltInProgress + " S.S.D: " + updateSuspended + " C.F.R: " + canFurnaceRun()); - if (updateSuspended && (getTick() % 500) != 0) return; + //LogHelper.info("S.I.P: " + smeltInProgress + " S.S.D: " + updateSuspended + " C.F.R: " + canFurnaceRun()); + if (updateSuspended && (getTick() % 500) != 0) return; - updateSuspended = false; - inTick = true; + updateSuspended = false; + inTick = true; - //======= Try to start the furnace ==================================================== - if (!smeltInProgress && (getTick() % 500) == 0 && energy.getEnergyStored() > 1000) - { - if (getFill() || getLock() || getAll()) feedNextItem(); - smeltInProgress = canFurnaceRun(); - } - //===================================================================================== - //======= Furnace running ============================================================= + //======= Try to start the furnace ==================================================== + if (!smeltInProgress && (getTick() % 500) == 0 && energy.getEnergyStored() > 1000) { + if (getFill() || getLock() || getAll()) feedNextItem(); + smeltInProgress = canFurnaceRun(); + } + //===================================================================================== + //======= Furnace running ============================================================= - if (smeltInProgress) - { - smeltingBurnSpeed = Math.min(energy.getEnergyStored() / 1000, smeltingMaxBurnSpeed); - energy.modifyEnergyStored(-smeltingBurnSpeed * 20); - smeltingProgressTime += smeltingBurnSpeed; + if (smeltInProgress) { + smeltingBurnSpeed = Math.min(energy.getEnergyStored() / 1000, smeltingMaxBurnSpeed); + energy.modifyEnergyStored(-smeltingBurnSpeed * 20); + smeltingProgressTime += smeltingBurnSpeed; - if (smeltingProgressTime >= smeltingCompleateTime) - { - if (canFurnaceRun() && trySmelt()) - { - if (getFill() || getLock() || getAll()) feedNextItem(); - smeltInProgress = canFurnaceRun(); - } - else - { - updateSuspended = true; - smeltInProgress = false; - smeltingProgressTime = 0; - smeltingBurnSpeed = 0; - } - smeltingProgressTime = 0; - } - } - else - { - smeltingProgressTime = 0; - smeltingBurnSpeed = 0; - } + if (smeltingProgressTime >= smeltingCompleateTime) { + if (canFurnaceRun() && trySmelt()) { + if (getFill() || getLock() || getAll()) feedNextItem(); + smeltInProgress = canFurnaceRun(); + } else { + updateSuspended = true; + smeltInProgress = false; + smeltingProgressTime = 0; + smeltingBurnSpeed = 0; + } + smeltingProgressTime = 0; + } + } else { + smeltingProgressTime = 0; + smeltingBurnSpeed = 0; + } - inTick = false; - } + inTick = false; + } - private void confirmRunningState() {} + private void confirmRunningState() { + } - private boolean canFurnaceRun() - { - boolean flag = false; - //====== Check if there is anything to smelt ========================================= - for (int i = 0; i < 5; i++) { - if (getStackInSlot(234 + i) == null) continue; - ItemStack stack = getStackInSlot(234 + i); - if (isSmeltable(stack)) - { - flag = true; - break; - } - } - if (!flag) return false; //Return false if there is nothing to smelt - //===================================================================================== - //===== Confirm that the furnace can still run when lock mode is enabled ============== - if (getLock()){ - flag = false; - for (int i = 0; i < 5; i++) - { - ItemStack recipe = getStackInSlot(234 + i); - if (recipe == null || recipe.stackSize == 1) continue; //checks that there is more then one of at least one item in the input - flag = true; - } - if (!flag) return false; - } - //===================================================================================== - //====== Check if there is room for the output ======================================== - for (int i = 0; i < 5; i++) - { - if (getStackInSlot(234 + i) == null) continue; - ItemStack output = getResult(getStackInSlot(234 + i)).copy(); + private boolean canFurnaceRun() { + boolean flag = false; + //====== Check if there is anything to smelt ========================================= + for (int i = 0; i < 5; i++) { + if (getStackInSlot(234 + i) == null) continue; + ItemStack stack = getStackInSlot(234 + i); + if (isSmeltable(stack)) { + flag = true; + break; + } + } + if (!flag) return false; //Return false if there is nothing to smelt + //===================================================================================== + //===== Confirm that the furnace can still run when lock mode is enabled ============== + if (getLock()) { + flag = false; + for (int i = 0; i < 5; i++) { + ItemStack recipe = getStackInSlot(234 + i); + if (recipe == null || recipe.stackSize == 1) + continue; //checks that there is more then one of at least one item in the input + flag = true; + } + if (!flag) return false; + } + //===================================================================================== + //====== Check if there is room for the output ======================================== + for (int i = 0; i < 5; i++) { + if (getStackInSlot(234 + i) == null) continue; + ItemStack output = getResult(getStackInSlot(234 + i)).copy(); - for (int j = 0; j < getSizeInventory(); j++) { - //if (getStackInSlot(234 + j).stackSize >= getStackInSlot(234 + j).getMaxStackSize()) continue;todo consider? - InventoryUtils.insertItemIntoInventory(this, output, ForgeDirection.DOWN, j, false); - if (output.stackSize == 0) break; - } - if (output.stackSize > 0) return false; //return false if the output could not be added to the inventory - } - //===================================================================================== - return true; - } + for (int j = 0; j < getSizeInventory(); j++) { + //if (getStackInSlot(234 + j).stackSize >= getStackInSlot(234 + j).getMaxStackSize()) continue;todo consider? + InventoryUtils.insertItemIntoInventory(this, output, ForgeDirection.DOWN, j, false); + if (output.stackSize == 0) break; + } + if (output.stackSize > 0) return false; //return false if the output could not be added to the inventory + } + //===================================================================================== + return true; + } - private boolean trySmelt() - { - int itemsToProcess = 5; - int processAttempts = 0; - boolean itemSmelted = false; + private boolean trySmelt() { + int itemsToProcess = 5; + int processAttempts = 0; + boolean itemSmelted = false; - do { - for (int i = 0; i < 5; i++) { + do { + for (int i = 0; i < 5; i++) { - ItemStack recipe = getStackInSlot(234 + i); + ItemStack recipe = getStackInSlot(234 + i); - if (recipe == null || (getLock() && recipe.stackSize == 1)) continue; + if (recipe == null || (getLock() && recipe.stackSize == 1)) continue; - ItemStack result = getResult(recipe).copy(); + ItemStack result = getResult(recipe).copy(); - //Try to merge with existing stacks todo needed? - for (int j = 0; j < getSizeInventory(); j++) { - if (getStackInSlot(j) == null) continue; - InventoryUtils.tryMergeStacks(result, getStackInSlot(j)); - } + //Try to merge with existing stacks todo needed? + for (int j = 0; j < getSizeInventory(); j++) { + if (getStackInSlot(j) == null) continue; + InventoryUtils.tryMergeStacks(result, getStackInSlot(j)); + } - if (result.stackSize > 0) InventoryUtils.insertItemIntoInventory(this, result); //Insert stack into inventory + if (result.stackSize > 0) + InventoryUtils.insertItemIntoInventory(this, result); //Insert stack into inventory - if (result.stackSize == 0) { - recipe.stackSize--; - if (recipe.stackSize == 0) setInventorySlotContents(234 + i, null); - itemsToProcess--; - itemSmelted = true; - } + if (result.stackSize == 0) { + recipe.stackSize--; + if (recipe.stackSize == 0) setInventorySlotContents(234 + i, null); + itemsToProcess--; + itemSmelted = true; + } - if (itemsToProcess == 0) break; - } + if (itemsToProcess == 0) break; + } - processAttempts++; + processAttempts++; - } while (itemsToProcess > 0 && processAttempts < 5); + } while (itemsToProcess > 0 && processAttempts < 5); - return itemSmelted; - } + return itemSmelted; + } - public void feedNextItem() { - boolean[] stacksFull = new boolean[]{false,false,false,false,false}; + public void feedNextItem() { + boolean[] stacksFull = new boolean[]{false, false, false, false, false}; - for (int i = 0; i < getSizeInventory(); i++) { - if (getStackInSlot(i) == null) continue; + for (int i = 0; i < getSizeInventory(); i++) { + if (getStackInSlot(i) == null) continue; - ItemStack candidate = getStackInSlot(i); + ItemStack candidate = getStackInSlot(i); - for (int j = 0; j < 5; j++) { - if (getStackInSlot(234 + j) == null && getAll()) - { + for (int j = 0; j < 5; j++) { + if (getStackInSlot(234 + j) == null && getAll()) { - if (candidate == null) break; - boolean candidateSmeltable = getResult(candidate) != null; - if (candidateSmeltable) { - setInventorySlotContents(234 + j, candidate.copy()); - setInventorySlotContents(i, null); - candidate = null; - } - } + if (candidate == null) break; + boolean candidateSmeltable = getResult(candidate) != null; + if (candidateSmeltable) { + setInventorySlotContents(234 + j, candidate.copy()); + setInventorySlotContents(i, null); + candidate = null; + } + } - if (getStackInSlot(234 + j) == null || candidate == null) continue; + if (getStackInSlot(234 + j) == null || candidate == null) continue; - ItemStack inputSlot = getStackInSlot(234 + j); + ItemStack inputSlot = getStackInSlot(234 + j); - InventoryUtils.tryMergeStacks(candidate, inputSlot); + InventoryUtils.tryMergeStacks(candidate, inputSlot); - if (candidate.stackSize == 0) { - setInventorySlotContents(i, null); - candidate = null; - } + if (candidate.stackSize == 0) { + setInventorySlotContents(i, null); + candidate = null; + } - if (inputSlot.stackSize == inputSlot.getMaxStackSize()) { - stacksFull[j] = true; - } - } + if (inputSlot.stackSize == inputSlot.getMaxStackSize()) { + stacksFull[j] = true; + } + } - if (candidate != null && candidate.stackSize == 0) setInventorySlotContents(i, null); + if (candidate != null && candidate.stackSize == 0) setInventorySlotContents(i, null); - if (stacksFull[0] && stacksFull[1] && stacksFull[2] && stacksFull[3] && stacksFull[4]) break; - } - } + if (stacksFull[0] && stacksFull[1] && stacksFull[2] && stacksFull[3] && stacksFull[4]) break; + } + } - private boolean getFill() {return smeltingAutoFeed == 1;} - private boolean getLock() {return smeltingAutoFeed == 2;} - private boolean getAll() {return smeltingAutoFeed == 3;} + private boolean getFill() { + return smeltingAutoFeed == 1; + } - private boolean isSmeltable(ItemStack stack) { - return FurnaceRecipes.smelting().getSmeltingResult(stack) != null || OreDoublingRegistry.getOreResult(stack) != null; - } + private boolean getLock() { + return smeltingAutoFeed == 2; + } - private ItemStack getResult(ItemStack stack) { - ItemStack oreResult = OreDoublingRegistry.getOreResult(stack); - return oreResult != null ? oreResult : FurnaceRecipes.smelting().getSmeltingResult(stack); - } + private boolean getAll() { + return smeltingAutoFeed == 3; + } - public void setAutoFeed(int i){ - smeltingAutoFeed = i; - } + private boolean isSmeltable(ItemStack stack) { + return FurnaceRecipes.smelting().getSmeltingResult(stack) != null || OreDoublingRegistry.getOreResult(stack) != null; + } - @Override - public boolean receiveClientEvent(int i, int j) { - if (i == 1) { - numUsingPlayers = j; - } else if (i == 2) { - facing = (byte) j; - } else if (i == 3) { - facing = (byte) (j & 0x7); - numUsingPlayers = (j & 0xF8) >> 3; - } - return true; - } + private ItemStack getResult(ItemStack stack) { + ItemStack oreResult = OreDoublingRegistry.getOreResult(stack); + return oreResult != null ? oreResult : FurnaceRecipes.smelting().getSmeltingResult(stack); + } - public void rotateAround(ForgeDirection axis) { - setFacing((byte) ForgeDirection.getOrientation(facing).getRotation(axis).ordinal()); - worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.draconiumChest, 3, ((numUsingPlayers << 3) & 0xF8) | (facing & 0x7)); - } + public void setAutoFeed(int i) { + smeltingAutoFeed = i; + } - public int getFacing() { - return this.facing; - } + @Override + public boolean receiveClientEvent(int i, int j) { + if (i == 1) { + numUsingPlayers = j; + } else if (i == 2) { + facing = (byte) j; + } else if (i == 3) { + facing = (byte) (j & 0x7); + numUsingPlayers = (j & 0xF8) >> 3; + } + return true; + } - public void setFacing(int facing2) { - this.facing = facing2; - } + public void rotateAround(ForgeDirection axis) { + setFacing((byte) ForgeDirection.getOrientation(facing).getRotation(axis).ordinal()); + worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.draconiumChest, 3, ((numUsingPlayers << 3) & 0xF8) | (facing & 0x7)); + } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound compound = new NBTTagCompound(); - compound.setByte("facing", (byte) facing); - compound.setInteger("Red", red); - compound.setInteger("Green", green); - compound.setInteger("Blue", blue); - compound.setBoolean("Edit", editMode); - compound.setByte("AutoFeed", (byte) smeltingAutoFeed); - if (customName != null && customName.length() > 0)compound.setString("CustomName", customName); - energy.writeToNBT(compound); - super.writeToNBT(compound); + public int getFacing() { + return this.facing; + } - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, compound); + public void setFacing(int facing2) { + this.facing = facing2; + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound compound = new NBTTagCompound(); + compound.setByte("facing", (byte) facing); + compound.setInteger("Red", red); + compound.setInteger("Green", green); + compound.setInteger("Blue", blue); + compound.setBoolean("Edit", editMode); + compound.setByte("AutoFeed", (byte) smeltingAutoFeed); + if (customName != null && customName.length() > 0) compound.setString("CustomName", customName); + energy.writeToNBT(compound); + super.writeToNBT(compound); + + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, compound); // NBTTagCompound tagCompound = new NBTTagCompound(); // this.writeToNBT(tagCompound); // return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - @Override - public int getSizeInventory() { - return items.length - 6; - } + @Override + public int getSizeInventory() { + return items.length - 6; + } - @Override - public ItemStack getStackInSlot(int i) { - return items[i]; - } + @Override + public ItemStack getStackInSlot(int i) { + return items[i]; + } - public ItemStack getStackInCraftingSlot(int i) { - return itemsCrafting[i]; - } + public ItemStack getStackInCraftingSlot(int i) { + return itemsCrafting[i]; + } - @Override - public ItemStack decrStackSize(int i, int count) { - ItemStack itemstack = getStackInSlot(i); + @Override + public ItemStack decrStackSize(int i, int count) { + ItemStack itemstack = getStackInSlot(i); - if (itemstack != null) { - if (itemstack.stackSize <= count) { - setInventorySlotContents(i, null); - } else { - itemstack = itemstack.splitStack(count); - if (itemstack.stackSize == 0) { - setInventorySlotContents(i, null); - } - } - } - return itemstack; - } + if (itemstack != null) { + if (itemstack.stackSize <= count) { + setInventorySlotContents(i, null); + } else { + itemstack = itemstack.splitStack(count); + if (itemstack.stackSize == 0) { + setInventorySlotContents(i, null); + } + } + } + return itemstack; + } - @Override - public ItemStack getStackInSlotOnClosing(int i) { - ItemStack item = getStackInSlot(i); - if (item != null) setInventorySlotContents(i, null); - return item; - } + @Override + public ItemStack getStackInSlotOnClosing(int i) { + ItemStack item = getStackInSlot(i); + if (item != null) setInventorySlotContents(i, null); + return item; + } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - items[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); - } - } + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + items[i] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } - public void setInventoryCraftingSlotContents(int i, ItemStack itemstack) { - itemsCrafting[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); - } - } + public void setInventoryCraftingSlotContents(int i, ItemStack itemstack) { + itemsCrafting[i] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } - @Override - public String getInventoryName() { - return hasCustomInventoryName() ? customName : StatCollector.translateToLocal(ModBlocks.draconiumChest.getUnlocalizedName() + ".name"); - } + @Override + public String getInventoryName() { + return hasCustomInventoryName() ? customName : StatCollector.translateToLocal(ModBlocks.draconiumChest.getUnlocalizedName() + ".name"); + } - public void setCustomName(String s){ - customName = s; - } + public void setCustomName(String s) { + customName = s; + } - @Override - public boolean hasCustomInventoryName() { - return customName != null && customName.length() > 0; - } + @Override + public boolean hasCustomInventoryName() { + return customName != null && customName.length() > 0; + } - @Override - public int getInventoryStackLimit() { - return 64; - } + @Override + public int getInventoryStackLimit() { + return 64; + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - if (worldObj == null) - { - return true; - } - if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) - { - return false; - } - return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; - } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + if (worldObj == null) { + return true; + } + if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { + return false; + } + return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; + } - @Override - public void openInventory() { - if (worldObj == null) return; - numUsingPlayers++; - worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.draconiumChest, 1, numUsingPlayers); - } + @Override + public void openInventory() { + if (worldObj == null) return; + numUsingPlayers++; + worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.draconiumChest, 1, numUsingPlayers); + } - @Override - public void closeInventory() { - if (worldObj == null) return; - numUsingPlayers--; - worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.draconiumChest, 1, numUsingPlayers); - } + @Override + public void closeInventory() { + if (worldObj == null) return; + numUsingPlayers--; + worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.draconiumChest, 1, numUsingPlayers); + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return DraconiumChest.isStackValid(itemstack); - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return DraconiumChest.isStackValid(itemstack); + } - @Override - public void writeToNBT(NBTTagCompound compound) { - super.writeToNBT(compound); - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) { - tag[i] = new NBTTagCompound(); + for (int i = 0; i < items.length; i++) { + tag[i] = new NBTTagCompound(); - if (items[i] != null) { - tag[i] = items[i].writeToNBT(tag[i]); - } + if (items[i] != null) { + tag[i] = items[i].writeToNBT(tag[i]); + } - compound.setTag("Item" + i, tag[i]); - } + compound.setTag("Item" + i, tag[i]); + } - for (int i = 0; i < itemsCrafting.length; i++) { - tag[i] = new NBTTagCompound(); + for (int i = 0; i < itemsCrafting.length; i++) { + tag[i] = new NBTTagCompound(); - if (itemsCrafting[i] != null) { - tag[i] = itemsCrafting[i].writeToNBT(tag[i]); - } + if (itemsCrafting[i] != null) { + tag[i] = itemsCrafting[i].writeToNBT(tag[i]); + } - compound.setTag("CraftingItem" + i, tag[i]); - } + compound.setTag("CraftingItem" + i, tag[i]); + } - compound.setByte("facing", (byte) facing); - compound.setInteger("Red", red); - compound.setInteger("Green", green); - compound.setInteger("Blue", blue); - compound.setBoolean("Edit", editMode); - compound.setBoolean("LockOutputSlots", lockOutputSlots); - compound.setByte("AutoFeed", (byte) smeltingAutoFeed); - if (customName != null && customName.length() > 0)compound.setString("CustomName", customName); - energy.writeToNBT(compound); - } + compound.setByte("facing", (byte) facing); + compound.setInteger("Red", red); + compound.setInteger("Green", green); + compound.setInteger("Blue", blue); + compound.setBoolean("Edit", editMode); + compound.setBoolean("LockOutputSlots", lockOutputSlots); + compound.setByte("AutoFeed", (byte) smeltingAutoFeed); + if (customName != null && customName.length() > 0) compound.setString("CustomName", customName); + energy.writeToNBT(compound); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - super.readFromNBT(compound); - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) { - tag[i] = compound.getCompoundTag("Item" + i); - items[i] = ItemStack.loadItemStackFromNBT(tag[i]); - } + for (int i = 0; i < items.length; i++) { + tag[i] = compound.getCompoundTag("Item" + i); + items[i] = ItemStack.loadItemStackFromNBT(tag[i]); + } - for (int i = 0; i < itemsCrafting.length; i++) { - tag[i] = compound.getCompoundTag("CraftingItem" + i); - itemsCrafting[i] = ItemStack.loadItemStackFromNBT(tag[i]); - } + for (int i = 0; i < itemsCrafting.length; i++) { + tag[i] = compound.getCompoundTag("CraftingItem" + i); + itemsCrafting[i] = ItemStack.loadItemStackFromNBT(tag[i]); + } - facing = compound.getByte("facing"); - red = compound.getInteger("Red"); - green = compound.getInteger("Green"); - blue = compound.getInteger("Blue"); - editMode = compound.getBoolean("Edit"); - lockOutputSlots = compound.getBoolean("LockOutputSlots"); - smeltingAutoFeed = compound.getByte("AutoFeed"); - customName = compound.getString("CustomName"); - energy.readFromNBT(compound); - } + facing = compound.getByte("facing"); + red = compound.getInteger("Red"); + green = compound.getInteger("Green"); + blue = compound.getInteger("Blue"); + editMode = compound.getBoolean("Edit"); + lockOutputSlots = compound.getBoolean("LockOutputSlots"); + smeltingAutoFeed = compound.getByte("AutoFeed"); + customName = compound.getString("CustomName"); + energy.readFromNBT(compound); + } - @Override - public void writeDataToItem(NBTTagCompound compound, ItemStack stack) { + @Override + public void writeDataToItem(NBTTagCompound compound, ItemStack stack) { - NBTTagList tagList = new NBTTagList(); + NBTTagList tagList = new NBTTagList(); - for (int i = 0; i < items.length; i++) { - if (items[i] != null) - { - NBTTagCompound tag = new NBTTagCompound(); - tag.setShort("IS", (short)i); - items[i].writeToNBT(tag); - tagList.appendTag(tag); - } - } + for (int i = 0; i < items.length; i++) { + if (items[i] != null) { + NBTTagCompound tag = new NBTTagCompound(); + tag.setShort("IS", (short) i); + items[i].writeToNBT(tag); + tagList.appendTag(tag); + } + } - for (int i = 0; i < itemsCrafting.length; i++) { - if (itemsCrafting[i] != null) - { - NBTTagCompound tag = new NBTTagCompound(); - tag.setShort("CS", (short)i); - itemsCrafting[i].writeToNBT(tag); - tagList.appendTag(tag); - } - } + for (int i = 0; i < itemsCrafting.length; i++) { + if (itemsCrafting[i] != null) { + NBTTagCompound tag = new NBTTagCompound(); + tag.setShort("CS", (short) i); + itemsCrafting[i].writeToNBT(tag); + tagList.appendTag(tag); + } + } - compound.setTag("Inventory", tagList); + compound.setTag("Inventory", tagList); - compound.setInteger("Red", red); - compound.setInteger("Green", green); - compound.setInteger("Blue", blue); - compound.setBoolean("Edit", editMode); - compound.setByte("AutoFeed", (byte) smeltingAutoFeed); - if (hasCustomInventoryName()) stack.setStackDisplayName(customName); - energy.writeToNBT(compound); - } + compound.setInteger("Red", red); + compound.setInteger("Green", green); + compound.setInteger("Blue", blue); + compound.setBoolean("Edit", editMode); + compound.setByte("AutoFeed", (byte) smeltingAutoFeed); + if (hasCustomInventoryName()) stack.setStackDisplayName(customName); + energy.writeToNBT(compound); + } - @Override - public void readDataFromItem(NBTTagCompound compound, ItemStack stack) { + @Override + public void readDataFromItem(NBTTagCompound compound, ItemStack stack) { - if (compound.hasKey("Inventory")) - { - NBTTagList tagList = compound.getTagList("Inventory", 10); - for (int i = 0; i < tagList.tagCount(); i++) - { - NBTTagCompound tag = tagList.getCompoundTagAt(i); - if (tag.hasKey("IS")) - { - items[tag.getShort("IS")] = ItemStack.loadItemStackFromNBT(tag); - } - else if (tag.hasKey("CS")) - { - itemsCrafting[tag.getShort("CS")] = ItemStack.loadItemStackFromNBT(tag); - } - } - } + if (compound.hasKey("Inventory")) { + NBTTagList tagList = compound.getTagList("Inventory", 10); + for (int i = 0; i < tagList.tagCount(); i++) { + NBTTagCompound tag = tagList.getCompoundTagAt(i); + if (tag.hasKey("IS")) { + items[tag.getShort("IS")] = ItemStack.loadItemStackFromNBT(tag); + } else if (tag.hasKey("CS")) { + itemsCrafting[tag.getShort("CS")] = ItemStack.loadItemStackFromNBT(tag); + } + } + } - red = compound.getInteger("Red"); - green = compound.getInteger("Green"); - blue = compound.getInteger("Blue"); - editMode = compound.getBoolean("Edit"); - smeltingAutoFeed = compound.getByte("AutoFeed"); - energy.readFromNBT(compound); - } + red = compound.getInteger("Red"); + green = compound.getInteger("Green"); + blue = compound.getInteger("Blue"); + editMode = compound.getBoolean("Edit"); + smeltingAutoFeed = compound.getByte("AutoFeed"); + energy.readFromNBT(compound); + } - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - return this.energy.receiveEnergy(maxReceive, simulate); - } + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + return this.energy.receiveEnergy(maxReceive, simulate); + } - @Override - public int getEnergyStored(ForgeDirection from) { - return energy.getEnergyStored(); - } + @Override + public int getEnergyStored(ForgeDirection from) { + return energy.getEnergyStored(); + } - @Override - public int getMaxEnergyStored(ForgeDirection from) { - return energy.getMaxEnergyStored(); - } + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return energy.getMaxEnergyStored(); + } - @Override - public boolean canConnectEnergy(ForgeDirection from) { - return true; - } + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return true; + } - @Override - public int[] getAccessibleSlotsFromSide(int side) { - int[] i = new int[getSizeInventory()]; - for (int i1 = 0; i1 < i.length; i1++) i[i1] = i1; - return i; - } + @Override + public int[] getAccessibleSlotsFromSide(int side) { + int[] i = new int[getSizeInventory()]; + for (int i1 = 0; i1 < i.length; i1++) i[i1] = i1; + return i; + } - @Override - public boolean canInsertItem(int slot, ItemStack stack, int side) { - return !lockOutputSlots || inTick || slot < getSizeInventory() - 5; - } + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side) { + return !lockOutputSlots || inTick || slot < getSizeInventory() - 5; + } - @Override - public boolean canExtractItem(int slot, ItemStack stack, int side) { - return true; - } + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side) { + return true; + } - private int getTick() {return xCoord + yCoord + zCoord + tick; } + private int getTick() { + return xCoord + yCoord + zCoord + tick; + } - @Override - public void markDirty() { - super.markDirty(); - if (!worldObj.isRemote) requiresUpdate = true; + @Override + public void markDirty() { + super.markDirty(); + if (!worldObj.isRemote) requiresUpdate = true; - } + } } - //inTick = true; // tick++; // diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileEnergyInfuser.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileEnergyInfuser.java index 77fe816f..5a247a08 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileEnergyInfuser.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileEnergyInfuser.java @@ -24,312 +24,310 @@ import net.minecraftforge.common.util.ForgeDirection; * Created by Brandon on 27/06/2014. */ public class TileEnergyInfuser extends TileObjectSync implements IEnergyReceiver, ISidedInventory { - ItemStack[] items = new ItemStack[1]; - public EnergyStorage energy = new EnergyStorage(BalanceConfigHandler.energyInfuserStorage, BalanceConfigHandler.energyInfuserMaxTransfer); - public boolean running = false; - public boolean runningCach = false; - private int tick = 0; - public float rotation = 0; - /**True is energy was transferred this tick*/ - public boolean transfer = false; - public boolean transferCach = false; + ItemStack[] items = new ItemStack[1]; + public EnergyStorage energy = new EnergyStorage(BalanceConfigHandler.energyInfuserStorage, BalanceConfigHandler.energyInfuserMaxTransfer); + public boolean running = false; + public boolean runningCach = false; + private int tick = 0; + public float rotation = 0; + /** + * True is energy was transferred this tick + */ + public boolean transfer = false; + public boolean transferCach = false; - //==============================================LOGIC=======================================================// + //==============================================LOGIC=======================================================// - @Override - public void updateEntity() { - if (worldObj.isRemote) { - if (running) { - rotation += 0.5F; - if (rotation > 360F) { - rotation = 0; - } - spawnParticles(); - } - return; - } + @Override + public void updateEntity() { + if (worldObj.isRemote) { + if (running) { + rotation += 0.5F; + if (rotation > 360F) { + rotation = 0; + } + spawnParticles(); + } + return; + } - if (tick % 100 == 0) tryStartOrStop(); - if (tick % 400 == 0) detectAndSendChanges(true); + if (tick % 100 == 0) tryStartOrStop(); + if (tick % 400 == 0) detectAndSendChanges(true); - if(running && tryStartOrStop()) - { - IEnergyContainerItem item = (IEnergyContainerItem)items[0].getItem(); - setTransfer(energy.extractEnergy(item.receiveEnergy(items[0], energy.getEnergyStored(), false), false) > 0); - }else setTransfer(false); + if (running && tryStartOrStop()) { + IEnergyContainerItem item = (IEnergyContainerItem) items[0].getItem(); + setTransfer(energy.extractEnergy(item.receiveEnergy(items[0], energy.getEnergyStored(), false), false) > 0); + } else setTransfer(false); - detectAndSendChanges(false); - tick++; - } + detectAndSendChanges(false); + tick++; + } - private boolean tryStartOrStop(){ - if (items[0] != null && items[0].stackSize == 1 && items[0] != null && items[0].getItem() instanceof IEnergyContainerItem) { - IEnergyContainerItem item = (IEnergyContainerItem)items[0].getItem(); - if (item.getEnergyStored(items[0]) < item.getMaxEnergyStored(items[0])) { - running = true; - }else{ - running = false; - } - }else { - running = false; - } + private boolean tryStartOrStop() { + if (items[0] != null && items[0].stackSize == 1 && items[0] != null && items[0].getItem() instanceof IEnergyContainerItem) { + IEnergyContainerItem item = (IEnergyContainerItem) items[0].getItem(); + if (item.getEnergyStored(items[0]) < item.getMaxEnergyStored(items[0])) { + running = true; + } else { + running = false; + } + } else { + running = false; + } - return running; - } + return running; + } - private void setTransfer(boolean t){ - transfer = t; - } - @SideOnly(Side.CLIENT) - private void spawnParticles(){ - if (worldObj.isRemote && running && transfer) { - Random rand = worldObj.rand; - double rotationF; - double yRand; - double radRand; - ParticleEnergy particle; - float y = 0.6f; + private void setTransfer(boolean t) { + transfer = t; + } - yRand = ((rand.nextFloat()-0.5)/2); - radRand = 1 - rand.nextFloat()/2; - rotationF = rotation / 57F; - particle = new ParticleEnergy(worldObj, xCoord + 0.5 + radRand*Math.sin(rotationF), yCoord + y + yRand, zCoord + 0.5 + radRand*Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 1); - ParticleHandler.spawnCustomParticle(particle); + @SideOnly(Side.CLIENT) + private void spawnParticles() { + if (worldObj.isRemote && running && transfer) { + Random rand = worldObj.rand; + double rotationF; + double yRand; + double radRand; + ParticleEnergy particle; + float y = 0.6f; - yRand = ((rand.nextFloat()-0.5)/2); - radRand = 1 - rand.nextFloat()/2; - rotationF = (rotation + 90) / 57F; - particle = new ParticleEnergy(worldObj, xCoord + 0.5 + radRand*Math.sin(rotationF), yCoord + y + yRand, zCoord + 0.5 + radRand*Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 1); - ParticleHandler.spawnCustomParticle(particle); + yRand = ((rand.nextFloat() - 0.5) / 2); + radRand = 1 - rand.nextFloat() / 2; + rotationF = rotation / 57F; + particle = new ParticleEnergy(worldObj, xCoord + 0.5 + radRand * Math.sin(rotationF), yCoord + y + yRand, zCoord + 0.5 + radRand * Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 1); + ParticleHandler.spawnCustomParticle(particle); - yRand = ((rand.nextFloat()-0.5)/2); - radRand = 1 - rand.nextFloat()/2; - rotationF = (rotation + 180) / 57F; - particle = new ParticleEnergy(worldObj, xCoord + 0.5 + radRand*Math.sin(rotationF), yCoord + y + yRand, zCoord + 0.5 + radRand*Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 1); - ParticleHandler.spawnCustomParticle(particle); + yRand = ((rand.nextFloat() - 0.5) / 2); + radRand = 1 - rand.nextFloat() / 2; + rotationF = (rotation + 90) / 57F; + particle = new ParticleEnergy(worldObj, xCoord + 0.5 + radRand * Math.sin(rotationF), yCoord + y + yRand, zCoord + 0.5 + radRand * Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 1); + ParticleHandler.spawnCustomParticle(particle); - yRand = ((rand.nextFloat()-0.5)/2); - radRand = 1 - rand.nextFloat()/2; - rotationF = (rotation + 270) / 57F; - particle = new ParticleEnergy(worldObj, xCoord + 0.5 + radRand*Math.sin(rotationF), yCoord + y + yRand, zCoord + 0.5 + radRand*Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 1); - ParticleHandler.spawnCustomParticle(particle); + yRand = ((rand.nextFloat() - 0.5) / 2); + radRand = 1 - rand.nextFloat() / 2; + rotationF = (rotation + 180) / 57F; + particle = new ParticleEnergy(worldObj, xCoord + 0.5 + radRand * Math.sin(rotationF), yCoord + y + yRand, zCoord + 0.5 + radRand * Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 1); + ParticleHandler.spawnCustomParticle(particle); - y = 0.79f; - radRand = 0.35; - rotationF = rotation / 57F; - particle = new ParticleEnergy(worldObj, xCoord + 0.5 + radRand*Math.sin(rotationF), yCoord + y, zCoord + 0.5 + radRand*Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 0); - ParticleHandler.spawnCustomParticle(particle); + yRand = ((rand.nextFloat() - 0.5) / 2); + radRand = 1 - rand.nextFloat() / 2; + rotationF = (rotation + 270) / 57F; + particle = new ParticleEnergy(worldObj, xCoord + 0.5 + radRand * Math.sin(rotationF), yCoord + y + yRand, zCoord + 0.5 + radRand * Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 1); + ParticleHandler.spawnCustomParticle(particle); - rotationF = (rotation + 90) / 57F; - particle = new ParticleEnergy(worldObj, xCoord + 0.5 + radRand*Math.sin(rotationF), yCoord + y, zCoord + 0.5 + radRand*Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 0); - ParticleHandler.spawnCustomParticle(particle); + y = 0.79f; + radRand = 0.35; + rotationF = rotation / 57F; + particle = new ParticleEnergy(worldObj, xCoord + 0.5 + radRand * Math.sin(rotationF), yCoord + y, zCoord + 0.5 + radRand * Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 0); + ParticleHandler.spawnCustomParticle(particle); - rotationF = (rotation + 180) / 57F; - particle = new ParticleEnergy(worldObj, xCoord + 0.5 + radRand*Math.sin(rotationF), yCoord + y, zCoord + 0.5 + radRand*Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 0); - ParticleHandler.spawnCustomParticle(particle); + rotationF = (rotation + 90) / 57F; + particle = new ParticleEnergy(worldObj, xCoord + 0.5 + radRand * Math.sin(rotationF), yCoord + y, zCoord + 0.5 + radRand * Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 0); + ParticleHandler.spawnCustomParticle(particle); - rotationF = (rotation + 270) / 57F; - particle = new ParticleEnergy(worldObj, xCoord + 0.5 + radRand*Math.sin(rotationF), yCoord + y, zCoord + 0.5 + radRand*Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 0); - ParticleHandler.spawnCustomParticle(particle); - } - } - //==============================================ENERGY======================================================// + rotationF = (rotation + 180) / 57F; + particle = new ParticleEnergy(worldObj, xCoord + 0.5 + radRand * Math.sin(rotationF), yCoord + y, zCoord + 0.5 + radRand * Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 0); + ParticleHandler.spawnCustomParticle(particle); - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - return this.energy.receiveEnergy(maxReceive, simulate); - } + rotationF = (rotation + 270) / 57F; + particle = new ParticleEnergy(worldObj, xCoord + 0.5 + radRand * Math.sin(rotationF), yCoord + y, zCoord + 0.5 + radRand * Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 0); + ParticleHandler.spawnCustomParticle(particle); + } + } + //==============================================ENERGY======================================================// - @Override - public int getEnergyStored(ForgeDirection from) { - return energy.getEnergyStored(); - } + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + return this.energy.receiveEnergy(maxReceive, simulate); + } - @Override - public int getMaxEnergyStored(ForgeDirection from) { - return energy.getMaxEnergyStored(); - } + @Override + public int getEnergyStored(ForgeDirection from) { + return energy.getEnergyStored(); + } - @Override - public boolean canConnectEnergy(ForgeDirection from) { - return true; - } + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return energy.getMaxEnergyStored(); + } - //==========================================SYNCHRONIZATION==================================================// + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return true; + } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound tagCompound = new NBTTagCompound(); - this.writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + //==========================================SYNCHRONIZATION==================================================// - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + this.writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } - public void detectAndSendChanges(boolean sendAnyway){ - if (runningCach != running || sendAnyway) { - runningCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 0, running); - } - if (transferCach != transfer || sendAnyway) { - transferCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 1, transfer); - } - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } + + public void detectAndSendChanges(boolean sendAnyway) { + if (runningCach != running || sendAnyway) { + runningCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 0, running); + } + if (transferCach != transfer || sendAnyway) { + transferCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 1, transfer); + } + } - @SideOnly(Side.CLIENT) - @Override - public void receiveObjectFromServer(int index, Object object) { - if (index == 0) running = (Boolean)object; - if (index == 1) transfer = (Boolean)object; - } + @SideOnly(Side.CLIENT) + @Override + public void receiveObjectFromServer(int index, Object object) { + if (index == 0) running = (Boolean) object; + if (index == 1) transfer = (Boolean) object; + } - //==============================================INVENTORY====================================================// + //==============================================INVENTORY====================================================// - @Override - public int getSizeInventory() { - return items.length; - } + @Override + public int getSizeInventory() { + return items.length; + } - @Override - public ItemStack getStackInSlot(int i) { - return items[i]; - } + @Override + public ItemStack getStackInSlot(int i) { + return items[i]; + } - @Override - public ItemStack decrStackSize(int i, int count) { - ItemStack itemstack = getStackInSlot(i); + @Override + public ItemStack decrStackSize(int i, int count) { + ItemStack itemstack = getStackInSlot(i); - if (itemstack != null) { - if (itemstack.stackSize <= count) { - setInventorySlotContents(i, null); - } else { - itemstack = itemstack.splitStack(count); - if (itemstack.stackSize == 0) { - setInventorySlotContents(i, null); - } - } - } - return itemstack; - } + if (itemstack != null) { + if (itemstack.stackSize <= count) { + setInventorySlotContents(i, null); + } else { + itemstack = itemstack.splitStack(count); + if (itemstack.stackSize == 0) { + setInventorySlotContents(i, null); + } + } + } + return itemstack; + } - @Override - public ItemStack getStackInSlotOnClosing(int i) { - ItemStack item = getStackInSlot(i); - if (item != null) setInventorySlotContents(i, null); - return item; - } + @Override + public ItemStack getStackInSlotOnClosing(int i) { + ItemStack item = getStackInSlot(i); + if (item != null) setInventorySlotContents(i, null); + return item; + } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - items[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); - } - tryStartOrStop(); - } + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + items[i] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + tryStartOrStop(); + } - @Override - public String getInventoryName() { - return ""; - } + @Override + public String getInventoryName() { + return ""; + } - @Override - public boolean hasCustomInventoryName() { - return false; - } + @Override + public boolean hasCustomInventoryName() { + return false; + } - @Override - public int getInventoryStackLimit() { - return 1; - } + @Override + public int getInventoryStackLimit() { + return 1; + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - if (worldObj == null) - { - return true; - } - if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) - { - return false; - } - return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; - } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + if (worldObj == null) { + return true; + } + if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { + return false; + } + return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; + } - @Override - public void openInventory() {System.out.println("open");} + @Override + public void openInventory() { + System.out.println("open"); + } - @Override - public void closeInventory() {System.out.println("close");} + @Override + public void closeInventory() { + System.out.println("close"); + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return itemstack != null && itemstack.getItem() instanceof IEnergyContainerItem; - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return itemstack != null && itemstack.getItem() instanceof IEnergyContainerItem; + } - @Override - public int[] getAccessibleSlotsFromSide(int var1) { - return new int[] {0}; - } + @Override + public int[] getAccessibleSlotsFromSide(int var1) { + return new int[]{0}; + } - @Override - public boolean canInsertItem(int slot, ItemStack item, int side) { - return true; - } + @Override + public boolean canInsertItem(int slot, ItemStack item, int side) { + return true; + } - @Override - public boolean canExtractItem(int slot, ItemStack item, int side) { - if (item == null || !(item.getItem() instanceof IEnergyContainerItem)) return true; + @Override + public boolean canExtractItem(int slot, ItemStack item, int side) { + if (item == null || !(item.getItem() instanceof IEnergyContainerItem)) return true; - if ((((IEnergyContainerItem)item.getItem()).getEnergyStored(item) >= ((IEnergyContainerItem)item.getItem()).getMaxEnergyStored(item)) || ((IEnergyContainerItem)item.getItem()).receiveEnergy(item, 1, true) == 0) - return true; - else - return false; - } + if ((((IEnergyContainerItem) item.getItem()).getEnergyStored(item) >= ((IEnergyContainerItem) item.getItem()).getMaxEnergyStored(item)) || ((IEnergyContainerItem) item.getItem()).receiveEnergy(item, 1, true) == 0) + return true; + else return false; + } - //===========================================================================================================// + //===========================================================================================================// - @Override - public void writeToNBT(NBTTagCompound compound) - { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void writeToNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) - { - tag[i] = new NBTTagCompound(); + for (int i = 0; i < items.length; i++) { + tag[i] = new NBTTagCompound(); - if (items[i] != null) - { - tag[i] = items[i].writeToNBT(tag[i]); - } + if (items[i] != null) { + tag[i] = items[i].writeToNBT(tag[i]); + } - compound.setTag("Item" + i, tag[i]); - } - compound.setBoolean("Running", running); - compound.setBoolean("Transfer", transfer); - energy.writeToNBT(compound); + compound.setTag("Item" + i, tag[i]); + } + compound.setBoolean("Running", running); + compound.setBoolean("Transfer", transfer); + energy.writeToNBT(compound); - super.writeToNBT(compound); - } + super.writeToNBT(compound); + } - @Override - public void readFromNBT(NBTTagCompound compound) - { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void readFromNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) - { - tag[i] = compound.getCompoundTag("Item" + i); - items[i] = ItemStack.loadItemStackFromNBT(tag[i]); - } - running = compound.getBoolean("Running"); - transfer = compound.getBoolean("Transfer"); - energy.readFromNBT(compound); + for (int i = 0; i < items.length; i++) { + tag[i] = compound.getCompoundTag("Item" + i); + items[i] = ItemStack.loadItemStackFromNBT(tag[i]); + } + running = compound.getBoolean("Running"); + transfer = compound.getBoolean("Transfer"); + energy.readFromNBT(compound); - super.readFromNBT(compound); - } + super.readFromNBT(compound); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileGenerator.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileGenerator.java index 4c1f2e4a..01cd4500 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileGenerator.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileGenerator.java @@ -22,281 +22,278 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; public class TileGenerator extends TileObjectSync implements ISidedInventory, IEnergyProvider { - //########### variables #############// - private ItemStack[] items; - public int burnTime = 1; - public int burnTimeRemaining = 0; - private int burnSpeed = 6; - public boolean isBurning = false; - public boolean isBurningCach = false; - private int tick; - /** - * Energy per burn tick - */ - private int EPBT = 14; - public EnergyStorage storage = new EnergyStorage(100000, 0, 1000); + //########### variables #############// + private ItemStack[] items; + public int burnTime = 1; + public int burnTimeRemaining = 0; + private int burnSpeed = 6; + public boolean isBurning = false; + public boolean isBurningCach = false; + private int tick; + /** + * Energy per burn tick + */ + private int EPBT = 14; + public EnergyStorage storage = new EnergyStorage(100000, 0, 1000); - //##################################// + //##################################// - public TileGenerator() { - items = new ItemStack[1]; - } + public TileGenerator() { + items = new ItemStack[1]; + } - @Override - public void updateEntity() { - if (worldObj.isRemote) return; + @Override + public void updateEntity() { + if (worldObj.isRemote) return; - isBurning = burnTimeRemaining > 0 && storage.getEnergyStored() < storage.getMaxEnergyStored(); + isBurning = burnTimeRemaining > 0 && storage.getEnergyStored() < storage.getMaxEnergyStored(); - if (burnTimeRemaining > 0 && storage.getEnergyStored() < storage.getMaxEnergyStored()) { - burnTimeRemaining -= burnSpeed; - storage.setEnergyStored(storage.getEnergyStored() + Math.min(burnSpeed * EPBT, storage.getMaxEnergyStored() - storage.getEnergyStored())); - } else if (burnTimeRemaining <= 0) tryRefuel(); + if (burnTimeRemaining > 0 && storage.getEnergyStored() < storage.getMaxEnergyStored()) { + burnTimeRemaining -= burnSpeed; + storage.setEnergyStored(storage.getEnergyStored() + Math.min(burnSpeed * EPBT, storage.getMaxEnergyStored() - storage.getEnergyStored())); + } else if (burnTimeRemaining <= 0) tryRefuel(); - if ((storage.getEnergyStored() > 0)) { - for (int i = 0; i < 6; i++){ - TileEntity tile = worldObj.getTileEntity(xCoord + ForgeDirection.getOrientation(i).offsetX, yCoord + ForgeDirection.getOrientation(i).offsetY, zCoord + ForgeDirection.getOrientation(i).offsetZ); - if (tile != null && tile instanceof IEnergyReceiver) { - storage.extractEnergy(((IEnergyReceiver)tile).receiveEnergy(ForgeDirection.getOrientation(i).getOpposite(), storage.extractEnergy(storage.getMaxExtract(), true), false), false); - } - } - } + if ((storage.getEnergyStored() > 0)) { + for (int i = 0; i < 6; i++) { + TileEntity tile = worldObj.getTileEntity(xCoord + ForgeDirection.getOrientation(i).offsetX, yCoord + ForgeDirection.getOrientation(i).offsetY, zCoord + ForgeDirection.getOrientation(i).offsetZ); + if (tile != null && tile instanceof IEnergyReceiver) { + storage.extractEnergy(((IEnergyReceiver) tile).receiveEnergy(ForgeDirection.getOrientation(i).getOpposite(), storage.extractEnergy(storage.getMaxExtract(), true), false), false); + } + } + } - detectAndSentChanges(tick % 500 == 0); - tick++; - } + detectAndSentChanges(tick % 500 == 0); + tick++; + } - public void tryRefuel() { - if (burnTimeRemaining > 0 || storage.getEnergyStored() >= storage.getMaxEnergyStored()) return; - if (items[0] != null && items[0].stackSize > 0) { - int itemBurnTime = getItemBurnTime(items[0]); + public void tryRefuel() { + if (burnTimeRemaining > 0 || storage.getEnergyStored() >= storage.getMaxEnergyStored()) return; + if (items[0] != null && items[0].stackSize > 0) { + int itemBurnTime = getItemBurnTime(items[0]); - if (itemBurnTime > 0) { - --items[0].stackSize; - if (this.items[0].stackSize == 0) - { - this.items[0] = items[0].getItem().getContainerItem(items[0]); - } - burnTime = itemBurnTime; - burnTimeRemaining = itemBurnTime; - } - } - } + if (itemBurnTime > 0) { + --items[0].stackSize; + if (this.items[0].stackSize == 0) { + this.items[0] = items[0].getItem().getContainerItem(items[0]); + } + burnTime = itemBurnTime; + burnTimeRemaining = itemBurnTime; + } + } + } - public static int getItemBurnTime(ItemStack stack) { - if (stack == null) { - return 0; - } else { - Item item = stack.getItem(); + public static int getItemBurnTime(ItemStack stack) { + if (stack == null) { + return 0; + } else { + Item item = stack.getItem(); - if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) { - Block block = Block.getBlockFromItem(item); + if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) { + Block block = Block.getBlockFromItem(item); - if (block == Blocks.wooden_slab) { - return 150; - } + if (block == Blocks.wooden_slab) { + return 150; + } - if (block.getMaterial() == Material.wood) { - return 300; - } + if (block.getMaterial() == Material.wood) { + return 300; + } - if (block == Blocks.coal_block) { - return 16000; - } - } + if (block == Blocks.coal_block) { + return 16000; + } + } - if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD")) return 200; - if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD")) return 200; - if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD")) return 200; - if (item == Items.stick) return 100; - if (item == Items.coal) return 1600; - if (item == Items.lava_bucket) return 20000; - if (item == Item.getItemFromBlock(Blocks.sapling)) return 100; - if (item == Items.blaze_rod) return 2400; - return GameRegistry.getFuelValue(stack); - } - } + if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD")) return 200; + if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD")) return 200; + if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD")) return 200; + if (item == Items.stick) return 100; + if (item == Items.coal) return 1600; + if (item == Items.lava_bucket) return 20000; + if (item == Item.getItemFromBlock(Blocks.sapling)) return 100; + if (item == Items.blaze_rod) return 2400; + return GameRegistry.getFuelValue(stack); + } + } - @Override - public int getSizeInventory() { - return items.length; - } + @Override + public int getSizeInventory() { + return items.length; + } - @Override - public ItemStack getStackInSlot(int i) { - return items[i]; - } + @Override + public ItemStack getStackInSlot(int i) { + return items[i]; + } - @Override - public ItemStack decrStackSize(int i, int count) { - ItemStack itemstack = getStackInSlot(i); + @Override + public ItemStack decrStackSize(int i, int count) { + ItemStack itemstack = getStackInSlot(i); - if (itemstack != null) { - if (itemstack.stackSize <= count) { - setInventorySlotContents(i, null); - } else { - itemstack = itemstack.splitStack(count); - if (itemstack.stackSize == 0) { - setInventorySlotContents(i, null); - } - } - } - return itemstack; - } + if (itemstack != null) { + if (itemstack.stackSize <= count) { + setInventorySlotContents(i, null); + } else { + itemstack = itemstack.splitStack(count); + if (itemstack.stackSize == 0) { + setInventorySlotContents(i, null); + } + } + } + return itemstack; + } - @Override - public ItemStack getStackInSlotOnClosing(int i) { - ItemStack item = getStackInSlot(i); - if (item != null) setInventorySlotContents(i, null); - return item; - } + @Override + public ItemStack getStackInSlotOnClosing(int i) { + ItemStack item = getStackInSlot(i); + if (item != null) setInventorySlotContents(i, null); + return item; + } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - items[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); - } - } + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + items[i] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } - @Override - public String getInventoryName() { - return ""; - } + @Override + public String getInventoryName() { + return ""; + } - @Override - public boolean hasCustomInventoryName() { - return false; - } + @Override + public boolean hasCustomInventoryName() { + return false; + } - @Override - public int getInventoryStackLimit() { - return 64; - } + @Override + public int getInventoryStackLimit() { + return 64; + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) - { - if (worldObj == null) - { - return true; - } - if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) - { - return false; - } - return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; - } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + if (worldObj == null) { + return true; + } + if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { + return false; + } + return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; + } - @Override - public void openInventory() { - } + @Override + public void openInventory() { + } - @Override - public void closeInventory() { - } + @Override + public void closeInventory() { + } - @Override - public boolean isItemValidForSlot(int i, ItemStack stack) { - return getItemBurnTime(stack) > 0; - } + @Override + public boolean isItemValidForSlot(int i, ItemStack stack) { + return getItemBurnTime(stack) > 0; + } - @Override - public int[] getAccessibleSlotsFromSide(int var1) { - return new int[1]; - } + @Override + public int[] getAccessibleSlotsFromSide(int var1) { + return new int[1]; + } - @Override - public boolean canInsertItem(int var1, ItemStack var2, int var3) { - return true; - } + @Override + public boolean canInsertItem(int var1, ItemStack var2, int var3) { + return true; + } - @Override - public boolean canExtractItem(int var1, ItemStack var2, int var3) { - return getItemBurnTime(var2) == 0; - } + @Override + public boolean canExtractItem(int var1, ItemStack var2, int var3) { + return getItemBurnTime(var2) == 0; + } - @Override - public void writeToNBT(NBTTagCompound compound) { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void writeToNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) { - tag[i] = new NBTTagCompound(); + for (int i = 0; i < items.length; i++) { + tag[i] = new NBTTagCompound(); - if (items[i] != null) { - tag[i] = items[i].writeToNBT(tag[i]); - } + if (items[i] != null) { + tag[i] = items[i].writeToNBT(tag[i]); + } - compound.setTag("Item" + i, tag[i]); - } + compound.setTag("Item" + i, tag[i]); + } - compound.setInteger("BurnTime", burnTime); - compound.setInteger("BurnTimeRemaining", burnTimeRemaining); - storage.writeToNBT(compound); + compound.setInteger("BurnTime", burnTime); + compound.setInteger("BurnTimeRemaining", burnTimeRemaining); + storage.writeToNBT(compound); - super.writeToNBT(compound); - } + super.writeToNBT(compound); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void readFromNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) { - tag[i] = compound.getCompoundTag("Item" + i); - items[i] = ItemStack.loadItemStackFromNBT(tag[i]); - } + for (int i = 0; i < items.length; i++) { + tag[i] = compound.getCompoundTag("Item" + i); + items[i] = ItemStack.loadItemStackFromNBT(tag[i]); + } - burnTime = compound.getInteger("BurnTime"); - burnTimeRemaining = compound.getInteger("BurnTimeRemaining"); - storage.readFromNBT(compound); + burnTime = compound.getInteger("BurnTime"); + burnTimeRemaining = compound.getInteger("BurnTimeRemaining"); + storage.readFromNBT(compound); - super.readFromNBT(compound); - } + super.readFromNBT(compound); + } - private void detectAndSentChanges(boolean sendAnyway){ - if (isBurning != isBurningCach || sendAnyway) isBurningCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 0, isBurning); - } + private void detectAndSentChanges(boolean sendAnyway) { + if (isBurning != isBurningCach || sendAnyway) + isBurningCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 0, isBurning); + } - @SideOnly(Side.CLIENT) - @Override - public void receiveObjectFromServer(int index, Object object) { - if (isBurning != (Boolean) object){ - isBurning = (Boolean) object; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } - } + @SideOnly(Side.CLIENT) + @Override + public void receiveObjectFromServer(int index, Object object) { + if (isBurning != (Boolean) object) { + isBurning = (Boolean) object; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound tagCompound = new NBTTagCompound(); - writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - /* IEnergyHandler */ - @Override - public boolean canConnectEnergy(ForgeDirection from) { - return true; - } + /* IEnergyHandler */ + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return true; + } - @Override - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { - return storage.extractEnergy(maxExtract, simulate); - } + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { + return storage.extractEnergy(maxExtract, simulate); + } - @Override - public int getEnergyStored(ForgeDirection from) { - return storage.getEnergyStored(); - } + @Override + public int getEnergyStored(ForgeDirection from) { + return storage.getEnergyStored(); + } - @Override - public int getMaxEnergyStored(ForgeDirection from) { - return storage.getMaxEnergyStored(); - } + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return storage.getMaxEnergyStored(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileGrinder.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileGrinder.java index 36a68818..f5d33260 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileGrinder.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileGrinder.java @@ -33,383 +33,376 @@ import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.common.util.ForgeDirection; public class TileGrinder extends TileObjectSync implements ISidedInventory, IEnergyReceiver { - //########### variables #############// - public int meta = -1; - List killList; - AxisAlignedBB killBox; - int tick = 0; - public double centreX; - public double centreY = -1; - public double centreZ; - private ItemStack[] items; - public int burnTime = 1; - public int burnTimeRemaining = 0; - public boolean disabled = false; - private boolean disabledCach = false; - public boolean hasPower = false; - public boolean hasPowerCach = false; - private boolean readyNext = false; - public EnergyStorage internalGenBuffer = new EnergyStorage(BalanceConfigHandler.grinderInternalEnergyBufferSize, BalanceConfigHandler.grinderMaxReceive, 0); - public EnergyStorage externalInputBuffer = new EnergyStorage(BalanceConfigHandler.grinderExternalEnergyBufferSize, BalanceConfigHandler.grinderMaxReceive, 0); - public int energyPerKill = BalanceConfigHandler.grinderEnergyPerKill; - private ItemStack diamondSword; - public static FakePlayer fakePlayer; + //########### variables #############// + public int meta = -1; + List killList; + AxisAlignedBB killBox; + int tick = 0; + public double centreX; + public double centreY = -1; + public double centreZ; + private ItemStack[] items; + public int burnTime = 1; + public int burnTimeRemaining = 0; + public boolean disabled = false; + private boolean disabledCach = false; + public boolean hasPower = false; + public boolean hasPowerCach = false; + private boolean readyNext = false; + public EnergyStorage internalGenBuffer = new EnergyStorage(BalanceConfigHandler.grinderInternalEnergyBufferSize, BalanceConfigHandler.grinderMaxReceive, 0); + public EnergyStorage externalInputBuffer = new EnergyStorage(BalanceConfigHandler.grinderExternalEnergyBufferSize, BalanceConfigHandler.grinderMaxReceive, 0); + public int energyPerKill = BalanceConfigHandler.grinderEnergyPerKill; + private ItemStack diamondSword; + public static FakePlayer fakePlayer; - public void updateVariables() { - if (meta == -1) meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); - if (centreY == -1) { - switch (meta) { - case 0: - centreX = xCoord + 0.5; - centreY = yCoord + 0.5; - centreZ = zCoord + 0.5 - 5; - break; - case 1: - centreX = xCoord + 0.5 + 5; - centreY = yCoord + 0.5; - centreZ = zCoord + 0.5; - break; - case 2: - centreX = xCoord + 0.5; - centreY = yCoord + 0.5; - centreZ = zCoord + 0.5 + 5; - break; - case 3: - centreX = xCoord + 0.5 - 5; - centreY = yCoord + 0.5; - centreZ = zCoord + 0.5; - break; - } - } - } - //##################################// + public void updateVariables() { + if (meta == -1) meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); + if (centreY == -1) { + switch (meta) { + case 0: + centreX = xCoord + 0.5; + centreY = yCoord + 0.5; + centreZ = zCoord + 0.5 - 5; + break; + case 1: + centreX = xCoord + 0.5 + 5; + centreY = yCoord + 0.5; + centreZ = zCoord + 0.5; + break; + case 2: + centreX = xCoord + 0.5; + centreY = yCoord + 0.5; + centreZ = zCoord + 0.5 + 5; + break; + case 3: + centreX = xCoord + 0.5 - 5; + centreY = yCoord + 0.5; + centreZ = zCoord + 0.5; + break; + } + } + } + //##################################// - public TileGrinder() { - items = new ItemStack[1]; - diamondSword = new ItemStack(Items.diamond_sword); - if (BalanceConfigHandler.grinderShouldUseLooting) - { - diamondSword.addEnchantment(Enchantment.looting, 3); - } - } + public TileGrinder() { + items = new ItemStack[1]; + diamondSword = new ItemStack(Items.diamond_sword); + if (BalanceConfigHandler.grinderShouldUseLooting) { + diamondSword.addEnchantment(Enchantment.looting, 3); + } + } - @Override - public void updateEntity() { - updateVariables(); + @Override + public void updateEntity() { + updateVariables(); - if (worldObj.isRemote) return; + if (worldObj.isRemote) return; - hasPower = getActiveBuffer().getEnergyStored() >= energyPerKill; + hasPower = getActiveBuffer().getEnergyStored() >= energyPerKill; - int burnSpeed = 2; - int EPBT = 10; + int burnSpeed = 2; + int EPBT = 10; - if (burnTimeRemaining > 0 && internalGenBuffer.getEnergyStored() < internalGenBuffer.getMaxEnergyStored()) { - burnTimeRemaining -= burnSpeed; - internalGenBuffer.setEnergyStored(internalGenBuffer.getEnergyStored() + Math.min(burnSpeed * EPBT, internalGenBuffer.getMaxEnergyStored() - internalGenBuffer.getEnergyStored())); - } else if (burnTimeRemaining <= 0) tryRefuel(); + if (burnTimeRemaining > 0 && internalGenBuffer.getEnergyStored() < internalGenBuffer.getMaxEnergyStored()) { + burnTimeRemaining -= burnSpeed; + internalGenBuffer.setEnergyStored(internalGenBuffer.getEnergyStored() + Math.min(burnSpeed * EPBT, internalGenBuffer.getMaxEnergyStored() - internalGenBuffer.getEnergyStored())); + } else if (burnTimeRemaining <= 0) tryRefuel(); - if (readyNext && !disabled && getActiveBuffer().getEnergyStored() >= energyPerKill) { - if (killNextEntity()) { - getActiveBuffer().modifyEnergyStored(-energyPerKill); - } - } + if (readyNext && !disabled && getActiveBuffer().getEnergyStored() >= energyPerKill) { + if (killNextEntity()) { + getActiveBuffer().modifyEnergyStored(-energyPerKill); + } + } - if (tick % 100 == 0) { - //checkSignal(); - readyNext = true; - } - detectAndSendChanges(tick % 500 == 0); - tick++; - } + if (tick % 100 == 0) { + //checkSignal(); + readyNext = true; + } + detectAndSendChanges(tick % 500 == 0); + tick++; + } - public EnergyStorage getActiveBuffer(){ - return isExternallyPowered() ? externalInputBuffer : internalGenBuffer; - } + public EnergyStorage getActiveBuffer() { + return isExternallyPowered() ? externalInputBuffer : internalGenBuffer; + } - public boolean isExternallyPowered() - { - return externalInputBuffer.getEnergyStored() > energyPerKill; - } + public boolean isExternallyPowered() { + return externalInputBuffer.getEnergyStored() > energyPerKill; + } - public void tryRefuel() { - if (burnTimeRemaining > 0 || internalGenBuffer.getEnergyStored() >= internalGenBuffer.getMaxEnergyStored()) return; - if (items[0] != null && items[0].stackSize > 0) { - int itemBurnTime = getItemBurnTime(items[0]); + public void tryRefuel() { + if (burnTimeRemaining > 0 || internalGenBuffer.getEnergyStored() >= internalGenBuffer.getMaxEnergyStored()) + return; + if (items[0] != null && items[0].stackSize > 0) { + int itemBurnTime = getItemBurnTime(items[0]); - if (itemBurnTime > 0) { - --items[0].stackSize; - if (this.items[0].stackSize == 0) - { - this.items[0] = items[0].getItem().getContainerItem(items[0]); - } - burnTime = itemBurnTime; - burnTimeRemaining = itemBurnTime; - } - } - } + if (itemBurnTime > 0) { + --items[0].stackSize; + if (this.items[0].stackSize == 0) { + this.items[0] = items[0].getItem().getContainerItem(items[0]); + } + burnTime = itemBurnTime; + burnTimeRemaining = itemBurnTime; + } + } + } - @SuppressWarnings("unchecked") - public boolean killNextEntity() { - if (worldObj.isRemote) return false; - if (fakePlayer == null) - { - fakePlayer = FakePlayerFactory.get((WorldServer) worldObj, new GameProfile(UUID.fromString("5b5689b9-e43d-4282-a42a-dc916f3616b7"), "[Draconic-Evolution]")); - } - if (fakePlayer.getHeldItem() == null || !ItemStack.areItemStacksEqual(fakePlayer.getHeldItem(), diamondSword)) - { - fakePlayer.setCurrentItemOrArmor(0, diamondSword); - } - killBox = AxisAlignedBB.getBoundingBox(centreX - 4.5, centreY - 4.5, centreZ - 4.5, centreX + 4.5, centreY + 4.5, centreZ + 4.5); + @SuppressWarnings("unchecked") + public boolean killNextEntity() { + if (worldObj.isRemote) return false; + if (fakePlayer == null) { + fakePlayer = FakePlayerFactory.get((WorldServer) worldObj, new GameProfile(UUID.fromString("5b5689b9-e43d-4282-a42a-dc916f3616b7"), "[Draconic-Evolution]")); + } + if (fakePlayer.getHeldItem() == null || !ItemStack.areItemStacksEqual(fakePlayer.getHeldItem(), diamondSword)) { + fakePlayer.setCurrentItemOrArmor(0, diamondSword); + } + killBox = AxisAlignedBB.getBoundingBox(centreX - 4.5, centreY - 4.5, centreZ - 4.5, centreX + 4.5, centreY + 4.5, centreZ + 4.5); - killList = worldObj.getEntitiesWithinAABB(EntityLiving.class, killBox); - List xp = worldObj.getEntitiesWithinAABB(EntityXPOrb.class, killBox.expand(4, 4, 4)); - for (EntityXPOrb orb : xp) if (orb.xpOrbAge < 5400) orb.xpOrbAge = 5400; + killList = worldObj.getEntitiesWithinAABB(EntityLiving.class, killBox); + List xp = worldObj.getEntitiesWithinAABB(EntityXPOrb.class, killBox.expand(4, 4, 4)); + for (EntityXPOrb orb : xp) if (orb.xpOrbAge < 5400) orb.xpOrbAge = 5400; - if (killList.size() > 0) { - EntityLiving mob = killList.get(worldObj.rand.nextInt(killList.size())); - if (mob.isEntityAlive()) { - mob.attackEntityFrom(DamageSource.causePlayerDamage(fakePlayer), 50000F); - readyNext = true; - return true; - } - readyNext = true; - return false; - } - readyNext = false; - return false; - } + if (killList.size() > 0) { + EntityLiving mob = killList.get(worldObj.rand.nextInt(killList.size())); + if (mob.isEntityAlive()) { + mob.attackEntityFrom(DamageSource.causePlayerDamage(fakePlayer), 50000F); + readyNext = true; + return true; + } + readyNext = true; + return false; + } + readyNext = false; + return false; + } - public static int getItemBurnTime(ItemStack stack) { - if (stack == null) { - return 0; - } else { - Item item = stack.getItem(); + public static int getItemBurnTime(ItemStack stack) { + if (stack == null) { + return 0; + } else { + Item item = stack.getItem(); - if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) { - Block block = Block.getBlockFromItem(item); + if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) { + Block block = Block.getBlockFromItem(item); - if (block == Blocks.wooden_slab) { - return 150; - } + if (block == Blocks.wooden_slab) { + return 150; + } - if (block.getMaterial() == Material.wood) { - return 300; - } + if (block.getMaterial() == Material.wood) { + return 300; + } - if (block == Blocks.coal_block) { - return 16000; - } - } + if (block == Blocks.coal_block) { + return 16000; + } + } - if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD")) return 200; - if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD")) return 200; - if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD")) return 200; - if (item == Items.stick) return 100; - if (item == Items.coal) return 1600; - if (item == Items.lava_bucket) return 20000; - if (item == Item.getItemFromBlock(Blocks.sapling)) return 100; - if (item == Items.blaze_rod) return 2400; - return GameRegistry.getFuelValue(stack); - } - } + if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD")) return 200; + if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD")) return 200; + if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD")) return 200; + if (item == Items.stick) return 100; + if (item == Items.coal) return 1600; + if (item == Items.lava_bucket) return 20000; + if (item == Item.getItemFromBlock(Blocks.sapling)) return 100; + if (item == Items.blaze_rod) return 2400; + return GameRegistry.getFuelValue(stack); + } + } - @Override - public int getSizeInventory() { - return items.length; - } + @Override + public int getSizeInventory() { + return items.length; + } - @Override - public ItemStack getStackInSlot(int i) { - return items[i]; - } + @Override + public ItemStack getStackInSlot(int i) { + return items[i]; + } - @Override - public ItemStack decrStackSize(int i, int count) { - ItemStack itemstack = getStackInSlot(i); + @Override + public ItemStack decrStackSize(int i, int count) { + ItemStack itemstack = getStackInSlot(i); - if (itemstack != null) { - if (itemstack.stackSize <= count) { - setInventorySlotContents(i, null); - } else { - itemstack = itemstack.splitStack(count); - if (itemstack.stackSize == 0) { - setInventorySlotContents(i, null); - } - } - } - return itemstack; - } + if (itemstack != null) { + if (itemstack.stackSize <= count) { + setInventorySlotContents(i, null); + } else { + itemstack = itemstack.splitStack(count); + if (itemstack.stackSize == 0) { + setInventorySlotContents(i, null); + } + } + } + return itemstack; + } - @Override - public ItemStack getStackInSlotOnClosing(int i) { - ItemStack item = getStackInSlot(i); - if (item != null) setInventorySlotContents(i, null); - return item; - } + @Override + public ItemStack getStackInSlotOnClosing(int i) { + ItemStack item = getStackInSlot(i); + if (item != null) setInventorySlotContents(i, null); + return item; + } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - items[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); - } - } + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + items[i] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } - @Override - public String getInventoryName() { - return ""; - } + @Override + public String getInventoryName() { + return ""; + } - @Override - public boolean hasCustomInventoryName() { - return false; - } + @Override + public boolean hasCustomInventoryName() { + return false; + } - @Override - public int getInventoryStackLimit() { - return 64; - } + @Override + public int getInventoryStackLimit() { + return 64; + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - if (worldObj == null) - { - return true; - } - if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) - { - return false; - } - return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; - } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + if (worldObj == null) { + return true; + } + if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { + return false; + } + return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; + } - @Override - public void openInventory() { - } + @Override + public void openInventory() { + } - @Override - public void closeInventory() { - } + @Override + public void closeInventory() { + } - @Override - public boolean isItemValidForSlot(int i, ItemStack stack) { - return getItemBurnTime(stack) > 0; - } + @Override + public boolean isItemValidForSlot(int i, ItemStack stack) { + return getItemBurnTime(stack) > 0; + } - @Override - public int[] getAccessibleSlotsFromSide(int var1) { - return new int[1]; - } + @Override + public int[] getAccessibleSlotsFromSide(int var1) { + return new int[1]; + } - @Override - public boolean canInsertItem(int var1, ItemStack var2, int var3) { - return true; - } + @Override + public boolean canInsertItem(int var1, ItemStack var2, int var3) { + return true; + } - @Override - public boolean canExtractItem(int var1, ItemStack var2, int var3) { - return false; - } + @Override + public boolean canExtractItem(int var1, ItemStack var2, int var3) { + return false; + } - @Override - public void writeToNBT(NBTTagCompound compound) { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void writeToNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) { - tag[i] = new NBTTagCompound(); + for (int i = 0; i < items.length; i++) { + tag[i] = new NBTTagCompound(); - if (items[i] != null) { - tag[i] = items[i].writeToNBT(tag[i]); - } + if (items[i] != null) { + tag[i] = items[i].writeToNBT(tag[i]); + } - compound.setTag("Item" + i, tag[i]); - } + compound.setTag("Item" + i, tag[i]); + } - compound.setBoolean("Disabled", disabled); - compound.setInteger("BurnTime", burnTime); - compound.setInteger("BurnTimeRemaining", burnTimeRemaining); - externalInputBuffer.writeToNBT(compound, "ExternalBuffer"); - internalGenBuffer.writeToNBT(compound, "InternalBuffer"); + compound.setBoolean("Disabled", disabled); + compound.setInteger("BurnTime", burnTime); + compound.setInteger("BurnTimeRemaining", burnTimeRemaining); + externalInputBuffer.writeToNBT(compound, "ExternalBuffer"); + internalGenBuffer.writeToNBT(compound, "InternalBuffer"); - super.writeToNBT(compound); - } + super.writeToNBT(compound); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void readFromNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) { - tag[i] = compound.getCompoundTag("Item" + i); - items[i] = ItemStack.loadItemStackFromNBT(tag[i]); - } + for (int i = 0; i < items.length; i++) { + tag[i] = compound.getCompoundTag("Item" + i); + items[i] = ItemStack.loadItemStackFromNBT(tag[i]); + } - disabled = compound.getBoolean("Disabled"); - burnTime = compound.getInteger("BurnTime"); - burnTimeRemaining = compound.getInteger("BurnTimeRemaining"); - externalInputBuffer.readFromNBT(compound, "ExternalBuffer"); - internalGenBuffer.readFromNBT(compound, "InternalBuffer"); + disabled = compound.getBoolean("Disabled"); + burnTime = compound.getInteger("BurnTime"); + burnTimeRemaining = compound.getInteger("BurnTimeRemaining"); + externalInputBuffer.readFromNBT(compound, "ExternalBuffer"); + internalGenBuffer.readFromNBT(compound, "InternalBuffer"); - super.readFromNBT(compound); - } + super.readFromNBT(compound); + } - @SideOnly(Side.CLIENT) - @Override - public void receiveObjectFromServer(int index, Object object) { - if (index == 0 && disabled != (Boolean) object) { - disabled = (Boolean) object; - worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); - } - else if (hasPower != (Boolean) object){ - hasPower = (Boolean) object; - worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); - } - } + @SideOnly(Side.CLIENT) + @Override + public void receiveObjectFromServer(int index, Object object) { + if (index == 0 && disabled != (Boolean) object) { + disabled = (Boolean) object; + worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); + } else if (hasPower != (Boolean) object) { + hasPower = (Boolean) object; + worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); + } + } - private void detectAndSendChanges(boolean sendAnyway){ - if (disabledCach != disabled || sendAnyway) { - disabledCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 0, disabled); - } - if (hasPowerCach != hasPower || sendAnyway) { - hasPowerCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 1, hasPower); - } - } + private void detectAndSendChanges(boolean sendAnyway) { + if (disabledCach != disabled || sendAnyway) { + disabledCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 0, disabled); + } + if (hasPowerCach != hasPower || sendAnyway) { + hasPowerCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 1, hasPower); + } + } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound tagCompound = new NBTTagCompound(); - writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - /* IEnergyHandler */ - @Override - public boolean canConnectEnergy(ForgeDirection from) { - return true; - } + /* IEnergyHandler */ + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return true; + } - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - return externalInputBuffer.receiveEnergy(maxReceive, simulate); - } + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + return externalInputBuffer.receiveEnergy(maxReceive, simulate); + } - @Override - public int getEnergyStored(ForgeDirection from) { - return externalInputBuffer.getEnergyStored(); - } + @Override + public int getEnergyStored(ForgeDirection from) { + return externalInputBuffer.getEnergyStored(); + } - @Override - public int getMaxEnergyStored(ForgeDirection from) { - return externalInputBuffer.getMaxEnergyStored(); - } + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return externalInputBuffer.getMaxEnergyStored(); + } - public EnergyStorage getInternalBuffer(){ - return internalGenBuffer; - } + public EnergyStorage getInternalBuffer() { + return internalGenBuffer; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileObjectSync.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileObjectSync.java index 6628c781..310604c5 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileObjectSync.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileObjectSync.java @@ -10,25 +10,35 @@ import net.minecraft.tileentity.TileEntity; */ public abstract class TileObjectSync extends TileEntity { - /**Sends a primitive to the client in the form of an object*/ - public Object sendObjectToClient(byte dataType, int index, Object object){ - return sendObjectToClient(dataType, index, object, new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 64)); - } + /** + * Sends a primitive to the client in the form of an object + */ + public Object sendObjectToClient(byte dataType, int index, Object object) { + return sendObjectToClient(dataType, index, object, new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 64)); + } - /**Sends a primitive to the client in the form of an object*/ - public Object sendObjectToClient(byte dataType, int index, Object object, TargetPoint point){ - DraconicEvolution.network.sendToAllAround(new TileObjectPacket(this, dataType, index, object), point); - return object; - } + /** + * Sends a primitive to the client in the form of an object + */ + public Object sendObjectToClient(byte dataType, int index, Object object, TargetPoint point) { + DraconicEvolution.network.sendToAllAround(new TileObjectPacket(this, dataType, index, object), point); + return object; + } - public Object sendObjectToServer(byte dataType, int index, Object object){ - DraconicEvolution.network.sendToServer(new TileObjectPacket(this, dataType, index, object)); - return object; - } + public Object sendObjectToServer(byte dataType, int index, Object object) { + DraconicEvolution.network.sendToServer(new TileObjectPacket(this, dataType, index, object)); + return object; + } - /**Receives an object from the server*/ - public void receiveObjectFromClient(int index, Object object) {} + /** + * Receives an object from the server + */ + public void receiveObjectFromClient(int index, Object object) { + } - /**Receives an object from the server*/ - public void receiveObjectFromServer(int index, Object object) {} + /** + * Receives an object from the server + */ + public void receiveObjectFromServer(int index, Object object) { + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileParticleGenerator.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileParticleGenerator.java index 99cdae58..f43aa1fb 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileParticleGenerator.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileParticleGenerator.java @@ -21,58 +21,58 @@ import java.util.Map; import java.util.Random; public class TileParticleGenerator extends TileEntity implements IDEPeripheral { - public boolean particles_enabled = true; + public boolean particles_enabled = true; - public int red = 0; - public int green = 0; - public int blue = 0; - public int random_red = 0; - public int random_green = 0; - public int random_blue = 0; - public float motion_x = 0.0F; - public float motion_y = 0.0F; - public float motion_z = 0.0F; - public float random_motion_x = 0.0F; - public float random_motion_y = 0.0F; - public float random_motion_z = 0.0F; - public float scale = 1F; - public float random_scale = 0F; - public int life = 100; - public int random_life = 0; - public float spawn_x = 0; - public float spawn_y = 0; - public float spawn_z = 0; - public float random_spawn_x = 0; - public float random_spawn_y = 0; - public float random_spawn_z = 0; - public int page = 1; - public int fade = 0; - public int spawn_rate = 1; - public boolean collide = false; - public int selected_particle = 1; - public int selected_max = 3; - public float gravity = 0F; - public boolean active = true; - public boolean signal = false; - public boolean inverted = false; - TileLocation master = new TileLocation(); - public float rotation = 0; - public boolean stabalizerMode = false; + public int red = 0; + public int green = 0; + public int blue = 0; + public int random_red = 0; + public int random_green = 0; + public int random_blue = 0; + public float motion_x = 0.0F; + public float motion_y = 0.0F; + public float motion_z = 0.0F; + public float random_motion_x = 0.0F; + public float random_motion_y = 0.0F; + public float random_motion_z = 0.0F; + public float scale = 1F; + public float random_scale = 0F; + public int life = 100; + public int random_life = 0; + public float spawn_x = 0; + public float spawn_y = 0; + public float spawn_z = 0; + public float random_spawn_x = 0; + public float random_spawn_y = 0; + public float random_spawn_z = 0; + public int page = 1; + public int fade = 0; + public int spawn_rate = 1; + public boolean collide = false; + public int selected_particle = 1; + public int selected_max = 3; + public float gravity = 0F; + public boolean active = true; + public boolean signal = false; + public boolean inverted = false; + TileLocation master = new TileLocation(); + public float rotation = 0; + public boolean stabalizerMode = false; - //beam - public boolean beam_enabled = false; - public boolean render_core = false; + //beam + public boolean beam_enabled = false; + public boolean render_core = false; - public int beam_red = 0; - public int beam_green = 0; - public int beam_blue = 0; - public float beam_scale = 1F; - public float beam_pitch = 0F; - public float beam_yaw = 0F; - public float beam_length = 0F; - public float beam_rotation = 0F; + public int beam_red = 0; + public int beam_green = 0; + public int beam_blue = 0; + public float beam_scale = 1F; + public float beam_pitch = 0F; + public float beam_yaw = 0F; + public float beam_length = 0F; + public float beam_rotation = 0F; - private int tick = 0; + private int tick = 0; @SideOnly(Side.SERVER) @Override @@ -80,466 +80,417 @@ public class TileParticleGenerator extends TileEntity implements IDEPeripheral { return false; } - @SideOnly(Side.CLIENT) - @Override - public void updateEntity() { - if (!worldObj.isRemote) return; - rotation += 0.5F; - if (stabalizerMode) { + @SideOnly(Side.CLIENT) + @Override + public void updateEntity() { + if (!worldObj.isRemote) return; + rotation += 0.5F; + if (stabalizerMode) { - spawnStabilizerParticle(); - } - if (stabalizerMode) return; + spawnStabilizerParticle(); + } + if (stabalizerMode) return; - if (signal && !inverted) active = true; - else if (!signal && inverted) active = true; - else active = false; + if (signal && !inverted) active = true; + else if (!signal && inverted) active = true; + else active = false; - if (tick >= spawn_rate && active && particles_enabled) { - tick = 0; + if (tick >= spawn_rate && active && particles_enabled) { + tick = 0; - Random rand = worldObj.rand; + Random rand = worldObj.rand; - float MX = motion_x + (random_motion_x * rand.nextFloat()); - float MY = motion_y + (random_motion_y * rand.nextFloat()); - float MZ = motion_z + (random_motion_z * rand.nextFloat()); - float SCALE = scale + (random_scale * rand.nextFloat()); - double spawnX = xCoord + spawn_x + (random_spawn_x * rand.nextFloat()); - double spawnY = yCoord + spawn_y + (random_spawn_y * rand.nextFloat()); - double spawnZ = zCoord + spawn_z + (random_spawn_z * rand.nextFloat()); + float MX = motion_x + (random_motion_x * rand.nextFloat()); + float MY = motion_y + (random_motion_y * rand.nextFloat()); + float MZ = motion_z + (random_motion_z * rand.nextFloat()); + float SCALE = scale + (random_scale * rand.nextFloat()); + double spawnX = xCoord + spawn_x + (random_spawn_x * rand.nextFloat()); + double spawnY = yCoord + spawn_y + (random_spawn_y * rand.nextFloat()); + double spawnZ = zCoord + spawn_z + (random_spawn_z * rand.nextFloat()); - ParticleCustom particle = new ParticleCustom(worldObj, spawnX + 0.5, spawnY + 0.5, spawnZ + 0.5, MX, MY, MZ, SCALE, collide, this.selected_particle); - particle.red = this.red + rand.nextInt(random_red + 1); - particle.green = this.green + rand.nextInt(random_green + 1); - particle.blue = this.blue + rand.nextInt(random_blue + 1); - particle.maxAge = this.life + rand.nextInt(random_life + 1); - particle.fadeTime = this.fade; - particle.fadeLength = this.fade; - particle.gravity = this.gravity; + ParticleCustom particle = new ParticleCustom(worldObj, spawnX + 0.5, spawnY + 0.5, spawnZ + 0.5, MX, MY, MZ, SCALE, collide, this.selected_particle); + particle.red = this.red + rand.nextInt(random_red + 1); + particle.green = this.green + rand.nextInt(random_green + 1); + particle.blue = this.blue + rand.nextInt(random_blue + 1); + particle.maxAge = this.life + rand.nextInt(random_life + 1); + particle.fadeTime = this.fade; + particle.fadeLength = this.fade; + particle.gravity = this.gravity; - ParticleHandler.spawnCustomParticle(particle, 256); + ParticleHandler.spawnCustomParticle(particle, 256); - } else tick++; - } + } else tick++; + } - @SideOnly(Side.CLIENT) - private void spawnStabilizerParticle(){ - if (getMaster() == null || worldObj.getTotalWorldTime() % (20) != 1) return; + @SideOnly(Side.CLIENT) + private void spawnStabilizerParticle() { + if (getMaster() == null || worldObj.getTotalWorldTime() % (20) != 1) return; - double x = xCoord + 0.5; - double y = yCoord + 0.5; - double z = zCoord + 0.5; - int direction = 0; + double x = xCoord + 0.5; + double y = yCoord + 0.5; + double z = zCoord + 0.5; + int direction = 0; - if (getMaster().xCoord > xCoord) - direction = 0; - else if (getMaster().xCoord < xCoord) - direction = 1; - else if (getMaster().zCoord > zCoord) - direction = 2; - else if (getMaster().zCoord < zCoord) - direction = 3; + if (getMaster().xCoord > xCoord) direction = 0; + else if (getMaster().xCoord < xCoord) direction = 1; + else if (getMaster().zCoord > zCoord) direction = 2; + else if (getMaster().zCoord < zCoord) direction = 3; - Particles.EnergyBeamParticle particle = new Particles.EnergyBeamParticle(worldObj, x, y, z, getMaster().xCoord + 0.5, getMaster().zCoord + 0.5, direction, false); - Particles.EnergyBeamParticle particle2 = new Particles.EnergyBeamParticle(worldObj, x, y, z, getMaster().xCoord + 0.5, getMaster().zCoord + 0.5, direction, true); - ParticleHandler.spawnCustomParticle(particle, 60); - ParticleHandler.spawnCustomParticle(particle2, 60); - } + Particles.EnergyBeamParticle particle = new Particles.EnergyBeamParticle(worldObj, x, y, z, getMaster().xCoord + 0.5, getMaster().zCoord + 0.5, direction, false); + Particles.EnergyBeamParticle particle2 = new Particles.EnergyBeamParticle(worldObj, x, y, z, getMaster().xCoord + 0.5, getMaster().zCoord + 0.5, direction, true); + ParticleHandler.spawnCustomParticle(particle, 60); + ParticleHandler.spawnCustomParticle(particle2, 60); + } - public void toggleInverted() { - inverted = !inverted; - } + public void toggleInverted() { + inverted = !inverted; + } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound tagCompound = new NBTTagCompound(); - this.writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + this.writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } - @Override - public void writeToNBT(NBTTagCompound compound) { - master.writeToNBT(compound, "Key"); - compound.setBoolean("StabalizerMode", stabalizerMode); - getBlockNBT(compound); + @Override + public void writeToNBT(NBTTagCompound compound) { + master.writeToNBT(compound, "Key"); + compound.setBoolean("StabalizerMode", stabalizerMode); + getBlockNBT(compound); - super.writeToNBT(compound); - } + super.writeToNBT(compound); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - master.readFromNBT(compound, "Key"); - stabalizerMode = compound.getBoolean("StabalizerMode"); - setBlockNBT(compound); - super.readFromNBT(compound); - } + @Override + public void readFromNBT(NBTTagCompound compound) { + master.readFromNBT(compound, "Key"); + stabalizerMode = compound.getBoolean("StabalizerMode"); + setBlockNBT(compound); + super.readFromNBT(compound); + } - public TileEnergyStorageCore getMaster() { - if (master == null) return null; - TileEnergyStorageCore tile = (worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) != null && worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) : null; - return tile; - } + public TileEnergyStorageCore getMaster() { + if (master == null) return null; + TileEnergyStorageCore tile = (worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) != null && worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) : null; + return tile; + } - public void setMaster(TileLocation master) { - this.master = master; - } + public void setMaster(TileLocation master) { + this.master = master; + } - @Override - public AxisAlignedBB getRenderBoundingBox() { - return INFINITE_EXTENT_AABB; - } + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } - public void getBlockNBT(NBTTagCompound compound) - { - compound.setInteger("Red", red); - compound.setInteger("Green", green); - compound.setInteger("Blue", blue); - compound.setInteger("RandomRed", random_red); - compound.setInteger("RandomGreen", random_green); - compound.setInteger("RandomBlue", random_blue); - compound.setFloat("MotionX", motion_x); - compound.setFloat("MotionY", motion_y); - compound.setFloat("MotionZ", motion_z); - compound.setFloat("RandomMotionX", random_motion_x); - compound.setFloat("RandomMotionY", random_motion_y); - compound.setFloat("RandomMotionZ", random_motion_z); - compound.setFloat("Scale", scale); - compound.setFloat("RandomScale", random_scale); - compound.setInteger("Life", life); - compound.setInteger("RandomLife", random_life); - compound.setFloat("SpawnX", spawn_x); - compound.setFloat("SpawnY", spawn_y); - compound.setFloat("SpawnZ", spawn_z); - compound.setFloat("RandomSpawnX", random_spawn_x); - compound.setFloat("RandomSpawnY", random_spawn_y); - compound.setFloat("RandomSpawnZ", random_spawn_z); - compound.setInteger("Page", page); - compound.setInteger("SpawnRate", spawn_rate); - compound.setBoolean("CanCollide", collide); - compound.setInteger("Fade", fade); - compound.setInteger("SelectedParticle", selected_particle); - compound.setFloat("Gravity", gravity); - compound.setBoolean("Active", active); - compound.setBoolean("Signal", signal); - compound.setBoolean("Inverted", inverted); - compound.setBoolean("particles_enabled", particles_enabled); + public void getBlockNBT(NBTTagCompound compound) { + compound.setInteger("Red", red); + compound.setInteger("Green", green); + compound.setInteger("Blue", blue); + compound.setInteger("RandomRed", random_red); + compound.setInteger("RandomGreen", random_green); + compound.setInteger("RandomBlue", random_blue); + compound.setFloat("MotionX", motion_x); + compound.setFloat("MotionY", motion_y); + compound.setFloat("MotionZ", motion_z); + compound.setFloat("RandomMotionX", random_motion_x); + compound.setFloat("RandomMotionY", random_motion_y); + compound.setFloat("RandomMotionZ", random_motion_z); + compound.setFloat("Scale", scale); + compound.setFloat("RandomScale", random_scale); + compound.setInteger("Life", life); + compound.setInteger("RandomLife", random_life); + compound.setFloat("SpawnX", spawn_x); + compound.setFloat("SpawnY", spawn_y); + compound.setFloat("SpawnZ", spawn_z); + compound.setFloat("RandomSpawnX", random_spawn_x); + compound.setFloat("RandomSpawnY", random_spawn_y); + compound.setFloat("RandomSpawnZ", random_spawn_z); + compound.setInteger("Page", page); + compound.setInteger("SpawnRate", spawn_rate); + compound.setBoolean("CanCollide", collide); + compound.setInteger("Fade", fade); + compound.setInteger("SelectedParticle", selected_particle); + compound.setFloat("Gravity", gravity); + compound.setBoolean("Active", active); + compound.setBoolean("Signal", signal); + compound.setBoolean("Inverted", inverted); + compound.setBoolean("particles_enabled", particles_enabled); - compound.setBoolean("beam_enabled", beam_enabled); - compound.setBoolean("render_core", render_core); - compound.setInteger("beam_red", beam_red); - compound.setInteger("beam_green", beam_green); - compound.setInteger("beam_blue", beam_blue); - compound.setFloat("beam_scale", beam_scale); - compound.setFloat("beam_pitch", beam_pitch); - compound.setFloat("beam_yaw", beam_yaw); - compound.setFloat("beam_length", beam_length); - compound.setFloat("beam_rotation", beam_rotation); - } + compound.setBoolean("beam_enabled", beam_enabled); + compound.setBoolean("render_core", render_core); + compound.setInteger("beam_red", beam_red); + compound.setInteger("beam_green", beam_green); + compound.setInteger("beam_blue", beam_blue); + compound.setFloat("beam_scale", beam_scale); + compound.setFloat("beam_pitch", beam_pitch); + compound.setFloat("beam_yaw", beam_yaw); + compound.setFloat("beam_length", beam_length); + compound.setFloat("beam_rotation", beam_rotation); + } - public void setBlockNBT(NBTTagCompound compound) - { - red = compound.getInteger("Red"); - green = compound.getInteger("Green"); - blue = compound.getInteger("Blue"); - random_red = compound.getInteger("RandomRed"); - random_green = compound.getInteger("RandomGreen"); - random_blue = compound.getInteger("RandomBlue"); - motion_x = compound.getFloat("MotionX"); - motion_y = compound.getFloat("MotionY"); - motion_z = compound.getFloat("MotionZ"); - random_motion_x = compound.getFloat("RandomMotionX"); - random_motion_y = compound.getFloat("RandomMotionY"); - random_motion_z = compound.getFloat("RandomMotionZ"); - scale = compound.getFloat("Scale"); - random_scale = compound.getFloat("RandomScale"); - life = compound.getInteger("Life"); - random_life = compound.getInteger("RandomLife"); - spawn_x = compound.getFloat("SpawnX"); - spawn_y = compound.getFloat("SpawnY"); - spawn_z = compound.getFloat("SpawnZ"); - random_spawn_x = compound.getFloat("RandomSpawnX"); - random_spawn_y = compound.getFloat("RandomSpawnY"); - random_spawn_z = compound.getFloat("RandomSpawnZ"); - page = compound.getInteger("Page"); - spawn_rate = compound.getInteger("SpawnRate"); - collide = compound.getBoolean("CanCollide"); - fade = compound.getInteger("Fade"); - selected_particle = compound.getInteger("SelectedParticle"); - gravity = compound.getFloat("Gravity"); - active = compound.getBoolean("Active"); - signal = compound.getBoolean("Signal"); - inverted = compound.getBoolean("Inverted"); - particles_enabled = compound.getBoolean("particles_enabled"); + public void setBlockNBT(NBTTagCompound compound) { + red = compound.getInteger("Red"); + green = compound.getInteger("Green"); + blue = compound.getInteger("Blue"); + random_red = compound.getInteger("RandomRed"); + random_green = compound.getInteger("RandomGreen"); + random_blue = compound.getInteger("RandomBlue"); + motion_x = compound.getFloat("MotionX"); + motion_y = compound.getFloat("MotionY"); + motion_z = compound.getFloat("MotionZ"); + random_motion_x = compound.getFloat("RandomMotionX"); + random_motion_y = compound.getFloat("RandomMotionY"); + random_motion_z = compound.getFloat("RandomMotionZ"); + scale = compound.getFloat("Scale"); + random_scale = compound.getFloat("RandomScale"); + life = compound.getInteger("Life"); + random_life = compound.getInteger("RandomLife"); + spawn_x = compound.getFloat("SpawnX"); + spawn_y = compound.getFloat("SpawnY"); + spawn_z = compound.getFloat("SpawnZ"); + random_spawn_x = compound.getFloat("RandomSpawnX"); + random_spawn_y = compound.getFloat("RandomSpawnY"); + random_spawn_z = compound.getFloat("RandomSpawnZ"); + page = compound.getInteger("Page"); + spawn_rate = compound.getInteger("SpawnRate"); + collide = compound.getBoolean("CanCollide"); + fade = compound.getInteger("Fade"); + selected_particle = compound.getInteger("SelectedParticle"); + gravity = compound.getFloat("Gravity"); + active = compound.getBoolean("Active"); + signal = compound.getBoolean("Signal"); + inverted = compound.getBoolean("Inverted"); + particles_enabled = compound.getBoolean("particles_enabled"); - beam_enabled = compound.getBoolean("beam_enabled"); - render_core = compound.getBoolean("render_core"); - beam_red = compound.getInteger("beam_red"); - beam_green = compound.getInteger("beam_green"); - beam_blue = compound.getInteger("beam_blue"); - beam_scale = compound.getFloat("beam_scale"); - beam_pitch = compound.getFloat("beam_pitch"); - beam_yaw = compound.getFloat("beam_yaw"); - beam_length = compound.getFloat("beam_length"); - beam_rotation = compound.getFloat("beam_rotation"); - } + beam_enabled = compound.getBoolean("beam_enabled"); + render_core = compound.getBoolean("render_core"); + beam_red = compound.getInteger("beam_red"); + beam_green = compound.getInteger("beam_green"); + beam_blue = compound.getInteger("beam_blue"); + beam_scale = compound.getFloat("beam_scale"); + beam_pitch = compound.getFloat("beam_pitch"); + beam_yaw = compound.getFloat("beam_yaw"); + beam_length = compound.getFloat("beam_length"); + beam_rotation = compound.getFloat("beam_rotation"); + } - @SideOnly(Side.CLIENT) - public double getMaxRenderDistanceSquared() { - return 655360.0D; - } + @SideOnly(Side.CLIENT) + public double getMaxRenderDistanceSquared() { + return 655360.0D; + } - public static double limit(double value, double min, double max) { - return Math.max(min, Math.min(value, max)); - } + public static double limit(double value, double min, double max) { + return Math.max(min, Math.min(value, max)); + } - public static int limit(int value, int min, int max) { - return Math.max(min, Math.min(value, max)); - } + public static int limit(int value, int min, int max) { + return Math.max(min, Math.min(value, max)); + } - @Override - public String getName() { - return "particle_generator"; - } + @Override + public String getName() { + return "particle_generator"; + } - @Override - public String[] getMethodNames() { - return new String[] { - "setGeneratorProperty", - "getGeneratorState", - "resetGeneratorState" - }; - } + @Override + public String[] getMethodNames() { + return new String[]{"setGeneratorProperty", "getGeneratorState", "resetGeneratorState"}; + } - @Override - public Object[] callMethod(String method, Object... args) { - if (method.startsWith("setGeneratorProperty")) { - if (args.length != 2) return new Object[] { false }; - else if (!(args[0] instanceof String)) return new Object[] { false }; + @Override + public Object[] callMethod(String method, Object... args) { + if (method.startsWith("setGeneratorProperty")) { + if (args.length != 2) return new Object[]{false}; + else if (!(args[0] instanceof String)) return new Object[]{false}; /* Particles */ - if (args[0].equals("particles_enabled") && args[1] instanceof Boolean) { - particles_enabled = (Boolean) args[1]; - } - else if (args[0].equals("red") && args[1] instanceof Double) { - red = limit(((Double) args[1]).intValue(), 0, 255); - } - else if (args[0].equals("green") && args[1] instanceof Double) { - green = limit(((Double) args[1]).intValue(), 0, 255); - } - else if (args[0].equals("blue") && args[1] instanceof Double) { - blue = limit(((Double) args[1]).intValue(), 0, 255); - } - else if (args[0].equals("random_red") && args[1] instanceof Double) { - random_red = limit(((Double) args[1]).intValue(), 0, 255); - } - else if (args[0].equals("random_green") && args[1] instanceof Double) { - random_green = limit(((Double) args[1]).intValue(), 0, 255); - } - else if (args[0].equals("random_blue") && args[1] instanceof Double) { - random_blue = limit(((Double) args[1]).intValue(), 0, 255); - } - else if (args[0].equals("motion_x") && args[1] instanceof Double) { - motion_x = (float) limit((Double) args[1], -5F, 5F); - } - else if (args[0].equals("motion_y") && args[1] instanceof Double) { - motion_y = (float) limit((Double) args[1], -5F, 5F); - } - else if (args[0].equals("motion_z") && args[1] instanceof Double) { - motion_z = (float) limit((Double) args[1], -5F, 5F); - } - else if (args[0].equals("random_motion_x") && args[1] instanceof Double) { - random_motion_x = (float) limit((Double) args[1], -5F, 5F); - } - else if (args[0].equals("random_motion_y") && args[1] instanceof Double) { - random_motion_y = (float) limit((Double) args[1], -5F, 5F); - } - else if (args[0].equals("random_motion_z") && args[1] instanceof Double) { - random_motion_z = (float) limit((Double) args[1], -5F, 5F); - } - else if (args[0].equals("scale") && args[1] instanceof Double) { - scale = (float) limit((Double) args[1], 0.01F, 50F); - } - else if (args[0].equals("random_scale") && args[1] instanceof Double) { - random_scale = (float) limit((Double) args[1], 0.01F, 50F); - } - else if (args[0].equals("life") && args[1] instanceof Double) { - life = limit(((Double) args[1]).intValue(), 0, 1000); - } - else if (args[0].equals("random_life") && args[1] instanceof Double) { - random_life = limit(((Double) args[1]).intValue(), 0, 1000); - } - else if (args[0].equals("spawn_x") && args[1] instanceof Double) { - spawn_x = (float) limit((Double) args[1], -50F, 50F); - } - else if (args[0].equals("spawn_y") && args[1] instanceof Double) { - spawn_y = (float) limit((Double) args[1], -50F, 50F); - } - else if (args[0].equals("spawn_z") && args[1] instanceof Double) { - spawn_z = (float) limit((Double) args[1], -50F, 50F); - } - else if (args[0].equals("random_spawn_x") && args[1] instanceof Double) { - random_spawn_x = (float) limit((Double) args[1], -50F, 50F); - } - else if (args[0].equals("random_spawn_y") && args[1] instanceof Double) { - random_spawn_y = (float) limit((Double) args[1], -50F, 50F); - } - else if (args[0].equals("random_spawn_z") && args[1] instanceof Double) { - random_spawn_z = (float) limit((Double) args[1], -50F, 50F); - } - else if (args[0].equals("fade") && args[1] instanceof Double) { - fade = limit(((Double) args[1]).intValue(), 0, 100); - } - else if (args[0].equals("spawn_rate") && args[1] instanceof Double) { - spawn_rate = limit(((Double) args[1]).intValue(), 1, 200); - } - else if (args[0].equals("collide") && args[1] instanceof Double) { - collide = (Boolean) args[1]; - } - else if (args[0].equals("selected_particle") && args[1] instanceof Double) { - selected_particle = limit(((Double) args[1]).intValue(), 1, selected_max); - } - else if (args[0].equals("gravity") && args[1] instanceof Double) { - gravity = (float) limit((Double) args[1], -5F, 5F); - } - /* Beam */ - else if (args[0].equals("beam_enabled") && args[1] instanceof Boolean) { - beam_enabled = (Boolean) args[1]; - } - else if (args[0].equals("render_core") && args[1] instanceof Boolean) { - render_core = (Boolean) args[1]; - } - else if (args[0].equals("beam_red") && args[1] instanceof Double) { - beam_red = limit(((Double) args[1]).intValue(), 0, 255); - } - else if (args[0].equals("beam_green") && args[1] instanceof Double) { - beam_green = limit(((Double) args[1]).intValue(), 0, 255); - } - else if (args[0].equals("beam_blue") && args[1] instanceof Double) { - beam_blue = limit(((Double) args[1]).intValue(), 0, 255); - } - else if (args[0].equals("beam_scale") && args[1] instanceof Double) { - beam_scale = (float) limit((Double) args[1], -0F, 5F); - } - else if (args[0].equals("beam_pitch") && args[1] instanceof Double) { - beam_pitch = (float) limit((Double) args[1], -180F, 180F); - } - else if (args[0].equals("beam_yaw") && args[1] instanceof Double) { - beam_yaw = (float) limit((Double) args[1], -180F, 180F); - } - else if (args[0].equals("beam_length") && args[1] instanceof Double) { - beam_length = (float) limit((Double) args[1], -0F, 320F); - } - else if (args[0].equals("beam_rotation") && args[1] instanceof Double) { - beam_rotation = (float) limit((Double) args[1], -1F, 1F); - } - else { - return new Object[] { false }; - } + if (args[0].equals("particles_enabled") && args[1] instanceof Boolean) { + particles_enabled = (Boolean) args[1]; + } else if (args[0].equals("red") && args[1] instanceof Double) { + red = limit(((Double) args[1]).intValue(), 0, 255); + } else if (args[0].equals("green") && args[1] instanceof Double) { + green = limit(((Double) args[1]).intValue(), 0, 255); + } else if (args[0].equals("blue") && args[1] instanceof Double) { + blue = limit(((Double) args[1]).intValue(), 0, 255); + } else if (args[0].equals("random_red") && args[1] instanceof Double) { + random_red = limit(((Double) args[1]).intValue(), 0, 255); + } else if (args[0].equals("random_green") && args[1] instanceof Double) { + random_green = limit(((Double) args[1]).intValue(), 0, 255); + } else if (args[0].equals("random_blue") && args[1] instanceof Double) { + random_blue = limit(((Double) args[1]).intValue(), 0, 255); + } else if (args[0].equals("motion_x") && args[1] instanceof Double) { + motion_x = (float) limit((Double) args[1], -5F, 5F); + } else if (args[0].equals("motion_y") && args[1] instanceof Double) { + motion_y = (float) limit((Double) args[1], -5F, 5F); + } else if (args[0].equals("motion_z") && args[1] instanceof Double) { + motion_z = (float) limit((Double) args[1], -5F, 5F); + } else if (args[0].equals("random_motion_x") && args[1] instanceof Double) { + random_motion_x = (float) limit((Double) args[1], -5F, 5F); + } else if (args[0].equals("random_motion_y") && args[1] instanceof Double) { + random_motion_y = (float) limit((Double) args[1], -5F, 5F); + } else if (args[0].equals("random_motion_z") && args[1] instanceof Double) { + random_motion_z = (float) limit((Double) args[1], -5F, 5F); + } else if (args[0].equals("scale") && args[1] instanceof Double) { + scale = (float) limit((Double) args[1], 0.01F, 50F); + } else if (args[0].equals("random_scale") && args[1] instanceof Double) { + random_scale = (float) limit((Double) args[1], 0.01F, 50F); + } else if (args[0].equals("life") && args[1] instanceof Double) { + life = limit(((Double) args[1]).intValue(), 0, 1000); + } else if (args[0].equals("random_life") && args[1] instanceof Double) { + random_life = limit(((Double) args[1]).intValue(), 0, 1000); + } else if (args[0].equals("spawn_x") && args[1] instanceof Double) { + spawn_x = (float) limit((Double) args[1], -50F, 50F); + } else if (args[0].equals("spawn_y") && args[1] instanceof Double) { + spawn_y = (float) limit((Double) args[1], -50F, 50F); + } else if (args[0].equals("spawn_z") && args[1] instanceof Double) { + spawn_z = (float) limit((Double) args[1], -50F, 50F); + } else if (args[0].equals("random_spawn_x") && args[1] instanceof Double) { + random_spawn_x = (float) limit((Double) args[1], -50F, 50F); + } else if (args[0].equals("random_spawn_y") && args[1] instanceof Double) { + random_spawn_y = (float) limit((Double) args[1], -50F, 50F); + } else if (args[0].equals("random_spawn_z") && args[1] instanceof Double) { + random_spawn_z = (float) limit((Double) args[1], -50F, 50F); + } else if (args[0].equals("fade") && args[1] instanceof Double) { + fade = limit(((Double) args[1]).intValue(), 0, 100); + } else if (args[0].equals("spawn_rate") && args[1] instanceof Double) { + spawn_rate = limit(((Double) args[1]).intValue(), 1, 200); + } else if (args[0].equals("collide") && args[1] instanceof Double) { + collide = (Boolean) args[1]; + } else if (args[0].equals("selected_particle") && args[1] instanceof Double) { + selected_particle = limit(((Double) args[1]).intValue(), 1, selected_max); + } else if (args[0].equals("gravity") && args[1] instanceof Double) { + gravity = (float) limit((Double) args[1], -5F, 5F); + } + /* Beam */ + else if (args[0].equals("beam_enabled") && args[1] instanceof Boolean) { + beam_enabled = (Boolean) args[1]; + } else if (args[0].equals("render_core") && args[1] instanceof Boolean) { + render_core = (Boolean) args[1]; + } else if (args[0].equals("beam_red") && args[1] instanceof Double) { + beam_red = limit(((Double) args[1]).intValue(), 0, 255); + } else if (args[0].equals("beam_green") && args[1] instanceof Double) { + beam_green = limit(((Double) args[1]).intValue(), 0, 255); + } else if (args[0].equals("beam_blue") && args[1] instanceof Double) { + beam_blue = limit(((Double) args[1]).intValue(), 0, 255); + } else if (args[0].equals("beam_scale") && args[1] instanceof Double) { + beam_scale = (float) limit((Double) args[1], -0F, 5F); + } else if (args[0].equals("beam_pitch") && args[1] instanceof Double) { + beam_pitch = (float) limit((Double) args[1], -180F, 180F); + } else if (args[0].equals("beam_yaw") && args[1] instanceof Double) { + beam_yaw = (float) limit((Double) args[1], -180F, 180F); + } else if (args[0].equals("beam_length") && args[1] instanceof Double) { + beam_length = (float) limit((Double) args[1], -0F, 320F); + } else if (args[0].equals("beam_rotation") && args[1] instanceof Double) { + beam_rotation = (float) limit((Double) args[1], -1F, 1F); + } else { + return new Object[]{false}; + } - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - return new Object[] { true }; - } - else if (method.startsWith("getGeneratorState")) { - Map map = new HashMap(); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return new Object[]{true}; + } else if (method.startsWith("getGeneratorState")) { + Map map = new HashMap(); /* Particles */ - map.put("particles_enabled", particles_enabled); - map.put("red", red); - map.put("green", green); - map.put("blue", blue); - map.put("random_red", random_red); - map.put("random_green", random_green); - map.put("random_blue", random_blue); - map.put("motion_x", motion_x); - map.put("motion_y", motion_y); - map.put("motion_z", motion_z); - map.put("random_motion_x", random_motion_x); - map.put("random_motion_y", random_motion_y); - map.put("random_motion_z", random_motion_z); - map.put("scale", scale); - map.put("random_scale", random_scale); - map.put("life", life); - map.put("random_life", random_life); - map.put("spawn_x", spawn_x); - map.put("spawn_y", spawn_y); - map.put("spawn_z", spawn_z); - map.put("random_spawn_x", random_spawn_x); - map.put("random_spawn_y", random_spawn_y); - map.put("random_spawn_z", random_spawn_z); - map.put("fade", fade); - map.put("spawn_rate", spawn_rate); - map.put("collide", collide); - map.put("selected_particle", selected_particle); - map.put("gravity", gravity); + map.put("particles_enabled", particles_enabled); + map.put("red", red); + map.put("green", green); + map.put("blue", blue); + map.put("random_red", random_red); + map.put("random_green", random_green); + map.put("random_blue", random_blue); + map.put("motion_x", motion_x); + map.put("motion_y", motion_y); + map.put("motion_z", motion_z); + map.put("random_motion_x", random_motion_x); + map.put("random_motion_y", random_motion_y); + map.put("random_motion_z", random_motion_z); + map.put("scale", scale); + map.put("random_scale", random_scale); + map.put("life", life); + map.put("random_life", random_life); + map.put("spawn_x", spawn_x); + map.put("spawn_y", spawn_y); + map.put("spawn_z", spawn_z); + map.put("random_spawn_x", random_spawn_x); + map.put("random_spawn_y", random_spawn_y); + map.put("random_spawn_z", random_spawn_z); + map.put("fade", fade); + map.put("spawn_rate", spawn_rate); + map.put("collide", collide); + map.put("selected_particle", selected_particle); + map.put("gravity", gravity); /* Beam */ - map.put("beam_enabled", beam_enabled); - map.put("render_core", render_core); - map.put("beam_red", beam_red); - map.put("beam_green", beam_green); - map.put("beam_blue", beam_blue); - map.put("beam_scale", beam_scale); - map.put("beam_pitch", beam_pitch); - map.put("beam_yaw", beam_yaw); - map.put("beam_length", beam_length); - map.put("beam_rotation", beam_rotation); + map.put("beam_enabled", beam_enabled); + map.put("render_core", render_core); + map.put("beam_red", beam_red); + map.put("beam_green", beam_green); + map.put("beam_blue", beam_blue); + map.put("beam_scale", beam_scale); + map.put("beam_pitch", beam_pitch); + map.put("beam_yaw", beam_yaw); + map.put("beam_length", beam_length); + map.put("beam_rotation", beam_rotation); - return new Object[]{ map }; - } - else if (method.startsWith("resetGeneratorState")) { - particles_enabled = true; - red = 0; - green = 0; - blue = 0; - random_red = 0; - random_green = 0; - random_blue = 0; - motion_x = 0.0F; - motion_y = 0.0F; - motion_z = 0.0F; - random_motion_x = 0.0F; - random_motion_y = 0.0F; - random_motion_z = 0.0F; - scale = 1F; - random_scale = 0F; - life = 100; - random_life = 0; - spawn_x = 0; - spawn_y = 0; - spawn_z = 0; - random_spawn_x = 0; - random_spawn_y = 0; - random_spawn_z = 0; - page = 1; - fade = 0; - spawn_rate = 1; - collide = false; - selected_particle = 1; - gravity = 0F; + return new Object[]{map}; + } else if (method.startsWith("resetGeneratorState")) { + particles_enabled = true; + red = 0; + green = 0; + blue = 0; + random_red = 0; + random_green = 0; + random_blue = 0; + motion_x = 0.0F; + motion_y = 0.0F; + motion_z = 0.0F; + random_motion_x = 0.0F; + random_motion_y = 0.0F; + random_motion_z = 0.0F; + scale = 1F; + random_scale = 0F; + life = 100; + random_life = 0; + spawn_x = 0; + spawn_y = 0; + spawn_z = 0; + random_spawn_x = 0; + random_spawn_y = 0; + random_spawn_z = 0; + page = 1; + fade = 0; + spawn_rate = 1; + collide = false; + selected_particle = 1; + gravity = 0F; - //beam - beam_enabled = false; - render_core = false; + //beam + beam_enabled = false; + render_core = false; - beam_red = 0; - beam_green = 0; - beam_blue = 0; - beam_scale = 1F; - beam_pitch = 0F; - beam_yaw = 0F; - beam_length = 0F; - beam_rotation = 0F; + beam_red = 0; + beam_green = 0; + beam_blue = 0; + beam_scale = 1F; + beam_pitch = 0F; + beam_yaw = 0F; + beam_length = 0F; + beam_rotation = 0F; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - return new Object[] { true }; - } + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return new Object[]{true}; + } - return new Object[] {0}; - } + return new Object[]{0}; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePlacedItem.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePlacedItem.java index 8dc0b761..831ace64 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePlacedItem.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePlacedItem.java @@ -11,56 +11,56 @@ import net.minecraft.tileentity.TileEntity; /** * Created by Brandon on 14/08/2014. */ -public class TilePlacedItem extends TileEntity{ - public ItemStack stack; - public float rotation = 0F; - private boolean hasUpdated = false; +public class TilePlacedItem extends TileEntity { + public ItemStack stack; + public float rotation = 0F; + private boolean hasUpdated = false; - @Override - public void updateEntity() { - if (!hasUpdated && stack != null) { - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - hasUpdated = true; - } - } + @Override + public void updateEntity() { + if (!hasUpdated && stack != null) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + hasUpdated = true; + } + } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound tagCompound = new NBTTagCompound(); - writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - public void setStack(ItemStack stack){ - this.stack = stack; - worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, ModBlocks.placedItem, 20); - } + public void setStack(ItemStack stack) { + this.stack = stack; + worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, ModBlocks.placedItem, 20); + } - public ItemStack getStack(){ - return stack; - } + public ItemStack getStack() { + return stack; + } - @Override - public void writeToNBT(NBTTagCompound compound) { - super.writeToNBT(compound); - NBTTagCompound[] tag = new NBTTagCompound[1]; - tag[0] = new NBTTagCompound(); - if (stack != null) tag[0] = stack.writeToNBT(tag[0]); - compound.setTag("Item" + 0, tag[0]); - compound.setFloat("Rotation", rotation); - } + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + NBTTagCompound[] tag = new NBTTagCompound[1]; + tag[0] = new NBTTagCompound(); + if (stack != null) tag[0] = stack.writeToNBT(tag[0]); + compound.setTag("Item" + 0, tag[0]); + compound.setFloat("Rotation", rotation); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - super.readFromNBT(compound); - NBTTagCompound[] tag = new NBTTagCompound[1]; - tag[0] = compound.getCompoundTag("Item" + 0); - stack = ItemStack.loadItemStackFromNBT(tag[0]); - rotation = compound.getFloat("Rotation"); - } + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + NBTTagCompound[] tag = new NBTTagCompound[1]; + tag[0] = compound.getCompoundTag("Item" + 0); + stack = ItemStack.loadItemStackFromNBT(tag[0]); + rotation = compound.getFloat("Rotation"); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePlayerDetector.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePlayerDetector.java index e1a79374..8fb743a1 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePlayerDetector.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePlayerDetector.java @@ -7,97 +7,79 @@ import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; -public class TilePlayerDetector extends TileEntity -{ - private int tick = 0; - public boolean output = false; - private int scanRate = 5; - private int range = 1; - - @Override - public void updateEntity() - { - if (worldObj.isRemote) - return; - - if (tick >= scanRate) - { - tick = 0; - EntityPlayer player = worldObj.getClosestPlayer(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, range + 0.5D); - if (player != null) - { - if (!output) - setOutput(true); - } - else{ - if (output) - setOutput(false); - } - }else - tick++; - - } - - private void setOutput(boolean out) - { - output = out; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - updateBlocks(); - } - - public void setRange(int value) - { - this.range = value; - } - - public int getRange() - { - return range; - } - - public void updateBlocks() - { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord - 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord + 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord + 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord - 1, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord + 1, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - - public Packet getDescriptionPacket() - { - NBTTagCompound tagCompound = new NBTTagCompound(); - this.writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } +public class TilePlayerDetector extends TileEntity { + private int tick = 0; + public boolean output = false; + private int scanRate = 5; + private int range = 1; - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) - { - readFromNBT(pkt.func_148857_g()); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } - - @Override - public void writeToNBT(NBTTagCompound compound) - { - compound.setBoolean("OutPut", output); - compound.setInteger("Range", range); - - super.writeToNBT(compound); - } + @Override + public void updateEntity() { + if (worldObj.isRemote) return; + + if (tick >= scanRate) { + tick = 0; + EntityPlayer player = worldObj.getClosestPlayer(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, range + 0.5D); + if (player != null) { + if (!output) setOutput(true); + } else { + if (output) setOutput(false); + } + } else tick++; + + } + + private void setOutput(boolean out) { + output = out; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + updateBlocks(); + } + + public void setRange(int value) { + this.range = value; + } + + public int getRange() { + return range; + } + + public void updateBlocks() { + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord - 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord + 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord + 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord - 1, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord + 1, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + this.writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + + @Override + public void writeToNBT(NBTTagCompound compound) { + compound.setBoolean("OutPut", output); + compound.setInteger("Range", range); + + super.writeToNBT(compound); + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + output = compound.getBoolean("OutPut"); + range = compound.getInteger("Range"); + + super.readFromNBT(compound); + } - @Override - public void readFromNBT(NBTTagCompound compound) - { - output = compound.getBoolean("OutPut"); - range = compound.getInteger("Range"); - - super.readFromNBT(compound); - } - - } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePlayerDetectorAdvanced.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePlayerDetectorAdvanced.java index 4046048b..fe753fb1 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePlayerDetectorAdvanced.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePlayerDetectorAdvanced.java @@ -19,301 +19,248 @@ import java.util.Iterator; import java.util.List; public class TilePlayerDetectorAdvanced extends TileEntity implements IInventory { - public String[] names = new String[42]; - private ItemStack[] items; - public boolean whiteList = false; - public int range = 10; - private int tick = 0; - private int scanRate = 5; - public boolean output = false; + public String[] names = new String[42]; + private ItemStack[] items; + public boolean whiteList = false; + public int range = 10; + private int tick = 0; + private int scanRate = 5; + public boolean output = false; public boolean outputInverted = false; - private List EntityList; + private List EntityList; - public TilePlayerDetectorAdvanced() - { - for (int i = 0; i < names.length; i++) - if (names[i] == null) - names[i] = ""; - - items = new ItemStack[1]; - } - - @Override - public void updateEntity() - { - if (worldObj.isRemote) - return; - - if (tick >= scanRate) - { - - tick = 0; - - if (shouldEmit()) - { - if (!output) - setOutput(true); - } - else{ - if (output) - setOutput(false); - } - }else - tick++; - } - - public boolean shouldEmit() - { - findEntitys(); - - boolean b = false; - Iterator i = EntityList.iterator(); - while (i.hasNext()) - { - Entity ent = i.next(); - if (!(ent instanceof EntityPlayer)) - return false; - - String name = ((EntityPlayer)ent).getCommandSenderName(); - if(whiteList) - { - if (isPlayerListed(name)) - return true; - }else - { - if (!isPlayerListed(name)) - return true; - } - - } - return b; - } - - @SuppressWarnings({ "unchecked" }) - private void findEntitys() - { - double x1 = xCoord + 0.5 - range; - double y1 = yCoord + 0.5 - range; - double z1 = zCoord + 0.5 - range; - double x2 = xCoord + 0.5 + range; - double y2 = yCoord + 0.5 + range; - double z2 = zCoord + 0.5 + range; - - //System.out.println(x1 + " " + y1 + " " + z1 + " " + x2 + " " + y2 + " " + z2); - - //ScanBox = AxisAlignedBB.getBoundingBox(x1, y1, z1, x2, y2, z2); - //ScanBox = AxisAlignedBB.getAABBPool().getAABB(xCoord + 0.5 - range, yCoord + 0.5 - range, zCoord + 0.5 - range, xCoord + 0.5 + range, yCoord + 0.5 + range, zCoord + 0.5 + range); - EntityList = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x1, y1, z1, x2, y2, z2)); - //System.out.println(EntityList); - } - - private void setOutput(boolean out) - { - output = out; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - updateBlocks(); - } - - public void updateBlocks() - { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord - 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord + 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord + 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord - 1, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord + 1, worldObj.getBlock(xCoord, yCoord, zCoord)); - } + public TilePlayerDetectorAdvanced() { + for (int i = 0; i < names.length; i++) + if (names[i] == null) names[i] = ""; - public boolean isPlayerListed(String name) - { - if (name == null) - return false; - - for (int i = 0; i < names.length; i++) - { - if (names[i].equals(name)) - return true; - } - return false; - } - - //###################INVENTORY########################### - public int getSizeInventory() - { - return items.length; - } + items = new ItemStack[1]; + } - @Override - public ItemStack getStackInSlot(int i) - { - return items[i]; - } + @Override + public void updateEntity() { + if (worldObj.isRemote) return; - @Override - public ItemStack decrStackSize(int i, int count) - { - ItemStack itemstack = getStackInSlot(i); + if (tick >= scanRate) { - if (itemstack != null) - { - if (itemstack.stackSize <= count) - { - setInventorySlotContents(i, null); - } else - { - itemstack = itemstack.splitStack(count); - if (itemstack.stackSize == 0) - { - setInventorySlotContents(i, null); - } - } - } - return itemstack; - } + tick = 0; - @Override - public ItemStack getStackInSlotOnClosing(int i) - { - ItemStack item = getStackInSlot(i); - if (item != null) - setInventorySlotContents(i, null); - return item; - } + if (shouldEmit()) { + if (!output) setOutput(true); + } else { + if (output) setOutput(false); + } + } else tick++; + } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) - { - items[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - { - itemstack.stackSize = getInventoryStackLimit(); - } - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } + public boolean shouldEmit() { + findEntitys(); - @Override - public String getInventoryName() - { - return ""; - } + boolean b = false; + Iterator i = EntityList.iterator(); + while (i.hasNext()) { + Entity ent = i.next(); + if (!(ent instanceof EntityPlayer)) return false; - @Override - public boolean hasCustomInventoryName() - { - return false; - } + String name = ((EntityPlayer) ent).getCommandSenderName(); + if (whiteList) { + if (isPlayerListed(name)) return true; + } else { + if (!isPlayerListed(name)) return true; + } - @Override - public int getInventoryStackLimit() - { - return 1; - } + } + return b; + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) - { - if (worldObj == null) - { - return true; - } - if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) - { - return false; - } - return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; - } + @SuppressWarnings({"unchecked"}) + private void findEntitys() { + double x1 = xCoord + 0.5 - range; + double y1 = yCoord + 0.5 - range; + double z1 = zCoord + 0.5 - range; + double x2 = xCoord + 0.5 + range; + double y2 = yCoord + 0.5 + range; + double z2 = zCoord + 0.5 + range; - @Override - public void openInventory() - { - } + //System.out.println(x1 + " " + y1 + " " + z1 + " " + x2 + " " + y2 + " " + z2); - @Override - public void closeInventory() - { - } + //ScanBox = AxisAlignedBB.getBoundingBox(x1, y1, z1, x2, y2, z2); + //ScanBox = AxisAlignedBB.getAABBPool().getAABB(xCoord + 0.5 - range, yCoord + 0.5 - range, zCoord + 0.5 - range, xCoord + 0.5 + range, yCoord + 0.5 + range, zCoord + 0.5 + range); + EntityList = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x1, y1, z1, x2, y2, z2)); + //System.out.println(EntityList); + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) - { - return false; - } + private void setOutput(boolean out) { + output = out; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + updateBlocks(); + } - //###################################################### - - public Packet getDescriptionPacket() - { - NBTTagCompound tagCompound = new NBTTagCompound(); - this.writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + public void updateBlocks() { + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord - 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord + 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord + 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord - 1, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord + 1, worldObj.getBlock(xCoord, yCoord, zCoord)); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) - { - readFromNBT(pkt.func_148857_g()); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } - - public Container getGuiContainer (InventoryPlayer inventoryplayer) - { + public boolean isPlayerListed(String name) { + if (name == null) return false; + + for (int i = 0; i < names.length; i++) { + if (names[i].equals(name)) return true; + } + return false; + } + + //###################INVENTORY########################### + public int getSizeInventory() { + return items.length; + } + + @Override + public ItemStack getStackInSlot(int i) { + return items[i]; + } + + @Override + public ItemStack decrStackSize(int i, int count) { + ItemStack itemstack = getStackInSlot(i); + + if (itemstack != null) { + if (itemstack.stackSize <= count) { + setInventorySlotContents(i, null); + } else { + itemstack = itemstack.splitStack(count); + if (itemstack.stackSize == 0) { + setInventorySlotContents(i, null); + } + } + } + return itemstack; + } + + @Override + public ItemStack getStackInSlotOnClosing(int i) { + ItemStack item = getStackInSlot(i); + if (item != null) setInventorySlotContents(i, null); + return item; + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + items[i] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + + @Override + public String getInventoryName() { + return ""; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + if (worldObj == null) { + return true; + } + if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { + return false; + } + return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return false; + } + + //###################################################### + + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + this.writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + + public Container getGuiContainer(InventoryPlayer inventoryplayer) { return new ContainerPlayerDetector(inventoryplayer, this); } - - - @Override - public void writeToNBT(NBTTagCompound compound) - { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) - { - tag[i] = new NBTTagCompound(); - if (items[i] != null) - { - tag[i] = items[i].writeToNBT(tag[i]); - } + @Override + public void writeToNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - compound.setTag("Item" + i, tag[i]); - } - - for (int i = 0; i < names.length; i++) - { - String name = (names[i] != null) ? names[i] : ""; - compound.setString("Name_"+i, name); - } - - compound.setBoolean("WhiteList", whiteList); - compound.setBoolean("Output", output); - compound.setInteger("Range", range); + for (int i = 0; i < items.length; i++) { + tag[i] = new NBTTagCompound(); + + if (items[i] != null) { + tag[i] = items[i].writeToNBT(tag[i]); + } + + compound.setTag("Item" + i, tag[i]); + } + + for (int i = 0; i < names.length; i++) { + String name = (names[i] != null) ? names[i] : ""; + compound.setString("Name_" + i, name); + } + + compound.setBoolean("WhiteList", whiteList); + compound.setBoolean("Output", output); + compound.setInteger("Range", range); compound.setBoolean("OutputInverted", outputInverted); - - super.writeToNBT(compound); - } - @Override - public void readFromNBT(NBTTagCompound compound) - { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + super.writeToNBT(compound); + } - for (int i = 0; i < items.length; i++) - { - tag[i] = compound.getCompoundTag("Item" + i); - items[i] = ItemStack.loadItemStackFromNBT(tag[i]); - } - - for (int i = 0; i < names.length; i++) - names[i] = compound.getString("Name_" + i); - - whiteList = compound.getBoolean("WhiteList"); - range = compound.getInteger("Range"); - output = compound.getBoolean("Output"); + @Override + public void readFromNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; + + for (int i = 0; i < items.length; i++) { + tag[i] = compound.getCompoundTag("Item" + i); + items[i] = ItemStack.loadItemStackFromNBT(tag[i]); + } + + for (int i = 0; i < names.length; i++) + names[i] = compound.getString("Name_" + i); + + whiteList = compound.getBoolean("WhiteList"); + range = compound.getInteger("Range"); + output = compound.getBoolean("Output"); outputInverted = compound.getBoolean("OutputInverted"); - - super.readFromNBT(compound); - } + + super.readFromNBT(compound); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePotentiometer.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePotentiometer.java index 4421a531..c41a5c25 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePotentiometer.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TilePotentiometer.java @@ -6,93 +6,70 @@ import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; -public class TilePotentiometer extends TileEntity -{ - public int power = 0; - - public void increasePower() - { - if (power < 15) - { - power++; - worldObj.playSound(xCoord, yCoord, zCoord, "random.click", 1, 0.5F + ((float)power / 15F), false); - } - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - updateBlocks(); - } - - public void decreasePower() - { - if (power > 0) - { - power--; - worldObj.playSound(xCoord, yCoord, zCoord, "random.click", 1, 0.5F + ((float)power / 15F), false); - } - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - updateBlocks(); - } - - public void updateBlocks() - { - int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); +public class TilePotentiometer extends TileEntity { + public int power = 0; - if (meta == 1) - { - worldObj.notifyBlocksOfNeighborChange(xCoord - 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - else if (meta == 2) - { - worldObj.notifyBlocksOfNeighborChange(xCoord + 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - else if (meta == 3) - { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord - 1, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - else if (meta == 4) - { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord + 1, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - else if (meta == 5) - { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord + 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - else if (meta == 6) - { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - else - { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - } - - @Override - public Packet getDescriptionPacket() - { - NBTTagCompound tagCompound = new NBTTagCompound(); - this.writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + public void increasePower() { + if (power < 15) { + power++; + worldObj.playSound(xCoord, yCoord, zCoord, "random.click", 1, 0.5F + ((float) power / 15F), false); + } + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + updateBlocks(); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) - { - readFromNBT(pkt.func_148857_g()); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } - - @Override - public void readFromNBT(NBTTagCompound compound) - { - super.readFromNBT(compound); - power = compound.getInteger("Power"); - } - - @Override - public void writeToNBT(NBTTagCompound compound) - { - compound.setInteger("Power", power); - super.writeToNBT(compound); - } + public void decreasePower() { + if (power > 0) { + power--; + worldObj.playSound(xCoord, yCoord, zCoord, "random.click", 1, 0.5F + ((float) power / 15F), false); + } + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + updateBlocks(); + } + + public void updateBlocks() { + int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + + if (meta == 1) { + worldObj.notifyBlocksOfNeighborChange(xCoord - 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } else if (meta == 2) { + worldObj.notifyBlocksOfNeighborChange(xCoord + 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } else if (meta == 3) { + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord - 1, worldObj.getBlock(xCoord, yCoord, zCoord)); + } else if (meta == 4) { + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord + 1, worldObj.getBlock(xCoord, yCoord, zCoord)); + } else if (meta == 5) { + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord + 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } else if (meta == 6) { + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } else { + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + this.writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + power = compound.getInteger("Power"); + } + + @Override + public void writeToNBT(NBTTagCompound compound) { + compound.setInteger("Power", power); + super.writeToNBT(compound); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileSunDial.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileSunDial.java index 2892ed05..fb8eab6c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileSunDial.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileSunDial.java @@ -6,217 +6,186 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; public class TileSunDial extends TileEntity implements IInventory { - int tick; - int tick2; - public boolean running = false; + int tick; + int tick2; + public boolean running = false; - @Override - public void updateEntity() - { - CheckPower(); - if (running) { - tick++; - tick2++; - Runn(); - } - } + @Override + public void updateEntity() { + CheckPower(); + if (running) { + tick++; + tick2++; + Runn(); + } + } - private void CheckPower() - { - if (worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) - running = true; - else { - if (running) { - tick = 0; - tick2 = 0; - running = false; - worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:discharge", 5F, worldObj.rand.nextFloat() * 0.1F + 0.9F); - } - } - } + private void CheckPower() { + if (worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) running = true; + else { + if (running) { + tick = 0; + tick2 = 0; + running = false; + worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:discharge", 5F, worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + } + } - private void Runn() - { - if (tick == 1) { - worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:charge", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } - if (tick < 74) { - worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 0.1, zCoord, 0D, 0D, -0.01D); - worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 0.1, zCoord + 1, 0D, 0D, 0.01D); - worldObj.spawnParticle("explode", xCoord + 0, yCoord + 0.1, zCoord + 0.5, -0.01D, 0D, 0D); - worldObj.spawnParticle("explode", xCoord + 1, yCoord + 0.1, zCoord + 0.5, 0.01D, 0D, 0D); - } - if (tick > 74 && tick2 == 1) { - worldObj.spawnParticle("flame", xCoord + worldObj.rand.nextFloat(), yCoord + worldObj.rand.nextFloat(), zCoord, 0D, 0D, -0.01D); - worldObj.spawnParticle("flame", xCoord + worldObj.rand.nextFloat(), yCoord + worldObj.rand.nextFloat(), zCoord + 1, 0D, 0D, 0.01D); - worldObj.spawnParticle("flame", xCoord + 0, yCoord + worldObj.rand.nextFloat(), zCoord + worldObj.rand.nextFloat(), -0.01D, 0D, 0D); - worldObj.spawnParticle("flame", xCoord + 1, yCoord + worldObj.rand.nextFloat(), zCoord + worldObj.rand.nextFloat(), 0.01D, 0D, 0D); - } - if (tick > 74) - Track(getTime()); - if (tick > 74) - worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:beam", 5F, worldObj.rand.nextFloat() * 0.1F + 0.9F); - if (tick > 74) - worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:boom", 20F, worldObj.rand.nextFloat() * 0.1F + 0.9F); - if (tick2 == 5) - tick2 = 0; - } + private void Runn() { + if (tick == 1) { + worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:charge", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + if (tick < 74) { + worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 0.1, zCoord, 0D, 0D, -0.01D); + worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 0.1, zCoord + 1, 0D, 0D, 0.01D); + worldObj.spawnParticle("explode", xCoord + 0, yCoord + 0.1, zCoord + 0.5, -0.01D, 0D, 0D); + worldObj.spawnParticle("explode", xCoord + 1, yCoord + 0.1, zCoord + 0.5, 0.01D, 0D, 0D); + } + if (tick > 74 && tick2 == 1) { + worldObj.spawnParticle("flame", xCoord + worldObj.rand.nextFloat(), yCoord + worldObj.rand.nextFloat(), zCoord, 0D, 0D, -0.01D); + worldObj.spawnParticle("flame", xCoord + worldObj.rand.nextFloat(), yCoord + worldObj.rand.nextFloat(), zCoord + 1, 0D, 0D, 0.01D); + worldObj.spawnParticle("flame", xCoord + 0, yCoord + worldObj.rand.nextFloat(), zCoord + worldObj.rand.nextFloat(), -0.01D, 0D, 0D); + worldObj.spawnParticle("flame", xCoord + 1, yCoord + worldObj.rand.nextFloat(), zCoord + worldObj.rand.nextFloat(), 0.01D, 0D, 0D); + } + if (tick > 74) Track(getTime()); + if (tick > 74) + worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:beam", 5F, worldObj.rand.nextFloat() * 0.1F + 0.9F); + if (tick > 74) + worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:boom", 20F, worldObj.rand.nextFloat() * 0.1F + 0.9F); + if (tick2 == 5) tick2 = 0; + } - private void Track(final double t) - { - double time = t; - if ((time >= 0 && time <= 5) || (time >= 19.3 && time <= 20)) { - if (time > 5) { - Beam(1, (time - 19.33) / 3); - } else { - final double x = 5 - time; - final double y = 1 * time + 1.2; - final double x1 = map(x, 0, 5, 0, 1); - final double y1 = map(y, 0, 5, 0, 1); - Beam(x1, y1); - } - } else if (time >= 5 && time <= 10.63) { - final double x = (time - 5) * -1; - final double y = 6.2 - (time - 5); - final double x1 = map(x, 0, 5, 0, 1); - final double y1 = map(y, 0, 5, 0, 1); - if (time > 10) - Beam(x1, y1 - ((time - 10) / 4.5)); - else - Beam(x1, y1); - } else if (time > 10.63 && time < 15) { - final double comp = time - 10.63; - time = (time - 10) - (0.63 - (comp / 7.936)); - final double x = time - 5; - final double y = 0 - time; - final double x1 = map(x, 0, 5, 0, 1); - final double y1 = map(y, 0, 5, 0, 1); - Beam(x1, y1); - } else if (time > 15 && time < 19.3) { - final double comp = time - 15; - time = time + comp / 6; - final double x = 0 + (time - 15); - final double y = -5 + (time - 15); - final double x1 = map(x, 0, 5, 0, 1); - final double y1 = map(y, 0, 5, 0, 1); - Beam(x1, y1); - } - } + private void Track(final double t) { + double time = t; + if ((time >= 0 && time <= 5) || (time >= 19.3 && time <= 20)) { + if (time > 5) { + Beam(1, (time - 19.33) / 3); + } else { + final double x = 5 - time; + final double y = 1 * time + 1.2; + final double x1 = map(x, 0, 5, 0, 1); + final double y1 = map(y, 0, 5, 0, 1); + Beam(x1, y1); + } + } else if (time >= 5 && time <= 10.63) { + final double x = (time - 5) * -1; + final double y = 6.2 - (time - 5); + final double x1 = map(x, 0, 5, 0, 1); + final double y1 = map(y, 0, 5, 0, 1); + if (time > 10) Beam(x1, y1 - ((time - 10) / 4.5)); + else Beam(x1, y1); + } else if (time > 10.63 && time < 15) { + final double comp = time - 10.63; + time = (time - 10) - (0.63 - (comp / 7.936)); + final double x = time - 5; + final double y = 0 - time; + final double x1 = map(x, 0, 5, 0, 1); + final double y1 = map(y, 0, 5, 0, 1); + Beam(x1, y1); + } else if (time > 15 && time < 19.3) { + final double comp = time - 15; + time = time + comp / 6; + final double x = 0 + (time - 15); + final double y = -5 + (time - 15); + final double x1 = map(x, 0, 5, 0, 1); + final double y1 = map(y, 0, 5, 0, 1); + Beam(x1, y1); + } + } - private void Beam(final double x, final double y) - { - long worldTime = worldObj.getWorldTime(); - worldTime = worldTime + 30; - worldObj.setWorldTime(worldTime); - worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 2, y * 2, 0D); - worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 3, y * 3, 0D); - worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 4, y * 4, 0D); - worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 5, y * 5, 0D); - worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 6, y * 6, 0D); - worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 7, y * 7, 0D); - worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 8, y * 8, 0D); - worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 9, y * 9, 0D); - worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 10, y * 10, 0D); - worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 19.3, y * 19.3, 0D); - worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 19.5, y * 19.5, 0D); - worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 19.7, y * 19.7, 0D); - worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 20, y * 20, 0D); - worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, 0D, 0D, 0D); - worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, 0D, 0D, 0D); - } + private void Beam(final double x, final double y) { + long worldTime = worldObj.getWorldTime(); + worldTime = worldTime + 30; + worldObj.setWorldTime(worldTime); + worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 2, y * 2, 0D); + worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 3, y * 3, 0D); + worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 4, y * 4, 0D); + worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 5, y * 5, 0D); + worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 6, y * 6, 0D); + worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 7, y * 7, 0D); + worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 8, y * 8, 0D); + worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 9, y * 9, 0D); + worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 10, y * 10, 0D); + worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 19.3, y * 19.3, 0D); + worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 19.5, y * 19.5, 0D); + worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 19.7, y * 19.7, 0D); + worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 20, y * 20, 0D); + worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, 0D, 0D, 0D); + worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, 0D, 0D, 0D); + } - private double getTime() - { - final double days = worldObj.getWorldTime() / 24000; - final double time = worldObj.getWorldTime() - days * 24000; - final double time2 = time / 1.2; - final double time3 = Math.round(time2 / 10); - final double time4 = time3 / 100; - return time4; - } + private double getTime() { + final double days = worldObj.getWorldTime() / 24000; + final double time = worldObj.getWorldTime() - days * 24000; + final double time2 = time / 1.2; + final double time3 = Math.round(time2 / 10); + final double time4 = time3 / 100; + return time4; + } - private double map(final double x, final double in_min, final double in_max, final double out_min, final double out_max) - { - return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; - } + private double map(final double x, final double in_min, final double in_max, final double out_min, final double out_max) { + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; + } - - - - - - - - //###################################Inventory#####################################################// - @Override - public int getSizeInventory() - { - return 0; - } + //###################################Inventory#####################################################// + @Override + public int getSizeInventory() { + return 0; + } - @Override - public ItemStack getStackInSlot(int i) - { - return null; - } + @Override + public ItemStack getStackInSlot(int i) { + return null; + } - @Override - public ItemStack decrStackSize(int i, int count) - { - return null; - } + @Override + public ItemStack decrStackSize(int i, int count) { + return null; + } - @Override - public ItemStack getStackInSlotOnClosing(int i) - { - return null; - } + @Override + public ItemStack getStackInSlotOnClosing(int i) { + return null; + } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) - { - } + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + } - @Override - public String getInventoryName() - { - return ""; - } + @Override + public String getInventoryName() { + return ""; + } - @Override - public boolean hasCustomInventoryName() - { - return false; - } + @Override + public boolean hasCustomInventoryName() { + return false; + } - @Override - public int getInventoryStackLimit() - { - return 0; - } + @Override + public int getInventoryStackLimit() { + return 0; + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) - { - return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; - } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; + } - @Override - public void openInventory() - { - } + @Override + public void openInventory() { + } - @Override - public void closeInventory() - { - } + @Override + public void closeInventory() { + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) - { - return false; - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileTeleporterStand.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileTeleporterStand.java index 3d669b5b..d9e973a4 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileTeleporterStand.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileTeleporterStand.java @@ -13,140 +13,137 @@ import net.minecraft.tileentity.TileEntity; * Created by Brandon on 27/06/2014. */ public class TileTeleporterStand extends TileEntity implements IInventory {//todo Create IRotatable Tile and gui - ItemStack[] items = new ItemStack[1]; - public int rotation = 0; + ItemStack[] items = new ItemStack[1]; + public int rotation = 0; - //==============================================LOGIC=======================================================// + //==============================================LOGIC=======================================================// - @Override - public void updateEntity() { - } + @Override + public void updateEntity() { + } - //==========================================SYNCHRONIZATION==================================================// + //==========================================SYNCHRONIZATION==================================================// - @Override - public Packet getDescriptionPacket() { - NBTTagCompound tagCompound = new NBTTagCompound(); - this.writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + this.writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - //==============================================INVENTORY====================================================// + //==============================================INVENTORY====================================================// - @Override - public int getSizeInventory() { - return items.length; - } + @Override + public int getSizeInventory() { + return items.length; + } - @Override - public ItemStack getStackInSlot(int i) { - return items[i]; - } + @Override + public ItemStack getStackInSlot(int i) { + return items[i]; + } - @Override - public ItemStack decrStackSize(int i, int count) { - ItemStack itemstack = getStackInSlot(i); + @Override + public ItemStack decrStackSize(int i, int count) { + ItemStack itemstack = getStackInSlot(i); - if (itemstack != null) { - if (itemstack.stackSize <= count) { - setInventorySlotContents(i, null); - } else { - itemstack = itemstack.splitStack(count); - if (itemstack.stackSize == 0) { - setInventorySlotContents(i, null); - } - } - } - return itemstack; - } + if (itemstack != null) { + if (itemstack.stackSize <= count) { + setInventorySlotContents(i, null); + } else { + itemstack = itemstack.splitStack(count); + if (itemstack.stackSize == 0) { + setInventorySlotContents(i, null); + } + } + } + return itemstack; + } - @Override - public ItemStack getStackInSlotOnClosing(int i) { - ItemStack item = getStackInSlot(i); - if (item != null) setInventorySlotContents(i, null); - return item; - } + @Override + public ItemStack getStackInSlotOnClosing(int i) { + ItemStack item = getStackInSlot(i); + if (item != null) setInventorySlotContents(i, null); + return item; + } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - items[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); - } - } + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + items[i] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } - @Override - public String getInventoryName() { - return ""; - } + @Override + public String getInventoryName() { + return ""; + } - @Override - public boolean hasCustomInventoryName() { - return false; - } + @Override + public boolean hasCustomInventoryName() { + return false; + } - @Override - public int getInventoryStackLimit() { - return 1; - } + @Override + public int getInventoryStackLimit() { + return 1; + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; - } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; + } - @Override - public void openInventory() {} + @Override + public void openInventory() { + } - @Override - public void closeInventory() {} + @Override + public void closeInventory() { + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } - //===========================================================================================================// + //===========================================================================================================// - @Override - public void writeToNBT(NBTTagCompound compound) - { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void writeToNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) - { - tag[i] = new NBTTagCompound(); + for (int i = 0; i < items.length; i++) { + tag[i] = new NBTTagCompound(); - if (items[i] != null) - { - tag[i] = items[i].writeToNBT(tag[i]); - } + if (items[i] != null) { + tag[i] = items[i].writeToNBT(tag[i]); + } - compound.setTag("Item" + i, tag[i]); - } - super.writeToNBT(compound); + compound.setTag("Item" + i, tag[i]); + } + super.writeToNBT(compound); - compound.setInteger("Rotation", rotation); - } + compound.setInteger("Rotation", rotation); + } - @Override - public void readFromNBT(NBTTagCompound compound) - { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void readFromNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) - { - tag[i] = compound.getCompoundTag("Item" + i); - items[i] = ItemStack.loadItemStackFromNBT(tag[i]); - } - super.readFromNBT(compound); + for (int i = 0; i < items.length; i++) { + tag[i] = compound.getCompoundTag("Item" + i); + items[i] = ItemStack.loadItemStackFromNBT(tag[i]); + } + super.readFromNBT(compound); - rotation = compound.getInteger("Rotation"); - } + rotation = compound.getInteger("Rotation"); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileTestBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileTestBlock.java index 88bca472..76e2fab2 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileTestBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileTestBlock.java @@ -22,26 +22,27 @@ import static net.minecraftforge.common.util.ForgeDirection.UP; * Created by Brandon on 24/06/2014. */ public class TileTestBlock extends TileEntity implements IEnergyHandler { - public EnergyStorage energy = new EnergyStorage(100000000); - public int maxInput = 100000000; - public float modelRotation; - //Use a map for the beam to each target (Target, Beam) - private ParticleEnergyBeam beam = null; - private ParticleEnergyField ring = null; + public EnergyStorage energy = new EnergyStorage(100000000); + public int maxInput = 100000000; + public float modelRotation; + //Use a map for the beam to each target (Target, Beam) + private ParticleEnergyBeam beam = null; + private ParticleEnergyField ring = null; - @Override - public void updateEntity() { + @Override + public void updateEntity() { - //beam = DraconicEvolution.proxy.energyBeam(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 0.5, 4.5, 0.5, 100, true, beam); - //ring = DraconicEvolution.proxy.energyField(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, ClientEventHandler.elapsedTicks % 100, true, ring); + //beam = DraconicEvolution.proxy.energyBeam(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 0.5, 4.5, 0.5, 100, true, beam); + //ring = DraconicEvolution.proxy.energyField(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, ClientEventHandler.elapsedTicks % 100, true, ring); - if (worldObj.isRemote) return; - for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { - if (worldObj.getTileEntity(xCoord+d.offsetX, yCoord+d.offsetY, zCoord+d.offsetZ) instanceof IEnergyReceiver) ((IEnergyReceiver)worldObj.getTileEntity(xCoord+d.offsetX, yCoord+d.offsetY, zCoord+d.offsetZ)).receiveEnergy(d.getOpposite(), Integer.MAX_VALUE, false); - } + if (worldObj.isRemote) return; + for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { + if (worldObj.getTileEntity(xCoord + d.offsetX, yCoord + d.offsetY, zCoord + d.offsetZ) instanceof IEnergyReceiver) + ((IEnergyReceiver) worldObj.getTileEntity(xCoord + d.offsetX, yCoord + d.offsetY, zCoord + d.offsetZ)).receiveEnergy(d.getOpposite(), Integer.MAX_VALUE, false); + } // LogHelper.info(Integer.MAX_VALUE); - //if (1==1)return; + //if (1==1)return; // for (Field f : StatList.class.getDeclaredFields()) { // f.setAccessible(true); @@ -76,8 +77,7 @@ public class TileTestBlock extends TileEntity implements IEnergyHandler { // if (worldObj.isRemote) modelRotation += 0.5; - //LogHelper.info(modelCoreRotation); - + //LogHelper.info(modelCoreRotation); // int test = 4; @@ -92,71 +92,70 @@ public class TileTestBlock extends TileEntity implements IEnergyHandler { // this.energy.extractEnergy(((IEnergyHandler)tile).receiveEnergy(UP.getOpposite(), this.energy.extractEnergy(maxInput, true), false), false); // } // } - } + } - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - if(from != UP) - return 0;//this.energy.receiveEnergy(Math.min(maxInput, maxReceive), simulate); - else - return 0; - } + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + if (from != UP) return 0;//this.energy.receiveEnergy(Math.min(maxInput, maxReceive), simulate); + else return 0; + } - @Override - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {; - if (from == UP) - return 0;//return this.energy.extractEnergy(maxExtract, simulate); - else - return 0; - } + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { + ; + if (from == UP) return 0;//return this.energy.extractEnergy(maxExtract, simulate); + else return 0; + } - @Override - public int getEnergyStored(ForgeDirection from) { - return energy.getEnergyStored(); - } + @Override + public int getEnergyStored(ForgeDirection from) { + return energy.getEnergyStored(); + } - @Override - public int getMaxEnergyStored(ForgeDirection from) { - return energy.getMaxEnergyStored(); - } + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return energy.getMaxEnergyStored(); + } - @Override - public boolean canConnectEnergy(ForgeDirection from) { - return true; - } + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return true; + } - @Override - public AxisAlignedBB getRenderBoundingBox() { - return INFINITE_EXTENT_AABB; - } + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } - @Override - public Packet getDescriptionPacket(){ - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeToNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - @Override - public void readFromNBT(NBTTagCompound p_145839_1_) { - super.readFromNBT(p_145839_1_); - EntityPlayer player = null; - if (worldObj != null) player = worldObj.getClosestPlayer(xCoord, yCoord, zCoord, -1); - if (player != null) LogHelper.info("Read: "+Utills.getDistanceAtoB(player.posX, player.posY, player.posZ, xCoord, yCoord, zCoord)); - LogHelper.info(worldObj+" "+player); - } + @Override + public void readFromNBT(NBTTagCompound p_145839_1_) { + super.readFromNBT(p_145839_1_); + EntityPlayer player = null; + if (worldObj != null) player = worldObj.getClosestPlayer(xCoord, yCoord, zCoord, -1); + if (player != null) + LogHelper.info("Read: " + Utills.getDistanceAtoB(player.posX, player.posY, player.posZ, xCoord, yCoord, zCoord)); + LogHelper.info(worldObj + " " + player); + } - @Override - public void writeToNBT(NBTTagCompound p_145841_1_) { - super.writeToNBT(p_145841_1_); - EntityPlayer player = null; - if (worldObj != null) player = worldObj.getClosestPlayer(xCoord, yCoord, zCoord, -1); - if (player != null) LogHelper.info("Write: "+Utills.getDistanceAtoB(player.posX, player.posY, player.posZ, xCoord, yCoord, zCoord)); - } + @Override + public void writeToNBT(NBTTagCompound p_145841_1_) { + super.writeToNBT(p_145841_1_); + EntityPlayer player = null; + if (worldObj != null) player = worldObj.getClosestPlayer(xCoord, yCoord, zCoord, -1); + if (player != null) + LogHelper.info("Write: " + Utills.getDistanceAtoB(player.posX, player.posY, player.posZ, xCoord, yCoord, zCoord)); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileUpgradeModifier.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileUpgradeModifier.java index 0eeeacb2..69ec7e59 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileUpgradeModifier.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileUpgradeModifier.java @@ -13,168 +13,164 @@ import net.minecraft.tileentity.TileEntity; * Created by brandon3055 on 23/12/2015. */ public class TileUpgradeModifier extends TileEntity implements ISidedInventory { - ItemStack[] items = new ItemStack[1]; + ItemStack[] items = new ItemStack[1]; - public float rotation = 0; - public float rotationSpeed = 0; - private float targetSpeed = 0; + public float rotation = 0; + public float rotationSpeed = 0; + private float targetSpeed = 0; - //==============================================LOGIC=======================================================// + //==============================================LOGIC=======================================================// - @Override - public void updateEntity() { - if (items[0] != null) targetSpeed = 5F; - else targetSpeed = 0F; + @Override + public void updateEntity() { + if (items[0] != null) targetSpeed = 5F; + else targetSpeed = 0F; - if (rotationSpeed < targetSpeed) rotationSpeed += 0.05F; - else if (rotationSpeed > targetSpeed) rotationSpeed -= 0.05F; - if (targetSpeed == 0 && rotationSpeed < 0) rotationSpeed = 0; - rotation += rotationSpeed; - } + if (rotationSpeed < targetSpeed) rotationSpeed += 0.05F; + else if (rotationSpeed > targetSpeed) rotationSpeed -= 0.05F; + if (targetSpeed == 0 && rotationSpeed < 0) rotationSpeed = 0; + rotation += rotationSpeed; + } - //==========================================SYNCHRONIZATION==================================================// + //==========================================SYNCHRONIZATION==================================================// - @Override - public Packet getDescriptionPacket() { - NBTTagCompound tagCompound = new NBTTagCompound(); - this.writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + this.writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - //==============================================INVENTORY====================================================// + //==============================================INVENTORY====================================================// - @Override - public int getSizeInventory() { - return items.length; - } + @Override + public int getSizeInventory() { + return items.length; + } - @Override - public ItemStack getStackInSlot(int i) { - return items[i]; - } + @Override + public ItemStack getStackInSlot(int i) { + return items[i]; + } - @Override - public ItemStack decrStackSize(int i, int count) { - ItemStack itemstack = getStackInSlot(i); + @Override + public ItemStack decrStackSize(int i, int count) { + ItemStack itemstack = getStackInSlot(i); - if (itemstack != null) { - if (itemstack.stackSize <= count) { - setInventorySlotContents(i, null); - } else { - itemstack = itemstack.splitStack(count); - if (itemstack.stackSize == 0) { - setInventorySlotContents(i, null); - } - } - } - return itemstack; - } + if (itemstack != null) { + if (itemstack.stackSize <= count) { + setInventorySlotContents(i, null); + } else { + itemstack = itemstack.splitStack(count); + if (itemstack.stackSize == 0) { + setInventorySlotContents(i, null); + } + } + } + return itemstack; + } - @Override - public ItemStack getStackInSlotOnClosing(int i) { - ItemStack item = getStackInSlot(i); - if (item != null) setInventorySlotContents(i, null); - return item; - } + @Override + public ItemStack getStackInSlotOnClosing(int i) { + ItemStack item = getStackInSlot(i); + if (item != null) setInventorySlotContents(i, null); + return item; + } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - items[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); - } - } + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + items[i] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } - @Override - public String getInventoryName() { - return ""; - } + @Override + public String getInventoryName() { + return ""; + } - @Override - public boolean hasCustomInventoryName() { - return false; - } + @Override + public boolean hasCustomInventoryName() { + return false; + } - @Override - public int getInventoryStackLimit() { - return 64; - } + @Override + public int getInventoryStackLimit() { + return 64; + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - if (worldObj == null) - { - return true; - } - if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) - { - return false; - } - return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + if (worldObj == null) { + return true; + } + if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { + return false; + } + return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; + } - @Override - public void openInventory() {} + @Override + public void openInventory() { + } - @Override - public void closeInventory() {} + @Override + public void closeInventory() { + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } - @Override - public int[] getAccessibleSlotsFromSide(int var1) { - return new int[] {0}; - } + @Override + public int[] getAccessibleSlotsFromSide(int var1) { + return new int[]{0}; + } - @Override - public boolean canInsertItem(int slot, ItemStack item, int side) { - return true; - } + @Override + public boolean canInsertItem(int slot, ItemStack item, int side) { + return true; + } - @Override - public boolean canExtractItem(int slot, ItemStack item, int side) { - return true; - } + @Override + public boolean canExtractItem(int slot, ItemStack item, int side) { + return true; + } - //===========================================================================================================// + //===========================================================================================================// - @Override - public void writeToNBT(NBTTagCompound compound) - { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void writeToNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) - { - tag[i] = new NBTTagCompound(); + for (int i = 0; i < items.length; i++) { + tag[i] = new NBTTagCompound(); - if (items[i] != null) - { - tag[i] = items[i].writeToNBT(tag[i]); - } + if (items[i] != null) { + tag[i] = items[i].writeToNBT(tag[i]); + } - compound.setTag("Item" + i, tag[i]); - } - super.writeToNBT(compound); - } + compound.setTag("Item" + i, tag[i]); + } + super.writeToNBT(compound); + } - @Override - public void readFromNBT(NBTTagCompound compound) - { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void readFromNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) - { - tag[i] = compound.getCompoundTag("Item" + i); - items[i] = ItemStack.loadItemStackFromNBT(tag[i]); - } - super.readFromNBT(compound); - } + for (int i = 0; i < items.length; i++) { + tag[i] = compound.getCompoundTag("Item" + i); + items[i] = ItemStack.loadItemStackFromNBT(tag[i]); + } + super.readFromNBT(compound); + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileWeatherController.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileWeatherController.java index 64f00aa0..94aaddf2 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileWeatherController.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileWeatherController.java @@ -13,310 +13,253 @@ import net.minecraft.world.storage.WorldInfo; import com.brandon3055.draconicevolution.DraconicEvolution; public class TileWeatherController extends TileEntity implements IInventory { - int tick = 0; - boolean running = false; - public boolean lastTickInput = false; - public int mode = 0; - private final static boolean debug = DraconicEvolution.debug; + int tick = 0; + boolean running = false; + public boolean lastTickInput = false; + public int mode = 0; + private final static boolean debug = DraconicEvolution.debug; - private ItemStack[] items; - public int charges; + private ItemStack[] items; + public int charges; - public TileWeatherController() { - items = new ItemStack[1]; - } + public TileWeatherController() { + items = new ItemStack[1]; + } - @Override - public void updateEntity() - { - if (charges == 0 && !worldObj.isRemote) - reload(); + @Override + public void updateEntity() { + if (charges == 0 && !worldObj.isRemote) reload(); - WorldInfo worldinfo = worldObj.getWorldInfo(); - toggleDownfall(worldinfo); - } + WorldInfo worldinfo = worldObj.getWorldInfo(); + toggleDownfall(worldinfo); + } - public void activate() - { - WorldInfo worldinfo = worldObj.getWorldInfo(); - if (!running && charges > 0) - { - if (mode == 0 && worldinfo.isRaining()) - running = true; - else if (mode == 1 && !worldinfo.isRaining()) - running = true; - else if (mode == 2 && !worldinfo.isRaining()) - running = true; - } - } + public void activate() { + WorldInfo worldinfo = worldObj.getWorldInfo(); + if (!running && charges > 0) { + if (mode == 0 && worldinfo.isRaining()) running = true; + else if (mode == 1 && !worldinfo.isRaining()) running = true; + else if (mode == 2 && !worldinfo.isRaining()) running = true; + } + } - private void reload() - { - ItemStack fuel = getStackInSlot(0); + private void reload() { + ItemStack fuel = getStackInSlot(0); - if (charges == 0 && fuel != null) - { + if (charges == 0 && fuel != null) { - if (fuel.stackSize > 0 && fuel.isItemEqual(new ItemStack(Items.emerald))) - { - addCharge(10); + if (fuel.stackSize > 0 && fuel.isItemEqual(new ItemStack(Items.emerald))) { + addCharge(10); - } - } - } + } + } + } - private void toggleDownfall(final WorldInfo worldinfo) - { - if (running) - { + private void toggleDownfall(final WorldInfo worldinfo) { + if (running) { - if (tick == 1 && !worldObj.isRemote) - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - if (tick < 70 && worldObj.isRemote) - { - worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, 0D, 3D, 0D); - worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, 0D, 5D, 0D); - worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1, zCoord + 0.5, 0D, 1D, 0D); - worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1, zCoord + 0.5, 0D, 2D, 0D); - worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1, zCoord + 0.5, 0D, 1D, 0D); - worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, 0D, -0.3D, 0D); - worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, 0D, -0.3D, 0D); - worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, 0D, -0.3D, 0D); + if (tick == 1 && !worldObj.isRemote) worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + if (tick < 70 && worldObj.isRemote) { + worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, 0D, 3D, 0D); + worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, 0D, 5D, 0D); + worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1, zCoord + 0.5, 0D, 1D, 0D); + worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1, zCoord + 0.5, 0D, 2D, 0D); + worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1, zCoord + 0.5, 0D, 1D, 0D); + worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, 0D, -0.3D, 0D); + worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, 0D, -0.3D, 0D); + worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, 0D, -0.3D, 0D); - worldObj.spawnParticle("flame", xCoord + 0.2, yCoord + 1, zCoord + 0.8, (worldObj.rand.nextFloat() - 0.5) * 1.5, 1.7D, (worldObj.rand.nextFloat() - 0.5) * 1.5); - worldObj.spawnParticle("flame", xCoord + 0.8, yCoord + 1, zCoord + 0.8, (worldObj.rand.nextFloat() - 0.5) * 1.5, 1.7D, (worldObj.rand.nextFloat() - 0.5) * 1.5); - worldObj.spawnParticle("flame", xCoord + 0.2, yCoord + 1, zCoord + 0.2, (worldObj.rand.nextFloat() - 0.5) * 1.5, 1.7D, (worldObj.rand.nextFloat() - 0.5) * 1.5); - worldObj.spawnParticle("flame", xCoord + 0.8, yCoord + 1, zCoord + 0.2, (worldObj.rand.nextFloat() - 0.5) * 1.5, 1.7D, (worldObj.rand.nextFloat() - 0.5) * 1.5); - worldObj.playSound(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "mob.ghast.fireball", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F, false); + worldObj.spawnParticle("flame", xCoord + 0.2, yCoord + 1, zCoord + 0.8, (worldObj.rand.nextFloat() - 0.5) * 1.5, 1.7D, (worldObj.rand.nextFloat() - 0.5) * 1.5); + worldObj.spawnParticle("flame", xCoord + 0.8, yCoord + 1, zCoord + 0.8, (worldObj.rand.nextFloat() - 0.5) * 1.5, 1.7D, (worldObj.rand.nextFloat() - 0.5) * 1.5); + worldObj.spawnParticle("flame", xCoord + 0.2, yCoord + 1, zCoord + 0.2, (worldObj.rand.nextFloat() - 0.5) * 1.5, 1.7D, (worldObj.rand.nextFloat() - 0.5) * 1.5); + worldObj.spawnParticle("flame", xCoord + 0.8, yCoord + 1, zCoord + 0.2, (worldObj.rand.nextFloat() - 0.5) * 1.5, 1.7D, (worldObj.rand.nextFloat() - 0.5) * 1.5); + worldObj.playSound(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "mob.ghast.fireball", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F, false); - } - if (tick > 80 && tick < 90) - { - if (!worldObj.isRemote) - { - if (mode == 0) - worldinfo.setRaining(false); - else if (mode == 1) - worldinfo.setRaining(true); - else if (mode == 2) - { - worldinfo.setRaining(true); - worldinfo.setThundering(true); - } - } - worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:boom", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F); - } - if (tick > 110 && worldObj.isRemote) - { + } + if (tick > 80 && tick < 90) { + if (!worldObj.isRemote) { + if (mode == 0) worldinfo.setRaining(false); + else if (mode == 1) worldinfo.setRaining(true); + else if (mode == 2) { + worldinfo.setRaining(true); + worldinfo.setThundering(true); + } + } + worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:boom", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + if (tick > 110 && worldObj.isRemote) { - worldObj.playSound(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "random.fizz", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F, false); - worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 0, zCoord + 0, 0D, 0D, 0D); - worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 0, zCoord + 1, 0D, 0D, 0D); - worldObj.spawnParticle("explode", xCoord + 0, yCoord + 0, zCoord + 0.5, 0D, 0D, 0D); - worldObj.spawnParticle("explode", xCoord + 1, yCoord + 0, zCoord + 0.5, 0D, 0D, 0D); + worldObj.playSound(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "random.fizz", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F, false); + worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 0, zCoord + 0, 0D, 0D, 0D); + worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 0, zCoord + 1, 0D, 0D, 0D); + worldObj.spawnParticle("explode", xCoord + 0, yCoord + 0, zCoord + 0.5, 0D, 0D, 0D); + worldObj.spawnParticle("explode", xCoord + 1, yCoord + 0, zCoord + 0.5, 0D, 0D, 0D); - } - if (tick > 130) - { - tick = 0; - running = false; - if (!worldObj.isRemote) - useCharge(); - } - tick++; - } + } + if (tick > 130) { + tick = 0; + running = false; + if (!worldObj.isRemote) useCharge(); + } + tick++; + } - } + } - private void addCharge(int count) - { - if (!worldObj.isRemote) - { - charges = 10; - decrStackSize(0, 1); - } - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } + private void addCharge(int count) { + if (!worldObj.isRemote) { + charges = 10; + decrStackSize(0, 1); + } + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } - private void useCharge() - { - if (!worldObj.isRemote) - charges--; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } + private void useCharge() { + if (!worldObj.isRemote) charges--; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } - @Override - public Packet getDescriptionPacket() - { - NBTTagCompound tagCompound = new NBTTagCompound(); - this.writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + this.writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) - { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - //==============================================INVENTORY====================================================// + //==============================================INVENTORY====================================================// - @Override - public int getSizeInventory() - { - return items.length; - } + @Override + public int getSizeInventory() { + return items.length; + } - @Override - public ItemStack getStackInSlot(int i) - { - return items[i]; - } + @Override + public ItemStack getStackInSlot(int i) { + return items[i]; + } - @Override - public ItemStack decrStackSize(int i, int count) - { - ItemStack itemstack = getStackInSlot(i); + @Override + public ItemStack decrStackSize(int i, int count) { + ItemStack itemstack = getStackInSlot(i); - if (itemstack != null) - { - if (itemstack.stackSize <= count) - { - setInventorySlotContents(i, null); - } else - { - itemstack = itemstack.splitStack(count); - if (itemstack.stackSize == 0) - { - setInventorySlotContents(i, null); - } - } - } - return itemstack; - } + if (itemstack != null) { + if (itemstack.stackSize <= count) { + setInventorySlotContents(i, null); + } else { + itemstack = itemstack.splitStack(count); + if (itemstack.stackSize == 0) { + setInventorySlotContents(i, null); + } + } + } + return itemstack; + } - @Override - public ItemStack getStackInSlotOnClosing(int i) - { - ItemStack item = getStackInSlot(i); - if (item != null) - setInventorySlotContents(i, null); - return item; - } + @Override + public ItemStack getStackInSlotOnClosing(int i) { + ItemStack item = getStackInSlot(i); + if (item != null) setInventorySlotContents(i, null); + return item; + } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) - { - items[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - { - itemstack.stackSize = getInventoryStackLimit(); - } - } + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + items[i] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } - @Override - public String getInventoryName() - { - return ""; - } + @Override + public String getInventoryName() { + return ""; + } - @Override - public boolean hasCustomInventoryName() - { - return false; - } + @Override + public boolean hasCustomInventoryName() { + return false; + } - @Override - public int getInventoryStackLimit() - { - return 64; - } + @Override + public int getInventoryStackLimit() { + return 64; + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) - { - if (worldObj == null) - { - return true; - } - if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) - { - return false; - } - return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; - } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + if (worldObj == null) { + return true; + } + if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { + return false; + } + return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; + } - @Override - public void openInventory() - { - } + @Override + public void openInventory() { + } - @Override - public void closeInventory() - { - } + @Override + public void closeInventory() { + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) - { - return itemstack.isItemEqual(new ItemStack(Items.emerald)); - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return itemstack.isItemEqual(new ItemStack(Items.emerald)); + } - //############################################################################################################// - @Override - public void writeToNBT(NBTTagCompound compound) - { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + //############################################################################################################// + @Override + public void writeToNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) - { - tag[i] = new NBTTagCompound(); + for (int i = 0; i < items.length; i++) { + tag[i] = new NBTTagCompound(); - if (items[i] != null) - { - tag[i] = items[i].writeToNBT(tag[i]); - } + if (items[i] != null) { + tag[i] = items[i].writeToNBT(tag[i]); + } - compound.setTag("Item" + i, tag[i]); - } + compound.setTag("Item" + i, tag[i]); + } - compound.setInteger("Tick", tick); - compound.setShort("Charges", (short) charges); - compound.setBoolean("Running", running); - compound.setShort("Mode", (short) mode); + compound.setInteger("Tick", tick); + compound.setShort("Charges", (short) charges); + compound.setBoolean("Running", running); + compound.setShort("Mode", (short) mode); - super.writeToNBT(compound); - } + super.writeToNBT(compound); + } - @Override - public void readFromNBT(NBTTagCompound compound) - { - NBTTagCompound[] tag = new NBTTagCompound[items.length]; + @Override + public void readFromNBT(NBTTagCompound compound) { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) - { - tag[i] = compound.getCompoundTag("Item" + i); - items[i] = ItemStack.loadItemStackFromNBT(tag[i]); - } + for (int i = 0; i < items.length; i++) { + tag[i] = compound.getCompoundTag("Item" + i); + items[i] = ItemStack.loadItemStackFromNBT(tag[i]); + } - tick = compound.getInteger("Tick"); - charges = compound.getShort("Charges"); - running = compound.getBoolean("Running"); - mode = compound.getShort("Mode"); + tick = compound.getInteger("Tick"); + charges = compound.getShort("Charges"); + running = compound.getBoolean("Running"); + mode = compound.getShort("Mode"); - super.readFromNBT(compound); - } + super.readFromNBT(compound); + } - public void reciveButtonEvent(byte buttonId) - { - if (buttonId == 0) - { - if (mode < 2) - mode++; - else - mode = 0; - } - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } + public void reciveButtonEvent(byte buttonId) { + if (buttonId == 0) { + if (mode < 2) mode++; + else mode = 0; + } + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/IRemoteEnergyHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/IRemoteEnergyHandler.java index a9b50009..44b4e63f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/IRemoteEnergyHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/IRemoteEnergyHandler.java @@ -8,25 +8,26 @@ import net.minecraft.entity.player.EntityPlayer; * Created by Brandon on 10/02/2015. */ public interface IRemoteEnergyHandler extends IEnergyHandler { - //todo add method for linking - /** - * @param player The player binding the tiles - * @param x the xCoord of the other tile - * @param y the yCoord of the other tile - * @param z the zCoord of the other tile - * @param callOtherEnd whether or not to call handleBinding in the other tile - * */ - boolean handleBinding(EntityPlayer player, int x, int y, int z, boolean callOtherEnd); + //todo add method for linking - double getCapacity(); + /** + * @param player The player binding the tiles + * @param x the xCoord of the other tile + * @param y the yCoord of the other tile + * @param z the zCoord of the other tile + * @param callOtherEnd whether or not to call handleBinding in the other tile + */ + boolean handleBinding(EntityPlayer player, int x, int y, int z, boolean callOtherEnd); - double getBeamX(); + double getCapacity(); - double getBeamY(); + double getBeamX(); - double getBeamZ(); + double getBeamY(); - EnergyStorage getStorage(); + double getBeamZ(); - int getMaxConnections(); + EnergyStorage getStorage(); + + int getMaxConnections(); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/LinkedReceiver.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/LinkedReceiver.java index 20556f7a..464d29ef 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/LinkedReceiver.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/LinkedReceiver.java @@ -12,78 +12,77 @@ import net.minecraftforge.common.util.ForgeDirection; */ public class LinkedReceiver { - public int xCoord; - public int yCoord; - public int zCoord; - public int connectionSide; - public int particleEnergyCounter = 0; - public Block target = null; - private double tBBXMin = -1; - private double tBBXMax = -1; - private double tBBYMin = -1; - private double tBBYMax = -1; - private double tBBZMin = -1; - private double tBBZMax = -1; + public int xCoord; + public int yCoord; + public int zCoord; + public int connectionSide; + public int particleEnergyCounter = 0; + public Block target = null; + private double tBBXMin = -1; + private double tBBXMax = -1; + private double tBBYMin = -1; + private double tBBYMax = -1; + private double tBBZMin = -1; + private double tBBZMax = -1; - public LinkedReceiver(){} + public LinkedReceiver() { + } - public LinkedReceiver(int xCoord, int yCoord, int zCoord, int connectionSide) - { - this.xCoord = xCoord; - this.yCoord = yCoord; - this.zCoord = zCoord; - this.connectionSide = connectionSide; - } + public LinkedReceiver(int xCoord, int yCoord, int zCoord, int connectionSide) { + this.xCoord = xCoord; + this.yCoord = yCoord; + this.zCoord = zCoord; + this.connectionSide = connectionSide; + } - public boolean isStillValid(World world) - { - TileEntity tile = world.getTileEntity(xCoord, yCoord, zCoord); - return tile instanceof IEnergyReceiver && ((IEnergyReceiver) tile).canConnectEnergy(ForgeDirection.getOrientation(connectionSide)); - } + public boolean isStillValid(World world) { + TileEntity tile = world.getTileEntity(xCoord, yCoord, zCoord); + return tile instanceof IEnergyReceiver && ((IEnergyReceiver) tile).canConnectEnergy(ForgeDirection.getOrientation(connectionSide)); + } - public IEnergyReceiver getReceiver(World world) - { - return isStillValid(world) ? (IEnergyReceiver) world.getTileEntity(xCoord, yCoord, zCoord) : null; - } + public IEnergyReceiver getReceiver(World world) { + return isStillValid(world) ? (IEnergyReceiver) world.getTileEntity(xCoord, yCoord, zCoord) : null; + } - public int receiveEnergy(World world, int maxReceive, boolean simulate) { - if (isStillValid(world)) return getReceiver(world).receiveEnergy(ForgeDirection.getOrientation(connectionSide), maxReceive, simulate); - else return 0; - } + public int receiveEnergy(World world, int maxReceive, boolean simulate) { + if (isStillValid(world)) + return getReceiver(world).receiveEnergy(ForgeDirection.getOrientation(connectionSide), maxReceive, simulate); + else return 0; + } - public int getEnergyStored(World world) { - if (isStillValid(world)) return getReceiver(world).getEnergyStored(ForgeDirection.getOrientation(connectionSide)); - else return 0; - } + public int getEnergyStored(World world) { + if (isStillValid(world)) + return getReceiver(world).getEnergyStored(ForgeDirection.getOrientation(connectionSide)); + else return 0; + } - public int getMaxEnergyStored(World world) { - if (isStillValid(world)) return getReceiver(world).getMaxEnergyStored(ForgeDirection.getOrientation(connectionSide)); - else return 0; - } + public int getMaxEnergyStored(World world) { + if (isStillValid(world)) + return getReceiver(world).getMaxEnergyStored(ForgeDirection.getOrientation(connectionSide)); + else return 0; + } - public void updateTarget(World world) { - target = world.getBlock(xCoord, yCoord, zCoord); - tBBXMin = target.getBlockBoundsMinX(); - tBBXMax = target.getBlockBoundsMinX(); - tBBYMin = target.getBlockBoundsMinX(); - tBBYMax = target.getBlockBoundsMinX(); - tBBZMin = target.getBlockBoundsMinX(); - tBBZMax = target.getBlockBoundsMinX(); - } + public void updateTarget(World world) { + target = world.getBlock(xCoord, yCoord, zCoord); + tBBXMin = target.getBlockBoundsMinX(); + tBBXMax = target.getBlockBoundsMinX(); + tBBYMin = target.getBlockBoundsMinX(); + tBBYMax = target.getBlockBoundsMinX(); + tBBZMin = target.getBlockBoundsMinX(); + tBBZMax = target.getBlockBoundsMinX(); + } - public void writeToNBT(NBTTagCompound compound, String tag) - { - compound.setInteger(tag + "_XCoord", xCoord); - compound.setInteger(tag + "_YCoord", yCoord); - compound.setInteger(tag + "_ZCoord", zCoord); - compound.setInteger(tag + "_Side", connectionSide); - } + public void writeToNBT(NBTTagCompound compound, String tag) { + compound.setInteger(tag + "_XCoord", xCoord); + compound.setInteger(tag + "_YCoord", yCoord); + compound.setInteger(tag + "_ZCoord", zCoord); + compound.setInteger(tag + "_Side", connectionSide); + } - public void readFromNBT(NBTTagCompound compound, String tag) - { - xCoord = compound.getInteger(tag + "_XCoord"); - yCoord = compound.getInteger(tag + "_YCoord"); - zCoord = compound.getInteger(tag + "_ZCoord"); - connectionSide = compound.getInteger(tag + "_Side"); - } + public void readFromNBT(NBTTagCompound compound, String tag) { + xCoord = compound.getInteger(tag + "_XCoord"); + yCoord = compound.getInteger(tag + "_YCoord"); + zCoord = compound.getInteger(tag + "_ZCoord"); + connectionSide = compound.getInteger(tag + "_Side"); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/TileEnergyRelay.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/TileEnergyRelay.java index 58fab98b..33003f8c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/TileEnergyRelay.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/TileEnergyRelay.java @@ -13,82 +13,82 @@ public class TileEnergyRelay extends TileRemoteEnergyBase { @SideOnly(Side.CLIENT) private ParticleEnergyField ring; - public TileEnergyRelay(){} + public TileEnergyRelay() { + } - public TileEnergyRelay(int powerTier){ - this.powerTier = powerTier; - this.updateStorage(); - } + public TileEnergyRelay(int powerTier) { + this.powerTier = powerTier; + this.updateStorage(); + } - @Override - public int getCap() { - return 50000 + (powerTier * 4500000); - } + @Override + public int getCap() { + return 50000 + (powerTier * 4500000); + } - @Override - public int getRec() { - return 50000 + (powerTier * 4500000); - } + @Override + public int getRec() { + return 50000 + (powerTier * 4500000); + } - @Override - public int getExt() { - return 50000 + (powerTier * 4500000); - } + @Override + public int getExt() { + return 50000 + (powerTier * 4500000); + } - @Override - public void updateEntity() { - super.updateEntity(); + @Override + public void updateEntity() { + super.updateEntity(); - if (worldObj.isRemote) - { - ring = DraconicEvolution.proxy.energyField(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 0, powerTier == 1, ring, inView > 0); - return; - } - } + if (worldObj.isRemote) { + ring = DraconicEvolution.proxy.energyField(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 0, powerTier == 1, ring, inView > 0); + return; + } + } + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + } - @Override - public void writeToNBT(NBTTagCompound compound) { - super.writeToNBT(compound); - } - - @Override - public void readFromNBT(NBTTagCompound compound) { - super.readFromNBT(compound); - } + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + } // @Override // public double getCapacity() { // return ((double) getEnergyStored(ForgeDirection.UNKNOWN) / (double) getMaxEnergyStored(ForgeDirection.UNKNOWN)) * 100D; // } - /**Calculates the energy flow based on the local buffer - * and the remote buffer - *return double between 0 to 100*/ - public double getFlow(double localCap, double remoteCap) - { - return Math.max(0, Math.min(100, (localCap - remoteCap) * 100D/*Flow Multiplier*/)); - } + /** + * Calculates the energy flow based on the local buffer + * and the remote buffer + * return double between 0 to 100 + */ + public double getFlow(double localCap, double remoteCap) { + return Math.max(0, Math.min(100, (localCap - remoteCap) * 100D/*Flow Multiplier*/)); + } - @Override - public double getBeamX() { - return xCoord + 0.5D; - } + @Override + public double getBeamX() { + return xCoord + 0.5D; + } - @Override - public double getBeamY() { - return yCoord + 0.5D; - } + @Override + public double getBeamY() { + return yCoord + 0.5D; + } - @Override - public double getBeamZ() { - return zCoord + 0.5D; - } + @Override + public double getBeamZ() { + return zCoord + 0.5D; + } - @Override - public int getMaxConnections() { - return powerTier == 0 ? 10 : 20; - } + @Override + public int getMaxConnections() { + return powerTier == 0 ? 10 : 20; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/TileEnergyTransceiver.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/TileEnergyTransceiver.java index b8460d70..e4d312c3 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/TileEnergyTransceiver.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/TileEnergyTransceiver.java @@ -16,154 +16,150 @@ import net.minecraftforge.common.util.ForgeDirection; /** * Created by Brandon on 16/02/2015. */ -public class TileEnergyTransceiver extends TileRemoteEnergyBase{ +public class TileEnergyTransceiver extends TileRemoteEnergyBase { - public int facing = 0;//0=up, 1=down, 3=north, 2=south, 4=east, 5=west - private boolean input = false; - public boolean transferBoost = false; + public int facing = 0;//0=up, 1=down, 3=north, 2=south, 4=east, 5=west + private boolean input = false; + public boolean transferBoost = false; @SideOnly(Side.CLIENT) private ParticleEnergyField particle; - public TileEnergyTransceiver() {} + public TileEnergyTransceiver() { + } - public TileEnergyTransceiver(int powerTier) - { - this.powerTier = powerTier; - this.updateStorage(); - } + public TileEnergyTransceiver(int powerTier) { + this.powerTier = powerTier; + this.updateStorage(); + } - @Override - public void updateEntity() { - super.updateEntity(); + @Override + public void updateEntity() { + super.updateEntity(); - if (!worldObj.isRemote) - { - ForgeDirection direction = ForgeDirection.getOrientation(facing).getOpposite(); - TileEntity adjacentTile = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ); - if (!input && adjacentTile instanceof IEnergyReceiver) - { - IEnergyReceiver handler = (IEnergyReceiver) adjacentTile; - storage.extractEnergy(handler.receiveEnergy(direction.getOpposite(), storage.extractEnergy(storage.getMaxExtract(), true), false), false); - if (transferBoost) - { - for (int i = 0; i < 4; i++) storage.extractEnergy(handler.receiveEnergy(direction.getOpposite(), storage.extractEnergy(storage.getMaxExtract(), true), false), false); - } - } - else if (input && adjacentTile instanceof IEnergyProvider) - { - IEnergyProvider handler = (IEnergyProvider) adjacentTile; - if (transferBoost) - { - for (int i = 0; i < 4; i++) storage.receiveEnergy(handler.extractEnergy(direction.getOpposite(), storage.receiveEnergy(storage.getMaxExtract(), true), false), false); - } - } - } + if (!worldObj.isRemote) { + ForgeDirection direction = ForgeDirection.getOrientation(facing).getOpposite(); + TileEntity adjacentTile = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ); + if (!input && adjacentTile instanceof IEnergyReceiver) { + IEnergyReceiver handler = (IEnergyReceiver) adjacentTile; + storage.extractEnergy(handler.receiveEnergy(direction.getOpposite(), storage.extractEnergy(storage.getMaxExtract(), true), false), false); + if (transferBoost) { + for (int i = 0; i < 4; i++) + storage.extractEnergy(handler.receiveEnergy(direction.getOpposite(), storage.extractEnergy(storage.getMaxExtract(), true), false), false); + } + } else if (input && adjacentTile instanceof IEnergyProvider) { + IEnergyProvider handler = (IEnergyProvider) adjacentTile; + if (transferBoost) { + for (int i = 0; i < 4; i++) + storage.receiveEnergy(handler.extractEnergy(direction.getOpposite(), storage.receiveEnergy(storage.getMaxExtract(), true), false), false); + } + } + } - if (worldObj.isRemote) particle = DraconicEvolution.proxy.energyField(worldObj, getBeamX(), getBeamY(), getBeamZ(), 1, powerTier == 1, particle, inView > 0); - } + if (worldObj.isRemote) + particle = DraconicEvolution.proxy.energyField(worldObj, getBeamX(), getBeamY(), getBeamZ(), 1, powerTier == 1, particle, inView > 0); + } - @Override - public boolean handleOther(EntityPlayer player, ItemStack wrench) { - String mode = Wrench.getMode(wrench); + @Override + public boolean handleOther(EntityPlayer player, ItemStack wrench) { + String mode = Wrench.getMode(wrench); - if (mode.equals(Wrench.MODE_SWITCH)) - { - if (powerTier == 0) - { - input = !input; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } - else - { - if (!transferBoost) transferBoost = true; - else - { - input = !input; - transferBoost = false; - } - } - } + if (mode.equals(Wrench.MODE_SWITCH)) { + if (powerTier == 0) { + input = !input; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } else { + if (!transferBoost) transferBoost = true; + else { + input = !input; + transferBoost = false; + } + } + } - return true; - } + return true; + } - public boolean getInput() { return input; } + public boolean getInput() { + return input; + } - public void setInput(boolean input) { this.input = input;} + public void setInput(boolean input) { + this.input = input; + } - @Override - public double getBeamX() { - return xCoord + 0.5; - } + @Override + public double getBeamX() { + return xCoord + 0.5; + } - @Override - public double getBeamY() { - return yCoord + 0.5; - } + @Override + public double getBeamY() { + return yCoord + 0.5; + } - @Override - public double getBeamZ() { - return zCoord + 0.5; - } + @Override + public double getBeamZ() { + return zCoord + 0.5; + } - @Override - public int getCap() { - return powerTier == 0 ? 50000 : 10000000; - } + @Override + public int getCap() { + return powerTier == 0 ? 50000 : 10000000; + } - @Override - public int getRec() { - return powerTier == 0 ? 50000 : 10000000; - } + @Override + public int getRec() { + return powerTier == 0 ? 50000 : 10000000; + } - @Override - public int getExt() { - return powerTier == 0 ? 50000 : 10000000; - } + @Override + public int getExt() { + return powerTier == 0 ? 50000 : 10000000; + } - @Override - public void writeToNBT(NBTTagCompound compound) { - super.writeToNBT(compound); - compound.setInteger("Facing", facing); - compound.setBoolean("Input", input); - compound.setBoolean("TransferBoost", transferBoost); - } + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setInteger("Facing", facing); + compound.setBoolean("Input", input); + compound.setBoolean("TransferBoost", transferBoost); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - super.readFromNBT(compound); - facing = compound.getInteger("Facing"); - input = compound.getBoolean("Input"); - transferBoost = compound.getBoolean("TransferBoost"); - } + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + facing = compound.getInteger("Facing"); + input = compound.getBoolean("Input"); + transferBoost = compound.getBoolean("TransferBoost"); + } - @Override - public boolean canConnectEnergy(ForgeDirection from) { - return from == ForgeDirection.getOrientation(facing).getOpposite(); - } + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return from == ForgeDirection.getOrientation(facing).getOpposite(); + } - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - return from == ForgeDirection.getOrientation(facing).getOpposite() && input ? storage.receiveEnergy(maxReceive, simulate) : 0; - } + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + return from == ForgeDirection.getOrientation(facing).getOpposite() && input ? storage.receiveEnergy(maxReceive, simulate) : 0; + } - @Override - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { - return from == ForgeDirection.getOrientation(facing).getOpposite() && !input ? storage.extractEnergy(maxExtract, simulate) : 0; - } + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { + return from == ForgeDirection.getOrientation(facing).getOpposite() && !input ? storage.extractEnergy(maxExtract, simulate) : 0; + } - @Override - public int getEnergyStored(ForgeDirection from) { - return storage.getEnergyStored(); - } + @Override + public int getEnergyStored(ForgeDirection from) { + return storage.getEnergyStored(); + } - @Override - public int getMaxEnergyStored(ForgeDirection from) { - return storage.getMaxEnergyStored(); - } + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return storage.getMaxEnergyStored(); + } - @Override - public int getMaxConnections() { - return powerTier == 0 ? 2 : 4; - } + @Override + public int getMaxConnections() { + return powerTier == 0 ? 2 : 4; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/TileRemoteEnergyBase.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/TileRemoteEnergyBase.java index d28710c3..61f23455 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/TileRemoteEnergyBase.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/TileRemoteEnergyBase.java @@ -30,44 +30,44 @@ import java.util.List; */ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRemoteEnergyHandler {//todo optimize (add cutoff, explore possible cach optimization) - /**The tier of the relay (0-1)*/ - protected int powerTier; - protected EnergyStorage storage = new EnergyStorage(0); - public List linkedDevices = new ArrayList(); - protected int lastTickEnergy; - private int tick = 0; + /** + * The tier of the relay (0-1) + */ + protected int powerTier; + protected EnergyStorage storage = new EnergyStorage(0); + public List linkedDevices = new ArrayList(); + protected int lastTickEnergy; + private int tick = 0; - public byte inView = 0; + public byte inView = 0; - public void updateStorage() - { - storage.setCapacity(getCap()); - storage.setMaxExtract(getExt()); - storage.setMaxReceive(getRec()); - } + public void updateStorage() { + storage.setCapacity(getCap()); + storage.setMaxExtract(getExt()); + storage.setMaxReceive(getRec()); + } - public abstract int getCap(); + public abstract int getCap(); - public abstract int getRec(); + public abstract int getRec(); - public abstract int getExt(); + public abstract int getExt(); - @Override - public void updateEntity() { - tick++; - //worldObj.theProfiler.startSection("DE REB"); - updateLinkedDevices(); - if (linkedDevices.size() == 0) detectAndSendChanges(-1); + @Override + public void updateEntity() { + tick++; + //worldObj.theProfiler.startSection("DE REB"); + updateLinkedDevices(); + if (linkedDevices.size() == 0) detectAndSendChanges(-1); - if (worldObj.isRemote && inView > 0) --inView; - //worldObj.theProfiler.endSection(); - } + if (worldObj.isRemote && inView > 0) --inView; + //worldObj.theProfiler.endSection(); + } - //**********Distribution Logic********** + //**********Distribution Logic********** - private void updateLinkedDevices() - { - boolean inView = false; + private void updateLinkedDevices() { + boolean inView = false; // if (worldObj.isRemote) // { // MovingObjectPosition mop = Minecraft.getMinecraft().thePlayer.rayTrace(5, 0); @@ -75,346 +75,309 @@ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRe // } - if (inView)LogHelper.info("######Start#######"); + if (inView) LogHelper.info("######Start#######"); - for (LinkedEnergyDevice device : linkedDevices) - { - if (!device.isValid(worldObj)) { - if (worldObj.getChunkFromBlockCoords(device.xCoord, device.zCoord).isChunkLoaded) - { - linkedDevices.remove(device); - updateLinkedDevices(); - return; - } - else - { - continue; - } - } + for (LinkedEnergyDevice device : linkedDevices) { + if (!device.isValid(worldObj)) { + if (worldObj.getChunkFromBlockCoords(device.xCoord, device.zCoord).isChunkLoaded) { + linkedDevices.remove(device); + updateLinkedDevices(); + return; + } else { + continue; + } + } - IRemoteEnergyHandler remoteTile = device.getEnergyTile(worldObj); + IRemoteEnergyHandler remoteTile = device.getEnergyTile(worldObj); - if (worldObj.isRemote) - { - int rType = 0; - if (this instanceof TileEnergyRelay || this instanceof TileWirelessEnergyTransceiver) - { - if (remoteTile instanceof TileEnergyTransceiver) rType = 2; - else rType = 3; - } - else if (this instanceof TileEnergyTransceiver) - { - if (remoteTile instanceof TileEnergyRelay || remoteTile instanceof TileWirelessEnergyTransceiver) rType = 1; - else rType = 0; - } - if (inView) LogHelper.info(device.energyFlow); - device.beam = DraconicEvolution.proxy.energyBeam(worldObj, getBeamX(), getBeamY(), getBeamZ(), remoteTile.getBeamX(), remoteTile.getBeamY(), remoteTile.getBeamZ(), (int)device.energyFlow, getPowerTier() == 1, device.beam, true, rType); - } - else - { - int transferCap = storage.getMaxExtract(); + if (worldObj.isRemote) { + int rType = 0; + if (this instanceof TileEnergyRelay || this instanceof TileWirelessEnergyTransceiver) { + if (remoteTile instanceof TileEnergyTransceiver) rType = 2; + else rType = 3; + } else if (this instanceof TileEnergyTransceiver) { + if (remoteTile instanceof TileEnergyRelay || remoteTile instanceof TileWirelessEnergyTransceiver) + rType = 1; + else rType = 0; + } + if (inView) LogHelper.info(device.energyFlow); + device.beam = DraconicEvolution.proxy.energyBeam(worldObj, getBeamX(), getBeamY(), getBeamZ(), remoteTile.getBeamX(), remoteTile.getBeamY(), remoteTile.getBeamZ(), (int) device.energyFlow, getPowerTier() == 1, device.beam, true, rType); + } else { + int transferCap = storage.getMaxExtract(); - double difference = getCapacity() - remoteTile.getCapacity(); + double difference = getCapacity() - remoteTile.getCapacity(); - int energyToEqual = (int)(((difference / 100D) * (double)remoteTile.getStorage().getMaxEnergyStored()) / 2.1D); + int energyToEqual = (int) (((difference / 100D) * (double) remoteTile.getStorage().getMaxEnergyStored()) / 2.1D); - double maxFlow = Math.min(energyToEqual, Math.min(transferCap, remoteTile.getStorage().getMaxEnergyStored() - remoteTile.getStorage().getEnergyStored())); + double maxFlow = Math.min(energyToEqual, Math.min(transferCap, remoteTile.getStorage().getMaxEnergyStored() - remoteTile.getStorage().getEnergyStored())); - device.energyFlow = getFlow(getCapacity(), remoteTile.getCapacity()); - int flow = (int) ((device.energyFlow / 100D) * maxFlow); + device.energyFlow = getFlow(getCapacity(), remoteTile.getCapacity()); + int flow = (int) ((device.energyFlow / 100D) * maxFlow); - int transfered = storage.extractEnergy(remoteTile.getStorage().receiveEnergy(storage.extractEnergy(flow, true), false), false); + int transfered = storage.extractEnergy(remoteTile.getStorage().receiveEnergy(storage.extractEnergy(flow, true), false), false); - if (inView)LogHelper.info(transfered); - device.energyFlow = Math.min(((double)transfered / 10000D) * 100D, 100D); + if (inView) LogHelper.info(transfered); + device.energyFlow = Math.min(((double) transfered / 10000D) * 100D, 100D); - //LogHelper.info("dif:" + difference + " flow:" + getFlow(getCapacity(), remoteTile.getCapacity()) + " EtoE:" + energyToEqual + " tfrd:" + transfered + " X:" + xCoord + " lCap:" + getCapacity() + " rCap:" + remoteTile.getCapacity() + " strd:" + storage.getEnergyStored() + " T:" + type + " mxflw:" + maxFlow); + //LogHelper.info("dif:" + difference + " flow:" + getFlow(getCapacity(), remoteTile.getCapacity()) + " EtoE:" + energyToEqual + " tfrd:" + transfered + " X:" + xCoord + " lCap:" + getCapacity() + " rCap:" + remoteTile.getCapacity() + " strd:" + storage.getEnergyStored() + " T:" + type + " mxflw:" + maxFlow); - //LogHelper.info(flow + " " + transfered + " " + getEnergyStored(ForgeDirection.UNKNOWN)); - //if (device.energyFlow > 0)LogHelper.info(device.energyFlow + " " + transfered); - //if (device.energyFlow == 0) LogHelper.info(device.getEnergyTile(worldObj));//todo clean up - detectAndSendChanges(linkedDevices.indexOf(device)); - if (inView) LogHelper.info(device.energyFlow); - } - } - if (inView)LogHelper.info("#######END########"); - } + //LogHelper.info(flow + " " + transfered + " " + getEnergyStored(ForgeDirection.UNKNOWN)); + //if (device.energyFlow > 0)LogHelper.info(device.energyFlow + " " + transfered); + //if (device.energyFlow == 0) LogHelper.info(device.getEnergyTile(worldObj));//todo clean up + detectAndSendChanges(linkedDevices.indexOf(device)); + if (inView) LogHelper.info(device.energyFlow); + } + } + if (inView) LogHelper.info("#######END########"); + } - protected void detectAndSendChanges(int index) - { - if (worldObj.isRemote) return; + protected void detectAndSendChanges(int index) { + if (worldObj.isRemote) return; - boolean forceSend = (tick + xCoord + yCoord + zCoord) % 100 == 0; + boolean forceSend = (tick + xCoord + yCoord + zCoord) % 100 == 0; - if ((tick + xCoord + yCoord + zCoord) % 20 == 0 || forceSend) - { - if (index >= 0 && (linkedDevices.get(index).energyFlow != linkedDevices.get(index).lastTickEnergyFlow || forceSend)) - { - sendObjectToClient(References.INT_PAIR_ID, 0, new DataUtills.IntPair(index, (int) linkedDevices.get(index).energyFlow)); - linkedDevices.get(index).lastTickEnergyFlow = linkedDevices.get(index).energyFlow; - } + if ((tick + xCoord + yCoord + zCoord) % 20 == 0 || forceSend) { + if (index >= 0 && (linkedDevices.get(index).energyFlow != linkedDevices.get(index).lastTickEnergyFlow || forceSend)) { + sendObjectToClient(References.INT_PAIR_ID, 0, new DataUtills.IntPair(index, (int) linkedDevices.get(index).energyFlow)); + linkedDevices.get(index).lastTickEnergyFlow = linkedDevices.get(index).energyFlow; + } - if (storage.getEnergyStored() != lastTickEnergy || forceSend) sendObjectToClient(References.INT_ID, 1, storage.getEnergyStored()); - } - } + if (storage.getEnergyStored() != lastTickEnergy || forceSend) + sendObjectToClient(References.INT_ID, 1, storage.getEnergyStored()); + } + } - @SideOnly(Side.CLIENT) - @Override - public void receiveObjectFromServer(int index, Object object) { - if (index == 0 && object instanceof DataUtills.IntPair && linkedDevices.size() > ((DataUtills.IntPair) object).i1) - { - linkedDevices.get(((DataUtills.IntPair) object).i1).energyFlow = ((DataUtills.IntPair) object).i2; - } - else if (index == 1) storage.setEnergyStored((Integer)object); - } + @SideOnly(Side.CLIENT) + @Override + public void receiveObjectFromServer(int index, Object object) { + if (index == 0 && object instanceof DataUtills.IntPair && linkedDevices.size() > ((DataUtills.IntPair) object).i1) { + linkedDevices.get(((DataUtills.IntPair) object).i1).energyFlow = ((DataUtills.IntPair) object).i2; + } else if (index == 1) storage.setEnergyStored((Integer) object); + } - @Override - public double getCapacity() { - return ((double) storage.getEnergyStored() / (double) storage.getMaxEnergyStored()) * 100D; - } + @Override + public double getCapacity() { + return ((double) storage.getEnergyStored() / (double) storage.getMaxEnergyStored()) * 100D; + } - /**Calculates the energy flow based on the local buffer - * and the remote buffer - *return double between 0 to 100*/ - public double getFlow(double localCap, double remoteCap) - { - return Math.max(0, Math.min(100, (localCap - remoteCap) * 10D/*Flow Multiplier*/)); - } + /** + * Calculates the energy flow based on the local buffer + * and the remote buffer + * return double between 0 to 100 + */ + public double getFlow(double localCap, double remoteCap) { + return Math.max(0, Math.min(100, (localCap - remoteCap) * 10D/*Flow Multiplier*/)); + } - public int getPowerTier() { - return powerTier; - } + public int getPowerTier() { + return powerTier; + } - public void onBlockActivated(EntityPlayer player) - { - ItemStack wrench = player.getHeldItem(); + public void onBlockActivated(EntityPlayer player) { + ItemStack wrench = player.getHeldItem(); - if (wrench != null && wrench.getItem() == Items.stick) - { - for (LinkedEnergyDevice ld : linkedDevices) - { - if (ld.beam != null) LogHelper.info(ld.beam.getFlow()); - } - } + if (wrench != null && wrench.getItem() == Items.stick) { + for (LinkedEnergyDevice ld : linkedDevices) { + if (ld.beam != null) LogHelper.info(ld.beam.getFlow()); + } + } - if (wrench == null || wrench.getItem() != ModItems.wrench) return; - String mode = Wrench.getMode(wrench); - NBTTagCompound linkDat = null; - if (wrench.hasTagCompound() && wrench.getTagCompound().hasKey("LinkData")) linkDat = wrench.getTagCompound().getCompoundTag("LinkData"); + if (wrench == null || wrench.getItem() != ModItems.wrench) return; + String mode = Wrench.getMode(wrench); + NBTTagCompound linkDat = null; + if (wrench.hasTagCompound() && wrench.getTagCompound().hasKey("LinkData")) + linkDat = wrench.getTagCompound().getCompoundTag("LinkData"); - if (mode.equals(Wrench.BIND_MODE)) - { - if (linkDat != null && linkDat.hasKey("Bound") && linkDat.getBoolean("Bound")) - { - //LogHelper.info("Bind"); - handleBinding(player, linkDat.getInteger("XCoord"), linkDat.getInteger("YCoord"), linkDat.getInteger("ZCoord"), true); - linkDat.setBoolean("Bound", false); - } - else - { - //LogHelper.info("Bind2"); - linkDat = new NBTTagCompound(); - linkDat.setInteger("XCoord", xCoord); - linkDat.setInteger("YCoord", yCoord); - linkDat.setInteger("ZCoord", zCoord); - linkDat.setBoolean("Bound", true); - ItemNBTHelper.getCompound(wrench).setTag("LinkData", linkDat); - if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.de.posSaved.txt")); - } - } - else if (mode.equals(Wrench.UNBIND_MODE)) - { - if (linkDat != null && linkDat.hasKey("Bound") && linkDat.getBoolean("Bound")) - { - for (LinkedEnergyDevice ld : linkedDevices) - { - if (ld.xCoord == linkDat.getInteger("XCoord") && ld.yCoord == linkDat.getInteger("YCoord") && ld.zCoord == linkDat.getInteger("ZCoord")) - { + if (mode.equals(Wrench.BIND_MODE)) { + if (linkDat != null && linkDat.hasKey("Bound") && linkDat.getBoolean("Bound")) { + //LogHelper.info("Bind"); + handleBinding(player, linkDat.getInteger("XCoord"), linkDat.getInteger("YCoord"), linkDat.getInteger("ZCoord"), true); + linkDat.setBoolean("Bound", false); + } else { + //LogHelper.info("Bind2"); + linkDat = new NBTTagCompound(); + linkDat.setInteger("XCoord", xCoord); + linkDat.setInteger("YCoord", yCoord); + linkDat.setInteger("ZCoord", zCoord); + linkDat.setBoolean("Bound", true); + ItemNBTHelper.getCompound(wrench).setTag("LinkData", linkDat); + if (worldObj.isRemote) + player.addChatComponentMessage(new ChatComponentTranslation("msg.de.posSaved.txt")); + } + } else if (mode.equals(Wrench.UNBIND_MODE)) { + if (linkDat != null && linkDat.hasKey("Bound") && linkDat.getBoolean("Bound")) { + for (LinkedEnergyDevice ld : linkedDevices) { + if (ld.xCoord == linkDat.getInteger("XCoord") && ld.yCoord == linkDat.getInteger("YCoord") && ld.zCoord == linkDat.getInteger("ZCoord")) { - if (!(ld.getTile(worldObj) instanceof TileRemoteEnergyBase)) - { - LogHelper.error("TileRemoteEnergyBase - UNBIND - Remote tile invalid (This should be reported)"); - break; - } + if (!(ld.getTile(worldObj) instanceof TileRemoteEnergyBase)) { + LogHelper.error("TileRemoteEnergyBase - UNBIND - Remote tile invalid (This should be reported)"); + break; + } - for (LinkedEnergyDevice rld : ((TileRemoteEnergyBase)ld.getTile(worldObj)).linkedDevices) - { - if (rld.xCoord == xCoord && rld.yCoord == yCoord && rld.zCoord == zCoord) - { - ((TileRemoteEnergyBase)ld.getTile(worldObj)).linkedDevices.remove(rld); - break; - } - } + for (LinkedEnergyDevice rld : ((TileRemoteEnergyBase) ld.getTile(worldObj)).linkedDevices) { + if (rld.xCoord == xCoord && rld.yCoord == yCoord && rld.zCoord == zCoord) { + ((TileRemoteEnergyBase) ld.getTile(worldObj)).linkedDevices.remove(rld); + break; + } + } - linkedDevices.remove(ld); - break; - } - } + linkedDevices.remove(ld); + break; + } + } - linkDat.setBoolean("Bound", false); - } - else - { - linkDat = new NBTTagCompound(); - linkDat.setInteger("XCoord", xCoord); - linkDat.setInteger("YCoord", yCoord); - linkDat.setInteger("ZCoord", zCoord); - linkDat.setBoolean("Bound", true); - ItemNBTHelper.getCompound(wrench).setTag("LinkData", linkDat); - if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.de.posSaved.txt")); - } - } - else if (mode.equals(Wrench.CLEAR_BINDINGS)) - { - if (this instanceof TileWirelessEnergyTransceiver) ((TileWirelessEnergyTransceiver)this).receiverList.clear(); + linkDat.setBoolean("Bound", false); + } else { + linkDat = new NBTTagCompound(); + linkDat.setInteger("XCoord", xCoord); + linkDat.setInteger("YCoord", yCoord); + linkDat.setInteger("ZCoord", zCoord); + linkDat.setBoolean("Bound", true); + ItemNBTHelper.getCompound(wrench).setTag("LinkData", linkDat); + if (worldObj.isRemote) + player.addChatComponentMessage(new ChatComponentTranslation("msg.de.posSaved.txt")); + } + } else if (mode.equals(Wrench.CLEAR_BINDINGS)) { + if (this instanceof TileWirelessEnergyTransceiver) + ((TileWirelessEnergyTransceiver) this).receiverList.clear(); - for (LinkedEnergyDevice ld : linkedDevices) - { - if (!(ld.getTile(worldObj) instanceof TileRemoteEnergyBase)) - { - LogHelper.error("TileRemoteEnergyBase - UNBIND - Remote tile invalid (This should be reported)"); - break; - } + for (LinkedEnergyDevice ld : linkedDevices) { + if (!(ld.getTile(worldObj) instanceof TileRemoteEnergyBase)) { + LogHelper.error("TileRemoteEnergyBase - UNBIND - Remote tile invalid (This should be reported)"); + break; + } - for (LinkedEnergyDevice rld : ((TileRemoteEnergyBase)ld.getTile(worldObj)).linkedDevices) - { - if (rld.xCoord == xCoord && rld.yCoord == yCoord && rld.zCoord == zCoord) - { - ((TileRemoteEnergyBase)ld.getTile(worldObj)).linkedDevices.remove(rld); - break; - } - } + for (LinkedEnergyDevice rld : ((TileRemoteEnergyBase) ld.getTile(worldObj)).linkedDevices) { + if (rld.xCoord == xCoord && rld.yCoord == yCoord && rld.zCoord == zCoord) { + ((TileRemoteEnergyBase) ld.getTile(worldObj)).linkedDevices.remove(rld); + break; + } + } - } + } - linkedDevices.clear(); - } - else - { - handleOther(player, wrench); - } - } + linkedDevices.clear(); + } else { + handleOther(player, wrench); + } + } - @Override - public boolean handleBinding(EntityPlayer player, int x, int y, int z, boolean callOther) - { - int range = (powerTier + 1) * 25; - IRemoteEnergyHandler tile = worldObj.getTileEntity(x, y, z) instanceof IRemoteEnergyHandler ? (IRemoteEnergyHandler) worldObj.getTileEntity(x, y, z) : null; + @Override + public boolean handleBinding(EntityPlayer player, int x, int y, int z, boolean callOther) { + int range = (powerTier + 1) * 25; + IRemoteEnergyHandler tile = worldObj.getTileEntity(x, y, z) instanceof IRemoteEnergyHandler ? (IRemoteEnergyHandler) worldObj.getTileEntity(x, y, z) : null; - if (tile == null || (x == xCoord && y == yCoord && z == zCoord)) - { - if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.de.invalidTile.txt")); - return false; - } - else if (Utills.getDistanceAtoB(xCoord, yCoord, zCoord, x, y, z) > range) - { - if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.de.outOfRange.txt")); - return false; - } - else if (linkedDevices.size() >= getMaxConnections()) - { - if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.de.maxConnections.txt")); - return false; - } + if (tile == null || (x == xCoord && y == yCoord && z == zCoord)) { + if (worldObj.isRemote) + player.addChatComponentMessage(new ChatComponentTranslation("msg.de.invalidTile.txt")); + return false; + } else if (Utills.getDistanceAtoB(xCoord, yCoord, zCoord, x, y, z) > range) { + if (worldObj.isRemote) + player.addChatComponentMessage(new ChatComponentTranslation("msg.de.outOfRange.txt")); + return false; + } else if (linkedDevices.size() >= getMaxConnections()) { + if (worldObj.isRemote) + player.addChatComponentMessage(new ChatComponentTranslation("msg.de.maxConnections.txt")); + return false; + } - if (callOther && !tile.handleBinding(player, xCoord, yCoord, zCoord, false)) - { - //LogHelper.info("other Invalid"); - return false; - } + if (callOther && !tile.handleBinding(player, xCoord, yCoord, zCoord, false)) { + //LogHelper.info("other Invalid"); + return false; + } - if (callOther && worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.de.linked.txt")); + if (callOther && worldObj.isRemote) + player.addChatComponentMessage(new ChatComponentTranslation("msg.de.linked.txt")); - for (LinkedEnergyDevice ld : linkedDevices) - { - if (ld.xCoord == x && ld.yCoord == y && ld.zCoord == z) return true; - } + for (LinkedEnergyDevice ld : linkedDevices) { + if (ld.xCoord == x && ld.yCoord == y && ld.zCoord == z) return true; + } - linkedDevices.add(new LinkedEnergyDevice(x, y, z, null)); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + linkedDevices.add(new LinkedEnergyDevice(x, y, z, null)); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - return true; - } + return true; + } - public boolean handleOther(EntityPlayer player, ItemStack wrench) { return false; } + public boolean handleOther(EntityPlayer player, ItemStack wrench) { + return false; + } - @Override - public EnergyStorage getStorage() { - return storage; - } + @Override + public EnergyStorage getStorage() { + return storage; + } - //************************************** + //************************************** - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - return 0; - } + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + return 0; + } - @Override - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { - return 0; - } + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { + return 0; + } - @Override - public int getEnergyStored(ForgeDirection from) { - return storage.getEnergyStored(); - } + @Override + public int getEnergyStored(ForgeDirection from) { + return storage.getEnergyStored(); + } - @Override - public int getMaxEnergyStored(ForgeDirection from) { - return storage.getMaxEnergyStored(); - } + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return storage.getMaxEnergyStored(); + } - @Override - public boolean canConnectEnergy(ForgeDirection from) { - return false; - } + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return false; + } - @Override - public void writeToNBT(NBTTagCompound compound) { - compound.setByte("Type", (byte) powerTier); - int index = 0; - compound.setInteger("LinkCount", linkedDevices.size()); - for (LinkedEnergyDevice ld : linkedDevices) - { - ld.writeToNBT(compound, "LinkedDevice_" + index); - ++index; - } - super.writeToNBT(compound); - storage.writeToNBT(compound); - } + @Override + public void writeToNBT(NBTTagCompound compound) { + compound.setByte("Type", (byte) powerTier); + int index = 0; + compound.setInteger("LinkCount", linkedDevices.size()); + for (LinkedEnergyDevice ld : linkedDevices) { + ld.writeToNBT(compound, "LinkedDevice_" + index); + ++index; + } + super.writeToNBT(compound); + storage.writeToNBT(compound); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - powerTier = compound.getByte("Type"); - this.updateStorage(); - int linkCount = compound.getInteger("LinkCount"); - linkedDevices = new ArrayList(); - for (int i = 0; i < linkCount; i++) - { - linkedDevices.add(new LinkedEnergyDevice().readFromNBT(compound, "LinkedDevice_" + i)); - } - super.readFromNBT(compound); - storage.readFromNBT(compound); - } + @Override + public void readFromNBT(NBTTagCompound compound) { + powerTier = compound.getByte("Type"); + this.updateStorage(); + int linkCount = compound.getInteger("LinkCount"); + linkedDevices = new ArrayList(); + for (int i = 0; i < linkCount; i++) { + linkedDevices.add(new LinkedEnergyDevice().readFromNBT(compound, "LinkedDevice_" + i)); + } + super.readFromNBT(compound); + storage.readFromNBT(compound); + } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound tagCompound = new NBTTagCompound(); - writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - @Override - public AxisAlignedBB getRenderBoundingBox() { - return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1); - } + @Override + public AxisAlignedBB getRenderBoundingBox() { + return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/TileWirelessEnergyTransceiver.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/TileWirelessEnergyTransceiver.java index 56095211..f705ee18 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/TileWirelessEnergyTransceiver.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/energynet/TileWirelessEnergyTransceiver.java @@ -27,199 +27,182 @@ public class TileWirelessEnergyTransceiver extends TileRemoteEnergyBase { @SideOnly(Side.CLIENT) private ParticleEnergyField ring; - public List receiverList = new ArrayList(); + public List receiverList = new ArrayList(); - public TileWirelessEnergyTransceiver(){} + public TileWirelessEnergyTransceiver() { + } - public TileWirelessEnergyTransceiver(int powerTier){ - this.powerTier = powerTier; - this.updateStorage(); - } + public TileWirelessEnergyTransceiver(int powerTier) { + this.powerTier = powerTier; + this.updateStorage(); + } - @Override - public int getCap() { - return 50000 + (powerTier * 4500000); - } + @Override + public int getCap() { + return 50000 + (powerTier * 4500000); + } - @Override - public int getRec() { - return 50000 + (powerTier * 4500000); - } + @Override + public int getRec() { + return 50000 + (powerTier * 4500000); + } - @Override - public int getExt() { - return 50000 + (powerTier * 4500000); - } + @Override + public int getExt() { + return 50000 + (powerTier * 4500000); + } - @Override - public void updateEntity() { - super.updateEntity(); + @Override + public void updateEntity() { + super.updateEntity(); - if (worldObj.isRemote) - { - ring = DraconicEvolution.proxy.energyField(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 2, powerTier == 1, ring, inView > 0); + if (worldObj.isRemote) { + ring = DraconicEvolution.proxy.energyField(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 2, powerTier == 1, ring, inView > 0); - for (LinkedReceiver receiver : receiverList) - { - int particleValue = 200; - if (receiver.particleEnergyCounter > particleValue) - { - receiver.particleEnergyCounter -= particleValue; + for (LinkedReceiver receiver : receiverList) { + int particleValue = 200; + if (receiver.particleEnergyCounter > particleValue) { + receiver.particleEnergyCounter -= particleValue; - //todo detect box size - DraconicEvolution.proxy.spawnParticle(new Particles.TransceiverParticle(worldObj, xCoord + 0.5, yCoord + 0.3 + (worldObj.rand.nextDouble() * 0.4), zCoord + 0.5, receiver.xCoord + worldObj.rand.nextDouble(), receiver.yCoord + worldObj.rand.nextDouble(), receiver.zCoord + worldObj.rand.nextDouble()), 64); - } - } - } - else - { - for (LinkedReceiver receiver : receiverList) - { - if (!receiver.isStillValid(worldObj) && worldObj.getChunkFromBlockCoords(receiver.xCoord, receiver.zCoord).isChunkLoaded) - { - receiverList.remove(receiver); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - break; - } + //todo detect box size + DraconicEvolution.proxy.spawnParticle(new Particles.TransceiverParticle(worldObj, xCoord + 0.5, yCoord + 0.3 + (worldObj.rand.nextDouble() * 0.4), zCoord + 0.5, receiver.xCoord + worldObj.rand.nextDouble(), receiver.yCoord + worldObj.rand.nextDouble(), receiver.zCoord + worldObj.rand.nextDouble()), 64); + } + } + } else { + for (LinkedReceiver receiver : receiverList) { + if (!receiver.isStillValid(worldObj) && worldObj.getChunkFromBlockCoords(receiver.xCoord, receiver.zCoord).isChunkLoaded) { + receiverList.remove(receiver); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + break; + } - int sent = receiver.receiveEnergy(worldObj, storage.extractEnergy(receiver.receiveEnergy(worldObj, powerTier == 0 ? 5000 : 50000, true), false), false); + int sent = receiver.receiveEnergy(worldObj, storage.extractEnergy(receiver.receiveEnergy(worldObj, powerTier == 0 ? 5000 : 50000, true), false), false); - sent = (sent / 20); + sent = (sent / 20); - if (sent > Short.MAX_VALUE) sent = Short.MAX_VALUE; + if (sent > Short.MAX_VALUE) sent = Short.MAX_VALUE; - if (sent > 0) sendObjectToClient(References.SHORT_ID, 10 + receiverList.indexOf(receiver), (short) sent); - } - } - } + if (sent > 0) + sendObjectToClient(References.SHORT_ID, 10 + receiverList.indexOf(receiver), (short) sent); + } + } + } - @SideOnly(Side.CLIENT) - @Override - public void receiveObjectFromServer(int index, Object object) { - super.receiveObjectFromServer(index, object); - if (index >= 10) - { + @SideOnly(Side.CLIENT) + @Override + public void receiveObjectFromServer(int index, Object object) { + super.receiveObjectFromServer(index, object); + if (index >= 10) { - if (receiverList.size() > index - 10 && receiverList.get(index - 10).particleEnergyCounter < 10000) receiverList.get(index - 10).particleEnergyCounter += (Short)object; - } - } + if (receiverList.size() > index - 10 && receiverList.get(index - 10).particleEnergyCounter < 10000) + receiverList.get(index - 10).particleEnergyCounter += (Short) object; + } + } - public void linkDevice(int x, int y, int z, int side, EntityPlayer player, String mode) - { - TileEntity target = worldObj.getTileEntity(x, y, z); - if (!(target instanceof IEnergyReceiver)) - { - player.addChatComponentMessage(new ChatComponentText("Unknown Error occurred [Invalid Tile]")); - return; - } + public void linkDevice(int x, int y, int z, int side, EntityPlayer player, String mode) { + TileEntity target = worldObj.getTileEntity(x, y, z); + if (!(target instanceof IEnergyReceiver)) { + player.addChatComponentMessage(new ChatComponentText("Unknown Error occurred [Invalid Tile]")); + return; + } - IEnergyReceiver receiver = (IEnergyReceiver) target; + IEnergyReceiver receiver = (IEnergyReceiver) target; - if (!receiver.canConnectEnergy(ForgeDirection.getOrientation(side))) - { - player.addChatComponentMessage(new ChatComponentTranslation("msg.de.wrongSide.txt")); - return; - } + if (!receiver.canConnectEnergy(ForgeDirection.getOrientation(side))) { + player.addChatComponentMessage(new ChatComponentTranslation("msg.de.wrongSide.txt")); + return; + } - if (receiverList.size() >= getmaxWirelessConnections()) - { - player.addChatComponentMessage(new ChatComponentTranslation("msg.de.maxConnections.txt")); - return; - } + if (receiverList.size() >= getmaxWirelessConnections()) { + player.addChatComponentMessage(new ChatComponentTranslation("msg.de.maxConnections.txt")); + return; + } - if (Utills.getDistanceAtoB(xCoord, yCoord, zCoord, x, y, z) > (powerTier == 0 ? 15 : 30)) - { - player.addChatComponentMessage(new ChatComponentTranslation("msg.de.outOfRange.txt")); - return; - } + if (Utills.getDistanceAtoB(xCoord, yCoord, zCoord, x, y, z) > (powerTier == 0 ? 15 : 30)) { + player.addChatComponentMessage(new ChatComponentTranslation("msg.de.outOfRange.txt")); + return; + } - if (mode.equals(Wrench.BIND_MODE)) - { - LinkedReceiver r = new LinkedReceiver(x, y, z, side); + if (mode.equals(Wrench.BIND_MODE)) { + LinkedReceiver r = new LinkedReceiver(x, y, z, side); - for (LinkedReceiver r2 : receiverList) - { - if (r.xCoord == r2.xCoord && r.yCoord == r2.yCoord && r.zCoord == r2.zCoord && r.connectionSide == r2.connectionSide) - { - player.addChatComponentMessage(new ChatComponentTranslation("msg.de.linked.txt")); - return; - } - } - receiverList.add(r); - player.addChatComponentMessage(new ChatComponentTranslation("msg.de.linked.txt")); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } - else if (mode.equals(Wrench.UNBIND_MODE)) - { - for (LinkedReceiver r2 : receiverList) - { - if (x == r2.xCoord && y == r2.yCoord && z == r2.zCoord && side == r2.connectionSide) - { - player.addChatComponentMessage(new ChatComponentTranslation("msg.de.unLinked.txt")); - receiverList.remove(r2); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - return; - } - } - } - } + for (LinkedReceiver r2 : receiverList) { + if (r.xCoord == r2.xCoord && r.yCoord == r2.yCoord && r.zCoord == r2.zCoord && r.connectionSide == r2.connectionSide) { + player.addChatComponentMessage(new ChatComponentTranslation("msg.de.linked.txt")); + return; + } + } + receiverList.add(r); + player.addChatComponentMessage(new ChatComponentTranslation("msg.de.linked.txt")); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } else if (mode.equals(Wrench.UNBIND_MODE)) { + for (LinkedReceiver r2 : receiverList) { + if (x == r2.xCoord && y == r2.yCoord && z == r2.zCoord && side == r2.connectionSide) { + player.addChatComponentMessage(new ChatComponentTranslation("msg.de.unLinked.txt")); + receiverList.remove(r2); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return; + } + } + } + } - @Override - public void writeToNBT(NBTTagCompound compound) { - super.writeToNBT(compound); - compound.setInteger("Receiver_Count", receiverList.size()); - for (int i = 0; i < receiverList.size(); i++) receiverList.get(i).writeToNBT(compound, String.valueOf(i)); - } + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setInteger("Receiver_Count", receiverList.size()); + for (int i = 0; i < receiverList.size(); i++) receiverList.get(i).writeToNBT(compound, String.valueOf(i)); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - super.readFromNBT(compound); - int count = compound.getInteger("Receiver_Count"); - receiverList.clear(); - for (int i = 0; i < count; i++) - { - LinkedReceiver r = new LinkedReceiver(); - r.readFromNBT(compound, String.valueOf(i)); - receiverList.add(r); - } - } + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + int count = compound.getInteger("Receiver_Count"); + receiverList.clear(); + for (int i = 0; i < count; i++) { + LinkedReceiver r = new LinkedReceiver(); + r.readFromNBT(compound, String.valueOf(i)); + receiverList.add(r); + } + } // @Override // public double getCapacity() { // return ((double) getEnergyStored(ForgeDirection.UNKNOWN) / (double) getMaxEnergyStored(ForgeDirection.UNKNOWN)) * 100D; // } - /**Calculates the energy flow based on the local buffer - * and the remote buffer - *return double between 0 to 100*/ - public double getFlow(double localCap, double remoteCap) - { - return Math.max(0, Math.min(100, (localCap - remoteCap) * 100D/*Flow Multiplier*/)); - } + /** + * Calculates the energy flow based on the local buffer + * and the remote buffer + * return double between 0 to 100 + */ + public double getFlow(double localCap, double remoteCap) { + return Math.max(0, Math.min(100, (localCap - remoteCap) * 100D/*Flow Multiplier*/)); + } - @Override - public double getBeamX() { - return xCoord + 0.5D; - } + @Override + public double getBeamX() { + return xCoord + 0.5D; + } - @Override - public double getBeamY() { - return yCoord + 0.5D; - } + @Override + public double getBeamY() { + return yCoord + 0.5D; + } - @Override - public double getBeamZ() { - return zCoord + 0.5D; - } + @Override + public double getBeamZ() { + return zCoord + 0.5D; + } - @Override - public int getMaxConnections() { - return powerTier == 0 ? 3 : 6; - } + @Override + public int getMaxConnections() { + return powerTier == 0 ? 3 : 6; + } - public int getmaxWirelessConnections() { - return powerTier == 0 ? 8 : 16; - } + public int getmaxWirelessConnections() { + return powerTier == 0 ? 8 : 16; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/gates/TileFluidGate.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/gates/TileFluidGate.java index 73770b36..10347ae1 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/gates/TileFluidGate.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/gates/TileFluidGate.java @@ -15,82 +15,81 @@ import net.minecraftforge.fluids.IFluidHandler; */ public class TileFluidGate extends TileGate implements IFluidHandler { - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - IFluidHandler target = getOutputTarget(); - if (target == null) return 0; - int transfer = Math.min(getActualFlow(), target.fill(from, resource, false)); - if (transfer < resource.amount){ - FluidStack newStack = resource.copy(); - newStack.amount = transfer; - resource.amount -= transfer; - return target.fill(from, newStack, doFill); - } - return target.fill(from, resource, doFill); - } + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + IFluidHandler target = getOutputTarget(); + if (target == null) return 0; + int transfer = Math.min(getActualFlow(), target.fill(from, resource, false)); + if (transfer < resource.amount) { + FluidStack newStack = resource.copy(); + newStack.amount = transfer; + resource.amount -= transfer; + return target.fill(from, newStack, doFill); + } + return target.fill(from, resource, doFill); + } - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - return null; - } + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + return null; + } - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - return null; - } + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return null; + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) { - IFluidHandler target = getOutputTarget(); - LogHelper.info(target != null && target.canFill(from, fluid)); - return target != null && target.canFill(from, fluid); - } + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + IFluidHandler target = getOutputTarget(); + LogHelper.info(target != null && target.canFill(from, fluid)); + return target != null && target.canFill(from, fluid); + } - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) { - return false; - } + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return false; + } - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) { - return new FluidTankInfo[0]; - } + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + return new FluidTankInfo[0]; + } - private IFluidHandler getOutputTarget(){ - TileEntity tile = worldObj.getTileEntity(xCoord + output.offsetX, yCoord + output.offsetY, zCoord + output.offsetZ); - return tile instanceof IFluidHandler ? (IFluidHandler) tile : null; - } + private IFluidHandler getOutputTarget() { + TileEntity tile = worldObj.getTileEntity(xCoord + output.offsetX, yCoord + output.offsetY, zCoord + output.offsetZ); + return tile instanceof IFluidHandler ? (IFluidHandler) tile : null; + } - @Override - public String getFlowSetting(int selector) { - return selector == 0 ? Utills.addCommas(flowRSLow) + " MB/t" : Utills.addCommas(flowRSHigh) + " MB/t"; - } + @Override + public String getFlowSetting(int selector) { + return selector == 0 ? Utills.addCommas(flowRSLow) + " MB/t" : Utills.addCommas(flowRSHigh) + " MB/t"; + } - @Override - public void incrementFlow(int selector, boolean ctrl, boolean shift, boolean add, int button) { - int amount = button == 0 ? shift ? ctrl ? 1000 : 100 : ctrl ? 50 : 5 : shift ? ctrl ? 100 : 50 : ctrl ? 10 : 1; - if (selector == 0) { - flowRSLow += add ? amount : -amount; - if (flowRSLow < 0) flowRSLow = 0; - if (worldObj.isRemote) sendObjectToServer(References.INT_ID, 0, flowRSLow); - } - else { - flowRSHigh += add ? amount : -amount; - if (flowRSHigh < 0) flowRSHigh = 0; - if (worldObj.isRemote) sendObjectToServer(References.INT_ID, 1, flowRSHigh); - } - } + @Override + public void incrementFlow(int selector, boolean ctrl, boolean shift, boolean add, int button) { + int amount = button == 0 ? shift ? ctrl ? 1000 : 100 : ctrl ? 50 : 5 : shift ? ctrl ? 100 : 50 : ctrl ? 10 : 1; + if (selector == 0) { + flowRSLow += add ? amount : -amount; + if (flowRSLow < 0) flowRSLow = 0; + if (worldObj.isRemote) sendObjectToServer(References.INT_ID, 0, flowRSLow); + } else { + flowRSHigh += add ? amount : -amount; + if (flowRSHigh < 0) flowRSHigh = 0; + if (worldObj.isRemote) sendObjectToServer(References.INT_ID, 1, flowRSHigh); + } + } - @Override - public String getToolTip(int selector, boolean shift, boolean ctrl) { - int b1 = shift ? ctrl ? 1000 : 100 : ctrl ? 50 : 5; - int b2 = shift ? ctrl ? 100 : 50 : ctrl ? 10 : 1; - return b1 + "/" + b2 + " MB/t"; - } + @Override + public String getToolTip(int selector, boolean shift, boolean ctrl) { + int b1 = shift ? ctrl ? 1000 : 100 : ctrl ? 50 : 5; + int b2 = shift ? ctrl ? 100 : 50 : ctrl ? 10 : 1; + return b1 + "/" + b2 + " MB/t"; + } - @Override - public String getName() { - return "fluid_gate"; - } + @Override + public String getName() { + return "fluid_gate"; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/gates/TileFluxGate.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/gates/TileFluxGate.java index c4f8eb59..800e5f93 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/gates/TileFluxGate.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/gates/TileFluxGate.java @@ -11,24 +11,24 @@ import net.minecraftforge.common.util.ForgeDirection; */ public class TileFluxGate extends TileGate implements IEnergyReceiver { - private int transferredThisTick = 0; + private int transferredThisTick = 0; - @Override - public void updateEntity() { - super.updateEntity(); + @Override + public void updateEntity() { + super.updateEntity(); - transferredThisTick = 0; - } + transferredThisTick = 0; + } - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - IEnergyReceiver target = getOutputTarget(); + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + IEnergyReceiver target = getOutputTarget(); // int i = buffer.receiveEnergy(Math.max(0, Math.min(maxReceive, Math.min(getActualFlow(), getActualFlow() - buffer.getEnergyStored()))), simulate); // return i; - int transfer = target == null ? 0 : target.receiveEnergy(from, Math.min(Math.max(0, getActualFlow()-transferredThisTick), target.receiveEnergy(from, maxReceive, true)), simulate); - transferredThisTick += transfer; - return transfer; - } + int transfer = target == null ? 0 : target.receiveEnergy(from, Math.min(Math.max(0, getActualFlow() - transferredThisTick), target.receiveEnergy(from, maxReceive, true)), simulate); + transferredThisTick += transfer; + return transfer; + } // private EnergyStorage buffer = new EnergyStorage(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); // @@ -50,61 +50,60 @@ public class TileFluxGate extends TileGate implements IEnergyReceiver { // } - @Override - public int getEnergyStored(ForgeDirection from) { - IEnergyReceiver target = getOutputTarget(); - return target == null ? 0 : target.getEnergyStored(from); - } + @Override + public int getEnergyStored(ForgeDirection from) { + IEnergyReceiver target = getOutputTarget(); + return target == null ? 0 : target.getEnergyStored(from); + } - @Override - public int getMaxEnergyStored(ForgeDirection from) { - IEnergyReceiver target = getOutputTarget(); - return target == null ? 0 : target.getMaxEnergyStored(from); - } + @Override + public int getMaxEnergyStored(ForgeDirection from) { + IEnergyReceiver target = getOutputTarget(); + return target == null ? 0 : target.getMaxEnergyStored(from); + } - @Override - public boolean canConnectEnergy(ForgeDirection from) { - return from == output || from == output.getOpposite(); - } + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return from == output || from == output.getOpposite(); + } - private IEnergyReceiver getOutputTarget(){ - TileEntity tile = worldObj.getTileEntity(xCoord + output.offsetX, yCoord + output.offsetY, zCoord + output.offsetZ); - return tile instanceof IEnergyReceiver ? (IEnergyReceiver) tile : null; - } + private IEnergyReceiver getOutputTarget() { + TileEntity tile = worldObj.getTileEntity(xCoord + output.offsetX, yCoord + output.offsetY, zCoord + output.offsetZ); + return tile instanceof IEnergyReceiver ? (IEnergyReceiver) tile : null; + } - @Override - public String getFlowSetting(int selector) { - return selector == 0 ? Utills.addCommas(flowRSLow) + " RF/t" : Utills.addCommas(flowRSHigh) + " RF/t"; - } + @Override + public String getFlowSetting(int selector) { + return selector == 0 ? Utills.addCommas(flowRSLow) + " RF/t" : Utills.addCommas(flowRSHigh) + " RF/t"; + } - @Override - public void incrementFlow(int selector, boolean ctrl, boolean shift, boolean add, int button) { - int amount = button == 0 ? shift ? ctrl ? 10000 : 1000 : ctrl ? 5 : 50 : shift ? ctrl ? 1000 : 100 : ctrl ? 1 : 10; + @Override + public void incrementFlow(int selector, boolean ctrl, boolean shift, boolean add, int button) { + int amount = button == 0 ? shift ? ctrl ? 10000 : 1000 : ctrl ? 5 : 50 : shift ? ctrl ? 1000 : 100 : ctrl ? 1 : 10; - if (selector == 0) { - if (ctrl && shift && button == 0) amount += flowRSLow / 100000 * 1000; - flowRSLow += (add ? amount : -amount); - if (flowRSLow < 0) flowRSLow = 0; - if (worldObj.isRemote) sendObjectToServer(References.INT_ID, 0, flowRSLow); - } - else { - if (ctrl && shift && button == 0) amount += flowRSHigh / 100000 * 1000; - flowRSHigh += add ? amount : -amount; - if (flowRSHigh < 0) flowRSHigh = 0; - if (worldObj.isRemote) sendObjectToServer(References.INT_ID, 1, flowRSHigh); - } - } + if (selector == 0) { + if (ctrl && shift && button == 0) amount += flowRSLow / 100000 * 1000; + flowRSLow += (add ? amount : -amount); + if (flowRSLow < 0) flowRSLow = 0; + if (worldObj.isRemote) sendObjectToServer(References.INT_ID, 0, flowRSLow); + } else { + if (ctrl && shift && button == 0) amount += flowRSHigh / 100000 * 1000; + flowRSHigh += add ? amount : -amount; + if (flowRSHigh < 0) flowRSHigh = 0; + if (worldObj.isRemote) sendObjectToServer(References.INT_ID, 1, flowRSHigh); + } + } - @Override - public String getToolTip(int selector, boolean shift, boolean ctrl) { - int i = selector == 0 ? flowRSLow / 100000 * 10000 : flowRSHigh / 100000 * 10000; - int b1 = shift ? ctrl ? 10000 + i : 1000 : ctrl ? 5 : 50; - int b2 = shift ? ctrl ? 1000 : 100 : ctrl ? 1 : 10; - return b1 + "/" + b2 + " RF/t"; - } + @Override + public String getToolTip(int selector, boolean shift, boolean ctrl) { + int i = selector == 0 ? flowRSLow / 100000 * 10000 : flowRSHigh / 100000 * 10000; + int b1 = shift ? ctrl ? 10000 + i : 1000 : ctrl ? 5 : 50; + int b2 = shift ? ctrl ? 1000 : 100 : ctrl ? 1 : 10; + return b1 + "/" + b2 + " RF/t"; + } - @Override - public String getName() { - return "flux_gate"; - } + @Override + public String getName() { + return "flux_gate"; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/gates/TileGate.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/gates/TileGate.java index 642bb1cb..3d0de006 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/gates/TileGate.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/gates/TileGate.java @@ -15,119 +15,116 @@ import net.minecraftforge.common.util.ForgeDirection; */ public abstract class TileGate extends TileObjectSync implements IDEPeripheral { - public ForgeDirection output = ForgeDirection.DOWN; - public int flowRSLow = 0; - public int flowRSHigh = 1000; - public int signal = -1; - public boolean flowOverridden = false; - protected int flowOverride = 0; + public ForgeDirection output = ForgeDirection.DOWN; + public int flowRSLow = 0; + public int flowRSHigh = 1000; + public int signal = -1; + public boolean flowOverridden = false; + protected int flowOverride = 0; - public abstract String getFlowSetting(int selector); + public abstract String getFlowSetting(int selector); - public abstract void incrementFlow(int selector, boolean ctrl, boolean shift, boolean add, int button); + public abstract void incrementFlow(int selector, boolean ctrl, boolean shift, boolean add, int button); - public abstract String getToolTip(int selector, boolean shift, boolean ctrl); + public abstract String getToolTip(int selector, boolean shift, boolean ctrl); - public int getActualFlow(){ - if (flowOverridden) return flowOverride; - if (signal == -1 ) signal = worldObj.getStrongestIndirectPower(xCoord, yCoord, zCoord); - return flowRSLow + (int) (((double)signal / 15D) * (double)(flowRSHigh - flowRSLow)); - } + public int getActualFlow() { + if (flowOverridden) return flowOverride; + if (signal == -1) signal = worldObj.getStrongestIndirectPower(xCoord, yCoord, zCoord); + return flowRSLow + (int) (((double) signal / 15D) * (double) (flowRSHigh - flowRSLow)); + } - @Override - public void receiveObjectFromClient(int index, Object object) { - if (index == 0) flowRSLow = (Integer)object; - else if (index == 1) flowRSHigh = (Integer)object; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } + @Override + public void receiveObjectFromClient(int index, Object object) { + if (index == 0) flowRSLow = (Integer) object; + else if (index == 1) flowRSHigh = (Integer) object; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } - @Override - public void receiveObjectFromServer(int index, Object object) { - if (index == 2){ - flowOverridden = (Boolean) object; - }else if (index == 3) { - flowOverride = (Integer) object; - }else if (index == 4) { - flowRSHigh = (Integer) object; - }else if (index == 5) { - flowRSLow = (Integer) object; - } - } + @Override + public void receiveObjectFromServer(int index, Object object) { + if (index == 2) { + flowOverridden = (Boolean) object; + } else if (index == 3) { + flowOverride = (Integer) object; + } else if (index == 4) { + flowRSHigh = (Integer) object; + } else if (index == 5) { + flowRSLow = (Integer) object; + } + } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, compound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound compound = new NBTTagCompound(); + writeToNBT(compound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, compound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - @Override - public void writeToNBT(NBTTagCompound compound) { - super.writeToNBT(compound); - compound.setInteger("Output", output.ordinal()); - compound.setInteger("FlowRSLow", flowRSLow); - compound.setInteger("FlowRSHigh", flowRSHigh); - compound.setInteger("Signal", signal); - compound.setInteger("FlowOverride", flowOverride); - compound.setBoolean("FlowOverridden", flowOverridden); - } + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setInteger("Output", output.ordinal()); + compound.setInteger("FlowRSLow", flowRSLow); + compound.setInteger("FlowRSHigh", flowRSHigh); + compound.setInteger("Signal", signal); + compound.setInteger("FlowOverride", flowOverride); + compound.setBoolean("FlowOverridden", flowOverridden); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - super.readFromNBT(compound); - output = ForgeDirection.getOrientation(compound.getInteger("Output")); - flowRSLow = compound.getInteger("FlowRSLow"); - flowRSHigh = compound.getInteger("FlowRSHigh"); - signal = compound.getInteger("Signal"); - flowOverride = compound.getInteger("FlowOverride"); - flowOverridden = compound.getBoolean("FlowOverridden"); - } + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + output = ForgeDirection.getOrientation(compound.getInteger("Output")); + flowRSLow = compound.getInteger("FlowRSLow"); + flowRSHigh = compound.getInteger("FlowRSHigh"); + signal = compound.getInteger("Signal"); + flowOverride = compound.getInteger("FlowOverride"); + flowOverridden = compound.getBoolean("FlowOverridden"); + } - @Override - public String[] getMethodNames() { - return new String[] { "getFlow", "setOverrideEnabled", "getOverrideEnabled", "setFlowOverride", "setSignalHighFlow", "getSignalHighFlow", "setSignalLowFlow", "getSignalLowFlow" }; - } + @Override + public String[] getMethodNames() { + return new String[]{"getFlow", "setOverrideEnabled", "getOverrideEnabled", "setFlowOverride", "setSignalHighFlow", "getSignalHighFlow", "setSignalLowFlow", "getSignalLowFlow"}; + } - @Override - public Object[] callMethod(String method, Object... args) { - if (method.equals("getFlow")){ - return new Object[] { getActualFlow() }; - } - else if (method.equals("setOverrideEnabled")){ - if (args.length == 0 || !(args[0] instanceof Boolean)) throw new IllegalArgumentException("Expected Boolean got "+(args.length == 0 ? "nil" : args[0].getClass().getSimpleName())); - flowOverridden = (Boolean)args[0]; - if (!worldObj.isRemote) sendObjectToClient(References.BOOLEAN_ID, 2, flowOverridden); - } - else if (method.equals("getOverrideEnabled")){ - return new Object[] { flowOverridden }; - } - else if (method.equals("setFlowOverride")){ - if (args.length == 0 || !(args[0] instanceof Number)) throw new IllegalArgumentException("Expected Number got "+(args.length == 0 ? "nil" : args[0].getClass().getSimpleName())); - flowOverride = Utills.toInt((Double)args[0]); - if (!worldObj.isRemote) sendObjectToClient(References.INT_ID, 3, flowOverride); - } - else if (method.equals("setSignalHighFlow")){ - if (args.length == 0 || !(args[0] instanceof Number)) throw new IllegalArgumentException("Expected Number got "+(args.length == 0 ? "nil" : args[0].getClass().getSimpleName())); - flowRSHigh = Utills.toInt((Double)args[0]); - if (!worldObj.isRemote) sendObjectToClient(References.INT_ID, 4, flowRSHigh); - } - else if (method.equals("getSignalHighFlow")){ - return new Object[] { flowRSHigh }; - } - else if (method.equals("setSignalLowFlow")){ - if (args.length == 0 || !(args[0] instanceof Number)) throw new IllegalArgumentException("Expected Number got "+(args.length == 0 ? "nil" : args[0].getClass().getSimpleName())); - flowRSLow = Utills.toInt((Double)args[0]); - if (!worldObj.isRemote) sendObjectToClient(References.INT_ID, 5, flowRSLow); - } - else if (method.equals("getSignalLowFlow")){ - return new Object[] { flowRSLow }; - } + @Override + public Object[] callMethod(String method, Object... args) { + if (method.equals("getFlow")) { + return new Object[]{getActualFlow()}; + } else if (method.equals("setOverrideEnabled")) { + if (args.length == 0 || !(args[0] instanceof Boolean)) + throw new IllegalArgumentException("Expected Boolean got " + (args.length == 0 ? "nil" : args[0].getClass().getSimpleName())); + flowOverridden = (Boolean) args[0]; + if (!worldObj.isRemote) sendObjectToClient(References.BOOLEAN_ID, 2, flowOverridden); + } else if (method.equals("getOverrideEnabled")) { + return new Object[]{flowOverridden}; + } else if (method.equals("setFlowOverride")) { + if (args.length == 0 || !(args[0] instanceof Number)) + throw new IllegalArgumentException("Expected Number got " + (args.length == 0 ? "nil" : args[0].getClass().getSimpleName())); + flowOverride = Utills.toInt((Double) args[0]); + if (!worldObj.isRemote) sendObjectToClient(References.INT_ID, 3, flowOverride); + } else if (method.equals("setSignalHighFlow")) { + if (args.length == 0 || !(args[0] instanceof Number)) + throw new IllegalArgumentException("Expected Number got " + (args.length == 0 ? "nil" : args[0].getClass().getSimpleName())); + flowRSHigh = Utills.toInt((Double) args[0]); + if (!worldObj.isRemote) sendObjectToClient(References.INT_ID, 4, flowRSHigh); + } else if (method.equals("getSignalHighFlow")) { + return new Object[]{flowRSHigh}; + } else if (method.equals("setSignalLowFlow")) { + if (args.length == 0 || !(args[0] instanceof Number)) + throw new IllegalArgumentException("Expected Number got " + (args.length == 0 ? "nil" : args[0].getClass().getSimpleName())); + flowRSLow = Utills.toInt((Double) args[0]); + if (!worldObj.isRemote) sendObjectToClient(References.INT_ID, 5, flowRSLow); + } else if (method.equals("getSignalLowFlow")) { + return new Object[]{flowRSLow}; + } - return new Object[0]; - } + return new Object[0]; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileDislocatorReceptacle.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileDislocatorReceptacle.java index 15496455..783ffcef 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileDislocatorReceptacle.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileDislocatorReceptacle.java @@ -17,197 +17,191 @@ import net.minecraft.tileentity.TileEntity; */ public class TileDislocatorReceptacle extends TileEntity implements IInventory { - private ItemStack dislocator; - public PortalHelper.PortalStructure structure = null; - public boolean isActive = false; - public boolean updating = false; - public int coolDown = 0; - public int ticksTillStart = -1; + private ItemStack dislocator; + public PortalHelper.PortalStructure structure = null; + public boolean isActive = false; + public boolean updating = false; + public int coolDown = 0; + public int ticksTillStart = -1; - @Override - public void updateEntity() { - if (worldObj.isRemote) return; - if (coolDown > 0) coolDown--; - if (ticksTillStart > -1) ticksTillStart--; - if (ticksTillStart == 0) worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord), 1); - } + @Override + public void updateEntity() { + if (worldObj.isRemote) return; + if (coolDown > 0) coolDown--; + if (ticksTillStart > -1) ticksTillStart--; + if (ticksTillStart == 0) + worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord), 1); + } - public void validateActivePortal() { - if (updating) return; - if (structure == null) { - isActive = false; - return; - } - isActive = structure.checkFrameIsValid(worldObj, xCoord, yCoord, zCoord) && structure.scanPortal(worldObj, xCoord, yCoord, zCoord, false, true); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } + public void validateActivePortal() { + if (updating) return; + if (structure == null) { + isActive = false; + return; + } + isActive = structure.checkFrameIsValid(worldObj, xCoord, yCoord, zCoord) && structure.scanPortal(worldObj, xCoord, yCoord, zCoord, false, true); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } - public void updateState(){ - if (structure == null || !isActive) structure = PortalHelper.getValidStructure(worldObj, xCoord, yCoord, zCoord); - if (structure == null) { - isActive = false; - worldObj.notifyBlockChange(xCoord, yCoord, zCoord, blockType); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - return; - } + public void updateState() { + if (structure == null || !isActive) + structure = PortalHelper.getValidStructure(worldObj, xCoord, yCoord, zCoord); + if (structure == null) { + isActive = false; + worldObj.notifyBlockChange(xCoord, yCoord, zCoord, blockType); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return; + } - if (isActive){ - if (getStackInSlot(0) == null || !structure.checkFrameIsValid(worldObj, xCoord, yCoord, zCoord)) isActive = false; - }else { - boolean frameValid = structure.checkFrameIsValid(worldObj, xCoord, yCoord, zCoord); - boolean portalEmpty = structure.scanPortal(worldObj, xCoord, yCoord, zCoord, false, false); + if (isActive) { + if (getStackInSlot(0) == null || !structure.checkFrameIsValid(worldObj, xCoord, yCoord, zCoord)) + isActive = false; + } else { + boolean frameValid = structure.checkFrameIsValid(worldObj, xCoord, yCoord, zCoord); + boolean portalEmpty = structure.scanPortal(worldObj, xCoord, yCoord, zCoord, false, false); - if (getLocation() != null && frameValid && portalEmpty) - { - isActive = true; - structure.scanPortal(worldObj, xCoord, yCoord, zCoord, true, false); - } - } - worldObj.notifyBlockChange(xCoord, yCoord, zCoord, blockType); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } + if (getLocation() != null && frameValid && portalEmpty) { + isActive = true; + structure.scanPortal(worldObj, xCoord, yCoord, zCoord, true, false); + } + } + worldObj.notifyBlockChange(xCoord, yCoord, zCoord, blockType); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } - public Teleporter.TeleportLocation getLocation(){ - if (getStackInSlot(0) != null && getStackInSlot(0).getItem() instanceof TeleporterMKI) return ((TeleporterMKI)getStackInSlot(0).getItem()).getLocation(getStackInSlot(0)); - return null; - } + public Teleporter.TeleportLocation getLocation() { + if (getStackInSlot(0) != null && getStackInSlot(0).getItem() instanceof TeleporterMKI) + return ((TeleporterMKI) getStackInSlot(0).getItem()).getLocation(getStackInSlot(0)); + return null; + } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setBoolean("IsActive", isActive); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setBoolean("IsActive", isActive); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - isActive = pkt.func_148857_g().getBoolean("IsActive"); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + isActive = pkt.func_148857_g().getBoolean("IsActive"); + } - @Override - public int getSizeInventory() - { - return 1; - } + @Override + public int getSizeInventory() { + return 1; + } - @Override - public ItemStack getStackInSlot(int i) - { - return i == 0 ? dislocator : null; - } + @Override + public ItemStack getStackInSlot(int i) { + return i == 0 ? dislocator : null; + } - @Override - public ItemStack decrStackSize(int i, int count) { - ItemStack itemstack = getStackInSlot(i); + @Override + public ItemStack decrStackSize(int i, int count) { + ItemStack itemstack = getStackInSlot(i); - if (itemstack != null) - { - if (itemstack.stackSize <= count) - { - setInventorySlotContents(i, null); - } else - { - itemstack = itemstack.splitStack(count); - if (itemstack.stackSize == 0) - { - setInventorySlotContents(i, null); - } - } - } - if (isActive) updateState(); - else ticksTillStart = 1; - return itemstack; - } + if (itemstack != null) { + if (itemstack.stackSize <= count) { + setInventorySlotContents(i, null); + } else { + itemstack = itemstack.splitStack(count); + if (itemstack.stackSize == 0) { + setInventorySlotContents(i, null); + } + } + } + if (isActive) updateState(); + else ticksTillStart = 1; + return itemstack; + } - @Override - public ItemStack getStackInSlotOnClosing(int i) { - ItemStack item = getStackInSlot(i); - if (item != null) setInventorySlotContents(i, null); - return item; - } + @Override + public ItemStack getStackInSlotOnClosing(int i) { + ItemStack item = getStackInSlot(i); + if (item != null) setInventorySlotContents(i, null); + return item; + } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - if (i != 0) return; - dislocator = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - { - itemstack.stackSize = getInventoryStackLimit(); - } - if (isActive) updateState(); - else ticksTillStart = 1; - } + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + if (i != 0) return; + dislocator = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + if (isActive) updateState(); + else ticksTillStart = 1; + } - @Override - public String getInventoryName() - { - return ""; - } + @Override + public String getInventoryName() { + return ""; + } - @Override - public boolean hasCustomInventoryName() - { - return false; - } + @Override + public boolean hasCustomInventoryName() { + return false; + } - @Override - public int getInventoryStackLimit() - { - return 1; - } + @Override + public int getInventoryStackLimit() { + return 1; + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - if (worldObj == null) - { - return true; - } - if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) - { - return false; - } - return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; - } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + if (worldObj == null) { + return true; + } + if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { + return false; + } + return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; + } - @Override - public void openInventory() {} + @Override + public void openInventory() { + } - @Override - public void closeInventory() {} + @Override + public void closeInventory() { + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return itemstack != null && itemstack.getItem() instanceof TeleporterMKI && ((TeleporterMKI)itemstack.getItem()).getLocation(itemstack) != null; - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return itemstack != null && itemstack.getItem() instanceof TeleporterMKI && ((TeleporterMKI) itemstack.getItem()).getLocation(itemstack) != null; + } - @Override - public void writeToNBT(NBTTagCompound compound) { - compound.setBoolean("IsActive", isActive); + @Override + public void writeToNBT(NBTTagCompound compound) { + compound.setBoolean("IsActive", isActive); - if (dislocator != null) { - NBTTagCompound stack = new NBTTagCompound(); - dislocator.writeToNBT(stack); - compound.setTag("Dislocator", stack); - } + if (dislocator != null) { + NBTTagCompound stack = new NBTTagCompound(); + dislocator.writeToNBT(stack); + compound.setTag("Dislocator", stack); + } - if (structure != null){ - compound.setBoolean("HasStructure", true); - structure.writeToNBT(compound); - } + if (structure != null) { + compound.setBoolean("HasStructure", true); + structure.writeToNBT(compound); + } - super.writeToNBT(compound); - } + super.writeToNBT(compound); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - isActive = compound.getBoolean("IsActive"); + @Override + public void readFromNBT(NBTTagCompound compound) { + isActive = compound.getBoolean("IsActive"); - if (compound.hasKey("Dislocator")) dislocator = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("Dislocator")); + if (compound.hasKey("Dislocator")) + dislocator = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("Dislocator")); - if (compound.hasKey("HasStructure")) { - structure = new PortalHelper.PortalStructure(); - structure.readFromNBT(compound); - } - super.readFromNBT(compound); - } + if (compound.hasKey("HasStructure")) { + structure = new PortalHelper.PortalStructure(); + structure.readFromNBT(compound); + } + super.readFromNBT(compound); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnderResurrection.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnderResurrection.java index 753dc504..9369792a 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnderResurrection.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnderResurrection.java @@ -27,362 +27,353 @@ import java.util.Random; /** * Created by Brandon on 8/08/2014. */ -public class TileEnderResurrection extends TileEntity{ +public class TileEnderResurrection extends TileEntity { - private MultiblockHelper.TileLocation diamondPillars[] = new MultiblockHelper.TileLocation[4]; - private MultiblockHelper.TileLocation draconiumPillars[] = new MultiblockHelper.TileLocation[4]; - private ExtendedPlayer playerProps; - private EntityPlayer owner; - private boolean spawnInProgress = false; - private int timer = 0; - private double level = 0; + private MultiblockHelper.TileLocation diamondPillars[] = new MultiblockHelper.TileLocation[4]; + private MultiblockHelper.TileLocation draconiumPillars[] = new MultiblockHelper.TileLocation[4]; + private ExtendedPlayer playerProps; + private EntityPlayer owner; + private boolean spawnInProgress = false; + private int timer = 0; + private double level = 0; - public TileEnderResurrection(){ - for (int i = 0; i < diamondPillars.length; i++) - { - diamondPillars[i] = new MultiblockHelper.TileLocation(); - } - for (int i = 0; i < draconiumPillars.length; i++) - { - draconiumPillars[i] = new MultiblockHelper.TileLocation(); - } - } + public TileEnderResurrection() { + for (int i = 0; i < diamondPillars.length; i++) { + diamondPillars[i] = new MultiblockHelper.TileLocation(); + } + for (int i = 0; i < draconiumPillars.length; i++) { + draconiumPillars[i] = new MultiblockHelper.TileLocation(); + } + } - @Override - public void updateEntity() { - if (spawnInProgress){ - //if (timer < 1800) timer = 2200; - if (!arePillarsValid() || !isBaseValid()) spawnInProgress = false; - effectDrive(); - findAndActivateChrystals(timer - 200, true); - if (timer > 2390 && arePillarsValid() && isBaseValid()) { - spawn(); - spawnInProgress = false; - } - if (timer < 556 || timer > 2300) timer++; - else timer += 2; - if (ConfigHandler.sumonRitualAccelerated) timer += 20; - } - } + @Override + public void updateEntity() { + if (spawnInProgress) { + //if (timer < 1800) timer = 2200; + if (!arePillarsValid() || !isBaseValid()) spawnInProgress = false; + effectDrive(); + findAndActivateChrystals(timer - 200, true); + if (timer > 2390 && arePillarsValid() && isBaseValid()) { + spawn(); + spawnInProgress = false; + } + if (timer < 556 || timer > 2300) timer++; + else timer += 2; + if (ConfigHandler.sumonRitualAccelerated) timer += 20; + } + } - private void spawn(){ - if (owner == null) return; - for (int i = 0; i < diamondPillars.length; i++){ - if (diamondPillars[i] == null) return; - worldObj.setBlockToAir(diamondPillars[i].getXCoord(), diamondPillars[i].getYCoord(), diamondPillars[i].getZCoord()); - if (!worldObj.isRemote) worldObj.createExplosion(owner, diamondPillars[i].getXCoord() + 0.5, diamondPillars[i].getYCoord() + 0.5, diamondPillars[i].getZCoord() + 0.5, 3, true); - } - for (int i = 0; i < draconiumPillars.length; i++){ - if (draconiumPillars[i] == null) return; - worldObj.setBlockToAir(draconiumPillars[i].getXCoord(), draconiumPillars[i].getYCoord(), draconiumPillars[i].getZCoord()); - if (!worldObj.isRemote) worldObj.createExplosion(owner, draconiumPillars[i].getXCoord() + 0.5, draconiumPillars[i].getYCoord() + 0.5, draconiumPillars[i].getZCoord() + 0.5, 3, true); - } + private void spawn() { + if (owner == null) return; + for (int i = 0; i < diamondPillars.length; i++) { + if (diamondPillars[i] == null) return; + worldObj.setBlockToAir(diamondPillars[i].getXCoord(), diamondPillars[i].getYCoord(), diamondPillars[i].getZCoord()); + if (!worldObj.isRemote) + worldObj.createExplosion(owner, diamondPillars[i].getXCoord() + 0.5, diamondPillars[i].getYCoord() + 0.5, diamondPillars[i].getZCoord() + 0.5, 3, true); + } + for (int i = 0; i < draconiumPillars.length; i++) { + if (draconiumPillars[i] == null) return; + worldObj.setBlockToAir(draconiumPillars[i].getXCoord(), draconiumPillars[i].getYCoord(), draconiumPillars[i].getZCoord()); + if (!worldObj.isRemote) + worldObj.createExplosion(owner, draconiumPillars[i].getXCoord() + 0.5, draconiumPillars[i].getYCoord() + 0.5, draconiumPillars[i].getZCoord() + 0.5, 3, true); + } - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - if (!worldObj.isRemote) worldObj.createExplosion(owner, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 3, true); - if (!worldObj.isRemote) worldObj.createExplosion(null, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, 10, false); + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + if (!worldObj.isRemote) worldObj.createExplosion(owner, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 3, true); + if (!worldObj.isRemote) worldObj.createExplosion(null, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, 10, false); - if (level > 10) level = 10; - EntityCustomDragon dragon = new EntityCustomDragon(worldObj, 200D + level * 50, 10F + (float)level * 5F); - dragon.setPosition(xCoord, yCoord + 60, zCoord); - dragon.onSpawnWithEgg(null); - if (!worldObj.isRemote) - worldObj.spawnEntityInWorld(dragon); - playerProps.setSpawnCount(playerProps.getSpawnCount()+1); + if (level > 10) level = 10; + EntityCustomDragon dragon = new EntityCustomDragon(worldObj, 200D + level * 50, 10F + (float) level * 5F); + dragon.setPosition(xCoord, yCoord + 60, zCoord); + dragon.onSpawnWithEgg(null); + if (!worldObj.isRemote) worldObj.spawnEntityInWorld(dragon); + playerProps.setSpawnCount(playerProps.getSpawnCount() + 1); - } + } - private void lEffects() { - int x = -100+worldObj.rand.nextInt(200); - int z = -100+worldObj.rand.nextInt(200); - EntityLightningBolt bolt = new EntityLightningBolt(worldObj, x, worldObj.getTopSolidOrLiquidBlock(z, z)-1, z); - if (!worldObj.isRemote) - worldObj.addWeatherEffect(bolt); - EntityPlayer p = worldObj.getClosestPlayer(xCoord, yCoord, zCoord, 100); - float yaw = p.rotationYaw; - float pitch = p.rotationPitch; - float mod = 0.1F; - yaw += worldObj.rand.nextBoolean() ? mod : -mod; - pitch += worldObj.rand.nextBoolean() ? mod : -mod; - //yaw += (-0.5F+worldObj.rand.nextFloat())*mod; - //pitch += (-0.5F+worldObj.rand.nextFloat())*mod; - if (worldObj.isRemote) - p.setLocationAndAngles(p.posX, p.posY-1.6, p.posZ, yaw, pitch); - } + private void lEffects() { + int x = -100 + worldObj.rand.nextInt(200); + int z = -100 + worldObj.rand.nextInt(200); + EntityLightningBolt bolt = new EntityLightningBolt(worldObj, x, worldObj.getTopSolidOrLiquidBlock(z, z) - 1, z); + if (!worldObj.isRemote) worldObj.addWeatherEffect(bolt); + EntityPlayer p = worldObj.getClosestPlayer(xCoord, yCoord, zCoord, 100); + float yaw = p.rotationYaw; + float pitch = p.rotationPitch; + float mod = 0.1F; + yaw += worldObj.rand.nextBoolean() ? mod : -mod; + pitch += worldObj.rand.nextBoolean() ? mod : -mod; + //yaw += (-0.5F+worldObj.rand.nextFloat())*mod; + //pitch += (-0.5F+worldObj.rand.nextFloat())*mod; + if (worldObj.isRemote) p.setLocationAndAngles(p.posX, p.posY - 1.6, p.posZ, yaw, pitch); + } - private void effectDrive(){ - if (timer == 1 || worldObj.rand.nextInt(50) == 0) randomBolt(); - if (timer > 100 && worldObj.rand.nextInt(Math.max(1, 50 - (timer/40))) == 0) randomBolt(); + private void effectDrive() { + if (timer == 1 || worldObj.rand.nextInt(50) == 0) randomBolt(); + if (timer > 100 && worldObj.rand.nextInt(Math.max(1, 50 - (timer / 40))) == 0) randomBolt(); - if (timer == 10 || timer == 20 || timer == 30 || timer == 40) draconiumStrikes(timer/10); - if (worldObj.rand.nextInt(50) == 0) draconiumStrikes(worldObj.rand.nextInt(4) + 1); + if (timer == 10 || timer == 20 || timer == 30 || timer == 40) draconiumStrikes(timer / 10); + if (worldObj.rand.nextInt(50) == 0) draconiumStrikes(worldObj.rand.nextInt(4) + 1); - if (timer > 60 && worldObj.isRemote) coreParticles(); + if (timer > 60 && worldObj.isRemote) coreParticles(); - findAndActivateChrystals(timer, false); - findAndActivateChrystals(timer - 50, false); - findAndActivateChrystals(timer - 100, false); + findAndActivateChrystals(timer, false); + findAndActivateChrystals(timer - 50, false); + findAndActivateChrystals(timer - 100, false); - - //if (timer == 1) worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:boom", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F); - //if (timer == 1 || worldObj.rand.nextInt(50) == 0) worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "ambient.weather.thunder", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F); + //if (timer == 1) worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:boom", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F); + //if (timer == 1 || worldObj.rand.nextInt(50) == 0) worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "ambient.weather.thunder", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F); + if (worldObj.rand.nextInt(50) == 0 && timer < 300) centreStrike(); + } + + private void draconiumStrikes(int pillar) { + if (pillar != 1 && pillar != 2 && pillar != 3 && pillar != 4) return; + pillar--; + if (draconiumPillars[pillar] == null) return; + EntityLightningBolt bolt = new EntityLightningBolt(worldObj, draconiumPillars[pillar].getXCoord(), draconiumPillars[pillar].getYCoord(), draconiumPillars[pillar].getZCoord()); + if (!worldObj.isRemote) worldObj.addWeatherEffect(bolt); + } + + private void findAndActivateChrystals(int y, boolean spawnCrystal) { + if (worldObj.isRemote) return; + if (y < 0 || y > 250) return; + for (int x = -200; x < 200; x++) { + for (int z = -200; z < 200; z++) { + if (worldObj.getBlock(x, y, z) == Blocks.bedrock) { + boolean flag = true; + for (int x1 = x - 1; x1 <= x + 1; x1++) { + for (int y1 = y - 1; y1 <= y + 1; y1++) { + for (int z1 = z - 1; z1 <= z + 1; z1++) { + if ((x1 != x || y1 != y || z1 != z) && worldObj.getBlock(x1, y1, z1) == Blocks.bedrock) + flag = false; + } + } + } + + if (flag && !worldObj.isRemote) { + if (spawnCrystal) { + //EntityEnderCrystal crystal = new EntityEnderCrystal(worldObj); + //crystal.setPosition(x + 0.5, y + 1, z + 0.5); + //worldObj.spawnEntityInWorld(crystal); + + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setString("id", "EnderCrystal"); + Entity crystal = EntityList.createEntityFromNBT(nbttagcompound, worldObj); + crystal.setPosition(x + 0.5, y + 1, z + 0.5); + worldObj.spawnEntityInWorld(crystal); + } else worldObj.addWeatherEffect(new EntityLightningBolt(worldObj, x, y + 1, z)); + } + } + } + } + } + + private void centreStrike() { + EntityLightningBolt bolt = new EntityLightningBolt(worldObj, xCoord, yCoord, zCoord); + if (!worldObj.isRemote) worldObj.addWeatherEffect(bolt); + } + + private void randomBolt() { + int x = -100 + worldObj.rand.nextInt(200); + int z = -100 + worldObj.rand.nextInt(200); + EntityLightningBolt bolt = new EntityLightningBolt(worldObj, x, worldObj.getTopSolidOrLiquidBlock(z, z) - 1, z); + if (!worldObj.isRemote) worldObj.addWeatherEffect(bolt); + } + + public boolean onActivated(EntityPlayer player) { + boolean flag = true; + if (worldObj.provider.dimensionId != 1) { + if (worldObj.isRemote) + player.addChatComponentMessage(new ChatComponentTranslation("msg.SpawnDragonMustBeInTheEnd.txt")); + return true; + } + if (xCoord > 100 || zCoord > 100 || xCoord < -100 || zCoord < -100) { + if (worldObj.isRemote) + player.addChatComponentMessage(new ChatComponentTranslation("msg.SpawnDragonToFarFrom00.txt")); + return false; + } + playerProps = ExtendedPlayer.get(player); + owner = player; + + if (spawnInProgress) { + for (int i = 0; i < draconiumPillars.length; i++) { + if (draconiumPillars[i] == null || !arePillarsValid()) return false; + worldObj.setBlock(draconiumPillars[i].getXCoord(), draconiumPillars[i].getYCoord(), draconiumPillars[i].getZCoord(), ModBlocks.draconiumBlock); + } + flag = false; + } + if (!isBaseValid()) flag = false; + if (!findPillars()) flag = false; + if (!arePillarsValid()) flag = false; + + if (!spawnInProgress && flag) timer = 0; + + spawnInProgress = flag; + level = (double) playerProps.getSpawnCount() / 2D; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + if (flag && !worldObj.isRemote) LogHelper.info("Starting Ritual of Ender Resurrection (Level " + level + ")"); + return flag; + } + + private boolean isBaseValid() { + if (worldObj.getBlock(xCoord + 1, yCoord, zCoord) != Blocks.obsidian || worldObj.getBlock(xCoord - 1, yCoord, zCoord) != Blocks.obsidian || worldObj.getBlock(xCoord, yCoord, zCoord + 1) != Blocks.obsidian || worldObj.getBlock(xCoord, yCoord, zCoord - 1) != Blocks.obsidian) + return false; + if (worldObj.getBlock(xCoord + 1, yCoord, zCoord + 1) != Blocks.glowstone || worldObj.getBlock(xCoord - 1, yCoord, zCoord - 1) != Blocks.glowstone || worldObj.getBlock(xCoord - 1, yCoord, zCoord + 1) != Blocks.glowstone || worldObj.getBlock(xCoord + 1, yCoord, zCoord - 1) != Blocks.glowstone) + return false; + return true; + } + + private boolean arePillarsValid() { + for (int i = 0; i < diamondPillars.length; i++) { + if (diamondPillars[i] == null) return false; + if (worldObj.getBlock(diamondPillars[i].getXCoord(), diamondPillars[i].getYCoord(), diamondPillars[i].getZCoord()) != Blocks.diamond_block || worldObj.getBlock(diamondPillars[i].getXCoord(), diamondPillars[i].getYCoord() - 1, diamondPillars[i].getZCoord()) != Blocks.quartz_block) + return false; + } + for (int i = 0; i < draconiumPillars.length; i++) { + if (draconiumPillars[i] == null) return false; + if ((worldObj.getBlock(draconiumPillars[i].getXCoord(), draconiumPillars[i].getYCoord(), draconiumPillars[i].getZCoord()) != ModBlocks.draconiumBlock && worldObj.getBlockMetadata(draconiumPillars[i].getXCoord(), draconiumPillars[i].getYCoord(), draconiumPillars[i].getZCoord()) != 2) || worldObj.getBlock(draconiumPillars[i].getXCoord(), draconiumPillars[i].getYCoord() - 1, draconiumPillars[i].getZCoord()) != Blocks.quartz_block || worldObj.getBlock(draconiumPillars[i].getXCoord(), draconiumPillars[i].getYCoord() - 2, draconiumPillars[i].getZCoord()) != Blocks.quartz_block) + return false; + } + return true; + } + + private boolean findPillars() { + int xzRange = 6; + int draconiumCount = 0; + int diamondCount = 0; + for (int x = xCoord - xzRange; x < xCoord + xzRange; x++) { + for (int y = yCoord + 2; y < yCoord + 5; y++) { + for (int z = zCoord - xzRange; z < zCoord + xzRange; z++) { + if (worldObj.getBlock(x, y, z) == ModBlocks.draconiumBlock && isPillarValid(0, x, y, z) && worldObj.getBlockMetadata(x, y, z) == 2 && draconiumCount < 4) { + draconiumPillars[draconiumCount] = new MultiblockHelper.TileLocation(x, y, z); + draconiumCount++; + } + } + } + } + + for (int x = xCoord - xzRange; x < xCoord + xzRange; x++) { + for (int y = yCoord + 1; y < yCoord + 4; y++) { + for (int z = zCoord - xzRange; z < zCoord + xzRange; z++) { + if (worldObj.getBlock(x, y, z) == Blocks.diamond_block && isPillarValid(1, x, y, z) && diamondCount < 4) { + diamondPillars[diamondCount] = new MultiblockHelper.TileLocation(x, y, z); + diamondCount++; + } + } + } + } + return draconiumCount == 4 && diamondCount == 4; + } + + @SideOnly(Side.CLIENT) + private void coreParticles() { + Random rand = new Random(); + { + float mM = 0.4F; + for (int i = 0; i < draconiumPillars.length; i++) { + if (draconiumPillars[i] == null) return; + AdvancedSeekerParticle particle = new AdvancedSeekerParticle(worldObj, draconiumPillars[i].getXCoord() + 0.5, draconiumPillars[i].getYCoord() + 0.5, draconiumPillars[i].getZCoord() + 0.5, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 2, 0F, 1.0F, 1.0F, 100); + AdvancedSeekerParticle particle2; + if (timer < 300) + particle2 = new AdvancedSeekerParticle(worldObj, draconiumPillars[i].getXCoord() + 0.5, draconiumPillars[i].getYCoord() + 0.5, draconiumPillars[i].getZCoord() + 0.5, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 1, 1F, 0.0F, 0F, 40); + else { + particle2 = new AdvancedSeekerParticle(worldObj, draconiumPillars[i].getXCoord() + 0.5, draconiumPillars[i].getYCoord() + 0.5, draconiumPillars[i].getZCoord() + 0.5, xCoord + rand.nextFloat(), yCoord + 3 + rand.nextFloat(), zCoord + rand.nextFloat(), 3, 1F, 0.0F, 0F, 70, timer); + } + if (timer > 2000) { + AdvancedSeekerParticle toDiamond = new AdvancedSeekerParticle(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, diamondPillars[i].getXCoord() + rand.nextFloat(), diamondPillars[i].getYCoord() + rand.nextFloat(), diamondPillars[i].getZCoord() + rand.nextFloat(), 3, 0, 1, 0, 100); + ParticleHandler.spawnCustomParticle(toDiamond, 250); + if (timer > 2100) { + AdvancedSeekerParticle toSpawn = new AdvancedSeekerParticle(worldObj, diamondPillars[i].getXCoord() + rand.nextFloat(), diamondPillars[i].getYCoord() + rand.nextFloat(), diamondPillars[i].getZCoord() + rand.nextFloat(), xCoord - 3.5 + (double) (rand.nextFloat() * 7F), yCoord + 60 + rand.nextInt(5), zCoord - 3.5 + (double) (rand.nextFloat() * 7F), 3, 0F, 1F, 0F, 100, timer); + ParticleHandler.spawnCustomParticle(toSpawn, 250); + } + } + particle.motionX = (rand.nextFloat() - 0.5) * mM; + particle.motionZ = (rand.nextFloat() - 0.5) * mM; + particle2.motionX = (rand.nextFloat() - 0.5) * mM; + particle2.motionZ = (rand.nextFloat() - 0.5) * mM; + ParticleHandler.spawnCustomParticle(particle, 250); + ParticleHandler.spawnCustomParticle(particle2, 250); + } - if (worldObj.rand.nextInt(50) == 0 && timer < 300) centreStrike(); - } + if (timer > 300) { + int t; + if (timer > 700) t = timer; + else t = 700; + AdvancedSeekerParticle particle3 = new AdvancedSeekerParticle(worldObj, xCoord + rand.nextFloat(), yCoord + 0.5, zCoord + rand.nextFloat(), xCoord + rand.nextFloat(), yCoord + 3 + rand.nextFloat(), zCoord + rand.nextFloat(), 3, 0F, 1.0F, 1.0F, 70, t); + ParticleHandler.spawnCustomParticle(particle3, 250); + } + if (timer > 1000) { + float red; + float green; + float blue; + float f = rand.nextFloat() * 0.6F + 0.4F; + red = green = blue = 1.0F * f; + green *= 0.3F; + red *= 0.9F; + AdvancedSeekerParticle particle4 = new AdvancedSeekerParticle(worldObj, xCoord + 0.5, yCoord + 3.5, zCoord + 0.5, xCoord + rand.nextFloat(), yCoord + 3 + rand.nextFloat(), zCoord + rand.nextFloat(), 1, red, green, blue, 100); + particle4.motionX = (rand.nextFloat() - 0.5) * mM; + particle4.motionZ = (rand.nextFloat() - 0.5) * mM; + ParticleHandler.spawnCustomParticle(particle4, 250); + } + } + } - private void draconiumStrikes(int pillar){ - if (pillar != 1 && pillar != 2 && pillar != 3 && pillar != 4) return; - pillar--; - if (draconiumPillars[pillar] == null) return; - EntityLightningBolt bolt = new EntityLightningBolt(worldObj, draconiumPillars[pillar].getXCoord(), draconiumPillars[pillar].getYCoord(), draconiumPillars[pillar].getZCoord()); - if (!worldObj.isRemote) - worldObj.addWeatherEffect(bolt); - } + /** + * Draconium = 0, Diamond = 1 + */ + private boolean isPillarValid(int type, int x, int y, int z) { + if (type == 0) { + if (worldObj.getBlock(x, y - 1, z) == Blocks.quartz_block && worldObj.getBlock(x, y - 2, z) == Blocks.quartz_block && worldObj.getBlockMetadata(x, y - 1, z) == 2 && worldObj.getBlockMetadata(x, y - 2, z) == 2) + return true; + } else if (type == 1) { + if (worldObj.getBlock(x, y - 1, z) == Blocks.quartz_block && worldObj.getBlockMetadata(x, y - 1, z) == 2) + return true; + } + return false; + } - private void findAndActivateChrystals(int y, boolean spawnCrystal){ - if (worldObj.isRemote) return; - if (y < 0 || y > 250) return; - for (int x = -200; x < 200; x++){ - for (int z = -200; z < 200; z++){ - if (worldObj.getBlock(x, y, z) == Blocks.bedrock){ - boolean flag = true; - for (int x1 = x-1; x1 <= x+1; x1++){ - for (int y1 = y-1; y1 <= y+1; y1++){ - for (int z1 = z-1; z1 <= z+1; z1++){ - if ((x1 != x || y1 != y || z1 != z) && worldObj.getBlock(x1, y1, z1) == Blocks.bedrock) flag = false; - } - } - } + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setBoolean("SpawnInProgress", spawnInProgress); + compound.setInteger("Timer", timer); + for (int i = 0; i < diamondPillars.length; i++) { + if (diamondPillars[i] != null) diamondPillars[i].writeToNBT(compound, String.valueOf(i)); + } + for (int i = 0; i < draconiumPillars.length; i++) { + if (draconiumPillars[i] != null) draconiumPillars[i].writeToNBT(compound, "D" + String.valueOf(i)); + } + } - if (flag && !worldObj.isRemote) { - if (spawnCrystal) { - //EntityEnderCrystal crystal = new EntityEnderCrystal(worldObj); - //crystal.setPosition(x + 0.5, y + 1, z + 0.5); - //worldObj.spawnEntityInWorld(crystal); - - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setString("id", "EnderCrystal"); - Entity crystal = EntityList.createEntityFromNBT(nbttagcompound, worldObj); - crystal.setPosition(x + 0.5, y + 1, z + 0.5); - worldObj.spawnEntityInWorld(crystal); - }else - worldObj.addWeatherEffect(new EntityLightningBolt(worldObj, x, y + 1, z)); - } - } - } - } - } - - private void centreStrike(){ - EntityLightningBolt bolt = new EntityLightningBolt(worldObj, xCoord, yCoord, zCoord); - if (!worldObj.isRemote) - worldObj.addWeatherEffect(bolt); - } - - private void randomBolt(){ - int x = -100+worldObj.rand.nextInt(200); - int z = -100+worldObj.rand.nextInt(200); - EntityLightningBolt bolt = new EntityLightningBolt(worldObj, x, worldObj.getTopSolidOrLiquidBlock(z, z)-1, z); - if (!worldObj.isRemote) - worldObj.addWeatherEffect(bolt); - } - - public boolean onActivated(EntityPlayer player){ - boolean flag = true; - if (worldObj.provider.dimensionId != 1) { - if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.SpawnDragonMustBeInTheEnd.txt")); - return true; - } - if (xCoord > 100 || zCoord > 100 || xCoord < -100 || zCoord < -100){ - if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.SpawnDragonToFarFrom00.txt")); - return false; - } - playerProps = ExtendedPlayer.get(player); - owner = player; - - if (spawnInProgress) { - for (int i = 0; i < draconiumPillars.length; i++){ - if (draconiumPillars[i] == null || !arePillarsValid()) return false; - worldObj.setBlock(draconiumPillars[i].getXCoord(), draconiumPillars[i].getYCoord(), draconiumPillars[i].getZCoord(), ModBlocks.draconiumBlock); - } - flag = false; - } - if (!isBaseValid()) flag = false; - if (!findPillars()) flag = false; - if (!arePillarsValid()) flag = false; - - if (!spawnInProgress && flag) timer = 0; - - spawnInProgress = flag; - level = (double)playerProps.getSpawnCount() / 2D; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - if (flag && !worldObj.isRemote) LogHelper.info("Starting Ritual of Ender Resurrection (Level "+level+")"); - return flag; - } - - private boolean isBaseValid(){ - if (worldObj.getBlock(xCoord+1, yCoord, zCoord) != Blocks.obsidian || worldObj.getBlock(xCoord-1, yCoord, zCoord) != Blocks.obsidian || worldObj.getBlock(xCoord, yCoord, zCoord+1) != Blocks.obsidian || worldObj.getBlock(xCoord, yCoord, zCoord-1) != Blocks.obsidian) return false; - if (worldObj.getBlock(xCoord+1, yCoord, zCoord+1) != Blocks.glowstone || worldObj.getBlock(xCoord-1, yCoord, zCoord-1) != Blocks.glowstone || worldObj.getBlock(xCoord-1, yCoord, zCoord+1) != Blocks.glowstone || worldObj.getBlock(xCoord+1, yCoord, zCoord-1) != Blocks.glowstone) return false; - return true; - } - - private boolean arePillarsValid(){ - for (int i = 0; i < diamondPillars.length; i++){ - if (diamondPillars[i] == null) return false; - if (worldObj.getBlock(diamondPillars[i].getXCoord(), diamondPillars[i].getYCoord(), diamondPillars[i].getZCoord()) != Blocks.diamond_block || worldObj.getBlock(diamondPillars[i].getXCoord(), diamondPillars[i].getYCoord()-1, diamondPillars[i].getZCoord()) != Blocks.quartz_block) return false; - } - for (int i = 0; i < draconiumPillars.length; i++){ - if (draconiumPillars[i] == null) return false; - if ((worldObj.getBlock(draconiumPillars[i].getXCoord(), draconiumPillars[i].getYCoord(), draconiumPillars[i].getZCoord()) != ModBlocks.draconiumBlock && worldObj.getBlockMetadata(draconiumPillars[i].getXCoord(), draconiumPillars[i].getYCoord(), draconiumPillars[i].getZCoord()) != 2) || worldObj.getBlock(draconiumPillars[i].getXCoord(), draconiumPillars[i].getYCoord()-1, draconiumPillars[i].getZCoord()) != Blocks.quartz_block || worldObj.getBlock(draconiumPillars[i].getXCoord(), draconiumPillars[i].getYCoord()-2, draconiumPillars[i].getZCoord()) != Blocks.quartz_block) return false; - } - return true; - } - - private boolean findPillars(){ - int xzRange = 6; - int draconiumCount = 0; - int diamondCount = 0; - for (int x = xCoord - xzRange; x < xCoord + xzRange; x++){ - for (int y = yCoord +2; y < yCoord + 5; y++){ - for (int z = zCoord - xzRange; z < zCoord + xzRange; z++){ - if (worldObj.getBlock(x, y, z) == ModBlocks.draconiumBlock && isPillarValid(0, x, y, z) && worldObj.getBlockMetadata(x, y, z) == 2 && draconiumCount < 4){ - draconiumPillars[draconiumCount] = new MultiblockHelper.TileLocation(x, y, z); - draconiumCount++; - } - } - } - } - - for (int x = xCoord - xzRange; x < xCoord + xzRange; x++){ - for (int y = yCoord +1; y < yCoord + 4; y++){ - for (int z = zCoord - xzRange; z < zCoord + xzRange; z++){ - if (worldObj.getBlock(x, y, z) == Blocks.diamond_block && isPillarValid(1, x, y, z) && diamondCount < 4){ - diamondPillars[diamondCount] = new MultiblockHelper.TileLocation(x, y, z); - diamondCount++; - } - } - } - } - return draconiumCount == 4 && diamondCount == 4; - } - - @SideOnly(Side.CLIENT) - private void coreParticles(){ - Random rand = new Random(); - { - float mM = 0.4F; - for (int i = 0; i < draconiumPillars.length; i++){ - if (draconiumPillars[i] == null) return; - AdvancedSeekerParticle particle = new AdvancedSeekerParticle(worldObj, draconiumPillars[i].getXCoord()+0.5, draconiumPillars[i].getYCoord()+0.5, draconiumPillars[i].getZCoord()+0.5, xCoord+0.5, yCoord+0.5, zCoord+0.5, 2, 0F, 1.0F, 1.0F, 100); - AdvancedSeekerParticle particle2; - if (timer < 300) - particle2 = new AdvancedSeekerParticle(worldObj, draconiumPillars[i].getXCoord()+0.5, draconiumPillars[i].getYCoord()+0.5, draconiumPillars[i].getZCoord()+0.5, xCoord+0.5, yCoord+0.5, zCoord+0.5, 1, 1F, 0.0F, 0F, 40); - else { - particle2 = new AdvancedSeekerParticle(worldObj, draconiumPillars[i].getXCoord() + 0.5, draconiumPillars[i].getYCoord() + 0.5, draconiumPillars[i].getZCoord() + 0.5, xCoord + rand.nextFloat(), yCoord + 3 + rand.nextFloat(), zCoord + rand.nextFloat(), 3, 1F, 0.0F, 0F, 70, timer); - } - if (timer > 2000){ - AdvancedSeekerParticle toDiamond = new AdvancedSeekerParticle(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, diamondPillars[i].getXCoord() + rand.nextFloat(), diamondPillars[i].getYCoord() + rand.nextFloat(), diamondPillars[i].getZCoord() + rand.nextFloat(), 3, 0, 1, 0, 100); - ParticleHandler.spawnCustomParticle(toDiamond, 250); - if (timer > 2100){ - AdvancedSeekerParticle toSpawn = new AdvancedSeekerParticle(worldObj, diamondPillars[i].getXCoord() + rand.nextFloat(), diamondPillars[i].getYCoord() + rand.nextFloat(), diamondPillars[i].getZCoord() + rand.nextFloat(), xCoord - 3.5 + (double)(rand.nextFloat()*7F), yCoord+60+rand.nextInt(5), zCoord - 3.5 + (double)(rand.nextFloat()*7F), 3, 0F, 1F, 0F, 100, timer); - ParticleHandler.spawnCustomParticle(toSpawn, 250); - } - } + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + spawnInProgress = compound.getBoolean("SpawnInProgress"); + timer = compound.getInteger("Timer"); + for (int i = 0; i < diamondPillars.length; i++) { + if (diamondPillars[i] != null) diamondPillars[i].readFromNBT(compound, String.valueOf(i)); + } + for (int i = 0; i < draconiumPillars.length; i++) { + if (draconiumPillars[i] != null) draconiumPillars[i].readFromNBT(compound, "D" + String.valueOf(i)); + } + } - particle.motionX = (rand.nextFloat()-0.5)*mM; - particle.motionZ = (rand.nextFloat()-0.5)*mM; - particle2.motionX = (rand.nextFloat()-0.5)*mM; - particle2.motionZ = (rand.nextFloat()-0.5)*mM; - ParticleHandler.spawnCustomParticle(particle, 250); - ParticleHandler.spawnCustomParticle(particle2, 250); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } - if (timer > 300) - { - int t; - if (timer > 700) - t = timer; - else - t = 700; - AdvancedSeekerParticle particle3 = new AdvancedSeekerParticle(worldObj, xCoord + rand.nextFloat(), yCoord + 0.5, zCoord + rand.nextFloat(), xCoord + rand.nextFloat(), yCoord + 3 + rand.nextFloat(), zCoord + rand.nextFloat(), 3, 0F, 1.0F, 1.0F, 70, t); - ParticleHandler.spawnCustomParticle(particle3, 250); - } - if (timer > 1000){ - float red; - float green; - float blue; - float f = rand.nextFloat() * 0.6F + 0.4F; - red = green = blue = 1.0F * f; - green *= 0.3F; - red *= 0.9F; - AdvancedSeekerParticle particle4 = new AdvancedSeekerParticle(worldObj, xCoord + 0.5, yCoord + 3.5, zCoord + 0.5, xCoord + rand.nextFloat(), yCoord + 3 + rand.nextFloat(), zCoord + rand.nextFloat(), 1, red, green, blue, 100); - particle4.motionX = (rand.nextFloat()-0.5)*mM; - particle4.motionZ = (rand.nextFloat()-0.5)*mM; - ParticleHandler.spawnCustomParticle(particle4, 250); - } - } - } - - /**Draconium = 0, Diamond = 1*/ - private boolean isPillarValid(int type, int x, int y, int z){ - if (type == 0) - { - if (worldObj.getBlock(x, y-1, z) == Blocks.quartz_block && worldObj.getBlock(x, y-2, z) == Blocks.quartz_block && worldObj.getBlockMetadata(x, y-1, z) == 2 && worldObj.getBlockMetadata(x, y-2, z) == 2) return true; - }else if (type == 1) - { - if (worldObj.getBlock(x, y-1, z) == Blocks.quartz_block && worldObj.getBlockMetadata(x, y-1, z) == 2) return true; - } - return false; - } - - @Override - public void writeToNBT(NBTTagCompound compound) { - super.writeToNBT(compound); - compound.setBoolean("SpawnInProgress", spawnInProgress); - compound.setInteger("Timer", timer); - for (int i = 0; i < diamondPillars.length; i++){ - if (diamondPillars[i] != null) - diamondPillars[i].writeToNBT(compound, String.valueOf(i)); - } - for (int i = 0; i < draconiumPillars.length; i++){ - if (draconiumPillars[i] != null) - draconiumPillars[i].writeToNBT(compound, "D"+String.valueOf(i)); - } - } - - @Override - public void readFromNBT(NBTTagCompound compound) { - super.readFromNBT(compound); - spawnInProgress = compound.getBoolean("SpawnInProgress"); - timer = compound.getInteger("Timer"); - for (int i = 0; i < diamondPillars.length; i++){ - if (diamondPillars[i] != null) - diamondPillars[i].readFromNBT(compound, String.valueOf(i)); - } - for (int i = 0; i < draconiumPillars.length; i++){ - if (draconiumPillars[i] != null) - draconiumPillars[i].readFromNBT(compound, "D"+String.valueOf(i)); - } - } - - - @Override - public Packet getDescriptionPacket() { - NBTTagCompound tagCompound = new NBTTagCompound(); - writeToNBT(tagCompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); - } - - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyPylon.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyPylon.java index e227dd8f..91267c63 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyPylon.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyPylon.java @@ -29,332 +29,336 @@ import java.util.Random; * Created by Brandon on 28/07/2014. */ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, IExtendedRFStorage, IDEPeripheral { - public boolean active = false; - public boolean lastTickActive = false; - public boolean reciveEnergy = false; //Power Flow to system - public boolean lastTickReciveEnergy = false; - public float modelRotation = 0; - public float modelScale = 0; - private List coreLocatios = new ArrayList(); - private int selectedCore = 0; - private byte particleRate = 0; - private byte lastTickParticleRate = 0; - private int lastCheckCompOverride = 0; - private int tick = 0; + public boolean active = false; + public boolean lastTickActive = false; + public boolean reciveEnergy = false; //Power Flow to system + public boolean lastTickReciveEnergy = false; + public float modelRotation = 0; + public float modelScale = 0; + private List coreLocatios = new ArrayList(); + private int selectedCore = 0; + private byte particleRate = 0; + private byte lastTickParticleRate = 0; + private int lastCheckCompOverride = 0; + private int tick = 0; - @Override - public void updateEntity() { - if (active && worldObj.isRemote) { - modelRotation += 1.5; - modelScale += !reciveEnergy ? -0.01F : 0.01F; - if ((modelScale < 0 && !reciveEnergy)) modelScale = 10000F; - if ((modelScale < 0 && reciveEnergy)) modelScale = 0F; - spawnParticles(); - } else if (worldObj.isRemote) modelScale = 0.5F; + @Override + public void updateEntity() { + if (active && worldObj.isRemote) { + modelRotation += 1.5; + modelScale += !reciveEnergy ? -0.01F : 0.01F; + if ((modelScale < 0 && !reciveEnergy)) modelScale = 10000F; + if ((modelScale < 0 && reciveEnergy)) modelScale = 0F; + spawnParticles(); + } else if (worldObj.isRemote) modelScale = 0.5F; - if (worldObj.isRemote) return; + if (worldObj.isRemote) return; - tick++; - if (tick % 20 == 0) - { - int cOut = (int)(getEnergyStored() / getMaxEnergyStored() * 15D); - if (cOut != lastCheckCompOverride) - { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord - 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord + 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord + 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord - 1, worldObj.getBlock(xCoord, yCoord, zCoord)); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord + 1, worldObj.getBlock(xCoord, yCoord, zCoord)); - lastCheckCompOverride = cOut; - } - } + tick++; + if (tick % 20 == 0) { + int cOut = (int) (getEnergyStored() / getMaxEnergyStored() * 15D); + if (cOut != lastCheckCompOverride) { + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord - 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord + 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord + 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord - 1, worldObj.getBlock(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord + 1, worldObj.getBlock(xCoord, yCoord, zCoord)); + lastCheckCompOverride = cOut; + } + } - if (active && !reciveEnergy){ - for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { - TileEntity tile = worldObj.getTileEntity(xCoord + d.offsetX, yCoord + d.offsetY, zCoord + d.offsetZ); - if (tile != null && tile instanceof IEnergyReceiver) { - extractEnergy(d, ((IEnergyReceiver)tile).receiveEnergy(d.getOpposite(), extractEnergy(d, Integer.MAX_VALUE, true), false), false); - } - } - } + if (active && !reciveEnergy) { + for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tile = worldObj.getTileEntity(xCoord + d.offsetX, yCoord + d.offsetY, zCoord + d.offsetZ); + if (tile != null && tile instanceof IEnergyReceiver) { + extractEnergy(d, ((IEnergyReceiver) tile).receiveEnergy(d.getOpposite(), extractEnergy(d, Integer.MAX_VALUE, true), false), false); + } + } + } - detectAndSendChanges(); - if (particleRate > 0) particleRate--; - } + detectAndSendChanges(); + if (particleRate > 0) particleRate--; + } - public void onActivated(){ - if (!active){ - active = isValidStructure(); - } - findCores(); - } + public void onActivated() { + if (!active) { + active = isValidStructure(); + } + findCores(); + } - private TileEnergyStorageCore getMaster(){ - if (coreLocatios.isEmpty()) return null; - if (selectedCore >= coreLocatios.size()) selectedCore = coreLocatios.size() - 1; - TileLocation core = coreLocatios.get(selectedCore); - if (core == null || !(worldObj.getTileEntity(core.getXCoord(), core.getYCoord(), core.getZCoord()) instanceof TileEnergyStorageCore)) return null; - return (TileEnergyStorageCore) worldObj.getTileEntity(core.getXCoord(), core.getYCoord(), core.getZCoord()); - } + private TileEnergyStorageCore getMaster() { + if (coreLocatios.isEmpty()) return null; + if (selectedCore >= coreLocatios.size()) selectedCore = coreLocatios.size() - 1; + TileLocation core = coreLocatios.get(selectedCore); + if (core == null || !(worldObj.getTileEntity(core.getXCoord(), core.getYCoord(), core.getZCoord()) instanceof TileEnergyStorageCore)) + return null; + return (TileEnergyStorageCore) worldObj.getTileEntity(core.getXCoord(), core.getYCoord(), core.getZCoord()); + } - private void findCores(){ - int yMod = worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1 ? 15 : -15; - int range = 15; - List locations = new ArrayList(); - for (int x = xCoord-range; x <= xCoord+range; x++){ - for (int y = yCoord+yMod-range; y <= yCoord+yMod+range; y++){ - for (int z = zCoord-range; z <= zCoord+range; z++){ - if (worldObj.getBlock(x, y, z) == ModBlocks.energyStorageCore){ - locations.add(new TileLocation(x, y, z)); - } - } - } - } + private void findCores() { + int yMod = worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1 ? 15 : -15; + int range = 15; + List locations = new ArrayList(); + for (int x = xCoord - range; x <= xCoord + range; x++) { + for (int y = yCoord + yMod - range; y <= yCoord + yMod + range; y++) { + for (int z = zCoord - range; z <= zCoord + range; z++) { + if (worldObj.getBlock(x, y, z) == ModBlocks.energyStorageCore) { + locations.add(new TileLocation(x, y, z)); + } + } + } + } - if (locations != coreLocatios){ - coreLocatios.clear(); - coreLocatios.addAll(locations); - selectedCore = selectedCore >= coreLocatios.size() ? 0 : selectedCore; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } - } + if (locations != coreLocatios) { + coreLocatios.clear(); + coreLocatios.addAll(locations); + selectedCore = selectedCore >= coreLocatios.size() ? 0 : selectedCore; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + } - public void nextCore(){ - findCores(); - selectedCore++; - if (selectedCore >= coreLocatios.size()) selectedCore = 0; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } + public void nextCore() { + findCores(); + selectedCore++; + if (selectedCore >= coreLocatios.size()) selectedCore = 0; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } - @SideOnly(Side.CLIENT) - private void spawnParticles(){ - Random rand = worldObj.rand; - if (getMaster() == null || !getMaster().isOnline()) return; + @SideOnly(Side.CLIENT) + private void spawnParticles() { + Random rand = worldObj.rand; + if (getMaster() == null || !getMaster().isOnline()) return; - int x = getMaster().xCoord; - int y = getMaster().yCoord; - int z = getMaster().zCoord; - int cYCoord = worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1 ? yCoord+1 : yCoord-1; + int x = getMaster().xCoord; + int y = getMaster().yCoord; + int z = getMaster().zCoord; + int cYCoord = worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1 ? yCoord + 1 : yCoord - 1; - float disMod = getMaster().getTier()==0 ? 0.5F : getMaster().getTier()==1 ? 1F: getMaster().getTier()==2 ? 1F : getMaster().getTier()==3 ? 2F : getMaster().getTier()==4 ? 2F : getMaster().getTier()==5 ? 3F : 4F; - double spawnX; - double spawnY; - double spawnZ; - double targetX; - double targetY; - double targetZ; - if (particleRate > 20) particleRate = 20; - if (!reciveEnergy){ - spawnX = x+0.5 - disMod + (rand.nextFloat() * (disMod*2)); - spawnY = y+0.5 - disMod + (rand.nextFloat() * (disMod*2)); - spawnZ = z+0.5 - disMod + (rand.nextFloat() * (disMod*2)); - targetX = xCoord + 0.5; - targetY = cYCoord + 0.5; - targetZ = zCoord + 0.5; - if (rand.nextFloat() < 0.05F) { - Particles.EnergyTransferParticle passiveParticle = new Particles.EnergyTransferParticle(worldObj, spawnX, spawnY, spawnZ, targetX, targetY, targetZ, true); - ParticleHandler.spawnCustomParticle(passiveParticle, 35); - } - if (particleRate > 0){ - if (particleRate > 10) { - for (int i = 0; i <= particleRate/10; i++) { - spawnX = x + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); - spawnY = y + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); - spawnZ = z + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); - Particles.EnergyTransferParticle passiveParticle = new Particles.EnergyTransferParticle(worldObj, spawnX, spawnY, spawnZ, targetX, targetY, targetZ, false); - ParticleHandler.spawnCustomParticle(passiveParticle, 35); - } - }else if (rand.nextInt(Math.max(1, 10 - particleRate)) == 0){ - spawnX = x + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); - spawnY = y + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); - spawnZ = z + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); - Particles.EnergyTransferParticle passiveParticle = new Particles.EnergyTransferParticle(worldObj, spawnX, spawnY, spawnZ, targetX, targetY, targetZ, false); - ParticleHandler.spawnCustomParticle(passiveParticle, 35); - } - } + float disMod = getMaster().getTier() == 0 ? 0.5F : getMaster().getTier() == 1 ? 1F : getMaster().getTier() == 2 ? 1F : getMaster().getTier() == 3 ? 2F : getMaster().getTier() == 4 ? 2F : getMaster().getTier() == 5 ? 3F : 4F; + double spawnX; + double spawnY; + double spawnZ; + double targetX; + double targetY; + double targetZ; + if (particleRate > 20) particleRate = 20; + if (!reciveEnergy) { + spawnX = x + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + spawnY = y + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + spawnZ = z + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + targetX = xCoord + 0.5; + targetY = cYCoord + 0.5; + targetZ = zCoord + 0.5; + if (rand.nextFloat() < 0.05F) { + Particles.EnergyTransferParticle passiveParticle = new Particles.EnergyTransferParticle(worldObj, spawnX, spawnY, spawnZ, targetX, targetY, targetZ, true); + ParticleHandler.spawnCustomParticle(passiveParticle, 35); + } + if (particleRate > 0) { + if (particleRate > 10) { + for (int i = 0; i <= particleRate / 10; i++) { + spawnX = x + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + spawnY = y + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + spawnZ = z + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + Particles.EnergyTransferParticle passiveParticle = new Particles.EnergyTransferParticle(worldObj, spawnX, spawnY, spawnZ, targetX, targetY, targetZ, false); + ParticleHandler.spawnCustomParticle(passiveParticle, 35); + } + } else if (rand.nextInt(Math.max(1, 10 - particleRate)) == 0) { + spawnX = x + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + spawnY = y + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + spawnZ = z + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + Particles.EnergyTransferParticle passiveParticle = new Particles.EnergyTransferParticle(worldObj, spawnX, spawnY, spawnZ, targetX, targetY, targetZ, false); + ParticleHandler.spawnCustomParticle(passiveParticle, 35); + } + } - }else { - targetX = x+0.5 - disMod + (rand.nextFloat() * (disMod*2)); - targetY = y+0.5 - disMod + (rand.nextFloat() * (disMod*2)); - targetZ = z+0.5 - disMod + (rand.nextFloat() * (disMod*2)); - spawnX = xCoord + 0.5; - spawnY = cYCoord + 0.5; - spawnZ = zCoord + 0.5; - if (rand.nextFloat() < 0.05F) { - Particles.EnergyTransferParticle passiveParticle = new Particles.EnergyTransferParticle(worldObj, spawnX, spawnY, spawnZ, targetX, targetY, targetZ, true); - ParticleHandler.spawnCustomParticle(passiveParticle, 35); - } + } else { + targetX = x + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + targetY = y + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + targetZ = z + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + spawnX = xCoord + 0.5; + spawnY = cYCoord + 0.5; + spawnZ = zCoord + 0.5; + if (rand.nextFloat() < 0.05F) { + Particles.EnergyTransferParticle passiveParticle = new Particles.EnergyTransferParticle(worldObj, spawnX, spawnY, spawnZ, targetX, targetY, targetZ, true); + ParticleHandler.spawnCustomParticle(passiveParticle, 35); + } - if (particleRate > 0){ - if (particleRate > 10) { - for (int i = 0; i <= particleRate/10; i++) { - targetX = x+0.5 - disMod + (rand.nextFloat() * (disMod*2)); - targetY = y+0.5 - disMod + (rand.nextFloat() * (disMod*2)); - targetZ = z+0.5 - disMod + (rand.nextFloat() * (disMod*2)); - Particles.EnergyTransferParticle passiveParticle = new Particles.EnergyTransferParticle(worldObj, spawnX, spawnY, spawnZ, targetX, targetY, targetZ, false); - ParticleHandler.spawnCustomParticle(passiveParticle, 35); - } - }else if (rand.nextInt(Math.max(1, 10 - particleRate)) == 0){ - targetX = x+0.5 - disMod + (rand.nextFloat() * (disMod*2)); - targetY = y+0.5 - disMod + (rand.nextFloat() * (disMod*2)); - targetZ = z+0.5 - disMod + (rand.nextFloat() * (disMod*2)); - Particles.EnergyTransferParticle passiveParticle = new Particles.EnergyTransferParticle(worldObj, spawnX, spawnY, spawnZ, targetX, targetY, targetZ, false); - ParticleHandler.spawnCustomParticle(passiveParticle, 35); - } - } - } - } + if (particleRate > 0) { + if (particleRate > 10) { + for (int i = 0; i <= particleRate / 10; i++) { + targetX = x + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + targetY = y + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + targetZ = z + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + Particles.EnergyTransferParticle passiveParticle = new Particles.EnergyTransferParticle(worldObj, spawnX, spawnY, spawnZ, targetX, targetY, targetZ, false); + ParticleHandler.spawnCustomParticle(passiveParticle, 35); + } + } else if (rand.nextInt(Math.max(1, 10 - particleRate)) == 0) { + targetX = x + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + targetY = y + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + targetZ = z + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); + Particles.EnergyTransferParticle passiveParticle = new Particles.EnergyTransferParticle(worldObj, spawnX, spawnY, spawnZ, targetX, targetY, targetZ, false); + ParticleHandler.spawnCustomParticle(passiveParticle, 35); + } + } + } + } - private boolean isValidStructure(){ - return (isGlass(xCoord, yCoord+1, zCoord) || isGlass(xCoord, yCoord-1, zCoord)) && (!isGlass(xCoord, yCoord+1, zCoord) || !isGlass(xCoord, yCoord-1, zCoord)); - } + private boolean isValidStructure() { + return (isGlass(xCoord, yCoord + 1, zCoord) || isGlass(xCoord, yCoord - 1, zCoord)) && (!isGlass(xCoord, yCoord + 1, zCoord) || !isGlass(xCoord, yCoord - 1, zCoord)); + } - private boolean isGlass(int x, int y, int z){ - return worldObj.getBlock(x, y, z) == ModBlocks.invisibleMultiblock && worldObj.getBlockMetadata(x, y, z) == 2; - } + private boolean isGlass(int x, int y, int z) { + return worldObj.getBlock(x, y, z) == ModBlocks.invisibleMultiblock && worldObj.getBlockMetadata(x, y, z) == 2; + } - @Override - public void readFromNBT(NBTTagCompound compound) { - super.readFromNBT(compound); - active = compound.getBoolean("Active"); - reciveEnergy = compound.getBoolean("Input"); - int i = compound.getInteger("Cores"); - List list = new ArrayList(); - for (int j = 0; j < i; j++){ - TileLocation l = new TileLocation(); - l.readFromNBT(compound, "Core" + j); - list.add(l); - } - coreLocatios = list; - selectedCore = compound.getInteger("SelectedCore"); - particleRate = compound.getByte("ParticleRate"); - } + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + active = compound.getBoolean("Active"); + reciveEnergy = compound.getBoolean("Input"); + int i = compound.getInteger("Cores"); + List list = new ArrayList(); + for (int j = 0; j < i; j++) { + TileLocation l = new TileLocation(); + l.readFromNBT(compound, "Core" + j); + list.add(l); + } + coreLocatios = list; + selectedCore = compound.getInteger("SelectedCore"); + particleRate = compound.getByte("ParticleRate"); + } - @Override - public void writeToNBT(NBTTagCompound compound) { + @Override + public void writeToNBT(NBTTagCompound compound) { - super.writeToNBT(compound); - compound.setBoolean("Active", active); - compound.setBoolean("Input", reciveEnergy); - int i = coreLocatios.size(); - compound.setInteger("Cores", i); - for (int j = 0; j < i; j++){ - coreLocatios.get(j).writeToNBT(compound, "Core" + j); - } - compound.setInteger("SelectedCore", selectedCore); - compound.setByte("ParticleRate", particleRate); - } + super.writeToNBT(compound); + compound.setBoolean("Active", active); + compound.setBoolean("Input", reciveEnergy); + int i = coreLocatios.size(); + compound.setInteger("Cores", i); + for (int j = 0; j < i; j++) { + coreLocatios.get(j).writeToNBT(compound, "Core" + j); + } + compound.setInteger("SelectedCore", selectedCore); + compound.setByte("ParticleRate", particleRate); + } - @Override - public Packet getDescriptionPacket(){ - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeToNBT(nbttagcompound); + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); - } + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - /* IEnergyHandler */ - @Override - public boolean canConnectEnergy(ForgeDirection from) { - return true; - } + /* IEnergyHandler */ + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return true; + } - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - if (getMaster() == null) return 0; - int received = reciveEnergy ? getMaster().receiveEnergy(maxReceive, simulate) : 0; - if (!simulate && received > 0) particleRate = (byte)Math.min(20, received < 500 && received > 0 ? 1 : received/500); - return received; - } + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + if (getMaster() == null) return 0; + int received = reciveEnergy ? getMaster().receiveEnergy(maxReceive, simulate) : 0; + if (!simulate && received > 0) + particleRate = (byte) Math.min(20, received < 500 && received > 0 ? 1 : received / 500); + return received; + } - @Override - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { - if (getMaster() == null || !getMaster().isOnline()) return 0; - int extracted = reciveEnergy ? 0 : getMaster().extractEnergy(maxExtract, simulate); - if (!simulate && extracted > 0) particleRate = (byte)Math.min(20, extracted < 500 && extracted > 0 ? 1 : extracted/500); - return extracted; - } + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { + if (getMaster() == null || !getMaster().isOnline()) return 0; + int extracted = reciveEnergy ? 0 : getMaster().extractEnergy(maxExtract, simulate); + if (!simulate && extracted > 0) + particleRate = (byte) Math.min(20, extracted < 500 && extracted > 0 ? 1 : extracted / 500); + return extracted; + } - @Override - public int getEnergyStored(ForgeDirection from) { - if (getMaster() == null) return 0; - return (int)Math.min(Integer.MAX_VALUE, getMaster().getEnergyStored()); - } + @Override + public int getEnergyStored(ForgeDirection from) { + if (getMaster() == null) return 0; + return (int) Math.min(Integer.MAX_VALUE, getMaster().getEnergyStored()); + } - @Override - public int getMaxEnergyStored(ForgeDirection from) { - if (getMaster() == null) return 0; - return (int)Math.min(Integer.MAX_VALUE, getMaster().getMaxEnergyStored()); - } + @Override + public int getMaxEnergyStored(ForgeDirection from) { + if (getMaster() == null) return 0; + return (int) Math.min(Integer.MAX_VALUE, getMaster().getMaxEnergyStored()); + } - @Override - public AxisAlignedBB getRenderBoundingBox() { - return INFINITE_EXTENT_AABB; - } + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } - private void detectAndSendChanges(){ - if (lastTickActive != active) lastTickActive = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 0, active, new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 256)); - if (lastTickReciveEnergy != reciveEnergy) lastTickReciveEnergy = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 1, reciveEnergy, new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 256)); - if (lastTickParticleRate != particleRate) lastTickParticleRate = (Byte) sendObjectToClient(References.BYTE_ID, 2, particleRate); - } + private void detectAndSendChanges() { + if (lastTickActive != active) + lastTickActive = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 0, active, new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 256)); + if (lastTickReciveEnergy != reciveEnergy) + lastTickReciveEnergy = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 1, reciveEnergy, new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 256)); + if (lastTickParticleRate != particleRate) + lastTickParticleRate = (Byte) sendObjectToClient(References.BYTE_ID, 2, particleRate); + } - @SideOnly(Side.CLIENT) - @Override - public void receiveObjectFromServer(int index, Object object) { - switch (index) { - case 0: - active = (Boolean) object; - break; - case 1: - reciveEnergy = (Boolean) object; - break; - case 2: - particleRate = (Byte) object; - break; - } - } + @SideOnly(Side.CLIENT) + @Override + public void receiveObjectFromServer(int index, Object object) { + switch (index) { + case 0: + active = (Boolean) object; + break; + case 1: + reciveEnergy = (Boolean) object; + break; + case 2: + particleRate = (Byte) object; + break; + } + } - @Override - public double getEnergyStored() { - return getMaster() != null ? getMaster().getEnergyStored() : 0D; - } + @Override + public double getEnergyStored() { + return getMaster() != null ? getMaster().getEnergyStored() : 0D; + } - @Override - public double getMaxEnergyStored() { - return getMaster() != null ? getMaster().getMaxEnergyStored() : 0D; - } + @Override + public double getMaxEnergyStored() { + return getMaster() != null ? getMaster().getMaxEnergyStored() : 0D; + } - @Override - public long getExtendedStorage() { - return getMaster() != null ? getMaster().getEnergyStored() : 0L; - } + @Override + public long getExtendedStorage() { + return getMaster() != null ? getMaster().getEnergyStored() : 0L; + } - @Override - public long getExtendedCapacity() { - return getMaster() != null ? getMaster().getMaxEnergyStored() : 0L; - } + @Override + public long getExtendedCapacity() { + return getMaster() != null ? getMaster().getMaxEnergyStored() : 0L; + } - @Override - public String getName() { - return "draconic_rf_storage"; - } + @Override + public String getName() { + return "draconic_rf_storage"; + } - @Override - public String[] getMethodNames() { - return new String[] {"getEnergyStored", "getMaxEnergyStored"}; - } + @Override + public String[] getMethodNames() { + return new String[]{"getEnergyStored", "getMaxEnergyStored"}; + } - @Override - public Object[] callMethod(String method, Object... args) { - if (method.equals("getEnergyStored")) return new Object[] {getExtendedStorage()}; - else if (method.equals("getMaxEnergyStored")) return new Object[] {getExtendedCapacity()}; - return new Object[0]; - } + @Override + public Object[] callMethod(String method, Object... args) { + if (method.equals("getEnergyStored")) return new Object[]{getExtendedStorage()}; + else if (method.equals("getMaxEnergyStored")) return new Object[]{getExtendedCapacity()}; + return new Object[0]; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyStorageCore.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyStorageCore.java index 940d4bdd..365a4726 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyStorageCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyStorageCore.java @@ -20,769 +20,762 @@ import net.minecraft.util.AxisAlignedBB; */ public class TileEnergyStorageCore extends TileObjectSync { - protected TileLocation[] stabilizers = new TileLocation[4]; - protected int tier = 0; - protected boolean online = false; - public float modelRotation = 0; - private long energy = 0; - private long capacity = 0; - private long lastTickCapacity = 0; - private int tick = 0; + protected TileLocation[] stabilizers = new TileLocation[4]; + protected int tier = 0; + protected boolean online = false; + public float modelRotation = 0; + private long energy = 0; + private long capacity = 0; + private long lastTickCapacity = 0; + private int tick = 0; - public TileEnergyStorageCore(){ - for (int i = 0; i < stabilizers.length; i++) - { - stabilizers[i] = new TileLocation(); - } - } + public TileEnergyStorageCore() { + for (int i = 0; i < stabilizers.length; i++) { + stabilizers[i] = new TileLocation(); + } + } - @Override - public void updateEntity() { - //energy = 200000000; - if (!online) return; - if (worldObj.isRemote) modelRotation += 0.5; - if (!worldObj.isRemote) detectAndRendChanges(); - tick++; - } + @Override + public void updateEntity() { + //energy = 200000000; + if (!online) return; + if (worldObj.isRemote) modelRotation += 0.5; + if (!worldObj.isRemote) detectAndRendChanges(); + tick++; + } - /** - * ######################MultiBlock Methods####################### - */ + /** + * ######################MultiBlock Methods####################### + */ - public boolean tryActivate() { - if (!findStabalyzers()) return false; - if (!setTier(false)) return false; - if (!testOrActivateStructureIfValid(false, false)) return false; - online = true; - if (!testOrActivateStructureIfValid(false, true)) { - online = false; - deactivateStabilizers(); - return false; - } - activateStabilizers(); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - return true; - } + public boolean tryActivate() { + if (!findStabalyzers()) return false; + if (!setTier(false)) return false; + if (!testOrActivateStructureIfValid(false, false)) return false; + online = true; + if (!testOrActivateStructureIfValid(false, true)) { + online = false; + deactivateStabilizers(); + return false; + } + activateStabilizers(); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return true; + } - public boolean creativeActivate() { - if (!findStabalyzers()) return false; - if (!setTier(false)) return false; - if (!testOrActivateStructureIfValid(true, false)) return false; - online = true; - if (!testOrActivateStructureIfValid(false, true)) { - online = false; - deactivateStabilizers(); - return false; - } - activateStabilizers(); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - return true; - } + public boolean creativeActivate() { + if (!findStabalyzers()) return false; + if (!setTier(false)) return false; + if (!testOrActivateStructureIfValid(true, false)) return false; + online = true; + if (!testOrActivateStructureIfValid(false, true)) { + online = false; + deactivateStabilizers(); + return false; + } + activateStabilizers(); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return true; + } - public boolean isStructureStillValid(boolean update){ - if (!checkStabilizers()) online = false; - if (!testOrActivateStructureIfValid(false, false)) online = false; - if (!areStabilizersActive()) online = false; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - if (!online) deactivateStabilizers(); - if (update && !online) reIntegrate(); - //if (update && !online && worldObj.getTileEntity(xCoord, yCoord + 1, zCoord) != null && worldObj.getTileEntity(xCoord, yCoord + 1, zCoord) instanceof TileInvisibleMultiblock) ((TileInvisibleMultiblock)worldObj.getTileEntity(xCoord, yCoord + 1, zCoord)).isStructureStillValid(); - return online; - } + public boolean isStructureStillValid(boolean update) { + if (!checkStabilizers()) online = false; + if (!testOrActivateStructureIfValid(false, false)) online = false; + if (!areStabilizersActive()) online = false; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + if (!online) deactivateStabilizers(); + if (update && !online) reIntegrate(); + //if (update && !online && worldObj.getTileEntity(xCoord, yCoord + 1, zCoord) != null && worldObj.getTileEntity(xCoord, yCoord + 1, zCoord) instanceof TileInvisibleMultiblock) ((TileInvisibleMultiblock)worldObj.getTileEntity(xCoord, yCoord + 1, zCoord)).isStructureStillValid(); + return online; + } - private void reIntegrate(){ - for (int x = xCoord - 1; x <= xCoord + 1; x++) { - for (int y = yCoord - 1; y <= yCoord + 1; y++) { - for (int z = zCoord - 1; z <= zCoord + 1; z++) { - if (worldObj.getBlock(x, y, z) == ModBlocks.invisibleMultiblock) - { - if (worldObj.getBlockMetadata(x, y, z) == 0) { - worldObj.setBlock(x, y, z, ModBlocks.draconiumBlock); - } - else if (worldObj.getBlockMetadata(x, y, z) == 1) { - worldObj.setBlock(x, y, z, BalanceConfigHandler.energyStorageStructureBlock, BalanceConfigHandler.energyStorageStructureBlockMetadata, 3); - } - } - } - } - } - } + private void reIntegrate() { + for (int x = xCoord - 1; x <= xCoord + 1; x++) { + for (int y = yCoord - 1; y <= yCoord + 1; y++) { + for (int z = zCoord - 1; z <= zCoord + 1; z++) { + if (worldObj.getBlock(x, y, z) == ModBlocks.invisibleMultiblock) { + if (worldObj.getBlockMetadata(x, y, z) == 0) { + worldObj.setBlock(x, y, z, ModBlocks.draconiumBlock); + } else if (worldObj.getBlockMetadata(x, y, z) == 1) { + worldObj.setBlock(x, y, z, BalanceConfigHandler.energyStorageStructureBlock, BalanceConfigHandler.energyStorageStructureBlockMetadata, 3); + } + } + } + } + } + } - private boolean findStabalyzers() { - boolean flag = true; - for (int x = xCoord; x <= xCoord + 11; x++) { - if (worldObj.getBlock(x, yCoord, zCoord) == ModBlocks.particleGenerator) { - if (worldObj.getBlockMetadata(x, yCoord, zCoord) == 1) { - flag = false; - break; - } - stabilizers[0] = new TileLocation(x, yCoord, zCoord); - break; - } else if (x == xCoord + 11) { - flag = false; - } + private boolean findStabalyzers() { + boolean flag = true; + for (int x = xCoord; x <= xCoord + 11; x++) { + if (worldObj.getBlock(x, yCoord, zCoord) == ModBlocks.particleGenerator) { + if (worldObj.getBlockMetadata(x, yCoord, zCoord) == 1) { + flag = false; + break; + } + stabilizers[0] = new TileLocation(x, yCoord, zCoord); + break; + } else if (x == xCoord + 11) { + flag = false; + } - } - for (int x = xCoord; x >= xCoord - 11; x--) { - if (worldObj.getBlock(x, yCoord, zCoord) == ModBlocks.particleGenerator) { - if (worldObj.getBlockMetadata(x, yCoord, zCoord) == 1) { - flag = false; - break; - } - stabilizers[1] = new TileLocation(x, yCoord, zCoord); - break; - } else if (x == xCoord - 11) { - flag = false; - } - } - for (int z = zCoord; z <= zCoord + 11; z++) { - if (worldObj.getBlock(xCoord, yCoord, z) == ModBlocks.particleGenerator) { - if (worldObj.getBlockMetadata(xCoord, yCoord, z) == 1) { - flag = false; - break; - } - stabilizers[2] = new TileLocation(xCoord, yCoord, z); - break; - } else if (z == zCoord + 11) { - flag = false; - } - } - for (int z = zCoord; z >= zCoord - 11; z--) { - if (worldObj.getBlock(xCoord, yCoord, z) == ModBlocks.particleGenerator) { - if (worldObj.getBlockMetadata(xCoord, yCoord, z) == 1) { - flag = false; - break; - } - stabilizers[3] = new TileLocation(xCoord, yCoord, z); - break; - } else if (z == zCoord - 11) { - flag = false; - } - } - return flag; - } + } + for (int x = xCoord; x >= xCoord - 11; x--) { + if (worldObj.getBlock(x, yCoord, zCoord) == ModBlocks.particleGenerator) { + if (worldObj.getBlockMetadata(x, yCoord, zCoord) == 1) { + flag = false; + break; + } + stabilizers[1] = new TileLocation(x, yCoord, zCoord); + break; + } else if (x == xCoord - 11) { + flag = false; + } + } + for (int z = zCoord; z <= zCoord + 11; z++) { + if (worldObj.getBlock(xCoord, yCoord, z) == ModBlocks.particleGenerator) { + if (worldObj.getBlockMetadata(xCoord, yCoord, z) == 1) { + flag = false; + break; + } + stabilizers[2] = new TileLocation(xCoord, yCoord, z); + break; + } else if (z == zCoord + 11) { + flag = false; + } + } + for (int z = zCoord; z >= zCoord - 11; z--) { + if (worldObj.getBlock(xCoord, yCoord, z) == ModBlocks.particleGenerator) { + if (worldObj.getBlockMetadata(xCoord, yCoord, z) == 1) { + flag = false; + break; + } + stabilizers[3] = new TileLocation(xCoord, yCoord, z); + break; + } else if (z == zCoord - 11) { + flag = false; + } + } + return flag; + } - private boolean setTier(boolean force) { - if (force) return true; - int xPos = 0; - int xNeg = 0; - int yPos = 0; - int yNeg = 0; - int zPos = 0; - int zNeg = 0; - int range = 5; + private boolean setTier(boolean force) { + if (force) return true; + int xPos = 0; + int xNeg = 0; + int yPos = 0; + int yNeg = 0; + int zPos = 0; + int zNeg = 0; + int range = 5; - for (int x = 0; x <= range; x++) { - if (testForOrActivateDraconium(xCoord + x, yCoord, zCoord, false, false)) { - xPos = x; - break; - } - } + for (int x = 0; x <= range; x++) { + if (testForOrActivateDraconium(xCoord + x, yCoord, zCoord, false, false)) { + xPos = x; + break; + } + } - for (int x = 0; x <= range; x++) { - if (testForOrActivateDraconium(xCoord - x, yCoord, zCoord, false, false)) { - xNeg = x; - break; - } - } + for (int x = 0; x <= range; x++) { + if (testForOrActivateDraconium(xCoord - x, yCoord, zCoord, false, false)) { + xNeg = x; + break; + } + } - for (int y = 0; y <= range; y++) { - if (testForOrActivateDraconium(xCoord, yCoord + y, zCoord, false, false)) { - yPos = y; - break; - } - } + for (int y = 0; y <= range; y++) { + if (testForOrActivateDraconium(xCoord, yCoord + y, zCoord, false, false)) { + yPos = y; + break; + } + } - for (int y = 0; y <= range; y++) { - if (testForOrActivateDraconium(xCoord, yCoord - y, zCoord, false, false)) { - yNeg = y; - break; - } - } + for (int y = 0; y <= range; y++) { + if (testForOrActivateDraconium(xCoord, yCoord - y, zCoord, false, false)) { + yNeg = y; + break; + } + } - for (int z = 0; z <= range; z++) { - if (testForOrActivateDraconium(xCoord, yCoord, zCoord + z, false, false)) { - zPos = z; - break; - } - } + for (int z = 0; z <= range; z++) { + if (testForOrActivateDraconium(xCoord, yCoord, zCoord + z, false, false)) { + zPos = z; + break; + } + } - for (int z = 0; z <= range; z++) { - if (testForOrActivateDraconium(xCoord, yCoord, zCoord - z, false, false)) { - zNeg = z; - break; - } - } + for (int z = 0; z <= range; z++) { + if (testForOrActivateDraconium(xCoord, yCoord, zCoord - z, false, false)) { + zNeg = z; + break; + } + } - if (zNeg != zPos || zNeg != yNeg || zNeg != yPos || zNeg != xNeg || zNeg != xPos) return false; + if (zNeg != zPos || zNeg != yNeg || zNeg != yPos || zNeg != xNeg || zNeg != xPos) return false; - tier = xPos; - if (tier > 1) tier++; - if (tier == 1){ - if (testForOrActivateDraconium(xCoord + 1, yCoord + 1, zCoord, false, false)) tier = 2; - } - return true; - } + tier = xPos; + if (tier > 1) tier++; + if (tier == 1) { + if (testForOrActivateDraconium(xCoord + 1, yCoord + 1, zCoord, false, false)) tier = 2; + } + return true; + } - private boolean testOrActivateStructureIfValid(boolean setBlocks, boolean activate){ - switch (tier){ - case 0: - if (!testOrActivateRect(1, 1, 1, "air", setBlocks, activate)) return false; - break; - case 1: - if (!testForOrActivateDraconium(xCoord + 1, yCoord, zCoord, setBlocks, activate) || !testForOrActivateDraconium(xCoord - 1, yCoord, zCoord, setBlocks, activate) || !testForOrActivateDraconium(xCoord, yCoord + 1, zCoord, setBlocks, activate) || !testForOrActivateDraconium(xCoord, yCoord - 1, zCoord, setBlocks, activate) || !testForOrActivateDraconium(xCoord, yCoord, zCoord + 1, setBlocks, activate) || !testForOrActivateDraconium(xCoord, yCoord, zCoord - 1, setBlocks, activate)) return false; - if (!isReplacable(xCoord + 1, yCoord + 1, zCoord, setBlocks) || !isReplacable(xCoord, yCoord + 1, zCoord + 1, setBlocks) || !isReplacable(xCoord - 1, yCoord + 1, zCoord, setBlocks) || !isReplacable(xCoord, yCoord + 1, zCoord - 1, setBlocks) || !isReplacable(xCoord + 1, yCoord - 1, zCoord, setBlocks) || !isReplacable(xCoord, yCoord - 1, zCoord + 1, setBlocks) || !isReplacable(xCoord - 1, yCoord - 1, zCoord, setBlocks) || !isReplacable(xCoord, yCoord - 1, zCoord - 1, setBlocks) || !isReplacable(xCoord + 1, yCoord, zCoord + 1, setBlocks) || !isReplacable(xCoord - 1, yCoord, zCoord - 1, setBlocks) || !isReplacable(xCoord + 1, yCoord, zCoord - 1, setBlocks) || !isReplacable(xCoord - 1, yCoord, zCoord + 1, setBlocks)) return false; - if (!isReplacable(xCoord + 1, yCoord + 1, zCoord + 1, setBlocks) || !isReplacable(xCoord - 1, yCoord + 1, zCoord - 1, setBlocks) || !isReplacable(xCoord + 1, yCoord + 1, zCoord - 1, setBlocks) || !isReplacable(xCoord - 1, yCoord + 1, zCoord + 1, setBlocks) || !isReplacable(xCoord + 1, yCoord - 1, zCoord + 1, setBlocks) || !isReplacable(xCoord - 1, yCoord - 1, zCoord - 1, setBlocks) || !isReplacable(xCoord + 1, yCoord - 1, zCoord - 1, setBlocks) || !isReplacable(xCoord - 1, yCoord - 1, zCoord + 1, setBlocks)) return false; - break; - case 2: - if (!testOrActivateRect(1, 1, 1, "draconiumBlock", setBlocks, activate)) return false; - break; - case 3: - if (!testOrActivateSides(1, "draconiumBlock", setBlocks, activate)) return false; - if (!testOrActivateRect(1, 1, 1, "redstone", setBlocks, activate)) return false; - break; - case 4: - if (!testOrActivateSides(2, "draconiumBlock", setBlocks, activate)) return false; - if (!testOrActivateRect(2, 1, 1, "redstone", setBlocks, activate)) return false; - if (!testOrActivateRect(1, 2, 1, "redstone", setBlocks, activate)) return false; - if (!testOrActivateRect(1, 1, 2, "redstone", setBlocks, activate)) return false; - if (!testOrActivateRings(2, 2, "draconiumBlock", setBlocks, activate)) return false; - break; - case 5: - if (!testOrActivateSides(3, "draconiumBlock", setBlocks, activate)) return false; - if (!testOrActivateSides(2, "redstone", setBlocks, activate)) return false; - if (!testOrActivateRect(2, 2, 2, "redstone", setBlocks, activate)) return false; - if (!testOrActivateRings(2, 3, "draconiumBlock", setBlocks, activate)) return false; - break; - case 6: - if (!testOrActivateSides(4, "draconiumBlock", setBlocks, activate)) return false; - if (!testOrActivateSides(3, "redstone", setBlocks, activate)) return false; - if (!testOrActivateRect(3, 2, 2, "redstone", setBlocks, activate)) return false; - if (!testOrActivateRect(2, 3, 2, "redstone", setBlocks, activate)) return false; - if (!testOrActivateRect(2, 2, 3, "redstone", setBlocks, activate)) return false; - if (!testOrActivateRings(2, 4, "draconiumBlock", setBlocks, activate)) return false; - if (!testOrActivateRings(3, 3, "draconiumBlock", setBlocks, activate)) return false; - break; - } - return true; - } + private boolean testOrActivateStructureIfValid(boolean setBlocks, boolean activate) { + switch (tier) { + case 0: + if (!testOrActivateRect(1, 1, 1, "air", setBlocks, activate)) return false; + break; + case 1: + if (!testForOrActivateDraconium(xCoord + 1, yCoord, zCoord, setBlocks, activate) || !testForOrActivateDraconium(xCoord - 1, yCoord, zCoord, setBlocks, activate) || !testForOrActivateDraconium(xCoord, yCoord + 1, zCoord, setBlocks, activate) || !testForOrActivateDraconium(xCoord, yCoord - 1, zCoord, setBlocks, activate) || !testForOrActivateDraconium(xCoord, yCoord, zCoord + 1, setBlocks, activate) || !testForOrActivateDraconium(xCoord, yCoord, zCoord - 1, setBlocks, activate)) + return false; + if (!isReplacable(xCoord + 1, yCoord + 1, zCoord, setBlocks) || !isReplacable(xCoord, yCoord + 1, zCoord + 1, setBlocks) || !isReplacable(xCoord - 1, yCoord + 1, zCoord, setBlocks) || !isReplacable(xCoord, yCoord + 1, zCoord - 1, setBlocks) || !isReplacable(xCoord + 1, yCoord - 1, zCoord, setBlocks) || !isReplacable(xCoord, yCoord - 1, zCoord + 1, setBlocks) || !isReplacable(xCoord - 1, yCoord - 1, zCoord, setBlocks) || !isReplacable(xCoord, yCoord - 1, zCoord - 1, setBlocks) || !isReplacable(xCoord + 1, yCoord, zCoord + 1, setBlocks) || !isReplacable(xCoord - 1, yCoord, zCoord - 1, setBlocks) || !isReplacable(xCoord + 1, yCoord, zCoord - 1, setBlocks) || !isReplacable(xCoord - 1, yCoord, zCoord + 1, setBlocks)) + return false; + if (!isReplacable(xCoord + 1, yCoord + 1, zCoord + 1, setBlocks) || !isReplacable(xCoord - 1, yCoord + 1, zCoord - 1, setBlocks) || !isReplacable(xCoord + 1, yCoord + 1, zCoord - 1, setBlocks) || !isReplacable(xCoord - 1, yCoord + 1, zCoord + 1, setBlocks) || !isReplacable(xCoord + 1, yCoord - 1, zCoord + 1, setBlocks) || !isReplacable(xCoord - 1, yCoord - 1, zCoord - 1, setBlocks) || !isReplacable(xCoord + 1, yCoord - 1, zCoord - 1, setBlocks) || !isReplacable(xCoord - 1, yCoord - 1, zCoord + 1, setBlocks)) + return false; + break; + case 2: + if (!testOrActivateRect(1, 1, 1, "draconiumBlock", setBlocks, activate)) return false; + break; + case 3: + if (!testOrActivateSides(1, "draconiumBlock", setBlocks, activate)) return false; + if (!testOrActivateRect(1, 1, 1, "redstone", setBlocks, activate)) return false; + break; + case 4: + if (!testOrActivateSides(2, "draconiumBlock", setBlocks, activate)) return false; + if (!testOrActivateRect(2, 1, 1, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRect(1, 2, 1, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRect(1, 1, 2, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRings(2, 2, "draconiumBlock", setBlocks, activate)) return false; + break; + case 5: + if (!testOrActivateSides(3, "draconiumBlock", setBlocks, activate)) return false; + if (!testOrActivateSides(2, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRect(2, 2, 2, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRings(2, 3, "draconiumBlock", setBlocks, activate)) return false; + break; + case 6: + if (!testOrActivateSides(4, "draconiumBlock", setBlocks, activate)) return false; + if (!testOrActivateSides(3, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRect(3, 2, 2, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRect(2, 3, 2, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRect(2, 2, 3, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRings(2, 4, "draconiumBlock", setBlocks, activate)) return false; + if (!testOrActivateRings(3, 3, "draconiumBlock", setBlocks, activate)) return false; + break; + } + return true; + } - private boolean testOrActivateRect(int xDim, int yDim, int zDim, String block, boolean set, boolean activate){ - for (int x = xCoord - xDim; x <= xCoord + xDim; x++){ - for (int y = yCoord - yDim; y <= yCoord + yDim; y++){ - for (int z = zCoord - zDim; z <= zCoord + zDim; z++){ + private boolean testOrActivateRect(int xDim, int yDim, int zDim, String block, boolean set, boolean activate) { + for (int x = xCoord - xDim; x <= xCoord + xDim; x++) { + for (int y = yCoord - yDim; y <= yCoord + yDim; y++) { + for (int z = zCoord - zDim; z <= zCoord + zDim; z++) { - if (block.equals("air")){ - if (!(x == xCoord && y == yCoord && z == zCoord) && !isReplacable(x, y, z, set)) return false; - } - else if (block.equals("redstone")){ - if (!(x == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(x, y, z, set, activate)) return false; - } - else if (block.equals("draconiumBlock")){ - if (!(x == xCoord && y == yCoord && z == zCoord) && !testForOrActivateDraconium(x, y, z, set, activate)) return false; - } - else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { - LogHelper.error("Invalid String In Multiblock Structure Code!!!"); - return false; - } - } - } - } - return true; - } + if (block.equals("air")) { + if (!(x == xCoord && y == yCoord && z == zCoord) && !isReplacable(x, y, z, set)) return false; + } else if (block.equals("redstone")) { + if (!(x == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(x, y, z, set, activate)) + return false; + } else if (block.equals("draconiumBlock")) { + if (!(x == xCoord && y == yCoord && z == zCoord) && !testForOrActivateDraconium(x, y, z, set, activate)) + return false; + } else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + } + return true; + } - private boolean testOrActivateRings(int size, int dist, String block, boolean set, boolean activate){ - for (int y=yCoord-size; y<=yCoord+size;y++){ - for (int z=zCoord-size; z<=zCoord+size;z++){ + private boolean testOrActivateRings(int size, int dist, String block, boolean set, boolean activate) { + for (int y = yCoord - size; y <= yCoord + size; y++) { + for (int z = zCoord - size; z <= zCoord + size; z++) { - if (y == yCoord-size || y == yCoord+size || z == zCoord-size || z==zCoord+size) { - if (block.equals("air")) { - if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !isReplacable(xCoord + dist, y, z, set)) - return false; - } else if (block.equals("redstone")) { - if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(xCoord + dist, y, z, set, activate)) - return false; - } else if (block.equals("draconiumBlock")) { - if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateDraconium(xCoord + dist, y, z, set, activate)) - return false; - } else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { - LogHelper.error("Invalid String In Multiblock Structure Code!!!"); - return false; - } - } - } - } - for (int y=yCoord-size; y<=yCoord+size;y++){ - for (int z=zCoord-size; z<=zCoord+size;z++){ + if (y == yCoord - size || y == yCoord + size || z == zCoord - size || z == zCoord + size) { + if (block.equals("air")) { + if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !isReplacable(xCoord + dist, y, z, set)) + return false; + } else if (block.equals("redstone")) { + if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(xCoord + dist, y, z, set, activate)) + return false; + } else if (block.equals("draconiumBlock")) { + if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateDraconium(xCoord + dist, y, z, set, activate)) + return false; + } else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + } + for (int y = yCoord - size; y <= yCoord + size; y++) { + for (int z = zCoord - size; z <= zCoord + size; z++) { - if (y == yCoord-size || y == yCoord+size || z == zCoord-size || z==zCoord+size) { - if (block.equals("air")) { - if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !isReplacable(xCoord - dist, y, z, set)) - return false; - } else if (block.equals("redstone")) { - if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(xCoord - dist, y, z, set, activate)) - return false; - } else if (block.equals("draconiumBlock")) { - if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateDraconium(xCoord - dist, y, z, set, activate)) - return false; - } else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { - LogHelper.error("Invalid String In Multiblock Structure Code!!!"); - return false; - } - } - } - } + if (y == yCoord - size || y == yCoord + size || z == zCoord - size || z == zCoord + size) { + if (block.equals("air")) { + if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !isReplacable(xCoord - dist, y, z, set)) + return false; + } else if (block.equals("redstone")) { + if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(xCoord - dist, y, z, set, activate)) + return false; + } else if (block.equals("draconiumBlock")) { + if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateDraconium(xCoord - dist, y, z, set, activate)) + return false; + } else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + } - for (int x=xCoord-size; x<=xCoord+size;x++){ - for (int z=zCoord-size; z<=zCoord+size;z++){ + for (int x = xCoord - size; x <= xCoord + size; x++) { + for (int z = zCoord - size; z <= zCoord + size; z++) { - if (x == xCoord-size || x == xCoord+size || z == zCoord-size || z == zCoord+size) { - if (block.equals("air")){ - if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !isReplacable(x, yCoord + dist, z, set)) return false; - } - else if (block.equals("redstone")){ - if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !testForOrActivateRedstone(x, yCoord + dist, z, set, activate)) return false; - } - else if (block.equals("draconiumBlock")){ - if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !testForOrActivateDraconium(x, yCoord + dist, z, set, activate)) return false; - } - else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { - LogHelper.error("Invalid String In Multiblock Structure Code!!!"); - return false; - } - } - } - } - for (int x=xCoord-size; x<=xCoord+size;x++){ - for (int z=zCoord-size; z<=zCoord+size;z++){ + if (x == xCoord - size || x == xCoord + size || z == zCoord - size || z == zCoord + size) { + if (block.equals("air")) { + if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !isReplacable(x, yCoord + dist, z, set)) + return false; + } else if (block.equals("redstone")) { + if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !testForOrActivateRedstone(x, yCoord + dist, z, set, activate)) + return false; + } else if (block.equals("draconiumBlock")) { + if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !testForOrActivateDraconium(x, yCoord + dist, z, set, activate)) + return false; + } else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + } + for (int x = xCoord - size; x <= xCoord + size; x++) { + for (int z = zCoord - size; z <= zCoord + size; z++) { - if (x == xCoord-size || x == xCoord+size || z == zCoord-size || z==zCoord+size) { - if (block.equals("air")){ - if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !isReplacable(x, yCoord - dist, z, set)) return false; - } - else if (block.equals("redstone")){ - if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !testForOrActivateRedstone(x, yCoord - dist, z, set, activate)) return false; - } - else if (block.equals("draconiumBlock")){ - if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !testForOrActivateDraconium(x, yCoord - dist, z, set, activate)) return false; - } - else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { - LogHelper.error("Invalid String In Multiblock Structure Code!!!"); - return false; - } - } - } - } + if (x == xCoord - size || x == xCoord + size || z == zCoord - size || z == zCoord + size) { + if (block.equals("air")) { + if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !isReplacable(x, yCoord - dist, z, set)) + return false; + } else if (block.equals("redstone")) { + if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !testForOrActivateRedstone(x, yCoord - dist, z, set, activate)) + return false; + } else if (block.equals("draconiumBlock")) { + if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !testForOrActivateDraconium(x, yCoord - dist, z, set, activate)) + return false; + } else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + } - for (int y=yCoord-size; y<=yCoord+size;y++){ - for (int x=xCoord-size; x<=xCoord+size;x++){ + for (int y = yCoord - size; y <= yCoord + size; y++) { + for (int x = xCoord - size; x <= xCoord + size; x++) { - if (y == yCoord-size || y == yCoord+size || x == xCoord-size || x == xCoord+size) { - if (block.equals("air")){ - if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !isReplacable(x, y, zCoord + dist, set)) return false; - } - else if (block.equals("redstone")){ - if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !testForOrActivateRedstone(x, y, zCoord + dist, set, activate)) return false; - } - else if (block.equals("draconiumBlock")){ - if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !testForOrActivateDraconium(x, y, zCoord + dist, set, activate)) return false; - } - else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { - LogHelper.error("Invalid String In Multiblock Structure Code!!!"); - return false; - } - } - } - } - for (int y=yCoord-size; y<=yCoord+size;y++){ - for (int x=xCoord-size; x<=xCoord+size;x++){ + if (y == yCoord - size || y == yCoord + size || x == xCoord - size || x == xCoord + size) { + if (block.equals("air")) { + if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !isReplacable(x, y, zCoord + dist, set)) + return false; + } else if (block.equals("redstone")) { + if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !testForOrActivateRedstone(x, y, zCoord + dist, set, activate)) + return false; + } else if (block.equals("draconiumBlock")) { + if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !testForOrActivateDraconium(x, y, zCoord + dist, set, activate)) + return false; + } else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + } + for (int y = yCoord - size; y <= yCoord + size; y++) { + for (int x = xCoord - size; x <= xCoord + size; x++) { - if (y == yCoord-size || y == yCoord+size || x == xCoord-size || x==xCoord+size) { - if (block.equals("air")){ - if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !isReplacable(x, y, zCoord - dist, set)) return false; - } - else if (block.equals("redstone")){ - if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !testForOrActivateRedstone(x, y, zCoord - dist, set, activate)) return false; - } - else if (block.equals("draconiumBlock")){ - if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !testForOrActivateDraconium(x, y, zCoord - dist, set, activate)) return false; - } - else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { - LogHelper.error("Invalid String In Multiblock Structure Code!!!"); - return false; - } - } - } - } - return true; - } + if (y == yCoord - size || y == yCoord + size || x == xCoord - size || x == xCoord + size) { + if (block.equals("air")) { + if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !isReplacable(x, y, zCoord - dist, set)) + return false; + } else if (block.equals("redstone")) { + if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !testForOrActivateRedstone(x, y, zCoord - dist, set, activate)) + return false; + } else if (block.equals("draconiumBlock")) { + if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !testForOrActivateDraconium(x, y, zCoord - dist, set, activate)) + return false; + } else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + } + return true; + } - private boolean testOrActivateSides(int dist, String block, boolean set, boolean activate){ - dist++; - for (int y=yCoord-1; y<=yCoord+1;y++){ - for (int z=zCoord-1; z<=zCoord+1;z++){ + private boolean testOrActivateSides(int dist, String block, boolean set, boolean activate) { + dist++; + for (int y = yCoord - 1; y <= yCoord + 1; y++) { + for (int z = zCoord - 1; z <= zCoord + 1; z++) { - if (block.equals("air")){ - if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !isReplacable(xCoord + dist, y, z, set)) return false; - } - else if (block.equals("redstone")){ - if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(xCoord + dist, y, z, set, activate)) return false; - } - else if (block.equals("draconiumBlock")){ - if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateDraconium(xCoord + dist, y, z, set, activate)) return false; - } - else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { - LogHelper.error("Invalid String In Multiblock Structure Code!!!"); - return false; - } - } - } - for (int y=yCoord-1; y<=yCoord+1;y++){ - for (int z=zCoord-1; z<=zCoord+1;z++){ + if (block.equals("air")) { + if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !isReplacable(xCoord + dist, y, z, set)) + return false; + } else if (block.equals("redstone")) { + if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(xCoord + dist, y, z, set, activate)) + return false; + } else if (block.equals("draconiumBlock")) { + if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateDraconium(xCoord + dist, y, z, set, activate)) + return false; + } else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + for (int y = yCoord - 1; y <= yCoord + 1; y++) { + for (int z = zCoord - 1; z <= zCoord + 1; z++) { - if (block.equals("air")){ - if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !isReplacable(xCoord - dist, y, z, set)) return false; - } - else if (block.equals("redstone")){ - if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(xCoord - dist, y, z, set, activate)) return false; - } - else if (block.equals("draconiumBlock")){ - if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateDraconium(xCoord - dist, y, z, set, activate)) return false; - } - else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { - LogHelper.error("Invalid String In Multiblock Structure Code!!!"); - return false; - } - } - } + if (block.equals("air")) { + if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !isReplacable(xCoord - dist, y, z, set)) + return false; + } else if (block.equals("redstone")) { + if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(xCoord - dist, y, z, set, activate)) + return false; + } else if (block.equals("draconiumBlock")) { + if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateDraconium(xCoord - dist, y, z, set, activate)) + return false; + } else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } - for (int x=xCoord-1; x<=xCoord+1;x++){ - for (int z=zCoord-1; z<=zCoord+1;z++){ + for (int x = xCoord - 1; x <= xCoord + 1; x++) { + for (int z = zCoord - 1; z <= zCoord + 1; z++) { - if (block.equals("air")){ - if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !isReplacable(x, yCoord + dist, z, set)) return false; - } - else if (block.equals("redstone")){ - if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !testForOrActivateRedstone(x, yCoord + dist, z, set, activate)) return false; - } - else if (block.equals("draconiumBlock")){ - if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !testForOrActivateDraconium(x, yCoord + dist, z, set, activate)) return false; - } - else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { - LogHelper.error("Invalid String In Multiblock Structure Code!!!"); - return false; - } - } - } - for (int x=xCoord-1; x<=xCoord+1;x++){ - for (int z=zCoord-1; z<=zCoord+1;z++){ + if (block.equals("air")) { + if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !isReplacable(x, yCoord + dist, z, set)) + return false; + } else if (block.equals("redstone")) { + if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !testForOrActivateRedstone(x, yCoord + dist, z, set, activate)) + return false; + } else if (block.equals("draconiumBlock")) { + if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !testForOrActivateDraconium(x, yCoord + dist, z, set, activate)) + return false; + } else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + for (int x = xCoord - 1; x <= xCoord + 1; x++) { + for (int z = zCoord - 1; z <= zCoord + 1; z++) { - if (block.equals("air")){ - if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !isReplacable(x, yCoord - dist, z, set)) return false; - } - else if (block.equals("redstone")){ - if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !testForOrActivateRedstone(x, yCoord - dist, z, set, activate)) return false; - } - else if (block.equals("draconiumBlock")){ - if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !testForOrActivateDraconium(x, yCoord - dist, z, set, activate)) return false; - } - else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { - LogHelper.error("Invalid String In Multiblock Structure Code!!!"); - return false; - } - } - } + if (block.equals("air")) { + if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !isReplacable(x, yCoord - dist, z, set)) + return false; + } else if (block.equals("redstone")) { + if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !testForOrActivateRedstone(x, yCoord - dist, z, set, activate)) + return false; + } else if (block.equals("draconiumBlock")) { + if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !testForOrActivateDraconium(x, yCoord - dist, z, set, activate)) + return false; + } else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } - for (int y=yCoord-1; y<=yCoord+1;y++){ - for (int x=xCoord-1; x<=xCoord+1;x++){ + for (int y = yCoord - 1; y <= yCoord + 1; y++) { + for (int x = xCoord - 1; x <= xCoord + 1; x++) { - if (block.equals("air")){ - if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !isReplacable(x, y, zCoord + dist, set)) return false; - } - else if (block.equals("redstone")){ - if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !testForOrActivateRedstone(x, y, zCoord + dist, set, activate)) return false; - } - else if (block.equals("draconiumBlock")){ - if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !testForOrActivateDraconium(x, y, zCoord + dist, set, activate)) return false; - } - else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { - LogHelper.error("Invalid String In Multiblock Structure Code!!!"); - return false; - } - } - } - for (int y=yCoord-1; y<=yCoord+1;y++){ - for (int x=xCoord-1; x<=xCoord+1;x++){ + if (block.equals("air")) { + if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !isReplacable(x, y, zCoord + dist, set)) + return false; + } else if (block.equals("redstone")) { + if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !testForOrActivateRedstone(x, y, zCoord + dist, set, activate)) + return false; + } else if (block.equals("draconiumBlock")) { + if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !testForOrActivateDraconium(x, y, zCoord + dist, set, activate)) + return false; + } else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + for (int y = yCoord - 1; y <= yCoord + 1; y++) { + for (int x = xCoord - 1; x <= xCoord + 1; x++) { - if (block.equals("air")){ - if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !isReplacable(x, y, zCoord - dist, set)) return false; - } - else if (block.equals("redstone")){ - if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !testForOrActivateRedstone(x, y, zCoord - dist, set, activate)) return false; - } - else if (block.equals("draconiumBlock")){ - if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !testForOrActivateDraconium(x, y, zCoord - dist, set, activate)) return false; - } - else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { - LogHelper.error("Invalid String In Multiblock Structure Code!!!"); - return false; - } - } - } + if (block.equals("air")) { + if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !isReplacable(x, y, zCoord - dist, set)) + return false; + } else if (block.equals("redstone")) { + if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !testForOrActivateRedstone(x, y, zCoord - dist, set, activate)) + return false; + } else if (block.equals("draconiumBlock")) { + if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !testForOrActivateDraconium(x, y, zCoord - dist, set, activate)) + return false; + } else if (!block.equals("draconiumBlock") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } - return true; - } + return true; + } - private boolean testForOrActivateDraconium(int x, int y, int z, boolean set, boolean activate){ - if (!activate) { - if (set) { - worldObj.setBlock(x, y, z, ModBlocks.draconiumBlock); - return true; - } else return worldObj.getBlock(x, y, z) == ModBlocks.draconiumBlock || (worldObj.getBlock(x, y, z) == ModBlocks.invisibleMultiblock && worldObj.getBlockMetadata(x, y, z) == 0); - }else{ - return activateDraconium(x, y, z); - } - } + private boolean testForOrActivateDraconium(int x, int y, int z, boolean set, boolean activate) { + if (!activate) { + if (set) { + worldObj.setBlock(x, y, z, ModBlocks.draconiumBlock); + return true; + } else + return worldObj.getBlock(x, y, z) == ModBlocks.draconiumBlock || (worldObj.getBlock(x, y, z) == ModBlocks.invisibleMultiblock && worldObj.getBlockMetadata(x, y, z) == 0); + } else { + return activateDraconium(x, y, z); + } + } - private boolean testForOrActivateRedstone(int x, int y, int z, boolean set, boolean activate){ - if (!activate) { - if (set) { - worldObj.setBlock(x, y, z, BalanceConfigHandler.energyStorageStructureBlock, BalanceConfigHandler.energyStorageStructureBlockMetadata, 3); - return true; - } else { - return (worldObj.getBlock(x, y, z) == BalanceConfigHandler.energyStorageStructureBlock && worldObj.getBlockMetadata(x, y, z) == BalanceConfigHandler.energyStorageStructureBlockMetadata) || - (worldObj.getBlock(x, y, z) == ModBlocks.invisibleMultiblock && worldObj.getBlockMetadata(x, y, z) == 1); - } - }else{ - return activateRedstone(x, y, z); - } - } + private boolean testForOrActivateRedstone(int x, int y, int z, boolean set, boolean activate) { + if (!activate) { + if (set) { + worldObj.setBlock(x, y, z, BalanceConfigHandler.energyStorageStructureBlock, BalanceConfigHandler.energyStorageStructureBlockMetadata, 3); + return true; + } else { + return (worldObj.getBlock(x, y, z) == BalanceConfigHandler.energyStorageStructureBlock && worldObj.getBlockMetadata(x, y, z) == BalanceConfigHandler.energyStorageStructureBlockMetadata) || (worldObj.getBlock(x, y, z) == ModBlocks.invisibleMultiblock && worldObj.getBlockMetadata(x, y, z) == 1); + } + } else { + return activateRedstone(x, y, z); + } + } - private boolean activateDraconium(int x, int y, int z){ - if (testForOrActivateDraconium(x, y, z, false, false)){ - worldObj.setBlock(x, y, z, ModBlocks.invisibleMultiblock, 0, 2); - TileInvisibleMultiblock tile = (worldObj.getTileEntity(x, y, z) != null && worldObj.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) worldObj.getTileEntity(x, y, z) : null; - if (tile != null) { - tile.master = new TileLocation(xCoord, yCoord, zCoord); - } - return true; - } - LogHelper.error("Failed to activate structure (activateDraconium)"); - return false; - } + private boolean activateDraconium(int x, int y, int z) { + if (testForOrActivateDraconium(x, y, z, false, false)) { + worldObj.setBlock(x, y, z, ModBlocks.invisibleMultiblock, 0, 2); + TileInvisibleMultiblock tile = (worldObj.getTileEntity(x, y, z) != null && worldObj.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) worldObj.getTileEntity(x, y, z) : null; + if (tile != null) { + tile.master = new TileLocation(xCoord, yCoord, zCoord); + } + return true; + } + LogHelper.error("Failed to activate structure (activateDraconium)"); + return false; + } - private boolean activateRedstone(int x, int y, int z){ - if (testForOrActivateRedstone(x, y, z, false, false)){ - worldObj.setBlock(x, y, z, ModBlocks.invisibleMultiblock, 1, 2); - TileInvisibleMultiblock tile = (worldObj.getTileEntity(x, y, z) != null && worldObj.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) worldObj.getTileEntity(x, y, z) : null; - if (tile != null) { - tile.master = new TileLocation(xCoord, yCoord, zCoord); - } - return true; - } - LogHelper.error("Failed to activate structure (activateRedstone)"); - return false; - } + private boolean activateRedstone(int x, int y, int z) { + if (testForOrActivateRedstone(x, y, z, false, false)) { + worldObj.setBlock(x, y, z, ModBlocks.invisibleMultiblock, 1, 2); + TileInvisibleMultiblock tile = (worldObj.getTileEntity(x, y, z) != null && worldObj.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) worldObj.getTileEntity(x, y, z) : null; + if (tile != null) { + tile.master = new TileLocation(xCoord, yCoord, zCoord); + } + return true; + } + LogHelper.error("Failed to activate structure (activateRedstone)"); + return false; + } - private boolean isReplacable(int x, int y, int z, boolean set){ - if (set){ - worldObj.setBlock(x, y, z, Blocks.air); - return true; - }else - return worldObj.getBlock(x, y, z).isReplaceable(worldObj, x, y, z) || worldObj.isAirBlock(x, y, z); - } + private boolean isReplacable(int x, int y, int z, boolean set) { + if (set) { + worldObj.setBlock(x, y, z, Blocks.air); + return true; + } else return worldObj.getBlock(x, y, z).isReplaceable(worldObj, x, y, z) || worldObj.isAirBlock(x, y, z); + } - public boolean isOnline(){ - return online; - } + public boolean isOnline() { + return online; + } - private void activateStabilizers(){ - for (int i = 0; i < stabilizers.length; i++) - { - if (stabilizers[i] == null){ - LogHelper.error("activateStabilizers stabalizers["+i+"] == null!!!"); - return; - } - TileParticleGenerator tile = (worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) != null && worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) instanceof TileParticleGenerator) ? (TileParticleGenerator) worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) : null; - if (tile == null) - { - LogHelper.error("Missing Tile Entity (Particle Generator)"); - return; - } - tile.stabalizerMode = true; - tile.setMaster(new TileLocation(xCoord, yCoord, zCoord)); - worldObj.setBlockMetadataWithNotify(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord(), 1, 2); - } - initializeCapacity(); - } + private void activateStabilizers() { + for (int i = 0; i < stabilizers.length; i++) { + if (stabilizers[i] == null) { + LogHelper.error("activateStabilizers stabalizers[" + i + "] == null!!!"); + return; + } + TileParticleGenerator tile = (worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) != null && worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) instanceof TileParticleGenerator) ? (TileParticleGenerator) worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) : null; + if (tile == null) { + LogHelper.error("Missing Tile Entity (Particle Generator)"); + return; + } + tile.stabalizerMode = true; + tile.setMaster(new TileLocation(xCoord, yCoord, zCoord)); + worldObj.setBlockMetadataWithNotify(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord(), 1, 2); + } + initializeCapacity(); + } - private void initializeCapacity() - { - long capacity = 0; - switch (tier){ - case 0: - capacity = BalanceConfigHandler.energyStorageTier1Storage; - break; - case 1: - capacity = BalanceConfigHandler.energyStorageTier2Storage; - break; - case 2: - capacity = BalanceConfigHandler.energyStorageTier3Storage; - break; - case 3: - capacity = BalanceConfigHandler.energyStorageTier4Storage; - break; - case 4: - capacity = BalanceConfigHandler.energyStorageTier5Storage; - break; - case 5: - capacity = BalanceConfigHandler.energyStorageTier6Storage; - break; - case 6: - capacity = BalanceConfigHandler.energyStorageTier7Storage; - break; - } - this.capacity = capacity; - if (energy > capacity) energy = capacity; - } + private void initializeCapacity() { + long capacity = 0; + switch (tier) { + case 0: + capacity = BalanceConfigHandler.energyStorageTier1Storage; + break; + case 1: + capacity = BalanceConfigHandler.energyStorageTier2Storage; + break; + case 2: + capacity = BalanceConfigHandler.energyStorageTier3Storage; + break; + case 3: + capacity = BalanceConfigHandler.energyStorageTier4Storage; + break; + case 4: + capacity = BalanceConfigHandler.energyStorageTier5Storage; + break; + case 5: + capacity = BalanceConfigHandler.energyStorageTier6Storage; + break; + case 6: + capacity = BalanceConfigHandler.energyStorageTier7Storage; + break; + } + this.capacity = capacity; + if (energy > capacity) energy = capacity; + } - public void deactivateStabilizers(){ - for (int i = 0; i < stabilizers.length; i++) - { - if (stabilizers[i] == null){ - LogHelper.error("activateStabilizers stabalizers["+i+"] == null!!!"); - }else { - TileParticleGenerator tile = (worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) != null && worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) instanceof TileParticleGenerator) ? (TileParticleGenerator) worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) : null; - if (tile == null) { - //LogHelper.error("Missing Tile Entity (Particle Generator)"); - }else { - tile.stabalizerMode = false; - worldObj.setBlockMetadataWithNotify(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord(), 0, 2); - } - } - } - } + public void deactivateStabilizers() { + for (int i = 0; i < stabilizers.length; i++) { + if (stabilizers[i] == null) { + LogHelper.error("activateStabilizers stabalizers[" + i + "] == null!!!"); + } else { + TileParticleGenerator tile = (worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) != null && worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) instanceof TileParticleGenerator) ? (TileParticleGenerator) worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) : null; + if (tile == null) { + //LogHelper.error("Missing Tile Entity (Particle Generator)"); + } else { + tile.stabalizerMode = false; + worldObj.setBlockMetadataWithNotify(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord(), 0, 2); + } + } + } + } - private boolean areStabilizersActive(){ - for (int i = 0; i < stabilizers.length; i++) - { - if (stabilizers[i] == null){ - LogHelper.error("activateStabilizers stabalizers["+i+"] == null!!!"); - return false; - } - TileParticleGenerator tile = (worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) != null && worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) instanceof TileParticleGenerator) ? (TileParticleGenerator) worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) : null; - if (tile == null) - { - //LogHelper.error("Missing Tile Entity (Particle Generator)"); - return false; - } - if (!tile.stabalizerMode || worldObj.getBlockMetadata(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) != 1) return false; - } - return true; - } + private boolean areStabilizersActive() { + for (int i = 0; i < stabilizers.length; i++) { + if (stabilizers[i] == null) { + LogHelper.error("activateStabilizers stabalizers[" + i + "] == null!!!"); + return false; + } + TileParticleGenerator tile = (worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) != null && worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) instanceof TileParticleGenerator) ? (TileParticleGenerator) worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) : null; + if (tile == null) { + //LogHelper.error("Missing Tile Entity (Particle Generator)"); + return false; + } + if (!tile.stabalizerMode || worldObj.getBlockMetadata(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) != 1) + return false; + } + return true; + } - private boolean checkStabilizers(){ - for (int i = 0; i < stabilizers.length; i++) - { - if (stabilizers[i] == null) return false; - TileParticleGenerator gen = (worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) != null && worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) instanceof TileParticleGenerator) ? (TileParticleGenerator)worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) : null; - if (gen == null || !gen.stabalizerMode) return false; - if (gen.getMaster().xCoord != xCoord || gen.getMaster().yCoord != yCoord || gen.getMaster().zCoord != zCoord) return false; - } - return true; - } + private boolean checkStabilizers() { + for (int i = 0; i < stabilizers.length; i++) { + if (stabilizers[i] == null) return false; + TileParticleGenerator gen = (worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) != null && worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) instanceof TileParticleGenerator) ? (TileParticleGenerator) worldObj.getTileEntity(stabilizers[i].getXCoord(), stabilizers[i].getYCoord(), stabilizers[i].getZCoord()) : null; + if (gen == null || !gen.stabalizerMode) return false; + if (gen.getMaster().xCoord != xCoord || gen.getMaster().yCoord != yCoord || gen.getMaster().zCoord != zCoord) + return false; + } + return true; + } - public int getTier(){ - return tier; - } - /** - * ############################################################### - */ + public int getTier() { + return tier; + } + + /** + * ############################################################### + */ - @Override - public void writeToNBT(NBTTagCompound compound) { - super.writeToNBT(compound); - compound.setBoolean("Online", online); - compound.setShort("Tier", (short)tier); - compound.setLong("EnergyL", energy); - for (int i = 0; i < stabilizers.length; i++){ - if (stabilizers[i] != null) - stabilizers[i].writeToNBT(compound, String.valueOf(i)); - } - } + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setBoolean("Online", online); + compound.setShort("Tier", (short) tier); + compound.setLong("EnergyL", energy); + for (int i = 0; i < stabilizers.length; i++) { + if (stabilizers[i] != null) stabilizers[i].writeToNBT(compound, String.valueOf(i)); + } + } - @Override - public void readFromNBT(NBTTagCompound compound) { - online = compound.getBoolean("Online"); - tier = (int)compound.getShort("Tier"); - energy = compound.getLong("EnergyL"); - if (compound.hasKey("Energy")) energy = (long) compound.getDouble("Energy"); - for (int i = 0; i < stabilizers.length; i++){ - if (stabilizers[i] != null) - stabilizers[i].readFromNBT(compound, String.valueOf(i)); - } - initializeCapacity(); - super.readFromNBT(compound); - } + @Override + public void readFromNBT(NBTTagCompound compound) { + online = compound.getBoolean("Online"); + tier = (int) compound.getShort("Tier"); + energy = compound.getLong("EnergyL"); + if (compound.hasKey("Energy")) energy = (long) compound.getDouble("Energy"); + for (int i = 0; i < stabilizers.length; i++) { + if (stabilizers[i] != null) stabilizers[i].readFromNBT(compound, String.valueOf(i)); + } + initializeCapacity(); + super.readFromNBT(compound); + } - @Override - public Packet getDescriptionPacket(){ - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeToNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } /* EnergyHandler */ - public int receiveEnergy(int maxReceive, boolean simulate) { - long energyReceived = Math.min(capacity - energy, maxReceive); + public int receiveEnergy(int maxReceive, boolean simulate) { + long energyReceived = Math.min(capacity - energy, maxReceive); - if (!simulate) { - energy += energyReceived; - } - return (int)energyReceived; - } + if (!simulate) { + energy += energyReceived; + } + return (int) energyReceived; + } - public int extractEnergy(int maxExtract, boolean simulate) { - long energyExtracted = Math.min(energy, maxExtract); + public int extractEnergy(int maxExtract, boolean simulate) { + long energyExtracted = Math.min(energy, maxExtract); - if (!simulate) { - energy -= energyExtracted; - } - return (int)energyExtracted; - } + if (!simulate) { + energy -= energyExtracted; + } + return (int) energyExtracted; + } - public long getEnergyStored() { - return energy; - } + public long getEnergyStored() { + return energy; + } - public long getMaxEnergyStored() { - return capacity; - } + public long getMaxEnergyStored() { + return capacity; + } - @Override - public AxisAlignedBB getRenderBoundingBox() { - return INFINITE_EXTENT_AABB; - } + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } - @Override - public double getMaxRenderDistanceSquared() { - return 40960.0D; - } + @Override + public double getMaxRenderDistanceSquared() { + return 40960.0D; + } - private void detectAndRendChanges(){ - if (lastTickCapacity != energy) lastTickCapacity = (Long) sendObjectToClient(References.LONG_ID, 0, energy, new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 20)); - } + private void detectAndRendChanges() { + if (lastTickCapacity != energy) + lastTickCapacity = (Long) sendObjectToClient(References.LONG_ID, 0, energy, new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 20)); + } - @Override - public void receiveObjectFromServer(int index, Object object) { - energy = (Long) object; - } + @Override + public void receiveObjectFromServer(int index, Object object) { + energy = (Long) object; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileInvisibleMultiblock.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileInvisibleMultiblock.java index 3528951a..fc19f59b 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileInvisibleMultiblock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileInvisibleMultiblock.java @@ -14,67 +14,66 @@ import net.minecraft.tileentity.TileEntity; * Created by Brandon on 26/07/2014. */ public class TileInvisibleMultiblock extends TileEntity { - public TileLocation master = new TileLocation(); + public TileLocation master = new TileLocation(); - @Override - public boolean canUpdate() { - return false; - } + @Override + public boolean canUpdate() { + return false; + } - public boolean isMasterOnline() { - TileEnergyStorageCore tile = (worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) != null && worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) : null; - if (tile == null) { - return false; - } - return tile.online; - } + public boolean isMasterOnline() { + TileEnergyStorageCore tile = (worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) != null && worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) : null; + if (tile == null) { + return false; + } + return tile.online; + } - public TileEnergyStorageCore getMaster(){ - if (master == null) return null; - TileEnergyStorageCore tile = (worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) != null && worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) : null; - return tile; - } + public TileEnergyStorageCore getMaster() { + if (master == null) return null; + TileEnergyStorageCore tile = (worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) != null && worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) : null; + return tile; + } - @Override - public void writeToNBT(NBTTagCompound compound) { - super.writeToNBT(compound); - //if (master != null) - master.writeToNBT(compound, "Key"); - } + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + //if (master != null) + master.writeToNBT(compound, "Key"); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - super.readFromNBT(compound); - //if (master != null) - master.readFromNBT(compound, "Key"); - } + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + //if (master != null) + master.readFromNBT(compound, "Key"); + } - @Override - public Packet getDescriptionPacket(){ - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeToNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - public void isStructureStillValid(){ - if (getMaster() == null) { - LogHelper.error("{Tile} Master = null reverting!"); - revert(); - return; - } - if (!getMaster().isOnline()) revert(); - } + public void isStructureStillValid() { + if (getMaster() == null) { + LogHelper.error("{Tile} Master = null reverting!"); + revert(); + return; + } + if (!getMaster().isOnline()) revert(); + } - private void revert(){ - int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); - if (meta == 0) - worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.draconiumBlock); - else if (meta == 1) - worldObj.setBlock(xCoord, yCoord, zCoord, BalanceConfigHandler.energyStorageStructureBlock, BalanceConfigHandler.energyStorageStructureBlockMetadata, 3); - } + private void revert() { + int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); + if (meta == 0) worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.draconiumBlock); + else if (meta == 1) + worldObj.setBlock(xCoord, yCoord, zCoord, BalanceConfigHandler.energyStorageStructureBlock, BalanceConfigHandler.energyStorageStructureBlockMetadata, 3); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TilePortalBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TilePortalBlock.java index c40ca916..abbd7875 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TilePortalBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TilePortalBlock.java @@ -14,70 +14,69 @@ import net.minecraft.tileentity.TileEntity; */ public class TilePortalBlock extends TileEntity { - public int masterX = 0; - public int masterY = 0; - public int masterZ = 0; + public int masterX = 0; + public int masterY = 0; + public int masterZ = 0; - @Override - @SideOnly(Side.SERVER) - public boolean canUpdate() { - return false; - } + @Override + @SideOnly(Side.SERVER) + public boolean canUpdate() { + return false; + } - @Override - @SideOnly(Side.CLIENT) - public void updateEntity() { - if (!worldObj.isRemote) return; - double distanceMod = Utills.getDistanceAtoB(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, RenderManager.renderPosX, RenderManager.renderPosY, RenderManager.renderPosZ); - if (worldObj.rand.nextInt(Math.max((int)(distanceMod * (distanceMod/5D)), 1)) == 0) - { - if (blockMetadata == -1) blockMetadata = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); + @Override + @SideOnly(Side.CLIENT) + public void updateEntity() { + if (!worldObj.isRemote) return; + double distanceMod = Utills.getDistanceAtoB(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, RenderManager.renderPosX, RenderManager.renderPosY, RenderManager.renderPosZ); + if (worldObj.rand.nextInt(Math.max((int) (distanceMod * (distanceMod / 5D)), 1)) == 0) { + if (blockMetadata == -1) blockMetadata = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); - double rD1 = worldObj.rand.nextDouble(); - double rD2 = worldObj.rand.nextDouble(); - double rO1 = -0.1 + worldObj.rand.nextDouble() * 0.2; - double rO2 = -0.1 + worldObj.rand.nextDouble() * 0.2; + double rD1 = worldObj.rand.nextDouble(); + double rD2 = worldObj.rand.nextDouble(); + double rO1 = -0.1 + worldObj.rand.nextDouble() * 0.2; + double rO2 = -0.1 + worldObj.rand.nextDouble() * 0.2; - if (blockMetadata == 1 && RenderManager.renderPosZ < zCoord + 0.5) - DraconicEvolution.proxy.spawnParticle(new Particles.PortalParticle(worldObj, xCoord + rD1, yCoord + rD2, zCoord, xCoord + rD1 + rO1, yCoord + rD2 + rO2, zCoord + 0.75), 256); - else if (blockMetadata == 1 && RenderManager.renderPosZ > zCoord + 0.5) - DraconicEvolution.proxy.spawnParticle(new Particles.PortalParticle(worldObj, xCoord + rD1, yCoord + rD2, zCoord + 1, xCoord + rD1 + rO1, yCoord + rD2 + rO2, zCoord + 0.25), 256); - else if (blockMetadata == 2 && RenderManager.renderPosX < xCoord + 0.5) - DraconicEvolution.proxy.spawnParticle(new Particles.PortalParticle(worldObj, xCoord, yCoord + rD1, zCoord + rD2, xCoord + 0.75, yCoord + rD1 + rO1, zCoord + rD2 + rO2), 256); - else if (blockMetadata == 2 && RenderManager.renderPosX > xCoord + 0.5) - DraconicEvolution.proxy.spawnParticle(new Particles.PortalParticle(worldObj, xCoord + 1, yCoord + rD1, zCoord + rD2, xCoord + 0.25, yCoord + rD1 + rO1, zCoord + rD2 + rO2), 256); - else if (blockMetadata == 3 && RenderManager.renderPosY > yCoord + 0.5) - DraconicEvolution.proxy.spawnParticle(new Particles.PortalParticle(worldObj, xCoord + rD1, yCoord + 1, zCoord + rD2, xCoord + rD1 + rO1, yCoord + 0.25, zCoord + rD2 + rO2), 256); - else if (blockMetadata == 3 && RenderManager.renderPosY < yCoord + 0.5) - DraconicEvolution.proxy.spawnParticle(new Particles.PortalParticle(worldObj, xCoord + rD1, yCoord, zCoord + rD2, xCoord + rD1 + rO1, yCoord + 0.75, zCoord + rD2 + rO2), 256); - } - } + if (blockMetadata == 1 && RenderManager.renderPosZ < zCoord + 0.5) + DraconicEvolution.proxy.spawnParticle(new Particles.PortalParticle(worldObj, xCoord + rD1, yCoord + rD2, zCoord, xCoord + rD1 + rO1, yCoord + rD2 + rO2, zCoord + 0.75), 256); + else if (blockMetadata == 1 && RenderManager.renderPosZ > zCoord + 0.5) + DraconicEvolution.proxy.spawnParticle(new Particles.PortalParticle(worldObj, xCoord + rD1, yCoord + rD2, zCoord + 1, xCoord + rD1 + rO1, yCoord + rD2 + rO2, zCoord + 0.25), 256); + else if (blockMetadata == 2 && RenderManager.renderPosX < xCoord + 0.5) + DraconicEvolution.proxy.spawnParticle(new Particles.PortalParticle(worldObj, xCoord, yCoord + rD1, zCoord + rD2, xCoord + 0.75, yCoord + rD1 + rO1, zCoord + rD2 + rO2), 256); + else if (blockMetadata == 2 && RenderManager.renderPosX > xCoord + 0.5) + DraconicEvolution.proxy.spawnParticle(new Particles.PortalParticle(worldObj, xCoord + 1, yCoord + rD1, zCoord + rD2, xCoord + 0.25, yCoord + rD1 + rO1, zCoord + rD2 + rO2), 256); + else if (blockMetadata == 3 && RenderManager.renderPosY > yCoord + 0.5) + DraconicEvolution.proxy.spawnParticle(new Particles.PortalParticle(worldObj, xCoord + rD1, yCoord + 1, zCoord + rD2, xCoord + rD1 + rO1, yCoord + 0.25, zCoord + rD2 + rO2), 256); + else if (blockMetadata == 3 && RenderManager.renderPosY < yCoord + 0.5) + DraconicEvolution.proxy.spawnParticle(new Particles.PortalParticle(worldObj, xCoord + rD1, yCoord, zCoord + rD2, xCoord + rD1 + rO1, yCoord + 0.75, zCoord + rD2 + rO2), 256); + } + } - public TileDislocatorReceptacle getMaster(){ - return worldObj.getTileEntity(masterX, masterY, masterZ) instanceof TileDislocatorReceptacle ? (TileDislocatorReceptacle)worldObj.getTileEntity(masterX, masterY, masterZ) : null; - } + public TileDislocatorReceptacle getMaster() { + return worldObj.getTileEntity(masterX, masterY, masterZ) instanceof TileDislocatorReceptacle ? (TileDislocatorReceptacle) worldObj.getTileEntity(masterX, masterY, masterZ) : null; + } - public boolean isPortalStillValid(){ - TileDislocatorReceptacle master = getMaster(); - if (master == null || !master.isActive) return false; - master.validateActivePortal(); - return master.isActive; - } + public boolean isPortalStillValid() { + TileDislocatorReceptacle master = getMaster(); + if (master == null || !master.isActive) return false; + master.validateActivePortal(); + return master.isActive; + } - @Override - public void writeToNBT(NBTTagCompound compound) { - super.writeToNBT(compound); - compound.setInteger("MasterX", masterX); - compound.setInteger("MasterY", masterY); - compound.setInteger("MasterZ", masterZ); - } + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setInteger("MasterX", masterX); + compound.setInteger("MasterY", masterY); + compound.setInteger("MasterZ", masterZ); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - super.readFromNBT(compound); - masterX = compound.getInteger("MasterX"); - masterY = compound.getInteger("MasterY"); - masterZ = compound.getInteger("MasterZ"); - } + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + masterX = compound.getInteger("MasterX"); + masterY = compound.getInteger("MasterY"); + masterZ = compound.getInteger("MasterZ"); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/reactor/ReactorExplosion.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/reactor/ReactorExplosion.java index f931a798..f4626aef 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/reactor/ReactorExplosion.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/reactor/ReactorExplosion.java @@ -13,53 +13,52 @@ import java.util.Random; */ public class ReactorExplosion implements IProcess { - public static DamageSource fusionExplosion = new DamageSource("damage.de.fusionExplode").setExplosion().setDamageBypassesArmor().setDamageIsAbsolute().setDamageAllowedInCreativeMode(); + public static DamageSource fusionExplosion = new DamageSource("damage.de.fusionExplode").setExplosion().setDamageBypassesArmor().setDamageIsAbsolute().setDamageAllowedInCreativeMode(); - private World worldObj; - private int xCoord; - private int yCoord; - private int zCoord; - private float power; - private Random random = new Random(); + private World worldObj; + private int xCoord; + private int yCoord; + private int zCoord; + private float power; + private Random random = new Random(); - private double expansion = 0; + private double expansion = 0; - public ReactorExplosion(World world, int x, int y, int z, float power){ - this.worldObj = world; - this.xCoord = x; - this.yCoord = y; - this.zCoord = z; - this.power = power; - isDead = world.isRemote; - } + public ReactorExplosion(World world, int x, int y, int z, float power) { + this.worldObj = world; + this.xCoord = x; + this.yCoord = y; + this.zCoord = z; + this.power = power; + isDead = world.isRemote; + } - @Override - public void updateProcess() { + @Override + public void updateProcess() { - int OD = (int) expansion; - int ID = OD - 1; - int size = (int) expansion; + int OD = (int) expansion; + int ID = OD - 1; + int size = (int) expansion; - for (int x = xCoord - size; x < xCoord + size; x++){ - for (int z = zCoord - size; z < zCoord + size; z++){ - double dist = Utills.getDistanceAtoB(x, z, xCoord, zCoord); - if (dist < OD && dist >= ID) - { - float tracePower = power - (float)(expansion/10D); - tracePower *= 1F + ((random.nextFloat() - 0.5F) * 0.2); - ProcessHandler.addProcess(new ReactorExplosionTrace(worldObj, x, yCoord, z, tracePower, random)); - } - } - } + for (int x = xCoord - size; x < xCoord + size; x++) { + for (int z = zCoord - size; z < zCoord + size; z++) { + double dist = Utills.getDistanceAtoB(x, z, xCoord, zCoord); + if (dist < OD && dist >= ID) { + float tracePower = power - (float) (expansion / 10D); + tracePower *= 1F + ((random.nextFloat() - 0.5F) * 0.2); + ProcessHandler.addProcess(new ReactorExplosionTrace(worldObj, x, yCoord, z, tracePower, random)); + } + } + } - isDead = expansion >= power * 10; - expansion += 1; - } + isDead = expansion >= power * 10; + expansion += 1; + } - private boolean isDead = false; + private boolean isDead = false; - @Override - public boolean isDead() { - return isDead; - } + @Override + public boolean isDead() { + return isDead; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/reactor/ReactorExplosionTrace.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/reactor/ReactorExplosionTrace.java index a20f2544..f82d8c1e 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/reactor/ReactorExplosionTrace.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/reactor/ReactorExplosionTrace.java @@ -16,72 +16,73 @@ import java.util.Random; */ public class ReactorExplosionTrace implements IProcess { - private World worldObj; - private int xCoord; - private int yCoord; - private int zCoord; - private float power; - private Random random; + private World worldObj; + private int xCoord; + private int yCoord; + private int zCoord; + private float power; + private Random random; - public ReactorExplosionTrace(World world, int x, int y, int z, float power, Random random){ - this.worldObj = world; - this.xCoord = x; - this.yCoord = y; - this.zCoord = z; - this.power = power; - this.random = random; - } + public ReactorExplosionTrace(World world, int x, int y, int z, float power, Random random) { + this.worldObj = world; + this.xCoord = x; + this.yCoord = y; + this.zCoord = z; + this.power = power; + this.random = random; + } - @Override - public void updateProcess() { + @Override + public void updateProcess() { - float energy = power * 10; + float energy = power * 10; - for (int y = yCoord; y > 0 && energy > 0; y--){ - Block block = worldObj.getBlock(xCoord, y, zCoord); + for (int y = yCoord; y > 0 && energy > 0; y--) { + Block block = worldObj.getBlock(xCoord, y, zCoord); - List entities = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord, y, zCoord, xCoord+1, y+1, zCoord+1)); - for (Entity entity : entities) entity.attackEntityFrom(ReactorExplosion.fusionExplosion, power * 100); + List entities = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord, y, zCoord, xCoord + 1, y + 1, zCoord + 1)); + for (Entity entity : entities) entity.attackEntityFrom(ReactorExplosion.fusionExplosion, power * 100); - energy -= block instanceof BlockLiquid ? 10 : block.getExplosionResistance(null); + energy -= block instanceof BlockLiquid ? 10 : block.getExplosionResistance(null); - boolean blockRemoved = false; - if (energy >= 0 && block != Blocks.air) { - worldObj.setBlockToAir(xCoord, y, zCoord); - blockRemoved = true; - } - energy -= 0.5F + (0.1F * (yCoord - y)); + boolean blockRemoved = false; + if (energy >= 0 && block != Blocks.air) { + worldObj.setBlockToAir(xCoord, y, zCoord); + blockRemoved = true; + } + energy -= 0.5F + (0.1F * (yCoord - y)); - if (energy <= 0 && random.nextInt(20) == 0 && blockRemoved) { - if (random.nextInt(3) > 0) worldObj.setBlock(xCoord, y, zCoord, Blocks.fire); - else { - worldObj.setBlock(xCoord, y, zCoord, Blocks.flowing_lava); - //worldObj.scheduleBlockUpdate(xCoord, y, zCoord, Blocks.flowing_lava, 100); - } - } - } + if (energy <= 0 && random.nextInt(20) == 0 && blockRemoved) { + if (random.nextInt(3) > 0) worldObj.setBlock(xCoord, y, zCoord, Blocks.fire); + else { + worldObj.setBlock(xCoord, y, zCoord, Blocks.flowing_lava); + //worldObj.scheduleBlockUpdate(xCoord, y, zCoord, Blocks.flowing_lava, 100); + } + } + } - energy = power * 20; - yCoord++; - for (int y = yCoord; y < 255 && energy > 0; y++){ - Block block = worldObj.getBlock(xCoord, y, zCoord); + energy = power * 20; + yCoord++; + for (int y = yCoord; y < 255 && energy > 0; y++) { + Block block = worldObj.getBlock(xCoord, y, zCoord); - List entities = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord, y, zCoord, xCoord+1, y+1, zCoord+1)); - for (Entity entity : entities) entity.attackEntityFrom(ReactorExplosion.fusionExplosion, power * 100); + List entities = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord, y, zCoord, xCoord + 1, y + 1, zCoord + 1)); + for (Entity entity : entities) entity.attackEntityFrom(ReactorExplosion.fusionExplosion, power * 100); - energy -= block instanceof BlockLiquid ? 10 : block.getExplosionResistance(null); - if (energy >= 0) worldObj.setBlockToAir(xCoord, y, zCoord); + energy -= block instanceof BlockLiquid ? 10 : block.getExplosionResistance(null); + if (energy >= 0) worldObj.setBlockToAir(xCoord, y, zCoord); - energy -= 0.5F + (0.1F * (y - yCoord)); - } + energy -= 0.5F + (0.1F * (y - yCoord)); + } - isDead = true; - } + isDead = true; + } - private boolean isDead = false; - @Override - public boolean isDead() { - return isDead; - } + private boolean isDead = false; + + @Override + public boolean isDead() { + return isDead; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/reactor/TileReactorCore.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/reactor/TileReactorCore.java index d08bb5a2..1246f472 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/reactor/TileReactorCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/reactor/TileReactorCore.java @@ -33,535 +33,574 @@ import java.util.List; * Created by Brandon on 16/6/2015. */ public class TileReactorCore extends TileObjectSync { - public static final int MAX_SLAVE_RANGE = 10; - public static final int STATE_OFFLINE = 0; - public static final int STATE_START = 1; - public static final int STATE_ONLINE = 2; - public static final int STATE_STOP = 3; - public static final int STATE_INVALID = 4; + public static final int MAX_SLAVE_RANGE = 10; + public static final int STATE_OFFLINE = 0; + public static final int STATE_START = 1; + public static final int STATE_ONLINE = 2; + public static final int STATE_STOP = 3; + public static final int STATE_INVALID = 4; - public int reactorState = 0; - public float renderRotation = 0; - public float renderSpeed = 0; - public boolean isStructureValid = false; - public float stabilizerRender = 0F; - private boolean startupInitialized = false; - public int tick = 0; + public int reactorState = 0; + public float renderRotation = 0; + public float renderSpeed = 0; + public boolean isStructureValid = false; + public float stabilizerRender = 0F; + private boolean startupInitialized = false; + public int tick = 0; - //Key operational figures - public int reactorFuel = 0; - public int convertedFuel = 0; //The amount of fuel that has converted - public double conversionUnit = 0; //used to smooth out the conversion between int and floating point. When >= 1 minus one and convert one int worth of fuel + //Key operational figures + public int reactorFuel = 0; + public int convertedFuel = 0; //The amount of fuel that has converted + public double conversionUnit = 0; //used to smooth out the conversion between int and floating point. When >= 1 minus one and convert one int worth of fuel - public double reactionTemperature = 20; - public double maxReactTemperature = 10000; + public double reactionTemperature = 20; + public double maxReactTemperature = 10000; - public double fieldCharge = 0; - public double maxFieldCharge = 0; + public double fieldCharge = 0; + public double maxFieldCharge = 0; - public int energySaturation = 0; - public int maxEnergySaturation = 0; + public int energySaturation = 0; + public int maxEnergySaturation = 0; - @SideOnly(Side.CLIENT) - private ReactorSound reactorSound; + @SideOnly(Side.CLIENT) + private ReactorSound reactorSound; - //####################### + //####################### - //TODO DONT FORGET TO ACTUALLY FINISH ALL THESE THINGS!!!! + //TODO DONT FORGET TO ACTUALLY FINISH ALL THESE THINGS!!!! //Check //-Bounding box //Check //-Custom player collision //Check //-Finish stabilizer place and break mechanics //Check //-Have the GUI tell you if the structure is invalid //Check //-Config - //TODO things for later - //-GUI info (maby speed up gui sync via the container) - //-GUI warning red bars - //-Maby get around to setting the angle of the stabiliser elements + //TODO things for later + //-GUI info (maby speed up gui sync via the container) + //-GUI warning red bars + //-Maby get around to setting the angle of the stabiliser elements //Check //-SOUND!!!!! //Check //-CC Integration //Check //-Redstone - //-Add reactor and gates to tablet + //-Add reactor and gates to tablet - public List stabilizerLocations = new ArrayList(); + public List stabilizerLocations = new ArrayList(); - @Override - public void updateEntity() { - tick++; - if (worldObj.isRemote) { - updateSound(); + @Override + public void updateEntity() { + tick++; + if (worldObj.isRemote) { + updateSound(); - renderSpeed = (float)Math.min((reactionTemperature-20) / 2000D, 1D); - stabilizerRender = (float)Math.min(fieldCharge / (maxFieldCharge * 0.1D), 1D); - renderRotation += renderSpeed; - //LogHelper.info(renderSpeed +" "+(reactionTemperature)); - checkPlayerCollision(); - return; - } - //else injectEnergy(10000000); + renderSpeed = (float) Math.min((reactionTemperature - 20) / 2000D, 1D); + stabilizerRender = (float) Math.min(fieldCharge / (maxFieldCharge * 0.1D), 1D); + renderRotation += renderSpeed; + //LogHelper.info(renderSpeed +" "+(reactionTemperature)); + checkPlayerCollision(); + return; + } + //else injectEnergy(10000000); - switch (reactorState){ - case STATE_OFFLINE: - offlineTick(); - break; - case STATE_START: - startingTick(); - break; - case STATE_ONLINE: - runTick(); - break; - case STATE_STOP: - runTick(); - break; - } + switch (reactorState) { + case STATE_OFFLINE: + offlineTick(); + break; + case STATE_START: + startingTick(); + break; + case STATE_ONLINE: + runTick(); + break; + case STATE_STOP: + runTick(); + break; + } - detectAndSendChanges(); - } + detectAndSendChanges(); + } - @SideOnly(Side.CLIENT) - private void updateSound(){if (reactorSound == null) reactorSound = (ReactorSound)DraconicEvolution.proxy.playISound(new ReactorSound(this));} + @SideOnly(Side.CLIENT) + private void updateSound() { + if (reactorSound == null) + reactorSound = (ReactorSound) DraconicEvolution.proxy.playISound(new ReactorSound(this)); + } - private void checkPlayerCollision(){ - EntityPlayer player = BrandonsCore.proxy.getClientPlayer(); - double distance = Utills.getDistanceAtoB(player.posX, player.posY, player.posZ, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); - if (distance < (getCoreDiameter()/2) + 0.5){ - double dMod = 1D - (distance / Math.max(0.1, (getCoreDiameter()/2) + 0.5)); - double offsetX = player.posX - xCoord + 0.5; - double offsetY = player.posY - yCoord + 0.5; - double offsetZ = player.posZ - zCoord + 0.5; - double m = 1D * dMod; - player.addVelocity(offsetX*m, offsetY*m, offsetZ*m); - } - } + private void checkPlayerCollision() { + EntityPlayer player = BrandonsCore.proxy.getClientPlayer(); + double distance = Utills.getDistanceAtoB(player.posX, player.posY, player.posZ, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + if (distance < (getCoreDiameter() / 2) + 0.5) { + double dMod = 1D - (distance / Math.max(0.1, (getCoreDiameter() / 2) + 0.5)); + double offsetX = player.posX - xCoord + 0.5; + double offsetY = player.posY - yCoord + 0.5; + double offsetZ = player.posZ - zCoord + 0.5; + double m = 1D * dMod; + player.addVelocity(offsetX * m, offsetY * m, offsetZ * m); + } + } - private void offlineTick(){ - if (reactionTemperature > 20) reactionTemperature -= 0.5; - if (fieldCharge > 0) fieldCharge-=maxFieldCharge * 0.0005; - else if (fieldCharge < 0) fieldCharge = 0; - if (energySaturation > 0) energySaturation-=maxEnergySaturation * 0.000001; - else if (energySaturation < 0) energySaturation = 0; - } + private void offlineTick() { + if (reactionTemperature > 20) reactionTemperature -= 0.5; + if (fieldCharge > 0) fieldCharge -= maxFieldCharge * 0.0005; + else if (fieldCharge < 0) fieldCharge = 0; + if (energySaturation > 0) energySaturation -= maxEnergySaturation * 0.000001; + else if (energySaturation < 0) energySaturation = 0; + } - private void startingTick(){ - if (!startupInitialized){ - int totalFuel = reactorFuel + convertedFuel; - maxFieldCharge = totalFuel * 96.45061728395062 * 100; - maxEnergySaturation = (int)(totalFuel * 96.45061728395062 * 1000); - if (energySaturation > maxEnergySaturation) energySaturation = maxEnergySaturation; - if (fieldCharge > maxFieldCharge) fieldCharge = maxFieldCharge; - startupInitialized = true; - } - } + private void startingTick() { + if (!startupInitialized) { + int totalFuel = reactorFuel + convertedFuel; + maxFieldCharge = totalFuel * 96.45061728395062 * 100; + maxEnergySaturation = (int) (totalFuel * 96.45061728395062 * 1000); + if (energySaturation > maxEnergySaturation) energySaturation = maxEnergySaturation; + if (fieldCharge > maxFieldCharge) fieldCharge = maxFieldCharge; + startupInitialized = true; + } + } + private boolean hasExploded = false; - private boolean hasExploded = false; + public double tempDrainFactor; + public double generationRate; + public int fieldDrain; + public double fieldInputRate; + public double fuelUseRate; - public double tempDrainFactor; - public double generationRate; - public int fieldDrain; - public double fieldInputRate; - public double fuelUseRate; + private void runTick() { + //Inverted core saturation (if multiplied by 100 this creates infinite numbers which breaks the code) + double saturation = ((double) energySaturation / (double) maxEnergySaturation); + double saturationI = (1D - ((double) energySaturation / (double) maxEnergySaturation)) * 99D; + double temp = ((reactionTemperature) / maxReactTemperature) * 50D; + //The conversion level. Ranges from -0.3 to 1.0 + double conversion = (((double) convertedFuel + conversionUnit) / ((double) (convertedFuel + reactorFuel) - conversionUnit) * 1.3) - 0.3D; - private void runTick(){ - //Inverted core saturation (if multiplied by 100 this creates infinite numbers which breaks the code) - double saturation = ((double)energySaturation / (double)maxEnergySaturation); - double saturationI = (1D - ((double)energySaturation / (double)maxEnergySaturation)) * 99D; - double temp = ((reactionTemperature) / maxReactTemperature) * 50D; - //The conversion level. Ranges from -0.3 to 1.0 - double conversion = (((double)convertedFuel + conversionUnit) / ((double)(convertedFuel + reactorFuel) - conversionUnit) * 1.3) - 0.3D; - - //Temperature Calculation - double tempOffset = 444.7; //Adjusts where the temp falls to at 100% saturation - //The exponential temperature rise which increases as the core saturation goes down - double tempRiseExpo = (saturationI * saturationI * saturationI) / (100 - saturationI) + tempOffset; - //This is used to add resistance as the temp rises because the hotter something gets the more energy it takes to get it hotter - double tempRiseResist = (temp * temp * temp * temp) / (100 - temp); - //This puts all the numbers together and gets the value to raise or lower the temp by this tick. This is dealing with very big numbers so the result is divided by 10000 - double riseAmount = (tempRiseExpo - (tempRiseResist * (1D-conversion)) + conversion * 1000) / 10000; - if (reactorState == STATE_STOP){ - if (reactionTemperature <= 2001) { - reactorState = STATE_OFFLINE; - startupInitialized = false; - return; - } - if (energySaturation >= maxEnergySaturation * 0.99 && reactorFuel > 0) reactionTemperature -= 1D-conversion; - else reactionTemperature += riseAmount*10; - } - else reactionTemperature += riseAmount*10; + //Temperature Calculation + double tempOffset = 444.7; //Adjusts where the temp falls to at 100% saturation + //The exponential temperature rise which increases as the core saturation goes down + double tempRiseExpo = (saturationI * saturationI * saturationI) / (100 - saturationI) + tempOffset; + //This is used to add resistance as the temp rises because the hotter something gets the more energy it takes to get it hotter + double tempRiseResist = (temp * temp * temp * temp) / (100 - temp); + //This puts all the numbers together and gets the value to raise or lower the temp by this tick. This is dealing with very big numbers so the result is divided by 10000 + double riseAmount = (tempRiseExpo - (tempRiseResist * (1D - conversion)) + conversion * 1000) / 10000; + if (reactorState == STATE_STOP) { + if (reactionTemperature <= 2001) { + reactorState = STATE_OFFLINE; + startupInitialized = false; + return; + } + if (energySaturation >= maxEnergySaturation * 0.99 && reactorFuel > 0) + reactionTemperature -= 1D - conversion; + else reactionTemperature += riseAmount * 10; + } else reactionTemperature += riseAmount * 10; - //====================== + //====================== - //Energy Calculation - int baseMaxRFt = (int)((maxEnergySaturation / 1000D) * ConfigHandler.reactorOutputMultiplier * 1.5D); - int maxRFt = (int)(baseMaxRFt * (1D+(conversion*2))); - generationRate = (1D - saturation) * maxRFt; - energySaturation += generationRate; + //Energy Calculation + int baseMaxRFt = (int) ((maxEnergySaturation / 1000D) * ConfigHandler.reactorOutputMultiplier * 1.5D); + int maxRFt = (int) (baseMaxRFt * (1D + (conversion * 2))); + generationRate = (1D - saturation) * maxRFt; + energySaturation += generationRate; - //LogHelper.info((1D - saturation) * maxRFt); - //====================== + //LogHelper.info((1D - saturation) * maxRFt); + //====================== - //When temp < 1000 power drain is 0, when temp > 2000 power drain is 1, when temp > 8000 power drain increases exponentially - tempDrainFactor = reactionTemperature > 8000 ? 1 + ((reactionTemperature-8000) * (reactionTemperature-8000) * 0.0000025) : reactionTemperature > 2000 ? 1 : reactionTemperature > 1000 ? (reactionTemperature-1000)/1000 : 0; - //todo add to guiInfo - //-temp drain factor - //-mass - //-generation - //-field drain + //When temp < 1000 power drain is 0, when temp > 2000 power drain is 1, when temp > 8000 power drain increases exponentially + tempDrainFactor = reactionTemperature > 8000 ? 1 + ((reactionTemperature - 8000) * (reactionTemperature - 8000) * 0.0000025) : reactionTemperature > 2000 ? 1 : reactionTemperature > 1000 ? (reactionTemperature - 1000) / 1000 : 0; + //todo add to guiInfo + //-temp drain factor + //-mass + //-generation + //-field drain - //Field Drain Calculation - fieldDrain = (int)Math.min(tempDrainFactor * (1D-saturation) * (baseMaxRFt / 10.923556), (double) Integer.MAX_VALUE); //<(baseMaxRFt/make smaller to increase field power drain) + //Field Drain Calculation + fieldDrain = (int) Math.min(tempDrainFactor * (1D - saturation) * (baseMaxRFt / 10.923556), (double) Integer.MAX_VALUE); //<(baseMaxRFt/make smaller to increase field power drain) - double fieldNegPercent = 1D - (fieldCharge / maxFieldCharge); - fieldInputRate = fieldDrain / fieldNegPercent; + double fieldNegPercent = 1D - (fieldCharge / maxFieldCharge); + fieldInputRate = fieldDrain / fieldNegPercent; // LogHelper.info(fieldDrain+" "+tempDrainFactor+" "+(1D-saturation)+" "+tempDrainFactor * (1D-saturation) * (baseMaxRFt/10.923556)); - fieldCharge -= fieldDrain; - //====================== + fieldCharge -= fieldDrain; + //====================== - //Calculate Fuel Usage - fuelUseRate = tempDrainFactor * (1D-saturation) * (0.001 * ConfigHandler.reactorFuelUsageMultiplier); //= 1 && reactorFuel > 0){ - conversionUnit--; - reactorFuel--; - convertedFuel++; - } + //Calculate Fuel Usage + fuelUseRate = tempDrainFactor * (1D - saturation) * (0.001 * ConfigHandler.reactorFuelUsageMultiplier); //= 1 && reactorFuel > 0) { + conversionUnit--; + reactorFuel--; + convertedFuel++; + } - //==================== + //==================== - //Make BOOM!!! - if ((fieldCharge <= 0) && !hasExploded) { - hasExploded = true; - goBoom(); - } - //=========== - } + //Make BOOM!!! + if ((fieldCharge <= 0) && !hasExploded) { + hasExploded = true; + goBoom(); + } + //=========== + } - private void goBoom(){ - if (!ConfigHandler.enableReactorBigBoom){ - worldObj.createExplosion(null, xCoord, yCoord, zCoord, 5, true); - }else - { - //float power = 10F + Math.min(10F, ((float) (convertedFuel + reactorFuel) / 10369F) * 10F); - float power = 2F + (((float) (convertedFuel + reactorFuel) / 10369F) * 18F); - ProcessHandler.addProcess(new ReactorExplosion(worldObj, xCoord, yCoord, zCoord, power)); - sendObjectToClient(References.INT_ID, 100, (int) (power * 10F), new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 512)); - } - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - } + private void goBoom() { + if (!ConfigHandler.enableReactorBigBoom) { + worldObj.createExplosion(null, xCoord, yCoord, zCoord, 5, true); + } else { + //float power = 10F + Math.min(10F, ((float) (convertedFuel + reactorFuel) / 10369F) * 10F); + float power = 2F + (((float) (convertedFuel + reactorFuel) / 10369F) * 18F); + ProcessHandler.addProcess(new ReactorExplosion(worldObj, xCoord, yCoord, zCoord, power)); + sendObjectToClient(References.INT_ID, 100, (int) (power * 10F), new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 512)); + } + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + } - public void validateStructure(){ - boolean updateRequired = false; - //Check that all of the stabilizers are still valid - Iterator i = stabilizerLocations.iterator(); - List stabilizers = new ArrayList(); - while (i.hasNext()) { - TileLocation location = i.next(); - if (!(location.getTileEntity(worldObj) instanceof TileReactorStabilizer) || !((TileReactorStabilizer) location.getTileEntity(worldObj)).masterLocation.isThisLocation(xCoord, yCoord, zCoord)) { - i.remove(); - updateRequired = true; - } - else stabilizers.add((TileReactorStabilizer) location.getTileEntity(worldObj)); - } + public void validateStructure() { + boolean updateRequired = false; + //Check that all of the stabilizers are still valid + Iterator i = stabilizerLocations.iterator(); + List stabilizers = new ArrayList(); + while (i.hasNext()) { + TileLocation location = i.next(); + if (!(location.getTileEntity(worldObj) instanceof TileReactorStabilizer) || !((TileReactorStabilizer) location.getTileEntity(worldObj)).masterLocation.isThisLocation(xCoord, yCoord, zCoord)) { + i.remove(); + updateRequired = true; + } else stabilizers.add((TileReactorStabilizer) location.getTileEntity(worldObj)); + } - //Check that there are 4 stabilizers in the correct configuration - isStructureValid = false; - List checkList = new ArrayList(); - for (TileReactorStabilizer stabilizer : stabilizers){ - if (checkList.contains(stabilizer)) continue; + //Check that there are 4 stabilizers in the correct configuration + isStructureValid = false; + List checkList = new ArrayList(); + for (TileReactorStabilizer stabilizer : stabilizers) { + if (checkList.contains(stabilizer)) continue; - for (TileReactorStabilizer comp : stabilizers){ - if (!(comp == stabilizer || checkList.contains(comp)) && ForgeDirection.getOrientation(comp.facingDirection) == ForgeDirection.getOrientation(stabilizer.facingDirection).getOpposite()){ - checkList.add(comp); - checkList.add(stabilizer); - if (checkList.size() == 4){ - isStructureValid = true; - if (reactorState == STATE_INVALID) reactorState = STATE_OFFLINE; - break; - } - } - } - } + for (TileReactorStabilizer comp : stabilizers) { + if (!(comp == stabilizer || checkList.contains(comp)) && ForgeDirection.getOrientation(comp.facingDirection) == ForgeDirection.getOrientation(stabilizer.facingDirection).getOpposite()) { + checkList.add(comp); + checkList.add(stabilizer); + if (checkList.size() == 4) { + isStructureValid = true; + if (reactorState == STATE_INVALID) reactorState = STATE_OFFLINE; + break; + } + } + } + } - for (TileReactorStabilizer stabilizer : stabilizers){ - if (Utills.getDistanceAtoB(stabilizer.xCoord, stabilizer.yCoord, stabilizer.zCoord, xCoord, yCoord, zCoord) < (getMaxCoreDiameter()/2)+1) { - isStructureValid = false; - break; - } - } + for (TileReactorStabilizer stabilizer : stabilizers) { + if (Utills.getDistanceAtoB(stabilizer.xCoord, stabilizer.yCoord, stabilizer.zCoord, xCoord, yCoord, zCoord) < (getMaxCoreDiameter() / 2) + 1) { + isStructureValid = false; + break; + } + } + if (!isStructureValid) { + reactorState = STATE_INVALID; + if (reactionTemperature >= 2000) { + goBoom(); + } + } - if (!isStructureValid) { - reactorState = STATE_INVALID; - if (reactionTemperature >= 2000){ - goBoom(); - } - } + if (updateRequired) worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } - if (updateRequired) worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } + public void onPlaced() { + for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { + boolean flag = false; + for (int i = 1; i < MAX_SLAVE_RANGE && !flag; i++) { + TileLocation location = new TileLocation(xCoord + direction.offsetX * i, yCoord + direction.offsetY * i, zCoord + direction.offsetZ * i); + if (location.getTileEntity(worldObj) != null) { + if (location.getTileEntity(worldObj) instanceof IReactorPart && !((IReactorPart) location.getTileEntity(worldObj)).getMaster().initialized) + ((IReactorPart) location.getTileEntity(worldObj)).checkForMaster(); + flag = true; + } + } + } + validateStructure(); + } - public void onPlaced(){ - for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS){ - boolean flag = false; - for (int i = 1; i < MAX_SLAVE_RANGE && !flag; i++){ - TileLocation location = new TileLocation(xCoord + direction.offsetX * i, yCoord + direction.offsetY * i, zCoord + direction.offsetZ * i); - if (location.getTileEntity(worldObj) != null){ - if (location.getTileEntity(worldObj) instanceof IReactorPart && !((IReactorPart) location.getTileEntity(worldObj)).getMaster().initialized) ((IReactorPart) location.getTileEntity(worldObj)).checkForMaster(); - flag = true; - } - } - } - validateStructure(); - } + public void onBroken() { + for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { + for (int i = 1; i < MAX_SLAVE_RANGE; i++) { + TileLocation location = new TileLocation(xCoord + direction.offsetX * i, yCoord + direction.offsetY * i, zCoord + direction.offsetZ * i); + if (location.getTileEntity(worldObj) instanceof IReactorPart && ((IReactorPart) location.getTileEntity(worldObj)).getMaster().compareTo(new TileLocation(xCoord, yCoord, zCoord)) == 0) + ((IReactorPart) location.getTileEntity(worldObj)).shutDown(); + } + } - public void onBroken(){ - for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS){ - for (int i = 1; i < MAX_SLAVE_RANGE; i++){ - TileLocation location = new TileLocation(xCoord + direction.offsetX * i, yCoord + direction.offsetY * i, zCoord + direction.offsetZ * i); - if (location.getTileEntity(worldObj) instanceof IReactorPart && ((IReactorPart) location.getTileEntity(worldObj)).getMaster().compareTo(new TileLocation(xCoord, yCoord, zCoord)) == 0) ((IReactorPart)location.getTileEntity(worldObj)).shutDown(); - } - } + if (reactionTemperature >= 2000) { + goBoom(); + } - if (reactionTemperature >= 2000) { - goBoom(); - } + } - } + public boolean onStructureRightClicked(EntityPlayer player) { + if (!worldObj.isRemote) + player.openGui(DraconicEvolution.instance, GuiHandler.GUIID_REACTOR, worldObj, xCoord, yCoord, zCoord); + return true; + } - public boolean onStructureRightClicked(EntityPlayer player){ - if (!worldObj.isRemote) player.openGui(DraconicEvolution.instance, GuiHandler.GUIID_REACTOR, worldObj, xCoord, yCoord, zCoord); - return true; - } + public int injectEnergy(int RF) { + int received = 0; + if (reactorState == STATE_START) { + if (!startupInitialized) return 0; + if (fieldCharge < (maxFieldCharge / 2)) { + received = Math.min(RF, (int) (maxFieldCharge / 2) - (int) fieldCharge + 1); + fieldCharge += received; + if (fieldCharge > (maxFieldCharge / 2)) fieldCharge = (maxFieldCharge / 2); + } else if (energySaturation < (maxEnergySaturation / 2)) { + received = Math.min(RF, (maxEnergySaturation / 2) - energySaturation); + energySaturation += received; + } else if (reactionTemperature < 2000) { + received = RF; + reactionTemperature += ((double) received / (1000D + (reactorFuel * 10))); + if (reactionTemperature > 2000) reactionTemperature = 2000; + } + } else if (reactorState == STATE_ONLINE || reactorState == STATE_STOP) { + fieldCharge += (RF * (1D - (fieldCharge / maxFieldCharge))); + if (fieldCharge > maxFieldCharge) fieldCharge = maxFieldCharge; + return RF; + } + return received; + } - public int injectEnergy(int RF){ - int received = 0; - if (reactorState == STATE_START){ - if (!startupInitialized) return 0; - if (fieldCharge < (maxFieldCharge / 2)) { - received = Math.min(RF, (int)(maxFieldCharge/2) - (int)fieldCharge + 1); - fieldCharge += received; - if (fieldCharge > (maxFieldCharge/2)) fieldCharge = (maxFieldCharge/2); - } - else if (energySaturation < (maxEnergySaturation / 2)) { - received = Math.min(RF, (maxEnergySaturation/2) - energySaturation); - energySaturation += received; - } - else if (reactionTemperature < 2000) { - received = RF; - reactionTemperature += ((double)received / (1000D + (reactorFuel * 10))); - if (reactionTemperature > 2000) reactionTemperature = 2000; - } - } - else if (reactorState == STATE_ONLINE || reactorState == STATE_STOP){ - fieldCharge += (RF * (1D-(fieldCharge/maxFieldCharge))); - if (fieldCharge > maxFieldCharge) fieldCharge = maxFieldCharge; - return RF; - } - return received; - } + public boolean canStart() { + validateStructure(); + return reactionTemperature >= 2000 && fieldCharge >= (maxFieldCharge / 2) && energySaturation >= (maxEnergySaturation / 2) && isStructureValid && convertedFuel + reactorFuel + conversionUnit >= 144; + } - public boolean canStart(){ - validateStructure(); - return reactionTemperature >= 2000 && fieldCharge >= (maxFieldCharge / 2) && energySaturation >= (maxEnergySaturation / 2) && isStructureValid && convertedFuel + reactorFuel + conversionUnit >= 144; - } + public boolean canCharge() { + validateStructure(); + return reactorState != STATE_ONLINE && isStructureValid && convertedFuel + reactorFuel + conversionUnit >= 144; + } - public boolean canCharge() { - validateStructure(); - return reactorState != STATE_ONLINE && isStructureValid && convertedFuel + reactorFuel + conversionUnit >= 144; - } - - public boolean canStop(){ - validateStructure(); - return reactorState != STATE_OFFLINE && isStructureValid; - } + public boolean canStop() { + validateStructure(); + return reactorState != STATE_OFFLINE && isStructureValid; + } - public void processButtonPress(int button){ - if (button == 0 && canCharge()) reactorState = STATE_START; - else if (button == 1 && canStart()) reactorState = STATE_ONLINE; - else if (button == 2 && canStop()) reactorState = STATE_STOP; - } + public void processButtonPress(int button) { + if (button == 0 && canCharge()) reactorState = STATE_START; + else if (button == 1 && canStart()) reactorState = STATE_ONLINE; + else if (button == 2 && canStop()) reactorState = STATE_STOP; + } - public double getCoreDiameter(){//todo adjust so the core dose not expand before 1000>2000c - //return (((1F + Math.sin((float)tick/50F)) / 2F) * 4) + 0.3; - double volume = (double)(reactorFuel + convertedFuel) / 1296D; - volume *= 1 + (reactionTemperature / maxReactTemperature) * 10D; - return Math.cbrt(volume / (4/3 * Math.PI)) * 2; - } + public double getCoreDiameter() {//todo adjust so the core dose not expand before 1000>2000c + //return (((1F + Math.sin((float)tick/50F)) / 2F) * 4) + 0.3; + double volume = (double) (reactorFuel + convertedFuel) / 1296D; + volume *= 1 + (reactionTemperature / maxReactTemperature) * 10D; + return Math.cbrt(volume / (4 / 3 * Math.PI)) * 2; + } - public double getMaxCoreDiameter(){ - //return (((1F + Math.sin((float)tick/50F)) / 2F) * 4) + 0.3; - double volume = (double)(reactorFuel + convertedFuel) / 1296D; - volume *= 1 + 1 * 10D; - return Math.cbrt(volume / (4/3 * Math.PI)) * 2; - } + public double getMaxCoreDiameter() { + //return (((1F + Math.sin((float)tick/50F)) / 2F) * 4) + 0.3; + double volume = (double) (reactorFuel + convertedFuel) / 1296D; + volume *= 1 + 1 * 10D; + return Math.cbrt(volume / (4 / 3 * Math.PI)) * 2; + } - private boolean isStructureValidCach = false; - private boolean startupInitializedCach = false; - private int reactorStateCach = -1; - private int reactorFuelCach = -1; - private int convertedFuelCach = -1; - private int energySaturationCach = -1; - private int maxEnergySaturationCach = -1; - private double reactionTemperatureCach = -1; - private double maxReactTemperatureCach = -1; - private double fieldChargeCach = -1; - private double maxFieldChargeCach = -1; + private boolean isStructureValidCach = false; + private boolean startupInitializedCach = false; + private int reactorStateCach = -1; + private int reactorFuelCach = -1; + private int convertedFuelCach = -1; + private int energySaturationCach = -1; + private int maxEnergySaturationCach = -1; + private double reactionTemperatureCach = -1; + private double maxReactTemperatureCach = -1; + private double fieldChargeCach = -1; + private double maxFieldChargeCach = -1; - private void detectAndSendChanges(){ - NetworkRegistry.TargetPoint tp = new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 128); - if (reactionTemperatureCach != reactionTemperature) reactionTemperatureCach = (Double) sendObjectToClient(References.DOUBLE_ID, 8, reactionTemperature, tp); - if (tick % 10 != 0) return; - if (isStructureValidCach != isStructureValid) isStructureValidCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 0, isStructureValid, tp); - //if (isActiveCach != isActive) isActiveCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 1, isActive, tp); - if (startupInitializedCach != startupInitialized) startupInitializedCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 2, startupInitialized, tp); - if (reactorStateCach != reactorState) reactorStateCach = (Integer) sendObjectToClient(References.INT_ID, 3, reactorState, tp); - if (reactorFuelCach != reactorFuel) reactorFuelCach = (Integer) sendObjectToClient(References.INT_ID, 4, reactorFuel, tp); - if (convertedFuelCach != convertedFuel) convertedFuelCach = (Integer) sendObjectToClient(References.INT_ID, 5, convertedFuel, tp); - if (energySaturationCach != energySaturation) energySaturationCach = (Integer) sendObjectToClient(References.INT_ID, 6, energySaturation, tp); - if (maxEnergySaturationCach != maxEnergySaturation) maxEnergySaturationCach = (Integer) sendObjectToClient(References.INT_ID, 7, maxEnergySaturation, tp); - if (maxReactTemperatureCach != maxReactTemperature) maxReactTemperatureCach = (Double) sendObjectToClient(References.DOUBLE_ID, 9, maxReactTemperature, tp); - if (fieldChargeCach != fieldCharge) fieldChargeCach = (Double) sendObjectToClient(References.DOUBLE_ID, 10, fieldCharge, tp); - if (maxFieldChargeCach != maxFieldCharge) maxFieldChargeCach = (Double) sendObjectToClient(References.DOUBLE_ID, 11, maxFieldCharge, tp); - } + private void detectAndSendChanges() { + NetworkRegistry.TargetPoint tp = new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 128); + if (reactionTemperatureCach != reactionTemperature) + reactionTemperatureCach = (Double) sendObjectToClient(References.DOUBLE_ID, 8, reactionTemperature, tp); + if (tick % 10 != 0) return; + if (isStructureValidCach != isStructureValid) + isStructureValidCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 0, isStructureValid, tp); + //if (isActiveCach != isActive) isActiveCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 1, isActive, tp); + if (startupInitializedCach != startupInitialized) + startupInitializedCach = (Boolean) sendObjectToClient(References.BOOLEAN_ID, 2, startupInitialized, tp); + if (reactorStateCach != reactorState) + reactorStateCach = (Integer) sendObjectToClient(References.INT_ID, 3, reactorState, tp); + if (reactorFuelCach != reactorFuel) + reactorFuelCach = (Integer) sendObjectToClient(References.INT_ID, 4, reactorFuel, tp); + if (convertedFuelCach != convertedFuel) + convertedFuelCach = (Integer) sendObjectToClient(References.INT_ID, 5, convertedFuel, tp); + if (energySaturationCach != energySaturation) + energySaturationCach = (Integer) sendObjectToClient(References.INT_ID, 6, energySaturation, tp); + if (maxEnergySaturationCach != maxEnergySaturation) + maxEnergySaturationCach = (Integer) sendObjectToClient(References.INT_ID, 7, maxEnergySaturation, tp); + if (maxReactTemperatureCach != maxReactTemperature) + maxReactTemperatureCach = (Double) sendObjectToClient(References.DOUBLE_ID, 9, maxReactTemperature, tp); + if (fieldChargeCach != fieldCharge) + fieldChargeCach = (Double) sendObjectToClient(References.DOUBLE_ID, 10, fieldCharge, tp); + if (maxFieldChargeCach != maxFieldCharge) + maxFieldChargeCach = (Double) sendObjectToClient(References.DOUBLE_ID, 11, maxFieldCharge, tp); + } - public int getComparatorOutput(int rsMode){ - switch (rsMode){ - case IReactorPart.RMODE_TEMP: return toRSStrength(reactionTemperature, maxReactTemperature, rsMode); - case IReactorPart.RMODE_TEMP_INV: return 15 - toRSStrength(reactionTemperature, maxReactTemperature, rsMode); - case IReactorPart.RMODE_FIELD: return toRSStrength(fieldCharge, maxFieldCharge, rsMode); - case IReactorPart.RMODE_FIELD_INV: return 15 - toRSStrength(fieldCharge, maxFieldCharge, rsMode); - case IReactorPart.RMODE_SAT: return toRSStrength(energySaturation, maxEnergySaturation, rsMode); - case IReactorPart.RMODE_SAT_INV: return 15 - toRSStrength(energySaturation, maxEnergySaturation, rsMode); - case IReactorPart.RMODE_FUEL: return toRSStrength(convertedFuel + conversionUnit, reactorFuel - conversionUnit, rsMode); - case IReactorPart.RMODE_FUEL_INV: return 15 - toRSStrength(convertedFuel + conversionUnit, reactorFuel - conversionUnit, rsMode); - } - return 0; - } + public int getComparatorOutput(int rsMode) { + switch (rsMode) { + case IReactorPart.RMODE_TEMP: + return toRSStrength(reactionTemperature, maxReactTemperature, rsMode); + case IReactorPart.RMODE_TEMP_INV: + return 15 - toRSStrength(reactionTemperature, maxReactTemperature, rsMode); + case IReactorPart.RMODE_FIELD: + return toRSStrength(fieldCharge, maxFieldCharge, rsMode); + case IReactorPart.RMODE_FIELD_INV: + return 15 - toRSStrength(fieldCharge, maxFieldCharge, rsMode); + case IReactorPart.RMODE_SAT: + return toRSStrength(energySaturation, maxEnergySaturation, rsMode); + case IReactorPart.RMODE_SAT_INV: + return 15 - toRSStrength(energySaturation, maxEnergySaturation, rsMode); + case IReactorPart.RMODE_FUEL: + return toRSStrength(convertedFuel + conversionUnit, reactorFuel - conversionUnit, rsMode); + case IReactorPart.RMODE_FUEL_INV: + return 15 - toRSStrength(convertedFuel + conversionUnit, reactorFuel - conversionUnit, rsMode); + } + return 0; + } - private int toRSStrength(double value, double maxValue, int mode){ - if (maxValue == 0) return 0; - double d = value / maxValue; - int rs = (int)(d * 15D); - switch (mode){ - case IReactorPart.RMODE_FIELD: - case IReactorPart.RMODE_FIELD_INV: - { - if (d < 0.1) rs = 0; - break; - } - case IReactorPart.RMODE_FUEL: - case IReactorPart.RMODE_FUEL_INV: - { - if (d > 0.9) rs = 15; - break; - } - } - return rs; - } + private int toRSStrength(double value, double maxValue, int mode) { + if (maxValue == 0) return 0; + double d = value / maxValue; + int rs = (int) (d * 15D); + switch (mode) { + case IReactorPart.RMODE_FIELD: + case IReactorPart.RMODE_FIELD_INV: { + if (d < 0.1) rs = 0; + break; + } + case IReactorPart.RMODE_FUEL: + case IReactorPart.RMODE_FUEL_INV: { + if (d > 0.9) rs = 15; + break; + } + } + return rs; + } - @Override - @SideOnly(Side.CLIENT) - public void receiveObjectFromServer(int index, Object object) { - switch (index){ - case 0: isStructureValid = (Boolean) object; break; - //case 1: isActive = (Boolean) object; break; - case 2: startupInitialized = (Boolean) object; break; - case 3: reactorState = (Integer) object; break; - case 4: reactorFuel = (Integer) object; break; - case 5: convertedFuel = (Integer) object; break; - case 6: energySaturation = (Integer) object; break; - case 7: maxEnergySaturation = (Integer) object; break; - case 8: reactionTemperature = (Double) object; break; - case 9: maxReactTemperature = (Double) object; break; - case 10: fieldCharge = (Double) object; break; - case 11: maxFieldCharge = (Double) object; break; - case 100: FMLClientHandler.instance().getClient().effectRenderer.addEffect(new Particles.ReactorExplosionParticle(worldObj, xCoord, yCoord, zCoord, (Integer) object)); - } - super.receiveObjectFromServer(index, object); - } + @Override + @SideOnly(Side.CLIENT) + public void receiveObjectFromServer(int index, Object object) { + switch (index) { + case 0: + isStructureValid = (Boolean) object; + break; + //case 1: isActive = (Boolean) object; break; + case 2: + startupInitialized = (Boolean) object; + break; + case 3: + reactorState = (Integer) object; + break; + case 4: + reactorFuel = (Integer) object; + break; + case 5: + convertedFuel = (Integer) object; + break; + case 6: + energySaturation = (Integer) object; + break; + case 7: + maxEnergySaturation = (Integer) object; + break; + case 8: + reactionTemperature = (Double) object; + break; + case 9: + maxReactTemperature = (Double) object; + break; + case 10: + fieldCharge = (Double) object; + break; + case 11: + maxFieldCharge = (Double) object; + break; + case 100: + FMLClientHandler.instance().getClient().effectRenderer.addEffect(new Particles.ReactorExplosionParticle(worldObj, xCoord, yCoord, zCoord, (Integer) object)); + } + super.receiveObjectFromServer(index, object); + } - @SideOnly(Side.CLIENT) - @Override - public AxisAlignedBB getRenderBoundingBox() { - return INFINITE_EXTENT_AABB; - } + @SideOnly(Side.CLIENT) + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } - @Override - public double getMaxRenderDistanceSquared() { - return 40960.0D; - } + @Override + public double getMaxRenderDistanceSquared() { + return 40960.0D; + } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound compound = new NBTTagCompound(); - writeToNBT(compound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, compound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound compound = new NBTTagCompound(); + writeToNBT(compound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, compound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } - @Override - public void writeToNBT(NBTTagCompound compound) { - super.writeToNBT(compound); + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); - NBTTagList stabilizerList = new NBTTagList(); - for (TileLocation offset : stabilizerLocations){ - NBTTagCompound compound1 = new NBTTagCompound(); - offset.writeToNBT(compound1, "tag"); - stabilizerList.appendTag(compound1); - } - if (stabilizerList.tagCount() > 0) compound.setTag("Stabilizers", stabilizerList); + NBTTagList stabilizerList = new NBTTagList(); + for (TileLocation offset : stabilizerLocations) { + NBTTagCompound compound1 = new NBTTagCompound(); + offset.writeToNBT(compound1, "tag"); + stabilizerList.appendTag(compound1); + } + if (stabilizerList.tagCount() > 0) compound.setTag("Stabilizers", stabilizerList); - compound.setByte("State", (byte) reactorState); - compound.setBoolean("isStructureValid", isStructureValid); - compound.setBoolean("startupInitialized", startupInitialized); - //compound.setBoolean("isActive", isActive); - compound.setInteger("energySaturation", energySaturation); - compound.setInteger("maxEnergySaturation", maxEnergySaturation); - compound.setInteger("reactorFuel", reactorFuel); - compound.setInteger("convertedFuel", convertedFuel); - compound.setDouble("reactionTemperature", reactionTemperature); - compound.setDouble("maxReactTemperature", maxReactTemperature); - compound.setDouble("fieldCharge", fieldCharge); - compound.setDouble("maxFieldCharge", maxFieldCharge); - } + compound.setByte("State", (byte) reactorState); + compound.setBoolean("isStructureValid", isStructureValid); + compound.setBoolean("startupInitialized", startupInitialized); + //compound.setBoolean("isActive", isActive); + compound.setInteger("energySaturation", energySaturation); + compound.setInteger("maxEnergySaturation", maxEnergySaturation); + compound.setInteger("reactorFuel", reactorFuel); + compound.setInteger("convertedFuel", convertedFuel); + compound.setDouble("reactionTemperature", reactionTemperature); + compound.setDouble("maxReactTemperature", maxReactTemperature); + compound.setDouble("fieldCharge", fieldCharge); + compound.setDouble("maxFieldCharge", maxFieldCharge); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - super.readFromNBT(compound); + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); - stabilizerLocations = new ArrayList(); - if (compound.hasKey("Stabilizers")){ - NBTTagList stabilizerList = compound.getTagList("Stabilizers", 10); - for (int i = 0; i < stabilizerList.tagCount(); i++){ - TileLocation offset = new TileLocation(); - offset.readFromNBT(stabilizerList.getCompoundTagAt(i), "tag"); - stabilizerLocations.add(offset); - } - } + stabilizerLocations = new ArrayList(); + if (compound.hasKey("Stabilizers")) { + NBTTagList stabilizerList = compound.getTagList("Stabilizers", 10); + for (int i = 0; i < stabilizerList.tagCount(); i++) { + TileLocation offset = new TileLocation(); + offset.readFromNBT(stabilizerList.getCompoundTagAt(i), "tag"); + stabilizerLocations.add(offset); + } + } - reactorState = compound.getByte("State"); - isStructureValid = compound.getBoolean("isStructureValid"); - startupInitialized = compound.getBoolean("startupInitialized"); - //isActive = compound.getBoolean("isActive"); - energySaturation = compound.getInteger("energySaturation"); - maxEnergySaturation = compound.getInteger("maxEnergySaturation"); - reactorFuel = compound.getInteger("reactorFuel"); - convertedFuel = compound.getInteger("convertedFuel"); - reactionTemperature = compound.getDouble("reactionTemperature"); - maxReactTemperature = compound.getDouble("maxReactTemperature"); - fieldCharge = compound.getDouble("fieldCharge"); - maxFieldCharge = compound.getDouble("maxFieldCharge"); - } + reactorState = compound.getByte("State"); + isStructureValid = compound.getBoolean("isStructureValid"); + startupInitialized = compound.getBoolean("startupInitialized"); + //isActive = compound.getBoolean("isActive"); + energySaturation = compound.getInteger("energySaturation"); + maxEnergySaturation = compound.getInteger("maxEnergySaturation"); + reactorFuel = compound.getInteger("reactorFuel"); + convertedFuel = compound.getInteger("convertedFuel"); + reactionTemperature = compound.getDouble("reactionTemperature"); + maxReactTemperature = compound.getDouble("maxReactTemperature"); + fieldCharge = compound.getDouble("fieldCharge"); + maxFieldCharge = compound.getDouble("maxFieldCharge"); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/reactor/TileReactorEnergyInjector.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/reactor/TileReactorEnergyInjector.java index 37597ea9..a490f45c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/reactor/TileReactorEnergyInjector.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/reactor/TileReactorEnergyInjector.java @@ -24,226 +24,222 @@ import java.util.Map; /** * Created by Brandon on 23/7/2015. */ -public class TileReactorEnergyInjector extends TileEntity implements IReactorPart, IEnergyReceiver, IDEPeripheral{ +public class TileReactorEnergyInjector extends TileEntity implements IReactorPart, IEnergyReceiver, IDEPeripheral { - public float modelIllumination = 1F; - public int facingDirection = ForgeDirection.UP.ordinal(); - public MultiblockHelper.TileLocation masterLocation = new MultiblockHelper.TileLocation(); - public boolean isValid = false; - public int tick = 0; + public float modelIllumination = 1F; + public int facingDirection = ForgeDirection.UP.ordinal(); + public MultiblockHelper.TileLocation masterLocation = new MultiblockHelper.TileLocation(); + public boolean isValid = false; + public int tick = 0; @SideOnly(Side.CLIENT) private ParticleReactorBeam beam; private TileReactorCore core = null; - private int redstoneMode = 0; - private int rs = -1; - private int rsCach = -1; + private int redstoneMode = 0; + private int rs = -1; + private int rsCach = -1; - @Override - public void updateEntity() { - if (worldObj.isRemote && isValid){ - updateBeam(); - } + @Override + public void updateEntity() { + if (worldObj.isRemote && isValid) { + updateBeam(); + } - TileEntity master = masterLocation.getTileEntity(worldObj); - if (!worldObj.isRemote && master instanceof TileReactorCore){ - rs = ((TileReactorCore) master).getComparatorOutput(redstoneMode); - if (rs != rsCach){ - rsCach = rs; - Utills.updateNeabourBlocks(worldObj, xCoord, yCoord, zCoord); - } - } + TileEntity master = masterLocation.getTileEntity(worldObj); + if (!worldObj.isRemote && master instanceof TileReactorCore) { + rs = ((TileReactorCore) master).getComparatorOutput(redstoneMode); + if (rs != rsCach) { + rsCach = rs; + Utills.updateNeabourBlocks(worldObj, xCoord, yCoord, zCoord); + } + } } @SideOnly(Side.CLIENT) - private void updateBeam(){ + private void updateBeam() { beam = DraconicEvolution.proxy.reactorBeam(this, beam, true); } - public void onPlaced() { - checkForMaster(); - } + public void onPlaced() { + checkForMaster(); + } - public boolean checkForMaster(){ - for (int i = 1; i < 10; i++) { - ForgeDirection dir = ForgeDirection.getOrientation(facingDirection); - int x = xCoord + (dir.offsetX*i); - int y = yCoord + (dir.offsetY*i); - int z = zCoord + (dir.offsetZ*i); - if (!worldObj.isAirBlock(x, y, z)) - { - TileEntity tile = worldObj.getTileEntity(x, y, z); - if (tile instanceof TileReactorCore) - { - masterLocation.set(x, y, z); - isValid = true; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - return true; - }else { - isValid = false; - return false; - } - } - } - isValid = false; - return false; - } + public boolean checkForMaster() { + for (int i = 1; i < 10; i++) { + ForgeDirection dir = ForgeDirection.getOrientation(facingDirection); + int x = xCoord + (dir.offsetX * i); + int y = yCoord + (dir.offsetY * i); + int z = zCoord + (dir.offsetZ * i); + if (!worldObj.isAirBlock(x, y, z)) { + TileEntity tile = worldObj.getTileEntity(x, y, z); + if (tile instanceof TileReactorCore) { + masterLocation.set(x, y, z); + isValid = true; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return true; + } else { + isValid = false; + return false; + } + } + } + isValid = false; + return false; + } - @Override - public boolean isActive() { - return isValid; - } + @Override + public boolean isActive() { + return isValid; + } - @Override - public String getRedstoneModeString() { - return StatCollector.translateToLocal("msg.de.reactorRSMode."+redstoneMode+".txt"); - } + @Override + public String getRedstoneModeString() { + return StatCollector.translateToLocal("msg.de.reactorRSMode." + redstoneMode + ".txt"); + } - @Override - public void changeRedstoneMode() { - if (redstoneMode == IReactorPart.RMODE_FUEL_INV) redstoneMode = 0; - else redstoneMode++; - } + @Override + public void changeRedstoneMode() { + if (redstoneMode == IReactorPart.RMODE_FUEL_INV) redstoneMode = 0; + else redstoneMode++; + } - @Override - public int getRedstoneMode() { - return redstoneMode; - } + @Override + public int getRedstoneMode() { + return redstoneMode; + } - @Override - public void shutDown() { - masterLocation = new MultiblockHelper.TileLocation(); - isValid = false; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } + @Override + public void shutDown() { + masterLocation = new MultiblockHelper.TileLocation(); + isValid = false; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound compound = new NBTTagCompound(); - masterLocation.writeToNBT(compound, "Master"); - compound.setInteger("Facing", facingDirection); - compound.setBoolean("IsValid", isValid); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, compound); - } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound compound = new NBTTagCompound(); + masterLocation.writeToNBT(compound, "Master"); + compound.setInteger("Facing", facingDirection); + compound.setBoolean("IsValid", isValid); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, compound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - NBTTagCompound compound = pkt.func_148857_g(); - masterLocation.readFromNBT(compound, "Master"); - facingDirection = compound.getInteger("Facing"); - isValid = compound.getBoolean("IsValid"); - super.onDataPacket(net, pkt); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + NBTTagCompound compound = pkt.func_148857_g(); + masterLocation.readFromNBT(compound, "Master"); + facingDirection = compound.getInteger("Facing"); + isValid = compound.getBoolean("IsValid"); + super.onDataPacket(net, pkt); + } - public TileReactorCore getCore(){ - if (core == null || core.isInvalid()) { - if (getMaster().getTileEntity(worldObj) instanceof TileReactorCore) core = (TileReactorCore)getMaster().getTileEntity(worldObj); - else core = null; - } - return core; - } + public TileReactorCore getCore() { + if (core == null || core.isInvalid()) { + if (getMaster().getTileEntity(worldObj) instanceof TileReactorCore) + core = (TileReactorCore) getMaster().getTileEntity(worldObj); + else core = null; + } + return core; + } - @Override - public void writeToNBT(NBTTagCompound compound) { - super.writeToNBT(compound); - masterLocation.writeToNBT(compound, "Master"); - compound.setInteger("Facing", facingDirection); - compound.setBoolean("IsValid", isValid); - compound.setInteger("RedstoneMode", redstoneMode); - } + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + masterLocation.writeToNBT(compound, "Master"); + compound.setInteger("Facing", facingDirection); + compound.setBoolean("IsValid", isValid); + compound.setInteger("RedstoneMode", redstoneMode); + } - @Override - public void readFromNBT(NBTTagCompound compound) { - super.readFromNBT(compound); - masterLocation.readFromNBT(compound, "Master"); - facingDirection = compound.getInteger("Facing"); - isValid = compound.getBoolean("IsValid"); - redstoneMode = compound.getInteger("RedstoneMode"); - } + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + masterLocation.readFromNBT(compound, "Master"); + facingDirection = compound.getInteger("Facing"); + isValid = compound.getBoolean("IsValid"); + redstoneMode = compound.getInteger("RedstoneMode"); + } - @Override - public MultiblockHelper.TileLocation getMaster() { - return masterLocation; - } + @Override + public MultiblockHelper.TileLocation getMaster() { + return masterLocation; + } - @Override - public AxisAlignedBB getRenderBoundingBox() { - return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1); - } + @Override + public AxisAlignedBB getRenderBoundingBox() { + return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1); + } - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - if (simulate) return Integer.MAX_VALUE; - else if (getCore() != null) return getCore().injectEnergy(maxReceive); - return 0; - } + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + if (simulate) return Integer.MAX_VALUE; + else if (getCore() != null) return getCore().injectEnergy(maxReceive); + return 0; + } - @Override - public int getEnergyStored(ForgeDirection from) { - return 0; - } + @Override + public int getEnergyStored(ForgeDirection from) { + return 0; + } - @Override - public int getMaxEnergyStored(ForgeDirection from) { - return Integer.MAX_VALUE; - } + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return Integer.MAX_VALUE; + } - @Override - public boolean canConnectEnergy(ForgeDirection from) { - return from == ForgeDirection.getOrientation(facingDirection).getOpposite(); - } + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return from == ForgeDirection.getOrientation(facingDirection).getOpposite(); + } - @Override - public String getName() { - return "draconic_reactor"; - } + @Override + public String getName() { + return "draconic_reactor"; + } - @Override - public String[] getMethodNames() { - return new String[] {"getReactorInfo", "chargeReactor", "activateReactor", "stopReactor"}; - } + @Override + public String[] getMethodNames() { + return new String[]{"getReactorInfo", "chargeReactor", "activateReactor", "stopReactor"}; + } - @Override - public Object[] callMethod(String method, Object... args) { - if (!(getMaster().getTileEntity(worldObj) instanceof TileReactorCore)) return null; - TileReactorCore reactor = (TileReactorCore)getMaster().getTileEntity(worldObj); + @Override + public Object[] callMethod(String method, Object... args) { + if (!(getMaster().getTileEntity(worldObj) instanceof TileReactorCore)) return null; + TileReactorCore reactor = (TileReactorCore) getMaster().getTileEntity(worldObj); - if (args.length > 0) throw new IllegalArgumentException("This method dose not accept arguments"); + if (args.length > 0) throw new IllegalArgumentException("This method dose not accept arguments"); - if (method.equals("getReactorInfo")){ - Map map = new HashMap(); - map.put("temperature", Utills.round(reactor.reactionTemperature, 100)); - map.put("fieldStrength", Utills.round(reactor.fieldCharge, 100)); - map.put("maxFieldStrength", Utills.round(reactor.maxFieldCharge, 100)); - map.put("energySaturation", reactor.energySaturation); - map.put("maxEnergySaturation", reactor.maxEnergySaturation); - map.put("fuelConversion", Utills.round((double)reactor.convertedFuel + reactor.conversionUnit, 1000)); - map.put("maxFuelConversion", reactor.reactorFuel + reactor.convertedFuel); - map.put("generationRate", (int)reactor.generationRate); - map.put("fieldDrainRate", reactor.fieldDrain); - map.put("fuelConversionRate", (int)Math.round(reactor.fuelUseRate * 1000000D)); - map.put("status", reactor.reactorState == 0 ? "offline" : reactor.reactorState == 1 && !reactor.canStart() ? "charging" : reactor.reactorState == 1 && reactor.canStart() ? "charged" : reactor.reactorState == 2 ? "online" : reactor.reactorState == 3 ? "stopping" : "invalid"); - return new Object[]{ map }; - } - else if (method.equals("chargeReactor")){ - if (reactor.canCharge()) { - reactor.reactorState = TileReactorCore.STATE_START; - return new Object[] { true }; - } else return new Object[] { false }; - } - else if (method.equals("activateReactor")){ - if (reactor.canStart()) { - reactor.reactorState = TileReactorCore.STATE_ONLINE; - return new Object[] { true }; - } else return new Object[] { false }; - } - else if (method.equals("stopReactor")){ - if (reactor.canStop()) { - reactor.reactorState = TileReactorCore.STATE_STOP; - return new Object[] { true }; - } else return new Object[] { false }; - } - return new Object[] {}; - } + if (method.equals("getReactorInfo")) { + Map map = new HashMap(); + map.put("temperature", Utills.round(reactor.reactionTemperature, 100)); + map.put("fieldStrength", Utills.round(reactor.fieldCharge, 100)); + map.put("maxFieldStrength", Utills.round(reactor.maxFieldCharge, 100)); + map.put("energySaturation", reactor.energySaturation); + map.put("maxEnergySaturation", reactor.maxEnergySaturation); + map.put("fuelConversion", Utills.round((double) reactor.convertedFuel + reactor.conversionUnit, 1000)); + map.put("maxFuelConversion", reactor.reactorFuel + reactor.convertedFuel); + map.put("generationRate", (int) reactor.generationRate); + map.put("fieldDrainRate", reactor.fieldDrain); + map.put("fuelConversionRate", (int) Math.round(reactor.fuelUseRate * 1000000D)); + map.put("status", reactor.reactorState == 0 ? "offline" : reactor.reactorState == 1 && !reactor.canStart() ? "charging" : reactor.reactorState == 1 && reactor.canStart() ? "charged" : reactor.reactorState == 2 ? "online" : reactor.reactorState == 3 ? "stopping" : "invalid"); + return new Object[]{map}; + } else if (method.equals("chargeReactor")) { + if (reactor.canCharge()) { + reactor.reactorState = TileReactorCore.STATE_START; + return new Object[]{true}; + } else return new Object[]{false}; + } else if (method.equals("activateReactor")) { + if (reactor.canStart()) { + reactor.reactorState = TileReactorCore.STATE_ONLINE; + return new Object[]{true}; + } else return new Object[]{false}; + } else if (method.equals("stopReactor")) { + if (reactor.canStop()) { + reactor.reactorState = TileReactorCore.STATE_STOP; + return new Object[]{true}; + } else return new Object[]{false}; + } + return new Object[]{}; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/DamageSourceChaos.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/DamageSourceChaos.java index 1df398a5..d96b1b97 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/utills/DamageSourceChaos.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/DamageSourceChaos.java @@ -10,21 +10,19 @@ import net.minecraft.util.IChatComponent; * Created by Brandon on 1/09/2014. */ public class DamageSourceChaos extends EntityDamageSource { - public DamageSourceChaos(Entity entity) - { - super("Chaos", entity); - this.setDamageBypassesArmor(); - } + public DamageSourceChaos(Entity entity) { + super("Chaos", entity); + this.setDamageBypassesArmor(); + } - @Override - public IChatComponent func_151519_b (EntityLivingBase par1EntityLivingBase) - { - return super.func_151519_b(par1EntityLivingBase); - //return new ChatComponentTranslation("death.attack.Chaos", par1EntityLivingBase.func_145748_c_()); - } + @Override + public IChatComponent func_151519_b(EntityLivingBase par1EntityLivingBase) { + return super.func_151519_b(par1EntityLivingBase); + //return new ChatComponentTranslation("death.attack.Chaos", par1EntityLivingBase.func_145748_c_()); + } - @Override - public boolean isUnblockable() { - return true; - } + @Override + public boolean isUnblockable() { + return true; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/DragonChunkLoader.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/DragonChunkLoader.java index d39c5ec9..e006c9e1 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/utills/DragonChunkLoader.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/DragonChunkLoader.java @@ -15,34 +15,31 @@ import java.util.*; * Created by brandon3055 on 21/10/2015. */ public class DragonChunkLoader implements LoadingCallback { - public static DragonChunkLoader instance; - public static Map ticketList = new HashMap(); + public static DragonChunkLoader instance; + public static Map ticketList = new HashMap(); public static boolean hasReportedIssue = false; - public static void init(){ - instance = new DragonChunkLoader(); - MinecraftForge.EVENT_BUS.register(instance); - ForgeChunkManager.setForcedChunkLoadingCallback(DraconicEvolution.instance, instance); - } + public static void init() { + instance = new DragonChunkLoader(); + MinecraftForge.EVENT_BUS.register(instance); + ForgeChunkManager.setForcedChunkLoadingCallback(DraconicEvolution.instance, instance); + } - public static void updateLoaded(EntityChaosGuardian guardian){ - Ticket ticket; + public static void updateLoaded(EntityChaosGuardian guardian) { + Ticket ticket; - if (ticketList.containsKey(guardian)) { - ticket = ticketList.get(guardian); - } - else - { - ticket = ForgeChunkManager.requestTicket(DraconicEvolution.instance, guardian.worldObj, ForgeChunkManager.Type.ENTITY); + if (ticketList.containsKey(guardian)) { + ticket = ticketList.get(guardian); + } else { + ticket = ForgeChunkManager.requestTicket(DraconicEvolution.instance, guardian.worldObj, ForgeChunkManager.Type.ENTITY); - if (ticket != null) { - ticket.bindEntity(guardian); - ticket.setChunkListDepth(9); - ticketList.put(guardian, ticket); + if (ticket != null) { + ticket.bindEntity(guardian); + ticket.setChunkListDepth(9); + ticketList.put(guardian, ticket); - } - else { - if (!hasReportedIssue){ + } else { + if (!hasReportedIssue) { LogHelper.error("##########################################################################################"); LogHelper.error("Could not get ticket for dragon"); LogHelper.error("Fore some reason forge has denied DE's request for a loader ticket for the chaos guardian"); @@ -51,54 +48,54 @@ public class DragonChunkLoader implements LoadingCallback { LogHelper.error("##########################################################################################"); hasReportedIssue = true; } - return; - } - } + return; + } + } - if (ticket == null || guardian.ticksExisted % 4 != 0) return; + if (ticket == null || guardian.ticksExisted % 4 != 0) return; - Set dragonChunks = new HashSet(); + Set dragonChunks = new HashSet(); - for(int xx = guardian.chunkCoordX-1; xx <= guardian.chunkCoordX+1; xx++){ - for(int zz = guardian.chunkCoordZ-1; zz <= guardian.chunkCoordZ+1; zz++){ - dragonChunks.add(new ChunkCoordIntPair(xx,zz)); - } - } + for (int xx = guardian.chunkCoordX - 1; xx <= guardian.chunkCoordX + 1; xx++) { + for (int zz = guardian.chunkCoordZ - 1; zz <= guardian.chunkCoordZ + 1; zz++) { + dragonChunks.add(new ChunkCoordIntPair(xx, zz)); + } + } - Set toLoad = new HashSet(); - Set toUnload = new HashSet(); + Set toLoad = new HashSet(); + Set toUnload = new HashSet(); - for (ChunkCoordIntPair pair : ticket.getChunkList()){ - if (!contains(dragonChunks, pair)) toUnload.add(pair); - } + for (ChunkCoordIntPair pair : ticket.getChunkList()) { + if (!contains(dragonChunks, pair)) toUnload.add(pair); + } - for (ChunkCoordIntPair pair : dragonChunks){ - if (!contains(ticket.getChunkList(), pair)) toLoad.add(pair); - } + for (ChunkCoordIntPair pair : dragonChunks) { + if (!contains(ticket.getChunkList(), pair)) toLoad.add(pair); + } - for(ChunkCoordIntPair unload : toUnload) ForgeChunkManager.unforceChunk(ticket, unload); - for(ChunkCoordIntPair load : toLoad) ForgeChunkManager.forceChunk(ticket, load); - } + for (ChunkCoordIntPair unload : toUnload) ForgeChunkManager.unforceChunk(ticket, unload); + for (ChunkCoordIntPair load : toLoad) ForgeChunkManager.forceChunk(ticket, load); + } - private static boolean contains(Set set, ChunkCoordIntPair pair){ - for (ChunkCoordIntPair pair1 : set) if (pair1.equals(pair)) return true; - return false; - } + private static boolean contains(Set set, ChunkCoordIntPair pair) { + for (ChunkCoordIntPair pair1 : set) if (pair1.equals(pair)) return true; + return false; + } - public static void stopLoading(EntityChaosGuardian guardian){ - if (!ticketList.containsKey(guardian)) return; - ForgeChunkManager.releaseTicket(ticketList.get(guardian)); - ticketList.remove(guardian); - } + public static void stopLoading(EntityChaosGuardian guardian) { + if (!ticketList.containsKey(guardian)) return; + ForgeChunkManager.releaseTicket(ticketList.get(guardian)); + ticketList.remove(guardian); + } - @Override - public void ticketsLoaded(List tickets, World world) { - if (!tickets.isEmpty()){ - for (Ticket ticket : tickets){ - if (ticket.getType() == ForgeChunkManager.Type.ENTITY && ticket.getEntity() instanceof EntityChaosGuardian){ - updateLoaded((EntityChaosGuardian) ticket.getEntity()); - } - } - } - } + @Override + public void ticketsLoaded(List tickets, World world) { + if (!tickets.isEmpty()) { + for (Ticket ticket : tickets) { + if (ticket.getType() == ForgeChunkManager.Type.ENTITY && ticket.getEntity() instanceof EntityChaosGuardian) { + updateLoaded((EntityChaosGuardian) ticket.getEntity()); + } + } + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/EnergyStorage.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/EnergyStorage.java index 00e2b213..f274e358 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/utills/EnergyStorage.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/EnergyStorage.java @@ -5,176 +5,175 @@ import net.minecraft.nbt.NBTTagCompound; /** * Reference implementation of {@link cofh.api.energy.IEnergyStorage}. Use/extend this or implement your own. - * + * * @author King Lemming - * */ public class EnergyStorage implements IEnergyStorage { - protected int energy; - protected int capacity; - protected int maxReceive; - protected int maxExtract; + protected int energy; + protected int capacity; + protected int maxReceive; + protected int maxExtract; - public EnergyStorage(int capacity) { + public EnergyStorage(int capacity) { - this(capacity, capacity, capacity); - } + this(capacity, capacity, capacity); + } - public EnergyStorage(int capacity, int maxTransfer) { + public EnergyStorage(int capacity, int maxTransfer) { - this(capacity, maxTransfer, maxTransfer); - } + this(capacity, maxTransfer, maxTransfer); + } - public EnergyStorage(int capacity, int maxReceive, int maxExtract) { + public EnergyStorage(int capacity, int maxReceive, int maxExtract) { - this.capacity = capacity; - this.maxReceive = maxReceive; - this.maxExtract = maxExtract; - } + this.capacity = capacity; + this.maxReceive = maxReceive; + this.maxExtract = maxExtract; + } - public EnergyStorage readFromNBT(NBTTagCompound nbt) { + public EnergyStorage readFromNBT(NBTTagCompound nbt) { - this.energy = nbt.getInteger("EnergyHelper"); + this.energy = nbt.getInteger("EnergyHelper"); - if (energy > capacity) { - energy = capacity; - } - return this; - } + if (energy > capacity) { + energy = capacity; + } + return this; + } - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { + public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - if (energy < 0) { - energy = 0; - } - nbt.setInteger("EnergyHelper", energy); - return nbt; - } + if (energy < 0) { + energy = 0; + } + nbt.setInteger("EnergyHelper", energy); + return nbt; + } - public void setCapacity(int capacity) { + public void setCapacity(int capacity) { - this.capacity = capacity; + this.capacity = capacity; - if (energy > capacity) { - energy = capacity; - } - } + if (energy > capacity) { + energy = capacity; + } + } - public void setMaxTransfer(int maxTransfer) { + public void setMaxTransfer(int maxTransfer) { - setMaxReceive(maxTransfer); - setMaxExtract(maxTransfer); - } + setMaxReceive(maxTransfer); + setMaxExtract(maxTransfer); + } - public void setMaxReceive(int maxReceive) { + public void setMaxReceive(int maxReceive) { - this.maxReceive = maxReceive; - } + this.maxReceive = maxReceive; + } - public void setMaxExtract(int maxExtract) { + public void setMaxExtract(int maxExtract) { - this.maxExtract = maxExtract; - } + this.maxExtract = maxExtract; + } - public int getMaxReceive() { + public int getMaxReceive() { - return maxReceive; - } + return maxReceive; + } - public int getMaxExtract() { + public int getMaxExtract() { - return maxExtract; - } + return maxExtract; + } - /** - * This function is included to allow for server -> client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers are - * guaranteed to have it. - * - * @param energy - */ - public void setEnergyStored(int energy) { + /** + * This function is included to allow for server -> client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers are + * guaranteed to have it. + * + * @param energy + */ + public void setEnergyStored(int energy) { - this.energy = energy; + this.energy = energy; - if (this.energy > capacity) { - this.energy = capacity; - } else if (this.energy < 0) { - this.energy = 0; - } - } + if (this.energy > capacity) { + this.energy = capacity; + } else if (this.energy < 0) { + this.energy = 0; + } + } - /** - * This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this - * externally, as not all IEnergyHandlers are guaranteed to have it. - * - * @param energy - */ - public void modifyEnergyStored(int energy) { + /** + * This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this + * externally, as not all IEnergyHandlers are guaranteed to have it. + * + * @param energy + */ + public void modifyEnergyStored(int energy) { - this.energy += energy; + this.energy += energy; - if (this.energy > capacity) { - this.energy = capacity; - } else if (this.energy < 0) { - this.energy = 0; - } - } + if (this.energy > capacity) { + this.energy = capacity; + } else if (this.energy < 0) { + this.energy = 0; + } + } - /* IEnergyStorage */ - @Override - public int receiveEnergy(int maxReceive, boolean simulate) { + /* IEnergyStorage */ + @Override + public int receiveEnergy(int maxReceive, boolean simulate) { - int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); - if (!simulate) { - energy += energyReceived; - } - return energyReceived; - } + if (!simulate) { + energy += energyReceived; + } + return energyReceived; + } - @Override - public int extractEnergy(int maxExtract, boolean simulate) { + @Override + public int extractEnergy(int maxExtract, boolean simulate) { - int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - if (!simulate) { - energy -= energyExtracted; - } - return energyExtracted; - } + if (!simulate) { + energy -= energyExtracted; + } + return energyExtracted; + } - @Override - public int getEnergyStored() { + @Override + public int getEnergyStored() { - return energy; - } + return energy; + } - @Override - public int getMaxEnergyStored() { + @Override + public int getMaxEnergyStored() { - return capacity; - } + return capacity; + } /* Added By Brandon3055 24/07/2014 */ - public EnergyStorage readFromNBT(NBTTagCompound nbt, String tag) { + public EnergyStorage readFromNBT(NBTTagCompound nbt, String tag) { - this.energy = nbt.getInteger(tag); + this.energy = nbt.getInteger(tag); - if (energy > capacity) { - energy = capacity; - } - return this; - } + if (energy > capacity) { + energy = capacity; + } + return this; + } - public NBTTagCompound writeToNBT(NBTTagCompound nbt, String tag) { + public NBTTagCompound writeToNBT(NBTTagCompound nbt, String tag) { - if (energy < 0) { - energy = 0; - } - nbt.setInteger(tag, energy); - return nbt; - } + if (energy < 0) { + energy = 0; + } + nbt.setInteger(tag, energy); + return nbt; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/IConfigurableItem.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/IConfigurableItem.java index 06ed2b51..49bb71b9 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/utills/IConfigurableItem.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/IConfigurableItem.java @@ -11,63 +11,63 @@ import java.util.List; * Created by Brandon on 29/12/2014. */ public interface IConfigurableItem { - List getFields(ItemStack stack, int slot); + List getFields(ItemStack stack, int slot); - public boolean hasProfiles(); + public boolean hasProfiles(); - public static class ProfileHelper { + public static class ProfileHelper { - public static NBTTagCompound getProfileCompound(ItemStack stack){ - int profile = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); - NBTTagCompound stackCompound = ItemNBTHelper.getCompound(stack); - if (!stackCompound.hasKey("ConfigProfiles") && stackCompound.getTagList("ConfigProfiles", 10).tagCount() < 5){ - NBTTagList profileList = new NBTTagList(); - for (int i = 0; i < 5; i++) profileList.appendTag(new NBTTagCompound()); - stackCompound.setTag("ConfigProfiles", profileList); - } + public static NBTTagCompound getProfileCompound(ItemStack stack) { + int profile = ItemNBTHelper.getInteger(stack, "ConfigProfile", 0); + NBTTagCompound stackCompound = ItemNBTHelper.getCompound(stack); + if (!stackCompound.hasKey("ConfigProfiles") && stackCompound.getTagList("ConfigProfiles", 10).tagCount() < 5) { + NBTTagList profileList = new NBTTagList(); + for (int i = 0; i < 5; i++) profileList.appendTag(new NBTTagCompound()); + stackCompound.setTag("ConfigProfiles", profileList); + } - return stackCompound.getTagList("ConfigProfiles", 10).getCompoundTagAt(profile); - } + return stackCompound.getTagList("ConfigProfiles", 10).getCompoundTagAt(profile); + } - public static void setBoolean(ItemStack stack, String tag, boolean b) { - getProfileCompound(stack).setBoolean(tag, b); - } + public static void setBoolean(ItemStack stack, String tag, boolean b) { + getProfileCompound(stack).setBoolean(tag, b); + } - public static void setInteger(ItemStack stack, String tag, int i) { - getProfileCompound(stack).setInteger(tag, i); - } + public static void setInteger(ItemStack stack, String tag, int i) { + getProfileCompound(stack).setInteger(tag, i); + } - public static void setFloat(ItemStack stack, String tag, float f) { - getProfileCompound(stack).setFloat(tag, f); - } + public static void setFloat(ItemStack stack, String tag, float f) { + getProfileCompound(stack).setFloat(tag, f); + } - public static void setDouble(ItemStack stack, String tag, double d) { - getProfileCompound(stack).setDouble(tag, d); - } + public static void setDouble(ItemStack stack, String tag, double d) { + getProfileCompound(stack).setDouble(tag, d); + } - public static void setString(ItemStack stack, String tag, String s) { - getProfileCompound(stack).setString(tag, s); - } + public static void setString(ItemStack stack, String tag, String s) { + getProfileCompound(stack).setString(tag, s); + } - public static boolean getBoolean(ItemStack stack, String tag, boolean defaultExpected){ - return getProfileCompound(stack).hasKey(tag) ? getProfileCompound(stack).getBoolean(tag) : defaultExpected; - } + public static boolean getBoolean(ItemStack stack, String tag, boolean defaultExpected) { + return getProfileCompound(stack).hasKey(tag) ? getProfileCompound(stack).getBoolean(tag) : defaultExpected; + } - public static int getInteger(ItemStack stack, String tag, int defaultExpected){ - return getProfileCompound(stack).hasKey(tag) ? getProfileCompound(stack).getInteger(tag) : defaultExpected; - } + public static int getInteger(ItemStack stack, String tag, int defaultExpected) { + return getProfileCompound(stack).hasKey(tag) ? getProfileCompound(stack).getInteger(tag) : defaultExpected; + } - public static float getFloat(ItemStack stack, String tag, float defaultExpected){ - return getProfileCompound(stack).hasKey(tag) ? getProfileCompound(stack).getFloat(tag) : defaultExpected; - } + public static float getFloat(ItemStack stack, String tag, float defaultExpected) { + return getProfileCompound(stack).hasKey(tag) ? getProfileCompound(stack).getFloat(tag) : defaultExpected; + } - public static double getDouble(ItemStack stack, String tag, double defaultExpected) { - return getProfileCompound(stack).hasKey(tag) ? getProfileCompound(stack).getDouble(tag) : defaultExpected; - } + public static double getDouble(ItemStack stack, String tag, double defaultExpected) { + return getProfileCompound(stack).hasKey(tag) ? getProfileCompound(stack).getDouble(tag) : defaultExpected; + } - public static String getString(ItemStack stack, String tag, String defaultExpected){ - return getProfileCompound(stack).hasKey(tag) ? getProfileCompound(stack).getString(tag) : defaultExpected; - } - } + public static String getString(ItemStack stack, String tag, String defaultExpected) { + return getProfileCompound(stack).hasKey(tag) ? getProfileCompound(stack).getString(tag) : defaultExpected; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/ICustomItemData.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/ICustomItemData.java index 6c1313e0..6b546d8d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/utills/ICustomItemData.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/ICustomItemData.java @@ -8,9 +8,9 @@ import net.minecraft.nbt.NBTTagCompound; */ public interface ICustomItemData { - public static final String tagName = "TileCompound"; + public static final String tagName = "TileCompound"; - void writeDataToItem(NBTTagCompound compound, ItemStack stack); + void writeDataToItem(NBTTagCompound compound, ItemStack stack); - void readDataFromItem(NBTTagCompound compound, ItemStack stack); + void readDataFromItem(NBTTagCompound compound, ItemStack stack); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/IHudDisplayBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/IHudDisplayBlock.java index d89bb51a..2bcdcb76 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/utills/IHudDisplayBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/IHudDisplayBlock.java @@ -8,5 +8,5 @@ import java.util.List; * Created by Brandon on 27/01/2015. */ public interface IHudDisplayBlock { - List getDisplayData(World world, int x, int y, int z); + List getDisplayData(World world, int x, int y, int z); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/IHudDisplayItem.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/IHudDisplayItem.java index c55378ca..4e4810f9 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/utills/IHudDisplayItem.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/IHudDisplayItem.java @@ -8,5 +8,5 @@ import java.util.List; * Created by Brandon on 26/01/2015. */ public interface IHudDisplayItem { - List getDisplayData(ItemStack stack); + List getDisplayData(ItemStack stack); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/IInventoryTool.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/IInventoryTool.java index 499672a0..68ae124f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/utills/IInventoryTool.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/IInventoryTool.java @@ -6,9 +6,9 @@ import net.minecraft.enchantment.Enchantment; * Created by Brandon on 17/01/2015. */ public interface IInventoryTool extends IConfigurableItem { - public abstract String getInventoryName(); + public abstract String getInventoryName(); - public abstract int getInventorySlots(); + public abstract int getInventorySlots(); - public abstract boolean isEnchantValid(Enchantment enchant); + public abstract boolean isEnchantValid(Enchantment enchant); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/ItemConfigField.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/ItemConfigField.java index 5d649704..53e747e4 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/utills/ItemConfigField.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/ItemConfigField.java @@ -14,181 +14,175 @@ import net.minecraft.util.StringUtils; */ public class ItemConfigField { - public Object value; - public int slot; - public int datatype; - public String name; - public int fieldid; - public Object max; - public Object min; - public Object incroment; - public String modifier; + public Object value; + public int slot; + public int datatype; + public String name; + public int fieldid; + public Object max; + public Object min; + public Object incroment; + public String modifier; - public ItemConfigField(int datatype, int slot, String name){ - this.slot = slot; - this.datatype = datatype; - this.name = name; - } + public ItemConfigField(int datatype, int slot, String name) { + this.slot = slot; + this.datatype = datatype; + this.name = name; + } - public ItemConfigField(int datatype, Object value, int slot, String name){ - this.value = value; - this.slot = slot; - this.datatype = datatype; - this.name = name; - } + public ItemConfigField(int datatype, Object value, int slot, String name) { + this.value = value; + this.slot = slot; + this.datatype = datatype; + this.name = name; + } - public ItemConfigField setMinMaxAndIncromente(Object min, Object max, Object incroment){ - this.max = max; - this.min = min; - this.incroment = incroment; - return this; - } + public ItemConfigField setMinMaxAndIncromente(Object min, Object max, Object incroment) { + this.max = max; + this.min = min; + this.incroment = incroment; + return this; + } - public String getLocalizedName() { return StatCollector.translateToLocal("button.de." + name + ".name"); } + public String getLocalizedName() { + return StatCollector.translateToLocal("button.de." + name + ".name"); + } // public void writeToItem(ItemStack stack){ // DataUtills.writeObjectToItem(stack, value, datatype, name); // } - public ItemConfigField readFromItem(ItemStack stack, Object defaultExpected){ - value = DataUtills.readObjectFromCompound(IConfigurableItem.ProfileHelper.getProfileCompound(stack), datatype, name, defaultExpected); - return this; - } + public ItemConfigField readFromItem(ItemStack stack, Object defaultExpected) { + value = DataUtills.readObjectFromCompound(IConfigurableItem.ProfileHelper.getProfileCompound(stack), datatype, name, defaultExpected); + return this; + } - public ItemConfigField setModifier(String modifier){ - this.modifier = modifier; - return this; - } + public ItemConfigField setModifier(String modifier) { + this.modifier = modifier; + return this; + } - public String getFormattedValue(){ - if (datatype == References.INT_ID && !StringUtils.isNullOrEmpty(modifier) && modifier.equals("AOE")){ - int i = (Integer) value; - i *= 2; - return String.valueOf((i + 1) + "x" + (i + 1)); - } - else if (datatype == References.BOOLEAN_ID){ - return (Boolean) value ? StatCollector.translateToLocal("gui.de.on.txt") : StatCollector.translateToLocal("gui.de.off.txt"); - } - else if (datatype == References.FLOAT_ID && !StringUtils.isNullOrEmpty(modifier) && modifier.equals("PERCENT")){ - return Math.round((Float)value * 100D) + "%"; - } - else if (datatype == References.FLOAT_ID && !StringUtils.isNullOrEmpty(modifier) && modifier.equals("PLUSPERCENT")) { - return "+"+Math.round((Float)value * 100D) + "%"; - } - else - { - return String.valueOf(value); - } - } + public String getFormattedValue() { + if (datatype == References.INT_ID && !StringUtils.isNullOrEmpty(modifier) && modifier.equals("AOE")) { + int i = (Integer) value; + i *= 2; + return String.valueOf((i + 1) + "x" + (i + 1)); + } else if (datatype == References.BOOLEAN_ID) { + return (Boolean) value ? StatCollector.translateToLocal("gui.de.on.txt") : StatCollector.translateToLocal("gui.de.off.txt"); + } else if (datatype == References.FLOAT_ID && !StringUtils.isNullOrEmpty(modifier) && modifier.equals("PERCENT")) { + return Math.round((Float) value * 100D) + "%"; + } else if (datatype == References.FLOAT_ID && !StringUtils.isNullOrEmpty(modifier) && modifier.equals("PLUSPERCENT")) { + return "+" + Math.round((Float) value * 100D) + "%"; + } else { + return String.valueOf(value); + } + } - public String getMaxFormattedValue(){ - if (datatype == References.INT_ID && !StringUtils.isNullOrEmpty(modifier) && modifier.equals("AOE")){ - int i = (Integer) max; - i *= 2; - return String.valueOf((i + 1) + "x" + (i + 1)); - } - else - { - return String.valueOf(max); - } - } + public String getMaxFormattedValue() { + if (datatype == References.INT_ID && !StringUtils.isNullOrEmpty(modifier) && modifier.equals("AOE")) { + int i = (Integer) max; + i *= 2; + return String.valueOf((i + 1) + "x" + (i + 1)); + } else { + return String.valueOf(max); + } + } - public String getTooltipInfo() - { - return InfoHelper.ITC() + getLocalizedName() + ": " + InfoHelper.HITC() + getFormattedValue(); - } + public String getTooltipInfo() { + return InfoHelper.ITC() + getLocalizedName() + ": " + InfoHelper.HITC() + getFormattedValue(); + } - public void sendChanges(){ - DraconicEvolution.network.sendToServer(new ItemConfigPacket(this)); - } + public void sendChanges() { + DraconicEvolution.network.sendToServer(new ItemConfigPacket(this)); + } - public int castToInt(){ - switch (datatype){ - case References.BYTE_ID: - return (int) (Byte) value; - case References.SHORT_ID: - return (int) (Short) value; - case References.INT_ID: - return (Integer) value; - case References.LONG_ID: - long l = (Long) value; - return (int) l; - case References.FLOAT_ID: - float f = (Float) value; - return (int) f; - case References.DOUBLE_ID: - double d = (Double) value; - return (int) d; - case References.BOOLEAN_ID: - return (Boolean) value ? 1 : 0; - } - return 0; - } + public int castToInt() { + switch (datatype) { + case References.BYTE_ID: + return (int) (Byte) value; + case References.SHORT_ID: + return (int) (Short) value; + case References.INT_ID: + return (Integer) value; + case References.LONG_ID: + long l = (Long) value; + return (int) l; + case References.FLOAT_ID: + float f = (Float) value; + return (int) f; + case References.DOUBLE_ID: + double d = (Double) value; + return (int) d; + case References.BOOLEAN_ID: + return (Boolean) value ? 1 : 0; + } + return 0; + } - public double castToDouble(){ - switch (datatype){ - case References.BYTE_ID: - return (double) (Byte) value; - case References.SHORT_ID: - return (double) (Short) value; - case References.INT_ID: - return (double) (Integer) value; - case References.LONG_ID: - long l = (Long) value; - return (double) l; - case References.FLOAT_ID: - float f = (Float) value; - return (double) f; - case References.DOUBLE_ID: - return (Double) value; - case References.BOOLEAN_ID: - return (Boolean) value ? 1D : 0D; - } - return 0D; - } + public double castToDouble() { + switch (datatype) { + case References.BYTE_ID: + return (double) (Byte) value; + case References.SHORT_ID: + return (double) (Short) value; + case References.INT_ID: + return (double) (Integer) value; + case References.LONG_ID: + long l = (Long) value; + return (double) l; + case References.FLOAT_ID: + float f = (Float) value; + return (double) f; + case References.DOUBLE_ID: + return (Double) value; + case References.BOOLEAN_ID: + return (Boolean) value ? 1D : 0D; + } + return 0D; + } - public double castMinToDouble(){ - switch (datatype){ - case References.BYTE_ID: - return (double) (Byte) min; - case References.SHORT_ID: - return (double) (Short) min; - case References.INT_ID: - return (double) (Integer) min; - case References.LONG_ID: - long l = (Long) min; - return (double) l; - case References.FLOAT_ID: - float f = (Float) min; - return (double) f; - case References.DOUBLE_ID: - return (Double) min; - case References.BOOLEAN_ID: - return 0D; - } - return 0D; - } + public double castMinToDouble() { + switch (datatype) { + case References.BYTE_ID: + return (double) (Byte) min; + case References.SHORT_ID: + return (double) (Short) min; + case References.INT_ID: + return (double) (Integer) min; + case References.LONG_ID: + long l = (Long) min; + return (double) l; + case References.FLOAT_ID: + float f = (Float) min; + return (double) f; + case References.DOUBLE_ID: + return (Double) min; + case References.BOOLEAN_ID: + return 0D; + } + return 0D; + } - public double castMaxToDouble(){ - switch (datatype){ - case References.BYTE_ID: - return (double) (Byte) max; - case References.SHORT_ID: - return (double) (Short) max; - case References.INT_ID: - return (double) (Integer) max; - case References.LONG_ID: - long l = (Long) max; - return (double) l; - case References.FLOAT_ID: - float f = (Float) max; - return (double) f; - case References.DOUBLE_ID: - return (Double) max; - case References.BOOLEAN_ID: - return 1D; - } - return 0D; - } + public double castMaxToDouble() { + switch (datatype) { + case References.BYTE_ID: + return (double) (Byte) max; + case References.SHORT_ID: + return (double) (Short) max; + case References.INT_ID: + return (double) (Integer) max; + case References.LONG_ID: + long l = (Long) max; + return (double) l; + case References.FLOAT_ID: + float f = (Float) max; + return (double) f; + case References.DOUBLE_ID: + return (Double) max; + case References.BOOLEAN_ID: + return 1D; + } + return 0D; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/LogHelper.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/LogHelper.java index 69aab3ae..7beb5e6e 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/utills/LogHelper.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/LogHelper.java @@ -10,27 +10,42 @@ import org.apache.logging.log4j.Level; */ public class LogHelper { - public static void log(Level logLevel, Object object) - { - if (ConfigHandler.disableLog){ + public static void log(Level logLevel, Object object) { + if (ConfigHandler.disableLog) { return; } - FMLLog.log(References.MODNAME, logLevel, String.valueOf(object)); - } + FMLLog.log(References.MODNAME, logLevel, String.valueOf(object)); + } - public static void all(Object object){ log(Level.ALL, object); } + public static void all(Object object) { + log(Level.ALL, object); + } - public static void debug(Object object){ log(Level.DEBUG, object); } + public static void debug(Object object) { + log(Level.DEBUG, object); + } - public static void error(Object object){ log(Level.ERROR, object); } + public static void error(Object object) { + log(Level.ERROR, object); + } - public static void fatal(Object object){ log(Level.FATAL, object); } + public static void fatal(Object object) { + log(Level.FATAL, object); + } - public static void info(Object object){ log(Level.INFO, object); } + public static void info(Object object) { + log(Level.INFO, object); + } - public static void off(Object object){ log(Level.OFF, object); } + public static void off(Object object) { + log(Level.OFF, object); + } - public static void trace(Object object){ log(Level.TRACE, object); } + public static void trace(Object object) { + log(Level.TRACE, object); + } - public static void warn(Object object){ log(Level.WARN, object); } + public static void warn(Object object) { + log(Level.WARN, object); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/PortalHelper.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/PortalHelper.java index ec0a7bf5..bbca7f35 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/utills/PortalHelper.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/PortalHelper.java @@ -14,194 +14,199 @@ import net.minecraftforge.common.util.ForgeDirection; */ public class PortalHelper { - static int iterationNow = 0; + static int iterationNow = 0; - public static boolean isFrame(Block block) { return block == ModBlocks.infusedObsidian; } + public static boolean isFrame(Block block) { + return block == ModBlocks.infusedObsidian; + } - public static boolean isReceptacle(Block block) { return block == ModBlocks.dislocatorReceptacle; } + public static boolean isReceptacle(Block block) { + return block == ModBlocks.dislocatorReceptacle; + } - public static boolean isPortal(Block block) { return block == ModBlocks.portal; } + public static boolean isPortal(Block block) { + return block == ModBlocks.portal; + } - public static PortalStructure getValidStructure(World world, int x, int y, int z) { - if (world.isRemote) return null; + public static PortalStructure getValidStructure(World world, int x, int y, int z) { + if (world.isRemote) return null; - for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS){ - for (ForgeDirection plane : ForgeDirection.VALID_DIRECTIONS){ - if (plane != direction && plane != direction.getOpposite()) { - PortalStructure structure = traceFrame(world, x, y, z, direction, plane); - if (structure != null && structure.scanPortal(world, x, y, z, false, false)) return structure; - } - } - } + for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { + for (ForgeDirection plane : ForgeDirection.VALID_DIRECTIONS) { + if (plane != direction && plane != direction.getOpposite()) { + PortalStructure structure = traceFrame(world, x, y, z, direction, plane); + if (structure != null && structure.scanPortal(world, x, y, z, false, false)) return structure; + } + } + } - return null; - } + return null; + } - public static PortalStructure traceFrame(World world, int x, int y, int z, ForgeDirection startDir, ForgeDirection plane){ - int MAX_SIZE = 150; - int startX = x + startDir.offsetX; - int startY = y + startDir.offsetY; - int startZ = z + startDir.offsetZ; + public static PortalStructure traceFrame(World world, int x, int y, int z, ForgeDirection startDir, ForgeDirection plane) { + int MAX_SIZE = 150; + int startX = x + startDir.offsetX; + int startY = y + startDir.offsetY; + int startZ = z + startDir.offsetZ; - //Check that the trace is starting from a receptacle - if (!world.isAirBlock(startX, startY, startZ)) return null; + //Check that the trace is starting from a receptacle + if (!world.isAirBlock(startX, startY, startZ)) return null; - int xSize = 0; - int ySize = 0; - int yOffset = 0; + int xSize = 0; + int ySize = 0; + int yOffset = 0; - //Get X size - for (int i = 0; i <= MAX_SIZE; i++){ - Block block = world.getBlock(startX + i * startDir.offsetX, startY + i * startDir.offsetY, startZ + i * startDir.offsetZ); - if (isFrame(block)) { - xSize = i; - break; - } - else if (!world.isAirBlock(startX + i * startDir.offsetX, startY + i * startDir.offsetY, startZ + i * startDir.offsetZ)) return null; - } + //Get X size + for (int i = 0; i <= MAX_SIZE; i++) { + Block block = world.getBlock(startX + i * startDir.offsetX, startY + i * startDir.offsetY, startZ + i * startDir.offsetZ); + if (isFrame(block)) { + xSize = i; + break; + } else if (!world.isAirBlock(startX + i * startDir.offsetX, startY + i * startDir.offsetY, startZ + i * startDir.offsetZ)) + return null; + } - //Get Y size above receptacle - for (int i = 0; i <= MAX_SIZE; i++){ - Block block = world.getBlock(startX + i * plane.offsetX, startY + i * plane.offsetY, startZ + i * plane.offsetZ); - if (isFrame(block)) { - ySize = i; - break; - } - else if (!world.isAirBlock(startX + i * plane.offsetX, startY + i * plane.offsetY, startZ + i * plane.offsetZ)) return null; - } + //Get Y size above receptacle + for (int i = 0; i <= MAX_SIZE; i++) { + Block block = world.getBlock(startX + i * plane.offsetX, startY + i * plane.offsetY, startZ + i * plane.offsetZ); + if (isFrame(block)) { + ySize = i; + break; + } else if (!world.isAirBlock(startX + i * plane.offsetX, startY + i * plane.offsetY, startZ + i * plane.offsetZ)) + return null; + } - //Get Y size below receptacle and get y offset - for (int i = 0; i <= MAX_SIZE; i++){ - Block block = world.getBlock(startX - i * plane.offsetX, startY - i * plane.offsetY, startZ - i * plane.offsetZ); - if (isFrame(block)) { - ySize += i - 1; - yOffset = i; - break; - } - else if (!world.isAirBlock(startX - i * plane.offsetX, startY - i * plane.offsetY, startZ - i * plane.offsetZ)) return null; + //Get Y size below receptacle and get y offset + for (int i = 0; i <= MAX_SIZE; i++) { + Block block = world.getBlock(startX - i * plane.offsetX, startY - i * plane.offsetY, startZ - i * plane.offsetZ); + if (isFrame(block)) { + ySize += i - 1; + yOffset = i; + break; + } else if (!world.isAirBlock(startX - i * plane.offsetX, startY - i * plane.offsetY, startZ - i * plane.offsetZ)) + return null; - } + } - if (xSize == 0 || ySize == 0 || ySize > MAX_SIZE) return null; + if (xSize == 0 || ySize == 0 || ySize > MAX_SIZE) return null; - PortalStructure structure = new PortalStructure(xSize, ySize, yOffset, startDir, plane); + PortalStructure structure = new PortalStructure(xSize, ySize, yOffset, startDir, plane); - if (!structure.checkFrameIsValid(world, x, y, z) || !structure.scanPortal(world, x, y, z, false, false)) return null; + if (!structure.checkFrameIsValid(world, x, y, z) || !structure.scanPortal(world, x, y, z, false, false)) + return null; - return structure; - } + return structure; + } - public static class PortalStructure { + public static class PortalStructure { - public int xSize; - public int ySize; - public int yOffset; - public ForgeDirection startDir; - public ForgeDirection plane; + public int xSize; + public int ySize; + public int yOffset; + public ForgeDirection startDir; + public ForgeDirection plane; - public PortalStructure(){} + public PortalStructure() { + } - public PortalStructure(int xSize, int ySize, int yOffset, ForgeDirection startDir, ForgeDirection plane){ - this.xSize = xSize; - this.ySize = ySize; - this.yOffset = yOffset; - this.startDir = startDir; - this.plane = plane; - } + public PortalStructure(int xSize, int ySize, int yOffset, ForgeDirection startDir, ForgeDirection plane) { + this.xSize = xSize; + this.ySize = ySize; + this.yOffset = yOffset; + this.startDir = startDir; + this.plane = plane; + } - public boolean checkFrameIsValid(World world, int x, int y, int z) { + public boolean checkFrameIsValid(World world, int x, int y, int z) { - int startX = x + startDir.offsetX; - int startY = y + startDir.offsetY; - int startZ = z + startDir.offsetZ; + int startX = x + startDir.offsetX; + int startY = y + startDir.offsetY; + int startZ = z + startDir.offsetZ; - //Check structure for y size - for (int y1 = 1; y1 <= ySize; y1++){ - int y2 = y1 - yOffset; + //Check structure for y size + for (int y1 = 1; y1 <= ySize; y1++) { + int y2 = y1 - yOffset; - int inX = startX + y2 * plane.offsetX - startDir.offsetX; - int inY = startY + y2 * plane.offsetY - startDir.offsetY; - int inZ = startZ + y2 * plane.offsetZ - startDir.offsetZ; + int inX = startX + y2 * plane.offsetX - startDir.offsetX; + int inY = startY + y2 * plane.offsetY - startDir.offsetY; + int inZ = startZ + y2 * plane.offsetZ - startDir.offsetZ; - int outX = startX + y2 * plane.offsetX + (xSize) * startDir.offsetX; - int outY = startY + y2 * plane.offsetY + (xSize) * startDir.offsetY; - int outZ = startZ + y2 * plane.offsetZ + (xSize) * startDir.offsetZ; + int outX = startX + y2 * plane.offsetX + (xSize) * startDir.offsetX; + int outY = startY + y2 * plane.offsetY + (xSize) * startDir.offsetY; + int outZ = startZ + y2 * plane.offsetZ + (xSize) * startDir.offsetZ; - if (!isFrame(world.getBlock(inX, inY, inZ)) && !(inX == x && inY == y && inZ == z)) return false; - if (!isFrame(world.getBlock(outX, outY, outZ))) return false; - } + if (!isFrame(world.getBlock(inX, inY, inZ)) && !(inX == x && inY == y && inZ == z)) return false; + if (!isFrame(world.getBlock(outX, outY, outZ))) return false; + } - //Check structure for x size - for (int x1 = 0; x1 < xSize; x1++){ - int upX = startX + x1 * startDir.offsetX - yOffset * plane.offsetX; - int upY = startY + x1 * startDir.offsetY - yOffset * plane.offsetY; - int upZ = startZ + x1 * startDir.offsetZ - yOffset * plane.offsetZ; + //Check structure for x size + for (int x1 = 0; x1 < xSize; x1++) { + int upX = startX + x1 * startDir.offsetX - yOffset * plane.offsetX; + int upY = startY + x1 * startDir.offsetY - yOffset * plane.offsetY; + int upZ = startZ + x1 * startDir.offsetZ - yOffset * plane.offsetZ; - int downX = startX + x1 * startDir.offsetX + (ySize - yOffset + 1) * plane.offsetX; - int downY = startY + x1 * startDir.offsetY + (ySize - yOffset + 1) * plane.offsetY; - int downZ = startZ + x1 * startDir.offsetZ + (ySize - yOffset + 1) * plane.offsetZ; + int downX = startX + x1 * startDir.offsetX + (ySize - yOffset + 1) * plane.offsetX; + int downY = startY + x1 * startDir.offsetY + (ySize - yOffset + 1) * plane.offsetY; + int downZ = startZ + x1 * startDir.offsetZ + (ySize - yOffset + 1) * plane.offsetZ; - if (!isFrame(world.getBlock(upX, upY, upZ))) return false; - if (!isFrame(world.getBlock(downX, downY, downZ))) return false; - } + if (!isFrame(world.getBlock(upX, upY, upZ))) return false; + if (!isFrame(world.getBlock(downX, downY, downZ))) return false; + } - return true; - } + return true; + } - public boolean scanPortal(World world, int x, int y, int z, boolean setPortalBlocks, boolean checkPortalBlocks){ - int startX = x + startDir.offsetX; - int startY = y + startDir.offsetY; - int startZ = z + startDir.offsetZ; + public boolean scanPortal(World world, int x, int y, int z, boolean setPortalBlocks, boolean checkPortalBlocks) { + int startX = x + startDir.offsetX; + int startY = y + startDir.offsetY; + int startZ = z + startDir.offsetZ; - TileDislocatorReceptacle receptacle = (TileDislocatorReceptacle) world.getTileEntity(x, y, z); - if (receptacle == null) return false; - if (setPortalBlocks) receptacle.updating = true; + TileDislocatorReceptacle receptacle = (TileDislocatorReceptacle) world.getTileEntity(x, y, z); + if (receptacle == null) return false; + if (setPortalBlocks) receptacle.updating = true; - for (int x1 = 0; x1 < xSize; x1++){ - for (int y1 = 1; y1 <= ySize; y1++) - { - int y2 = y1 - yOffset; - int X = (startX + x1 * startDir.offsetX) + y2 * plane.offsetX; - int Y = (startY + x1 * startDir.offsetY) + y2 * plane.offsetY; - int Z = (startZ + x1 * startDir.offsetZ) + y2 * plane.offsetZ; + for (int x1 = 0; x1 < xSize; x1++) { + for (int y1 = 1; y1 <= ySize; y1++) { + int y2 = y1 - yOffset; + int X = (startX + x1 * startDir.offsetX) + y2 * plane.offsetX; + int Y = (startY + x1 * startDir.offsetY) + y2 * plane.offsetY; + int Z = (startZ + x1 * startDir.offsetZ) + y2 * plane.offsetZ; - Block block = world.getBlock(X, Y, Z); + Block block = world.getBlock(X, Y, Z); - if (checkPortalBlocks){ - if (!isPortal(block)) return false; - } - else if (setPortalBlocks) { - world.setBlock(X, Y, Z, ModBlocks.portal); - Chunk chunk = world.getChunkFromBlockCoords(X, Z); - TilePortalBlock tile = (TilePortalBlock) chunk.func_150806_e(X & 15, Y, Z & 15); - tile.masterX = x; - tile.masterY = y; - tile.masterZ = z; - } - else if (!world.isAirBlock(X, Y, Z)) return false; - } - } + if (checkPortalBlocks) { + if (!isPortal(block)) return false; + } else if (setPortalBlocks) { + world.setBlock(X, Y, Z, ModBlocks.portal); + Chunk chunk = world.getChunkFromBlockCoords(X, Z); + TilePortalBlock tile = (TilePortalBlock) chunk.func_150806_e(X & 15, Y, Z & 15); + tile.masterX = x; + tile.masterY = y; + tile.masterZ = z; + } else if (!world.isAirBlock(X, Y, Z)) return false; + } + } - if (setPortalBlocks) receptacle.updating = false; + if (setPortalBlocks) receptacle.updating = false; - return true; - } + return true; + } - public void writeToNBT(NBTTagCompound compound){ - compound.setInteger("XSize", xSize); - compound.setInteger("YSize", ySize); - compound.setInteger("YOffset", yOffset); - compound.setString("StartDir", startDir.name()); - compound.setString("Plane", plane.name()); - } + public void writeToNBT(NBTTagCompound compound) { + compound.setInteger("XSize", xSize); + compound.setInteger("YSize", ySize); + compound.setInteger("YOffset", yOffset); + compound.setString("StartDir", startDir.name()); + compound.setString("Plane", plane.name()); + } - public void readFromNBT(NBTTagCompound compound){ - xSize = compound.getInteger("XSize"); - ySize = compound.getInteger("YSize"); - yOffset = compound.getInteger("YOffset"); - startDir = ForgeDirection.valueOf(compound.getString("StartDir")); - plane = ForgeDirection.valueOf(compound.getString("Plane")); - } - } + public void readFromNBT(NBTTagCompound compound) { + xSize = compound.getInteger("XSize"); + ySize = compound.getInteger("YSize"); + yOffset = compound.getInteger("YOffset"); + startDir = ForgeDirection.valueOf(compound.getString("StartDir")); + plane = ForgeDirection.valueOf(compound.getString("Plane")); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/ShapedOreEnergyRecipe.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/ShapedOreEnergyRecipe.java index 420e8ce1..ba0bcd06 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/utills/ShapedOreEnergyRecipe.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/ShapedOreEnergyRecipe.java @@ -13,24 +13,33 @@ import net.minecraftforge.oredict.ShapedOreRecipe; */ public class ShapedOreEnergyRecipe extends ShapedOreRecipe { - public ShapedOreEnergyRecipe(Block result, Object... recipe){ this(new ItemStack(result), recipe); } - public ShapedOreEnergyRecipe(Item result, Object... recipe){ this(new ItemStack(result), recipe); } - public ShapedOreEnergyRecipe(ItemStack result, Object... recipe) {super(result, recipe);} + public ShapedOreEnergyRecipe(Block result, Object... recipe) { + this(new ItemStack(result), recipe); + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - ItemStack result = super.getCraftingResult(var1); + public ShapedOreEnergyRecipe(Item result, Object... recipe) { + this(new ItemStack(result), recipe); + } - int energy = 0; - for (int i = 0; i < var1.getSizeInventory(); i++) { - ItemStack stack = var1.getStackInSlot(i); - if (stack != null && stack.getItem() instanceof IEnergyContainerItem) { - energy += ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack); - } - } + public ShapedOreEnergyRecipe(ItemStack result, Object... recipe) { + super(result, recipe); + } - if (energy > 0 && result != null && result.getItem() instanceof IEnergyContainerItem) ItemNBTHelper.setInteger(result, "Energy", energy); + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) { + ItemStack result = super.getCraftingResult(var1); - return result; - } + int energy = 0; + for (int i = 0; i < var1.getSizeInventory(); i++) { + ItemStack stack = var1.getStackInSlot(i); + if (stack != null && stack.getItem() instanceof IEnergyContainerItem) { + energy += ((IEnergyContainerItem) stack.getItem()).getEnergyStored(stack); + } + } + + if (energy > 0 && result != null && result.getItem() instanceof IEnergyContainerItem) + ItemNBTHelper.setInteger(result, "Energy", energy); + + return result; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/UpdateChecker.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/UpdateChecker.java index 880b68b5..ac57cbde 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/utills/UpdateChecker.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/UpdateChecker.java @@ -15,96 +15,87 @@ import java.net.URL; /** * Created by Brandon on 24/02/2015. */ -public class UpdateChecker -{ - private final UpdateCheckThread thread; - private int delay = 300; - private boolean playerNotified = false; +public class UpdateChecker { + private final UpdateCheckThread thread; + private int delay = 300; + private boolean playerNotified = false; - public UpdateChecker() - { - thread = new UpdateCheckThread(); - thread.start(); - } + public UpdateChecker() { + thread = new UpdateCheckThread(); + thread.start(); + } - @SubscribeEvent - public void tickStart(TickEvent.PlayerTickEvent event) { - if (event.phase != TickEvent.Phase.START) return; - if (delay > 0) { - delay--; - return; - } + @SubscribeEvent + public void tickStart(TickEvent.PlayerTickEvent event) { + if (event.phase != TickEvent.Phase.START) return; + if (delay > 0) { + delay--; + return; + } - if (!playerNotified && thread.isComplete()) - { - playerNotified = true; - FMLCommonHandler.instance().bus().unregister(this); + if (!playerNotified && thread.isComplete()) { + playerNotified = true; + FMLCommonHandler.instance().bus().unregister(this); - if (!thread.getVersion().equals(VersionHandler.VERSION) || (VersionHandler.SNAPSHOT > 0 && thread.getSnapshot() == 0)) - { - event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "[Draconic Evolution]" + EnumChatFormatting.RESET + " New version available:")); - event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Draconic Evolution v" + thread.getVersion())); - if (!StringUtils.isNullOrEmpty(thread.getNote())) event.player.addChatComponentMessage(new ChatComponentText(thread.getNote())); - } - else if (thread.getSnapshot() > VersionHandler.SNAPSHOT) - { - event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE + "[Draconic Evolution]" + EnumChatFormatting.RESET + " New snapshot version available:")); - event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.BLUE + "Draconic Evolution v" + thread.getVersion() + "-snapshot_" + thread.getSnapshot())); - if (!StringUtils.isNullOrEmpty(thread.getNote())) event.player.addChatComponentMessage(new ChatComponentText(thread.getNote())); - } + if (!thread.getVersion().equals(VersionHandler.VERSION) || (VersionHandler.SNAPSHOT > 0 && thread.getSnapshot() == 0)) { + event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.LIGHT_PURPLE + "[Draconic Evolution]" + EnumChatFormatting.RESET + " New version available:")); + event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Draconic Evolution v" + thread.getVersion())); + if (!StringUtils.isNullOrEmpty(thread.getNote())) + event.player.addChatComponentMessage(new ChatComponentText(thread.getNote())); + } else if (thread.getSnapshot() > VersionHandler.SNAPSHOT) { + event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE + "[Draconic Evolution]" + EnumChatFormatting.RESET + " New snapshot version available:")); + event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.BLUE + "Draconic Evolution v" + thread.getVersion() + "-snapshot_" + thread.getSnapshot())); + if (!StringUtils.isNullOrEmpty(thread.getNote())) + event.player.addChatComponentMessage(new ChatComponentText(thread.getNote())); + } - } else if (thread.isFailed()) - { - playerNotified = true; - FMLCommonHandler.instance().bus().unregister(this); + } else if (thread.isFailed()) { + playerNotified = true; + FMLCommonHandler.instance().bus().unregister(this); - event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE + "[Draconic Evolution]" + EnumChatFormatting.RED + " Version check failed")); - if (!StringUtils.isNullOrEmpty(thread.getNote())) event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + thread.getNote())); - } + event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE + "[Draconic Evolution]" + EnumChatFormatting.RED + " Version check failed")); + if (!StringUtils.isNullOrEmpty(thread.getNote())) + event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + thread.getNote())); + } - - } + } - public class UpdateCheckThread extends Thread - { - private String version = null; - private int snapshot = -1; - private String note = null; - private boolean complete = false; - private boolean failed = false; + public class UpdateCheckThread extends Thread { + private String version = null; + private int snapshot = -1; + private String note = null; + private boolean complete = false; + private boolean failed = false; - @Override - public void run() { - LogHelper.info("[Update Checker] Thread Started"); - try - { - URL versionURL = new URL("https://raw.githubusercontent.com/brandon3055/Draconic-Evolution/master/VERSION.txt"); + @Override + public void run() { + LogHelper.info("[Update Checker] Thread Started"); + try { + URL versionURL = new URL("https://raw.githubusercontent.com/brandon3055/Draconic-Evolution/master/VERSION.txt"); - BufferedReader bufferedReader = new BufferedReader(new InputStreamReader((versionURL).openStream())); + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader((versionURL).openStream())); - String line; + String line; - while ((line = bufferedReader.readLine()) != null) - { - if (line.contains(":")) - { - String value = line.substring(line.indexOf(":") + 1); - if (line.contains("Version")) version = value; - else if (line.contains("Snapshot")) snapshot = Integer.parseInt(value); - else if (line.contains("ReleaseNote")) note = value; - } - } + while ((line = bufferedReader.readLine()) != null) { + if (line.contains(":")) { + String value = line.substring(line.indexOf(":") + 1); + if (line.contains("Version")) version = value; + else if (line.contains("Snapshot")) snapshot = Integer.parseInt(value); + else if (line.contains("ReleaseNote")) note = value; + } + } - if (version != null && snapshot >= 0) complete = true; - else { - note = "[Invalid Response]"; - failed = true; - } + if (version != null && snapshot >= 0) complete = true; + else { + note = "[Invalid Response]"; + failed = true; + } - LogHelper.info("[Update Checker] Thread Finished"); + LogHelper.info("[Update Checker] Thread Finished"); // if (complete) // { // if (!getVersion().equals(VersionHandler.VERSION) || (VersionHandler.SNAPSHOT > 0 && getSnapshot() == 0)) @@ -124,35 +115,34 @@ public class UpdateChecker // LogHelper.info("###############################"); // } // } - } - catch (Exception e) - { - LogHelper.info("[Update Checker] Check Failed"); - failed = true; - note = e.getClass().toString(); - e.printStackTrace(); - } - } + } + catch (Exception e) { + LogHelper.info("[Update Checker] Check Failed"); + failed = true; + note = e.getClass().toString(); + e.printStackTrace(); + } + } - public String getVersion() { - return version; - } + public String getVersion() { + return version; + } - public int getSnapshot() { - return snapshot; - } + public int getSnapshot() { + return snapshot; + } - public String getNote() { - return note; - } + public String getNote() { + return note; + } - public boolean isComplete() { - return complete; - } + public boolean isComplete() { + return complete; + } - public boolean isFailed() { - return failed; - } - } + public boolean isFailed() { + return failed; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/world/ChaosWorldGenHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/world/ChaosWorldGenHandler.java index b80d82d5..b1e186e7 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/world/ChaosWorldGenHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/world/ChaosWorldGenHandler.java @@ -22,281 +22,275 @@ import java.util.Random; public class ChaosWorldGenHandler { - /** - * Used to generate the chaos island chunk by chunk - * @param world The world. - * @param chunkX The X position of the chunk being generated. - * @param chunkZ The Z position of the chunk being generated. - * @param islandCenter Where to generate the island. If left null the islands will generate in a 10000 by 10000 grid. - * */ - public static void generateChunk(World world, int chunkX, int chunkZ, DataUtills.XZPair islandCenter, Random random){ - DataUtills.XZPair closestSpawn = islandCenter == null ? getClosestChaosSpawn(chunkX, chunkZ) : islandCenter; + /** + * Used to generate the chaos island chunk by chunk + * + * @param world The world. + * @param chunkX The X position of the chunk being generated. + * @param chunkZ The Z position of the chunk being generated. + * @param islandCenter Where to generate the island. If left null the islands will generate in a 10000 by 10000 grid. + */ + public static void generateChunk(World world, int chunkX, int chunkZ, DataUtills.XZPair islandCenter, Random random) { + DataUtills.XZPair closestSpawn = islandCenter == null ? getClosestChaosSpawn(chunkX, chunkZ) : islandCenter; - if (closestSpawn.x == 0 && closestSpawn.z == 0) return; - int posX = chunkX*16; - int posZ = chunkZ*16; - int copyStartDistance = 180; - if (Math.abs(posX-closestSpawn.x) > copyStartDistance || Math.abs(posZ-closestSpawn.z) > copyStartDistance) return; + if (closestSpawn.x == 0 && closestSpawn.z == 0) return; + int posX = chunkX * 16; + int posZ = chunkZ * 16; + int copyStartDistance = 180; + if (Math.abs(posX - closestSpawn.x) > copyStartDistance || Math.abs(posZ - closestSpawn.z) > copyStartDistance) + return; - if (closestSpawn.x > posX && closestSpawn.x <= posX + 16 && closestSpawn.z > posZ && closestSpawn.z <= posZ + 16) generateStructures(world, closestSpawn, random); + if (closestSpawn.x > posX && closestSpawn.x <= posX + 16 && closestSpawn.z > posZ && closestSpawn.z <= posZ + 16) + generateStructures(world, closestSpawn, random); - //long l = System.nanoTime(); + //long l = System.nanoTime(); - for (int trueX = posX; trueX < posX + 16; trueX++){ - for (int y = 0; y < 255; y++){ - for (int trueZ = posZ; trueZ < posZ + 16; trueZ++){ - int x = trueX - closestSpawn.x; - int z = trueZ - closestSpawn.z; - int size = 80; - double dist = Math.sqrt(x*x + (y-16)*(y-16) + z*z); - double xd, yd, zd; - double density, centerFalloff, plateauFalloff, heightMapFalloff; + for (int trueX = posX; trueX < posX + 16; trueX++) { + for (int y = 0; y < 255; y++) { + for (int trueZ = posZ; trueZ < posZ + 16; trueZ++) { + int x = trueX - closestSpawn.x; + int z = trueZ - closestSpawn.z; + int size = 80; + double dist = Math.sqrt(x * x + (y - 16) * (y - 16) + z * z); + double xd, yd, zd; + double density, centerFalloff, plateauFalloff, heightMapFalloff; - xd=(double)x/size; - yd=(double)y/(32); - zd=(double)z/size; + xd = (double) x / size; + yd = (double) y / (32); + zd = (double) z / size; - //Calculate Center Falloff - double diameterScale = 150D; - //centerFalloff = (1D - (dist / diameterScale)) * 1D; - centerFalloff = 1D / (dist * 0.05D); - if (centerFalloff < 0) centerFalloff = 0; + //Calculate Center Falloff + double diameterScale = 150D; + //centerFalloff = (1D - (dist / diameterScale)) * 1D; + centerFalloff = 1D / (dist * 0.05D); + if (centerFalloff < 0) centerFalloff = 0; - //Calculate Plateau Falloff - if(yd < 0.4D) plateauFalloff = yd*2.5D; - else if(yd <= 0.6D) plateauFalloff = 1D; - else if(yd > 0.6D && yd < 1D) plateauFalloff = 1D-(yd-0.6D)*2.5D; - else plateauFalloff = 0; + //Calculate Plateau Falloff + if (yd < 0.4D) plateauFalloff = yd * 2.5D; + else if (yd <= 0.6D) plateauFalloff = 1D; + else if (yd > 0.6D && yd < 1D) plateauFalloff = 1D - (yd - 0.6D) * 2.5D; + else plateauFalloff = 0; - //Trim Further calculations - if (plateauFalloff == 0 || centerFalloff == 0) continue; + //Trim Further calculations + if (plateauFalloff == 0 || centerFalloff == 0) continue; - //Calculate heightMapFalloff - heightMapFalloff = 0; - for (int octave = 1; octave < 5; octave++) heightMapFalloff += ((SimplexNoise.noise(xd * octave + closestSpawn.x, zd * octave + closestSpawn.z) + 1) * 0.5D) * 0.01D * (octave * 10D * 1-(dist * 0.001D)); - if (heightMapFalloff <= 0) heightMapFalloff = 0; - heightMapFalloff += ((0.5D-Math.abs(yd-0.5D)) * 0.15D); - if (heightMapFalloff == 0) continue; + //Calculate heightMapFalloff + heightMapFalloff = 0; + for (int octave = 1; octave < 5; octave++) + heightMapFalloff += ((SimplexNoise.noise(xd * octave + closestSpawn.x, zd * octave + closestSpawn.z) + 1) * 0.5D) * 0.01D * (octave * 10D * 1 - (dist * 0.001D)); + if (heightMapFalloff <= 0) heightMapFalloff = 0; + heightMapFalloff += ((0.5D - Math.abs(yd - 0.5D)) * 0.15D); + if (heightMapFalloff == 0) continue; - density = centerFalloff * plateauFalloff * heightMapFalloff; + density = centerFalloff * plateauFalloff * heightMapFalloff; - if (density > 0.1 && world.getBlock(x + closestSpawn.x, y + 64, z + closestSpawn.z) == Blocks.air) world.setBlock(x + closestSpawn.x, y + 64, z + closestSpawn.z, (dist > 60 || dist > random.nextInt(60)) ? Blocks.end_stone : Blocks.obsidian); + if (density > 0.1 && world.getBlock(x + closestSpawn.x, y + 64, z + closestSpawn.z) == Blocks.air) + world.setBlock(x + closestSpawn.x, y + 64, z + closestSpawn.z, (dist > 60 || dist > random.nextInt(60)) ? Blocks.end_stone : Blocks.obsidian); // if (density > 0.1 && world.getBlock(x + closestSpawn.x, y + 64, z + closestSpawn.z) == Blocks.air) { // boolean b = dist > 60 || dist > random.nextInt(60); // world.setBlock(x + closestSpawn.x, y + 64, z + closestSpawn.z, (dist > 60 || dist > random.nextInt(60)) ? Blocks.end_stone : Blocks.obsidian); // } - } - } - } - } + } + } + } + } - public static void generateStructures(World world, DataUtills.XZPair islandCenter, Random random){ - int outerRadius = 330; + public static void generateStructures(World world, DataUtills.XZPair islandCenter, Random random) { + int outerRadius = 330; - //Gen Chaos Cavern - int shardY = 80; + //Gen Chaos Cavern + int shardY = 80; - int coreHeight = 10; - int coreWidth = 20; + int coreHeight = 10; + int coreWidth = 20; - for(int y = shardY-coreHeight; y <= shardY+coreHeight; y++){ - int h = Math.abs(y-shardY); - int inRadius = h-3; - double yp = (coreHeight - h) / (double)coreHeight; - int outRadius = (int)(yp * coreWidth); - outRadius -= (outRadius * outRadius)/100; + for (int y = shardY - coreHeight; y <= shardY + coreHeight; y++) { + int h = Math.abs(y - shardY); + int inRadius = h - 3; + double yp = (coreHeight - h) / (double) coreHeight; + int outRadius = (int) (yp * coreWidth); + outRadius -= (outRadius * outRadius) / 100; - genCoreSlice(world, islandCenter.x, y, islandCenter.z, inRadius, shardY, coreWidth, true, random); - genCoreSlice(world, islandCenter.x, y, islandCenter.z, outRadius, shardY, coreWidth, false, random); - } + genCoreSlice(world, islandCenter.x, y, islandCenter.z, inRadius, shardY, coreWidth, true, random); + genCoreSlice(world, islandCenter.x, y, islandCenter.z, outRadius, shardY, coreWidth, false, random); + } - world.setBlock(islandCenter.x, shardY, islandCenter.z, ModBlocks.chaosCrystal); - TileChaosShard tileChaosShard = (TileChaosShard)world.getTileEntity(islandCenter.x, shardY, islandCenter.z); - tileChaosShard.locationHash = tileChaosShard.getLocationHash(islandCenter.x, shardY, islandCenter.z, world.provider.dimensionId); + world.setBlock(islandCenter.x, shardY, islandCenter.z, ModBlocks.chaosCrystal); + TileChaosShard tileChaosShard = (TileChaosShard) world.getTileEntity(islandCenter.x, shardY, islandCenter.z); + tileChaosShard.locationHash = tileChaosShard.getLocationHash(islandCenter.x, shardY, islandCenter.z, world.provider.dimensionId); - EntityChaosGuardian guardian = new EntityChaosGuardian(world); - guardian.setPositionAndUpdate(islandCenter.x, shardY, islandCenter.z); - world.spawnEntityInWorld(guardian); + EntityChaosGuardian guardian = new EntityChaosGuardian(world); + guardian.setPositionAndUpdate(islandCenter.x, shardY, islandCenter.z); + world.spawnEntityInWorld(guardian); - //Gen Ring - int rings = 4; - int width = 20; - int spacing = 8; - for (int x = islandCenter.x - outerRadius; x <= islandCenter.x + outerRadius; x++) { - for (int z = islandCenter.z - outerRadius; z <= islandCenter.z + outerRadius; z++) { - int dist = (int) (Utills.getDistanceAtoB(x, z, islandCenter.x, islandCenter.z)); - for (int i = 0; i < rings; i++) - { - //if (dist < outerRadius1 && dist >= innerRadius1 || dist < outerRadius2 && dist >= innerRadius2) - if (dist < (outerRadius - ((width + spacing) * i)) && dist >= (outerRadius - width - ((width + spacing) * i))) - { - int y = 90 + (int) ((double) (islandCenter.x - x) * 0.1D) + (random.nextInt(10) - 5); - if (0.1F > random.nextFloat()) world.setBlock(x, y, z, Blocks.end_stone, 0, 2); - if (0.001F > random.nextFloat()) world.setBlock(x, y, z, ModBlocks.draconiumOre, 0, 2); - } - } - } - } - generateObelisks(world, islandCenter, random); - } + //Gen Ring + int rings = 4; + int width = 20; + int spacing = 8; + for (int x = islandCenter.x - outerRadius; x <= islandCenter.x + outerRadius; x++) { + for (int z = islandCenter.z - outerRadius; z <= islandCenter.z + outerRadius; z++) { + int dist = (int) (Utills.getDistanceAtoB(x, z, islandCenter.x, islandCenter.z)); + for (int i = 0; i < rings; i++) { + //if (dist < outerRadius1 && dist >= innerRadius1 || dist < outerRadius2 && dist >= innerRadius2) + if (dist < (outerRadius - ((width + spacing) * i)) && dist >= (outerRadius - width - ((width + spacing) * i))) { + int y = 90 + (int) ((double) (islandCenter.x - x) * 0.1D) + (random.nextInt(10) - 5); + if (0.1F > random.nextFloat()) world.setBlock(x, y, z, Blocks.end_stone, 0, 2); + if (0.001F > random.nextFloat()) world.setBlock(x, y, z, ModBlocks.draconiumOre, 0, 2); + } + } + } + } + generateObelisks(world, islandCenter, random); + } - public static void genCoreSlice(World world, int xi, int yi, int zi, int ringRadius, int yc, int coreRadious, boolean fillIn, Random rand) { - for( int x = xi-coreRadious ; x<= xi+coreRadious; x++) { - for (int z = zi - coreRadious; z <= zi + coreRadious; z++) { - double dist = Utills.getDistanceAtoB(x, yi, z, xi, yc, zi); + public static void genCoreSlice(World world, int xi, int yi, int zi, int ringRadius, int yc, int coreRadious, boolean fillIn, Random rand) { + for (int x = xi - coreRadious; x <= xi + coreRadious; x++) { + for (int z = zi - coreRadious; z <= zi + coreRadious; z++) { + double dist = Utills.getDistanceAtoB(x, yi, z, xi, yc, zi); - double oRad = coreRadious - (Math.abs(yc-yi) * Math.abs(yc-yi))/10; - if (dist > oRad-3D && rand.nextDouble()*3D < dist-(oRad-3D)) continue; + double oRad = coreRadious - (Math.abs(yc - yi) * Math.abs(yc - yi)) / 10; + if (dist > oRad - 3D && rand.nextDouble() * 3D < dist - (oRad - 3D)) continue; - if (fillIn && (int) (Utills.getDistanceAtoB(x, z, xi, zi)) <= ringRadius) - { - if ((int)dist < 9)world.setBlock(x, yi, z, ModBlocks.infusedObsidian); - else world.setBlock(x, yi, z, Blocks.obsidian); - } - else - if (!fillIn && (int) (Utills.getDistanceAtoB(x, z, xi, zi)) >= ringRadius) - { - world.setBlock(x, yi, z, Blocks.obsidian); - } - else if (!fillIn && (int) Utills.getDistanceAtoB(x, z, xi, zi) <= ringRadius) - { - Block b = world.getBlock(x, yi, z); - if (b == Blocks.air || b == Blocks.end_stone || b == Blocks.obsidian) world.setBlock(x, yi, z, ModBlocks.chaosShardAtmos); - } + if (fillIn && (int) (Utills.getDistanceAtoB(x, z, xi, zi)) <= ringRadius) { + if ((int) dist < 9) world.setBlock(x, yi, z, ModBlocks.infusedObsidian); + else world.setBlock(x, yi, z, Blocks.obsidian); + } else if (!fillIn && (int) (Utills.getDistanceAtoB(x, z, xi, zi)) >= ringRadius) { + world.setBlock(x, yi, z, Blocks.obsidian); + } else if (!fillIn && (int) Utills.getDistanceAtoB(x, z, xi, zi) <= ringRadius) { + Block b = world.getBlock(x, yi, z); + if (b == Blocks.air || b == Blocks.end_stone || b == Blocks.obsidian) + world.setBlock(x, yi, z, ModBlocks.chaosShardAtmos); + } - } - } -} - - - public static DataUtills.XZPair getClosestChaosSpawn(int chunkX, int chunkZ){ - return new DataUtills.XZPair(Utills.getNearestMultiple(chunkX * 16, ConfigHandler.chaosIslandSeparation), Utills.getNearestMultiple(chunkZ*16, ConfigHandler.chaosIslandSeparation)); - } - - private static void generateObelisks(World world, DataUtills.XZPair islandCenter, Random rand) { - - for (int i = 0; i < 7; i++) { - double rotation = i * 0.9D; - int sX = islandCenter.x + (int) (Math.sin(rotation) * 45D); - int sZ = islandCenter.z + (int) (Math.cos(rotation) * 45D); - generateObelisk(world, sX, 90, sZ, false, rand); - } - - for (int i = 0; i < 14; i++) { - double rotation = i * 0.45D; - int sX = islandCenter.x + (int) (Math.sin(rotation) * 90D); - int sZ = islandCenter.z + (int) (Math.cos(rotation) * 90D); - generateObelisk(world, sX, 90, sZ, true, rand); - } - - } - - private static void generateObelisk(World world, int x1, int y1, int z1, boolean outer, Random rand) { - if (!outer) { - world.setBlock(x1, y1 + 20, z1, ModBlocks.infusedObsidian, 0, 2); - if (!world.isRemote) { - EntityChaosCrystal crystal = new EntityChaosCrystal(world); - crystal.setPosition(x1 + 0.5, y1 + 21, z1 + 0.5); - world.spawnEntityInWorld(crystal); - } - for (int y = y1; y < y1 + 20; y++) { - world.setBlock(x1, y, z1, Blocks.obsidian, 0, 2); - world.setBlock(x1 + 1, y, z1, Blocks.obsidian, 0, 2); - world.setBlock(x1 - 1, y, z1, Blocks.obsidian, 0, 2); - world.setBlock(x1, y, z1 + 1, Blocks.obsidian, 0, 2); - world.setBlock(x1, y, z1 - 1, Blocks.obsidian, 0, 2); - world.setBlock(x1 + 1, y, z1 + 1, Blocks.obsidian, 0, 2); - world.setBlock(x1 - 1, y, z1 - 1, Blocks.obsidian, 0, 2); - world.setBlock(x1 + 1, y, z1 - 1, Blocks.obsidian, 0, 2); - world.setBlock(x1 - 1, y, z1 + 1, Blocks.obsidian, 0, 2); - } - } else { - world.setBlock(x1, y1 + 40, z1, ModBlocks.infusedObsidian, 0, 2); - if (!world.isRemote) { - EntityChaosCrystal crystal = new EntityChaosCrystal(world); - crystal.setPosition(x1 + 0.5, y1 + 41, z1 + 0.5); - world.spawnEntityInWorld(crystal); - } - int diff = 0; - for (int y = y1 + 20; y < y1 + 40; y++) { - diff++; - double pct = (double) diff / 25D; - int r = 3; - for (int x = x1 - r; x <= x1 + r; x++) { - for (int z = z1 - r; z <= z1 + r; z++) { - if (Utills.getDistanceAtoB(x, z, x1, z1) <= r) { - if (pct > rand.nextDouble()) world.setBlock(x, y, z, Blocks.obsidian, 0, 2); - } - } - } - } - - int cageS = 2; - for (int x = x1 - cageS; x <= x1 + cageS; x++) { - for (int y = y1 - cageS; y <= y1 + cageS; y++) { - if (0.8F > rand.nextFloat()) world.setBlock(x, y + 41, z1 + cageS, Blocks.iron_bars, 0, 2); - if (0.8F > rand.nextFloat()) world.setBlock(x, y + 41, z1 - cageS, Blocks.iron_bars, 0, 2); - } - } - for (int z = z1 - cageS; z <= z1 + cageS; z++) { - for (int y = y1 - cageS; y <= y1 + cageS; y++) { - if (0.8F > rand.nextFloat()) world.setBlock(x1 + cageS, y + 41, z, Blocks.iron_bars, 0, 2); - if (0.8F > rand.nextFloat()) world.setBlock(x1 - cageS, y + 41, z, Blocks.iron_bars, 0, 2); - } - } - for (int z = z1 - cageS; z <= z1 + cageS; z++) { - for (int x = x1 - cageS; x <= x1 + cageS; x++) { - if (0.8F > rand.nextFloat()) world.setBlock(x, y1 + 44, z, Blocks.stone_slab, 6, 2); - } - } - - } - } - - public static class CrystalRemover implements IProcess { - private boolean dead = false; - - private Entity entity; - private int delay = 2; - public CrystalRemover(Entity entity){ - this.entity = entity; - } - - @Override - public void updateProcess() { - if (delay > 0) delay--; - else - { - boolean flag = true; - int y = (int) entity.posY - 1; - for (; flag; ) - { - flag = false; - for (int x = (int) Math.floor(entity.posX) - 4; x <= (int) Math.floor(entity.posX) + 4; x++) - { - for (int z = (int) Math.floor(entity.posZ) - 4; z <= (int) Math.floor(entity.posZ) + 4; z++) - { - Block block = entity.worldObj.getBlock(x, y, z); - if (block == Blocks.bedrock || block == Blocks.obsidian) - { - flag = true; - entity.worldObj.setBlockToAir(x, y, z); - } - } - } - if (flag) y--; - } - entity.setDead(); - this.dead = true; - } - } - - @Override - public boolean isDead() { - return dead; - } - } + } + } + } + + + public static DataUtills.XZPair getClosestChaosSpawn(int chunkX, int chunkZ) { + return new DataUtills.XZPair(Utills.getNearestMultiple(chunkX * 16, ConfigHandler.chaosIslandSeparation), Utills.getNearestMultiple(chunkZ * 16, ConfigHandler.chaosIslandSeparation)); + } + + private static void generateObelisks(World world, DataUtills.XZPair islandCenter, Random rand) { + + for (int i = 0; i < 7; i++) { + double rotation = i * 0.9D; + int sX = islandCenter.x + (int) (Math.sin(rotation) * 45D); + int sZ = islandCenter.z + (int) (Math.cos(rotation) * 45D); + generateObelisk(world, sX, 90, sZ, false, rand); + } + + for (int i = 0; i < 14; i++) { + double rotation = i * 0.45D; + int sX = islandCenter.x + (int) (Math.sin(rotation) * 90D); + int sZ = islandCenter.z + (int) (Math.cos(rotation) * 90D); + generateObelisk(world, sX, 90, sZ, true, rand); + } + + } + + private static void generateObelisk(World world, int x1, int y1, int z1, boolean outer, Random rand) { + if (!outer) { + world.setBlock(x1, y1 + 20, z1, ModBlocks.infusedObsidian, 0, 2); + if (!world.isRemote) { + EntityChaosCrystal crystal = new EntityChaosCrystal(world); + crystal.setPosition(x1 + 0.5, y1 + 21, z1 + 0.5); + world.spawnEntityInWorld(crystal); + } + for (int y = y1; y < y1 + 20; y++) { + world.setBlock(x1, y, z1, Blocks.obsidian, 0, 2); + world.setBlock(x1 + 1, y, z1, Blocks.obsidian, 0, 2); + world.setBlock(x1 - 1, y, z1, Blocks.obsidian, 0, 2); + world.setBlock(x1, y, z1 + 1, Blocks.obsidian, 0, 2); + world.setBlock(x1, y, z1 - 1, Blocks.obsidian, 0, 2); + world.setBlock(x1 + 1, y, z1 + 1, Blocks.obsidian, 0, 2); + world.setBlock(x1 - 1, y, z1 - 1, Blocks.obsidian, 0, 2); + world.setBlock(x1 + 1, y, z1 - 1, Blocks.obsidian, 0, 2); + world.setBlock(x1 - 1, y, z1 + 1, Blocks.obsidian, 0, 2); + } + } else { + world.setBlock(x1, y1 + 40, z1, ModBlocks.infusedObsidian, 0, 2); + if (!world.isRemote) { + EntityChaosCrystal crystal = new EntityChaosCrystal(world); + crystal.setPosition(x1 + 0.5, y1 + 41, z1 + 0.5); + world.spawnEntityInWorld(crystal); + } + int diff = 0; + for (int y = y1 + 20; y < y1 + 40; y++) { + diff++; + double pct = (double) diff / 25D; + int r = 3; + for (int x = x1 - r; x <= x1 + r; x++) { + for (int z = z1 - r; z <= z1 + r; z++) { + if (Utills.getDistanceAtoB(x, z, x1, z1) <= r) { + if (pct > rand.nextDouble()) world.setBlock(x, y, z, Blocks.obsidian, 0, 2); + } + } + } + } + + int cageS = 2; + for (int x = x1 - cageS; x <= x1 + cageS; x++) { + for (int y = y1 - cageS; y <= y1 + cageS; y++) { + if (0.8F > rand.nextFloat()) world.setBlock(x, y + 41, z1 + cageS, Blocks.iron_bars, 0, 2); + if (0.8F > rand.nextFloat()) world.setBlock(x, y + 41, z1 - cageS, Blocks.iron_bars, 0, 2); + } + } + for (int z = z1 - cageS; z <= z1 + cageS; z++) { + for (int y = y1 - cageS; y <= y1 + cageS; y++) { + if (0.8F > rand.nextFloat()) world.setBlock(x1 + cageS, y + 41, z, Blocks.iron_bars, 0, 2); + if (0.8F > rand.nextFloat()) world.setBlock(x1 - cageS, y + 41, z, Blocks.iron_bars, 0, 2); + } + } + for (int z = z1 - cageS; z <= z1 + cageS; z++) { + for (int x = x1 - cageS; x <= x1 + cageS; x++) { + if (0.8F > rand.nextFloat()) world.setBlock(x, y1 + 44, z, Blocks.stone_slab, 6, 2); + } + } + + } + } + + public static class CrystalRemover implements IProcess { + private boolean dead = false; + + private Entity entity; + private int delay = 2; + + public CrystalRemover(Entity entity) { + this.entity = entity; + } + + @Override + public void updateProcess() { + if (delay > 0) delay--; + else { + boolean flag = true; + int y = (int) entity.posY - 1; + for (; flag; ) { + flag = false; + for (int x = (int) Math.floor(entity.posX) - 4; x <= (int) Math.floor(entity.posX) + 4; x++) { + for (int z = (int) Math.floor(entity.posZ) - 4; z <= (int) Math.floor(entity.posZ) + 4; z++) { + Block block = entity.worldObj.getBlock(x, y, z); + if (block == Blocks.bedrock || block == Blocks.obsidian) { + flag = true; + entity.worldObj.setBlockToAir(x, y, z); + } + } + } + if (flag) y--; + } + entity.setDead(); + this.dead = true; + } + } + + @Override + public boolean isDead() { + return dead; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/world/DraconicWorldGenerator.java b/src/main/java/com/brandon3055/draconicevolution/common/world/DraconicWorldGenerator.java index db7d50fc..e027717b 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/world/DraconicWorldGenerator.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/world/DraconicWorldGenerator.java @@ -12,72 +12,78 @@ import net.minecraft.world.gen.feature.WorldGenMinable; import java.util.Random; public class DraconicWorldGenerator implements IWorldGenerator { - public static boolean chaosIslandsEnabled = true; - public static boolean cometsEnabled = true; - public static boolean oreEnabledInEnd = true; + public static boolean chaosIslandsEnabled = true; + public static boolean cometsEnabled = true; + public static boolean oreEnabledInEnd = true; - @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { - switch (world.provider.dimensionId) { - case 0: - generateSurface(random, chunkX * 16, chunkZ * 16, world); - break; - case 1: - generateEnd(random, chunkX * 16, chunkZ * 16, world); - break; - case -1: - generateNether(random, chunkX * 16, chunkZ * 16, world); - break; - default: - for (Integer i : ConfigHandler.oreGenDimentionBlacklist) - { - if (i == world.provider.dimensionId) return; - } - addOreSpawn(ModBlocks.draconiumOre, world, random, chunkX * 16, chunkZ * 16, 3, 4, 2, 2, 8); - break; - } + @Override + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { + switch (world.provider.dimensionId) { + case 0: + generateSurface(random, chunkX * 16, chunkZ * 16, world); + break; + case 1: + generateEnd(random, chunkX * 16, chunkZ * 16, world); + break; + case -1: + generateNether(random, chunkX * 16, chunkZ * 16, world); + break; + default: + for (Integer i : ConfigHandler.oreGenDimentionBlacklist) { + if (i == world.provider.dimensionId) return; + } + addOreSpawn(ModBlocks.draconiumOre, world, random, chunkX * 16, chunkZ * 16, 3, 4, 2, 2, 8); + break; + } - } + } - public void generateSurface(Random random, int x, int z, World world) {// minVainSise, maxVainSize, spawnChance(Def2), minY, maxY - if (!ConfigHandler.disableOreSpawnOverworld) addOreSpawn(ModBlocks.draconiumOre, world, random, x, z, 3, 4, 2, 2, 8); - } + public void generateSurface(Random random, int x, int z, World world) {// minVainSise, maxVainSize, spawnChance(Def2), minY, maxY + if (!ConfigHandler.disableOreSpawnOverworld) + addOreSpawn(ModBlocks.draconiumOre, world, random, x, z, 3, 4, 2, 2, 8); + } - public void generateEnd(Random random, int x, int z, World world) { - int x1 = x + random.nextInt(16); - int y = 20 + random.nextInt(170); - int z1 = z + random.nextInt(16); - if (cometsEnabled && ConfigHandler.generateEnderComets && Math.sqrt(x*x + z*z) > 200 && random.nextInt(Math.max(1, ConfigHandler.cometRarity)) == 0) new WorldGenEnderComet().generate(world, random, x1, y , z1); - if (chaosIslandsEnabled && ConfigHandler.generateChaosIslands) ChaosWorldGenHandler.generateChunk(world, x/16, z/16, null, random); - if (oreEnabledInEnd && !ConfigHandler.disableOreSpawnEnd) addOreSpawn(ModBlocks.draconiumOre, world, random, x, z, 4, 5, 10, 1, 70); - } + public void generateEnd(Random random, int x, int z, World world) { + int x1 = x + random.nextInt(16); + int y = 20 + random.nextInt(170); + int z1 = z + random.nextInt(16); + if (cometsEnabled && ConfigHandler.generateEnderComets && Math.sqrt(x * x + z * z) > 200 && random.nextInt(Math.max(1, ConfigHandler.cometRarity)) == 0) + new WorldGenEnderComet().generate(world, random, x1, y, z1); + if (chaosIslandsEnabled && ConfigHandler.generateChaosIslands) + ChaosWorldGenHandler.generateChunk(world, x / 16, z / 16, null, random); + if (oreEnabledInEnd && !ConfigHandler.disableOreSpawnEnd) + addOreSpawn(ModBlocks.draconiumOre, world, random, x, z, 4, 5, 10, 1, 70); + } - public void generateNether(Random random, int chunkX, int chunkZ, World world) { - if (!ConfigHandler.disableOreSpawnNether) addOreSpawn(ModBlocks.draconiumOre, world, random, chunkX, chunkZ, 3, 4, 5, 1, 125); - } - /**Generate Ore - * Block to generate - * World - * Random - * Chunk x - * Chunk z - * min vain size - * max vain size - * number of tries to spawn - * min y - * max y - * **/ - public void addOreSpawn(Block block, World world, Random random, int chunkXPos, int chunkZPos, int minVainSize, int maxVainSize, int chancesToSpawn, int minY, int maxY) { - for (int i = 0; i < chancesToSpawn; i++) { - int posX = chunkXPos + random.nextInt(16); - int posY = minY + random.nextInt(maxY - minY); - int posZ = chunkZPos + random.nextInt(16); - new WorldGenMinable(block, 0, (minVainSize + random.nextInt(maxVainSize - minVainSize)), Blocks.end_stone).generate(world, random, posX, posY, posZ); - new WorldGenMinable(block, 0, 3, Blocks.stone).generate(world, random, posX, posY, posZ); - new WorldGenMinable(block, 0, (minVainSize + random.nextInt(maxVainSize - minVainSize)), Blocks.netherrack).generate(world, random, posX, posY, posZ); - } - } + public void generateNether(Random random, int chunkX, int chunkZ, World world) { + if (!ConfigHandler.disableOreSpawnNether) + addOreSpawn(ModBlocks.draconiumOre, world, random, chunkX, chunkZ, 3, 4, 5, 1, 125); + } + /** + * Generate Ore + * Block to generate + * World + * Random + * Chunk x + * Chunk z + * min vain size + * max vain size + * number of tries to spawn + * min y + * max y + * * + */ + public void addOreSpawn(Block block, World world, Random random, int chunkXPos, int chunkZPos, int minVainSize, int maxVainSize, int chancesToSpawn, int minY, int maxY) { + for (int i = 0; i < chancesToSpawn; i++) { + int posX = chunkXPos + random.nextInt(16); + int posY = minY + random.nextInt(maxY - minY); + int posZ = chunkZPos + random.nextInt(16); + new WorldGenMinable(block, 0, (minVainSize + random.nextInt(maxVainSize - minVainSize)), Blocks.end_stone).generate(world, random, posX, posY, posZ); + new WorldGenMinable(block, 0, 3, Blocks.stone).generate(world, random, posX, posY, posZ); + new WorldGenMinable(block, 0, (minVainSize + random.nextInt(maxVainSize - minVainSize)), Blocks.netherrack).generate(world, random, posX, posY, posZ); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/world/WorldGenChaosIsland.java b/src/main/java/com/brandon3055/draconicevolution/common/world/WorldGenChaosIsland.java index b03e4b45..c34aedb2 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/world/WorldGenChaosIsland.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/world/WorldGenChaosIsland.java @@ -16,116 +16,100 @@ import java.util.Random; */ public class WorldGenChaosIsland { - private int spawnHeight = 128; - private int size; - private BlockCollection blockCollection; - public boolean initialized = false; + private int spawnHeight = 128; + private int size; + private BlockCollection blockCollection; + public boolean initialized = false; - public void initialize(Random random) { - generate(blockCollection, random); - initialized = true; - } + public void initialize(Random random) { + generate(blockCollection, random); + initialized = true; + } - public BlockCollection getBlocks(Random random){ - if (!initialized) initialize(random); - return blockCollection; - } + public BlockCollection getBlocks(Random random) { + if (!initialized) initialize(random); + return blockCollection; + } - public boolean generate(BlockCollection world, Random random) { - //LogHelper.info("Generate"); + public boolean generate(BlockCollection world, Random random) { + //LogHelper.info("Generate"); // for (int y1 = y - 10; y1 < y + 10; y1++) { // if (world.getBlock(x, y1, z) == Blocks.end_stone) { // //LogHelper.info("cancel"); // return false; // } // } - size = 400; + size = 400; - generateCentre(world, random); + generateCentre(world, random); // generateBelt(world, random, size + 50, size + 200); // generateObelisks(world, random); // EntityChaosGuardian dragon = new EntityChaosGuardian(world); // dragon.setPositionAndUpdate(x, 180, z); // world.spawnEntityInWorld(dragon); - return true; - } + return true; + } - double[] noiseData; + double[] noiseData; - private void generateCentre(BlockCollection blocks, Random rand) { - //int centreThikness = 10; //multiplied by 2 and + 1 - int curve = 2; - int diffStart = 20;//(int)((double)size * 0.1D); - //int offPoint = size * curve; + private void generateCentre(BlockCollection blocks, Random rand) { + //int centreThikness = 10; //multiplied by 2 and + 1 + int curve = 2; + int diffStart = 20;//(int)((double)size * 0.1D); + //int offPoint = size * curve; - int coreDiameter = 90; + int coreDiameter = 90; - NoiseGeneratorSimplex simX = new NoiseGeneratorSimplex(rand); - NoiseGeneratorSimplex simY = new NoiseGeneratorSimplex(rand); - NoiseGeneratorSimplex simZ = new NoiseGeneratorSimplex(rand); - NoiseGeneratorImproved generatorImproved = new NoiseGeneratorImproved(rand); - generatorImproved.populateNoiseArray(new double[size * 255 * size], 0, 0, 0, size, 255, size, 10, 10, 10, 500); - NoiseGeneratorOctaves generatorOctaves = new NoiseGeneratorOctaves(rand, 8); - - boolean f = true; - - int randOffset = rand.nextInt(10000); - - for (int x = 0; x <= size; x++) { - f = true; - for (int z = 0; z <= size; z++) { - for (int y = 0; y <= (size / 2); y++) { - - double dist = Math.sqrt(x*x + (y-spawnHeight)*(y-spawnHeight) + z*z); - - double xf, yf, zf; - xf=(double)x/size; - yf=(double)y/(size/2); - zf=(double)z/size; - - double density, center_falloff, plateau_falloff, densityZ; - - - center_falloff = 0.1;///(Math.pow((xf - 0.5) * 1.5, 2) + Math.pow((yf - 1.0) * 0.8, 2) + Math.pow((zf - 0.5) * 1.5, 2)); - - double diameterScale = 100D; - //center_falloff = 1;//(1D - (dist / diameterScale)) * 4D; - if (center_falloff < 0) center_falloff = 0; - - if(yf <= 0.8){ - plateau_falloff = 1.0; - } - else if(0.8 < yf && yf < 0.9){ - plateau_falloff = 1.0-(yf-0.8)*10.0; - } - else{ - plateau_falloff = 0.0; - } - - density = 0.1; - for (int octave = 0; octave < 4; octave++) - { - //density += Math.abs(SimplexNoise.noise(xf*Math.pow(2, octave), yf*Math.pow(2, octave), zf*Math.pow(2, octave))); - } - - density *= center_falloff * plateau_falloff; - - //if (y % 50 == 0) LogHelper.info((density) + " " + center_falloff + " " + yf); - //LogHelper.info(yf); - f = false; + NoiseGeneratorSimplex simX = new NoiseGeneratorSimplex(rand); + NoiseGeneratorSimplex simY = new NoiseGeneratorSimplex(rand); + NoiseGeneratorSimplex simZ = new NoiseGeneratorSimplex(rand); + NoiseGeneratorImproved generatorImproved = new NoiseGeneratorImproved(rand); + generatorImproved.populateNoiseArray(new double[size * 255 * size], 0, 0, 0, size, 255, size, 10, 10, 10, 500); + NoiseGeneratorOctaves generatorOctaves = new NoiseGeneratorOctaves(rand, 8); + boolean f = true; + int randOffset = rand.nextInt(10000); + for (int x = 0; x <= size; x++) { + f = true; + for (int z = 0; z <= size; z++) { + for (int y = 0; y <= (size / 2); y++) { + double dist = Math.sqrt(x * x + (y - spawnHeight) * (y - spawnHeight) + z * z); + double xf, yf, zf; + xf = (double) x / size; + yf = (double) y / (size / 2); + zf = (double) z / size; + double density, center_falloff, plateau_falloff, densityZ; + center_falloff = 0.1;///(Math.pow((xf - 0.5) * 1.5, 2) + Math.pow((yf - 1.0) * 0.8, 2) + Math.pow((zf - 0.5) * 1.5, 2)); + double diameterScale = 100D; + //center_falloff = 1;//(1D - (dist / diameterScale)) * 4D; + if (center_falloff < 0) center_falloff = 0; + if (yf <= 0.8) { + plateau_falloff = 1.0; + } else if (0.8 < yf && yf < 0.9) { + plateau_falloff = 1.0 - (yf - 0.8) * 10.0; + } else { + plateau_falloff = 0.0; + } + density = 0.1; + for (int octave = 0; octave < 4; octave++) { + //density += Math.abs(SimplexNoise.noise(xf*Math.pow(2, octave), yf*Math.pow(2, octave), zf*Math.pow(2, octave))); + } + density *= center_falloff * plateau_falloff; + //if (y % 50 == 0) LogHelper.info((density) + " " + center_falloff + " " + yf); + //LogHelper.info(yf); + f = false; // //setup fields @@ -140,59 +124,56 @@ public class WorldGenChaosIsland { // } // - } - } - } - } + } + } + } + } - public static void generate(World world, int trueX, int y, int trueZ, int offsetX, int offsetZ){ - int x = trueX - offsetX; - int z = trueZ - offsetZ; + public static void generate(World world, int trueX, int y, int trueZ, int offsetX, int offsetZ) { + int x = trueX - offsetX; + int z = trueZ - offsetZ; - int size = 300; + int size = 300; - //double dist = Math.sqrt(x*x + (y-spawnHeight)*(y-spawnHeight) + z*z); + //double dist = Math.sqrt(x*x + (y-spawnHeight)*(y-spawnHeight) + z*z); - double xf, yf, zf; - xf=(double)x/size; - yf=(double)y/(256); - zf=(double)z/size; + double xf, yf, zf; + xf = (double) x / size; + yf = (double) y / (256); + zf = (double) z / size; - double density, center_falloff, plateau_falloff, densityZ; + double density, center_falloff, plateau_falloff, densityZ; - center_falloff = 0.1;///(Math.pow((xf - 0.5) * 1.5, 2) + Math.pow((yf - 1.0) * 0.8, 2) + Math.pow((zf - 0.5) * 1.5, 2)); + center_falloff = 0.1;///(Math.pow((xf - 0.5) * 1.5, 2) + Math.pow((yf - 1.0) * 0.8, 2) + Math.pow((zf - 0.5) * 1.5, 2)); - double diameterScale = 100D; - //center_falloff = 1;//(1D - (dist / diameterScale)) * 4D; - if (center_falloff < 0) center_falloff = 0; + double diameterScale = 100D; + //center_falloff = 1;//(1D - (dist / diameterScale)) * 4D; + if (center_falloff < 0) center_falloff = 0; - if(yf <= 0.8){ - plateau_falloff = 1.0; - } - else if(0.8 < yf && yf < 0.9){ - plateau_falloff = 1.0-(yf-0.8)*10.0; - } - else{ - plateau_falloff = 0.0; - } + if (yf <= 0.8) { + plateau_falloff = 1.0; + } else if (0.8 < yf && yf < 0.9) { + plateau_falloff = 1.0 - (yf - 0.8) * 10.0; + } else { + plateau_falloff = 0.0; + } - density = 0.1; - for (int octave = 0; octave < 4; octave++) - { - density += Math.abs(SimplexNoise.noise(xf * Math.pow(2, octave), yf * Math.pow(2, octave), zf * Math.pow(2, octave))); - } + density = 0.1; + for (int octave = 0; octave < 4; octave++) { + density += Math.abs(SimplexNoise.noise(xf * Math.pow(2, octave), yf * Math.pow(2, octave), zf * Math.pow(2, octave))); + } - //density *= center_falloff * plateau_falloff; + //density *= center_falloff * plateau_falloff; - if (y % 50 == 0) LogHelper.info((density) + " " + center_falloff + " " + yf); - //LogHelper.info(yf); + if (y % 50 == 0) LogHelper.info((density) + " " + center_falloff + " " + yf); + //LogHelper.info(yf); - if (density > 1) world.setBlock(x + offsetX, y, z + offsetZ, Blocks.end_stone); + if (density > 1) world.setBlock(x + offsetX, y, z + offsetZ, Blocks.end_stone); - } + } - // if(yf <= 0.8){ + // if(yf <= 0.8){ // plateau_falloff = 1.0F; // } // else if(0.8 < yf && yf < 0.9){ @@ -208,15 +189,15 @@ public class WorldGenChaosIsland { // Math.pow((zf - 0.5F) * 1.5F, 2F) // ); // caves = (float)Math.pow(simplex_noise(1, xf * 5, yf * 5, zf * 5), 3); - //density = ( simplex_noise(5, xf, yf * 0.5F, zf));// * center_falloff * plateau_falloff); + //density = ( simplex_noise(5, xf, yf * 0.5F, zf));// * center_falloff * plateau_falloff); - //density *= Math.pow( noise((xf+1)*3.0F, (yf+1)*3.0F, (zf+1)*3.0F)+0.4, 1.8F); + //density *= Math.pow( noise((xf+1)*3.0F, (yf+1)*3.0F, (zf+1)*3.0F)+0.4, 1.8F); // if(caves<0.5){ // density = 0; // } - //put(x, y, z, density>3.1 ? ROCK : 0); - //endfor + //put(x, y, z, density>3.1 ? ROCK : 0); + //endfor // public float dot(float x, float y, float z, float... g){ // return x*g[0] + y*g[1] + z*g[2]; @@ -436,18 +417,18 @@ public class WorldGenChaosIsland { // } // } - private int getDiffusionPct(int dist, int maxDist) { - double d = (double) dist / (double) maxDist; - int i = Math.max(1, (int) (d * 1000D)); - return 1000 - i; - } + private int getDiffusionPct(int dist, int maxDist) { + double d = (double) dist / (double) maxDist; + int i = Math.max(1, (int) (d * 1000D)); + return 1000 - i; + } - private double getDiffusionPctD(int dist, int maxDist) { - double d = (double) dist / (double) maxDist; - return d; - } + private double getDiffusionPctD(int dist, int maxDist) { + double d = (double) dist / (double) maxDist; + return d; + } - private void generateObelisks(BlockCollection world, Random rand) { + private void generateObelisks(BlockCollection world, Random rand) { // for (int i = 0; i < 7; i++) { // double rotation = i * 0.9D; @@ -463,9 +444,9 @@ public class WorldGenChaosIsland { // generateObelisk(world, sX, spawnY + 10, sZ, true, rand); // } - } + } - private void generateObelisk(BlockCollection world, int x1, int y1, int z1, boolean outer, Random rand) { + private void generateObelisk(BlockCollection world, int x1, int y1, int z1, boolean outer, Random rand) { // if (!outer) { // world.setBlock(x1, y1 + 20, z1, ModBlocks.infusedObsidian, 0, 2); //// if (!world.isRemote) { @@ -526,9 +507,9 @@ public class WorldGenChaosIsland { // } // // } - } + } - private void generateBelt(BlockCollection world, Random random, int innerRadius, int outerRadius) { + private void generateBelt(BlockCollection world, Random random, int innerRadius, int outerRadius) { // int r = outerRadius; // for (int x = spawnX - r; x <= spawnX + r; x++) { // for (int z = spawnZ - r; z <= spawnZ + r; z++) { @@ -540,5 +521,5 @@ public class WorldGenChaosIsland { // } // } // } - } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/world/WorldGenEnderComet.java b/src/main/java/com/brandon3055/draconicevolution/common/world/WorldGenEnderComet.java index 4adec634..e476d98d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/world/WorldGenEnderComet.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/world/WorldGenEnderComet.java @@ -12,100 +12,100 @@ import java.util.Random; */ public class WorldGenEnderComet extends WorldGenerator { - private int spawnX; - private int spawnY; - private int spawnZ; - private int tailX; - private int tailY; - private int tailZ; - private int size; + private int spawnX; + private int spawnY; + private int spawnZ; + private int tailX; + private int tailY; + private int tailZ; + private int size; - private void initialize(Random rand, int x, int y, int z) { - spawnX = x; - spawnY = y; - spawnZ = z; - double rotation = rand.nextInt(); - double xmod = Math.sin(rotation); - double zmod = Math.cos(rotation); - int distMod = 150 + rand.nextInt(50); - tailX = x + (int) (xmod * distMod); - tailY = y + 40 + rand.nextInt(40); - tailZ = z + (int) (zmod * distMod); - size = 2 + rand.nextInt(8); - } + private void initialize(Random rand, int x, int y, int z) { + spawnX = x; + spawnY = y; + spawnZ = z; + double rotation = rand.nextInt(); + double xmod = Math.sin(rotation); + double zmod = Math.cos(rotation); + int distMod = 150 + rand.nextInt(50); + tailX = x + (int) (xmod * distMod); + tailY = y + 40 + rand.nextInt(40); + tailZ = z + (int) (zmod * distMod); + size = 2 + rand.nextInt(8); + } - @Override - public boolean generate(World world, Random random, int x, int y, int z) { - initialize(random, x, y, z); + @Override + public boolean generate(World world, Random random, int x, int y, int z) { + initialize(random, x, y, z); - generateCore(world, random, size); - generateTrail(world, random); + generateCore(world, random, size); + generateTrail(world, random); - return true; - } + return true; + } - private void generateCore(World world, Random rand, int r) { - for( int x = spawnX-r ; x <= spawnX + r; x++){ - for( int z = spawnZ-r ; z <= spawnZ + r; z++) { - for (int y = spawnY-r; y <= spawnY + r; y++) { - if ((int) (getDistance(x, y, z, spawnX, spawnY, spawnZ)) <= r) { - float genP = rand.nextFloat(); + private void generateCore(World world, Random rand, int r) { + for (int x = spawnX - r; x <= spawnX + r; x++) { + for (int z = spawnZ - r; z <= spawnZ + r; z++) { + for (int y = spawnY - r; y <= spawnY + r; y++) { + if ((int) (getDistance(x, y, z, spawnX, spawnY, spawnZ)) <= r) { + float genP = rand.nextFloat(); - if (0.1F > genP){ - world.setBlock(x, y, z, ModBlocks.draconiumOre, 0, 2); - }else if (0.4F > genP){ - world.setBlock(x, y, z, Blocks.obsidian, 0, 2); - }else { - world.setBlock(x, y, z, Blocks.end_stone, 0, 2); - } - } - } - } - } - } + if (0.1F > genP) { + world.setBlock(x, y, z, ModBlocks.draconiumOre, 0, 2); + } else if (0.4F > genP) { + world.setBlock(x, y, z, Blocks.obsidian, 0, 2); + } else { + world.setBlock(x, y, z, Blocks.end_stone, 0, 2); + } + } + } + } + } + } - private void generateTrail(World world, Random rand) { - int xDiff = tailX - spawnX; - int yDiff = tailY - spawnY; - int zDiff = tailZ - spawnZ; + private void generateTrail(World world, Random rand) { + int xDiff = tailX - spawnX; + int yDiff = tailY - spawnY; + int zDiff = tailZ - spawnZ; - for (int p = 0; p < 100; p += 2) { - int cX = spawnX + (int) (((float) p / 100F) * xDiff); - int cY = spawnY + (int) (((float) p / 100F) * yDiff); - int cZ = spawnZ + (int) (((float) p / 100F) * zDiff); - float pc = (float)p / 100F; + for (int p = 0; p < 100; p += 2) { + int cX = spawnX + (int) (((float) p / 100F) * xDiff); + int cY = spawnY + (int) (((float) p / 100F) * yDiff); + int cZ = spawnZ + (int) (((float) p / 100F) * zDiff); + float pc = (float) p / 100F; - int density = 500 - (int)(pc*550); - if (density < 20) density = 20; - generateTrailSphere(world, cX, cY, cZ, (size+3)-(int)(pc*(size-2)), density, rand); + int density = 500 - (int) (pc * 550); + if (density < 20) density = 20; + generateTrailSphere(world, cX, cY, cZ, (size + 3) - (int) (pc * (size - 2)), density, rand); - density = 1000 - (int)(pc*10000); - generateTrailSphere(world, cX, cY, cZ, (size+3)-(int)(pc*(size-2)), density, rand); + density = 1000 - (int) (pc * 10000); + generateTrailSphere(world, cX, cY, cZ, (size + 3) - (int) (pc * (size - 2)), density, rand); - } - } + } + } - public static void generateTrailSphere(World world, int xi, int yi, int zi, int r, int density, Random rand) { - if (density <= 0) return; - if (density > 10000) density = 10000; - for( int x = xi-r ; x <= xi + r; x++){ - for( int z = zi-r ; z <= zi + r; z++) { - for (int y = yi-r; y <= yi + r; y++) { - if ((density >= rand.nextInt(10000)) && world.isAirBlock(x, y, z) && (int) (getDistance(x, y, z, xi, yi, zi)) == r) { - if (0.9F >= rand.nextFloat()) world.setBlock(x, y, z, Blocks.end_stone, 0, 2); - else if (rand.nextBoolean())world.setBlock(x, y, z, Blocks.obsidian, 0, 2); - else world.setBlock(x, y, z, ModBlocks.draconiumOre, 0, 2); - } - } - } - } - } + public static void generateTrailSphere(World world, int xi, int yi, int zi, int r, int density, Random rand) { + if (density <= 0) return; + if (density > 10000) density = 10000; + for (int x = xi - r; x <= xi + r; x++) { + for (int z = zi - r; z <= zi + r; z++) { + for (int y = yi - r; y <= yi + r; y++) { + if ((density >= rand.nextInt(10000)) && world.isAirBlock(x, y, z) && (int) (getDistance(x, y, z, xi, yi, zi)) == r) { + if (0.9F >= rand.nextFloat()) world.setBlock(x, y, z, Blocks.end_stone, 0, 2); + else if (rand.nextBoolean()) world.setBlock(x, y, z, Blocks.obsidian, 0, 2); + else world.setBlock(x, y, z, ModBlocks.draconiumOre, 0, 2); + } + } + } + } + } - public static double getDistance(int x1, int y1, int z1, int x2, int y2, int z2){ - int dx = x1-x2; - int dy = y1-y2; - int dz = z1-z2; - return Math.sqrt( (dx*dx + dy*dy + dz*dz ) ); - } + public static double getDistance(int x1, int y1, int z1, int x2, int y2, int z2) { + int dx = x1 - x2; + int dy = y1 - y2; + int dz = z1 - z2; + return Math.sqrt((dx * dx + dy * dy + dz * dz)); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/world/WorldGenEnderIsland.java b/src/main/java/com/brandon3055/draconicevolution/common/world/WorldGenEnderIsland.java index fe66a299..4e44cbee 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/world/WorldGenEnderIsland.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/world/WorldGenEnderIsland.java @@ -14,219 +14,219 @@ import java.util.Random; */ public class WorldGenEnderIsland extends WorldGenerator { - private int spawnX; - private int spawnY; - private int spawnZ; - private int size; + private int spawnX; + private int spawnY; + private int spawnZ; + private int size; - private void initialize(Random rand, int x, int y, int z) { - spawnX = x; - spawnY = y; - spawnZ = z; - size = 150;// + rand.nextInt(8); - } + private void initialize(Random rand, int x, int y, int z) { + spawnX = x; + spawnY = y; + spawnZ = z; + size = 150;// + rand.nextInt(8); + } - @Override - public boolean generate(World world, Random random, int x, int y, int z) { - //LogHelper.info("Generate"); - for (int y1 = y - 10; y1 < y + 10; y1++) { - if (world.getBlock(x, y1, z) == Blocks.end_stone) { - //LogHelper.info("cancel"); - return false; - } - } - initialize(random, x, y, z); - generateCentre(world, random); - generateBelt(world, random, size + 50, size + 200); - generateObelisks(world, random); - EntityChaosGuardian dragon = new EntityChaosGuardian(world); - dragon.setPositionAndUpdate(x, 180, z); - world.spawnEntityInWorld(dragon); - return true; - } + @Override + public boolean generate(World world, Random random, int x, int y, int z) { + //LogHelper.info("Generate"); + for (int y1 = y - 10; y1 < y + 10; y1++) { + if (world.getBlock(x, y1, z) == Blocks.end_stone) { + //LogHelper.info("cancel"); + return false; + } + } + initialize(random, x, y, z); + generateCentre(world, random); + generateBelt(world, random, size + 50, size + 200); + generateObelisks(world, random); + EntityChaosGuardian dragon = new EntityChaosGuardian(world); + dragon.setPositionAndUpdate(x, 180, z); + world.spawnEntityInWorld(dragon); + return true; + } - private void generateCentre(World world, Random rand) { - int centreThikness = 10; //multiplied by 2 and + 1 - int curve = 2; - int diffStart = 20;//(int)((double)size * 0.1D); - int r = size; - int offPoint = size * curve; + private void generateCentre(World world, Random rand) { + int centreThikness = 10; //multiplied by 2 and + 1 + int curve = 2; + int diffStart = 20;//(int)((double)size * 0.1D); + int r = size; + int offPoint = size * curve; - for (int x = spawnX - r; x <= spawnX + r; x++) { - for (int z = spawnZ - r; z <= spawnZ + r; z++) { - for (int y = spawnY - (r / 2); y <= spawnY + (r / 2); y++) { - if ((int) (getDistance(x, y, z, spawnX, spawnY + offPoint + centreThikness, spawnZ)) >= offPoint && (int) (getDistance(x, y, z, spawnX, spawnY - offPoint - centreThikness, spawnZ)) >= offPoint && (int) (getDistance(x, y, z, spawnX, spawnY, spawnZ)) <= r) { - int dist = (int) getDistance(x, y, z, spawnX, spawnY, spawnZ); - int diffusionPCt = getDiffusionPct(dist - diffStart, size - diffStart); - int yRand = (int) (Math.max(0, getDiffusionPctD(dist - 40, size - 40)) * (double) (40 - rand.nextInt(80))); - if (dist <= diffStart) { - if (world.isAirBlock(x, y + yRand, z)) - world.setBlock(x, y + yRand, z, Blocks.end_stone, 0, 2); - } else if (dist < (int) ((double) size * 0.3D) && diffusionPCt > rand.nextInt(3000)) { - if (0.95F > rand.nextFloat()) { - if (world.isAirBlock(x, y + yRand, z)) - world.setBlock(x, y + yRand, z, Blocks.end_stone, 0, 2); - } else if (world.isAirBlock(x, y + yRand, z)) - world.setBlock(x, y + yRand, z, Blocks.obsidian, 0, 2); - } else if (dist < (int) ((double) size * 0.4D) && diffusionPCt > rand.nextInt(4000)) { - if (0.95F > rand.nextFloat()) { - if (world.isAirBlock(x, y + yRand, z)) - world.setBlock(x, y + yRand, z, Blocks.end_stone, 0, 2); - } else if (world.isAirBlock(x, y + yRand, z)) - world.setBlock(x, y + yRand, z, Blocks.obsidian, 0, 2); - } else if (dist < (int) ((double) size * 0.5D) && diffusionPCt > rand.nextInt(5000)) { - if (0.95F > rand.nextFloat()) { - if (world.isAirBlock(x, y + yRand, z)) - world.setBlock(x, y + yRand, z, Blocks.end_stone, 0, 2); - } else if (world.isAirBlock(x, y + yRand, z)) - world.setBlock(x, y + yRand, z, Blocks.obsidian, 0, 2); - } else if (dist < (int) ((double) size * 0.6D) && diffusionPCt > rand.nextInt(6000)) { - if (0.95F > rand.nextFloat()) { - if (world.isAirBlock(x, y + yRand, z)) - world.setBlock(x, y + yRand, z, Blocks.end_stone, 0, 2); - } else if (world.isAirBlock(x, y + yRand, z)) - world.setBlock(x, y + yRand, z, Blocks.obsidian, 0, 2); - } else if (dist < (int) ((double) size * 0.7D) && diffusionPCt > rand.nextInt(7000)) { - if (0.95F > rand.nextFloat()) { - if (world.isAirBlock(x, y + yRand, z)) - world.setBlock(x, y + yRand, z, Blocks.end_stone, 0, 2); - } else if (world.isAirBlock(x, y + yRand, z)) - world.setBlock(x, y + yRand, z, Blocks.obsidian, 0, 2); - } else if (dist < (int) ((double) size * 0.8D) && diffusionPCt > rand.nextInt(8000)) { - if (0.95F > rand.nextFloat()) { - if (world.isAirBlock(x, y + yRand, z)) - world.setBlock(x, y + yRand, z, Blocks.end_stone, 0, 2); - } else if (world.isAirBlock(x, y + yRand, z)) - world.setBlock(x, y + yRand, z, Blocks.obsidian, 0, 2); - } else if (diffusionPCt > rand.nextInt(9000)) { - if (0.95F > rand.nextFloat()) { - if (world.isAirBlock(x, y + yRand, z)) - world.setBlock(x, y + yRand, z, Blocks.end_stone, 0, 2); - } else if (world.isAirBlock(x, y + yRand, z)) - world.setBlock(x, y + yRand, z, Blocks.obsidian, 0, 2); - } - } - } - } - } - } + for (int x = spawnX - r; x <= spawnX + r; x++) { + for (int z = spawnZ - r; z <= spawnZ + r; z++) { + for (int y = spawnY - (r / 2); y <= spawnY + (r / 2); y++) { + if ((int) (getDistance(x, y, z, spawnX, spawnY + offPoint + centreThikness, spawnZ)) >= offPoint && (int) (getDistance(x, y, z, spawnX, spawnY - offPoint - centreThikness, spawnZ)) >= offPoint && (int) (getDistance(x, y, z, spawnX, spawnY, spawnZ)) <= r) { + int dist = (int) getDistance(x, y, z, spawnX, spawnY, spawnZ); + int diffusionPCt = getDiffusionPct(dist - diffStart, size - diffStart); + int yRand = (int) (Math.max(0, getDiffusionPctD(dist - 40, size - 40)) * (double) (40 - rand.nextInt(80))); + if (dist <= diffStart) { + if (world.isAirBlock(x, y + yRand, z)) + world.setBlock(x, y + yRand, z, Blocks.end_stone, 0, 2); + } else if (dist < (int) ((double) size * 0.3D) && diffusionPCt > rand.nextInt(3000)) { + if (0.95F > rand.nextFloat()) { + if (world.isAirBlock(x, y + yRand, z)) + world.setBlock(x, y + yRand, z, Blocks.end_stone, 0, 2); + } else if (world.isAirBlock(x, y + yRand, z)) + world.setBlock(x, y + yRand, z, Blocks.obsidian, 0, 2); + } else if (dist < (int) ((double) size * 0.4D) && diffusionPCt > rand.nextInt(4000)) { + if (0.95F > rand.nextFloat()) { + if (world.isAirBlock(x, y + yRand, z)) + world.setBlock(x, y + yRand, z, Blocks.end_stone, 0, 2); + } else if (world.isAirBlock(x, y + yRand, z)) + world.setBlock(x, y + yRand, z, Blocks.obsidian, 0, 2); + } else if (dist < (int) ((double) size * 0.5D) && diffusionPCt > rand.nextInt(5000)) { + if (0.95F > rand.nextFloat()) { + if (world.isAirBlock(x, y + yRand, z)) + world.setBlock(x, y + yRand, z, Blocks.end_stone, 0, 2); + } else if (world.isAirBlock(x, y + yRand, z)) + world.setBlock(x, y + yRand, z, Blocks.obsidian, 0, 2); + } else if (dist < (int) ((double) size * 0.6D) && diffusionPCt > rand.nextInt(6000)) { + if (0.95F > rand.nextFloat()) { + if (world.isAirBlock(x, y + yRand, z)) + world.setBlock(x, y + yRand, z, Blocks.end_stone, 0, 2); + } else if (world.isAirBlock(x, y + yRand, z)) + world.setBlock(x, y + yRand, z, Blocks.obsidian, 0, 2); + } else if (dist < (int) ((double) size * 0.7D) && diffusionPCt > rand.nextInt(7000)) { + if (0.95F > rand.nextFloat()) { + if (world.isAirBlock(x, y + yRand, z)) + world.setBlock(x, y + yRand, z, Blocks.end_stone, 0, 2); + } else if (world.isAirBlock(x, y + yRand, z)) + world.setBlock(x, y + yRand, z, Blocks.obsidian, 0, 2); + } else if (dist < (int) ((double) size * 0.8D) && diffusionPCt > rand.nextInt(8000)) { + if (0.95F > rand.nextFloat()) { + if (world.isAirBlock(x, y + yRand, z)) + world.setBlock(x, y + yRand, z, Blocks.end_stone, 0, 2); + } else if (world.isAirBlock(x, y + yRand, z)) + world.setBlock(x, y + yRand, z, Blocks.obsidian, 0, 2); + } else if (diffusionPCt > rand.nextInt(9000)) { + if (0.95F > rand.nextFloat()) { + if (world.isAirBlock(x, y + yRand, z)) + world.setBlock(x, y + yRand, z, Blocks.end_stone, 0, 2); + } else if (world.isAirBlock(x, y + yRand, z)) + world.setBlock(x, y + yRand, z, Blocks.obsidian, 0, 2); + } + } + } + } + } + } - private int getDiffusionPct(int dist, int maxDist) { - double d = (double) dist / (double) maxDist; - int i = Math.max(1, (int) (d * 1000D)); - return 1000 - i; - } + private int getDiffusionPct(int dist, int maxDist) { + double d = (double) dist / (double) maxDist; + int i = Math.max(1, (int) (d * 1000D)); + return 1000 - i; + } - private double getDiffusionPctD(int dist, int maxDist) { - double d = (double) dist / (double) maxDist; - return d; - } + private double getDiffusionPctD(int dist, int maxDist) { + double d = (double) dist / (double) maxDist; + return d; + } - private void generateObelisks(World world, Random rand) { + private void generateObelisks(World world, Random rand) { - for (int i = 0; i < 7; i++) { - double rotation = i * 0.9D; - int sX = spawnX + (int) (Math.sin(rotation) * 35D); - int sZ = spawnZ + (int) (Math.cos(rotation) * 35D); - generateObelisk(world, sX, spawnY + 10, sZ, false, rand); - } + for (int i = 0; i < 7; i++) { + double rotation = i * 0.9D; + int sX = spawnX + (int) (Math.sin(rotation) * 35D); + int sZ = spawnZ + (int) (Math.cos(rotation) * 35D); + generateObelisk(world, sX, spawnY + 10, sZ, false, rand); + } - for (int i = 0; i < 14; i++) { - double rotation = i * 0.45D; - int sX = spawnX + (int) (Math.sin(rotation) * 70D); - int sZ = spawnZ + (int) (Math.cos(rotation) * 70D); - generateObelisk(world, sX, spawnY + 10, sZ, true, rand); - } + for (int i = 0; i < 14; i++) { + double rotation = i * 0.45D; + int sX = spawnX + (int) (Math.sin(rotation) * 70D); + int sZ = spawnZ + (int) (Math.cos(rotation) * 70D); + generateObelisk(world, sX, spawnY + 10, sZ, true, rand); + } - } + } - private void generateObelisk(World world, int x1, int y1, int z1, boolean outer, Random rand) { - if (!outer) { - world.setBlock(x1, y1 + 20, z1, ModBlocks.infusedObsidian, 0, 2); - if (!world.isRemote) { - EntityChaosCrystal crystal = new EntityChaosCrystal(world); - crystal.setPosition(x1 + 0.5, y1 + 21, z1 + 0.5); - world.spawnEntityInWorld(crystal); - } - for (int y = y1; y < y1 + 20; y++) { - world.setBlock(x1, y, z1, Blocks.obsidian, 0, 2); - world.setBlock(x1 + 1, y, z1, Blocks.obsidian, 0, 2); - world.setBlock(x1 - 1, y, z1, Blocks.obsidian, 0, 2); - world.setBlock(x1, y, z1 + 1, Blocks.obsidian, 0, 2); - world.setBlock(x1, y, z1 - 1, Blocks.obsidian, 0, 2); - world.setBlock(x1 + 1, y, z1 + 1, Blocks.obsidian, 0, 2); - world.setBlock(x1 - 1, y, z1 - 1, Blocks.obsidian, 0, 2); - world.setBlock(x1 + 1, y, z1 - 1, Blocks.obsidian, 0, 2); - world.setBlock(x1 - 1, y, z1 + 1, Blocks.obsidian, 0, 2); - } - } else { - world.setBlock(x1, y1 + 40, z1, ModBlocks.infusedObsidian, 0, 2); - if (!world.isRemote) { - EntityChaosCrystal crystal = new EntityChaosCrystal(world); - crystal.setPosition(x1 + 0.5, y1 + 41, z1 + 0.5); - world.spawnEntityInWorld(crystal); - } - int diff = 0; - for (int y = y1 + 20; y < y1 + 40; y++) { - diff++; - double pct = (double) diff / 25D; - int r = 3; - for (int x = x1 - r; x <= x1 + r; x++) { - for (int z = z1 - r; z <= z1 + r; z++) { - if (getDistance(x, z, x1, z1) <= r) { - if (pct > rand.nextDouble()) world.setBlock(x, y, z, Blocks.obsidian, 0, 2); - } - } - } - } + private void generateObelisk(World world, int x1, int y1, int z1, boolean outer, Random rand) { + if (!outer) { + world.setBlock(x1, y1 + 20, z1, ModBlocks.infusedObsidian, 0, 2); + if (!world.isRemote) { + EntityChaosCrystal crystal = new EntityChaosCrystal(world); + crystal.setPosition(x1 + 0.5, y1 + 21, z1 + 0.5); + world.spawnEntityInWorld(crystal); + } + for (int y = y1; y < y1 + 20; y++) { + world.setBlock(x1, y, z1, Blocks.obsidian, 0, 2); + world.setBlock(x1 + 1, y, z1, Blocks.obsidian, 0, 2); + world.setBlock(x1 - 1, y, z1, Blocks.obsidian, 0, 2); + world.setBlock(x1, y, z1 + 1, Blocks.obsidian, 0, 2); + world.setBlock(x1, y, z1 - 1, Blocks.obsidian, 0, 2); + world.setBlock(x1 + 1, y, z1 + 1, Blocks.obsidian, 0, 2); + world.setBlock(x1 - 1, y, z1 - 1, Blocks.obsidian, 0, 2); + world.setBlock(x1 + 1, y, z1 - 1, Blocks.obsidian, 0, 2); + world.setBlock(x1 - 1, y, z1 + 1, Blocks.obsidian, 0, 2); + } + } else { + world.setBlock(x1, y1 + 40, z1, ModBlocks.infusedObsidian, 0, 2); + if (!world.isRemote) { + EntityChaosCrystal crystal = new EntityChaosCrystal(world); + crystal.setPosition(x1 + 0.5, y1 + 41, z1 + 0.5); + world.spawnEntityInWorld(crystal); + } + int diff = 0; + for (int y = y1 + 20; y < y1 + 40; y++) { + diff++; + double pct = (double) diff / 25D; + int r = 3; + for (int x = x1 - r; x <= x1 + r; x++) { + for (int z = z1 - r; z <= z1 + r; z++) { + if (getDistance(x, z, x1, z1) <= r) { + if (pct > rand.nextDouble()) world.setBlock(x, y, z, Blocks.obsidian, 0, 2); + } + } + } + } - int cageS = 2; - for (int x = x1 - cageS; x <= x1 + cageS; x++) { - for (int y = y1 - cageS; y <= y1 + cageS; y++) { - if (0.8F > rand.nextFloat()) world.setBlock(x, y + 41, z1 + cageS, Blocks.iron_bars, 0, 2); - if (0.8F > rand.nextFloat()) world.setBlock(x, y + 41, z1 - cageS, Blocks.iron_bars, 0, 2); - } - } - for (int z = z1 - cageS; z <= z1 + cageS; z++) { - for (int y = y1 - cageS; y <= y1 + cageS; y++) { - if (0.8F > rand.nextFloat()) world.setBlock(x1 + cageS, y + 41, z, Blocks.iron_bars, 0, 2); - if (0.8F > rand.nextFloat()) world.setBlock(x1 - cageS, y + 41, z, Blocks.iron_bars, 0, 2); - } - } - for (int z = z1 - cageS; z <= z1 + cageS; z++) { - for (int x = x1 - cageS; x <= x1 + cageS; x++) { - if (0.8F > rand.nextFloat()) world.setBlock(x, y1 + 44, z, Blocks.stone_slab, 6, 2); - } - } + int cageS = 2; + for (int x = x1 - cageS; x <= x1 + cageS; x++) { + for (int y = y1 - cageS; y <= y1 + cageS; y++) { + if (0.8F > rand.nextFloat()) world.setBlock(x, y + 41, z1 + cageS, Blocks.iron_bars, 0, 2); + if (0.8F > rand.nextFloat()) world.setBlock(x, y + 41, z1 - cageS, Blocks.iron_bars, 0, 2); + } + } + for (int z = z1 - cageS; z <= z1 + cageS; z++) { + for (int y = y1 - cageS; y <= y1 + cageS; y++) { + if (0.8F > rand.nextFloat()) world.setBlock(x1 + cageS, y + 41, z, Blocks.iron_bars, 0, 2); + if (0.8F > rand.nextFloat()) world.setBlock(x1 - cageS, y + 41, z, Blocks.iron_bars, 0, 2); + } + } + for (int z = z1 - cageS; z <= z1 + cageS; z++) { + for (int x = x1 - cageS; x <= x1 + cageS; x++) { + if (0.8F > rand.nextFloat()) world.setBlock(x, y1 + 44, z, Blocks.stone_slab, 6, 2); + } + } - } - } + } + } - private void generateBelt(World world, Random random, int innerRadius, int outerRadius) { - int r = outerRadius; - for (int x = spawnX - r; x <= spawnX + r; x++) { - for (int z = spawnZ - r; z <= spawnZ + r; z++) { - int dist = (int) (getDistance(x, z, spawnX, spawnZ)); - if (dist < outerRadius && dist >= innerRadius) { - int y = spawnY + (int) ((double) (spawnX - x) * 0.2D) + (random.nextInt(10) - 5); - if (0.1F > random.nextFloat()) world.setBlock(x, y, z, Blocks.end_stone, 0, 2); - if (0.001F > random.nextFloat()) world.setBlock(x, y, z, ModBlocks.draconiumOre, 0, 2); - } - } - } - } + private void generateBelt(World world, Random random, int innerRadius, int outerRadius) { + int r = outerRadius; + for (int x = spawnX - r; x <= spawnX + r; x++) { + for (int z = spawnZ - r; z <= spawnZ + r; z++) { + int dist = (int) (getDistance(x, z, spawnX, spawnZ)); + if (dist < outerRadius && dist >= innerRadius) { + int y = spawnY + (int) ((double) (spawnX - x) * 0.2D) + (random.nextInt(10) - 5); + if (0.1F > random.nextFloat()) world.setBlock(x, y, z, Blocks.end_stone, 0, 2); + if (0.001F > random.nextFloat()) world.setBlock(x, y, z, ModBlocks.draconiumOre, 0, 2); + } + } + } + } - public static double getDistance(int x1, int y1, int z1, int x2, int y2, int z2) { - int dx = x1 - x2; - int dy = y1 - y2; - int dz = z1 - z2; - return Math.sqrt((dx * dx + dy * dy + dz * dz)); - } + public static double getDistance(int x1, int y1, int z1, int x2, int y2, int z2) { + int dx = x1 - x2; + int dy = y1 - y2; + int dz = z1 - z2; + return Math.sqrt((dx * dx + dy * dy + dz * dz)); + } - public static double getDistance(int x1, int z1, int x2, int z2) { - int dx = x1 - x2; - int dz = z1 - z2; - return Math.sqrt((dx * dx + dz * dz)); - } + public static double getDistance(int x1, int z1, int x2, int z2) { + int dx = x1 - x2; + int dz = z1 - z2; + return Math.sqrt((dx * dx + dz * dz)); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/integration/ModHelper.java b/src/main/java/com/brandon3055/draconicevolution/integration/ModHelper.java index 0edec404..cec40ef5 100644 --- a/src/main/java/com/brandon3055/draconicevolution/integration/ModHelper.java +++ b/src/main/java/com/brandon3055/draconicevolution/integration/ModHelper.java @@ -19,58 +19,56 @@ public class ModHelper { private static Item avaritiaSword; private static Item bedrockSword; - public static void init(){ - isTConInstalled = Loader.isModLoaded("TConstruct"); + public static void init() { + isTConInstalled = Loader.isModLoaded("TConstruct"); isAvaritiaInstalled = Loader.isModLoaded("Avaritia"); isRotaryCraftInstalled = Loader.isModLoaded("RotaryCraft"); - } + } - public static boolean isHoldingCleaver(EntityPlayer player){ - if (!isTConInstalled) return false; - else if (cleaver == null) cleaver = GameRegistry.findItem("TConstruct", "cleaver"); + public static boolean isHoldingCleaver(EntityPlayer player) { + if (!isTConInstalled) return false; + else if (cleaver == null) cleaver = GameRegistry.findItem("TConstruct", "cleaver"); - return cleaver != null && player.getHeldItem() != null && player.getHeldItem().getItem().equals(cleaver); - } + return cleaver != null && player.getHeldItem() != null && player.getHeldItem().getItem().equals(cleaver); + } - public static boolean isHoldingAvaritiaSword(EntityPlayer player){ + public static boolean isHoldingAvaritiaSword(EntityPlayer player) { if (!isAvaritiaInstalled) return false; else if (avaritiaSword == null) avaritiaSword = GameRegistry.findItem("Avaritia", "Infinity_Sword"); return avaritiaSword != null && player.getHeldItem() != null && player.getHeldItem().getItem().equals(avaritiaSword); } - public static boolean isHoldingBedrockSword(EntityPlayer player){ + public static boolean isHoldingBedrockSword(EntityPlayer player) { if (!isRotaryCraftInstalled) return false; else if (bedrockSword == null) bedrockSword = GameRegistry.findItem("RotaryCraft", "rotarycraft_item_bedsword"); return bedrockSword != null && player.getHeldItem() != null && player.getHeldItem().getItem().equals(bedrockSword); } - public static float applyModDamageAdjustments(ArmorSummery summery, LivingAttackEvent event){ + public static float applyModDamageAdjustments(ArmorSummery summery, LivingAttackEvent event) { if (summery == null) return event.ammount; EntityPlayer attacker = event.source.getEntity() instanceof EntityPlayer ? (EntityPlayer) event.source.getEntity() : null; - if (attacker == null){ + if (attacker == null) { return event.ammount; } - if (isHoldingAvaritiaSword(attacker)){ + if (isHoldingAvaritiaSword(attacker)) { event.entityLiving.hurtResistantTime = 0; return 300F; - } - else if (isHoldingBedrockSword(attacker)){ + } else if (isHoldingBedrockSword(attacker)) { summery.entropy += 10; - if (summery.entropy > 100){ + if (summery.entropy > 100) { summery.entropy = 100; } return Math.max(event.ammount, Math.min(50F, summery.protectionPoints)); - } - else if (event.source.isUnblockable() || event.source.canHarmInCreative()){ + } else if (event.source.isUnblockable() || event.source.canHarmInCreative()) { summery.entropy += 3; - if (summery.entropy > 100){ + if (summery.entropy > 100) { summery.entropy = 100; } diff --git a/src/main/java/com/brandon3055/draconicevolution/integration/computers/CCOCIntegration.java b/src/main/java/com/brandon3055/draconicevolution/integration/computers/CCOCIntegration.java index 4c1a78cc..06d7fc8b 100644 --- a/src/main/java/com/brandon3055/draconicevolution/integration/computers/CCOCIntegration.java +++ b/src/main/java/com/brandon3055/draconicevolution/integration/computers/CCOCIntegration.java @@ -18,44 +18,43 @@ import net.minecraft.world.World; */ public class CCOCIntegration { - public static void init() { - if (Loader.isModLoaded("ComputerCraft")) initCC(); - if (Loader.isModLoaded("OpenComputers")) initOC(); - } + public static void init() { + if (Loader.isModLoaded("ComputerCraft")) initCC(); + if (Loader.isModLoaded("OpenComputers")) initOC(); + } - @Optional.Method(modid = "ComputerCraft") - public static void initCC() { - ComputerCraftAPI.registerPeripheralProvider(new DEPeripheralProvider()); - } + @Optional.Method(modid = "ComputerCraft") + public static void initCC() { + ComputerCraftAPI.registerPeripheralProvider(new DEPeripheralProvider()); + } - @Optional.Method(modid = "OpenComputers") - public static void initOC() { - Driver.add(new OCAdapter()); - } + @Optional.Method(modid = "OpenComputers") + public static void initOC() { + Driver.add(new OCAdapter()); + } - public static class OCAdapter extends DriverTileEntity { + public static class OCAdapter extends DriverTileEntity { - @Override - public Class getTileEntityClass() { - return IDEPeripheral.class; - } + @Override + public Class getTileEntityClass() { + return IDEPeripheral.class; + } - @Override - public ManagedEnvironment createEnvironment(World world, int x, int y, int z) { - return new DEManagedPeripheral((IDEPeripheral)world.getTileEntity(x, y, z)); - } - } + @Override + public ManagedEnvironment createEnvironment(World world, int x, int y, int z) { + return new DEManagedPeripheral((IDEPeripheral) world.getTileEntity(x, y, z)); + } + } - public static class DEPeripheralProvider implements IPeripheralProvider { + public static class DEPeripheralProvider implements IPeripheralProvider { - @Override - public IPeripheral getPeripheral(World world, int x, int y, int z, int i3) { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof IDEPeripheral) { - return new CCAdapter((IDEPeripheral)tile); - } - else return null; - } - } + @Override + public IPeripheral getPeripheral(World world, int x, int y, int z, int i3) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof IDEPeripheral) { + return new CCAdapter((IDEPeripheral) tile); + } else return null; + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/integration/computers/IDEPeripheral.java b/src/main/java/com/brandon3055/draconicevolution/integration/computers/IDEPeripheral.java index bc2bf8ba..8f690505 100644 --- a/src/main/java/com/brandon3055/draconicevolution/integration/computers/IDEPeripheral.java +++ b/src/main/java/com/brandon3055/draconicevolution/integration/computers/IDEPeripheral.java @@ -5,12 +5,18 @@ package com.brandon3055.draconicevolution.integration.computers; */ public interface IDEPeripheral { - /**Get the unique name for this peripheral type */ - public String getName(); + /** + * Get the unique name for this peripheral type + */ + public String getName(); - /**Get a list of methods for this peripheral*/ - public String[] getMethodNames(); + /** + * Get a list of methods for this peripheral + */ + public String[] getMethodNames(); - /**Call a method*/ - public Object[] callMethod(String method, Object... args); + /** + * Call a method + */ + public Object[] callMethod(String method, Object... args); } diff --git a/src/main/java/com/brandon3055/draconicevolution/integration/computers/cc/CCAdapter.java b/src/main/java/com/brandon3055/draconicevolution/integration/computers/cc/CCAdapter.java index f9f51590..920c6156 100644 --- a/src/main/java/com/brandon3055/draconicevolution/integration/computers/cc/CCAdapter.java +++ b/src/main/java/com/brandon3055/draconicevolution/integration/computers/cc/CCAdapter.java @@ -10,42 +10,42 @@ import dan200.computercraft.api.peripheral.IPeripheral; * Created by brandon3055 on 21/9/2015. */ public class CCAdapter implements IPeripheral { - private IDEPeripheral peripheral; + private IDEPeripheral peripheral; - public CCAdapter(IDEPeripheral peripheral){ - this.peripheral = peripheral; - } + public CCAdapter(IDEPeripheral peripheral) { + this.peripheral = peripheral; + } - @Override - public String getType() { - return peripheral.getName(); - } + @Override + public String getType() { + return peripheral.getName(); + } - @Override - public String[] getMethodNames() { - return peripheral.getMethodNames(); - } + @Override + public String[] getMethodNames() { + return peripheral.getMethodNames(); + } - @Override - public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException { - try - { - return peripheral.callMethod(peripheral.getMethodNames()[method], arguments); - } - catch (Exception e) - { - throw new LuaException(e.getMessage()); - } - } + @Override + public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException { + try { + return peripheral.callMethod(peripheral.getMethodNames()[method], arguments); + } + catch (Exception e) { + throw new LuaException(e.getMessage()); + } + } - @Override - public void attach(IComputerAccess iComputerAccess) {} + @Override + public void attach(IComputerAccess iComputerAccess) { + } - @Override - public void detach(IComputerAccess iComputerAccess) {} + @Override + public void detach(IComputerAccess iComputerAccess) { + } - @Override - public boolean equals(IPeripheral iPeripheral) { - return false; - } + @Override + public boolean equals(IPeripheral iPeripheral) { + return false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/integration/computers/oc/DEManagedPeripheral.java b/src/main/java/com/brandon3055/draconicevolution/integration/computers/oc/DEManagedPeripheral.java index 1fdf440b..57ff0302 100644 --- a/src/main/java/com/brandon3055/draconicevolution/integration/computers/oc/DEManagedPeripheral.java +++ b/src/main/java/com/brandon3055/draconicevolution/integration/computers/oc/DEManagedPeripheral.java @@ -11,29 +11,29 @@ import li.cil.oc.api.prefab.ManagedEnvironment; * Created by brandon3055 on 22/9/2015. */ public class DEManagedPeripheral extends ManagedEnvironment implements ManagedPeripheral, NamedBlock { - private IDEPeripheral peripheral; + private IDEPeripheral peripheral; - public DEManagedPeripheral(IDEPeripheral peripheral){ - this.peripheral = peripheral; - } + public DEManagedPeripheral(IDEPeripheral peripheral) { + this.peripheral = peripheral; + } - @Override - public String[] methods() { - return peripheral.getMethodNames(); - } + @Override + public String[] methods() { + return peripheral.getMethodNames(); + } - @Override - public Object[] invoke(String method, Context context, Arguments args) throws Exception { - return peripheral.callMethod(method, args.toArray()); - } + @Override + public Object[] invoke(String method, Context context, Arguments args) throws Exception { + return peripheral.callMethod(method, args.toArray()); + } - @Override - public String preferredName() { - return peripheral.getName(); - } + @Override + public String preferredName() { + return peripheral.getName(); + } - @Override - public int priority() { - return 10; - } + @Override + public int priority() { + return 10; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/integration/nei/CraftingChestOverlayHandler.java b/src/main/java/com/brandon3055/draconicevolution/integration/nei/CraftingChestOverlayHandler.java index 9159b344..05b93d3a 100644 --- a/src/main/java/com/brandon3055/draconicevolution/integration/nei/CraftingChestOverlayHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/integration/nei/CraftingChestOverlayHandler.java @@ -17,294 +17,261 @@ import java.util.*; /** * Created by Brandon on 30/10/2014. */ -public class CraftingChestOverlayHandler implements IOverlayHandler -{ - public static class DistributedIngred - { - public DistributedIngred(ItemStack item) - { - stack = InventoryUtils.copyStack(item, 1); - } +public class CraftingChestOverlayHandler implements IOverlayHandler { + public static class DistributedIngred { + public DistributedIngred(ItemStack item) { + stack = InventoryUtils.copyStack(item, 1); + } - public ItemStack stack; - public int invAmount; - public int distributed; - public int numSlots; - public int recipeAmount; - } + public ItemStack stack; + public int invAmount; + public int distributed; + public int numSlots; + public int recipeAmount; + } - public static class IngredientDistribution - { - public IngredientDistribution(DistributedIngred distrib, ItemStack permutation) - { - this.distrib = distrib; - this.permutation = permutation; - } + public static class IngredientDistribution { + public IngredientDistribution(DistributedIngred distrib, ItemStack permutation) { + this.distrib = distrib; + this.permutation = permutation; + } - public DistributedIngred distrib; - public ItemStack permutation; - public Slot[] slots; - } + public DistributedIngred distrib; + public ItemStack permutation; + public Slot[] slots; + } - @Override - public void overlayRecipe(GuiContainer gui, IRecipeHandler recipe, int recipeIndex, boolean shift) - { - List ingredients = recipe.getIngredientStacks(recipeIndex); - List ingredStacks = getPermutationIngredients(ingredients); + @Override + public void overlayRecipe(GuiContainer gui, IRecipeHandler recipe, int recipeIndex, boolean shift) { + List ingredients = recipe.getIngredientStacks(recipeIndex); + List ingredStacks = getPermutationIngredients(ingredients); - if(!clearIngredients(gui, ingredients)) return; + if (!clearIngredients(gui, ingredients)) return; - findInventoryQuantities(gui, ingredStacks); + findInventoryQuantities(gui, ingredStacks); - List assignedIngredients = assignIngredients(ingredients, ingredStacks); - if(assignedIngredients == null) { - return; - } + List assignedIngredients = assignIngredients(ingredients, ingredStacks); + if (assignedIngredients == null) { + return; + } - assignIngredSlots(gui, ingredients, assignedIngredients); - int quantity = calculateRecipeQuantity(assignedIngredients); + assignIngredSlots(gui, ingredients, assignedIngredients); + int quantity = calculateRecipeQuantity(assignedIngredients); - if(quantity != 0) - moveIngredients(gui, assignedIngredients, quantity); - } + if (quantity != 0) moveIngredients(gui, assignedIngredients, quantity); + } - @SuppressWarnings("unchecked") - private boolean clearIngredients(GuiContainer gui, List ingreds) { - int offsetx = getOffsetX(gui); - int offsety = getOffsetY(gui); - for(PositionedStack pstack : ingreds) - for(Slot slot : (List)gui.inventorySlots.inventorySlots) - if(slot.xDisplayPosition == pstack.relx+offsetx && slot.yDisplayPosition == pstack.rely+offsety) { - if(!slot.getHasStack()) continue; + @SuppressWarnings("unchecked") + private boolean clearIngredients(GuiContainer gui, List ingreds) { + int offsetx = getOffsetX(gui); + int offsety = getOffsetY(gui); + for (PositionedStack pstack : ingreds) + for (Slot slot : (List) gui.inventorySlots.inventorySlots) + if (slot.xDisplayPosition == pstack.relx + offsetx && slot.yDisplayPosition == pstack.rely + offsety) { + if (!slot.getHasStack()) continue; - FastTransferManager.clickSlot(gui, slot.slotNumber, 0, 1); - if(slot.getHasStack()) return false; - } + FastTransferManager.clickSlot(gui, slot.slotNumber, 0, 1); + if (slot.getHasStack()) return false; + } - return true; - } + return true; + } - @SuppressWarnings("unchecked") - private void moveIngredients(GuiContainer gui, List assignedIngredients, int quantity){ - for(IngredientDistribution distrib : assignedIngredients) - { - ItemStack pstack = distrib.permutation; - int transferCap = quantity*pstack.stackSize; - int transferred = 0; + @SuppressWarnings("unchecked") + private void moveIngredients(GuiContainer gui, List assignedIngredients, int quantity) { + for (IngredientDistribution distrib : assignedIngredients) { + ItemStack pstack = distrib.permutation; + int transferCap = quantity * pstack.stackSize; + int transferred = 0; - int destSlotIndex = 0; - Slot dest = distrib.slots[0]; - int slotTransferred = 0; - int slotTransferCap = pstack.getMaxStackSize(); + int destSlotIndex = 0; + Slot dest = distrib.slots[0]; + int slotTransferred = 0; + int slotTransferCap = pstack.getMaxStackSize(); - for(Slot slot : (List)gui.inventorySlots.inventorySlots) - { - if(!slot.getHasStack() || !canMoveFrom(slot, gui)) - continue; + for (Slot slot : (List) gui.inventorySlots.inventorySlots) { + if (!slot.getHasStack() || !canMoveFrom(slot, gui)) continue; - ItemStack stack = slot.getStack(); - if(!InventoryUtils.canStack(stack, pstack)) - continue; + ItemStack stack = slot.getStack(); + if (!InventoryUtils.canStack(stack, pstack)) continue; - FastTransferManager.clickSlot(gui, slot.slotNumber); - int amount = Math.min(transferCap-transferred, stack.stackSize); - for(int c = 0; c < amount; c++) - { - FastTransferManager.clickSlot(gui, dest.slotNumber, 1); - transferred++; - slotTransferred++; - if(slotTransferred >= slotTransferCap) - { - destSlotIndex++; - if(destSlotIndex == distrib.slots.length) - { - dest = null; - break; - } - dest = distrib.slots[destSlotIndex]; - slotTransferred = 0; - } - } - FastTransferManager.clickSlot(gui, slot.slotNumber); - if(transferred >= transferCap || dest == null) - break; - } - } - } + FastTransferManager.clickSlot(gui, slot.slotNumber); + int amount = Math.min(transferCap - transferred, stack.stackSize); + for (int c = 0; c < amount; c++) { + FastTransferManager.clickSlot(gui, dest.slotNumber, 1); + transferred++; + slotTransferred++; + if (slotTransferred >= slotTransferCap) { + destSlotIndex++; + if (destSlotIndex == distrib.slots.length) { + dest = null; + break; + } + dest = distrib.slots[destSlotIndex]; + slotTransferred = 0; + } + } + FastTransferManager.clickSlot(gui, slot.slotNumber); + if (transferred >= transferCap || dest == null) break; + } + } + } - private int calculateRecipeQuantity(List assignedIngredients){ - int quantity = Integer.MAX_VALUE; - for(IngredientDistribution distrib : assignedIngredients) - { - DistributedIngred istack = distrib.distrib; - if(istack.numSlots == 0) - return 0; + private int calculateRecipeQuantity(List assignedIngredients) { + int quantity = Integer.MAX_VALUE; + for (IngredientDistribution distrib : assignedIngredients) { + DistributedIngred istack = distrib.distrib; + if (istack.numSlots == 0) return 0; - int allSlots = istack.invAmount; - if(allSlots/istack.numSlots > istack.stack.getMaxStackSize()) - allSlots = istack.numSlots*istack.stack.getMaxStackSize(); + int allSlots = istack.invAmount; + if (allSlots / istack.numSlots > istack.stack.getMaxStackSize()) + allSlots = istack.numSlots * istack.stack.getMaxStackSize(); - quantity = Math.min(quantity, allSlots/istack.distributed); - } + quantity = Math.min(quantity, allSlots / istack.distributed); + } - return quantity; - } + return quantity; + } - private Slot[][] assignIngredSlots(GuiContainer gui, List ingredients, List assignedIngredients){ - Slot[][] recipeSlots = mapIngredSlots(gui, ingredients);//setup the slot map + private Slot[][] assignIngredSlots(GuiContainer gui, List ingredients, List assignedIngredients) { + Slot[][] recipeSlots = mapIngredSlots(gui, ingredients);//setup the slot map - HashMap distribution = new HashMap(); - for(int i = 0; i < recipeSlots.length; i++) - for(Slot slot : recipeSlots[i]) - if(!distribution.containsKey(slot)) - distribution.put(slot, -1); + HashMap distribution = new HashMap(); + for (int i = 0; i < recipeSlots.length; i++) + for (Slot slot : recipeSlots[i]) + if (!distribution.containsKey(slot)) distribution.put(slot, -1); - HashSet avaliableSlots = new HashSet(distribution.keySet()); - HashSet remainingIngreds = new HashSet(); - ArrayList> assignedSlots = new ArrayList>(); - for(int i = 0; i < ingredients.size(); i++) - { - remainingIngreds.add(i); - assignedSlots.add(new LinkedList()); - } + HashSet avaliableSlots = new HashSet(distribution.keySet()); + HashSet remainingIngreds = new HashSet(); + ArrayList> assignedSlots = new ArrayList>(); + for (int i = 0; i < ingredients.size(); i++) { + remainingIngreds.add(i); + assignedSlots.add(new LinkedList()); + } - while(avaliableSlots.size() > 0 && remainingIngreds.size() > 0) - { - for(Iterator iterator = remainingIngreds.iterator(); iterator.hasNext();) - { - int i = iterator.next(); - boolean assigned = false; - DistributedIngred istack = assignedIngredients.get(i).distrib; + while (avaliableSlots.size() > 0 && remainingIngreds.size() > 0) { + for (Iterator iterator = remainingIngreds.iterator(); iterator.hasNext(); ) { + int i = iterator.next(); + boolean assigned = false; + DistributedIngred istack = assignedIngredients.get(i).distrib; - for(Slot slot : recipeSlots[i]) - { - if(avaliableSlots.contains(slot)) - { - avaliableSlots.remove(slot); - if(slot.getHasStack()) - continue; + for (Slot slot : recipeSlots[i]) { + if (avaliableSlots.contains(slot)) { + avaliableSlots.remove(slot); + if (slot.getHasStack()) continue; - istack.numSlots++; - assignedSlots.get(i).add(slot); - assigned = true; - break; - } - } + istack.numSlots++; + assignedSlots.get(i).add(slot); + assigned = true; + break; + } + } - if(!assigned || istack.numSlots*istack.stack.getMaxStackSize() >= istack.invAmount) - iterator.remove(); - } - } + if (!assigned || istack.numSlots * istack.stack.getMaxStackSize() >= istack.invAmount) + iterator.remove(); + } + } - for(int i = 0; i < ingredients.size(); i++) - assignedIngredients.get(i).slots = assignedSlots.get(i).toArray(new Slot[0]); - return recipeSlots; - } + for (int i = 0; i < ingredients.size(); i++) + assignedIngredients.get(i).slots = assignedSlots.get(i).toArray(new Slot[0]); + return recipeSlots; + } - private List assignIngredients(List ingredients, List ingredStacks){ - ArrayList assignedIngredients = new ArrayList(); - for(PositionedStack posstack : ingredients)//assign what we need and have - { - DistributedIngred biggestIngred = null; - ItemStack permutation = null; - int biggestSize = 0; - for (ItemStack pstack : posstack.items) { - if (pstack.stackSize == 0) continue; - for (int j = 0; j < ingredStacks.size(); j++) { - DistributedIngred istack = ingredStacks.get(j); - if (!InventoryUtils.canStack(pstack, istack.stack) || istack.invAmount - istack.distributed < pstack.stackSize) - continue; - LogHelper.info(istack.invAmount - istack.invAmount + " " + istack.recipeAmount * istack.distributed + " " + pstack.stackSize); - int relsize = (istack.invAmount - istack.invAmount / istack.recipeAmount * istack.distributed) / pstack.stackSize; - if (relsize > biggestSize) { - biggestSize = relsize; - biggestIngred = istack; - permutation = pstack; - break; - } - } - } + private List assignIngredients(List ingredients, List ingredStacks) { + ArrayList assignedIngredients = new ArrayList(); + for (PositionedStack posstack : ingredients)//assign what we need and have + { + DistributedIngred biggestIngred = null; + ItemStack permutation = null; + int biggestSize = 0; + for (ItemStack pstack : posstack.items) { + if (pstack.stackSize == 0) continue; + for (int j = 0; j < ingredStacks.size(); j++) { + DistributedIngred istack = ingredStacks.get(j); + if (!InventoryUtils.canStack(pstack, istack.stack) || istack.invAmount - istack.distributed < pstack.stackSize) + continue; + LogHelper.info(istack.invAmount - istack.invAmount + " " + istack.recipeAmount * istack.distributed + " " + pstack.stackSize); + int relsize = (istack.invAmount - istack.invAmount / istack.recipeAmount * istack.distributed) / pstack.stackSize; + if (relsize > biggestSize) { + biggestSize = relsize; + biggestIngred = istack; + permutation = pstack; + break; + } + } + } - if (biggestIngred == null)//not enough ingreds - return null; + if (biggestIngred == null)//not enough ingreds + return null; - biggestIngred.distributed+=permutation.stackSize; - assignedIngredients.add(new IngredientDistribution(biggestIngred, permutation)); - } + biggestIngred.distributed += permutation.stackSize; + assignedIngredients.add(new IngredientDistribution(biggestIngred, permutation)); + } - return assignedIngredients; - } + return assignedIngredients; + } - @SuppressWarnings("unchecked") - private void findInventoryQuantities(GuiContainer gui, List ingredStacks){ - for(Slot slot : (List)gui.inventorySlots.inventorySlots)//work out how much we have to go round - { - if(slot.getHasStack() && canMoveFrom(slot, gui)) - { - ItemStack pstack = slot.getStack(); - DistributedIngred istack = findIngred(ingredStacks, pstack); - if(istack != null) - istack.invAmount+=pstack.stackSize; - } - } - } + @SuppressWarnings("unchecked") + private void findInventoryQuantities(GuiContainer gui, List ingredStacks) { + for (Slot slot : (List) gui.inventorySlots.inventorySlots)//work out how much we have to go round + { + if (slot.getHasStack() && canMoveFrom(slot, gui)) { + ItemStack pstack = slot.getStack(); + DistributedIngred istack = findIngred(ingredStacks, pstack); + if (istack != null) istack.invAmount += pstack.stackSize; + } + } + } - private List getPermutationIngredients(List ingredients){ - ArrayList ingredStacks = new ArrayList(); - for(PositionedStack posstack : ingredients)//work out what we need - { - for(ItemStack pstack : posstack.items) - { - DistributedIngred istack = findIngred(ingredStacks, pstack); - if(istack == null) - ingredStacks.add(istack = new DistributedIngred(pstack)); - istack.recipeAmount+=pstack.stackSize; - } - } - return ingredStacks; - } + private List getPermutationIngredients(List ingredients) { + ArrayList ingredStacks = new ArrayList(); + for (PositionedStack posstack : ingredients)//work out what we need + { + for (ItemStack pstack : posstack.items) { + DistributedIngred istack = findIngred(ingredStacks, pstack); + if (istack == null) ingredStacks.add(istack = new DistributedIngred(pstack)); + istack.recipeAmount += pstack.stackSize; + } + } + return ingredStacks; + } - public boolean canMoveFrom(Slot slot, GuiContainer gui) { - return slot.inventory instanceof InventoryPlayer || slot.inventory instanceof TileDraconiumChest; - } + public boolean canMoveFrom(Slot slot, GuiContainer gui) { + return slot.inventory instanceof InventoryPlayer || slot.inventory instanceof TileDraconiumChest; + } - @SuppressWarnings("unchecked") - public Slot[][] mapIngredSlots(GuiContainer gui, List ingredients){ - int offsetx = getOffsetX(gui); - int offsety = getOffsetY(gui); - Slot[][] recipeSlotList = new Slot[ingredients.size()][]; - for(int i = 0; i < ingredients.size(); i++)//identify slots - { - LinkedList recipeSlots = new LinkedList(); - PositionedStack pstack = ingredients.get(i); - for(Slot slot : (List)gui.inventorySlots.inventorySlots) - { - if(slot.xDisplayPosition == pstack.relx+offsetx && slot.yDisplayPosition == pstack.rely+offsety) - { - recipeSlots.add(slot); - break; - } - } - recipeSlotList[i] = recipeSlots.toArray(new Slot[0]); - } - return recipeSlotList; - } + @SuppressWarnings("unchecked") + public Slot[][] mapIngredSlots(GuiContainer gui, List ingredients) { + int offsetx = getOffsetX(gui); + int offsety = getOffsetY(gui); + Slot[][] recipeSlotList = new Slot[ingredients.size()][]; + for (int i = 0; i < ingredients.size(); i++)//identify slots + { + LinkedList recipeSlots = new LinkedList(); + PositionedStack pstack = ingredients.get(i); + for (Slot slot : (List) gui.inventorySlots.inventorySlots) { + if (slot.xDisplayPosition == pstack.relx + offsetx && slot.yDisplayPosition == pstack.rely + offsety) { + recipeSlots.add(slot); + break; + } + } + recipeSlotList[i] = recipeSlots.toArray(new Slot[0]); + } + return recipeSlotList; + } - public DistributedIngred findIngred(List ingredStacks, ItemStack pstack){ - for(DistributedIngred istack : ingredStacks) - if(InventoryUtils.canStack(pstack, istack.stack)) - return istack; - return null; - } + public DistributedIngred findIngred(List ingredStacks, ItemStack pstack) { + for (DistributedIngred istack : ingredStacks) + if (InventoryUtils.canStack(pstack, istack.stack)) return istack; + return null; + } - private int getOffsetX(GuiContainer gui) - { - return 309; - } + private int getOffsetX(GuiContainer gui) { + return 309; + } - private int getOffsetY(GuiContainer gui) - { - return 182; - } + private int getOffsetY(GuiContainer gui) { + return 182; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/integration/nei/CraftingChestStackPositioner.java b/src/main/java/com/brandon3055/draconicevolution/integration/nei/CraftingChestStackPositioner.java index 593f5b39..cc56b41f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/integration/nei/CraftingChestStackPositioner.java +++ b/src/main/java/com/brandon3055/draconicevolution/integration/nei/CraftingChestStackPositioner.java @@ -12,36 +12,31 @@ import java.util.ArrayList; /** * Created by Brandon on 30/10/2014. */ -public class CraftingChestStackPositioner implements IStackPositioner -{ +public class CraftingChestStackPositioner implements IStackPositioner { - @Override - public ArrayList positionStacks (ArrayList stacks) - { + @Override + public ArrayList positionStacks(ArrayList stacks) { - if (Minecraft.getMinecraft().currentScreen instanceof GuiRecipe) - { - GuiRecipe recipeGui = (GuiRecipe) Minecraft.getMinecraft().currentScreen; + if (Minecraft.getMinecraft().currentScreen instanceof GuiRecipe) { + GuiRecipe recipeGui = (GuiRecipe) Minecraft.getMinecraft().currentScreen; - if (!(recipeGui.firstGui instanceof GUIDraconiumChest)) - { - LogHelper.error("No CraftingStationGui found!"); - return stacks; - } + if (!(recipeGui.firstGui instanceof GUIDraconiumChest)) { + LogHelper.error("No CraftingStationGui found!"); + return stacks; + } - GUIDraconiumChest gui = (GUIDraconiumChest) recipeGui.firstGui; + GUIDraconiumChest gui = (GUIDraconiumChest) recipeGui.firstGui; - int offsetX = 309; - int offsetY = 182; + int offsetX = 309; + int offsetY = 182; - for (PositionedStack stack : stacks) - { - stack.relx += offsetX; - stack.rely += offsetY; - } - } + for (PositionedStack stack : stacks) { + stack.relx += offsetX; + stack.rely += offsetY; + } + } - return stacks; - } + return stacks; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/integration/nei/DENEIGuiHandler.java b/src/main/java/com/brandon3055/draconicevolution/integration/nei/DENEIGuiHandler.java index 2f09b7b7..2eae9aa9 100644 --- a/src/main/java/com/brandon3055/draconicevolution/integration/nei/DENEIGuiHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/integration/nei/DENEIGuiHandler.java @@ -17,25 +17,25 @@ import java.util.List; */ public class DENEIGuiHandler implements INEIGuiHandler { - public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) { - if (gui instanceof GUIUpgradeModifier && ((GUIUpgradeModifier)gui).inUse) currentVisibility.showNEI = false; - else if (gui instanceof GUIToolConfig || gui instanceof GUIManual) currentVisibility.showNEI = false; - return currentVisibility; - } + public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) { + if (gui instanceof GUIUpgradeModifier && ((GUIUpgradeModifier) gui).inUse) currentVisibility.showNEI = false; + else if (gui instanceof GUIToolConfig || gui instanceof GUIManual) currentVisibility.showNEI = false; + return currentVisibility; + } - public Iterable getItemSpawnSlots(GuiContainer gui, ItemStack item) { - return Collections.emptyList(); - } + public Iterable getItemSpawnSlots(GuiContainer gui, ItemStack item) { + return Collections.emptyList(); + } - public List getInventoryAreas(GuiContainer gui) { - return null; - } + public List getInventoryAreas(GuiContainer gui) { + return null; + } - public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) { - return false; - } + public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) { + return false; + } - public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) { - return false; - } + public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) { + return false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/integration/nei/NEIDraconicevolutionConfig.java b/src/main/java/com/brandon3055/draconicevolution/integration/nei/NEIDraconicevolutionConfig.java index 5c65e15d..350620f7 100644 --- a/src/main/java/com/brandon3055/draconicevolution/integration/nei/NEIDraconicevolutionConfig.java +++ b/src/main/java/com/brandon3055/draconicevolution/integration/nei/NEIDraconicevolutionConfig.java @@ -12,37 +12,36 @@ import net.minecraft.item.ItemStack; /** * Created by Brandon on 30/10/2014. */ -public class NEIDraconicevolutionConfig implements IConfigureNEI -{ - @Override - public void loadConfig() { +public class NEIDraconicevolutionConfig implements IConfigureNEI { + @Override + public void loadConfig() { - API.registerGuiOverlay(GUIDraconiumChest.class, "crafting", new CraftingChestStackPositioner()); - API.registerGuiOverlayHandler(GUIDraconiumChest.class, new CraftingChestOverlayHandler(), "crafting"); - API.hideItem(new ItemStack(ModBlocks.placedItem)); - API.hideItem(new ItemStack(ModBlocks.invisibleMultiblock)); - API.hideItem(new ItemStack(ModBlocks.safetyFlame)); - API.hideItem(new ItemStack(ModItems.tclogo)); - API.hideItem(new ItemStack(ModItems.creativeStructureSpawner)); - API.hideItem(new ItemStack(ModItems.dezilsMarshmallow)); - API.hideItem(new ItemStack(ModItems.creativeStructureSpawner, 1, 1)); - API.hideItem(new ItemStack(ModItems.sunFocus)); - API.hideItem(new ItemStack(ModBlocks.portal)); - API.hideItem(new ItemStack(ModBlocks.chaosShardAtmos)); - API.hideItem(new ItemStack(ModBlocks.chaosCrystal)); - API.registerNEIGuiHandler(new DENEIGuiHandler()); + API.registerGuiOverlay(GUIDraconiumChest.class, "crafting", new CraftingChestStackPositioner()); + API.registerGuiOverlayHandler(GUIDraconiumChest.class, new CraftingChestOverlayHandler(), "crafting"); + API.hideItem(new ItemStack(ModBlocks.placedItem)); + API.hideItem(new ItemStack(ModBlocks.invisibleMultiblock)); + API.hideItem(new ItemStack(ModBlocks.safetyFlame)); + API.hideItem(new ItemStack(ModItems.tclogo)); + API.hideItem(new ItemStack(ModItems.creativeStructureSpawner)); + API.hideItem(new ItemStack(ModItems.dezilsMarshmallow)); + API.hideItem(new ItemStack(ModItems.creativeStructureSpawner, 1, 1)); + API.hideItem(new ItemStack(ModItems.sunFocus)); + API.hideItem(new ItemStack(ModBlocks.portal)); + API.hideItem(new ItemStack(ModBlocks.chaosShardAtmos)); + API.hideItem(new ItemStack(ModBlocks.chaosCrystal)); + API.registerNEIGuiHandler(new DENEIGuiHandler()); - LogHelper.info("Added NEI integration"); - } + LogHelper.info("Added NEI integration"); + } - @Override - public String getName() { - return "DraconicEvolution-NEIConfig"; - } + @Override + public String getName() { + return "DraconicEvolution-NEIConfig"; + } - @Override - public String getVersion() { - return References.VERSION; - } + @Override + public String getVersion() { + return References.VERSION; + } }