From e48eedb874f8a08770bfa35efb95d9df3c4059dd Mon Sep 17 00:00:00 2001 From: WayofTime Date: Wed, 30 Dec 2015 15:34:40 -0500 Subject: [PATCH] Changed formatting to have bracing on a new line --- .../java/WayofTime/bloodmagic/BloodMagic.java | 20 +- .../WayofTime/bloodmagic/ConfigHandler.java | 36 +- .../AlchemyArrayEffectBinding.java | 93 ++- .../bloodmagic/altar/BloodAltar.java | 344 ++++---- .../WayofTime/bloodmagic/api/BlockStack.java | 12 +- .../bloodmagic/api/BloodMagicAPI.java | 22 +- .../WayofTime/bloodmagic/api/Constants.java | 15 +- .../api/DamageSourceBloodMagic.java | 9 +- .../bloodmagic/api/ItemStackWrapper.java | 33 +- .../alchemyCrafting/AlchemyArrayEffect.java | 9 +- .../AlchemyArrayEffectCrafting.java | 64 +- .../AlchemyCircleRenderer.java | 232 +++--- .../bloodmagic/api/altar/AltarComponent.java | 22 +- .../bloodmagic/api/altar/AltarUpgrade.java | 30 +- .../api/altar/EnumAltarComponent.java | 10 +- .../bloodmagic/api/altar/EnumAltarTier.java | 58 +- .../bloodmagic/api/altar/IAltarComponent.java | 3 +- .../api/altar/IAltarManipulator.java | 7 +- .../bloodmagic/api/altar/IBloodAltar.java | 17 +- .../api/compress/CompressionHandler.java | 12 +- .../api/compress/CompressionRegistry.java | 41 +- .../api/event/AddToNetworkEvent.java | 22 +- .../bloodmagic/api/event/BoundToolEvent.java | 18 +- .../bloodmagic/api/event/ItemBindEvent.java | 6 +- .../bloodmagic/api/event/RitualEvent.java | 45 +- .../api/event/SacrificeKnifeUsedEvent.java | 6 +- .../api/event/SoulNetworkEvent.java | 47 +- .../bloodmagic/api/iface/IAltarReader.java | 3 +- .../bloodmagic/api/iface/IBindable.java | 5 +- .../bloodmagic/api/iface/ISigil.java | 3 +- .../api/livingArmour/LivingArmourHandler.java | 103 +-- .../api/livingArmour/LivingArmourUpgrade.java | 77 +- .../api/livingArmour/StatTracker.java | 70 +- .../bloodmagic/api/network/SoulNetwork.java | 62 +- .../bloodmagic/api/orb/BloodOrb.java | 61 +- .../bloodmagic/api/orb/IBloodOrb.java | 3 +- .../api/recipe/ShapedBloodOrbRecipe.java | 426 +++++----- .../api/recipe/ShapelessBloodOrbRecipe.java | 262 +++--- .../registry/AlchemyArrayRecipeRegistry.java | 327 ++++---- .../api/registry/AltarRecipeRegistry.java | 66 +- .../api/registry/ImperfectRitualRegistry.java | 56 +- .../bloodmagic/api/registry/OrbRegistry.java | 28 +- .../api/registry/RitualRegistry.java | 65 +- .../bloodmagic/api/ritual/AreaDescriptor.java | 21 +- .../bloodmagic/api/ritual/EnumRuneType.java | 23 +- .../api/ritual/IMasterRitualStone.java | 5 +- .../bloodmagic/api/ritual/IRitualStone.java | 8 +- .../bloodmagic/api/ritual/Ritual.java | 252 +++--- .../api/ritual/RitualComponent.java | 58 +- .../bloodmagic/api/ritual/RitualRenderer.java | 6 +- .../imperfect/IImperfectRitualStone.java | 5 +- .../api/ritual/imperfect/ImperfectRitual.java | 30 +- .../api/util/helper/BindableHelper.java | 82 +- .../api/util/helper/IncenseHelper.java | 12 +- .../bloodmagic/api/util/helper/LogHelper.java | 21 +- .../bloodmagic/api/util/helper/NBTHelper.java | 6 +- .../api/util/helper/NetworkHelper.java | 170 ++-- .../api/util/helper/PlayerHelper.java | 36 +- .../util/helper/PlayerSacrificeHelper.java | 57 +- .../api/util/helper/RitualHelper.java | 162 ++-- .../bloodmagic/block/BlockAlchemyArray.java | 126 +-- .../bloodmagic/block/BlockAltar.java | 33 +- .../bloodmagic/block/BlockBloodLight.java | 36 +- .../bloodmagic/block/BlockBloodRune.java | 11 +- .../block/BlockBloodStoneBrick.java | 8 +- .../bloodmagic/block/BlockCrystal.java | 8 +- .../bloodmagic/block/BlockLifeEssence.java | 24 +- .../bloodmagic/block/BlockPedestal.java | 65 +- .../bloodmagic/block/BlockPhantom.java | 27 +- .../block/BlockRitualController.java | 44 +- .../bloodmagic/block/BlockRitualStone.java | 11 +- .../bloodmagic/block/BlockSoulForge.java | 10 +- .../bloodmagic/block/BlockSpectral.java | 30 +- .../bloodmagic/block/BlockTeleposer.java | 21 +- .../bloodmagic/block/BlockTestSpellBlock.java | 42 +- .../bloodmagic/block/base/BlockInteger.java | 51 +- .../block/base/BlockIntegerContainer.java | 15 +- .../bloodmagic/block/base/BlockString.java | 56 +- .../block/base/BlockStringContainer.java | 15 +- .../block/property/PropertyString.java | 18 +- .../property/UnlistedPropertyInteger.java | 18 +- .../property/UnlistedPropertyString.java | 18 +- .../bloodmagic/client/gui/ConfigGui.java | 12 +- .../client/gui/ConfigGuiFactory.java | 15 +- .../client/render/RenderAlchemyArray.java | 18 +- .../BindingAlchemyCircleRenderer.java | 434 +++++----- .../bloodmagic/compat/ICompatibility.java | 8 +- .../compat/jei/BloodMagicPlugin.java | 30 +- .../compat/jei/BloodMagicRecipeWrapper.java | 9 +- .../jei/CompatibilityJustEnoughItems.java | 12 +- .../AlchemyArrayCraftingCategory.java | 25 +- .../AlchemyArrayCraftingRecipeHandler.java | 15 +- .../AlchemyArrayCraftingRecipeJEI.java | 20 +- .../AlchemyArrayCraftingRecipeMaker.java | 15 +- .../compat/jei/altar/AltarRecipeCategory.java | 24 +- .../compat/jei/altar/AltarRecipeHandler.java | 15 +- .../compat/jei/altar/AltarRecipeJEI.java | 20 +- .../compat/jei/altar/AltarRecipeMaker.java | 13 +- .../jei/binding/BindingRecipeCategory.java | 24 +- .../jei/binding/BindingRecipeHandler.java | 15 +- .../compat/jei/binding/BindingRecipeJEI.java | 20 +- .../jei/binding/BindingRecipeMaker.java | 15 +- .../compress/AdvancedCompressionHandler.java | 105 ++- .../compress/BaseCompressionHandler.java | 54 +- .../compress/StorageBlockCraftingManager.java | 96 ++- ...StorageBlockCraftingRecipeAssimilator.java | 204 +++-- .../entity/projectile/EntityBloodLight.java | 91 ++- .../item/ItemActivationCrystal.java | 20 +- .../bloodmagic/item/ItemAltarMaker.java | 42 +- .../bloodmagic/item/ItemBindable.java | 85 +- .../bloodmagic/item/ItemBloodOrb.java | 39 +- .../bloodmagic/item/ItemBloodShard.java | 12 +- .../bloodmagic/item/ItemBoundAxe.java | 33 +- .../bloodmagic/item/ItemBoundPickaxe.java | 36 +- .../bloodmagic/item/ItemBoundShovel.java | 33 +- .../bloodmagic/item/ItemBoundSword.java | 49 +- .../bloodmagic/item/ItemBoundTool.java | 82 +- .../bloodmagic/item/ItemBucketEssence.java | 6 +- .../bloodmagic/item/ItemComponent.java | 18 +- .../item/ItemDaggerOfSacrifice.java | 44 +- .../bloodmagic/item/ItemInscriptionTool.java | 24 +- .../bloodmagic/item/ItemRitualDiviner.java | 749 ++++++++++-------- .../item/ItemSacrificialDagger.java | 71 +- .../WayofTime/bloodmagic/item/ItemSlate.java | 15 +- .../item/ItemTelepositionFocus.java | 29 +- .../item/armour/ItemLivingArmour.java | 25 +- .../item/block/ItemBlockBloodRune.java | 12 +- .../item/block/ItemBlockBloodStoneBrick.java | 12 +- .../item/block/ItemBlockCrystal.java | 12 +- .../item/block/ItemBlockPedestal.java | 12 +- .../item/block/ItemBlockRitualController.java | 12 +- .../item/block/ItemBlockRitualStone.java | 12 +- .../item/gear/ItemPackSacrifice.java | 39 +- .../item/gear/ItemPackSelfSacrifice.java | 48 +- .../bloodmagic/item/sigil/ItemSigilAir.java | 21 +- .../bloodmagic/item/sigil/ItemSigilBase.java | 33 +- .../item/sigil/ItemSigilBloodLight.java | 21 +- .../item/sigil/ItemSigilCompression.java | 16 +- .../item/sigil/ItemSigilDivination.java | 27 +- .../sigil/ItemSigilElementalAffinity.java | 9 +- .../item/sigil/ItemSigilEnderSeverance.java | 12 +- .../item/sigil/ItemSigilFastMiner.java | 9 +- .../item/sigil/ItemSigilGreenGrove.java | 48 +- .../bloodmagic/item/sigil/ItemSigilHaste.java | 9 +- .../bloodmagic/item/sigil/ItemSigilLava.java | 76 +- .../item/sigil/ItemSigilMagnetism.java | 21 +- .../item/sigil/ItemSigilPhantomBridge.java | 27 +- .../bloodmagic/item/sigil/ItemSigilSeer.java | 37 +- .../item/sigil/ItemSigilSuppression.java | 27 +- .../item/sigil/ItemSigilToggleable.java | 37 +- .../bloodmagic/item/sigil/ItemSigilVoid.java | 57 +- .../bloodmagic/item/sigil/ItemSigilWater.java | 93 ++- .../item/sigil/ItemSigilWhirlwind.java | 9 +- .../bloodmagic/livingArmour/LivingArmour.java | 212 ++--- .../network/BloodMagicPacketHandler.java | 15 +- .../bloodmagic/potion/PotionBloodMagic.java | 6 +- .../potion/PotionEventHandlers.java | 72 +- .../bloodmagic/proxy/ClientProxy.java | 15 +- .../bloodmagic/proxy/CommonProxy.java | 15 +- .../bloodmagic/registry/ModBlocks.java | 24 +- .../bloodmagic/registry/ModCompatibility.java | 9 +- .../bloodmagic/registry/ModEntities.java | 6 +- .../bloodmagic/registry/ModItems.java | 27 +- .../bloodmagic/registry/ModPotions.java | 42 +- .../bloodmagic/registry/ModRecipes.java | 126 +-- .../bloodmagic/registry/ModRituals.java | 11 +- .../render/RenderEntityBloodLight.java | 15 +- .../bloodmagic/ritual/RitualGreenGrove.java | 134 ++-- .../bloodmagic/ritual/RitualLava.java | 71 +- .../bloodmagic/ritual/RitualTest.java | 21 +- .../bloodmagic/ritual/RitualWater.java | 71 +- .../ritual/imperfect/ImperfectRitualDay.java | 9 +- .../imperfect/ImperfectRitualNight.java | 9 +- .../ritual/imperfect/ImperfectRitualRain.java | 15 +- .../imperfect/ImperfectRitualResistance.java | 9 +- .../imperfect/ImperfectRitualZombie.java | 9 +- .../bloodmagic/tile/TileAlchemyArray.java | 114 +-- .../WayofTime/bloodmagic/tile/TileAltar.java | 223 +++--- .../tile/TileImperfectRitualStone.java | 15 +- .../bloodmagic/tile/TileInventory.java | 108 ++- .../tile/TileMasterRitualStone.java | 294 +++---- .../bloodmagic/tile/TilePhantomBlock.java | 21 +- .../WayofTime/bloodmagic/tile/TilePlinth.java | 6 +- .../bloodmagic/tile/TileSpectralBlock.java | 39 +- .../WayofTime/bloodmagic/util/ChatUtil.java | 165 ++-- .../java/WayofTime/bloodmagic/util/Utils.java | 74 +- .../bloodmagic/util/handler/EventHandler.java | 33 +- .../util/helper/InventoryRenderHelper.java | 108 ++- .../bloodmagic/util/helper/TextHelper.java | 30 +- 189 files changed, 6092 insertions(+), 4041 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/BloodMagic.java b/src/main/java/WayofTime/bloodmagic/BloodMagic.java index c594d0a4..d82450bd 100644 --- a/src/main/java/WayofTime/bloodmagic/BloodMagic.java +++ b/src/main/java/WayofTime/bloodmagic/BloodMagic.java @@ -30,7 +30,8 @@ import WayofTime.bloodmagic.util.handler.EventHandler; @Mod(modid = Constants.Mod.MODID, name = Constants.Mod.NAME, version = Constants.Mod.VERSION, dependencies = Constants.Mod.DEPEND, acceptedMinecraftVersions = "[1.8.8,1.8.9]", guiFactory = "WayofTime.bloodmagic.client.gui.ConfigGuiFactory") @Getter -public class BloodMagic { +public class BloodMagic +{ @SidedProxy(serverSide = "WayofTime.bloodmagic.proxy.CommonProxy", clientSide = "WayofTime.bloodmagic.proxy.ClientProxy") public static CommonProxy proxy; @@ -38,9 +39,11 @@ public class BloodMagic { @Mod.Instance(Constants.Mod.MODID) public static BloodMagic instance; - public static CreativeTabs tabBloodMagic = new CreativeTabs(Constants.Mod.MODID + ".creativeTab") { + public static CreativeTabs tabBloodMagic = new CreativeTabs(Constants.Mod.MODID + ".creativeTab") + { @Override - public Item getTabIconItem() { + public Item getTabIconItem() + { return ModItems.bloodOrb; } }; @@ -49,12 +52,13 @@ public class BloodMagic { private File configDir; @Mod.EventHandler - public void preInit(FMLPreInitializationEvent event) { + public void preInit(FMLPreInitializationEvent event) + { configDir = new File(event.getModConfigurationDirectory(), "BloodMagic"); ConfigHandler.init(new File(getConfigDir(), "BloodMagic.cfg")); MinecraftForge.EVENT_BUS.register(new EventHandler()); - + ModBlocks.init(); ModItems.init(); ModPotions.init(); @@ -64,7 +68,8 @@ public class BloodMagic { } @Mod.EventHandler - public void init(FMLInitializationEvent event) { + public void init(FMLInitializationEvent event) + { BloodMagicPacketHandler.init(); ModRecipes.init(); @@ -77,7 +82,8 @@ public class BloodMagic { } @Mod.EventHandler - public void postInit(FMLPostInitializationEvent event) { + public void postInit(FMLPostInitializationEvent event) + { ModRecipes.addCompressionHandlers(); proxy.postInit(); diff --git a/src/main/java/WayofTime/bloodmagic/ConfigHandler.java b/src/main/java/WayofTime/bloodmagic/ConfigHandler.java index 3ba99dc9..e36c9397 100644 --- a/src/main/java/WayofTime/bloodmagic/ConfigHandler.java +++ b/src/main/java/WayofTime/bloodmagic/ConfigHandler.java @@ -18,9 +18,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -public class ConfigHandler { +public class ConfigHandler +{ - @Getter @Setter + @Getter + @Setter private static Configuration config; // Teleposer @@ -89,23 +91,25 @@ public class ConfigHandler { // Compat - public static void init(File file) { + public static void init(File file) + { config = new Configuration(file); syncConfig(); } - public static void syncConfig() { + public static void syncConfig() + { String category; category = "Item/Block Blacklisting"; config.addCustomCategoryComment(category, "Allows disabling of specific Blocks/Items.\nNote that using this may result in crashes. Use is not supported."); config.setCategoryRequiresMcRestart(category, true); - itemBlacklist = Arrays.asList(config.getStringList("itemBlacklist", category, new String[]{}, "Items to not be registered. This requires their mapping name. Usually the same as the class name. Can be found in F3+H mode.")); - blockBlacklist = Arrays.asList(config.getStringList("blockBlacklist", category, new String[]{}, "Blocks to not be registered. This requires their mapping name. Usually the same as the class name. Can be found in F3+H mode.")); + itemBlacklist = Arrays.asList(config.getStringList("itemBlacklist", category, new String[] {}, "Items to not be registered. This requires their mapping name. Usually the same as the class name. Can be found in F3+H mode.")); + blockBlacklist = Arrays.asList(config.getStringList("blockBlacklist", category, new String[] {}, "Blocks to not be registered. This requires their mapping name. Usually the same as the class name. Can be found in F3+H mode.")); category = "Teleposer Blacklist"; config.addCustomCategoryComment(category, "Block blacklisting"); - teleposerBlacklisting = config.getStringList("teleposerBlacklist", category, new String[]{"minecraft:bedrock"}, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta"); + teleposerBlacklisting = config.getStringList("teleposerBlacklist", category, new String[] { "minecraft:bedrock" }, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta"); buildTeleposerBlacklist(); category = "Potions"; @@ -179,21 +183,26 @@ public class ConfigHandler { config.save(); } - private static void buildTeleposerBlacklist() { + private static void buildTeleposerBlacklist() + { // Make sure it's empty before setting the blacklist. - // Otherwise, reloading the config while in-game will duplicate the list. + // Otherwise, reloading the config while in-game will duplicate the + // list. teleposerBlacklist.clear(); - for (String blockSet : teleposerBlacklisting) { + for (String blockSet : teleposerBlacklisting) + { String[] blockData = blockSet.split(":"); Block block = GameRegistry.findBlock(blockData[0], blockData[1]); int meta = 0; // If the block follows full syntax: modid:blockname:meta - if (blockData.length == 3) { - // Check if it's an int, if so, parse it. If not, set meta to 0 to avoid crashing. + if (blockData.length == 3) + { + // Check if it's an int, if so, parse it. If not, set meta to 0 + // to avoid crashing. if (Utils.isInteger(blockData[2])) meta = Integer.parseInt(blockData[2]); else if (blockData[2].equals("*")) @@ -206,7 +215,8 @@ public class ConfigHandler { } } - public static void checkRituals() { + public static void checkRituals() + { RitualHelper.checkRituals(config, "WayofTime.bloodmagic.ritual", "Rituals"); RitualHelper.checkImperfectRituals(config, "WayofTime.bloodmagic.ritual.imperfect", "Rituals.imperfect"); config.save(); diff --git a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectBinding.java b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectBinding.java index 3c759d17..83624024 100644 --- a/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectBinding.java +++ b/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectBinding.java @@ -11,51 +11,60 @@ import net.minecraft.world.World; import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting; import WayofTime.bloodmagic.client.render.alchemyArray.BindingAlchemyCircleRenderer; -public class AlchemyArrayEffectBinding extends AlchemyArrayEffect { +public class AlchemyArrayEffectBinding extends AlchemyArrayEffect +{ - @Getter - public final ItemStack outputStack; + @Getter + public final ItemStack outputStack; - public AlchemyArrayEffectBinding(ItemStack outputStack) { - this.outputStack = outputStack; - } - - @Override - public boolean update(TileEntity tile, int ticksActive) { - if(ticksActive >= 50 && ticksActive <= 250) { - //TODO: Find a way to spawn lightning from only the server side - does not render when just spawned on server, not client. - this.spawnLightningOnCircle(tile.getWorld(), tile.getPos(), ticksActive); - } - - if(tile.getWorld().isRemote) { - return false; - } - - if(ticksActive >= 300){ - BlockPos pos = tile.getPos(); + public AlchemyArrayEffectBinding(ItemStack outputStack) + { + this.outputStack = outputStack; + } - ItemStack output = outputStack.copy(); - EntityItem outputEntity = new EntityItem(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output); + @Override + public boolean update(TileEntity tile, int ticksActive) + { + if (ticksActive >= 50 && ticksActive <= 250) + { + // TODO: Find a way to spawn lightning from only the server side - + // does not render when just spawned on server, not client. + this.spawnLightningOnCircle(tile.getWorld(), tile.getPos(), ticksActive); + } - tile.getWorld().spawnEntityInWorld(outputEntity); + if (tile.getWorld().isRemote) + { + return false; + } - return true; - } - - return false; - } - - public void spawnLightningOnCircle(World world, BlockPos pos, int ticksActive) { - if(ticksActive % 50 == 0) { - int circle = ticksActive / 50 - 1; - float distance = BindingAlchemyCircleRenderer.getDistanceOfCircle(circle, ticksActive); - float angle = BindingAlchemyCircleRenderer.getAngleOfCircle(circle, ticksActive); - - double dispX = distance * Math.sin(angle); - double dispZ = -distance * Math.cos(angle); - - EntityLightningBolt lightning = new EntityLightningBolt(world, pos.getX() + dispX, pos.getY(), pos.getZ() + dispZ); - world.spawnEntityInWorld(lightning); - } - } + if (ticksActive >= 300) + { + BlockPos pos = tile.getPos(); + + ItemStack output = outputStack.copy(); + EntityItem outputEntity = new EntityItem(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output); + + tile.getWorld().spawnEntityInWorld(outputEntity); + + return true; + } + + return false; + } + + public void spawnLightningOnCircle(World world, BlockPos pos, int ticksActive) + { + if (ticksActive % 50 == 0) + { + int circle = ticksActive / 50 - 1; + float distance = BindingAlchemyCircleRenderer.getDistanceOfCircle(circle, ticksActive); + float angle = BindingAlchemyCircleRenderer.getAngleOfCircle(circle, ticksActive); + + double dispX = distance * Math.sin(angle); + double dispZ = -distance * Math.cos(angle); + + EntityLightningBolt lightning = new EntityLightningBolt(world, pos.getX() + dispX, pos.getY(), pos.getZ() + dispZ); + world.spawnEntityInWorld(lightning); + } + } } diff --git a/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java b/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java index 21a960b2..7208fd59 100644 --- a/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java +++ b/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java @@ -31,19 +31,20 @@ import WayofTime.bloodmagic.util.Utils; import com.google.common.base.Enums; import com.google.common.base.Strings; -public class BloodAltar { +public class BloodAltar +{ - private TileAltar tileAltar; - private int internalCounter = 0; - - public boolean isActive; + private TileAltar tileAltar; + private int internalCounter = 0; + + public boolean isActive; protected FluidStack fluidOutput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0); protected FluidStack fluidInput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0); private EnumAltarTier altarTier = EnumAltarTier.ONE; private AltarUpgrade upgrade; private int capacity = FluidContainerRegistry.BUCKET_VOLUME * 10; private FluidStack fluid = new FluidStack(BloodMagicAPI.getLifeEssence(), 0); - private int liquidRequired; //mB + private int liquidRequired; // mB private boolean canBeFilled; private int consumptionRate; private int drainRate; @@ -65,13 +66,14 @@ public class BloodAltar { private int cooldownAfterCrafting = 500; private ItemStack result; - - public BloodAltar(TileAltar tileAltar) - { - this.tileAltar = tileAltar; - } - - static { + + public BloodAltar(TileAltar tileAltar) + { + this.tileAltar = tileAltar; + } + + static + { EnumAltarTier.ONE.buildComponents(); EnumAltarTier.TWO.buildComponents(); EnumAltarTier.THREE.buildComponents(); @@ -80,9 +82,12 @@ public class BloodAltar { EnumAltarTier.SIX.buildComponents(); } - public static EnumAltarTier getAltarTier(World world, BlockPos pos) { - for (int i = EnumAltarTier.MAXTIERS - 1; i >= 1; i--) { - if (checkAltarIsValid(world, pos, i)) { + public static EnumAltarTier getAltarTier(World world, BlockPos pos) + { + for (int i = EnumAltarTier.MAXTIERS - 1; i >= 1; i--) + { + if (checkAltarIsValid(world, pos, i)) + { return EnumAltarTier.values()[i]; } } @@ -90,22 +95,28 @@ public class BloodAltar { return EnumAltarTier.ONE; } - public static boolean checkAltarIsValid(World world, BlockPos worldPos, int altarTier) { + public static boolean checkAltarIsValid(World world, BlockPos worldPos, int altarTier) + { - for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents()) { + for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents()) + { BlockPos componentPos = worldPos.add(altarComponent.getOffset()); BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos))); - if (altarComponent.getComponent() != EnumAltarComponent.NOTAIR) { - if (worldBlock.getBlock() instanceof IAltarComponent) { + if (altarComponent.getComponent() != EnumAltarComponent.NOTAIR) + { + if (worldBlock.getBlock() instanceof IAltarComponent) + { EnumAltarComponent component = ((IAltarComponent) worldBlock.getBlock()).getType(worldBlock.getMeta()); if (component != altarComponent.getComponent()) return false; - } else if (worldBlock.getBlock() != Utils.getBlockForComponent(altarComponent.getComponent())) { + } else if (worldBlock.getBlock() != Utils.getBlockForComponent(altarComponent.getComponent())) + { return false; } - } else { + } else + { if (world.isAirBlock(componentPos)) return false; } @@ -114,57 +125,63 @@ public class BloodAltar { return true; } - public static AltarUpgrade getUpgrades(World world, BlockPos pos, EnumAltarTier altarTier) { - if (world.isRemote) { + public static AltarUpgrade getUpgrades(World world, BlockPos pos, EnumAltarTier altarTier) + { + if (world.isRemote) + { return null; } AltarUpgrade upgrades = new AltarUpgrade(); List list = altarTier.getAltarComponents(); - for (AltarComponent altarComponent : list) { + for (AltarComponent altarComponent : list) + { BlockPos componentPos = pos.add(altarComponent.getOffset()); - if (altarComponent.isUpgradeSlot()) { + if (altarComponent.isUpgradeSlot()) + { BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos))); - if (worldBlock.getBlock() instanceof BlockBloodRune) { - switch (((BlockBloodRune) worldBlock.getBlock()).getRuneEffect(worldBlock.getMeta())) { - case 1: - upgrades.addSpeed(); - break; + if (worldBlock.getBlock() instanceof BlockBloodRune) + { + switch (((BlockBloodRune) worldBlock.getBlock()).getRuneEffect(worldBlock.getMeta())) + { + case 1: + upgrades.addSpeed(); + break; - case 2: - upgrades.addEfficiency(); - break; + case 2: + upgrades.addEfficiency(); + break; - case 3: - upgrades.addSacrifice(); - break; + case 3: + upgrades.addSacrifice(); + break; - case 4: - upgrades.addSelfSacrifice(); - break; + case 4: + upgrades.addSelfSacrifice(); + break; - case 5: - upgrades.addDisplacement(); - break; + case 5: + upgrades.addDisplacement(); + break; - case 6: - upgrades.addCapacity(); - break; + case 6: + upgrades.addCapacity(); + break; - case 7: - upgrades.addBetterCapacity(); - break; + case 7: + upgrades.addBetterCapacity(); + break; - case 8: - upgrades.addOrbCapacity(); - break; + case 8: + upgrades.addOrbCapacity(); + break; - case 9: - upgrades.addAcceleration(); - break; + case 9: + upgrades.addAcceleration(); + break; } } } @@ -172,9 +189,11 @@ public class BloodAltar { return upgrades; } - - public void readFromNBT(NBTTagCompound tagCompound) { - if (!tagCompound.hasKey(Constants.NBT.EMPTY)) { + + public void readFromNBT(NBTTagCompound tagCompound) + { + if (!tagCompound.hasKey(Constants.NBT.EMPTY)) + { FluidStack fluid = FluidStack.loadFluidStackFromNBT(tagCompound); if (fluid != null) @@ -212,7 +231,8 @@ public class BloodAltar { cooldownAfterCrafting = tagCompound.getInteger(Constants.NBT.ALTAR_COOLDOWN_AFTER_CRAFTING); } - public void writeToNBT(NBTTagCompound tagCompound) { + public void writeToNBT(NBTTagCompound tagCompound) + { if (fluid != null) fluid.writeToNBT(tagCompound); @@ -249,10 +269,11 @@ public class BloodAltar { tagCompound.setInteger(Constants.NBT.ALTAR_DEMON_BLOOD_DURATION, demonBloodDuration); tagCompound.setInteger(Constants.NBT.ALTAR_COOLDOWN_AFTER_CRAFTING, cooldownAfterCrafting); } - - public void startCycle() { + + public void startCycle() + { if (tileAltar.getWorld() != null) - tileAltar.getWorld().markBlockForUpdate(tileAltar.getPos()); + tileAltar.getWorld().markBlockForUpdate(tileAltar.getPos()); checkTier(); @@ -262,10 +283,13 @@ public class BloodAltar { if (!isActive) progress = 0; - if (tileAltar.getStackInSlot(0) != null) { + if (tileAltar.getStackInSlot(0) != null) + { // Do recipes - for (AltarRecipe recipe : AltarRecipeRegistry.getRecipes().values()) { - if (recipe.doesRequiredItemMatch(tileAltar.getStackInSlot(0), altarTier)) { + for (AltarRecipe recipe : AltarRecipeRegistry.getRecipes().values()) + { + if (recipe.doesRequiredItemMatch(tileAltar.getStackInSlot(0), altarTier)) + { this.isActive = true; this.result = new ItemStack(recipe.getOutput().getItem(), 1, recipe.getOutput().getMetadata()); this.liquidRequired = recipe.getSyphon(); @@ -279,27 +303,32 @@ public class BloodAltar { isActive = false; } - - public void update() { - World world = tileAltar.getWorld(); + + public void update() + { + World world = tileAltar.getWorld(); BlockPos pos = tileAltar.getPos(); - - if (world.isRemote) + + if (world.isRemote) return; - internalCounter++; //Used instead of the world time for checks that do not happen every tick + internalCounter++; // Used instead of the world time for checks that do + // not happen every tick if (lockdownDuration > 0) lockdownDuration--; - if (internalCounter % 20 == 0) { - for(EnumFacing facing : EnumFacing.VALUES){ - BlockPos newPos = pos.offset(facing); - IBlockState block = world.getBlockState(newPos); - block.getBlock().onNeighborBlockChange(world, newPos, block, block.getBlock()); - } + if (internalCounter % 20 == 0) + { + for (EnumFacing facing : EnumFacing.VALUES) + { + BlockPos newPos = pos.offset(facing); + IBlockState block = world.getBlockState(newPos); + block.getBlock().onNeighborBlockChange(world, newPos, block, block.getBlock()); + } } - if (internalCounter % (Math.max(20 - this.accelerationUpgrades, 1)) == 0) { + if (internalCounter % (Math.max(20 - this.accelerationUpgrades, 1)) == 0) + { int syphonMax = (int) (20 * this.dislocationMultiplier); int fluidInputted; int fluidOutputted; @@ -312,15 +341,17 @@ public class BloodAltar { this.fluidOutput.amount += fluidOutputted; this.fluid.amount -= fluidOutputted; } - + if (internalCounter % 100 == 0 && (this.isActive || this.cooldownAfterCrafting <= 0)) startCycle(); updateAltar(); } - - private void updateAltar() { - if (!isActive) { + + private void updateAltar() + { + if (!isActive) + { if (cooldownAfterCrafting > 0) cooldownAfterCrafting--; return; @@ -331,7 +362,7 @@ public class BloodAltar { World world = tileAltar.getWorld(); BlockPos pos = tileAltar.getPos(); - + if (world.isRemote) return; @@ -339,9 +370,11 @@ public class BloodAltar { float f1 = f * 0.6F + 0.4F; float f2 = f * f * 0.7F - 0.5F; float f3 = f * f * 0.6F - 0.7F; - - if (!canBeFilled) { - if (fluid != null && fluid.amount >= 1) { + + if (!canBeFilled) + { + if (fluid != null && fluid.amount >= 1) + { int stackSize = tileAltar.getStackInSlot(0).stackSize; int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount); @@ -354,7 +387,8 @@ public class BloodAltar { if (internalCounter % 4 == 0) world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + Math.random() - Math.random(), pos.getY() + Math.random() - Math.random(), pos.getZ() + Math.random() - Math.random(), f1, f2, f3); - if (progress >= liquidRequired * stackSize) { + if (progress >= liquidRequired * stackSize) + { ItemStack result = this.result; if (result != null) @@ -368,13 +402,15 @@ public class BloodAltar { this.isActive = false; } - } else if (progress > 0) { + } else if (progress > 0) + { progress -= (int) (efficiencyMultiplier * drainRate); if (internalCounter % 2 == 0) world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + Math.random() - Math.random(), pos.getY() + Math.random() - Math.random(), pos.getZ() + Math.random() - Math.random(), f1, f2, f3); } - } else { + } else + { ItemStack returnedItem = tileAltar.getStackInSlot(0); if (!(returnedItem.getItem() instanceof IBloodOrb)) @@ -391,7 +427,8 @@ public class BloodAltar { if (Strings.isNullOrEmpty(ownerUUID)) return; - if (fluid != null && fluid.amount >= 1) { + if (fluid != null && fluid.amount >= 1) + { int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount); int drain = NetworkHelper.getSoulNetwork(ownerUUID, world).addLifeEssence(liquidDrained, (int) (item.getMaxEssence(returnedItem.getMetadata()) * this.orbCapacityMultiplier)); @@ -405,14 +442,16 @@ public class BloodAltar { world.markBlockForUpdate(pos); } - - public void checkTier() { + + public void checkTier() + { EnumAltarTier tier = BloodAltar.getAltarTier(tileAltar.getWorld(), tileAltar.getPos()); this.altarTier = tier; - + upgrade = BloodAltar.getUpgrades(tileAltar.getWorld(), tileAltar.getPos(), tier); - if (tier.equals(EnumAltarTier.ONE)) { + if (tier.equals(EnumAltarTier.ONE)) + { upgrade = null; isUpgraded = false; this.consumptionMultiplier = 0; @@ -424,7 +463,8 @@ public class BloodAltar { this.dislocationMultiplier = 1; this.accelerationUpgrades = 0; return; - } else if (!tier.equals(EnumAltarTier.ONE) && upgrade != null) { + } else if (!tier.equals(EnumAltarTier.ONE) && upgrade != null) + { this.isUpgraded = true; this.consumptionMultiplier = (float) (0.20 * upgrade.getSpeedCount()); this.efficiencyMultiplier = (float) Math.pow(0.85, upgrade.getEfficiencyCount()); @@ -439,131 +479,165 @@ public class BloodAltar { this.capacity = (int) (FluidContainerRegistry.BUCKET_VOLUME * 10 * capacityMultiplier); this.bufferCapacity = (int) (FluidContainerRegistry.BUCKET_VOLUME * 1 * capacityMultiplier); - if (this.fluid.amount > this.capacity) this.fluid.amount = this.capacity; - if (this.fluidOutput.amount > this.bufferCapacity) this.fluidOutput.amount = this.bufferCapacity; - if (this.fluidInput.amount > this.bufferCapacity) this.fluidInput.amount = this.bufferCapacity; + if (this.fluid.amount > this.capacity) + this.fluid.amount = this.capacity; + if (this.fluidOutput.amount > this.bufferCapacity) + this.fluidOutput.amount = this.bufferCapacity; + if (this.fluidInput.amount > this.bufferCapacity) + this.fluidInput.amount = this.bufferCapacity; tileAltar.getWorld().markBlockForUpdate(tileAltar.getPos()); } - - public int fillMainTank(int amount) { + + public int fillMainTank(int amount) + { int filledAmount = Math.min(capacity - fluid.amount, amount); fluid.amount += filledAmount; - + return filledAmount; } - - public void sacrificialDaggerCall(int amount, boolean isSacrifice) { - if (this.lockdownDuration > 0) { + + public void sacrificialDaggerCall(int amount, boolean isSacrifice) + { + if (this.lockdownDuration > 0) + { int amt = (int) Math.min(bufferCapacity - fluidInput.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount); fluidInput.amount += amt; - } else { + } else + { fluid.amount += Math.min(capacity - fluid.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount); } } - - public void setMainFluid(FluidStack fluid) { + + public void setMainFluid(FluidStack fluid) + { this.fluid = fluid; } - public void setOutputFluid(FluidStack fluid) { + public void setOutputFluid(FluidStack fluid) + { this.fluidOutput = fluid; } - public void setInputFluid(FluidStack fluid) { + public void setInputFluid(FluidStack fluid) + { this.fluidInput = fluid; } - - public AltarUpgrade getUpgrade() { + + public AltarUpgrade getUpgrade() + { return upgrade; } - public void setUpgrade(AltarUpgrade upgrade) { + public void setUpgrade(AltarUpgrade upgrade) + { this.upgrade = upgrade; } - public int getCapacity() { + public int getCapacity() + { return capacity; } - public FluidStack getFluid() { + public FluidStack getFluid() + { return fluid; } - public int getFluidAmount() { + public int getFluidAmount() + { return fluid.amount; } - - public int getCurrentBlood() { + + public int getCurrentBlood() + { return getFluidAmount(); } - public EnumAltarTier getTier() { + public EnumAltarTier getTier() + { return altarTier; } - public void setTier(EnumAltarTier tier) { + public void setTier(EnumAltarTier tier) + { this.altarTier = tier; } - public int getProgress() { + public int getProgress() + { return progress; } - public float getSacrificeMultiplier() { + public float getSacrificeMultiplier() + { return sacrificeEfficiencyMultiplier; } - public float getSelfSacrificeMultiplier() { + public float getSelfSacrificeMultiplier() + { return selfSacrificeEfficiencyMultiplier; } - public float getOrbMultiplier() { + public float getOrbMultiplier() + { return orbCapacityMultiplier; } - public float getDislocationMultiplier() { + public float getDislocationMultiplier() + { return dislocationMultiplier; } - public float getConsumptionMultiplier() { + public float getConsumptionMultiplier() + { return consumptionMultiplier; } - public float getConsumptionRate() { + public float getConsumptionRate() + { return consumptionRate; } - public int getLiquidRequired() { + public int getLiquidRequired() + { return liquidRequired; } - public int getBufferCapacity() { + public int getBufferCapacity() + { return bufferCapacity; } - public void addToDemonBloodDuration(int dur) { + public void addToDemonBloodDuration(int dur) + { this.demonBloodDuration += dur; } - public boolean hasDemonBlood() { + public boolean hasDemonBlood() + { return this.demonBloodDuration > 0; } - public void decrementDemonBlood() { + public void decrementDemonBlood() + { this.demonBloodDuration = Math.max(0, this.demonBloodDuration - 1); } - public void setActive() { + public void setActive() + { isActive = false; } - public boolean isActive() { + public boolean isActive() + { return isActive; } - public void requestPauseAfterCrafting(int amount) { - if (this.isActive) { + public void requestPauseAfterCrafting(int amount) + { + if (this.isActive) + { this.cooldownAfterCrafting = amount; } } diff --git a/src/main/java/WayofTime/bloodmagic/api/BlockStack.java b/src/main/java/WayofTime/bloodmagic/api/BlockStack.java index 8a2472b4..6f5e72f2 100644 --- a/src/main/java/WayofTime/bloodmagic/api/BlockStack.java +++ b/src/main/java/WayofTime/bloodmagic/api/BlockStack.java @@ -7,22 +7,26 @@ import net.minecraftforge.fml.common.registry.GameData; @Getter @EqualsAndHashCode -public class BlockStack { +public class BlockStack +{ private final Block block; private final int meta; - public BlockStack(Block block, int meta) { + public BlockStack(Block block, int meta) + { this.block = block; this.meta = meta; } - public BlockStack(Block block) { + public BlockStack(Block block) + { this(block, 0); } @Override - public String toString() { + public String toString() + { return GameData.getBlockRegistry().getNameForObject(block) + ":" + meta; } } diff --git a/src/main/java/WayofTime/bloodmagic/api/BloodMagicAPI.java b/src/main/java/WayofTime/bloodmagic/api/BloodMagicAPI.java index defd9a2b..fea96086 100644 --- a/src/main/java/WayofTime/bloodmagic/api/BloodMagicAPI.java +++ b/src/main/java/WayofTime/bloodmagic/api/BloodMagicAPI.java @@ -8,12 +8,14 @@ import net.minecraft.util.DamageSource; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fml.common.registry.GameRegistry; -public class BloodMagicAPI { +public class BloodMagicAPI +{ public static final String ORB = "ItemBloodOrb"; public static final String SCRIBE = "ItemInscriptionTool"; - @Getter @Setter + @Getter + @Setter private static boolean loggingEnabled; @Getter @@ -23,16 +25,20 @@ public class BloodMagicAPI { private static DamageSource damageSource = new DamageSourceBloodMagic(); /** - * Used to obtain Items from BloodMagic. Use the constants above for common items in case internal names - * change. - * - * @param name - The registered name of the item. Usually the same as the class name. + * Used to obtain Items from BloodMagic. Use the constants above for common + * items in case internal names change. + * + * @param name + * - The registered name of the item. Usually the same as the + * class name. * @return - The requested Item */ - public static Item getItem(String name) { + public static Item getItem(String name) + { return GameRegistry.findItem(Constants.Mod.MODID, name); } - @Getter @Setter + @Getter + @Setter private static Fluid lifeEssence; } diff --git a/src/main/java/WayofTime/bloodmagic/api/Constants.java b/src/main/java/WayofTime/bloodmagic/api/Constants.java index d3c947f1..4cebbbf7 100644 --- a/src/main/java/WayofTime/bloodmagic/api/Constants.java +++ b/src/main/java/WayofTime/bloodmagic/api/Constants.java @@ -4,9 +4,11 @@ import net.minecraft.potion.Potion; import java.util.Locale; -public class Constants { +public class Constants +{ - public static class NBT { + public static class NBT + { public static final String OWNER_UUID = "ownerUUID"; public static final String USES = "uses"; @@ -62,7 +64,8 @@ public class Constants { public static final String CONTAINED_BLOCK_META = "containedBlockMeta"; } - public static class Mod { + public static class Mod + { public static final String MODID = "BloodMagic"; public static final String DOMAIN = MODID.toLowerCase(Locale.ENGLISH) + ":"; @@ -71,13 +74,15 @@ public class Constants { public static final String DEPEND = ""; } - public static class Compat { + public static class Compat + { public static final String JEI_CATEGORY_ALTAR = Mod.MODID + ":altar"; public static final String JEI_CATEGORY_BINDING = Mod.MODID + ":binding"; public static final String JEI_CATEGORY_ALCHEMYARRAY = Mod.MODID + ":alchemyArray"; } - public static class Misc { + public static class Misc + { public static final int POTION_ARRAY_SIZE = Potion.potionTypes.length; } } diff --git a/src/main/java/WayofTime/bloodmagic/api/DamageSourceBloodMagic.java b/src/main/java/WayofTime/bloodmagic/api/DamageSourceBloodMagic.java index 60b46a9d..a7468a9f 100644 --- a/src/main/java/WayofTime/bloodmagic/api/DamageSourceBloodMagic.java +++ b/src/main/java/WayofTime/bloodmagic/api/DamageSourceBloodMagic.java @@ -6,9 +6,11 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.DamageSource; import net.minecraft.util.IChatComponent; -public class DamageSourceBloodMagic extends DamageSource { +public class DamageSourceBloodMagic extends DamageSource +{ - public DamageSourceBloodMagic() { + public DamageSourceBloodMagic() + { super("bloodMagic"); setDamageBypassesArmor(); @@ -16,7 +18,8 @@ public class DamageSourceBloodMagic extends DamageSource { } @Override - public IChatComponent getDeathMessage(EntityLivingBase livingBase) { + public IChatComponent getDeathMessage(EntityLivingBase livingBase) + { return new ChatComponentText(TextHelper.localizeEffect("chat.BloodMagic.damageSource", livingBase.getName())); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/ItemStackWrapper.java b/src/main/java/WayofTime/bloodmagic/api/ItemStackWrapper.java index a6a79bb6..efad9c32 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ItemStackWrapper.java +++ b/src/main/java/WayofTime/bloodmagic/api/ItemStackWrapper.java @@ -10,7 +10,8 @@ import net.minecraft.nbt.NBTTagCompound; @RequiredArgsConstructor @EqualsAndHashCode -public class ItemStackWrapper { +public class ItemStackWrapper +{ public final Item item; public final int stackSize; @@ -18,44 +19,54 @@ public class ItemStackWrapper { @Setter public NBTTagCompound nbtTag; - public ItemStackWrapper(Item item, int stackSize) { + public ItemStackWrapper(Item item, int stackSize) + { this(item, stackSize, 0); } - public ItemStackWrapper(Item item) { + public ItemStackWrapper(Item item) + { this(item, 1, 0); } - public ItemStackWrapper(Block block, int stackSize, int meta) { + public ItemStackWrapper(Block block, int stackSize, int meta) + { this(Item.getItemFromBlock(block), stackSize, meta); } - public ItemStackWrapper(Block block, int stackSize) { + public ItemStackWrapper(Block block, int stackSize) + { this(block, stackSize, 0); } - public ItemStackWrapper(Block block) { + public ItemStackWrapper(Block block) + { this(block, 1, 0); } - public static ItemStackWrapper getHolder(ItemStack stack) { + public static ItemStackWrapper getHolder(ItemStack stack) + { return new ItemStackWrapper(stack.getItem(), stack.stackSize, stack.getItemDamage()); } - public ItemStack toStack() { + public ItemStack toStack() + { return new ItemStack(item, stackSize, meta); } - public String getDisplayName() { + public String getDisplayName() + { return toStack().getDisplayName(); } @Override - public String toString() { + public String toString() + { return stackSize + "x" + item.getUnlocalizedName() + "@" + this.meta; } - public ItemStack toStack(int count) { + public ItemStack toStack(int count) + { ItemStack result = new ItemStack(item, count, meta); result.setTagCompound(nbtTag); return result; diff --git a/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyArrayEffect.java b/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyArrayEffect.java index d3650e52..a5e32df0 100644 --- a/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyArrayEffect.java +++ b/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyArrayEffect.java @@ -2,8 +2,9 @@ package WayofTime.bloodmagic.api.alchemyCrafting; import net.minecraft.tileentity.TileEntity; -public abstract class AlchemyArrayEffect { - - public abstract boolean update(TileEntity tile, int ticksActive); - +public abstract class AlchemyArrayEffect +{ + + public abstract boolean update(TileEntity tile, int ticksActive); + } diff --git a/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyArrayEffectCrafting.java b/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyArrayEffectCrafting.java index 97912e1d..70205b58 100644 --- a/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyArrayEffectCrafting.java +++ b/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyArrayEffectCrafting.java @@ -6,39 +6,45 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; -public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect { +public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect +{ - @Getter - public final ItemStack outputStack; - public int tickLimit; + @Getter + public final ItemStack outputStack; + public int tickLimit; - public AlchemyArrayEffectCrafting(ItemStack outputStack) { - this(outputStack, 200); - } - - public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit) { - this.outputStack = outputStack; - this.tickLimit = tickLimit; - } + public AlchemyArrayEffectCrafting(ItemStack outputStack) + { + this(outputStack, 200); + } - @Override - public boolean update(TileEntity tile, int ticksActive) { - //TODO: Add recipe rechecking to verify nothing screwy is going on. - if(tile.getWorld().isRemote) { - return false; - } - - if(ticksActive >= tickLimit){ - BlockPos pos = tile.getPos(); + public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit) + { + this.outputStack = outputStack; + this.tickLimit = tickLimit; + } - ItemStack output = outputStack.copy(); - EntityItem outputEntity = new EntityItem(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output); + @Override + public boolean update(TileEntity tile, int ticksActive) + { + // TODO: Add recipe rechecking to verify nothing screwy is going on. + if (tile.getWorld().isRemote) + { + return false; + } - tile.getWorld().spawnEntityInWorld(outputEntity); + if (ticksActive >= tickLimit) + { + BlockPos pos = tile.getPos(); - return true; - } - - return false; - } + ItemStack output = outputStack.copy(); + EntityItem outputEntity = new EntityItem(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output); + + tile.getWorld().spawnEntityInWorld(outputEntity); + + return true; + } + + return false; + } } diff --git a/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyCircleRenderer.java b/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyCircleRenderer.java index 8e5d6753..32fded29 100644 --- a/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyCircleRenderer.java +++ b/src/main/java/WayofTime/bloodmagic/api/alchemyCrafting/AlchemyCircleRenderer.java @@ -9,132 +9,146 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; -public class AlchemyCircleRenderer { +public class AlchemyCircleRenderer +{ - public float offsetFromFace = -0.9f; - public final ResourceLocation arrayResource; + public float offsetFromFace = -0.9f; + public final ResourceLocation arrayResource; - public AlchemyCircleRenderer() { - this(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png")); - } - - public AlchemyCircleRenderer(ResourceLocation arrayResource) { - this.arrayResource = arrayResource; - } + public AlchemyCircleRenderer() + { + this(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png")); + } - public float getRotation(float craftTime) { - float offset = 2; - if (craftTime >= offset) { - float modifier = (float) Math.pow(craftTime - offset, 1.5); - return modifier * 1f; - } - return 0; - } + public AlchemyCircleRenderer(ResourceLocation arrayResource) + { + this.arrayResource = arrayResource; + } - public float getSecondaryRotation(float craftTime) { - float offset = 50; - if (craftTime >= offset) { - float modifier = (float) Math.pow(craftTime - offset, 1.7); - return modifier * 0.5f; - } - return 0; - } + public float getRotation(float craftTime) + { + float offset = 2; + if (craftTime >= offset) + { + float modifier = (float) Math.pow(craftTime - offset, 1.5); + return modifier * 1f; + } + return 0; + } - public float getSizeModifier(float craftTime) { - if (craftTime >= 150 && craftTime <= 250) { - return (200 - craftTime) / 50f; - } - return 1.0f; - } + public float getSecondaryRotation(float craftTime) + { + float offset = 50; + if (craftTime >= offset) + { + float modifier = (float) Math.pow(craftTime - offset, 1.7); + return modifier * 0.5f; + } + return 0; + } - public float getVerticalOffset(float craftTime) { - if (craftTime >= 5) { - if (craftTime <= 40) { - return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3)); - } else { - return -0.4f; - } - } - return 0; - } + public float getSizeModifier(float craftTime) + { + if (craftTime >= 150 && craftTime <= 250) + { + return (200 - craftTime) / 50f; + } + return 1.0f; + } - public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) { - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer wr = tessellator.getWorldRenderer(); + public float getVerticalOffset(float craftTime) + { + if (craftTime >= 5) + { + if (craftTime <= 40) + { + return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3)); + } else + { + return -0.4f; + } + } + return 0; + } - GlStateManager.pushMatrix(); - // float rot = (float)(this.worldObj.provider.getWorldTime() % (360 / - // this.rotationspeed) * this.rotationspeed) + this.rotationspeed * f; - float rot = getRotation(craftTime); - float secondaryRot = getSecondaryRotation(craftTime); + public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) + { + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer wr = tessellator.getWorldRenderer(); - float size = 1.0F * getSizeModifier(craftTime); + GlStateManager.pushMatrix(); + // float rot = (float)(this.worldObj.provider.getWorldTime() % (360 / + // this.rotationspeed) * this.rotationspeed) + this.rotationspeed * f; + float rot = getRotation(craftTime); + float secondaryRot = getSecondaryRotation(craftTime); - // Bind the texture to the circle - Minecraft.getMinecraft().renderEngine.bindTexture(arrayResource); + float size = 1.0F * getSizeModifier(craftTime); - GlStateManager.disableCull(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(770, 1); + // Bind the texture to the circle + Minecraft.getMinecraft().renderEngine.bindTexture(arrayResource); - GlStateManager.translate(x, y, z); + GlStateManager.disableCull(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(770, 1); - EnumFacing sideHit = EnumFacing.UP; // Specify which face this "circle" - // is located on - GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() - * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace); + GlStateManager.translate(x, y, z); - switch (sideHit) { - case DOWN: - GlStateManager.translate(0, 0, 1); - GlStateManager.rotate(-90.0f, 1, 0, 0); - break; - case EAST: - GlStateManager.rotate(-90.0f, 0, 1, 0); - GlStateManager.translate(0, 0, -1); - break; - case NORTH: - break; - case SOUTH: - GlStateManager.rotate(180.0f, 0, 1, 0); - GlStateManager.translate(-1, 0, -1); - break; - case UP: - GlStateManager.translate(0, 1, 0); - GlStateManager.rotate(90.0f, 1, 0, 0); - break; - case WEST: - GlStateManager.translate(0, 0, 1); - GlStateManager.rotate(90.0f, 0, 1, 0); - break; - } + EnumFacing sideHit = EnumFacing.UP; // Specify which face this "circle" + // is located on + GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace); - GlStateManager.pushMatrix(); - GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime)); - GlStateManager.rotate(rot, 0, 0, 1); - GlStateManager.rotate(secondaryRot, 1, 0, 0); - GlStateManager.rotate(secondaryRot * 0.45812f, 0, 0, 1); - double var31 = 0.0D; - double var33 = 1.0D; - double var35 = 0; - double var37 = 1; + switch (sideHit) + { + case DOWN: + GlStateManager.translate(0, 0, 1); + GlStateManager.rotate(-90.0f, 1, 0, 0); + break; + case EAST: + GlStateManager.rotate(-90.0f, 0, 1, 0); + GlStateManager.translate(0, 0, -1); + break; + case NORTH: + break; + case SOUTH: + GlStateManager.rotate(180.0f, 0, 1, 0); + GlStateManager.translate(-1, 0, -1); + break; + case UP: + GlStateManager.translate(0, 1, 0); + GlStateManager.rotate(90.0f, 1, 0, 0); + break; + case WEST: + GlStateManager.translate(0, 0, 1); + GlStateManager.rotate(90.0f, 0, 1, 0); + break; + } - GlStateManager.color(0.5f, 1f, 1f, 1f); - wr.begin(7, DefaultVertexFormats.POSITION_TEX); - // wr.setBrightness(200); - wr.pos(size / 2f, size / 2f, 0.0D).tex(var33, var37).endVertex(); - wr.pos(size / 2f, -size / 2f, 0.0D).tex(var33, var35).endVertex(); - wr.pos(-size / 2f, -size / 2f, 0.0D).tex(var31, var35).endVertex(); - wr.pos(-size / 2f, size / 2f, 0.0D).tex(var31, var37).endVertex(); - tessellator.draw(); + GlStateManager.pushMatrix(); + GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime)); + GlStateManager.rotate(rot, 0, 0, 1); + GlStateManager.rotate(secondaryRot, 1, 0, 0); + GlStateManager.rotate(secondaryRot * 0.45812f, 0, 0, 1); + double var31 = 0.0D; + double var33 = 1.0D; + double var35 = 0; + double var37 = 1; - GlStateManager.popMatrix(); + GlStateManager.color(0.5f, 1f, 1f, 1f); + wr.begin(7, DefaultVertexFormats.POSITION_TEX); + // wr.setBrightness(200); + wr.pos(size / 2f, size / 2f, 0.0D).tex(var33, var37).endVertex(); + wr.pos(size / 2f, -size / 2f, 0.0D).tex(var33, var35).endVertex(); + wr.pos(-size / 2f, -size / 2f, 0.0D).tex(var31, var35).endVertex(); + wr.pos(-size / 2f, size / 2f, 0.0D).tex(var31, var37).endVertex(); + tessellator.draw(); - // GlStateManager.depthMask(true); - GlStateManager.disableBlend(); - GlStateManager.enableCull(); - // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.popMatrix(); - GlStateManager.popMatrix(); - } + // GlStateManager.depthMask(true); + GlStateManager.disableBlend(); + GlStateManager.enableCull(); + // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + GlStateManager.popMatrix(); + } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/api/altar/AltarComponent.java b/src/main/java/WayofTime/bloodmagic/api/altar/AltarComponent.java index bad9b03c..b5f3f8b7 100644 --- a/src/main/java/WayofTime/bloodmagic/api/altar/AltarComponent.java +++ b/src/main/java/WayofTime/bloodmagic/api/altar/AltarComponent.java @@ -7,7 +7,8 @@ import net.minecraft.util.BlockPos; * Used for building the altar structure. */ @Getter -public class AltarComponent { +public class AltarComponent +{ private BlockPos offset; private boolean upgradeSlot; @@ -16,11 +17,14 @@ public class AltarComponent { /** * Sets a component location for the altar. - * - * @param offset - Where the block should be in relation to the Altar - * @param component - The type of Component the location should contain + * + * @param offset + * - Where the block should be in relation to the Altar + * @param component + * - The type of Component the location should contain */ - public AltarComponent(BlockPos offset, EnumAltarComponent component) { + public AltarComponent(BlockPos offset, EnumAltarComponent component) + { this.offset = offset; this.component = component; } @@ -29,16 +33,18 @@ public class AltarComponent { * Use for setting a location at which there must be a block, but the type * of block does not matter. */ - public AltarComponent(BlockPos offset) { + public AltarComponent(BlockPos offset) + { this(offset, EnumAltarComponent.NOTAIR); } /** * Sets the location to an upgrade slot. - * + * * @return the current instance for further use. */ - public AltarComponent setUpgradeSlot() { + public AltarComponent setUpgradeSlot() + { this.upgradeSlot = true; return this; } diff --git a/src/main/java/WayofTime/bloodmagic/api/altar/AltarUpgrade.java b/src/main/java/WayofTime/bloodmagic/api/altar/AltarUpgrade.java index 11a6e0af..13e5c775 100644 --- a/src/main/java/WayofTime/bloodmagic/api/altar/AltarUpgrade.java +++ b/src/main/java/WayofTime/bloodmagic/api/altar/AltarUpgrade.java @@ -7,7 +7,8 @@ import lombok.NoArgsConstructor; @Getter @NoArgsConstructor @AllArgsConstructor -public class AltarUpgrade { +public class AltarUpgrade +{ private int speedCount; private int efficiencyCount; @@ -21,47 +22,56 @@ public class AltarUpgrade { // Adders - public AltarUpgrade addSpeed() { + public AltarUpgrade addSpeed() + { speedCount++; return this; } - public AltarUpgrade addEfficiency() { + public AltarUpgrade addEfficiency() + { efficiencyCount++; return this; } - public AltarUpgrade addSacrifice() { + public AltarUpgrade addSacrifice() + { sacrificeCount++; return this; } - public AltarUpgrade addSelfSacrifice() { + public AltarUpgrade addSelfSacrifice() + { selfSacrificeCount++; return this; } - public AltarUpgrade addDisplacement() { + public AltarUpgrade addDisplacement() + { displacementCount++; return this; } - public AltarUpgrade addCapacity() { + public AltarUpgrade addCapacity() + { capacityCount++; return this; } - public AltarUpgrade addOrbCapacity() { + public AltarUpgrade addOrbCapacity() + { orbCapacityCount++; return this; } - public AltarUpgrade addBetterCapacity() { + public AltarUpgrade addBetterCapacity() + { betterCapacityCount++; return this; } - public AltarUpgrade addAcceleration() { + public AltarUpgrade addAcceleration() + { accelerationCount++; return this; } diff --git a/src/main/java/WayofTime/bloodmagic/api/altar/EnumAltarComponent.java b/src/main/java/WayofTime/bloodmagic/api/altar/EnumAltarComponent.java index d7b1a4f8..3102d87d 100644 --- a/src/main/java/WayofTime/bloodmagic/api/altar/EnumAltarComponent.java +++ b/src/main/java/WayofTime/bloodmagic/api/altar/EnumAltarComponent.java @@ -1,11 +1,7 @@ package WayofTime.bloodmagic.api.altar; -public enum EnumAltarComponent { +public enum EnumAltarComponent +{ - GLOWSTONE, - BLOODSTONE, - BEACON, - BLOODRUNE, - CRYSTAL, - NOTAIR + GLOWSTONE, BLOODSTONE, BEACON, BLOODRUNE, CRYSTAL, NOTAIR } diff --git a/src/main/java/WayofTime/bloodmagic/api/altar/EnumAltarTier.java b/src/main/java/WayofTime/bloodmagic/api/altar/EnumAltarTier.java index 92ed0991..d53deebc 100644 --- a/src/main/java/WayofTime/bloodmagic/api/altar/EnumAltarTier.java +++ b/src/main/java/WayofTime/bloodmagic/api/altar/EnumAltarTier.java @@ -6,11 +6,13 @@ import net.minecraft.util.BlockPos; import java.util.ArrayList; @Getter -public enum EnumAltarTier { - ONE(), - TWO() { +public enum EnumAltarTier +{ + ONE(), TWO() + { @Override - public void buildComponents() { + public void buildComponents() + { altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), EnumAltarComponent.BLOODRUNE)); altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(1, -1, -1), EnumAltarComponent.BLOODRUNE)); @@ -21,9 +23,11 @@ public enum EnumAltarTier { altarComponents.add(new AltarComponent(new BlockPos(1, -1, 1), EnumAltarComponent.BLOODRUNE)); } }, - THREE() { + THREE() + { @Override - public void buildComponents() { + public void buildComponents() + { altarComponents.addAll(TWO.getAltarComponents()); altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); @@ -46,7 +50,8 @@ public enum EnumAltarTier { altarComponents.add(new AltarComponent(new BlockPos(-3, 1, 3), EnumAltarComponent.GLOWSTONE)); altarComponents.add(new AltarComponent(new BlockPos(3, 1, 3), EnumAltarComponent.GLOWSTONE)); - for (int i = -2; i <= 2; i++) { + for (int i = -2; i <= 2; i++) + { altarComponents.add(new AltarComponent(new BlockPos(3, -2, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(-3, -2, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(i, -2, 3), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); @@ -54,19 +59,23 @@ public enum EnumAltarTier { } } }, - FOUR() { + FOUR() + { @Override - public void buildComponents() { + public void buildComponents() + { altarComponents.addAll(THREE.getAltarComponents()); - for (int i = -3; i <= 3; i++) { + for (int i = -3; i <= 3; i++) + { altarComponents.add(new AltarComponent(new BlockPos(5, -3, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(-5, -3, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(i, -3, 5), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(i, -3, -5), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); } - for (int i = -2; i <= 1; i++) { + for (int i = -2; i <= 1; i++) + { altarComponents.add(new AltarComponent(new BlockPos(5, i, 5))); altarComponents.add(new AltarComponent(new BlockPos(5, i, -5))); altarComponents.add(new AltarComponent(new BlockPos(-5, i, -5))); @@ -79,16 +88,19 @@ public enum EnumAltarTier { altarComponents.add(new AltarComponent(new BlockPos(-5, 2, 5), EnumAltarComponent.BLOODSTONE)); } }, - FIVE() { + FIVE() + { @Override - public void buildComponents() { + public void buildComponents() + { altarComponents.addAll(FOUR.getAltarComponents()); altarComponents.add(new AltarComponent(new BlockPos(-8, -3, 8), EnumAltarComponent.BEACON)); altarComponents.add(new AltarComponent(new BlockPos(-8, -3, -8), EnumAltarComponent.BEACON)); altarComponents.add(new AltarComponent(new BlockPos(8, -3, -8), EnumAltarComponent.BEACON)); altarComponents.add(new AltarComponent(new BlockPos(8, -3, 8), EnumAltarComponent.BEACON)); - for (int i = -6; i <= 6; i++) { + for (int i = -6; i <= 6; i++) + { altarComponents.add(new AltarComponent(new BlockPos(8, -4, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(-8, -4, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(i, -4, 8), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); @@ -96,12 +108,15 @@ public enum EnumAltarTier { } } }, - SIX() { + SIX() + { @Override - public void buildComponents() { + public void buildComponents() + { altarComponents.addAll(FIVE.getAltarComponents()); - for (int i = -4; i <= 2; i++) { + for (int i = -4; i <= 2; i++) + { altarComponents.add(new AltarComponent(new BlockPos(11, i, 11))); altarComponents.add(new AltarComponent(new BlockPos(-11, i, -11))); altarComponents.add(new AltarComponent(new BlockPos(11, i, -11))); @@ -113,7 +128,8 @@ public enum EnumAltarTier { altarComponents.add(new AltarComponent(new BlockPos(11, 3, -11), EnumAltarComponent.CRYSTAL)); altarComponents.add(new AltarComponent(new BlockPos(-11, 3, 11), EnumAltarComponent.CRYSTAL)); - for (int i = -9; i <= 9; i++) { + for (int i = -9; i <= 9; i++) + { altarComponents.add(new AltarComponent(new BlockPos(11, -5, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(-11, -5, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); altarComponents.add(new AltarComponent(new BlockPos(i, -5, 11), EnumAltarComponent.BLOODRUNE).setUpgradeSlot()); @@ -126,11 +142,13 @@ public enum EnumAltarTier { ArrayList altarComponents = new ArrayList(); - public void buildComponents() { + public void buildComponents() + { } - public int toInt() { + public int toInt() + { return ordinal() + 1; } } diff --git a/src/main/java/WayofTime/bloodmagic/api/altar/IAltarComponent.java b/src/main/java/WayofTime/bloodmagic/api/altar/IAltarComponent.java index d3cea101..7c26635c 100644 --- a/src/main/java/WayofTime/bloodmagic/api/altar/IAltarComponent.java +++ b/src/main/java/WayofTime/bloodmagic/api/altar/IAltarComponent.java @@ -1,6 +1,7 @@ package WayofTime.bloodmagic.api.altar; -public interface IAltarComponent { +public interface IAltarComponent +{ EnumAltarComponent getType(int meta); } diff --git a/src/main/java/WayofTime/bloodmagic/api/altar/IAltarManipulator.java b/src/main/java/WayofTime/bloodmagic/api/altar/IAltarManipulator.java index 0c8c2d48..1c846da3 100644 --- a/src/main/java/WayofTime/bloodmagic/api/altar/IAltarManipulator.java +++ b/src/main/java/WayofTime/bloodmagic/api/altar/IAltarManipulator.java @@ -1,8 +1,9 @@ package WayofTime.bloodmagic.api.altar; /** - * Any item that implements this interface will not be pulled into the Altar - * on right click. + * Any item that implements this interface will not be pulled into the Altar on + * right click. */ -public interface IAltarManipulator { +public interface IAltarManipulator +{ } diff --git a/src/main/java/WayofTime/bloodmagic/api/altar/IBloodAltar.java b/src/main/java/WayofTime/bloodmagic/api/altar/IBloodAltar.java index 93026308..eeff591e 100644 --- a/src/main/java/WayofTime/bloodmagic/api/altar/IBloodAltar.java +++ b/src/main/java/WayofTime/bloodmagic/api/altar/IBloodAltar.java @@ -1,6 +1,7 @@ package WayofTime.bloodmagic.api.altar; -public interface IBloodAltar { +public interface IBloodAltar +{ int getCapacity(); @@ -31,18 +32,20 @@ public interface IBloodAltar { void startCycle(); void checkTier(); - + boolean isActive(); - + void setActive(); - + int fillMainTank(int amount); /** - * Will set the altar to initiate a cooldown cycle after it crafts before starting to craft again, giving the user time to interact with the altar. + * Will set the altar to initiate a cooldown cycle after it crafts before + * starting to craft again, giving the user time to interact with the altar. * This can only be set while the altar is not active. - * - * @param cooldown - How long the cooldown should last + * + * @param cooldown + * - How long the cooldown should last */ void requestPauseAfterCrafting(int cooldown); } diff --git a/src/main/java/WayofTime/bloodmagic/api/compress/CompressionHandler.java b/src/main/java/WayofTime/bloodmagic/api/compress/CompressionHandler.java index ddb123e4..0b5e7792 100644 --- a/src/main/java/WayofTime/bloodmagic/api/compress/CompressionHandler.java +++ b/src/main/java/WayofTime/bloodmagic/api/compress/CompressionHandler.java @@ -3,12 +3,16 @@ package WayofTime.bloodmagic.api.compress; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public abstract class CompressionHandler { +public abstract class CompressionHandler +{ /** - * Called to look at the inventory and syphons the required stack. Returns resultant stack if successful, and null if not. - * @param inv The inventory iterated through - * @return The result of the compression + * Called to look at the inventory and syphons the required stack. Returns + * resultant stack if successful, and null if not. + * + * @param inv + * The inventory iterated through + * @return The result of the compression */ public abstract ItemStack compressInventory(ItemStack[] inv, World world); } diff --git a/src/main/java/WayofTime/bloodmagic/api/compress/CompressionRegistry.java b/src/main/java/WayofTime/bloodmagic/api/compress/CompressionRegistry.java index 70c72084..44707126 100644 --- a/src/main/java/WayofTime/bloodmagic/api/compress/CompressionRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/compress/CompressionRegistry.java @@ -9,31 +9,40 @@ import java.util.List; import java.util.Map; /** - * A registry aimed to help compress items in an inventory into its compressible form. + * A registry aimed to help compress items in an inventory into its compressible + * form. */ -public class CompressionRegistry { +public class CompressionRegistry +{ public static List compressionRegistry = new ArrayList(); public static Map thresholdMap = new HashMap(); - public static void registerHandler(CompressionHandler handler) { + public static void registerHandler(CompressionHandler handler) + { compressionRegistry.add(handler); } /** * Registers an item so that it only compresses while above this threshold - * - * @param stack item/block to be compressed - * @param threshold amount that is to be compressed + * + * @param stack + * item/block to be compressed + * @param threshold + * amount that is to be compressed */ - public static void registerItemThreshold(ItemStack stack, int threshold) { + public static void registerItemThreshold(ItemStack stack, int threshold) + { thresholdMap.put(stack, threshold); } - public static ItemStack compressInventory(ItemStack[] inv, World world) { - for (CompressionHandler handler : compressionRegistry) { + public static ItemStack compressInventory(ItemStack[] inv, World world) + { + for (CompressionHandler handler : compressionRegistry) + { ItemStack stack = handler.compressInventory(inv, world); - if (stack != null) { + if (stack != null) + { return stack; } } @@ -41,9 +50,12 @@ public class CompressionRegistry { return null; } - public static int getItemThreshold(ItemStack stack) { - for (Map.Entry entry : thresholdMap.entrySet()) { - if (areItemStacksEqual(entry.getKey(), stack)) { + public static int getItemThreshold(ItemStack stack) + { + for (Map.Entry entry : thresholdMap.entrySet()) + { + if (areItemStacksEqual(entry.getKey(), stack)) + { return entry.getValue(); } } @@ -51,7 +63,8 @@ public class CompressionRegistry { return 0; } - public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack) { + public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack) + { return stack.isItemEqual(compressedStack) && (stack.getTagCompound() == null ? compressedStack.getTagCompound() == null : stack.getTagCompound().equals(compressedStack.getTagCompound())); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/event/AddToNetworkEvent.java b/src/main/java/WayofTime/bloodmagic/api/event/AddToNetworkEvent.java index 7e7a4ea8..e58c54ca 100644 --- a/src/main/java/WayofTime/bloodmagic/api/event/AddToNetworkEvent.java +++ b/src/main/java/WayofTime/bloodmagic/api/event/AddToNetworkEvent.java @@ -2,21 +2,27 @@ package WayofTime.bloodmagic.api.event; import net.minecraftforge.fml.common.eventhandler.Event; -public class AddToNetworkEvent extends Event { +public class AddToNetworkEvent extends Event +{ public String ownerNetwork; public int addedAmount; public int maximum; /** - * This event is called whenever the network is added to. If cancelled, no LP will be drained from the source. If result is set to Result.DENY, - * the LP will still be drained but the soul network will not be added to. - * - * @param ownerNetwork Key used for the soul network - * @param addedAmount Amount added - * @param maximum Ceiling that the network can add to + * This event is called whenever the network is added to. If cancelled, no + * LP will be drained from the source. If result is set to Result.DENY, the + * LP will still be drained but the soul network will not be added to. + * + * @param ownerNetwork + * Key used for the soul network + * @param addedAmount + * Amount added + * @param maximum + * Ceiling that the network can add to */ - public AddToNetworkEvent(String ownerNetwork, int addedAmount, int maximum) { + public AddToNetworkEvent(String ownerNetwork, int addedAmount, int maximum) + { this.ownerNetwork = ownerNetwork; this.addedAmount = addedAmount; this.maximum = maximum; diff --git a/src/main/java/WayofTime/bloodmagic/api/event/BoundToolEvent.java b/src/main/java/WayofTime/bloodmagic/api/event/BoundToolEvent.java index 55edea89..2ac08665 100644 --- a/src/main/java/WayofTime/bloodmagic/api/event/BoundToolEvent.java +++ b/src/main/java/WayofTime/bloodmagic/api/event/BoundToolEvent.java @@ -5,32 +5,38 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; -public class BoundToolEvent extends Event { +public class BoundToolEvent extends Event +{ public EntityPlayer player; - public BoundToolEvent(EntityPlayer player) { + public BoundToolEvent(EntityPlayer player) + { this.player = player; } @Cancelable - public static class Charge extends BoundToolEvent { + public static class Charge extends BoundToolEvent + { public ItemStack result; - public Charge(EntityPlayer player, ItemStack result) { + public Charge(EntityPlayer player, ItemStack result) + { super(player); this.result = result; } } @Cancelable - public static class Release extends BoundToolEvent { + public static class Release extends BoundToolEvent + { public final ItemStack boundTool; public int charge; - public Release(EntityPlayer player, ItemStack boundTool, int charge) { + public Release(EntityPlayer player, ItemStack boundTool, int charge) + { super(player); this.boundTool = boundTool; this.charge = charge; diff --git a/src/main/java/WayofTime/bloodmagic/api/event/ItemBindEvent.java b/src/main/java/WayofTime/bloodmagic/api/event/ItemBindEvent.java index 4b7ef268..16ef1981 100644 --- a/src/main/java/WayofTime/bloodmagic/api/event/ItemBindEvent.java +++ b/src/main/java/WayofTime/bloodmagic/api/event/ItemBindEvent.java @@ -6,13 +6,15 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; @Cancelable -public class ItemBindEvent extends Event { +public class ItemBindEvent extends Event +{ public final EntityPlayer player; public String key; public ItemStack itemStack; - public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack) { + public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack) + { super(); this.player = player; this.key = key; diff --git a/src/main/java/WayofTime/bloodmagic/api/event/RitualEvent.java b/src/main/java/WayofTime/bloodmagic/api/event/RitualEvent.java index e01c013b..2039437d 100644 --- a/src/main/java/WayofTime/bloodmagic/api/event/RitualEvent.java +++ b/src/main/java/WayofTime/bloodmagic/api/event/RitualEvent.java @@ -12,30 +12,35 @@ import net.minecraft.world.World; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; -public class RitualEvent extends Event { +public class RitualEvent extends Event +{ public final IMasterRitualStone mrs; public final String ownerName; public final Ritual ritual; - private RitualEvent(IMasterRitualStone mrs, String ownerName, Ritual ritual) { + private RitualEvent(IMasterRitualStone mrs, String ownerName, Ritual ritual) + { this.mrs = mrs; this.ownerName = ownerName; this.ritual = ritual; } /** - * This event is called when a ritual is activated. If cancelled, it will not activate. - * + * This event is called when a ritual is activated. If cancelled, it will + * not activate. + * * {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)} */ @Cancelable - public static class RitualActivatedEvent extends RitualEvent { + public static class RitualActivatedEvent extends RitualEvent + { public final EntityPlayer player; public final ItemStack crystalStack; public int crystalTier; - public RitualActivatedEvent(IMasterRitualStone mrs, String owner, Ritual ritual, EntityPlayer player, ItemStack activationCrystal, int crystalTier) { + public RitualActivatedEvent(IMasterRitualStone mrs, String owner, Ritual ritual, EntityPlayer player, ItemStack activationCrystal, int crystalTier) + { super(mrs, owner, ritual); this.player = player; @@ -45,28 +50,34 @@ public class RitualEvent extends Event { } /** - * This event is called when a Ritual effect is performed. If cancelled, the effect will not happen. - * + * This event is called when a Ritual effect is performed. If cancelled, the + * effect will not happen. + * * {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)} */ @Cancelable - public static class RitualRunEvent extends RitualEvent { + public static class RitualRunEvent extends RitualEvent + { - public RitualRunEvent(IMasterRitualStone mrs, String owner, Ritual ritual) { + public RitualRunEvent(IMasterRitualStone mrs, String owner, Ritual ritual) + { super(mrs, owner, ritual); } } /** - * This event is called when a Ritual is stopped by a {@link Ritual.BreakType}. - * + * This event is called when a Ritual is stopped by a + * {@link Ritual.BreakType}. + * * {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(Ritual.BreakType)} * */ - public static class RitualStopEvent extends RitualEvent { + public static class RitualStopEvent extends RitualEvent + { public final Ritual.BreakType method; - public RitualStopEvent(IMasterRitualStone mrs, String owner, Ritual ritual, Ritual.BreakType method) { + public RitualStopEvent(IMasterRitualStone mrs, String owner, Ritual ritual, Ritual.BreakType method) + { super(mrs, owner, ritual); this.method = method; @@ -74,13 +85,15 @@ public class RitualEvent extends Event { } @Cancelable - public static class ImperfectRitualActivatedEvent extends Event { + public static class ImperfectRitualActivatedEvent extends Event + { public final IImperfectRitualStone ims; public final String ownerName; public final ImperfectRitual imperfectRitual; - public ImperfectRitualActivatedEvent(IImperfectRitualStone ims, String ownerName, ImperfectRitual imperfectRitual) { + public ImperfectRitualActivatedEvent(IImperfectRitualStone ims, String ownerName, ImperfectRitual imperfectRitual) + { this.ims = ims; this.ownerName = ownerName; this.imperfectRitual = imperfectRitual; diff --git a/src/main/java/WayofTime/bloodmagic/api/event/SacrificeKnifeUsedEvent.java b/src/main/java/WayofTime/bloodmagic/api/event/SacrificeKnifeUsedEvent.java index 7b28d4ec..e1db5173 100644 --- a/src/main/java/WayofTime/bloodmagic/api/event/SacrificeKnifeUsedEvent.java +++ b/src/main/java/WayofTime/bloodmagic/api/event/SacrificeKnifeUsedEvent.java @@ -5,13 +5,15 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; @Cancelable -public class SacrificeKnifeUsedEvent extends Event { +public class SacrificeKnifeUsedEvent extends Event +{ public final EntityPlayer player; public final int healthDrained; public boolean shouldDrainHealth; public boolean shouldFillAltar; - public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp) { + public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp) + { this.player = player; this.shouldDrainHealth = shouldDrainHealth; this.shouldFillAltar = shouldFillAltar; diff --git a/src/main/java/WayofTime/bloodmagic/api/event/SoulNetworkEvent.java b/src/main/java/WayofTime/bloodmagic/api/event/SoulNetworkEvent.java index 4d45b3a5..009eb4b3 100644 --- a/src/main/java/WayofTime/bloodmagic/api/event/SoulNetworkEvent.java +++ b/src/main/java/WayofTime/bloodmagic/api/event/SoulNetworkEvent.java @@ -5,34 +5,41 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; -public class SoulNetworkEvent extends Event { +public class SoulNetworkEvent extends Event +{ public final String ownerName; public int syphon; - public SoulNetworkEvent(String ownerName, int syphon) { + public SoulNetworkEvent(String ownerName, int syphon) + { this.ownerName = ownerName; this.syphon = syphon; } @Cancelable - public static class ItemDrainInContainerEvent extends SoulNetworkEvent { + public static class ItemDrainInContainerEvent extends SoulNetworkEvent + { public ItemStack stack; - public ItemDrainInContainerEvent(ItemStack stack, String ownerName, int syphon) { + public ItemDrainInContainerEvent(ItemStack stack, String ownerName, int syphon) + { super(ownerName, syphon); this.stack = stack; } } @Cancelable - public static class PlayerDrainNetworkEvent extends SoulNetworkEvent { + public static class PlayerDrainNetworkEvent extends SoulNetworkEvent + { public final EntityPlayer player; - public boolean shouldDamage; //If true, will damage regardless of if the network had enough inside it + public boolean shouldDamage; // If true, will damage regardless of if + // the network had enough inside it - public PlayerDrainNetworkEvent(EntityPlayer player, String ownerNetwork, int drainAmount) { + public PlayerDrainNetworkEvent(EntityPlayer player, String ownerNetwork, int drainAmount) + { super(ownerNetwork, drainAmount); this.shouldDamage = false; this.player = player; @@ -40,20 +47,28 @@ public class SoulNetworkEvent extends Event { } @Cancelable - public static class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent { + public static class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent + { public final ItemStack itemStack; - public float damageAmount; //Amount of damage that would incur if the network could not drain properly + public float damageAmount; // Amount of damage that would incur if the + // network could not drain properly /** - * Set result to deny the action i.e. damage/drain anyways. Cancelling event prevents action without penalties - * - * @param player Player using the item - * @param ownerNetwork Network that the item is tied to - * @param itemStack Item used - * @param drainAmount Original drain amount - change to alter cost + * Set result to deny the action i.e. damage/drain anyways. Cancelling + * event prevents action without penalties + * + * @param player + * Player using the item + * @param ownerNetwork + * Network that the item is tied to + * @param itemStack + * Item used + * @param drainAmount + * Original drain amount - change to alter cost */ - public ItemDrainNetworkEvent(EntityPlayer player, String ownerNetwork, ItemStack itemStack, int drainAmount) { + public ItemDrainNetworkEvent(EntityPlayer player, String ownerNetwork, ItemStack itemStack, int drainAmount) + { super(player, ownerNetwork, drainAmount); this.itemStack = itemStack; this.damageAmount = (float) (drainAmount) / 100.0f; diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/IAltarReader.java b/src/main/java/WayofTime/bloodmagic/api/iface/IAltarReader.java index 9d9ff367..8666eeac 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/IAltarReader.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/IAltarReader.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.api.iface; -public interface IAltarReader { +public interface IAltarReader +{ } diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/IBindable.java b/src/main/java/WayofTime/bloodmagic/api/iface/IBindable.java index d2dc3cbc..55f45d0f 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/IBindable.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/IBindable.java @@ -6,11 +6,12 @@ import net.minecraft.item.ItemStack; /** * Implement this interface on any Item that can be bound to a player. */ -public interface IBindable { +public interface IBindable +{ /** * Called when the player attempts to bind the item. - * + * * If false, binding fails. */ boolean onBind(EntityPlayer player, ItemStack stack); diff --git a/src/main/java/WayofTime/bloodmagic/api/iface/ISigil.java b/src/main/java/WayofTime/bloodmagic/api/iface/ISigil.java index b43036df..2ca43928 100644 --- a/src/main/java/WayofTime/bloodmagic/api/iface/ISigil.java +++ b/src/main/java/WayofTime/bloodmagic/api/iface/ISigil.java @@ -1,4 +1,5 @@ package WayofTime.bloodmagic.api.iface; -public interface ISigil { +public interface ISigil +{ } diff --git a/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourHandler.java b/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourHandler.java index dc05208f..31f2556f 100644 --- a/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourHandler.java +++ b/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourHandler.java @@ -7,55 +7,68 @@ import java.util.List; import net.minecraft.nbt.NBTTagCompound; -public class LivingArmourHandler { - public static List> trackers = new ArrayList(); - public static HashMap> upgradeMap = new HashMap(); - public static HashMap> upgradeConstructorMap = new HashMap(); +public class LivingArmourHandler +{ + public static List> trackers = new ArrayList(); + public static HashMap> upgradeMap = new HashMap(); + public static HashMap> upgradeConstructorMap = new HashMap(); - public static void registerStatTracker(Class tracker) { - trackers.add(tracker); - } + public static void registerStatTracker(Class tracker) + { + trackers.add(tracker); + } - /** - * Registers a LivingArmourUpgrade using its unique identifier and class. - * This is done to more easily load upgrades - * - * @param upgrade - */ - public static void registerArmourUpgrade(LivingArmourUpgrade upgrade) { - Class clazz = upgrade.getClass(); - upgradeMap.put(upgrade.getUniqueIdentifier(), clazz); - try { - Constructor ctor = clazz.getConstructor(int.class); - if (ctor == null) { - // TODO: This is bad - add something to the log - } else { - upgradeConstructorMap.put(upgrade.getUniqueIdentifier(), ctor); - } - } catch (Exception e) { - e.printStackTrace(); - } + /** + * Registers a LivingArmourUpgrade using its unique identifier and class. + * This is done to more easily load upgrades + * + * @param upgrade + */ + public static void registerArmourUpgrade(LivingArmourUpgrade upgrade) + { + Class clazz = upgrade.getClass(); + upgradeMap.put(upgrade.getUniqueIdentifier(), clazz); + try + { + Constructor ctor = clazz.getConstructor(int.class); + if (ctor == null) + { + // TODO: This is bad - add something to the log + } else + { + upgradeConstructorMap.put(upgrade.getUniqueIdentifier(), ctor); + } + } catch (Exception e) + { + e.printStackTrace(); + } - } + } - public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level) { - return generateUpgradeFromKey(key, level, null); - } + public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level) + { + return generateUpgradeFromKey(key, level, null); + } - public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level, NBTTagCompound tag) { - Constructor ctor = upgradeConstructorMap.get(key); - if (ctor != null) { - try { - LivingArmourUpgrade upgrade = ctor.newInstance(level); - if (upgrade != null && tag != null) { - upgrade.readFromNBT(tag); - } - return upgrade; - } catch (Exception e) { - e.printStackTrace(); - } - } + public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level, NBTTagCompound tag) + { + Constructor ctor = upgradeConstructorMap.get(key); + if (ctor != null) + { + try + { + LivingArmourUpgrade upgrade = ctor.newInstance(level); + if (upgrade != null && tag != null) + { + upgrade.readFromNBT(tag); + } + return upgrade; + } catch (Exception e) + { + e.printStackTrace(); + } + } - return null; - } + return null; + } } diff --git a/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourUpgrade.java b/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourUpgrade.java index 5518dee1..60eb0d41 100644 --- a/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourUpgrade.java +++ b/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourUpgrade.java @@ -9,45 +9,50 @@ import WayofTime.bloodmagic.livingArmour.LivingArmour; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; -public abstract class LivingArmourUpgrade { +public abstract class LivingArmourUpgrade +{ - protected int level = 0; // Upgrade level 0 is the first upgrade. Upgrade - // goes from 0 to getMaxTier() - 1. + protected int level = 0; // Upgrade level 0 is the first upgrade. Upgrade + // goes from 0 to getMaxTier() - 1. - /** - * The LivingArmourUpgrade must have a constructor that has a single integer - * parameter. Upgrades may have other constructors, but must have one of - * these. - * - * @param level - * The level of the upgrade - */ - public LivingArmourUpgrade(int level) { - this.level = level; - } - - public int getUpgradeLevel() - { - return this.level; - } + /** + * The LivingArmourUpgrade must have a constructor that has a single integer + * parameter. Upgrades may have other constructors, but must have one of + * these. + * + * @param level + * The level of the upgrade + */ + public LivingArmourUpgrade(int level) + { + this.level = level; + } - public abstract String getUniqueIdentifier(); + public int getUpgradeLevel() + { + return this.level; + } - /** - * - * @return - */ - public abstract int getMaxTier(); - - public abstract int getCostOfUpgrade(); - - public void onTick(World world, EntityPlayer player, LivingArmour livingArmour){} + public abstract String getUniqueIdentifier(); - public Multimap getAttributeModifiers() { - return HashMultimap. create(); - } - - public abstract void writeToNBT(NBTTagCompound tag); - - public abstract void readFromNBT(NBTTagCompound tag); + /** + * + * @return + */ + public abstract int getMaxTier(); + + public abstract int getCostOfUpgrade(); + + public void onTick(World world, EntityPlayer player, LivingArmour livingArmour) + { + } + + public Multimap getAttributeModifiers() + { + return HashMultimap. create(); + } + + public abstract void writeToNBT(NBTTagCompound tag); + + public abstract void readFromNBT(NBTTagCompound tag); } diff --git a/src/main/java/WayofTime/bloodmagic/api/livingArmour/StatTracker.java b/src/main/java/WayofTime/bloodmagic/api/livingArmour/StatTracker.java index 5d156eda..ebc3f916 100644 --- a/src/main/java/WayofTime/bloodmagic/api/livingArmour/StatTracker.java +++ b/src/main/java/WayofTime/bloodmagic/api/livingArmour/StatTracker.java @@ -5,47 +5,51 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import WayofTime.bloodmagic.livingArmour.LivingArmour; -public abstract class StatTracker { +public abstract class StatTracker +{ - private boolean isDirty = false; + private boolean isDirty = false; - public abstract String getUniqueIdentifier(); + public abstract String getUniqueIdentifier(); - /** - * When called the StatTracker should reset all of its data, including - * upgrades. - */ - public abstract void resetTracker(); + /** + * When called the StatTracker should reset all of its data, including + * upgrades. + */ + public abstract void resetTracker(); - public abstract void readFromNBT(NBTTagCompound tag); + public abstract void readFromNBT(NBTTagCompound tag); - public abstract void writeToNBT(NBTTagCompound tag); + public abstract void writeToNBT(NBTTagCompound tag); - /** - * Called each tick to update the tracker's information. Called in - * LivingArmour - * - * @param world - * World the player is in - * @param player - * The player that has the armour equipped - * @param livingArmour - * The equipped LivingArmour - * @return True if there is a new upgrade unlocked this tick. - */ - public abstract boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour); + /** + * Called each tick to update the tracker's information. Called in + * LivingArmour + * + * @param world + * World the player is in + * @param player + * The player that has the armour equipped + * @param livingArmour + * The equipped LivingArmour + * @return True if there is a new upgrade unlocked this tick. + */ + public abstract boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour); - public abstract LivingArmourUpgrade[] getUpgrades(); + public abstract LivingArmourUpgrade[] getUpgrades(); - public final boolean isDirty() { - return isDirty; - } + public final boolean isDirty() + { + return isDirty; + } - public final void markDirty() { - this.isDirty = true; - } + public final void markDirty() + { + this.isDirty = true; + } - public final void resetDirty() { - this.isDirty = false; - } + public final void resetDirty() + { + this.isDirty = false; + } } diff --git a/src/main/java/WayofTime/bloodmagic/api/network/SoulNetwork.java b/src/main/java/WayofTime/bloodmagic/api/network/SoulNetwork.java index 8ff2cfca..36888812 100644 --- a/src/main/java/WayofTime/bloodmagic/api/network/SoulNetwork.java +++ b/src/main/java/WayofTime/bloodmagic/api/network/SoulNetwork.java @@ -22,14 +22,16 @@ import javax.annotation.Nullable; @Getter @Setter -public class SoulNetwork extends WorldSavedData { +public class SoulNetwork extends WorldSavedData +{ @Nullable private final EntityPlayer player; private int currentEssence; private int orbTier; - public SoulNetwork(String name) { + public SoulNetwork(String name) + { super(name); currentEssence = 0; @@ -38,18 +40,21 @@ public class SoulNetwork extends WorldSavedData { } @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { + public void readFromNBT(NBTTagCompound nbttagcompound) + { currentEssence = nbttagcompound.getInteger(Constants.NBT.CURRENT_ESSENCE); orbTier = nbttagcompound.getInteger(Constants.NBT.ORB_TIER); } @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { + public void writeToNBT(NBTTagCompound nbttagcompound) + { nbttagcompound.setInteger(Constants.NBT.CURRENT_ESSENCE, currentEssence); nbttagcompound.setInteger(Constants.NBT.ORB_TIER, orbTier); } - public int addLifeEssence(int toAdd, int maximum) { + public int addLifeEssence(int toAdd, int maximum) + { AddToNetworkEvent event = new AddToNetworkEvent(mapName, toAdd, maximum); if (MinecraftForge.EVENT_BUS.post(event)) @@ -61,7 +66,8 @@ public class SoulNetwork extends WorldSavedData { World world = MinecraftServer.getServer().worldServers[0]; SoulNetwork data = (SoulNetwork) world.loadItemData(SoulNetwork.class, event.ownerNetwork); - if (data == null) { + if (data == null) + { data = new SoulNetwork(event.ownerNetwork); world.setItemData(event.ownerNetwork, data); } @@ -83,8 +89,10 @@ public class SoulNetwork extends WorldSavedData { /** * Used to syphon LP from the network */ - public int syphon(int syphon) { - if (getCurrentEssence() >= syphon) { + public int syphon(int syphon) + { + if (getCurrentEssence() >= syphon) + { setCurrentEssence(getCurrentEssence() - syphon); markDirty(); return syphon; @@ -94,19 +102,22 @@ public class SoulNetwork extends WorldSavedData { } /** - * If the player exists on the server, syphon the given amount of LP from the player's LP network and - * damage for any remaining LP required. - * + * If the player exists on the server, syphon the given amount of LP from + * the player's LP network and damage for any remaining LP required. + * * Always returns false on the client side. - * + * * @return - Whether the action should be performed. */ - public boolean syphonAndDamage(int toSyphon) { - if (getPlayer() != null) { + public boolean syphonAndDamage(int toSyphon) + { + if (getPlayer() != null) + { if (getPlayer().worldObj.isRemote) return false; - if (!Strings.isNullOrEmpty(mapName)) { + if (!Strings.isNullOrEmpty(mapName)) + { SoulNetworkEvent.ItemDrainNetworkEvent event = new SoulNetworkEvent.ItemDrainNetworkEvent(player, mapName, getPlayer().getHeldItem(), toSyphon); if (MinecraftForge.EVENT_BUS.post(event)) @@ -129,18 +140,25 @@ public class SoulNetwork extends WorldSavedData { return false; } - public void hurtPlayer(float syphon) { - if (getPlayer() != null) { + public void hurtPlayer(float syphon) + { + if (getPlayer() != null) + { getPlayer().addPotionEffect(new PotionEffect(Potion.confusion.getId(), 20)); - if (syphon < 100 && syphon > 0) { - if (!getPlayer().capabilities.isCreativeMode) { + if (syphon < 100 && syphon > 0) + { + if (!getPlayer().capabilities.isCreativeMode) + { getPlayer().hurtResistantTime = 0; getPlayer().attackEntityFrom(BloodMagicAPI.getDamageSource(), 1.0F); } - } else if (syphon >= 100) { - if (!getPlayer().capabilities.isCreativeMode) { - for (int i = 0; i < ((syphon + 99) / 100); i++) { + } else if (syphon >= 100) + { + if (!getPlayer().capabilities.isCreativeMode) + { + for (int i = 0; i < ((syphon + 99) / 100); i++) + { getPlayer().hurtResistantTime = 0; getPlayer().attackEntityFrom(BloodMagicAPI.getDamageSource(), 1.0F); } diff --git a/src/main/java/WayofTime/bloodmagic/api/orb/BloodOrb.java b/src/main/java/WayofTime/bloodmagic/api/orb/BloodOrb.java index 393b36cc..fd1f083b 100644 --- a/src/main/java/WayofTime/bloodmagic/api/orb/BloodOrb.java +++ b/src/main/java/WayofTime/bloodmagic/api/orb/BloodOrb.java @@ -4,12 +4,15 @@ import WayofTime.bloodmagic.api.registry.OrbRegistry; /** * Base object for all Blood Orbs. Makes Orb creation quite a bit easier. - * - * Just create a new BloodOrb instance then register it with {@link OrbRegistry#registerOrb(BloodOrb)} - * This will allow the use of just one item ID for all orbs. If an addon dev needs more control over the intricacies - * of their orb (custom right clicking, renderers, etc), they can just create their own item as normal. + * + * Just create a new BloodOrb instance then register it with + * {@link OrbRegistry#registerOrb(BloodOrb)} This will allow the use of just one + * item ID for all orbs. If an addon dev needs more control over the intricacies + * of their orb (custom right clicking, renderers, etc), they can just create + * their own item as normal. */ -public class BloodOrb { +public class BloodOrb +{ private String name; private int tier; @@ -17,52 +20,58 @@ public class BloodOrb { private String owner = "BloodMagic"; /** - * A base object for BloodOrbs. A bit cleaner than the - * old way through EnergyItems. - * - * @param name - A name for the Orb. Gets put into an unlocalized name. - * @param tier - The tier of the Orb. - * @param capacity - The max amount of LP the Orb can store. + * A base object for BloodOrbs. A bit cleaner than the old way through + * EnergyItems. + * + * @param name + * - A name for the Orb. Gets put into an unlocalized name. + * @param tier + * - The tier of the Orb. + * @param capacity + * - The max amount of LP the Orb can store. */ - public BloodOrb(String name, int tier, int capacity) { + public BloodOrb(String name, int tier, int capacity) + { this.name = name; this.tier = tier; this.capacity = capacity; } - public String getName() { + public String getName() + { return name; } - public int getTier() { + public int getTier() + { return tier; } - public int getCapacity() { + public int getCapacity() + { return capacity; } - public String getOwner() { + public String getOwner() + { return owner; } /** - * For setting the MODID of the mod that creates the Orb. Not required, but preferred. - * + * For setting the MODID of the mod that creates the Orb. Not required, but + * preferred. + * * @return - The BloodOrb object for further use. */ - public BloodOrb setOwner(String owner) { + public BloodOrb setOwner(String owner) + { this.owner = owner; return this; } @Override - public String toString() { - return "BloodOrb{" + - "name='" + name + '\'' + - ", tier=" + tier + - ", capacity=" + capacity + - ", owner=" + owner + - '}'; + public String toString() + { + return "BloodOrb{" + "name='" + name + '\'' + ", tier=" + tier + ", capacity=" + capacity + ", owner=" + owner + '}'; } } diff --git a/src/main/java/WayofTime/bloodmagic/api/orb/IBloodOrb.java b/src/main/java/WayofTime/bloodmagic/api/orb/IBloodOrb.java index c0ebd8c0..37ae034e 100644 --- a/src/main/java/WayofTime/bloodmagic/api/orb/IBloodOrb.java +++ b/src/main/java/WayofTime/bloodmagic/api/orb/IBloodOrb.java @@ -1,6 +1,7 @@ package WayofTime.bloodmagic.api.orb; -public interface IBloodOrb { +public interface IBloodOrb +{ BloodOrb getOrb(int meta); diff --git a/src/main/java/WayofTime/bloodmagic/api/recipe/ShapedBloodOrbRecipe.java b/src/main/java/WayofTime/bloodmagic/api/recipe/ShapedBloodOrbRecipe.java index 54dccfc8..febbd3f4 100644 --- a/src/main/java/WayofTime/bloodmagic/api/recipe/ShapedBloodOrbRecipe.java +++ b/src/main/java/WayofTime/bloodmagic/api/recipe/ShapedBloodOrbRecipe.java @@ -19,227 +19,281 @@ import WayofTime.bloodmagic.api.orb.IBloodOrb; /** * Shaped Blood Orb Recipe Handler by joshie * */ -public class ShapedBloodOrbRecipe implements IRecipe { - private static final int MAX_CRAFT_GRID_WIDTH = 3; - private static final int MAX_CRAFT_GRID_HEIGHT = 3; +public class ShapedBloodOrbRecipe implements IRecipe +{ + private static final int MAX_CRAFT_GRID_WIDTH = 3; + private static final int MAX_CRAFT_GRID_HEIGHT = 3; - private ItemStack output = null; - private Object[] input = null; - public int width = 0; - public int height = 0; - private boolean mirrored = true; + private ItemStack output = null; + private Object[] input = null; + public int width = 0; + public int height = 0; + private boolean mirrored = true; - public ShapedBloodOrbRecipe(Block result, Object... recipe) { - this(new ItemStack(result), recipe); - } + public ShapedBloodOrbRecipe(Block result, Object... recipe) + { + this(new ItemStack(result), recipe); + } - public ShapedBloodOrbRecipe(Item result, Object... recipe) { - this(new ItemStack(result), recipe); - } + public ShapedBloodOrbRecipe(Item result, Object... recipe) + { + this(new ItemStack(result), recipe); + } - public ShapedBloodOrbRecipe(ItemStack result, Object... recipe) { - output = result.copy(); + public ShapedBloodOrbRecipe(ItemStack result, Object... recipe) + { + output = result.copy(); - String shape = ""; - int idx = 0; + String shape = ""; + int idx = 0; - if (recipe[idx] instanceof Boolean) { - mirrored = (Boolean) recipe[idx]; - if (recipe[idx + 1] instanceof Object[]) { - recipe = (Object[]) recipe[idx + 1]; - } else { - idx = 1; - } - } + if (recipe[idx] instanceof Boolean) + { + mirrored = (Boolean) recipe[idx]; + if (recipe[idx + 1] instanceof Object[]) + { + recipe = (Object[]) recipe[idx + 1]; + } else + { + idx = 1; + } + } - if (recipe[idx] instanceof String[]) { - String[] parts = ((String[]) recipe[idx++]); + if (recipe[idx] instanceof String[]) + { + String[] parts = ((String[]) recipe[idx++]); - for (String s : parts) { - width = s.length(); - shape += s; - } + for (String s : parts) + { + width = s.length(); + shape += s; + } - height = parts.length; - } else { - while (recipe[idx] instanceof String) { - String s = (String) recipe[idx++]; - shape += s; - width = s.length(); - height++; - } - } + height = parts.length; + } else + { + while (recipe[idx] instanceof String) + { + String s = (String) recipe[idx++]; + shape += s; + width = s.length(); + height++; + } + } - if (width * height != shape.length()) { - String ret = "Invalid shaped ore recipe: "; - for (Object tmp : recipe) { - ret += tmp + ", "; - } - ret += output; - throw new RuntimeException(ret); - } + if (width * height != shape.length()) + { + String ret = "Invalid shaped ore recipe: "; + for (Object tmp : recipe) + { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } - HashMap itemMap = new HashMap(); + HashMap itemMap = new HashMap(); - for (; idx < recipe.length; idx += 2) { - Character chr = (Character) recipe[idx]; - Object in = recipe[idx + 1]; + for (; idx < recipe.length; idx += 2) + { + Character chr = (Character) recipe[idx]; + Object in = recipe[idx + 1]; - if (in instanceof IBloodOrb || (in instanceof ItemStack && ((ItemStack) in).getItem() instanceof IBloodOrb)) { - // If the item is an instanceof IBloodOrb then save the level of the orb. - if (in instanceof ItemStack) - itemMap.put(chr, ((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel(((ItemStack) in).getItemDamage())); - else - itemMap.put(chr, ((IBloodOrb) in).getOrbLevel(((ItemStack) in).getItemDamage())); - } else if (in instanceof ItemStack) { - itemMap.put(chr, ((ItemStack) in).copy()); - } else if (in instanceof Item) { - itemMap.put(chr, new ItemStack((Item) in)); - } else if (in instanceof Block) { - itemMap.put(chr, new ItemStack((Block) in, 1, OreDictionary.WILDCARD_VALUE)); - } else if (in instanceof String) { - itemMap.put(chr, OreDictionary.getOres((String) in)); - } else { - String ret = "Invalid shaped orb recipe: "; - for (Object tmp : recipe) { - ret += tmp + ", "; - } - ret += output; - throw new RuntimeException(ret); - } - } + if (in instanceof IBloodOrb || (in instanceof ItemStack && ((ItemStack) in).getItem() instanceof IBloodOrb)) + { + // If the item is an instanceof IBloodOrb then save the level of + // the orb. + if (in instanceof ItemStack) + itemMap.put(chr, ((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel(((ItemStack) in).getItemDamage())); + else + itemMap.put(chr, ((IBloodOrb) in).getOrbLevel(((ItemStack) in).getItemDamage())); + } else if (in instanceof ItemStack) + { + itemMap.put(chr, ((ItemStack) in).copy()); + } else if (in instanceof Item) + { + itemMap.put(chr, new ItemStack((Item) in)); + } else if (in instanceof Block) + { + itemMap.put(chr, new ItemStack((Block) in, 1, OreDictionary.WILDCARD_VALUE)); + } else if (in instanceof String) + { + itemMap.put(chr, OreDictionary.getOres((String) in)); + } else + { + String ret = "Invalid shaped orb recipe: "; + for (Object tmp : recipe) + { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } + } - input = new Object[width * height]; - int x = 0; - for (char chr : shape.toCharArray()) { - input[x++] = itemMap.get(chr); - } - } + input = new Object[width * height]; + int x = 0; + for (char chr : shape.toCharArray()) + { + input[x++] = itemMap.get(chr); + } + } - ShapedBloodOrbRecipe(ShapedRecipes recipe, Map replacements) { - output = recipe.getRecipeOutput(); - width = recipe.recipeWidth; - height = recipe.recipeHeight; + ShapedBloodOrbRecipe(ShapedRecipes recipe, Map replacements) + { + output = recipe.getRecipeOutput(); + width = recipe.recipeWidth; + height = recipe.recipeHeight; - input = new Object[recipe.recipeItems.length]; + input = new Object[recipe.recipeItems.length]; - for (int i = 0; i < input.length; i++) { - ItemStack ingred = recipe.recipeItems[i]; + for (int i = 0; i < input.length; i++) + { + ItemStack ingred = recipe.recipeItems[i]; - if (ingred == null) - continue; + if (ingred == null) + continue; - input[i] = recipe.recipeItems[i]; + input[i] = recipe.recipeItems[i]; - for (Entry replace : replacements.entrySet()) { - if (OreDictionary.itemMatches(replace.getKey(), ingred, true)) { - input[i] = OreDictionary.getOres(replace.getValue()); - break; - } - } - } - } + for (Entry replace : replacements.entrySet()) + { + if (OreDictionary.itemMatches(replace.getKey(), ingred, true)) + { + input[i] = OreDictionary.getOres(replace.getValue()); + break; + } + } + } + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - return output.copy(); - } + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) + { + return output.copy(); + } - @Override - public int getRecipeSize() { - return input.length; - } + @Override + public int getRecipeSize() + { + return input.length; + } - @Override - public ItemStack getRecipeOutput() { - return output; - } + @Override + public ItemStack getRecipeOutput() + { + return output; + } - @Override - public boolean matches(InventoryCrafting inv, World world) { - for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) { - for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) { - if (checkMatch(inv, x, y, false)) { - return true; - } + @Override + public boolean matches(InventoryCrafting inv, World world) + { + for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) + { + for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) + { + if (checkMatch(inv, x, y, false)) + { + return true; + } - if (mirrored && checkMatch(inv, x, y, true)) { - return true; - } - } - } + if (mirrored && checkMatch(inv, x, y, true)) + { + return true; + } + } + } - return false; - } + return false; + } - @SuppressWarnings("unchecked") - private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) { - for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) { - for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) { - int subX = x - startX; - int subY = y - startY; - Object target = null; + @SuppressWarnings("unchecked") + private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) + { + for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) + { + for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) + { + int subX = x - startX; + int subY = y - startY; + Object target = null; - if (subX >= 0 && subY >= 0 && subX < width && subY < height) { - if (mirror) { - target = input[width - subX - 1 + subY * width]; - } else { - target = input[subX + subY * width]; - } - } + if (subX >= 0 && subY >= 0 && subX < width && subY < height) + { + if (mirror) + { + target = input[width - subX - 1 + subY * width]; + } else + { + target = input[subX + subY * width]; + } + } - ItemStack slot = inv.getStackInRowAndColumn(x, y); - // If target is integer, then we should be check the blood orb - // value of the item instead - if (target instanceof Integer) { - if (slot != null && slot.getItem() instanceof IBloodOrb) { - IBloodOrb orb = (IBloodOrb) slot.getItem(); - if (orb.getOrbLevel(slot.getItemDamage()) < (Integer) target) { - return false; - } - } else - return false; - } else if (target instanceof ItemStack) { - if (!OreDictionary.itemMatches((ItemStack) target, slot, false)) { - return false; - } - } else if (target instanceof ArrayList) { - boolean matched = false; + ItemStack slot = inv.getStackInRowAndColumn(x, y); + // If target is integer, then we should be check the blood orb + // value of the item instead + if (target instanceof Integer) + { + if (slot != null && slot.getItem() instanceof IBloodOrb) + { + IBloodOrb orb = (IBloodOrb) slot.getItem(); + if (orb.getOrbLevel(slot.getItemDamage()) < (Integer) target) + { + return false; + } + } else + return false; + } else if (target instanceof ItemStack) + { + if (!OreDictionary.itemMatches((ItemStack) target, slot, false)) + { + return false; + } + } else if (target instanceof ArrayList) + { + boolean matched = false; - Iterator itr = ((ArrayList) target).iterator(); - while (itr.hasNext() && !matched) { - matched = OreDictionary.itemMatches(itr.next(), slot, false); - } + Iterator itr = ((ArrayList) target).iterator(); + while (itr.hasNext() && !matched) + { + matched = OreDictionary.itemMatches(itr.next(), slot, false); + } - if (!matched) { - return false; - } - } else if (target == null && slot != null) { - return false; - } - } - } + if (!matched) + { + return false; + } + } else if (target == null && slot != null) + { + return false; + } + } + } - return true; - } + return true; + } - public ShapedBloodOrbRecipe setMirrored(boolean mirror) { - mirrored = mirror; - return this; - } + public ShapedBloodOrbRecipe setMirrored(boolean mirror) + { + mirrored = mirror; + return this; + } - public Object[] getInput() { - return this.input; - } + public Object[] getInput() + { + return this.input; + } - public ItemStack[] getRemainingItems(InventoryCrafting inv) { - ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()]; + public ItemStack[] getRemainingItems(InventoryCrafting inv) + { + ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()]; - for (int i = 0; i < aitemstack.length; ++i) { - ItemStack itemstack = inv.getStackInSlot(i); - aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack); - } + for (int i = 0; i < aitemstack.length; ++i) + { + ItemStack itemstack = inv.getStackInSlot(i); + aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack); + } - return aitemstack; - } + return aitemstack; + } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/api/recipe/ShapelessBloodOrbRecipe.java b/src/main/java/WayofTime/bloodmagic/api/recipe/ShapelessBloodOrbRecipe.java index a94c78ff..c69dfcb1 100644 --- a/src/main/java/WayofTime/bloodmagic/api/recipe/ShapelessBloodOrbRecipe.java +++ b/src/main/java/WayofTime/bloodmagic/api/recipe/ShapelessBloodOrbRecipe.java @@ -19,139 +19,173 @@ import WayofTime.bloodmagic.api.orb.IBloodOrb; /** * Shapeless Blood Orb Recipe Handler by joshie * */ -public class ShapelessBloodOrbRecipe implements IRecipe { - private ItemStack output = null; - private ArrayList input = new ArrayList(); +public class ShapelessBloodOrbRecipe implements IRecipe +{ + private ItemStack output = null; + private ArrayList input = new ArrayList(); - public ShapelessBloodOrbRecipe(Block result, Object... recipe) { - this(new ItemStack(result), recipe); - } + public ShapelessBloodOrbRecipe(Block result, Object... recipe) + { + this(new ItemStack(result), recipe); + } - public ShapelessBloodOrbRecipe(Item result, Object... recipe) { - this(new ItemStack(result), recipe); - } + public ShapelessBloodOrbRecipe(Item result, Object... recipe) + { + this(new ItemStack(result), recipe); + } - public ShapelessBloodOrbRecipe(ItemStack result, Object... recipe) { - output = result.copy(); - for (Object in : recipe) { - if (in instanceof ItemStack) { - if (((ItemStack) in).getItem() instanceof IBloodOrb) { - input.add(((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel(((ItemStack) in).getItemDamage())); - } else - input.add(((ItemStack) in).copy()); - } else if (in instanceof Item) { - input.add(new ItemStack((Item) in)); - } else if (in instanceof Block) { - input.add(new ItemStack((Block) in)); - } else if (in instanceof String) { - input.add(OreDictionary.getOres((String) in)); - } else { - String ret = "Invalid shapeless ore recipe: "; - for (Object tmp : recipe) { - ret += tmp + ", "; - } - ret += output; - throw new RuntimeException(ret); - } - } - } + public ShapelessBloodOrbRecipe(ItemStack result, Object... recipe) + { + output = result.copy(); + for (Object in : recipe) + { + if (in instanceof ItemStack) + { + if (((ItemStack) in).getItem() instanceof IBloodOrb) + { + input.add(((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel(((ItemStack) in).getItemDamage())); + } else + input.add(((ItemStack) in).copy()); + } else if (in instanceof Item) + { + input.add(new ItemStack((Item) in)); + } else if (in instanceof Block) + { + input.add(new ItemStack((Block) in)); + } else if (in instanceof String) + { + input.add(OreDictionary.getOres((String) in)); + } else + { + String ret = "Invalid shapeless ore recipe: "; + for (Object tmp : recipe) + { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } + } + } - ShapelessBloodOrbRecipe(ShapelessRecipes recipe, Map replacements) { - output = recipe.getRecipeOutput(); + ShapelessBloodOrbRecipe(ShapelessRecipes recipe, Map replacements) + { + output = recipe.getRecipeOutput(); - for (ItemStack ingred : ((List) recipe.recipeItems)) { - Object finalObj = ingred; - for (Entry replace : replacements.entrySet()) { - if (OreDictionary.itemMatches(replace.getKey(), ingred, false)) { - finalObj = OreDictionary.getOres(replace.getValue()); - break; - } - } - input.add(finalObj); - } - } + for (ItemStack ingred : ((List) recipe.recipeItems)) + { + Object finalObj = ingred; + for (Entry replace : replacements.entrySet()) + { + if (OreDictionary.itemMatches(replace.getKey(), ingred, false)) + { + finalObj = OreDictionary.getOres(replace.getValue()); + break; + } + } + input.add(finalObj); + } + } - @Override - public int getRecipeSize() { - return input.size(); - } + @Override + public int getRecipeSize() + { + return input.size(); + } - @Override - public ItemStack getRecipeOutput() { - return output; - } + @Override + public ItemStack getRecipeOutput() + { + return output; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting var1) { - return output.copy(); - } + @Override + public ItemStack getCraftingResult(InventoryCrafting var1) + { + return output.copy(); + } - @SuppressWarnings("unchecked") - @Override - public boolean matches(InventoryCrafting var1, World world) { - ArrayList required = new ArrayList(input); + @SuppressWarnings("unchecked") + @Override + public boolean matches(InventoryCrafting var1, World world) + { + ArrayList required = new ArrayList(input); - for (int x = 0; x < var1.getSizeInventory(); x++) { - ItemStack slot = var1.getStackInSlot(x); + for (int x = 0; x < var1.getSizeInventory(); x++) + { + ItemStack slot = var1.getStackInSlot(x); - if (slot != null) { - boolean inRecipe = false; - Iterator req = required.iterator(); + if (slot != null) + { + boolean inRecipe = false; + Iterator req = required.iterator(); - while (req.hasNext()) { - boolean match = false; + while (req.hasNext()) + { + boolean match = false; - Object next = req.next(); + Object next = req.next(); - // If target is integer, then we should be check the blood - // orb value of the item instead - if (next instanceof Integer) { - if (slot != null && slot.getItem() instanceof IBloodOrb) { - IBloodOrb orb = (IBloodOrb) slot.getItem(); - if (orb.getOrbLevel(slot.getItemDamage()) < (Integer) next) { - return false; - } - } else - return false; - match = true; - } else if (next instanceof ItemStack) { - match = OreDictionary.itemMatches((ItemStack) next, slot, false); - } else if (next instanceof ArrayList) { - Iterator itr = ((ArrayList) next).iterator(); - while (itr.hasNext() && !match) { - match = OreDictionary.itemMatches(itr.next(), slot, false); - } - } + // If target is integer, then we should be check the blood + // orb value of the item instead + if (next instanceof Integer) + { + if (slot != null && slot.getItem() instanceof IBloodOrb) + { + IBloodOrb orb = (IBloodOrb) slot.getItem(); + if (orb.getOrbLevel(slot.getItemDamage()) < (Integer) next) + { + return false; + } + } else + return false; + match = true; + } else if (next instanceof ItemStack) + { + match = OreDictionary.itemMatches((ItemStack) next, slot, false); + } else if (next instanceof ArrayList) + { + Iterator itr = ((ArrayList) next).iterator(); + while (itr.hasNext() && !match) + { + match = OreDictionary.itemMatches(itr.next(), slot, false); + } + } - if (match) { - inRecipe = true; - required.remove(next); - break; - } - } + if (match) + { + inRecipe = true; + required.remove(next); + break; + } + } - if (!inRecipe) { - return false; - } - } - } + if (!inRecipe) + { + return false; + } + } + } - return required.isEmpty(); - } + return required.isEmpty(); + } - public ArrayList getInput() { - return this.input; - } + public ArrayList getInput() + { + return this.input; + } - @Override - public ItemStack[] getRemainingItems(InventoryCrafting inv) { - ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()]; + @Override + public ItemStack[] getRemainingItems(InventoryCrafting inv) + { + ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()]; - for (int i = 0; i < aitemstack.length; ++i) { - ItemStack itemstack = inv.getStackInSlot(i); - aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack); - } + for (int i = 0; i < aitemstack.length; ++i) + { + ItemStack itemstack = inv.getStackInSlot(i); + aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack); + } - return aitemstack; - } + return aitemstack; + } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/AlchemyArrayRecipeRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/AlchemyArrayRecipeRegistry.java index 26b69881..b12f2746 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/AlchemyArrayRecipeRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/AlchemyArrayRecipeRegistry.java @@ -17,177 +17,212 @@ import com.google.common.collect.HashBiMap; import javax.annotation.Nullable; -public class AlchemyArrayRecipeRegistry { +public class AlchemyArrayRecipeRegistry +{ - public static final AlchemyCircleRenderer defaultRenderer = new AlchemyCircleRenderer(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png")); + public static final AlchemyCircleRenderer defaultRenderer = new AlchemyCircleRenderer(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png")); - @Getter - private static BiMap recipes = HashBiMap.create(); + @Getter + private static BiMap recipes = HashBiMap.create(); - /** - * General case for creating an AlchemyArrayEffect for a given input. - * - * @param inputStack - * - Input item that is used to change the Alchemy Circle into - * the circle that you are making - * @param catalystStack - * - Catalyst item that, when right-clicked onto the array, will - * cause an effect - * @param arrayEffect - * - The effect that will be activated once the array is - * activated - * @param circleRenderer - * - Circle rendered when the array is passive - can be - * substituted for a special renderer - */ - public static void registerRecipe(ItemStack inputStack, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) { - for (Entry entry : recipes.entrySet()) { - AlchemyArrayRecipe arrayRecipe = entry.getValue(); - if (arrayRecipe.doesInputMatchRecipe(inputStack)) { - AlchemyArrayEffect eff = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack); - if (eff != null) { - return; // Recipe already exists! - } else { - arrayRecipe.catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect); - if (circleRenderer != null) { - arrayRecipe.circleRenderer = circleRenderer; - } - return; - } - } - } + /** + * General case for creating an AlchemyArrayEffect for a given input. + * + * @param inputStack + * - Input item that is used to change the Alchemy Circle into + * the circle that you are making + * @param catalystStack + * - Catalyst item that, when right-clicked onto the array, will + * cause an effect + * @param arrayEffect + * - The effect that will be activated once the array is + * activated + * @param circleRenderer + * - Circle rendered when the array is passive - can be + * substituted for a special renderer + */ + public static void registerRecipe(ItemStack inputStack, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) + { + for (Entry entry : recipes.entrySet()) + { + AlchemyArrayRecipe arrayRecipe = entry.getValue(); + if (arrayRecipe.doesInputMatchRecipe(inputStack)) + { + AlchemyArrayEffect eff = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack); + if (eff != null) + { + return; // Recipe already exists! + } else + { + arrayRecipe.catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect); + if (circleRenderer != null) + { + arrayRecipe.circleRenderer = circleRenderer; + } + return; + } + } + } - if (circleRenderer == null) { - recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, defaultRenderer)); - } else { - recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, circleRenderer)); - } + if (circleRenderer == null) + { + recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, defaultRenderer)); + } else + { + recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, circleRenderer)); + } - recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, circleRenderer)); - } + recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, circleRenderer)); + } - public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack, AlchemyCircleRenderer circleRenderer) { - registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack), circleRenderer); - } + public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack, AlchemyCircleRenderer circleRenderer) + { + registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack), circleRenderer); + } - public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) { - registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource); - } + public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) + { + registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource); + } - public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack) { - registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack)); - } + public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack) + { + registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack)); + } - public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) { - AlchemyCircleRenderer circleRenderer = null; - if (arrayResource == null) { - circleRenderer = defaultRenderer; - } else { - circleRenderer = new AlchemyCircleRenderer(arrayResource); - } + public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) + { + AlchemyCircleRenderer circleRenderer = null; + if (arrayResource == null) + { + circleRenderer = defaultRenderer; + } else + { + circleRenderer = new AlchemyCircleRenderer(arrayResource); + } - registerRecipe(inputStack, catalystStack, arrayEffect, circleRenderer); - } + registerRecipe(inputStack, catalystStack, arrayEffect, circleRenderer); + } - public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) { - registerRecipe(inputStack, catalystStack, arrayEffect, (AlchemyCircleRenderer) null); - } + public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) + { + registerRecipe(inputStack, catalystStack, arrayEffect, (AlchemyCircleRenderer) null); + } - public static void replaceAlchemyCircle(ItemStack inputStack, AlchemyCircleRenderer circleRenderer) { - if (circleRenderer == null) { - return; - } - for (Entry entry : recipes.entrySet()) { - AlchemyArrayRecipe arrayRecipe = entry.getValue(); - if (arrayRecipe.doesInputMatchRecipe(inputStack)) { - arrayRecipe.circleRenderer = circleRenderer; - } - } - } + public static void replaceAlchemyCircle(ItemStack inputStack, AlchemyCircleRenderer circleRenderer) + { + if (circleRenderer == null) + { + return; + } + for (Entry entry : recipes.entrySet()) + { + AlchemyArrayRecipe arrayRecipe = entry.getValue(); + if (arrayRecipe.doesInputMatchRecipe(inputStack)) + { + arrayRecipe.circleRenderer = circleRenderer; + } + } + } - public static AlchemyArrayRecipe getRecipeForInput(ItemStack input) { - return recipes.get(input); - } + public static AlchemyArrayRecipe getRecipeForInput(ItemStack input) + { + return recipes.get(input); + } - public static AlchemyArrayEffect getAlchemyArrayEffect(ItemStack inputStack, @Nullable ItemStack catalystStack) { - for (Entry entry : recipes.entrySet()) { - AlchemyArrayRecipe arrayRecipe = entry.getValue(); - if (ItemStackWrapper.getHolder(arrayRecipe.getInputStack()).equals(ItemStackWrapper.getHolder(inputStack))) { - AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack); + public static AlchemyArrayEffect getAlchemyArrayEffect(ItemStack inputStack, @Nullable ItemStack catalystStack) + { + for (Entry entry : recipes.entrySet()) + { + AlchemyArrayRecipe arrayRecipe = entry.getValue(); + if (ItemStackWrapper.getHolder(arrayRecipe.getInputStack()).equals(ItemStackWrapper.getHolder(inputStack))) + { + AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack); - return effect; // TODO: Decide if a copy should be returned. - } - } + return effect; // TODO: Decide if a copy should be returned. + } + } - return null; - } + return null; + } - public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack inputStack) { - for (Entry entry : recipes.entrySet()) { - AlchemyArrayRecipe arrayRecipe = entry.getValue(); - if (arrayRecipe.doesInputMatchRecipe(inputStack)) { - return arrayRecipe.circleRenderer; - } - } + public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack inputStack) + { + for (Entry entry : recipes.entrySet()) + { + AlchemyArrayRecipe arrayRecipe = entry.getValue(); + if (arrayRecipe.doesInputMatchRecipe(inputStack)) + { + return arrayRecipe.circleRenderer; + } + } - return defaultRenderer; - } + return defaultRenderer; + } - @Getter - @ToString - @EqualsAndHashCode - public static class AlchemyArrayRecipe { + @Getter + @ToString + @EqualsAndHashCode + public static class AlchemyArrayRecipe + { - public AlchemyCircleRenderer circleRenderer; - public final ItemStack inputStack; - public final BiMap catalystMap = HashBiMap.create(); + public AlchemyCircleRenderer circleRenderer; + public final ItemStack inputStack; + public final BiMap catalystMap = HashBiMap.create(); - public AlchemyArrayRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) { - this.inputStack = inputStack; - - catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect); - - this.circleRenderer = circleRenderer; - } + public AlchemyArrayRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) + { + this.inputStack = inputStack; - /** - * Compares the inputed ItemStack to see if it matches with the recipe's - * inputStack. - * - * @param comparedStack - * @return - true if the ItemStack is a compatible item - */ - public boolean doesInputMatchRecipe(ItemStack comparedStack) { - if (comparedStack == null || this.inputStack == null) - return false; + catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect); - return this.inputStack.isItemEqual(comparedStack); - } + this.circleRenderer = circleRenderer; + } - /** - * Gets the actual AlchemyArrayEffect for the given catalyst. - * - * @param comparedStack - * The catalyst that is being checked - * @return - */ - public AlchemyArrayEffect getAlchemyArrayEffectForCatalyst(@Nullable ItemStack comparedStack) { - for (Entry entry : catalystMap.entrySet()) { - ItemStack catalystStack = entry.getKey().toStack(); - if (comparedStack == null && catalystStack == null) { - return entry.getValue(); - } + /** + * Compares the inputed ItemStack to see if it matches with the recipe's + * inputStack. + * + * @param comparedStack + * @return - true if the ItemStack is a compatible item + */ + public boolean doesInputMatchRecipe(ItemStack comparedStack) + { + if (comparedStack == null || this.inputStack == null) + return false; - if (comparedStack == null || catalystStack == null) { - continue; - } + return this.inputStack.isItemEqual(comparedStack); + } - if (catalystStack.isItemEqual(comparedStack)) { - return entry.getValue(); - } - } + /** + * Gets the actual AlchemyArrayEffect for the given catalyst. + * + * @param comparedStack + * The catalyst that is being checked + * @return + */ + public AlchemyArrayEffect getAlchemyArrayEffectForCatalyst(@Nullable ItemStack comparedStack) + { + for (Entry entry : catalystMap.entrySet()) + { + ItemStack catalystStack = entry.getKey().toStack(); + if (comparedStack == null && catalystStack == null) + { + return entry.getValue(); + } - return null; - } - } + if (comparedStack == null || catalystStack == null) + { + continue; + } + + if (catalystStack.isItemEqual(comparedStack)) + { + return entry.getValue(); + } + } + + return null; + } + } } diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/AltarRecipeRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/AltarRecipeRegistry.java index 69bb8022..dbdaa8d2 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/AltarRecipeRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/AltarRecipeRegistry.java @@ -11,26 +11,29 @@ import net.minecraft.item.ItemStack; import javax.annotation.Nullable; -public class AltarRecipeRegistry { - +public class AltarRecipeRegistry +{ @Getter private static BiMap recipes = HashBiMap.create(); - public static void registerRecipe(AltarRecipe recipe) { + public static void registerRecipe(AltarRecipe recipe) + { if (!recipes.containsValue(recipe)) recipes.put(recipe.input, recipe); else - BloodMagicAPI.getLogger().error("Error adding altar recipe for %s. Recipe already exists.", recipe.input.getDisplayName(), recipe.output == null ? "" : " -> " ); + BloodMagicAPI.getLogger().error("Error adding altar recipe for %s. Recipe already exists.", recipe.input.getDisplayName(), recipe.output == null ? "" : " -> "); } - public static AltarRecipe getRecipeForInput(ItemStack input) { + public static AltarRecipe getRecipeForInput(ItemStack input) + { return recipes.get(input); } @Getter @ToString @EqualsAndHashCode - public static class AltarRecipe { + public static class AltarRecipe + { public final int syphon, consumeRate, drainRate; public final boolean useTag; @@ -38,18 +41,29 @@ public class AltarRecipeRegistry { public final EnumAltarTier minTier; /** - * Allows creation of a recipe for the {@link WayofTime.bloodmagic.block.BlockAltar} / {@link WayofTime.bloodmagic.tile.TileAltar}. - * The output ItemStack is allowed to be null as some recipes do not contain an output. (Blood Orbs) - * - * @param input - The input ItemStack - * @param output - The ItemStack obtained from the recipe - * @param minTier - The minimum tier of Altar required - * @param syphon - The amount of LP to syphon from the Altar - * @param consumeRate - The rate at which LP is consumed during crafting - * @param drainRate - The rate at which LP is drained during crafting - * @param useTag - + * Allows creation of a recipe for the + * {@link WayofTime.bloodmagic.block.BlockAltar} / + * {@link WayofTime.bloodmagic.tile.TileAltar}. The output ItemStack is + * allowed to be null as some recipes do not contain an output. (Blood + * Orbs) + * + * @param input + * - The input ItemStack + * @param output + * - The ItemStack obtained from the recipe + * @param minTier + * - The minimum tier of Altar required + * @param syphon + * - The amount of LP to syphon from the Altar + * @param consumeRate + * - The rate at which LP is consumed during crafting + * @param drainRate + * - The rate at which LP is drained during crafting + * @param useTag + * - */ - public AltarRecipe(ItemStack input, @Nullable ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean useTag) { + public AltarRecipe(ItemStack input, @Nullable ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean useTag) + { this.input = input; this.output = output; this.minTier = minTier; @@ -59,19 +73,27 @@ public class AltarRecipeRegistry { this.useTag = useTag; } - public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) { + public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) + { this(input, output, minTier, syphon, consumeRate, drainRate, false); } - public AltarRecipe(ItemStack input, EnumAltarTier minTier, int consumeRate, int drainRate) { + public AltarRecipe(ItemStack input, EnumAltarTier minTier, int consumeRate, int drainRate) + { this(input, null, minTier, 0, consumeRate, drainRate); } - - public boolean doesRequiredItemMatch(ItemStack comparedStack, EnumAltarTier tierCheck) { + + public boolean doesRequiredItemMatch(ItemStack comparedStack, EnumAltarTier tierCheck) + { if (comparedStack == null || this.input == null) return false; - return tierCheck.ordinal() >= minTier.ordinal() && this.input.isItemEqual(comparedStack);// && (this.useTag ? this.areRequiredTagsEqual(comparedStack) : true); + return tierCheck.ordinal() >= minTier.ordinal() && this.input.isItemEqual(comparedStack);// && + // (this.useTag + // ? + // this.areRequiredTagsEqual(comparedStack) + // : + // true); } } } diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/ImperfectRitualRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/ImperfectRitualRegistry.java index 7033b8b0..80b14e37 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/ImperfectRitualRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/ImperfectRitualRegistry.java @@ -10,19 +10,24 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -public class ImperfectRitualRegistry { +public class ImperfectRitualRegistry +{ public static final Map enabledRituals = new HashMap(); private static final BiMap registry = HashBiMap.create(); /** * The safe way to register a new Ritual. - * - * @param imperfectRitual - The imperfect ritual to register. - * @param id - The ID for the imperfect ritual. Cannot be duplicated. + * + * @param imperfectRitual + * - The imperfect ritual to register. + * @param id + * - The ID for the imperfect ritual. Cannot be duplicated. */ - public static void registerRitual(ImperfectRitual imperfectRitual, String id) { - if (imperfectRitual != null) { + public static void registerRitual(ImperfectRitual imperfectRitual, String id) + { + if (imperfectRitual != null) + { if (registry.containsKey(id)) BloodMagicAPI.getLogger().error("Duplicate imperfect ritual id: %s", id); else @@ -30,11 +35,13 @@ public class ImperfectRitualRegistry { } } - public static void registerRitual(ImperfectRitual imperfectRitual) { + public static void registerRitual(ImperfectRitual imperfectRitual) + { registerRitual(imperfectRitual, imperfectRitual.getName()); } - public static ImperfectRitual getRitualForBlock(BlockStack blockStack) { + public static ImperfectRitual getRitualForBlock(BlockStack blockStack) + { for (ImperfectRitual imperfectRitual : getRegistry().values()) if (imperfectRitual.getRequiredBlock().equals(blockStack)) return imperfectRitual; @@ -42,44 +49,55 @@ public class ImperfectRitualRegistry { return null; } - public static ImperfectRitual getRitualForId(String id) { + public static ImperfectRitual getRitualForId(String id) + { return registry.get(id); } - public static String getIdForRitual(ImperfectRitual imperfectRitual) { + public static String getIdForRitual(ImperfectRitual imperfectRitual) + { return registry.inverse().get(imperfectRitual); } - public static boolean isMapEmpty() { + public static boolean isMapEmpty() + { return registry.isEmpty(); } - public static int getMapSize() { + public static int getMapSize() + { return registry.size(); } - public static boolean ritualEnabled(ImperfectRitual imperfectRitual) { - try { + public static boolean ritualEnabled(ImperfectRitual imperfectRitual) + { + try + { return enabledRituals.get(imperfectRitual); - } catch (NullPointerException e) { + } catch (NullPointerException e) + { BloodMagicAPI.getLogger().error("Invalid Imperfect Ritual was called"); return false; } } - public static BiMap getRegistry() { + public static BiMap getRegistry() + { return HashBiMap.create(registry); } - public static BiMap getEnabledMap() { + public static BiMap getEnabledMap() + { return HashBiMap.create(enabledRituals); } - public static ArrayList getIds() { + public static ArrayList getIds() + { return new ArrayList(registry.keySet()); } - public static ArrayList getRituals() { + public static ArrayList getRituals() + { return new ArrayList(registry.values()); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/OrbRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/OrbRegistry.java index 33745102..b693177c 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/OrbRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/OrbRegistry.java @@ -14,15 +14,17 @@ import java.util.ArrayList; import java.util.List; /** - * This is only for those who wish to add a basic {@link BloodOrb}. If you need custom handling, - * you will need your own item class. + * This is only for those who wish to add a basic {@link BloodOrb}. If you need + * custom handling, you will need your own item class. */ -public class OrbRegistry { +public class OrbRegistry +{ @Getter private static List orbs = new ArrayList(); - public static void registerOrb(BloodOrb orb) { + public static void registerOrb(BloodOrb orb) + { if (!orbs.contains(orb)) orbs.add(orb); else @@ -30,30 +32,36 @@ public class OrbRegistry { } @SideOnly(Side.CLIENT) - public static void registerOrbTexture(BloodOrb orb, String resourceLocation) { + public static void registerOrbTexture(BloodOrb orb, String resourceLocation) + { int meta = getIndexOf(orb); ModelBakery.addVariantName(BloodMagicAPI.getItem(BloodMagicAPI.ORB), resourceLocation); ModelLoader.setCustomModelResourceLocation(BloodMagicAPI.getItem(BloodMagicAPI.ORB), meta, new ModelResourceLocation(resourceLocation, "inventory")); } - public static BloodOrb getOrb(int index) { + public static BloodOrb getOrb(int index) + { return orbs.get(index); } - public static int getIndexOf(BloodOrb orb) { + public static int getIndexOf(BloodOrb orb) + { return orbs.indexOf(orb); } - public static boolean isEmpty() { + public static boolean isEmpty() + { return orbs.isEmpty(); } - public static int getSize() { + public static int getSize() + { return orbs.size(); } - public static ItemStack getOrbStack(BloodOrb orb) { + public static ItemStack getOrbStack(BloodOrb orb) + { return new ItemStack(BloodMagicAPI.getItem(BloodMagicAPI.ORB), 1, getIndexOf(orb)); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/RitualRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/RitualRegistry.java index 47fcb7fb..9c3eb218 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/RitualRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/RitualRegistry.java @@ -10,72 +10,91 @@ import WayofTime.bloodmagic.api.ritual.Ritual; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; -public class RitualRegistry { +public class RitualRegistry +{ public static final Map enabledRituals = new HashMap(); private static final BiMap registry = HashBiMap.create(); - // Ordered list for actions that depend on the order that the rituals were registered in - private static final ArrayList orderedIdList = new ArrayList(); + // Ordered list for actions that depend on the order that the rituals were + // registered in + private static final ArrayList orderedIdList = new ArrayList(); /** * The safe way to register a new Ritual. - * - * @param ritual - The ritual to register. - * @param id - The ID for the ritual. Cannot be duplicated. + * + * @param ritual + * - The ritual to register. + * @param id + * - The ID for the ritual. Cannot be duplicated. */ - public static void registerRitual(Ritual ritual, String id) { - if (ritual != null) { + public static void registerRitual(Ritual ritual, String id) + { + if (ritual != null) + { if (registry.containsKey(id)) BloodMagicAPI.getLogger().error("Duplicate ritual id: %s", id); - else { + else + { registry.put(id, ritual); orderedIdList.add(id); } } } - public static Ritual getRitualForId(String id) { + public static Ritual getRitualForId(String id) + { return registry.get(id); } - public static String getIdForRitual(Ritual ritual) { + public static String getIdForRitual(Ritual ritual) + { return registry.inverse().get(ritual); } - public static boolean isMapEmpty() { + public static boolean isMapEmpty() + { return registry.isEmpty(); } - public static int getMapSize() { + public static int getMapSize() + { return registry.size(); } - public static boolean ritualEnabled(Ritual ritual) { - try { + public static boolean ritualEnabled(Ritual ritual) + { + try + { return enabledRituals.get(ritual); - } catch (NullPointerException e) { + } catch (NullPointerException e) + { BloodMagicAPI.getLogger().error("Invalid Ritual was called"); return false; } } - public static BiMap getRegistry() { + public static BiMap getRegistry() + { return HashBiMap.create(registry); } - public static Map getEnabledMap() { + public static Map getEnabledMap() + { return new HashMap(enabledRituals); } - public static ArrayList getIds() { + public static ArrayList getIds() + { return new ArrayList(registry.keySet()); } - - public static ArrayList getOrderedIds() { - return orderedIdList; + + public static ArrayList getOrderedIds() + { + return orderedIdList; } - public static ArrayList getRituals() { + public static ArrayList getRituals() + { return new ArrayList(registry.values()); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/AreaDescriptor.java b/src/main/java/WayofTime/bloodmagic/api/ritual/AreaDescriptor.java index 80626f6b..926b06e5 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/AreaDescriptor.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/AreaDescriptor.java @@ -6,13 +6,16 @@ import java.util.List; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; -public class AreaDescriptor { - - public List getContainedPositions() { - return new ArrayList(); - } - - public AxisAlignedBB getAABB() { - return null; - } +public class AreaDescriptor +{ + + public List getContainedPositions() + { + return new ArrayList(); + } + + public AxisAlignedBB getAABB() + { + return null; + } } diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/EnumRuneType.java b/src/main/java/WayofTime/bloodmagic/api/ritual/EnumRuneType.java index 5215305c..f0287375 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/EnumRuneType.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/EnumRuneType.java @@ -6,34 +6,33 @@ import net.minecraft.util.IStringSerializable; import java.util.Locale; -public enum EnumRuneType implements IStringSerializable { +public enum EnumRuneType implements IStringSerializable +{ - BLANK, - WATER, - FIRE, - EARTH, - AIR, - DUSK, - DAWN; + BLANK, WATER, FIRE, EARTH, AIR, DUSK, DAWN; - public static EnumRuneType byMetadata(int meta) { + public static EnumRuneType byMetadata(int meta) + { if (meta < 0 || meta >= values().length) meta = 0; return values()[meta]; } - public ItemStack getScribeStack() { + public ItemStack getScribeStack() + { return new ItemStack(BloodMagicAPI.getItem(BloodMagicAPI.SCRIBE), 1, ordinal()); } @Override - public String toString() { + public String toString() + { return name().toLowerCase(Locale.ENGLISH); } @Override - public String getName() { + public String getName() + { return this.toString(); } diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/IMasterRitualStone.java b/src/main/java/WayofTime/bloodmagic/api/ritual/IMasterRitualStone.java index 82c648a5..a595d795 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/IMasterRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/IMasterRitualStone.java @@ -8,10 +8,11 @@ import net.minecraft.world.World; /** * This interface is for internal implementation only. - * + * * It is provided via the API for easy obtaining of basic data. */ -public interface IMasterRitualStone { +public interface IMasterRitualStone +{ String getOwner(); diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/IRitualStone.java b/src/main/java/WayofTime/bloodmagic/api/ritual/IRitualStone.java index 3ed6954e..73ed662e 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/IRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/IRitualStone.java @@ -5,14 +5,16 @@ import net.minecraft.world.World; /** * This interface is for internal implementation only. - * + * * It is provided via the API for easy obtaining of basic data. */ -public interface IRitualStone { +public interface IRitualStone +{ boolean isRuneType(World world, BlockPos pos, EnumRuneType runeType); - interface Tile { + interface Tile + { boolean isRuneType(EnumRuneType runeType); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/Ritual.java b/src/main/java/WayofTime/bloodmagic/api/ritual/Ritual.java index 731e33c3..9b3113e5 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/Ritual.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/Ritual.java @@ -21,140 +21,152 @@ import net.minecraft.world.World; @RequiredArgsConstructor @EqualsAndHashCode(exclude = { "modableRangeMap" }) @ToString -public abstract class Ritual { +public abstract class Ritual +{ - public final ArrayList ritualComponents = new ArrayList(); - private final String name; - private final int crystalLevel; - private final int activationCost; - private final RitualRenderer renderer; - private final String unlocalizedName; + public final ArrayList ritualComponents = new ArrayList(); + private final String name; + private final int crystalLevel; + private final int activationCost; + private final RitualRenderer renderer; + private final String unlocalizedName; - private final Map modableRangeMap = new HashMap(); + private final Map modableRangeMap = new HashMap(); - /** - * @param name - * - The name of the ritual - * @param crystalLevel - * - Required Activation Crystal tier - * @param activationCost - * - Base LP cost for activating the ritual - */ - public Ritual(String name, int crystalLevel, int activationCost, String unlocalizedName) { - this(name, crystalLevel, activationCost, null, unlocalizedName); - } + /** + * @param name + * - The name of the ritual + * @param crystalLevel + * - Required Activation Crystal tier + * @param activationCost + * - Base LP cost for activating the ritual + */ + public Ritual(String name, int crystalLevel, int activationCost, String unlocalizedName) + { + this(name, crystalLevel, activationCost, null, unlocalizedName); + } - /** - * Called when the player attempts to activate the ritual. - * - * {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)} - * - * @param masterRitualStone - * - The {@link IMasterRitualStone} that the ritual is bound to - * @param player - * - The activating player - * @return - Whether activation was successful - */ - public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player) { - return true; - } + /** + * Called when the player attempts to activate the ritual. + * + * {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)} + * + * @param masterRitualStone + * - The {@link IMasterRitualStone} that the ritual is bound to + * @param player + * - The activating player + * @return - Whether activation was successful + */ + public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player) + { + return true; + } - /** - * Called every {@link #getRefreshTime()} ticks while active. - * - * {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)} - * - * @param masterRitualStone - * - The {@link IMasterRitualStone} that the ritual is bound to - */ - public abstract void performRitual(IMasterRitualStone masterRitualStone); + /** + * Called every {@link #getRefreshTime()} ticks while active. + * + * {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)} + * + * @param masterRitualStone + * - The {@link IMasterRitualStone} that the ritual is bound to + */ + public abstract void performRitual(IMasterRitualStone masterRitualStone); - /** - * Called when the ritual is stopped for a given {@link BreakType}. - * - * {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(BreakType)} - * - * @param masterRitualStone - * - The {@link IMasterRitualStone} that the ritual is bound to - * @param breakType - * - The type of break that caused the stoppage. - */ - public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType) { + /** + * Called when the ritual is stopped for a given {@link BreakType}. + * + * {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(BreakType)} + * + * @param masterRitualStone + * - The {@link IMasterRitualStone} that the ritual is bound to + * @param breakType + * - The type of break that caused the stoppage. + */ + public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType) + { - } + } - /** - * Used to set the amount of LP drained every {@link #getRefreshTime()} - * ticks. - * - * @return - The amount of LP drained per refresh - */ - public abstract int getRefreshCost(); + /** + * Used to set the amount of LP drained every {@link #getRefreshTime()} + * ticks. + * + * @return - The amount of LP drained per refresh + */ + public abstract int getRefreshCost(); - /** - * Used to set the refresh rate of the ritual. (How often - * {@link #performRitual(IMasterRitualStone)} is called. - * - * @return - How often to perform the effect in ticks. - */ - public int getRefreshTime() { - return 20; - } + /** + * Used to set the refresh rate of the ritual. (How often + * {@link #performRitual(IMasterRitualStone)} is called. + * + * @return - How often to perform the effect in ticks. + */ + public int getRefreshTime() + { + return 20; + } - public void addBlockRange(String range, BlockPos[] defaultRange) { - modableRangeMap.put(range, defaultRange); - } + public void addBlockRange(String range, BlockPos[] defaultRange) + { + modableRangeMap.put(range, defaultRange); + } - /** - * Used to grab the range of a ritual for a given effect. The order of the - * blockPos array is: bottom corner, top corner. - * - * @param range - * - Range that needs to be pulled. - * @return - The range of the ritual effect. Array must be of size 2 and - * have non-null values, with the first BlockPos having the lower - * offset values and the second BlockPos having the higher offset - * values - */ - public BlockPos[] getBlockRange(String range) { - if (modableRangeMap.containsKey(range)) { - return modableRangeMap.get(range); - } - - return new BlockPos[] { new BlockPos(0, 0, 0), new BlockPos(0, 0, 0) }; - } + /** + * Used to grab the range of a ritual for a given effect. The order of the + * blockPos array is: bottom corner, top corner. + * + * @param range + * - Range that needs to be pulled. + * @return - The range of the ritual effect. Array must be of size 2 and + * have non-null values, with the first BlockPos having the lower + * offset values and the second BlockPos having the higher offset + * values + */ + public BlockPos[] getBlockRange(String range) + { + if (modableRangeMap.containsKey(range)) + { + return modableRangeMap.get(range); + } - /** - * @return a list of {@link RitualComponent} for checking the ritual. - */ - public abstract ArrayList getComponents(); + return new BlockPos[] { new BlockPos(0, 0, 0), new BlockPos(0, 0, 0) }; + } - public void addOffsetRunes(ArrayList components, int offset1, int offset2, int y, EnumRuneType rune) { - components.add(new RitualComponent(new BlockPos(offset1, y, offset2), rune)); - components.add(new RitualComponent(new BlockPos(offset2, y, offset1), rune)); - components.add(new RitualComponent(new BlockPos(offset1, y, -offset2), rune)); - components.add(new RitualComponent(new BlockPos(-offset2, y, offset1), rune)); - components.add(new RitualComponent(new BlockPos(-offset1, y, offset2), rune)); - components.add(new RitualComponent(new BlockPos(offset2, y, -offset1), rune)); - components.add(new RitualComponent(new BlockPos(-offset1, y, -offset2), rune)); - components.add(new RitualComponent(new BlockPos(-offset2, y, -offset1), rune)); - } + /** + * @return a list of {@link RitualComponent} for checking the ritual. + */ + public abstract ArrayList getComponents(); - public void addCornerRunes(ArrayList components, int offset, int y, EnumRuneType rune) { - components.add(new RitualComponent(new BlockPos(offset, y, offset), rune)); - components.add(new RitualComponent(new BlockPos(offset, y, -offset), rune)); - components.add(new RitualComponent(new BlockPos(-offset, y, -offset), rune)); - components.add(new RitualComponent(new BlockPos(-offset, y, offset), rune)); - } + public void addOffsetRunes(ArrayList components, int offset1, int offset2, int y, EnumRuneType rune) + { + components.add(new RitualComponent(new BlockPos(offset1, y, offset2), rune)); + components.add(new RitualComponent(new BlockPos(offset2, y, offset1), rune)); + components.add(new RitualComponent(new BlockPos(offset1, y, -offset2), rune)); + components.add(new RitualComponent(new BlockPos(-offset2, y, offset1), rune)); + components.add(new RitualComponent(new BlockPos(-offset1, y, offset2), rune)); + components.add(new RitualComponent(new BlockPos(offset2, y, -offset1), rune)); + components.add(new RitualComponent(new BlockPos(-offset1, y, -offset2), rune)); + components.add(new RitualComponent(new BlockPos(-offset2, y, -offset1), rune)); + } - public void addParallelRunes(ArrayList components, int offset, int y, EnumRuneType rune) { - components.add(new RitualComponent(new BlockPos(offset, y, 0), rune)); - components.add(new RitualComponent(new BlockPos(-offset, y, 0), rune)); - components.add(new RitualComponent(new BlockPos(0, y, -offset), rune)); - components.add(new RitualComponent(new BlockPos(0, y, offset), rune)); - } + public void addCornerRunes(ArrayList components, int offset, int y, EnumRuneType rune) + { + components.add(new RitualComponent(new BlockPos(offset, y, offset), rune)); + components.add(new RitualComponent(new BlockPos(offset, y, -offset), rune)); + components.add(new RitualComponent(new BlockPos(-offset, y, -offset), rune)); + components.add(new RitualComponent(new BlockPos(-offset, y, offset), rune)); + } - public enum BreakType { - REDSTONE, BREAK_MRS, BREAK_STONE, ACTIVATE, DEACTIVATE, EXPLOSION, - } + public void addParallelRunes(ArrayList components, int offset, int y, EnumRuneType rune) + { + components.add(new RitualComponent(new BlockPos(offset, y, 0), rune)); + components.add(new RitualComponent(new BlockPos(-offset, y, 0), rune)); + components.add(new RitualComponent(new BlockPos(0, y, -offset), rune)); + components.add(new RitualComponent(new BlockPos(0, y, offset), rune)); + } + + public enum BreakType + { + REDSTONE, BREAK_MRS, BREAK_STONE, ACTIVATE, DEACTIVATE, EXPLOSION, + } } diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/RitualComponent.java b/src/main/java/WayofTime/bloodmagic/api/ritual/RitualComponent.java index 28bc0847..51a96f8c 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/RitualComponent.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/RitualComponent.java @@ -6,43 +6,49 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; /** - * Used to set a {@link EnumRuneType} type to a given {@link BlockPos} - * for usage in Ritual creation. + * Used to set a {@link EnumRuneType} type to a given {@link BlockPos} for usage + * in Ritual creation. */ @Getter @RequiredArgsConstructor -public class RitualComponent { +public class RitualComponent +{ private final BlockPos offset; private final EnumRuneType runeType; - public int getX(EnumFacing direction) { - switch (direction) { - case EAST: - return -this.getOffset().getZ(); - case SOUTH: - return -this.getOffset().getX(); - case WEST: - return this.getOffset().getZ(); - default: - return this.getOffset().getX(); + public int getX(EnumFacing direction) + { + switch (direction) + { + case EAST: + return -this.getOffset().getZ(); + case SOUTH: + return -this.getOffset().getX(); + case WEST: + return this.getOffset().getZ(); + default: + return this.getOffset().getX(); } } - public int getZ(EnumFacing direction) { - switch (direction) { - case EAST: - return this.getOffset().getX(); - case SOUTH: - return -this.getOffset().getZ(); - case WEST: - return -this.getOffset().getX(); - default: - return this.getOffset().getZ(); + public int getZ(EnumFacing direction) + { + switch (direction) + { + case EAST: + return this.getOffset().getX(); + case SOUTH: + return -this.getOffset().getZ(); + case WEST: + return -this.getOffset().getX(); + default: + return this.getOffset().getZ(); } } - - public BlockPos getOffset(EnumFacing direction) { - return new BlockPos(getX(direction), offset.getY(), getZ(direction)); + + public BlockPos getOffset(EnumFacing direction) + { + return new BlockPos(getX(direction), offset.getY(), getZ(direction)); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/RitualRenderer.java b/src/main/java/WayofTime/bloodmagic/api/ritual/RitualRenderer.java index 73881d10..4ce6a752 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/RitualRenderer.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/RitualRenderer.java @@ -3,11 +3,13 @@ package WayofTime.bloodmagic.api.ritual; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; -public abstract class RitualRenderer { +public abstract class RitualRenderer +{ public abstract void renderAt(IMasterRitualStone masterRitualStone, double x, double y, double z); - protected void bindTexture(ResourceLocation resourceLocation) { + protected void bindTexture(ResourceLocation resourceLocation) + { Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/imperfect/IImperfectRitualStone.java b/src/main/java/WayofTime/bloodmagic/api/ritual/imperfect/IImperfectRitualStone.java index 7818a091..7bb39c91 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/imperfect/IImperfectRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/imperfect/IImperfectRitualStone.java @@ -6,10 +6,11 @@ import net.minecraft.world.World; /** * This interface is for internal implementation only. - * + * * It is provided via the API for easy obtaining of basic data. */ -public interface IImperfectRitualStone { +public interface IImperfectRitualStone +{ boolean performRitual(World world, BlockPos pos, ImperfectRitual imperfectRitual, EntityPlayer player); diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/imperfect/ImperfectRitual.java b/src/main/java/WayofTime/bloodmagic/api/ritual/imperfect/ImperfectRitual.java index 7e9d4a2a..d42973b7 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/imperfect/ImperfectRitual.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/imperfect/ImperfectRitual.java @@ -9,13 +9,15 @@ import net.minecraft.util.BlockPos; import net.minecraft.world.World; /** - * Abstract class for creating new imperfect rituals. ImperfectRituals need be registered with + * Abstract class for creating new imperfect rituals. ImperfectRituals need be + * registered with * {@link WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry#registerRitual(ImperfectRitual)} */ @RequiredArgsConstructor @Getter @EqualsAndHashCode -public abstract class ImperfectRitual { +public abstract class ImperfectRitual +{ private final String name; private final BlockStack requiredBlock; @@ -23,26 +25,34 @@ public abstract class ImperfectRitual { private final boolean lightshow; /** - * @param name - The name of the ritual - * @param requiredBlock - The block required above the ImperfectRitualStone - * @param activationCost - Base LP cost for activating the ritual + * @param name + * - The name of the ritual + * @param requiredBlock + * - The block required above the ImperfectRitualStone + * @param activationCost + * - Base LP cost for activating the ritual */ - public ImperfectRitual(String name, BlockStack requiredBlock, int activationCost) { + public ImperfectRitual(String name, BlockStack requiredBlock, int activationCost) + { this(name, requiredBlock, activationCost, false); } /** * Called when the player activates the ritual * {@link WayofTime.bloodmagic.tile.TileImperfectRitualStone#performRitual(World, BlockPos, ImperfectRitual, EntityPlayer)} - * - * @param imperfectRitualStone - The {@link IImperfectRitualStone} that the ritual is bound to - * @param player - The player activating the ritual + * + * @param imperfectRitualStone + * - The {@link IImperfectRitualStone} that the ritual is bound + * to + * @param player + * - The player activating the ritual * @return - Whether activation was successful */ public abstract boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player); @Override - public String toString() { + public String toString() + { return getName() + ":" + getRequiredBlock().toString() + "@" + getActivationCost(); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/BindableHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/BindableHelper.java index f0fe7289..b7716244 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/BindableHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/BindableHelper.java @@ -10,40 +10,50 @@ import net.minecraftforge.common.MinecraftForge; import java.util.UUID; -public class BindableHelper { +public class BindableHelper +{ /** - * Bind an item to a player. Handles checking if the player was an instanceof - * {@link net.minecraftforge.common.util.FakePlayer} or other type of Fake Player. - * - * @param stack - The ItemStack to bind - * @param player - The Player to bind the ItemStack to - * + * Bind an item to a player. Handles checking if the player was an + * instanceof {@link net.minecraftforge.common.util.FakePlayer} or other + * type of Fake Player. + * + * @param stack + * - The ItemStack to bind + * @param player + * - The Player to bind the ItemStack to + * * @return - Whether binding was successful */ - public static boolean checkAndSetItemOwner(ItemStack stack, EntityPlayer player) { + public static boolean checkAndSetItemOwner(ItemStack stack, EntityPlayer player) + { return !PlayerHelper.isFakePlayer(player) && checkAndSetItemOwner(stack, PlayerHelper.getUUIDFromPlayer(player)); } /** * Bind an item to a username. - * - * Requires the Item contained in the ItemStack to be an instanceof {@link IBindable} - * + * + * Requires the Item contained in the ItemStack to be an instanceof + * {@link IBindable} + * * Fires {@link ItemBindEvent}. - * - * @param stack - The ItemStack to bind - * @param uuid - The username to bind the ItemStack to - * + * + * @param stack + * - The ItemStack to bind + * @param uuid + * - The username to bind the ItemStack to + * * @return - Whether the binding was successful */ - public static boolean checkAndSetItemOwner(ItemStack stack, String uuid) { + public static boolean checkAndSetItemOwner(ItemStack stack, String uuid) + { stack = NBTHelper.checkNBT(stack); if (!(stack.getItem() instanceof IBindable)) return false; - if (Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID))) { + if (Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID))) + { MinecraftForge.EVENT_BUS.post(new ItemBindEvent(PlayerHelper.getPlayerFromUUID(uuid), uuid, stack)); ((IBindable) stack.getItem()).onBind(PlayerHelper.getPlayerFromUUID(uuid), stack); stack.getTagCompound().setString(Constants.NBT.OWNER_UUID, uuid); @@ -56,18 +66,22 @@ public class BindableHelper { /** * @see BindableHelper#checkAndSetItemOwner(ItemStack, String) */ - public static boolean checkAndSetItemOwner(ItemStack stack, UUID uuid) { + public static boolean checkAndSetItemOwner(ItemStack stack, UUID uuid) + { return checkAndSetItemOwner(stack, uuid.toString()); } /** - * Sets the Owner of the item without checking if it is already bound. - * Also bypasses {@link ItemBindEvent}. - * - * @param stack - The ItemStack to bind - * @param ownerName - The username to bind the ItemStack to + * Sets the Owner of the item without checking if it is already bound. Also + * bypasses {@link ItemBindEvent}. + * + * @param stack + * - The ItemStack to bind + * @param ownerName + * - The username to bind the ItemStack to */ - public static void setItemOwner(ItemStack stack, String ownerName) { + public static void setItemOwner(ItemStack stack, String ownerName) + { stack = NBTHelper.checkNBT(stack); stack.getTagCompound().setString(Constants.NBT.OWNER_UUID, ownerName); @@ -75,12 +89,14 @@ public class BindableHelper { /** * Used to safely obtain the username of the ItemStack's owner - * - * @param stack - The ItemStack to check the owner of - * + * + * @param stack + * - The ItemStack to check the owner of + * * @return - The username of the ItemStack's owner */ - public static String getOwnerName(ItemStack stack) { + public static String getOwnerName(ItemStack stack) + { stack = NBTHelper.checkNBT(stack); return PlayerHelper.getUsernameFromStack(stack); @@ -88,12 +104,14 @@ public class BindableHelper { /** * Used to safely obtain the UUID of the ItemStack's owner - * - * @param stack - The ItemStack to check the owner of - * + * + * @param stack + * - The ItemStack to check the owner of + * * @return - The UUID of the ItemStack's owner */ - public static String getOwnerUUID(ItemStack stack) { + public static String getOwnerUUID(ItemStack stack) + { stack = NBTHelper.checkNBT(stack); return stack.getTagCompound().getString(Constants.NBT.OWNER_UUID); diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/IncenseHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/IncenseHelper.java index 3adb86dd..74f9930c 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/IncenseHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/IncenseHelper.java @@ -4,18 +4,22 @@ import WayofTime.bloodmagic.api.Constants; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; -public class IncenseHelper { +public class IncenseHelper +{ - public static float getCurrentIncense(EntityPlayer player) { + public static float getCurrentIncense(EntityPlayer player) + { NBTTagCompound data = player.getEntityData(); - if (data.hasKey(Constants.NBT.CURRENT_INCENSE)) { + if (data.hasKey(Constants.NBT.CURRENT_INCENSE)) + { return data.getFloat(Constants.NBT.CURRENT_INCENSE); } return 0; } - public static void setCurrentIncense(EntityPlayer player, float amount) { + public static void setCurrentIncense(EntityPlayer player, float amount) + { NBTTagCompound data = player.getEntityData(); data.setFloat(Constants.NBT.CURRENT_INCENSE, amount); } diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/LogHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/LogHelper.java index 4dabdc77..70cd0c80 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/LogHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/LogHelper.java @@ -4,34 +4,41 @@ import WayofTime.bloodmagic.api.BloodMagicAPI; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public class LogHelper { +public class LogHelper +{ private Logger logger; - public LogHelper(String logger) { + public LogHelper(String logger) + { this.logger = LogManager.getLogger(logger); } - public void info(String info, Object ... format) { + public void info(String info, Object... format) + { if (BloodMagicAPI.isLoggingEnabled()) logger.info(info, format); } - public void error(String error, Object ... format) { + public void error(String error, Object... format) + { if (BloodMagicAPI.isLoggingEnabled()) logger.info(error, format); } - public void debug(String debug, Object ... format) { + public void debug(String debug, Object... format) + { if (BloodMagicAPI.isLoggingEnabled()) logger.info(debug, format); } - public void fatal(String fatal, Object ... format) { + public void fatal(String fatal, Object... format) + { logger.fatal(fatal, format); } - public Logger getLogger() { + public Logger getLogger() + { return logger; } } diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/NBTHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/NBTHelper.java index 385d2325..b4a85470 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/NBTHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/NBTHelper.java @@ -3,9 +3,11 @@ package WayofTime.bloodmagic.api.util.helper; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class NBTHelper { +public class NBTHelper +{ - public static ItemStack checkNBT(ItemStack stack) { + public static ItemStack checkNBT(ItemStack stack) + { if (stack.getTagCompound() == null) stack.setTagCompound(new NBTTagCompound()); diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/NetworkHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/NetworkHelper.java index 6a730e2a..b3addcaf 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/NetworkHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/NetworkHelper.java @@ -15,22 +15,27 @@ import net.minecraftforge.fml.common.eventhandler.Event; import java.util.UUID; -public class NetworkHelper { +public class NetworkHelper +{ // Get /** * Gets the SoulNetwork for the player. - * - * @param name - The username of the SoulNetwork owner - * @param world - The world - * + * + * @param name + * - The username of the SoulNetwork owner + * @param world + * - The world + * * @return - The SoulNetwork for the given name. */ - public static SoulNetwork getSoulNetwork(String name, World world) { + public static SoulNetwork getSoulNetwork(String name, World world) + { SoulNetwork network = (SoulNetwork) world.getMapStorage().loadData(SoulNetwork.class, name); - if (network == null) { + if (network == null) + { network = new SoulNetwork(name); world.getMapStorage().setData(name, network); } @@ -41,42 +46,51 @@ public class NetworkHelper { /** * @see NetworkHelper#getSoulNetwork(String, World) */ - public static SoulNetwork getSoulNetwork(UUID uuid, World world) { + public static SoulNetwork getSoulNetwork(UUID uuid, World world) + { return getSoulNetwork(PlayerHelper.getUsernameFromUUID(uuid), world); } /** * @see NetworkHelper#getSoulNetwork(String, World) */ - public static SoulNetwork getSoulNetwork(EntityPlayer player, World world) { + public static SoulNetwork getSoulNetwork(EntityPlayer player, World world) + { return getSoulNetwork(PlayerHelper.getUUIDFromPlayer(player), world); } /** * Gets the current orb tier of the SoulNetwork. - * - * @param soulNetwork - SoulNetwork to get the tier of. - * + * + * @param soulNetwork + * - SoulNetwork to get the tier of. + * * @return - The Orb tier of the given SoulNetwork */ - public static int getCurrentMaxOrb(SoulNetwork soulNetwork) { + public static int getCurrentMaxOrb(SoulNetwork soulNetwork) + { return soulNetwork.getOrbTier(); } // Syphon /** - * Syphons from the player and damages them if there was not enough stored LP. - * + * Syphons from the player and damages them if there was not enough stored + * LP. + * * Handles null-checking the player for you. - * - * @param soulNetwork - SoulNetwork to syphon from - * @param toSyphon - Amount of LP to syphon - * + * + * @param soulNetwork + * - SoulNetwork to syphon from + * @param toSyphon + * - Amount of LP to syphon + * * @return - Whether the action should be performed. */ - public static boolean syphonAndDamage(SoulNetwork soulNetwork, int toSyphon) { - if (soulNetwork.getPlayer() == null) { + public static boolean syphonAndDamage(SoulNetwork soulNetwork, int toSyphon) + { + if (soulNetwork.getPlayer() == null) + { soulNetwork.syphon(toSyphon); return true; } @@ -86,14 +100,18 @@ public class NetworkHelper { /** * Syphons a player from within a container. - * - * @param stack - ItemStack in the Container. - * @param world - The world the Container is in - * @param toSyphon - Amount of LP to syphon - * + * + * @param stack + * - ItemStack in the Container. + * @param world + * - The world the Container is in + * @param toSyphon + * - Amount of LP to syphon + * * @return - If the syphon was successful. */ - public static boolean syphonFromContainer(ItemStack stack, World world, int toSyphon) { + public static boolean syphonFromContainer(ItemStack stack, World world, int toSyphon) + { stack = NBTHelper.checkNBT(stack); String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_UUID); @@ -110,13 +128,16 @@ public class NetworkHelper { // Set /** - * Sets the orb tier of the SoulNetwork to the given orb. Will not set - * if the given tier is lower than the current tier. - * - * @param soulNetwork - SoulNetwork to set the orb tier of - * @param maxOrb - Tier of orb to set to + * Sets the orb tier of the SoulNetwork to the given orb. Will not set if + * the given tier is lower than the current tier. + * + * @param soulNetwork + * - SoulNetwork to set the orb tier of + * @param maxOrb + * - Tier of orb to set to */ - public static void setMaxOrb(SoulNetwork soulNetwork, int maxOrb) { + public static void setMaxOrb(SoulNetwork soulNetwork, int maxOrb) + { soulNetwork.setOrbTier(Math.max(maxOrb, soulNetwork.getOrbTier())); soulNetwork.markDirty(); } @@ -124,23 +145,29 @@ public class NetworkHelper { // TODO - Remove everything below. It is deprecated and should not be used. /** - * Master method used to syphon from the player's network, and will damage them accordingly if they do not have enough LP. - * Does not drain on the client side. - * - * @param stack Owned itemStack - * @param player Player using the item - * - * @return True if the action should be executed and false if it should not. Always returns false if client-sided. + * Master method used to syphon from the player's network, and will damage + * them accordingly if they do not have enough LP. Does not drain on the + * client side. + * + * @param stack + * Owned itemStack + * @param player + * Player using the item + * + * @return True if the action should be executed and false if it should not. + * Always returns false if client-sided. */ @Deprecated - public static boolean syphonAndDamageFromNetwork(ItemStack stack, EntityPlayer player, int syphon) { + public static boolean syphonAndDamageFromNetwork(ItemStack stack, EntityPlayer player, int syphon) + { if (player.worldObj.isRemote) return false; stack = NBTHelper.checkNBT(stack); String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_UUID); - if (!Strings.isNullOrEmpty(ownerName)) { + if (!Strings.isNullOrEmpty(ownerName)) + { SoulNetworkEvent.ItemDrainNetworkEvent event = new SoulNetworkEvent.ItemDrainNetworkEvent(player, ownerName, stack, syphon); if (MinecraftForge.EVENT_BUS.post(event)) @@ -151,7 +178,8 @@ public class NetworkHelper { if (drainAmount == 0 || event.shouldDamage) hurtPlayer(player, event.syphon); - //The event has been told to prevent the action but allow all repercussions of using the item. + // The event has been told to prevent the action but allow all + // repercussions of using the item. return event.getResult() != Event.Result.DENY; } @@ -163,7 +191,8 @@ public class NetworkHelper { } @Deprecated - public static boolean syphonFromNetworkWhileInContainer(ItemStack stack, int syphon) { + public static boolean syphonFromNetworkWhileInContainer(ItemStack stack, int syphon) + { stack = NBTHelper.checkNBT(stack); String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_UUID); @@ -179,7 +208,8 @@ public class NetworkHelper { } @Deprecated - public static int syphonFromNetwork(ItemStack stack, int syphon) { + public static int syphonFromNetwork(ItemStack stack, int syphon) + { stack = NBTHelper.checkNBT(stack); String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_UUID); if (!Strings.isNullOrEmpty(ownerName)) @@ -189,19 +219,22 @@ public class NetworkHelper { } @Deprecated - public static int syphonFromNetwork(String ownerName, int syphon) { + public static int syphonFromNetwork(String ownerName, int syphon) + { if (MinecraftServer.getServer() == null) return 0; World world = MinecraftServer.getServer().worldServers[0]; SoulNetwork network = (SoulNetwork) world.loadItemData(SoulNetwork.class, ownerName); - if (network == null) { + if (network == null) + { network = new SoulNetwork(ownerName); world.setItemData(ownerName, network); } - if (network.getCurrentEssence() >= syphon) { + if (network.getCurrentEssence() >= syphon) + { network.setCurrentEssence(network.getCurrentEssence() - syphon); network.markDirty(); return syphon; @@ -214,11 +247,12 @@ public class NetworkHelper { /** * A method to add to an owner's network up to a maximum value. - * + * * @return amount added to the network */ @Deprecated - public static int addCurrentEssenceToMaximum(String ownerName, int addedEssence, int maximum) { + public static int addCurrentEssenceToMaximum(String ownerName, int addedEssence, int maximum) + { AddToNetworkEvent event = new AddToNetworkEvent(ownerName, addedEssence, maximum); if (MinecraftForge.EVENT_BUS.post(event)) @@ -230,7 +264,8 @@ public class NetworkHelper { World world = MinecraftServer.getServer().worldServers[0]; SoulNetwork data = (SoulNetwork) world.loadItemData(SoulNetwork.class, event.ownerNetwork); - if (data == null) { + if (data == null) + { data = new SoulNetwork(event.ownerNetwork); world.setItemData(event.ownerNetwork, data); } @@ -250,14 +285,16 @@ public class NetworkHelper { // Get @Deprecated - public static int getCurrentEssence(String ownerName) { + public static int getCurrentEssence(String ownerName) + { if (MinecraftServer.getServer() == null) return 0; World world = MinecraftServer.getServer().worldServers[0]; SoulNetwork network = (SoulNetwork) world.loadItemData(SoulNetwork.class, ownerName); - if (network == null) { + if (network == null) + { network = new SoulNetwork(ownerName); world.setItemData(ownerName, network); } @@ -268,20 +305,27 @@ public class NetworkHelper { // Do damage @Deprecated - public static void hurtPlayer(EntityPlayer user, int energySyphoned) { - if (energySyphoned < 100 && energySyphoned > 0) { - if (!user.capabilities.isCreativeMode) { + public static void hurtPlayer(EntityPlayer user, int energySyphoned) + { + if (energySyphoned < 100 && energySyphoned > 0) + { + if (!user.capabilities.isCreativeMode) + { user.setHealth((user.getHealth() - 1)); if (user.getHealth() <= 0.0005f) user.onDeath(BloodMagicAPI.getDamageSource()); } - } else if (energySyphoned >= 100) { - if (!user.capabilities.isCreativeMode) { - for (int i = 0; i < ((energySyphoned + 99) / 100); i++) { + } else if (energySyphoned >= 100) + { + if (!user.capabilities.isCreativeMode) + { + for (int i = 0; i < ((energySyphoned + 99) / 100); i++) + { user.setHealth((user.getHealth() - 1)); - if (user.getHealth() <= 0.0005f) { + if (user.getHealth() <= 0.0005f) + { user.onDeath(BloodMagicAPI.getDamageSource()); break; } @@ -291,8 +335,10 @@ public class NetworkHelper { } @Deprecated - public static void hurtPlayer(EntityPlayer user, float damage) { - if (!user.capabilities.isCreativeMode) { + public static void hurtPlayer(EntityPlayer user, float damage) + { + if (!user.capabilities.isCreativeMode) + { user.attackEntityFrom(BloodMagicAPI.getDamageSource(), 0F); user.setHealth((user.getHealth() - damage)); } diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerHelper.java index 9c29bdea..40041196 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerHelper.java @@ -13,59 +13,71 @@ import net.minecraftforge.common.util.FakePlayer; import java.util.UUID; import java.util.regex.Pattern; -public class PlayerHelper { +public class PlayerHelper +{ private static final Pattern FAKE_PLAYER_PATTERN = Pattern.compile("^(?:\\[.*\\])|(?:ComputerCraft)$"); - public static String getUsernameFromPlayer(EntityPlayer player) { + public static String getUsernameFromPlayer(EntityPlayer player) + { return UsernameCache.getLastKnownUsername(getUUIDFromPlayer(player)); } - public static EntityPlayer getPlayerFromUsername(String username) { + public static EntityPlayer getPlayerFromUsername(String username) + { if (MinecraftServer.getServer() == null) return null; return MinecraftServer.getServer().getConfigurationManager().getPlayerByUsername(username); } - public static EntityPlayer getPlayerFromUUID(String uuid) { + public static EntityPlayer getPlayerFromUUID(String uuid) + { return getPlayerFromUsername(getUsernameFromUUID(uuid)); } - public static EntityPlayer getPlayerFromUUID(UUID uuid) { + public static EntityPlayer getPlayerFromUUID(UUID uuid) + { return getPlayerFromUsername(getUsernameFromUUID(uuid)); } - public static UUID getUUIDFromPlayer(EntityPlayer player) { + public static UUID getUUIDFromPlayer(EntityPlayer player) + { return player.getGameProfile().getId(); } - public static String getUsernameFromUUID(String uuid) { + public static String getUsernameFromUUID(String uuid) + { return UsernameCache.getLastKnownUsername(UUID.fromString(uuid)); } - public static String getUsernameFromUUID(UUID uuid) { + public static String getUsernameFromUUID(UUID uuid) + { return UsernameCache.getLastKnownUsername(uuid); } - public static String getUsernameFromStack(ItemStack stack) { + public static String getUsernameFromStack(ItemStack stack) + { stack = NBTHelper.checkNBT(stack); return PlayerHelper.getUsernameFromUUID(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)); } - public static boolean isFakePlayer(EntityPlayer player) { + public static boolean isFakePlayer(EntityPlayer player) + { return player instanceof FakePlayer || FAKE_PLAYER_PATTERN.matcher(getUsernameFromPlayer(player)).matches(); } - public static void causeNauseaToPlayer(ItemStack stack) { + public static void causeNauseaToPlayer(ItemStack stack) + { stack = NBTHelper.checkNBT(stack); if (!Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID))) causeNauseaToPlayer(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)); } - public static void causeNauseaToPlayer(String ownerName) { + public static void causeNauseaToPlayer(String ownerName) + { EntityPlayer player = getPlayerFromUsername(ownerName); if (player == null) diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerSacrificeHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerSacrificeHelper.java index 3bcdadb9..ef83b088 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerSacrificeHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerSacrificeHelper.java @@ -8,48 +8,59 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.world.World; -public class PlayerSacrificeHelper { +public class PlayerSacrificeHelper +{ public static float scalingOfSacrifice = 0.001f; public static int soulFrayDuration = 400; public static Potion soulFrayId; - public static float getPlayerIncense(EntityPlayer player) { + public static float getPlayerIncense(EntityPlayer player) + { return IncenseHelper.getCurrentIncense(player); } - public static void setPlayerIncense(EntityPlayer player, float amount) { + public static void setPlayerIncense(EntityPlayer player, float amount) + { IncenseHelper.setCurrentIncense(player, amount); } - public static boolean incrementIncense(EntityPlayer player, float min, float max, float increment) { + public static boolean incrementIncense(EntityPlayer player, float min, float max, float increment) + { float amount = getPlayerIncense(player); - if (amount < min || amount >= max) { + if (amount < min || amount >= max) + { return false; } amount = amount + Math.min(increment, max - amount); setPlayerIncense(player, amount); -// System.out.println("Amount of incense: " + amount + ", Increment: " + increment); + // System.out.println("Amount of incense: " + amount + ", Increment: " + + // increment); return true; } - public static boolean sacrificePlayerHealth(EntityPlayer player) { - if (player.isPotionActive(soulFrayId)) { + public static boolean sacrificePlayerHealth(EntityPlayer player) + { + if (player.isPotionActive(soulFrayId)) + { return false; } float amount = getPlayerIncense(player); - if (amount >= 0) { + if (amount >= 0) + { float health = player.getHealth(); float maxHealth = player.getMaxHealth(); - if (health > maxHealth / 10.0) { + if (health > maxHealth / 10.0) + { float sacrificedHealth = health - maxHealth / 10.0f; - if (findAndFillAltar(player.getEntityWorld(), player, (int) (sacrificedHealth * 100f * getModifier(amount)))) { + if (findAndFillAltar(player.getEntityWorld(), player, (int) (sacrificedHealth * 100f * getModifier(amount)))) + { player.setHealth(maxHealth / 10.0f); setPlayerIncense(player, 0); player.addPotionEffect(new PotionEffect(soulFrayId.id, soulFrayDuration)); @@ -62,17 +73,20 @@ public class PlayerSacrificeHelper { return false; } - public static float getModifier(float amount) { + public static float getModifier(float amount) + { return 1 + amount * scalingOfSacrifice; } - public static boolean findAndFillAltar(World world, EntityPlayer player, int amount) { + public static boolean findAndFillAltar(World world, EntityPlayer player, int amount) + { int posX = (int) Math.round(player.posX - 0.5f); int posY = (int) player.posY; int posZ = (int) Math.round(player.posZ - 0.5f); IBloodAltar altarEntity = getAltar(world, new BlockPos(posX, posY, posZ)); - if (altarEntity == null) { + if (altarEntity == null) + { return false; } @@ -82,15 +96,20 @@ public class PlayerSacrificeHelper { return true; } - public static IBloodAltar getAltar(World world, BlockPos blockPos) { + public static IBloodAltar getAltar(World world, BlockPos blockPos) + { TileEntity tileEntity; - for (int i = -2; i <= 2; i++) { - for (int j = -2; j <= 2; j++) { - for (int k = -2; k <= 1; k++) { + for (int i = -2; i <= 2; i++) + { + for (int j = -2; j <= 2; j++) + { + for (int k = -2; k <= 1; k++) + { tileEntity = world.getTileEntity(new BlockPos(i + blockPos.getX(), k + blockPos.getY(), j + blockPos.getZ())); - if (tileEntity instanceof IBloodAltar) { + if (tileEntity instanceof IBloodAltar) + { return (IBloodAltar) tileEntity; } } diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/RitualHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/RitualHelper.java index 6712a4bd..38befb63 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/RitualHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/RitualHelper.java @@ -19,20 +19,24 @@ import WayofTime.bloodmagic.api.ritual.Ritual; import WayofTime.bloodmagic.api.ritual.RitualComponent; import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual; -public class RitualHelper { +public class RitualHelper +{ - public static boolean canCrystalActivate(Ritual ritual, int crystalLevel) { + public static boolean canCrystalActivate(Ritual ritual, int crystalLevel) + { return ritual.getCrystalLevel() <= crystalLevel && RitualRegistry.ritualEnabled(ritual); } - public static String getNextRitualKey(String currentKey) { + public static String getNextRitualKey(String currentKey) + { int currentIndex = RitualRegistry.getIds().indexOf(currentKey); int nextIndex = RitualRegistry.getRituals().listIterator(currentIndex).nextIndex(); return RitualRegistry.getIds().get(nextIndex); } - public static String getPrevRitualKey(String currentKey) { + public static String getPrevRitualKey(String currentKey) + { int currentIndex = RitualRegistry.getIds().indexOf(currentKey); int previousIndex = RitualRegistry.getIds().listIterator(currentIndex).previousIndex(); @@ -40,87 +44,106 @@ public class RitualHelper { } /** - * Checks the RitualRegistry to see if the configuration of the ritual stones in the world is valid - * for the given EnumFacing. - * + * Checks the RitualRegistry to see if the configuration of the ritual + * stones in the world is valid for the given EnumFacing. + * * @return The ID of the valid ritual */ - public static String getValidRitual(World world, BlockPos pos) { - for(String key : RitualRegistry.getIds()) { - for(EnumFacing direction : EnumFacing.HORIZONTALS) { - boolean test = checkValidRitual(world, pos, key, direction); - if(test) { - return key; - } - } - } - - return ""; + public static String getValidRitual(World world, BlockPos pos) + { + for (String key : RitualRegistry.getIds()) + { + for (EnumFacing direction : EnumFacing.HORIZONTALS) + { + boolean test = checkValidRitual(world, pos, key, direction); + if (test) + { + return key; + } + } + } + + return ""; } - - public static EnumFacing getDirectionOfRitual(World world, BlockPos pos, String key) { - for(EnumFacing direction : EnumFacing.HORIZONTALS) { - boolean test = checkValidRitual(world, pos, key, direction); - if(test) { - return direction; - } - } - - return null; + + public static EnumFacing getDirectionOfRitual(World world, BlockPos pos, String key) + { + for (EnumFacing direction : EnumFacing.HORIZONTALS) + { + boolean test = checkValidRitual(world, pos, key, direction); + if (test) + { + return direction; + } + } + + return null; } - - public static boolean checkValidRitual(World world, BlockPos pos, String ritualId, EnumFacing direction) { - Ritual ritual = RitualRegistry.getRitualForId(ritualId); - if(ritual == null) { - return false; - } - + + public static boolean checkValidRitual(World world, BlockPos pos, String ritualId, EnumFacing direction) + { + Ritual ritual = RitualRegistry.getRitualForId(ritualId); + if (ritual == null) + { + return false; + } + ArrayList components = ritual.getComponents(); - + if (components == null) return false; - - for (RitualComponent component : components) { - BlockPos newPos = pos.add(component.getOffset(direction)); + + for (RitualComponent component : components) + { + BlockPos newPos = pos.add(component.getOffset(direction)); IBlockState worldState = world.getBlockState(newPos); Block block = worldState.getBlock(); - if (block instanceof IRitualStone) { - if(!((IRitualStone)block).isRuneType(world, newPos, component.getRuneType())) { - return false; - } - }else { - return false; + if (block instanceof IRitualStone) + { + if (!((IRitualStone) block).isRuneType(world, newPos, component.getRuneType())) + { + return false; + } + } else + { + return false; } } return true; } - public static void checkImperfectRituals(Configuration config, String packageName, String category) { + public static void checkImperfectRituals(Configuration config, String packageName, String category) + { checkRituals(config, packageName, category, ImperfectRitual.class, ImperfectRitualRegistry.enabledRituals); } - public static void checkRituals(Configuration config, String packageName, String category) { + public static void checkRituals(Configuration config, String packageName, String category) + { checkRituals(config, packageName, category, Ritual.class, RitualRegistry.enabledRituals); } /** - * Adds your Ritual to the {@link RitualRegistry#enabledRituals} Map. - * This is used to determine whether your effect is enabled or not. - * - * The config option will be created as {@code B:ClassName=true} with a comment of - * {@code Enables the ClassName ritual}. - * + * Adds your Ritual to the {@link RitualRegistry#enabledRituals} Map. This + * is used to determine whether your effect is enabled or not. + * + * The config option will be created as {@code B:ClassName=true} with a + * comment of {@code Enables the ClassName ritual}. + * * Use {@link #} - * + * * Should be safe to modify at any point. - * - * @param config - Your mod's Forge {@link Configuration} object. - * @param packageName - The package your Rituals are located in. - * @param category - The config category to write to. + * + * @param config + * - Your mod's Forge {@link Configuration} object. + * @param packageName + * - The package your Rituals are located in. + * @param category + * - The config category to write to. */ @SuppressWarnings("unchecked") - private static void checkRituals(Configuration config, String packageName, String category, Class ritualClass, Map enabledMap) { + private static void checkRituals(Configuration config, String packageName, String category, Class ritualClass, Map enabledMap) + { String name = packageName; if (!name.startsWith("/")) name = "/" + name; @@ -129,24 +152,31 @@ public class RitualHelper { URL url = BloodMagic.class.getResource(name); File directory = new File(url.getFile()); - if (directory.exists()) { + if (directory.exists()) + { String[] files = directory.list(); - for (String file : files) { - if (file.endsWith(".class")) { + for (String file : files) + { + if (file.endsWith(".class")) + { String className = file.substring(0, file.length() - 6); - try { + try + { Object o = Class.forName(packageName + "." + className).newInstance(); if (ritualClass.isInstance(o)) enabledMap.put(ritualClass.cast(o), config.get(category, className, true).getBoolean()); - } catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) + { e.printStackTrace(); - } catch (InstantiationException e) { + } catch (InstantiationException e) + { e.printStackTrace(); - } catch (IllegalAccessException e) { + } catch (IllegalAccessException e) + { e.printStackTrace(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyArray.java b/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyArray.java index 61d9fee6..7cd8b6e5 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyArray.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockAlchemyArray.java @@ -23,76 +23,90 @@ import WayofTime.bloodmagic.tile.TileAlchemyArray; import WayofTime.bloodmagic.tile.TileAlchemyArray; import WayofTime.bloodmagic.util.Utils; -public class BlockAlchemyArray extends BlockContainer { +public class BlockAlchemyArray extends BlockContainer +{ - public BlockAlchemyArray() { - super(Material.cloth); + public BlockAlchemyArray() + { + super(Material.cloth); - setUnlocalizedName(Constants.Mod.MODID + ".alchemyArray"); - setCreativeTab(BloodMagic.tabBloodMagic); - this.setHardness(0.1f); - } + setUnlocalizedName(Constants.Mod.MODID + ".alchemyArray"); + setCreativeTab(BloodMagic.tabBloodMagic); + this.setHardness(0.1f); + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() + { + return false; + } - @Override - @SideOnly(Side.CLIENT) - public EnumWorldBlockLayer getBlockLayer() { - return EnumWorldBlockLayer.CUTOUT; - } + @Override + @SideOnly(Side.CLIENT) + public EnumWorldBlockLayer getBlockLayer() + { + return EnumWorldBlockLayer.CUTOUT; + } - @Override - public boolean isFullCube() { - return false; - } + @Override + public boolean isFullCube() + { + return false; + } - @Override - public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) { - this.setBlockBounds(0, 0, 0, 1, 0.1f, 1); - } + @Override + public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) + { + this.setBlockBounds(0, 0, 0, 1, 0.1f, 1); + } - @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) { - TileAlchemyArray array = (TileAlchemyArray) world.getTileEntity(pos); + @Override + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) + { + TileAlchemyArray array = (TileAlchemyArray) world.getTileEntity(pos); - if (array == null || player.isSneaking()) - return false; + if (array == null || player.isSneaking()) + return false; - ItemStack playerItem = player.getCurrentEquippedItem(); + ItemStack playerItem = player.getCurrentEquippedItem(); - if (playerItem != null) { - if (array.getStackInSlot(0) == null) { - Utils.insertItemToTile(array, player, 0); - } else { - Utils.insertItemToTile(array, player, 1); - array.attemptCraft(); - } - } + if (playerItem != null) + { + if (array.getStackInSlot(0) == null) + { + Utils.insertItemToTile(array, player, 0); + } else + { + Utils.insertItemToTile(array, player, 1); + array.attemptCraft(); + } + } - world.markBlockForUpdate(pos); - return true; - } + world.markBlockForUpdate(pos); + return true; + } - @Override - public int quantityDropped(Random random) { - return 0; - } + @Override + public int quantityDropped(Random random) + { + return 0; + } - @Override - public int getRenderType() { - return -1; - } + @Override + public int getRenderType() + { + return -1; + } - @Override - public TileEntity createNewTileEntity(World worldIn, int meta) { - return new TileAlchemyArray(); - } - - @Override - public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) { + @Override + public TileEntity createNewTileEntity(World worldIn, int meta) + { + return new TileAlchemyArray(); + } + + @Override + public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) + { TileAlchemyArray alchemyArray = (TileAlchemyArray) world.getTileEntity(blockPos); if (alchemyArray != null) alchemyArray.dropItems(); diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockAltar.java b/src/main/java/WayofTime/bloodmagic/block/BlockAltar.java index e4c20bc1..6f5cb732 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockAltar.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockAltar.java @@ -16,9 +16,11 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; -public class BlockAltar extends BlockContainer { +public class BlockAltar extends BlockContainer +{ - public BlockAltar() { + public BlockAltar() + { super(Material.rock); setUnlocalizedName(Constants.Mod.MODID + ".altar"); @@ -26,32 +28,38 @@ public class BlockAltar extends BlockContainer { } @Override - public boolean isOpaqueCube() { + public boolean isOpaqueCube() + { return false; } @Override - public boolean isFullCube() { + public boolean isFullCube() + { return false; } @Override - public boolean isVisuallyOpaque() { + public boolean isVisuallyOpaque() + { return false; } @Override - public int getRenderType() { + public int getRenderType() + { return 3; } @Override - public TileEntity createNewTileEntity(World world, int meta) { + public TileEntity createNewTileEntity(World world, int meta) + { return new TileAltar(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) + { TileAltar altar = (TileAltar) world.getTileEntity(pos); if (altar == null || player.isSneaking()) @@ -59,8 +67,10 @@ public class BlockAltar extends BlockContainer { ItemStack playerItem = player.getCurrentEquippedItem(); - if (playerItem != null) { - if (playerItem.getItem() instanceof IAltarReader || playerItem.getItem() instanceof IAltarManipulator) { + if (playerItem != null) + { + if (playerItem.getItem() instanceof IAltarReader || playerItem.getItem() instanceof IAltarManipulator) + { playerItem.getItem().onItemRightClick(playerItem, world, player); return true; } @@ -76,7 +86,8 @@ public class BlockAltar extends BlockContainer { } @Override - public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) { + public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) + { TileAltar tileAltar = (TileAltar) world.getTileEntity(blockPos); if (tileAltar != null) tileAltar.dropItems(); diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockBloodLight.java b/src/main/java/WayofTime/bloodmagic/block/BlockBloodLight.java index 63e26644..56aefe9a 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockBloodLight.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockBloodLight.java @@ -17,9 +17,11 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; import java.util.Random; -public class BlockBloodLight extends Block { +public class BlockBloodLight extends Block +{ - public BlockBloodLight() { + public BlockBloodLight() + { super(Material.cloth); setUnlocalizedName(Constants.Mod.MODID + ".bloodLight"); @@ -27,30 +29,36 @@ public class BlockBloodLight extends Block { } @Override - public boolean isOpaqueCube() { + public boolean isOpaqueCube() + { return false; } @Override @SideOnly(Side.CLIENT) - public EnumWorldBlockLayer getBlockLayer() { + public EnumWorldBlockLayer getBlockLayer() + { return EnumWorldBlockLayer.CUTOUT; } @Override - public boolean isFullCube() { + public boolean isFullCube() + { return false; } @Override - public int getLightValue() { + public int getLightValue() + { return 15; } @Override @SideOnly(Side.CLIENT) - public boolean addDestroyEffects(World world, BlockPos pos, net.minecraft.client.particle.EffectRenderer effectRenderer) { - if (world.getBlockState(pos).getBlock() == this) { + public boolean addDestroyEffects(World world, BlockPos pos, net.minecraft.client.particle.EffectRenderer effectRenderer) + { + if (world.getBlockState(pos).getBlock() == this) + { Random random = new Random(); float f = 1.0F; float f1 = f * 0.6F + 0.4F; @@ -63,8 +71,10 @@ public class BlockBloodLight extends Block { @Override @SideOnly(Side.CLIENT) - public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { - if (rand.nextInt(3) != 0) { + public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand) + { + if (rand.nextInt(3) != 0) + { float f = 1.0F; float f1 = f * 0.6F + 0.4F; float f2 = f * f * 0.7F - 0.5F; @@ -74,12 +84,14 @@ public class BlockBloodLight extends Block { } @Override - public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) { + public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) + { this.setBlockBounds(0.35F, 0.35F, 0.35F, 0.65F, 0.65F, 0.65F); } @Override - public int quantityDropped(Random par1Random) { + public int quantityDropped(Random par1Random) + { return 0; } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockBloodRune.java b/src/main/java/WayofTime/bloodmagic/block/BlockBloodRune.java index 28475d87..eb11ec62 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockBloodRune.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockBloodRune.java @@ -5,11 +5,13 @@ import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.block.base.BlockString; import net.minecraft.block.material.Material; -public class BlockBloodRune extends BlockString { +public class BlockBloodRune extends BlockString +{ - public static final String[] names = {"blank", "speed", "efficiency", "sacrifice", "selfSacrifice", "displacement", "capacity", "augCapacity", "orb", "acceleration"}; + public static final String[] names = { "blank", "speed", "efficiency", "sacrifice", "selfSacrifice", "displacement", "capacity", "augCapacity", "orb", "acceleration" }; - public BlockBloodRune() { + public BlockBloodRune() + { super(Material.rock, names); setUnlocalizedName(Constants.Mod.MODID + ".rune."); @@ -20,7 +22,8 @@ public class BlockBloodRune extends BlockString { setHarvestLevel("pickaxe", 2); } - public int getRuneEffect(int meta) { + public int getRuneEffect(int meta) + { return meta; } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockBloodStoneBrick.java b/src/main/java/WayofTime/bloodmagic/block/BlockBloodStoneBrick.java index 5c7445f9..b880aaa7 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockBloodStoneBrick.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockBloodStoneBrick.java @@ -5,11 +5,13 @@ import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.block.base.BlockString; import net.minecraft.block.material.Material; -public class BlockBloodStoneBrick extends BlockString { +public class BlockBloodStoneBrick extends BlockString +{ - public static final String[] names = {"normal", "large"}; + public static final String[] names = { "normal", "large" }; - public BlockBloodStoneBrick() { + public BlockBloodStoneBrick() + { super(Material.rock, names); setUnlocalizedName(Constants.Mod.MODID + ".bloodstonebrick."); diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockCrystal.java b/src/main/java/WayofTime/bloodmagic/block/BlockCrystal.java index 74e9e9dc..1c9b06f6 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockCrystal.java @@ -5,10 +5,12 @@ import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.block.base.BlockString; import net.minecraft.block.material.Material; -public class BlockCrystal extends BlockString { - public static final String[] names = {"normal", "brick"}; +public class BlockCrystal extends BlockString +{ + public static final String[] names = { "normal", "brick" }; - public BlockCrystal() { + public BlockCrystal() + { super(Material.rock, names); setUnlocalizedName(Constants.Mod.MODID + ".crystal."); diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockLifeEssence.java b/src/main/java/WayofTime/bloodmagic/block/BlockLifeEssence.java index c0f03f2a..0c5ddad8 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockLifeEssence.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockLifeEssence.java @@ -15,12 +15,14 @@ import net.minecraftforge.fluids.FluidStack; import java.awt.*; -public class BlockLifeEssence extends BlockFluidClassic { +public class BlockLifeEssence extends BlockFluidClassic +{ @Getter private static Fluid lifeEssence = new FluidLifeEssence(); - public BlockLifeEssence() { + public BlockLifeEssence() + { super(lifeEssence, Material.water); setUnlocalizedName(Constants.Mod.MODID + ".fluid.lifeEssence"); @@ -30,18 +32,22 @@ public class BlockLifeEssence extends BlockFluidClassic { } @Override - public boolean canDisplace(IBlockAccess world, BlockPos blockPos) { + public boolean canDisplace(IBlockAccess world, BlockPos blockPos) + { return !world.getBlockState(blockPos).getBlock().getMaterial().isLiquid() && super.canDisplace(world, blockPos); } @Override - public boolean displaceIfPossible(World world, BlockPos blockPos) { + public boolean displaceIfPossible(World world, BlockPos blockPos) + { return !world.getBlockState(blockPos).getBlock().getMaterial().isLiquid() && super.displaceIfPossible(world, blockPos); } - public static class FluidLifeEssence extends Fluid { + public static class FluidLifeEssence extends Fluid + { - public FluidLifeEssence() { + public FluidLifeEssence() + { super("lifeEssence", new ResourceLocation(Constants.Mod.DOMAIN + "blocks/lifeEssenceStill"), new ResourceLocation(Constants.Mod.DOMAIN + "blocks/lifeEssenceFlowing")); setDensity(2000); @@ -49,12 +55,14 @@ public class BlockLifeEssence extends BlockFluidClassic { } @Override - public int getColor() { + public int getColor() + { return Color.WHITE.getRGB(); } @Override - public String getLocalizedName(FluidStack fluidStack) { + public String getLocalizedName(FluidStack fluidStack) + { return StatCollector.translateToLocal("tile.BloodMagic.fluid.lifeEssence.name"); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockPedestal.java b/src/main/java/WayofTime/bloodmagic/block/BlockPedestal.java index e0b75a52..ad7b1e32 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockPedestal.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockPedestal.java @@ -14,11 +14,13 @@ import net.minecraft.util.EnumFacing; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockPedestal extends BlockStringContainer { +public class BlockPedestal extends BlockStringContainer +{ - public static String[] names = {"pedestal", "plinth"}; + public static String[] names = { "pedestal", "plinth" }; - public BlockPedestal() { + public BlockPedestal() + { super(Material.rock, names); setUnlocalizedName(Constants.Mod.MODID + "."); @@ -28,35 +30,41 @@ public class BlockPedestal extends BlockStringContainer { } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) { - switch (getMetaFromState(state)) { - case 0: { -// TileEntity plinth = world.getTileEntity(pos); -// -// if (plinth!= null && plinth instanceof TilePlinth) { -// Utils.insertItemToTile((TilePlinth) plinth, player); -// } - } - - case 1: { - TileEntity plinth = world.getTileEntity(pos); - - if (plinth == null || player.isSneaking()) - return false; - - if (plinth instanceof TilePlinth) { - Utils.insertItemToTile((TilePlinth) plinth, player); - return true; - } + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) + { + switch (getMetaFromState(state)) + { + case 0: + { + // TileEntity plinth = world.getTileEntity(pos); + // + // if (plinth!= null && plinth instanceof TilePlinth) { + // Utils.insertItemToTile((TilePlinth) plinth, player); + // } + } + + case 1: + { + TileEntity plinth = world.getTileEntity(pos); + + if (plinth == null || player.isSneaking()) + return false; + + if (plinth instanceof TilePlinth) + { + Utils.insertItemToTile((TilePlinth) plinth, player); + return true; } } + } world.markBlockForUpdate(pos); return false; } @Override - public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, BlockPos pos) { + public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, BlockPos pos) + { IBlockState state = blockAccess.getBlockState(pos); if (getMetaFromState(state) == 0) @@ -67,17 +75,20 @@ public class BlockPedestal extends BlockStringContainer { } @Override - public boolean isOpaqueCube() { + public boolean isOpaqueCube() + { return false; } @Override - public boolean isFullCube() { + public boolean isFullCube() + { return false; } @Override - public TileEntity createNewTileEntity(World world, int meta) { + public TileEntity createNewTileEntity(World world, int meta) + { return meta == 0 ? null : new TilePlinth(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockPhantom.java b/src/main/java/WayofTime/bloodmagic/block/BlockPhantom.java index ea72825b..9620d23f 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockPhantom.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockPhantom.java @@ -17,21 +17,25 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.Random; -public class BlockPhantom extends BlockContainer { +public class BlockPhantom extends BlockContainer +{ - public BlockPhantom() { + public BlockPhantom() + { super(Material.cloth); setUnlocalizedName(Constants.Mod.MODID + ".phantom"); } @Override - public boolean isOpaqueCube() { + public boolean isOpaqueCube() + { return false; } @Override - public boolean isFullCube() { + public boolean isFullCube() + { return false; } @@ -44,17 +48,20 @@ public class BlockPhantom extends BlockContainer { @Override @SideOnly(Side.CLIENT) - public EnumWorldBlockLayer getBlockLayer() { + public EnumWorldBlockLayer getBlockLayer() + { return EnumWorldBlockLayer.TRANSLUCENT; } @Override @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side) { + public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side) + { IBlockState iblockstate = worldIn.getBlockState(pos); Block block = iblockstate.getBlock(); - if (worldIn.getBlockState(pos.offset(side.getOpposite())) != iblockstate) { + if (worldIn.getBlockState(pos.offset(side.getOpposite())) != iblockstate) + { return true; } @@ -62,12 +69,14 @@ public class BlockPhantom extends BlockContainer { } @Override - public int quantityDropped(Random par1Random) { + public int quantityDropped(Random par1Random) + { return 0; } @Override - public TileEntity createNewTileEntity(World world, int meta) { + public TileEntity createNewTileEntity(World world, int meta) + { return new TilePhantomBlock(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockRitualController.java b/src/main/java/WayofTime/bloodmagic/block/BlockRitualController.java index a3b29276..f559088a 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockRitualController.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockRitualController.java @@ -20,11 +20,13 @@ import WayofTime.bloodmagic.registry.ModItems; import WayofTime.bloodmagic.tile.TileImperfectRitualStone; import WayofTime.bloodmagic.tile.TileMasterRitualStone; -public class BlockRitualController extends BlockStringContainer { +public class BlockRitualController extends BlockStringContainer +{ - public static final String[] names = {"master", "imperfect"}; + public static final String[] names = { "master", "imperfect" }; - public BlockRitualController() { + public BlockRitualController() + { super(Material.rock, names); setUnlocalizedName(Constants.Mod.MODID + ".stone.ritual."); @@ -36,21 +38,28 @@ public class BlockRitualController extends BlockStringContainer { } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) + { TileEntity tile = world.getTileEntity(pos); - if (getMetaFromState(state) == 0 && tile instanceof TileMasterRitualStone) { - if (player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.activationCrystal) { - String key = RitualHelper.getValidRitual(world, pos); - EnumFacing direction = RitualHelper.getDirectionOfRitual(world, pos, key); - //TODO: Give a message stating that this ritual is not a valid ritual. - if (!key.isEmpty() && direction != null && RitualHelper.checkValidRitual(world, pos, key, direction)) { - if(((TileMasterRitualStone) tile).activateRitual(player.getHeldItem(), player, RitualRegistry.getRitualForId(key))) { - ((TileMasterRitualStone) tile).setDirection(direction); + if (getMetaFromState(state) == 0 && tile instanceof TileMasterRitualStone) + { + if (player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.activationCrystal) + { + String key = RitualHelper.getValidRitual(world, pos); + EnumFacing direction = RitualHelper.getDirectionOfRitual(world, pos, key); + // TODO: Give a message stating that this ritual is not a valid + // ritual. + if (!key.isEmpty() && direction != null && RitualHelper.checkValidRitual(world, pos, key, direction)) + { + if (((TileMasterRitualStone) tile).activateRitual(player.getHeldItem(), player, RitualRegistry.getRitualForId(key))) + { + ((TileMasterRitualStone) tile).setDirection(direction); } } } - } else if (getMetaFromState(state) == 1 && tile instanceof TileImperfectRitualStone) { + } else if (getMetaFromState(state) == 1 && tile instanceof TileImperfectRitualStone) + { IBlockState determinerState = world.getBlockState(pos.up()); BlockStack determiner = new BlockStack(determinerState.getBlock(), determinerState.getBlock().getMetaFromState(determinerState)); @@ -62,7 +71,8 @@ public class BlockRitualController extends BlockStringContainer { } @Override - public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) { + public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) + { TileEntity tile = world.getTileEntity(pos); if (getMetaFromState(state) == 0 && tile instanceof TileMasterRitualStone) @@ -70,7 +80,8 @@ public class BlockRitualController extends BlockStringContainer { } @Override - public void onBlockDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) { + public void onBlockDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) + { TileEntity tile = world.getTileEntity(pos); IBlockState state = world.getBlockState(pos); @@ -79,7 +90,8 @@ public class BlockRitualController extends BlockStringContainer { } @Override - public TileEntity createNewTileEntity(World world, int meta) { + public TileEntity createNewTileEntity(World world, int meta) + { return meta == 0 ? (new TileMasterRitualStone()) : (new TileImperfectRitualStone()); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockRitualStone.java b/src/main/java/WayofTime/bloodmagic/block/BlockRitualStone.java index 0cb73b56..89c44364 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockRitualStone.java @@ -9,11 +9,13 @@ import net.minecraft.block.material.Material; import net.minecraft.util.BlockPos; import net.minecraft.world.World; -public class BlockRitualStone extends BlockString implements IRitualStone { +public class BlockRitualStone extends BlockString implements IRitualStone +{ - public static final String[] names = {"blank", "water", "fire", "earth", "air", "dusk", "dawn"}; + public static final String[] names = { "blank", "water", "fire", "earth", "air", "dusk", "dawn" }; - public BlockRitualStone() { + public BlockRitualStone() + { super(Material.iron, names); setUnlocalizedName(Constants.Mod.MODID + ".ritualStone."); @@ -25,7 +27,8 @@ public class BlockRitualStone extends BlockString implements IRitualStone { } @Override - public boolean isRuneType(World world, BlockPos pos, EnumRuneType runeType) { + public boolean isRuneType(World world, BlockPos pos, EnumRuneType runeType) + { return runeType.toString().equals(names[getMetaFromState(world.getBlockState(pos))]); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockSoulForge.java b/src/main/java/WayofTime/bloodmagic/block/BlockSoulForge.java index bd4985f0..018e11cd 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockSoulForge.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockSoulForge.java @@ -10,9 +10,11 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; -public class BlockSoulForge extends Block { +public class BlockSoulForge extends Block +{ - public BlockSoulForge() { + public BlockSoulForge() + { super(Material.iron); setUnlocalizedName(Constants.Mod.MODID + ".soulforge."); @@ -24,11 +26,11 @@ public class BlockSoulForge extends Block { } @Override - public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) + { if (world.isRemote) return false; - return false; } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockSpectral.java b/src/main/java/WayofTime/bloodmagic/block/BlockSpectral.java index 499f1560..58150841 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockSpectral.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockSpectral.java @@ -18,9 +18,11 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; import java.util.Random; -public class BlockSpectral extends BlockContainer { +public class BlockSpectral extends BlockContainer +{ - public BlockSpectral() { + public BlockSpectral() + { super(Material.cloth); setUnlocalizedName(Constants.Mod.MODID + ".spectral"); @@ -28,42 +30,50 @@ public class BlockSpectral extends BlockContainer { } @Override - public boolean isOpaqueCube() { + public boolean isOpaqueCube() + { return false; } @Override - public boolean isFullCube() { + public boolean isFullCube() + { return false; } @Override @SideOnly(Side.CLIENT) - public EnumWorldBlockLayer getBlockLayer() { + public EnumWorldBlockLayer getBlockLayer() + { return EnumWorldBlockLayer.CUTOUT; } @Override - public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) { + public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) + { } @Override - public int quantityDropped(Random par1Random) { + public int quantityDropped(Random par1Random) + { return 0; } @Override - public boolean isReplaceable(World world, BlockPos blockPos) { + public boolean isReplaceable(World world, BlockPos blockPos) + { return true; } @Override - public boolean isAir(IBlockAccess world, BlockPos blockPos) { + public boolean isAir(IBlockAccess world, BlockPos blockPos) + { return true; } @Override - public TileEntity createNewTileEntity(World world, int meta) { + public TileEntity createNewTileEntity(World world, int meta) + { return new TileSpectralBlock(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockTeleposer.java b/src/main/java/WayofTime/bloodmagic/block/BlockTeleposer.java index 0184507d..26d68796 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockTeleposer.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockTeleposer.java @@ -14,9 +14,11 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; -public class BlockTeleposer extends BlockContainer { +public class BlockTeleposer extends BlockContainer +{ - public BlockTeleposer() { + public BlockTeleposer() + { super(Material.rock); setCreativeTab(BloodMagic.tabBloodMagic); @@ -26,27 +28,32 @@ public class BlockTeleposer extends BlockContainer { } @Override - public int getRenderType() { + public int getRenderType() + { return 3; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) + { ItemStack playerItem = player.getCurrentEquippedItem(); - if (playerItem != null && playerItem.getItem() instanceof ItemTelepositionFocus) { + if (playerItem != null && playerItem.getItem() instanceof ItemTelepositionFocus) + { BindableHelper.checkAndSetItemOwner(playerItem, player); ((ItemTelepositionFocus) playerItem.getItem()).setBlockPos(playerItem, world, pos); return true; } -// player.openGui(AlchemicalWizardry.instance, 1, world, pos.getX(), pos.getY(), pos.getZ()); + // player.openGui(AlchemicalWizardry.instance, 1, world, pos.getX(), + // pos.getY(), pos.getZ()); return true; } @Override - public TileEntity createNewTileEntity(World worldIn, int meta) { + public TileEntity createNewTileEntity(World worldIn, int meta) + { return null; } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockTestSpellBlock.java b/src/main/java/WayofTime/bloodmagic/block/BlockTestSpellBlock.java index b2f4abeb..5be4c8c1 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockTestSpellBlock.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockTestSpellBlock.java @@ -12,57 +12,61 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.IBlockAccess; -public class BlockTestSpellBlock extends Block { - public static final PropertyDirection INPUT = PropertyDirection - .create("input"); - public static final PropertyDirection OUTPUT = PropertyDirection - .create("output"); +public class BlockTestSpellBlock extends Block +{ + public static final PropertyDirection INPUT = PropertyDirection.create("input"); + public static final PropertyDirection OUTPUT = PropertyDirection.create("output"); - public BlockTestSpellBlock() { + public BlockTestSpellBlock() + { super(Material.rock); setHardness(2.0F); setResistance(5.0F); setUnlocalizedName(Constants.Mod.MODID + ".testSpellBlock"); setCreativeTab(BloodMagic.tabBloodMagic); - this.setDefaultState(this.blockState.getBaseState() - .withProperty(INPUT, EnumFacing.DOWN) - .withProperty(OUTPUT, EnumFacing.UP)); + this.setDefaultState(this.blockState.getBaseState().withProperty(INPUT, EnumFacing.DOWN).withProperty(OUTPUT, EnumFacing.UP)); } @Override - public IBlockState getStateFromMeta(int meta) { + public IBlockState getStateFromMeta(int meta) + { return this.getDefaultState(); } @Override - public int getMetaFromState(IBlockState state) { + public int getMetaFromState(IBlockState state) + { return 0; } @Override - public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - return state.withProperty(INPUT, EnumFacing.DOWN) - .withProperty(OUTPUT, EnumFacing.UP); + public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) + { + return state.withProperty(INPUT, EnumFacing.DOWN).withProperty(OUTPUT, EnumFacing.UP); } @Override - protected BlockState createBlockState() { - return new BlockState(this, new IProperty[]{INPUT, OUTPUT}); + protected BlockState createBlockState() + { + return new BlockState(this, new IProperty[] { INPUT, OUTPUT }); } @Override - public boolean isOpaqueCube() { + public boolean isOpaqueCube() + { return false; } @Override - public boolean isFullCube() { + public boolean isFullCube() + { return false; } @Override - public boolean isPassable(IBlockAccess blockAccess, BlockPos pos) { + public boolean isPassable(IBlockAccess blockAccess, BlockPos pos) + { return false; } } diff --git a/src/main/java/WayofTime/bloodmagic/block/base/BlockInteger.java b/src/main/java/WayofTime/bloodmagic/block/base/BlockInteger.java index 421798e0..59415936 100644 --- a/src/main/java/WayofTime/bloodmagic/block/base/BlockInteger.java +++ b/src/main/java/WayofTime/bloodmagic/block/base/BlockInteger.java @@ -26,20 +26,23 @@ import java.util.List; /** * Creates a block that has multiple meta-based states. - * + * * These states will be numbered 0 through {@code maxMeta}. - * - * For {@link net.minecraft.tileentity.TileEntity}'s, use {@link BlockIntegerContainer}. + * + * For {@link net.minecraft.tileentity.TileEntity}'s, use + * {@link BlockIntegerContainer}. */ @Getter -public class BlockInteger extends Block { +public class BlockInteger extends Block +{ private final int maxMeta; private final PropertyInteger metaProp; private final IUnlistedProperty unlistedMetaProp; private final BlockState realBlockState; - public BlockInteger(Material material, int maxMeta, String propName) { + public BlockInteger(Material material, int maxMeta, String propName) + { super(material); this.maxMeta = maxMeta; @@ -50,60 +53,72 @@ public class BlockInteger extends Block { setupStates(); } - public BlockInteger(Material material, int maxMeta) { + public BlockInteger(Material material, int maxMeta) + { this(material, maxMeta, "meta"); } @Override - public IBlockState getStateFromMeta(int meta) { + public IBlockState getStateFromMeta(int meta) + { return getBlockState().getBaseState().withProperty(metaProp, meta); } @Override - public int getMetaFromState(IBlockState state) { + public int getMetaFromState(IBlockState state) + { return (Integer) state.getValue(metaProp); } @Override - public int damageDropped(IBlockState state) { + public int damageDropped(IBlockState state) + { return getMetaFromState(state); } @Override - public BlockState getBlockState() { + public BlockState getBlockState() + { return this.realBlockState; } @Override - public BlockState createBlockState() { + public BlockState createBlockState() + { return Blocks.air.getBlockState(); } @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) { + public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) + { return new ItemStack(this, 1, this.getMetaFromState(world.getBlockState(pos))); } @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) { + public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) + { for (int i = 0; i < maxMeta + 1; i++) list.add(new ItemStack(this, 1, i)); } - private void setupStates() { + private void setupStates() + { this.setDefaultState(getExtendedBlockState().withProperty(unlistedMetaProp, 0).withProperty(metaProp, 0)); } - public ExtendedBlockState getBaseExtendedState() { + public ExtendedBlockState getBaseExtendedState() + { return (ExtendedBlockState) this.getBlockState(); } - public IExtendedBlockState getExtendedBlockState() { + public IExtendedBlockState getExtendedBlockState() + { return (IExtendedBlockState) this.getBaseExtendedState().getBaseState(); } - private BlockState createRealBlockState() { - return new ExtendedBlockState(this, new IProperty[]{metaProp}, new IUnlistedProperty[]{unlistedMetaProp}); + private BlockState createRealBlockState() + { + return new ExtendedBlockState(this, new IProperty[] { metaProp }, new IUnlistedProperty[] { unlistedMetaProp }); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/base/BlockIntegerContainer.java b/src/main/java/WayofTime/bloodmagic/block/base/BlockIntegerContainer.java index e841981a..c1f46a76 100644 --- a/src/main/java/WayofTime/bloodmagic/block/base/BlockIntegerContainer.java +++ b/src/main/java/WayofTime/bloodmagic/block/base/BlockIntegerContainer.java @@ -7,26 +7,31 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.world.World; -public abstract class BlockIntegerContainer extends BlockInteger implements ITileEntityProvider { +public abstract class BlockIntegerContainer extends BlockInteger implements ITileEntityProvider +{ - public BlockIntegerContainer(Material material, int maxMeta, String propName) { + public BlockIntegerContainer(Material material, int maxMeta, String propName) + { super(material, maxMeta, propName); this.isBlockContainer = true; } - public BlockIntegerContainer(Material material, int maxMeta) { + public BlockIntegerContainer(Material material, int maxMeta) + { this(material, maxMeta, "meta"); } @Override - public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { + public void breakBlock(World worldIn, BlockPos pos, IBlockState state) + { super.breakBlock(worldIn, pos, state); worldIn.removeTileEntity(pos); } @Override - public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam) { + public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam) + { super.onBlockEventReceived(worldIn, pos, state, eventID, eventParam); TileEntity tileentity = worldIn.getTileEntity(pos); return tileentity != null && tileentity.receiveClientEvent(eventID, eventParam); diff --git a/src/main/java/WayofTime/bloodmagic/block/base/BlockString.java b/src/main/java/WayofTime/bloodmagic/block/base/BlockString.java index 4cc632e1..2f0efca7 100644 --- a/src/main/java/WayofTime/bloodmagic/block/base/BlockString.java +++ b/src/main/java/WayofTime/bloodmagic/block/base/BlockString.java @@ -27,14 +27,17 @@ import java.util.List; /** * Creates a block that has multiple meta-based states. - * - * These states will be named after the given string array. Somewhere along the way, each - * value is {@code toLowerCase()}'ed, so the blockstate JSON needs all values to be lowercase. - * - * For {@link net.minecraft.tileentity.TileEntity}'s, use {@link BlockStringContainer}. + * + * These states will be named after the given string array. Somewhere along the + * way, each value is {@code toLowerCase()}'ed, so the blockstate JSON needs all + * values to be lowercase. + * + * For {@link net.minecraft.tileentity.TileEntity}'s, use + * {@link BlockStringContainer}. */ @Getter -public class BlockString extends Block { +public class BlockString extends Block +{ private final int maxMeta; private final List values; @@ -42,7 +45,8 @@ public class BlockString extends Block { private final IUnlistedProperty unlistedStringProp; private final BlockState realBlockState; - public BlockString(Material material, String[] values, String propName) { + public BlockString(Material material, String[] values, String propName) + { super(material); this.maxMeta = values.length - 1; @@ -54,60 +58,72 @@ public class BlockString extends Block { setupStates(); } - public BlockString(Material material, String[] values) { + public BlockString(Material material, String[] values) + { this(material, values, "type"); } @Override - public IBlockState getStateFromMeta(int meta) { + public IBlockState getStateFromMeta(int meta) + { return getBlockState().getBaseState().withProperty(stringProp, values.get(meta)); } @Override - public int getMetaFromState(IBlockState state) { + public int getMetaFromState(IBlockState state) + { return values.indexOf(String.valueOf(state.getValue(stringProp))); } @Override - public int damageDropped(IBlockState state) { + public int damageDropped(IBlockState state) + { return getMetaFromState(state); } @Override - public BlockState getBlockState() { + public BlockState getBlockState() + { return this.realBlockState; } @Override - public BlockState createBlockState() { + public BlockState createBlockState() + { return Blocks.air.getBlockState(); } @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) { + public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) + { return new ItemStack(this, 1, this.getMetaFromState(world.getBlockState(pos))); } @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) { + public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) + { for (int i = 0; i < maxMeta + 1; i++) list.add(new ItemStack(this, 1, i)); } - private void setupStates() { + private void setupStates() + { this.setDefaultState(getExtendedBlockState().withProperty(unlistedStringProp, values.get(0)).withProperty(stringProp, values.get(0))); } - public ExtendedBlockState getBaseExtendedState() { + public ExtendedBlockState getBaseExtendedState() + { return (ExtendedBlockState) this.getBlockState(); } - public IExtendedBlockState getExtendedBlockState() { + public IExtendedBlockState getExtendedBlockState() + { return (IExtendedBlockState) this.getBaseExtendedState().getBaseState(); } - private BlockState createRealBlockState() { - return new ExtendedBlockState(this, new IProperty[]{stringProp}, new IUnlistedProperty[]{unlistedStringProp}); + private BlockState createRealBlockState() + { + return new ExtendedBlockState(this, new IProperty[] { stringProp }, new IUnlistedProperty[] { unlistedStringProp }); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/base/BlockStringContainer.java b/src/main/java/WayofTime/bloodmagic/block/base/BlockStringContainer.java index 987b2abb..85db927a 100644 --- a/src/main/java/WayofTime/bloodmagic/block/base/BlockStringContainer.java +++ b/src/main/java/WayofTime/bloodmagic/block/base/BlockStringContainer.java @@ -7,26 +7,31 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.world.World; -public abstract class BlockStringContainer extends BlockString implements ITileEntityProvider { +public abstract class BlockStringContainer extends BlockString implements ITileEntityProvider +{ - public BlockStringContainer(Material material, String[] values, String propName) { + public BlockStringContainer(Material material, String[] values, String propName) + { super(material, values, propName); this.isBlockContainer = true; } - public BlockStringContainer(Material material, String[] values) { + public BlockStringContainer(Material material, String[] values) + { this(material, values, "type"); } @Override - public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { + public void breakBlock(World worldIn, BlockPos pos, IBlockState state) + { super.breakBlock(worldIn, pos, state); worldIn.removeTileEntity(pos); } @Override - public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam) { + public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam) + { super.onBlockEventReceived(worldIn, pos, state, eventID, eventParam); TileEntity tileentity = worldIn.getTileEntity(pos); return tileentity != null && tileentity.receiveClientEvent(eventID, eventParam); diff --git a/src/main/java/WayofTime/bloodmagic/block/property/PropertyString.java b/src/main/java/WayofTime/bloodmagic/block/property/PropertyString.java index 678e887e..c3e5817d 100644 --- a/src/main/java/WayofTime/bloodmagic/block/property/PropertyString.java +++ b/src/main/java/WayofTime/bloodmagic/block/property/PropertyString.java @@ -8,11 +8,13 @@ import java.util.Arrays; import java.util.Collection; import java.util.HashSet; -public class PropertyString extends PropertyHelper { +public class PropertyString extends PropertyHelper +{ private final ImmutableSet allowedValues; - protected PropertyString(String name, String[] values) { + protected PropertyString(String name, String[] values) + { super(name, String.class); HashSet hashSet = Sets.newHashSet(); @@ -20,21 +22,25 @@ public class PropertyString extends PropertyHelper { allowedValues = ImmutableSet.copyOf(hashSet); } - public static PropertyString create(String name, String[] values) { + public static PropertyString create(String name, String[] values) + { return new PropertyString(name, values); } @Override - public Collection getAllowedValues() { + public Collection getAllowedValues() + { return allowedValues; } - public String getName0(String value) { + public String getName0(String value) + { return value; } @Override - public String getName(Comparable value) { + public String getName(Comparable value) + { return this.getName0(value.toString()); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/property/UnlistedPropertyInteger.java b/src/main/java/WayofTime/bloodmagic/block/property/UnlistedPropertyInteger.java index 79cd6142..b988b8fa 100644 --- a/src/main/java/WayofTime/bloodmagic/block/property/UnlistedPropertyInteger.java +++ b/src/main/java/WayofTime/bloodmagic/block/property/UnlistedPropertyInteger.java @@ -2,33 +2,39 @@ package WayofTime.bloodmagic.block.property; import net.minecraftforge.common.property.IUnlistedProperty; -public class UnlistedPropertyInteger implements IUnlistedProperty { +public class UnlistedPropertyInteger implements IUnlistedProperty +{ private int maxMeta; private String propName; - public UnlistedPropertyInteger(int maxMeta, String propName) { + public UnlistedPropertyInteger(int maxMeta, String propName) + { this.maxMeta = maxMeta; this.propName = propName; } @Override - public String getName() { + public String getName() + { return propName; } @Override - public boolean isValid(Integer value) { + public boolean isValid(Integer value) + { return value <= maxMeta; } @Override - public Class getType() { + public Class getType() + { return Integer.class; } @Override - public String valueToString(Integer value) { + public String valueToString(Integer value) + { return value.toString(); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/property/UnlistedPropertyString.java b/src/main/java/WayofTime/bloodmagic/block/property/UnlistedPropertyString.java index 22d5c8c4..77e555c9 100644 --- a/src/main/java/WayofTime/bloodmagic/block/property/UnlistedPropertyString.java +++ b/src/main/java/WayofTime/bloodmagic/block/property/UnlistedPropertyString.java @@ -5,33 +5,39 @@ import net.minecraftforge.common.property.IUnlistedProperty; import java.util.Arrays; import java.util.List; -public class UnlistedPropertyString implements IUnlistedProperty { +public class UnlistedPropertyString implements IUnlistedProperty +{ private List values; private String propName; - public UnlistedPropertyString(String[] values, String propName) { + public UnlistedPropertyString(String[] values, String propName) + { this.values = Arrays.asList(values); this.propName = propName; } @Override - public String getName() { + public String getName() + { return propName; } @Override - public boolean isValid(String value) { + public boolean isValid(String value) + { return values.contains(value); } @Override - public Class getType() { + public Class getType() + { return String.class; } @Override - public String valueToString(String value) { + public String valueToString(String value) + { return value; } } diff --git a/src/main/java/WayofTime/bloodmagic/client/gui/ConfigGui.java b/src/main/java/WayofTime/bloodmagic/client/gui/ConfigGui.java index e4a1290d..e1826dfd 100644 --- a/src/main/java/WayofTime/bloodmagic/client/gui/ConfigGui.java +++ b/src/main/java/WayofTime/bloodmagic/client/gui/ConfigGui.java @@ -10,17 +10,21 @@ import net.minecraftforge.fml.client.config.IConfigElement; import java.util.ArrayList; import java.util.List; -public class ConfigGui extends GuiConfig { +public class ConfigGui extends GuiConfig +{ - public ConfigGui(GuiScreen parentScreen) { + public ConfigGui(GuiScreen parentScreen) + { super(parentScreen, getConfigElements(parentScreen), Constants.Mod.MODID, false, false, "BloodMagic Configuration"); } @SuppressWarnings("rawtypes") - private static List getConfigElements(GuiScreen parent) { + private static List getConfigElements(GuiScreen parent) + { List list = new ArrayList(); - // adds sections declared in ConfigHandler. toLowerCase() is used because the configuration class automatically does this, so must we. + // adds sections declared in ConfigHandler. toLowerCase() is used + // because the configuration class automatically does this, so must we. list.add(new ConfigElement(ConfigHandler.getConfig().getCategory("Potions".toLowerCase()))); list.add(new ConfigElement(ConfigHandler.getConfig().getCategory("Teleposer Blacklist".toLowerCase()))); list.add(new ConfigElement(ConfigHandler.getConfig().getCategory("Item/Block Blacklisting".toLowerCase()))); diff --git a/src/main/java/WayofTime/bloodmagic/client/gui/ConfigGuiFactory.java b/src/main/java/WayofTime/bloodmagic/client/gui/ConfigGuiFactory.java index 7c63e5ce..daf1d422 100644 --- a/src/main/java/WayofTime/bloodmagic/client/gui/ConfigGuiFactory.java +++ b/src/main/java/WayofTime/bloodmagic/client/gui/ConfigGuiFactory.java @@ -6,25 +6,30 @@ import net.minecraftforge.fml.client.IModGuiFactory; import java.util.Set; -public class ConfigGuiFactory implements IModGuiFactory { +public class ConfigGuiFactory implements IModGuiFactory +{ @Override - public void initialize(Minecraft minecraftInstance) { + public void initialize(Minecraft minecraftInstance) + { } @Override - public Class mainConfigGuiClass() { + public Class mainConfigGuiClass() + { return ConfigGui.class; } @Override - public Set runtimeGuiCategories() { + public Set runtimeGuiCategories() + { return null; } @Override - public RuntimeOptionGuiHandler getHandlerFor(IModGuiFactory.RuntimeOptionCategoryElement element) { + public RuntimeOptionGuiHandler getHandlerFor(IModGuiFactory.RuntimeOptionCategoryElement element) + { return null; } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/RenderAlchemyArray.java b/src/main/java/WayofTime/bloodmagic/client/render/RenderAlchemyArray.java index a4dff8f9..79739bd7 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/RenderAlchemyArray.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/RenderAlchemyArray.java @@ -6,14 +6,16 @@ import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer; import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry; import WayofTime.bloodmagic.tile.TileAlchemyArray; -public class RenderAlchemyArray extends TileEntitySpecialRenderer { +public class RenderAlchemyArray extends TileEntitySpecialRenderer +{ - @Override - public void renderTileEntityAt(TileAlchemyArray alchemyArray, double x, double y, double z, float partialTicks, int destroyStage) { - ItemStack inputStack = alchemyArray.getStackInSlot(0); - int craftTime = alchemyArray.activeCounter; - AlchemyCircleRenderer renderer = AlchemyArrayRecipeRegistry.getAlchemyCircleRenderer(inputStack); + @Override + public void renderTileEntityAt(TileAlchemyArray alchemyArray, double x, double y, double z, float partialTicks, int destroyStage) + { + ItemStack inputStack = alchemyArray.getStackInSlot(0); + int craftTime = alchemyArray.activeCounter; + AlchemyCircleRenderer renderer = AlchemyArrayRecipeRegistry.getAlchemyCircleRenderer(inputStack); - renderer.renderAt(alchemyArray, x, y, z, (craftTime > 0 ? craftTime + partialTicks : 0)); - } + renderer.renderAt(alchemyArray, x, y, z, (craftTime > 0 ? craftTime + partialTicks : 0)); + } } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/BindingAlchemyCircleRenderer.java b/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/BindingAlchemyCircleRenderer.java index 9bb0df4a..c4f98287 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/BindingAlchemyCircleRenderer.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/alchemyArray/BindingAlchemyCircleRenderer.java @@ -10,234 +10,264 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer; -public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer { +public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer +{ - public float offsetFromFace = -0.9f; - public final ResourceLocation arrayResource; - public final ResourceLocation[] arraysResources; - - public static final int numberOfSweeps = 5; - public static final int startTime = 50; - public static final int sweepTime = 40; - - public static final int inwardRotationTime = 50; - - public static final float arcLength = (float) Math.sqrt(2*(2*2) - 2*2*2*Math.cos(2*Math.PI*2/5)); - public static final float theta2 = (float) (18f * Math.PI / 180f); - - public static final int endTime = 300; + public float offsetFromFace = -0.9f; + public final ResourceLocation arrayResource; + public final ResourceLocation[] arraysResources; - public BindingAlchemyCircleRenderer() { - this.arrayResource = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingArray.png"); - arraysResources = new ResourceLocation[5]; - arraysResources[0] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png"); - arraysResources[1] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png"); - arraysResources[2] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png"); - arraysResources[3] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png"); - arraysResources[4] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png"); - } + public static final int numberOfSweeps = 5; + public static final int startTime = 50; + public static final int sweepTime = 40; - public static float getAngleOfCircle(int circle, float craftTime) { - if (circle >= 0 && circle <= 4) { - float originalAngle = (float) (circle * 2 * Math.PI / 5d); - - double sweep = (craftTime - startTime)/sweepTime; - if(sweep >= 0 && sweep < numberOfSweeps) { - float offset = ((int)sweep)*sweepTime + startTime; - originalAngle += 2*Math.PI*2/5*(int)sweep + getAngle(craftTime - offset, (int)sweep); - }else if(sweep >= numberOfSweeps) - { - originalAngle += 2*Math.PI*2/5*numberOfSweeps + (craftTime - 5*sweepTime - startTime)*2*Math.PI*2/5/sweepTime; - } - - return originalAngle; - } + public static final int inwardRotationTime = 50; - return 0; - } - - public static float getAngle(float craftTime, int sweep) { - float rDP = craftTime/sweepTime*arcLength; - float rEnd = (float) Math.sqrt(rDP*rDP + 2*2 - 2*rDP*2*Math.cos(theta2)); - return (float) (Math.acos((2*2 + rEnd*rEnd - rDP*rDP)/(2*rEnd*2))); - } + public static final float arcLength = (float) Math.sqrt(2 * (2 * 2) - 2 * 2 * 2 * Math.cos(2 * Math.PI * 2 / 5)); + public static final float theta2 = (float) (18f * Math.PI / 180f); - /** - * Returns the center-to-center distance of this circle. - */ - public static float getDistanceOfCircle(int circle, float craftTime) { //TODO Change this so it doesn't use angle, since it is a constant speed. - double sweep = (craftTime - startTime)/sweepTime; - if(sweep >= 0 && sweep < numberOfSweeps) { - float offset = ((int)sweep)*sweepTime + startTime; - float angle = getAngle(craftTime - offset, (int) sweep); - float thetaPrime = (float) (Math.PI - theta2 - angle); -// if(thetaPrime > 0 && thetaPrime < Math.PI) { - return (float) (2 * Math.sin(theta2) / Math.sin(thetaPrime)); -// } - } else if(sweep >= numberOfSweeps && craftTime < endTime) { - return 2 - 2 * (craftTime - startTime - numberOfSweeps * sweepTime) / (endTime - startTime - numberOfSweeps * sweepTime); - } else if(craftTime >= endTime) { - return 0; - } - - return 2; - } + public static final int endTime = 300; - public float getRotation(int circle, float craftTime) { - float offset = 2; - if(circle == -1) { - return (float) (craftTime * 360 * 2/5/sweepTime); - } - if (craftTime >= offset) { - float modifier = (float) Math.pow(craftTime - offset, 1.5); - return modifier * 0.5f; - } - return 0; - } + public BindingAlchemyCircleRenderer() + { + this.arrayResource = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingArray.png"); + arraysResources = new ResourceLocation[5]; + arraysResources[0] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png"); + arraysResources[1] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png"); + arraysResources[2] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png"); + arraysResources[3] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png"); + arraysResources[4] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png"); + } - public float getSecondaryRotation(int circle, float craftTime) { - float offset = 50; - if (craftTime >= offset) { - float modifier = (float) Math.pow(craftTime - offset, 1.7); - return modifier * 0.5f; - } - return 0; - } + public static float getAngleOfCircle(int circle, float craftTime) + { + if (circle >= 0 && circle <= 4) + { + float originalAngle = (float) (circle * 2 * Math.PI / 5d); - public float getVerticalOffset(int circle, float craftTime) { - if (circle >= 0 && circle <= 4) { - if (craftTime >= 5) { - if (craftTime <= 40) { - return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3)); - } else { - return -0.4f; - } - } + double sweep = (craftTime - startTime) / sweepTime; + if (sweep >= 0 && sweep < numberOfSweeps) + { + float offset = ((int) sweep) * sweepTime + startTime; + originalAngle += 2 * Math.PI * 2 / 5 * (int) sweep + getAngle(craftTime - offset, (int) sweep); + } else if (sweep >= numberOfSweeps) + { + originalAngle += 2 * Math.PI * 2 / 5 * numberOfSweeps + (craftTime - 5 * sweepTime - startTime) * 2 * Math.PI * 2 / 5 / sweepTime; + } - return 0; - } + return originalAngle; + } - if (craftTime >= 5) { - if (craftTime <= 40) { - return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3)); - } else { - return -0.4f; - } - } - return 0; - } - - public float getInwardRotation(int circle, float craftTime) { - float offset = startTime + numberOfSweeps * sweepTime; - if(craftTime >= offset) { - if(craftTime <= offset + inwardRotationTime) { - return 90f / inwardRotationTime * (craftTime - offset); - } else { - return 90; - } - } - - return 0; - } + return 0; + } - public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) { - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer wr = tessellator.getWorldRenderer(); + public static float getAngle(float craftTime, int sweep) + { + float rDP = craftTime / sweepTime * arcLength; + float rEnd = (float) Math.sqrt(rDP * rDP + 2 * 2 - 2 * rDP * 2 * Math.cos(theta2)); + return (float) (Math.acos((2 * 2 + rEnd * rEnd - rDP * rDP) / (2 * rEnd * 2))); + } - GlStateManager.pushMatrix(); + /** + * Returns the center-to-center distance of this circle. + */ + public static float getDistanceOfCircle(int circle, float craftTime) + { // TODO Change this so it doesn't use angle, since it is a constant speed. + double sweep = (craftTime - startTime) / sweepTime; + if (sweep >= 0 && sweep < numberOfSweeps) + { + float offset = ((int) sweep) * sweepTime + startTime; + float angle = getAngle(craftTime - offset, (int) sweep); + float thetaPrime = (float) (Math.PI - theta2 - angle); + // if(thetaPrime > 0 && thetaPrime < Math.PI) { + return (float) (2 * Math.sin(theta2) / Math.sin(thetaPrime)); + // } + } else if (sweep >= numberOfSweeps && craftTime < endTime) + { + return 2 - 2 * (craftTime - startTime - numberOfSweeps * sweepTime) / (endTime - startTime - numberOfSweeps * sweepTime); + } else if (craftTime >= endTime) + { + return 0; + } - float rot = getRotation(-1, craftTime); + return 2; + } - float size = 3.0F; + public float getRotation(int circle, float craftTime) + { + float offset = 2; + if (circle == -1) + { + return (float) (craftTime * 360 * 2 / 5 / sweepTime); + } + if (craftTime >= offset) + { + float modifier = (float) Math.pow(craftTime - offset, 1.5); + return modifier * 0.5f; + } + return 0; + } - // Bind the texture to the circle - Minecraft.getMinecraft().renderEngine.bindTexture(arrayResource); + public float getSecondaryRotation(int circle, float craftTime) + { + float offset = 50; + if (craftTime >= offset) + { + float modifier = (float) Math.pow(craftTime - offset, 1.7); + return modifier * 0.5f; + } + return 0; + } - GlStateManager.disableCull(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(770, 1); + public float getVerticalOffset(int circle, float craftTime) + { + if (circle >= 0 && circle <= 4) + { + if (craftTime >= 5) + { + if (craftTime <= 40) + { + return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3)); + } else + { + return -0.4f; + } + } - GlStateManager.translate(x, y, z); + return 0; + } - EnumFacing sideHit = EnumFacing.UP; // Specify which face this "circle" - // is located on - GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace); + if (craftTime >= 5) + { + if (craftTime <= 40) + { + return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3)); + } else + { + return -0.4f; + } + } + return 0; + } - switch (sideHit) { - case DOWN: - GlStateManager.translate(0, 0, 1); - GlStateManager.rotate(-90.0f, 1, 0, 0); - break; - case EAST: - GlStateManager.rotate(-90.0f, 0, 1, 0); - GlStateManager.translate(0, 0, -1); - break; - case NORTH: - break; - case SOUTH: - GlStateManager.rotate(180.0f, 0, 1, 0); - GlStateManager.translate(-1, 0, -1); - break; - case UP: - GlStateManager.translate(0, 1, 0); - GlStateManager.rotate(90.0f, 1, 0, 0); - break; - case WEST: - GlStateManager.translate(0, 0, 1); - GlStateManager.rotate(90.0f, 0, 1, 0); - break; - } + public float getInwardRotation(int circle, float craftTime) + { + float offset = startTime + numberOfSweeps * sweepTime; + if (craftTime >= offset) + { + if (craftTime <= offset + inwardRotationTime) + { + return 90f / inwardRotationTime * (craftTime - offset); + } else + { + return 90; + } + } - GlStateManager.pushMatrix(); - GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime)); + return 0; + } - double var31 = 0.0D; - double var33 = 1.0D; - double var35 = 0; - double var37 = 1; + public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) + { + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer wr = tessellator.getWorldRenderer(); - // GlStateManager.color(0.5f, 1f, 1f, 1f); - GlStateManager.pushMatrix(); - GlStateManager.rotate(rot, 0, 0, 1); + GlStateManager.pushMatrix(); - wr.begin(7, DefaultVertexFormats.POSITION_TEX); - // wr.setBrightness(200); - wr.pos(size / 2f, size / 2f, 0.0D).tex(var33, var37).endVertex(); - wr.pos(size / 2f, -size / 2f, 0.0D).tex(var33, var35).endVertex(); - wr.pos(-size / 2f, -size / 2f, 0.0D).tex(var31, var35).endVertex(); - wr.pos(-size / 2f, size / 2f, 0.0D).tex(var31, var37).endVertex(); - tessellator.draw(); - GlStateManager.popMatrix(); + float rot = getRotation(-1, craftTime); - for (int i = 0; i < 5; i++) { - GlStateManager.pushMatrix(); - Minecraft.getMinecraft().renderEngine.bindTexture(arraysResources[i]); - float newSize = 1; - float distance = this.getDistanceOfCircle(i, craftTime); - float angle = this.getAngleOfCircle(i, craftTime); - float rotation = this.getRotation(i, craftTime); - - GlStateManager.translate(distance * Math.sin(angle), -distance * Math.cos(angle), this.getVerticalOffset(i, craftTime)); - GlStateManager.rotate(i * 360/5, 0, 0, 1); - GlStateManager.rotate(getInwardRotation(i, craftTime), 1, 0, 0); - GlStateManager.rotate(rotation, 0, 0, 1); - wr.begin(7, DefaultVertexFormats.POSITION_TEX); - wr.pos(newSize / 2f, newSize / 2f, 0.0D).tex(var33, var37).endVertex(); - wr.pos(newSize / 2f, -newSize / 2f, 0.0D).tex(var33, var35).endVertex(); - wr.pos(-newSize / 2f, -newSize / 2f, 0.0D).tex(var31, var35).endVertex(); - wr.pos(-newSize / 2f, newSize / 2f, 0.0D).tex(var31, var37).endVertex(); - tessellator.draw(); + float size = 3.0F; - GlStateManager.popMatrix(); - } + // Bind the texture to the circle + Minecraft.getMinecraft().renderEngine.bindTexture(arrayResource); - GlStateManager.popMatrix(); + GlStateManager.disableCull(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(770, 1); - // GlStateManager.depthMask(true); - GlStateManager.disableBlend(); - GlStateManager.enableCull(); - // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.translate(x, y, z); - GlStateManager.popMatrix(); - } + EnumFacing sideHit = EnumFacing.UP; // Specify which face this "circle" + // is located on + GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace); + + switch (sideHit) + { + case DOWN: + GlStateManager.translate(0, 0, 1); + GlStateManager.rotate(-90.0f, 1, 0, 0); + break; + case EAST: + GlStateManager.rotate(-90.0f, 0, 1, 0); + GlStateManager.translate(0, 0, -1); + break; + case NORTH: + break; + case SOUTH: + GlStateManager.rotate(180.0f, 0, 1, 0); + GlStateManager.translate(-1, 0, -1); + break; + case UP: + GlStateManager.translate(0, 1, 0); + GlStateManager.rotate(90.0f, 1, 0, 0); + break; + case WEST: + GlStateManager.translate(0, 0, 1); + GlStateManager.rotate(90.0f, 0, 1, 0); + break; + } + + GlStateManager.pushMatrix(); + GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime)); + + double var31 = 0.0D; + double var33 = 1.0D; + double var35 = 0; + double var37 = 1; + + // GlStateManager.color(0.5f, 1f, 1f, 1f); + GlStateManager.pushMatrix(); + GlStateManager.rotate(rot, 0, 0, 1); + + wr.begin(7, DefaultVertexFormats.POSITION_TEX); + // wr.setBrightness(200); + wr.pos(size / 2f, size / 2f, 0.0D).tex(var33, var37).endVertex(); + wr.pos(size / 2f, -size / 2f, 0.0D).tex(var33, var35).endVertex(); + wr.pos(-size / 2f, -size / 2f, 0.0D).tex(var31, var35).endVertex(); + wr.pos(-size / 2f, size / 2f, 0.0D).tex(var31, var37).endVertex(); + tessellator.draw(); + GlStateManager.popMatrix(); + + for (int i = 0; i < 5; i++) + { + GlStateManager.pushMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(arraysResources[i]); + float newSize = 1; + float distance = this.getDistanceOfCircle(i, craftTime); + float angle = this.getAngleOfCircle(i, craftTime); + float rotation = this.getRotation(i, craftTime); + + GlStateManager.translate(distance * Math.sin(angle), -distance * Math.cos(angle), this.getVerticalOffset(i, craftTime)); + GlStateManager.rotate(i * 360 / 5, 0, 0, 1); + GlStateManager.rotate(getInwardRotation(i, craftTime), 1, 0, 0); + GlStateManager.rotate(rotation, 0, 0, 1); + wr.begin(7, DefaultVertexFormats.POSITION_TEX); + wr.pos(newSize / 2f, newSize / 2f, 0.0D).tex(var33, var37).endVertex(); + wr.pos(newSize / 2f, -newSize / 2f, 0.0D).tex(var33, var35).endVertex(); + wr.pos(-newSize / 2f, -newSize / 2f, 0.0D).tex(var31, var35).endVertex(); + wr.pos(-newSize / 2f, newSize / 2f, 0.0D).tex(var31, var37).endVertex(); + tessellator.draw(); + + GlStateManager.popMatrix(); + } + + GlStateManager.popMatrix(); + + // GlStateManager.depthMask(true); + GlStateManager.disableBlend(); + GlStateManager.enableCull(); + // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + GlStateManager.popMatrix(); + } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/compat/ICompatibility.java b/src/main/java/WayofTime/bloodmagic/compat/ICompatibility.java index 4b7ce66f..0faf4d9a 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/ICompatibility.java +++ b/src/main/java/WayofTime/bloodmagic/compat/ICompatibility.java @@ -3,7 +3,8 @@ package WayofTime.bloodmagic.compat; /** * Implement on all primary compatibility classes. */ -public interface ICompatibility { +public interface ICompatibility +{ /** * Called after the given {@code modid} has been verified as loaded. @@ -16,8 +17,9 @@ public interface ICompatibility { String getModId(); /** - * Whether or not compatibility should be loaded even if the mod were to be found. - * + * Whether or not compatibility should be loaded even if the mod were to be + * found. + * * Generally a determined by a config option. */ boolean enableCompat(); diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/BloodMagicPlugin.java b/src/main/java/WayofTime/bloodmagic/compat/jei/BloodMagicPlugin.java index 67ef4ff5..1ac12dec 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/BloodMagicPlugin.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/BloodMagicPlugin.java @@ -18,28 +18,23 @@ import net.minecraft.item.ItemStack; import java.util.Collections; @JEIPlugin -public class BloodMagicPlugin implements IModPlugin { +public class BloodMagicPlugin implements IModPlugin +{ public static IJeiHelpers jeiHelper; @Override - public boolean isModLoaded() { + public boolean isModLoaded() + { return true; } @Override - public void register(IModRegistry registry) { - registry.addRecipeCategories( - new AltarRecipeCategory(), - new BindingRecipeCategory(), - new AlchemyArrayCraftingCategory() - ); + public void register(IModRegistry registry) + { + registry.addRecipeCategories(new AltarRecipeCategory(), new BindingRecipeCategory(), new AlchemyArrayCraftingCategory()); - registry.addRecipeHandlers( - new AltarRecipeHandler(), - new BindingRecipeHandler(), - new AlchemyArrayCraftingRecipeHandler() - ); + registry.addRecipeHandlers(new AltarRecipeHandler(), new BindingRecipeHandler(), new AlchemyArrayCraftingRecipeHandler()); registry.addRecipes(AltarRecipeMaker.getRecipes()); registry.addRecipes(BindingRecipeMaker.getRecipes()); @@ -49,19 +44,22 @@ public class BloodMagicPlugin implements IModPlugin { } @Override - public void onJeiHelpersAvailable(IJeiHelpers jeiHelpers) { + public void onJeiHelpersAvailable(IJeiHelpers jeiHelpers) + { jeiHelper = jeiHelpers; jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.bloodLight)); } @Override - public void onItemRegistryAvailable(IItemRegistry itemRegistry) { + public void onItemRegistryAvailable(IItemRegistry itemRegistry) + { } @Override - public void onRecipeRegistryAvailable(IRecipeRegistry recipeRegistry) { + public void onRecipeRegistryAvailable(IRecipeRegistry recipeRegistry) + { } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/BloodMagicRecipeWrapper.java b/src/main/java/WayofTime/bloodmagic/compat/jei/BloodMagicRecipeWrapper.java index b2ffd19a..7e925d27 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/BloodMagicRecipeWrapper.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/BloodMagicRecipeWrapper.java @@ -6,15 +6,18 @@ import net.minecraftforge.fluids.FluidStack; import java.util.Collections; import java.util.List; -public abstract class BloodMagicRecipeWrapper implements IRecipeWrapper { +public abstract class BloodMagicRecipeWrapper implements IRecipeWrapper +{ @Override - public List getFluidInputs() { + public List getFluidInputs() + { return Collections.emptyList(); } @Override - public List getFluidOutputs() { + public List getFluidOutputs() + { return Collections.emptyList(); } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/CompatibilityJustEnoughItems.java b/src/main/java/WayofTime/bloodmagic/compat/jei/CompatibilityJustEnoughItems.java index 76ecdd7d..e6b10184 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/CompatibilityJustEnoughItems.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/CompatibilityJustEnoughItems.java @@ -2,20 +2,24 @@ package WayofTime.bloodmagic.compat.jei; import WayofTime.bloodmagic.compat.ICompatibility; -public class CompatibilityJustEnoughItems implements ICompatibility { +public class CompatibilityJustEnoughItems implements ICompatibility +{ @Override - public void loadCompatibility() { + public void loadCompatibility() + { } @Override - public String getModId() { + public String getModId() + { return "JEI"; } @Override - public boolean enableCompat() { + public boolean enableCompat() + { return true; } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingCategory.java b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingCategory.java index 8f8ddd97..a06f4ff9 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingCategory.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingCategory.java @@ -13,7 +13,8 @@ import net.minecraft.util.ResourceLocation; import javax.annotation.Nonnull; -public class AlchemyArrayCraftingCategory implements IRecipeCategory { +public class AlchemyArrayCraftingCategory implements IRecipeCategory +{ private static final int INPUT_SLOT = 0; private static final int CATALYST_SLOT = 1; @@ -26,41 +27,48 @@ public class AlchemyArrayCraftingCategory implements IRecipeCategory { @Nonnull @Override - public String getUid() { + public String getUid() + { return Constants.Compat.JEI_CATEGORY_ALCHEMYARRAY; } @Nonnull @Override - public String getTitle() { + public String getTitle() + { return localizedName; } @Nonnull @Override - public IDrawable getBackground() { + public IDrawable getBackground() + { return background; } @Override - public void drawExtras(Minecraft minecraft) { + public void drawExtras(Minecraft minecraft) + { } @Override - public void drawAnimations(Minecraft minecraft) { + public void drawAnimations(Minecraft minecraft) + { } @Override @SuppressWarnings("unchecked") - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) { + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) + { recipeLayout.getItemStacks().init(INPUT_SLOT, true, 0, 5); recipeLayout.getItemStacks().init(CATALYST_SLOT, true, 50, 5); recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 73, 5); - if (recipeWrapper instanceof AlchemyArrayCraftingRecipeJEI) { + if (recipeWrapper instanceof AlchemyArrayCraftingRecipeJEI) + { AlchemyArrayCraftingRecipeJEI alchemyArrayWrapper = (AlchemyArrayCraftingRecipeJEI) recipeWrapper; recipeLayout.getItemStacks().set(INPUT_SLOT, (ItemStack) alchemyArrayWrapper.getInputs().get(0)); recipeLayout.getItemStacks().set(CATALYST_SLOT, (ItemStack) alchemyArrayWrapper.getInputs().get(1)); @@ -68,4 +76,3 @@ public class AlchemyArrayCraftingCategory implements IRecipeCategory { } } } - diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeHandler.java b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeHandler.java index f720c2d1..b9a594fd 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeHandler.java @@ -6,28 +6,33 @@ import mezz.jei.api.recipe.IRecipeWrapper; import javax.annotation.Nonnull; -public class AlchemyArrayCraftingRecipeHandler implements IRecipeHandler { +public class AlchemyArrayCraftingRecipeHandler implements IRecipeHandler +{ @Nonnull @Override - public Class getRecipeClass() { + public Class getRecipeClass() + { return AlchemyArrayCraftingRecipeJEI.class; } @Nonnull @Override - public String getRecipeCategoryUid() { + public String getRecipeCategoryUid() + { return Constants.Compat.JEI_CATEGORY_ALCHEMYARRAY; } @Nonnull @Override - public IRecipeWrapper getRecipeWrapper(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) { + public IRecipeWrapper getRecipeWrapper(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) + { return recipe; } @Override - public boolean isRecipeValid(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) { + public boolean isRecipeValid(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) + { return recipe.getInputs().size() > 0 && recipe.getOutputs().size() > 0; } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeJEI.java b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeJEI.java index 09fec477..d98d31d0 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeJEI.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeJEI.java @@ -10,7 +10,8 @@ import javax.annotation.Nullable; import java.util.Collections; import java.util.List; -public class AlchemyArrayCraftingRecipeJEI extends BloodMagicRecipeWrapper { +public class AlchemyArrayCraftingRecipeJEI extends BloodMagicRecipeWrapper +{ @Nonnull private final List inputs; @@ -19,28 +20,33 @@ public class AlchemyArrayCraftingRecipeJEI extends BloodMagicRecipeWrapper { private final ItemStack output; @SuppressWarnings("unchecked") - public AlchemyArrayCraftingRecipeJEI(@Nonnull ItemStack input, @Nullable ItemStack catalyst, @Nonnull ItemStack output) { - this.inputs = Arrays.asList(new ItemStack[] {input, catalyst}); + public AlchemyArrayCraftingRecipeJEI(@Nonnull ItemStack input, @Nullable ItemStack catalyst, @Nonnull ItemStack output) + { + this.inputs = Arrays.asList(new ItemStack[] { input, catalyst }); this.output = output; } @Override - public List getInputs() { + public List getInputs() + { return inputs; } @Override - public List getOutputs() { + public List getOutputs() + { return Collections.singletonList(output); } @Override - public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) { + public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) + { } @Override - public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) { + public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) + { } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeMaker.java b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeMaker.java index dfb93f11..783854e7 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeMaker.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/alchemyArray/AlchemyArrayCraftingRecipeMaker.java @@ -12,21 +12,26 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -public class AlchemyArrayCraftingRecipeMaker { +public class AlchemyArrayCraftingRecipeMaker +{ @Nonnull - public static List getRecipes() { + public static List getRecipes() + { Map alchemyArrayRecipeMap = AlchemyArrayRecipeRegistry.getRecipes(); ArrayList recipes = new ArrayList(); - for (Map.Entry itemStackAlchemyArrayRecipeEntry : alchemyArrayRecipeMap.entrySet()) { + for (Map.Entry itemStackAlchemyArrayRecipeEntry : alchemyArrayRecipeMap.entrySet()) + { ItemStack input = itemStackAlchemyArrayRecipeEntry.getValue().getInputStack(); BiMap catalystMap = itemStackAlchemyArrayRecipeEntry.getValue().catalystMap; - for(Map.Entry entry : catalystMap.entrySet()) { + for (Map.Entry entry : catalystMap.entrySet()) + { ItemStack catalyst = entry.getKey().toStack(); - if (AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(input, catalyst) instanceof AlchemyArrayEffectCrafting) { + if (AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(input, catalyst) instanceof AlchemyArrayEffectCrafting) + { ItemStack output = ((AlchemyArrayEffectCrafting) itemStackAlchemyArrayRecipeEntry.getValue().getAlchemyArrayEffectForCatalyst(catalyst)).getOutputStack(); AlchemyArrayCraftingRecipeJEI recipe = new AlchemyArrayCraftingRecipeJEI(input, catalyst, output); diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeCategory.java b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeCategory.java index 9b84f7d9..6a8138a1 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeCategory.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeCategory.java @@ -13,7 +13,8 @@ import net.minecraft.util.ResourceLocation; import javax.annotation.Nonnull; -public class AltarRecipeCategory implements IRecipeCategory { +public class AltarRecipeCategory implements IRecipeCategory +{ private static final int INPUT_SLOT = 0; private static final int OUTPUT_SLOT = 1; @@ -25,40 +26,47 @@ public class AltarRecipeCategory implements IRecipeCategory { @Nonnull @Override - public String getUid() { + public String getUid() + { return Constants.Compat.JEI_CATEGORY_ALTAR; } @Nonnull @Override - public String getTitle() { + public String getTitle() + { return localizedName; } @Nonnull @Override - public IDrawable getBackground() { + public IDrawable getBackground() + { return background; } @Override - public void drawExtras(Minecraft minecraft) { + public void drawExtras(Minecraft minecraft) + { } @Override - public void drawAnimations(Minecraft minecraft) { + public void drawAnimations(Minecraft minecraft) + { } @Override @SuppressWarnings("unchecked") - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) { + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) + { recipeLayout.getItemStacks().init(INPUT_SLOT, true, 31, 0); recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 125, 30); - if (recipeWrapper instanceof AltarRecipeJEI) { + if (recipeWrapper instanceof AltarRecipeJEI) + { AltarRecipeJEI altarRecipeWrapper = (AltarRecipeJEI) recipeWrapper; recipeLayout.getItemStacks().set(INPUT_SLOT, altarRecipeWrapper.getInputs()); recipeLayout.getItemStacks().set(OUTPUT_SLOT, altarRecipeWrapper.getOutputs()); diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeHandler.java b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeHandler.java index a4454fd8..70ac0f52 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeHandler.java @@ -6,28 +6,33 @@ import mezz.jei.api.recipe.IRecipeWrapper; import javax.annotation.Nonnull; -public class AltarRecipeHandler implements IRecipeHandler { +public class AltarRecipeHandler implements IRecipeHandler +{ @Nonnull @Override - public Class getRecipeClass() { + public Class getRecipeClass() + { return AltarRecipeJEI.class; } @Nonnull @Override - public String getRecipeCategoryUid() { + public String getRecipeCategoryUid() + { return Constants.Compat.JEI_CATEGORY_ALTAR; } @Nonnull @Override - public IRecipeWrapper getRecipeWrapper(@Nonnull AltarRecipeJEI recipe) { + public IRecipeWrapper getRecipeWrapper(@Nonnull AltarRecipeJEI recipe) + { return recipe; } @Override - public boolean isRecipeValid(@Nonnull AltarRecipeJEI recipe) { + public boolean isRecipeValid(@Nonnull AltarRecipeJEI recipe) + { return recipe.getInputs().size() > 0 && recipe.getOutputs().size() > 0; } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeJEI.java b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeJEI.java index 8fbf8560..076f36bf 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeJEI.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeJEI.java @@ -10,7 +10,8 @@ import java.awt.*; import java.util.Collections; import java.util.List; -public class AltarRecipeJEI extends BloodMagicRecipeWrapper { +public class AltarRecipeJEI extends BloodMagicRecipeWrapper +{ @Nonnull private final ItemStack input; @@ -20,31 +21,36 @@ public class AltarRecipeJEI extends BloodMagicRecipeWrapper { private final String[] infoString; - public AltarRecipeJEI(@Nonnull ItemStack input, @Nonnull ItemStack output, int tier, int requiredLP) { + public AltarRecipeJEI(@Nonnull ItemStack input, @Nonnull ItemStack output, int tier, int requiredLP) + { this.input = input; this.output = output; - this.infoString = new String[]{TextHelper.localize("jei.BloodMagic.recipe.requiredTier", tier), TextHelper.localize("jei.BloodMagic.recipe.requiredLP", requiredLP)}; + this.infoString = new String[] { TextHelper.localize("jei.BloodMagic.recipe.requiredTier", tier), TextHelper.localize("jei.BloodMagic.recipe.requiredLP", requiredLP) }; } @Override - public List getInputs() { + public List getInputs() + { return Collections.singletonList(input); } @Override - public List getOutputs() { + public List getOutputs() + { return Collections.singletonList(output); } @Override - public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) { + public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) + { minecraft.fontRendererObj.drawString(infoString[0], 90 - minecraft.fontRendererObj.getStringWidth(infoString[0]) / 2, 0, Color.gray.getRGB()); minecraft.fontRendererObj.drawString(infoString[1], 90 - minecraft.fontRendererObj.getStringWidth(infoString[1]) / 2, 10, Color.gray.getRGB()); } @Override - public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) { + public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) + { } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeMaker.java b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeMaker.java index 5a1a3cad..079fc2d1 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeMaker.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/altar/AltarRecipeMaker.java @@ -8,16 +8,21 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -public class AltarRecipeMaker { +public class AltarRecipeMaker +{ @Nonnull - public static List getRecipes() { + public static List getRecipes() + { Map altarMap = AltarRecipeRegistry.getRecipes(); ArrayList recipes = new ArrayList(); - for (Map.Entry itemStackAltarRecipeEntry : altarMap.entrySet()) { - if (itemStackAltarRecipeEntry.getValue().getOutput() != null) { // Make sure output is not null. If it is, the recipe is for a filling orb, and we don't want that. + for (Map.Entry itemStackAltarRecipeEntry : altarMap.entrySet()) + { + if (itemStackAltarRecipeEntry.getValue().getOutput() != null) + { // Make sure output is not null. If it is, the recipe is for a + // filling orb, and we don't want that. ItemStack input = itemStackAltarRecipeEntry.getKey(); ItemStack output = itemStackAltarRecipeEntry.getValue().getOutput(); int requiredTier = itemStackAltarRecipeEntry.getValue().getMinTier().toInt(); diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeCategory.java b/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeCategory.java index 829a40af..dfac1b53 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeCategory.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeCategory.java @@ -13,7 +13,8 @@ import net.minecraft.util.ResourceLocation; import javax.annotation.Nonnull; -public class BindingRecipeCategory implements IRecipeCategory { +public class BindingRecipeCategory implements IRecipeCategory +{ private static final int INPUT_SLOT = 0; private static final int CATALYST_SLOT = 1; @@ -26,41 +27,48 @@ public class BindingRecipeCategory implements IRecipeCategory { @Nonnull @Override - public String getUid() { + public String getUid() + { return Constants.Compat.JEI_CATEGORY_BINDING; } @Nonnull @Override - public String getTitle() { + public String getTitle() + { return localizedName; } @Nonnull @Override - public IDrawable getBackground() { + public IDrawable getBackground() + { return background; } @Override - public void drawExtras(Minecraft minecraft) { + public void drawExtras(Minecraft minecraft) + { } @Override - public void drawAnimations(Minecraft minecraft) { + public void drawAnimations(Minecraft minecraft) + { } @Override @SuppressWarnings("unchecked") - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) { + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) + { recipeLayout.getItemStacks().init(INPUT_SLOT, true, 0, 5); recipeLayout.getItemStacks().init(CATALYST_SLOT, true, 50, 5); recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 73, 5); - if (recipeWrapper instanceof BindingRecipeJEI) { + if (recipeWrapper instanceof BindingRecipeJEI) + { BindingRecipeJEI bindingRecipe = (BindingRecipeJEI) recipeWrapper; recipeLayout.getItemStacks().set(INPUT_SLOT, (ItemStack) bindingRecipe.getInputs().get(0)); recipeLayout.getItemStacks().set(CATALYST_SLOT, (ItemStack) bindingRecipe.getInputs().get(1)); diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeHandler.java b/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeHandler.java index 70065bda..dec2bd62 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeHandler.java @@ -6,28 +6,33 @@ import mezz.jei.api.recipe.IRecipeWrapper; import javax.annotation.Nonnull; -public class BindingRecipeHandler implements IRecipeHandler { +public class BindingRecipeHandler implements IRecipeHandler +{ @Nonnull @Override - public Class getRecipeClass() { + public Class getRecipeClass() + { return BindingRecipeJEI.class; } @Nonnull @Override - public String getRecipeCategoryUid() { + public String getRecipeCategoryUid() + { return Constants.Compat.JEI_CATEGORY_BINDING; } @Nonnull @Override - public IRecipeWrapper getRecipeWrapper(@Nonnull BindingRecipeJEI recipe) { + public IRecipeWrapper getRecipeWrapper(@Nonnull BindingRecipeJEI recipe) + { return recipe; } @Override - public boolean isRecipeValid(@Nonnull BindingRecipeJEI recipe) { + public boolean isRecipeValid(@Nonnull BindingRecipeJEI recipe) + { return recipe.getInputs().size() > 0 && recipe.getOutputs().size() > 0; } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeJEI.java b/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeJEI.java index 053f57a7..78949c21 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeJEI.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeJEI.java @@ -10,7 +10,8 @@ import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; import WayofTime.bloodmagic.compat.jei.BloodMagicRecipeWrapper; -public class BindingRecipeJEI extends BloodMagicRecipeWrapper { +public class BindingRecipeJEI extends BloodMagicRecipeWrapper +{ @Nonnull private final List inputs; @@ -19,28 +20,33 @@ public class BindingRecipeJEI extends BloodMagicRecipeWrapper { private final ItemStack output; @SuppressWarnings("unchecked") - public BindingRecipeJEI(@Nonnull ItemStack input, @Nonnull ItemStack catalyst, @Nonnull ItemStack output) { - this.inputs = Arrays.asList(new ItemStack[] {input, catalyst}); + public BindingRecipeJEI(@Nonnull ItemStack input, @Nonnull ItemStack catalyst, @Nonnull ItemStack output) + { + this.inputs = Arrays.asList(new ItemStack[] { input, catalyst }); this.output = output; } @Override - public List getInputs() { + public List getInputs() + { return inputs; } @Override - public List getOutputs() { + public List getOutputs() + { return Collections.singletonList(output); } @Override - public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) { + public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) + { } @Override - public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) { + public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) + { } } diff --git a/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeMaker.java b/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeMaker.java index cdcf54cb..0d831e1f 100644 --- a/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeMaker.java +++ b/src/main/java/WayofTime/bloodmagic/compat/jei/binding/BindingRecipeMaker.java @@ -12,21 +12,26 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -public class BindingRecipeMaker { +public class BindingRecipeMaker +{ @Nonnull - public static List getRecipes() { + public static List getRecipes() + { Map alchemyArrayRecipeMap = AlchemyArrayRecipeRegistry.getRecipes(); ArrayList recipes = new ArrayList(); - for (Map.Entry itemStackAlchemyArrayRecipeEntry : alchemyArrayRecipeMap.entrySet()) { + for (Map.Entry itemStackAlchemyArrayRecipeEntry : alchemyArrayRecipeMap.entrySet()) + { ItemStack input = itemStackAlchemyArrayRecipeEntry.getValue().getInputStack(); BiMap catalystMap = itemStackAlchemyArrayRecipeEntry.getValue().catalystMap; - for(Map.Entry entry : catalystMap.entrySet()) { + for (Map.Entry entry : catalystMap.entrySet()) + { ItemStack catalyst = entry.getKey().toStack(); - if (AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(input, catalyst) instanceof AlchemyArrayEffectBinding) { + if (AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(input, catalyst) instanceof AlchemyArrayEffectBinding) + { ItemStack output = ((AlchemyArrayEffectBinding) itemStackAlchemyArrayRecipeEntry.getValue().getAlchemyArrayEffectForCatalyst(catalyst)).getOutputStack(); BindingRecipeJEI recipe = new BindingRecipeJEI(input, catalyst, output); diff --git a/src/main/java/WayofTime/bloodmagic/compress/AdvancedCompressionHandler.java b/src/main/java/WayofTime/bloodmagic/compress/AdvancedCompressionHandler.java index 59883ec3..9d90d576 100644 --- a/src/main/java/WayofTime/bloodmagic/compress/AdvancedCompressionHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compress/AdvancedCompressionHandler.java @@ -8,27 +8,35 @@ import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public class AdvancedCompressionHandler extends CompressionHandler { +public class AdvancedCompressionHandler extends CompressionHandler +{ @Override - public ItemStack compressInventory(ItemStack[] inv, World world) { + public ItemStack compressInventory(ItemStack[] inv, World world) + { return test(inv, true, world); } - public ItemStack test(ItemStack[] inv, boolean doDrain, World world) { - for (ItemStack invStack : inv) { - if (invStack == null) { + public ItemStack test(ItemStack[] inv, boolean doDrain, World world) + { + for (ItemStack invStack : inv) + { + if (invStack == null) + { continue; } - for (int i = 2; i <= 3; i++) { + for (int i = 2; i <= 3; i++) + { ItemStack stacky = getRecipe(invStack, world, i); - if (stacky != null) { + if (stacky != null) + { int threshold = CompressionRegistry.getItemThreshold(invStack); int needed = i * i; int neededLeft = iterateThroughInventory(invStack, threshold + invStack.getMaxStackSize() - needed, inv, needed, false); - if (neededLeft <= 0) { + if (neededLeft <= 0) + { iterateThroughInventory(invStack, 0, inv, needed, true); return stacky; } @@ -39,31 +47,39 @@ public class AdvancedCompressionHandler extends CompressionHandler { return null; } - public int iterateThroughInventory(ItemStack required, int kept, ItemStack[] inv, int needed, boolean doDrain) { + public int iterateThroughInventory(ItemStack required, int kept, ItemStack[] inv, int needed, boolean doDrain) + { int i = -1; - for (ItemStack invStack : inv) { + for (ItemStack invStack : inv) + { i++; - if (invStack == null) { + if (invStack == null) + { continue; } - if (invStack.isItemEqual(required) && (invStack.getTagCompound() == null ? required.getTagCompound() == null : invStack.getTagCompound().equals(required.getTagCompound()))) { + if (invStack.isItemEqual(required) && (invStack.getTagCompound() == null ? required.getTagCompound() == null : invStack.getTagCompound().equals(required.getTagCompound()))) + { int stackSize = invStack.stackSize; int used = 0; - if (kept > 0) { + if (kept > 0) + { int remainingFromStack = Math.max(stackSize - kept, 0); used += stackSize - remainingFromStack; } kept -= used; - if (kept <= 0 && needed > 0) { + if (kept <= 0 && needed > 0) + { int remainingFromStack = Math.max(stackSize - used - needed, 0); - if (doDrain) { + if (doDrain) + { invStack.stackSize = remainingFromStack + used; - if (invStack.stackSize <= 0) { + if (invStack.stackSize <= 0) + { inv[i] = null; } } @@ -71,7 +87,8 @@ public class AdvancedCompressionHandler extends CompressionHandler { needed -= (stackSize - used - remainingFromStack); } - if (needed <= 0) { + if (needed <= 0) + { return 0; } } @@ -80,12 +97,16 @@ public class AdvancedCompressionHandler extends CompressionHandler { return needed; } - public static boolean isResultStackReversible(ItemStack stack, int gridSize, World world) { - if (stack == null) { + public static boolean isResultStackReversible(ItemStack stack, int gridSize, World world) + { + if (stack == null) + { return false; } - InventoryCrafting inventory = new InventoryCrafting(new Container() { - public boolean canInteractWith(EntityPlayer player) { + InventoryCrafting inventory = new InventoryCrafting(new Container() + { + public boolean canInteractWith(EntityPlayer player) + { return false; } }, 2, 2); @@ -93,49 +114,59 @@ public class AdvancedCompressionHandler extends CompressionHandler { inventory.setInventorySlotContents(0, stack); ItemStack returnStack = StorageBlockCraftingManager.getInstance().findMatchingRecipe(inventory, world); - if (returnStack == null) { + if (returnStack == null) + { return false; } ItemStack compressedStack = null; - switch (gridSize) { - case 2: - compressedStack = get22Recipe(returnStack, world); - break; - case 3: - compressedStack = get33Recipe(returnStack, world); - break; + switch (gridSize) + { + case 2: + compressedStack = get22Recipe(returnStack, world); + break; + case 3: + compressedStack = get33Recipe(returnStack, world); + break; } return compressedStack != null && CompressionRegistry.areItemStacksEqual(stack, compressedStack); } - public static ItemStack getRecipe(ItemStack stack, World world, int gridSize) { - InventoryCrafting inventory = new InventoryCrafting(new Container() { - public boolean canInteractWith(EntityPlayer player) { + public static ItemStack getRecipe(ItemStack stack, World world, int gridSize) + { + InventoryCrafting inventory = new InventoryCrafting(new Container() + { + public boolean canInteractWith(EntityPlayer player) + { return false; } }, gridSize, gridSize); - for (int i = 0; i < inventory.getSizeInventory(); i++) { + for (int i = 0; i < inventory.getSizeInventory(); i++) + { inventory.setInventorySlotContents(i, stack); } return StorageBlockCraftingManager.getInstance().findMatchingRecipe(inventory, world); } - public static boolean has22Recipe(ItemStack stack, World world) { + public static boolean has22Recipe(ItemStack stack, World world) + { return get22Recipe(stack, world) != null; } - public static ItemStack get22Recipe(ItemStack stack, World world) { + public static ItemStack get22Recipe(ItemStack stack, World world) + { return getRecipe(stack, world, 2); } - public static boolean has33Recipe(ItemStack stack, World world) { + public static boolean has33Recipe(ItemStack stack, World world) + { return get33Recipe(stack, world) != null; } - public static ItemStack get33Recipe(ItemStack stack, World world) { + public static ItemStack get33Recipe(ItemStack stack, World world) + { return getRecipe(stack, world, 3); } } diff --git a/src/main/java/WayofTime/bloodmagic/compress/BaseCompressionHandler.java b/src/main/java/WayofTime/bloodmagic/compress/BaseCompressionHandler.java index 0039c09f..fa8720a8 100644 --- a/src/main/java/WayofTime/bloodmagic/compress/BaseCompressionHandler.java +++ b/src/main/java/WayofTime/bloodmagic/compress/BaseCompressionHandler.java @@ -4,31 +4,37 @@ import WayofTime.bloodmagic.api.compress.CompressionHandler; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public class BaseCompressionHandler extends CompressionHandler { +public class BaseCompressionHandler extends CompressionHandler +{ private final ItemStack required; private final ItemStack result; private final int leftover; - public BaseCompressionHandler(ItemStack requested, ItemStack result, int leftover) { + public BaseCompressionHandler(ItemStack requested, ItemStack result, int leftover) + { super(); this.required = requested; this.result = result; this.leftover = leftover; } - public ItemStack getResultStack() { + public ItemStack getResultStack() + { return this.result.copy(); } - public ItemStack getRequiredStack() { + public ItemStack getRequiredStack() + { return this.required.copy(); } @Override - public ItemStack compressInventory(ItemStack[] inv, World world) { + public ItemStack compressInventory(ItemStack[] inv, World world) + { int remaining = this.getRemainingNeeded(inv); - if (remaining <= 0) { + if (remaining <= 0) + { this.drainInventory(inv); return this.getResultStack(); } @@ -36,41 +42,51 @@ public class BaseCompressionHandler extends CompressionHandler { return null; } - public int getRemainingNeeded(ItemStack[] inv) { + public int getRemainingNeeded(ItemStack[] inv) + { return iterateThroughInventory(inv, false); } - public int drainInventory(ItemStack[] inv) { + public int drainInventory(ItemStack[] inv) + { return iterateThroughInventory(inv, true); } - public int iterateThroughInventory(ItemStack[] inv, boolean doDrain) { + public int iterateThroughInventory(ItemStack[] inv, boolean doDrain) + { int needed = this.required.stackSize; int kept = this.getLeftover(); int i = -1; - for (ItemStack invStack : inv) { + for (ItemStack invStack : inv) + { i++; - if (invStack == null) { + if (invStack == null) + { continue; } - if (invStack.isItemEqual(this.required) && (invStack.getTagCompound() == null ? this.required.getTagCompound() == null : invStack.getTagCompound().equals(this.required.getTagCompound()))) { + if (invStack.isItemEqual(this.required) && (invStack.getTagCompound() == null ? this.required.getTagCompound() == null : invStack.getTagCompound().equals(this.required.getTagCompound()))) + { int stackSize = invStack.stackSize; int used = 0; - if (kept > 0) { + if (kept > 0) + { int remainingFromStack = Math.max(stackSize - kept, 0); used += stackSize - remainingFromStack; } kept -= used; - if (kept <= 0 && needed > 0) { + if (kept <= 0 && needed > 0) + { int remainingFromStack = Math.max(stackSize - used - needed, 0); - if (doDrain) { + if (doDrain) + { invStack.stackSize = remainingFromStack + used; - if (invStack.stackSize <= 0) { + if (invStack.stackSize <= 0) + { inv[i] = null; } } @@ -78,7 +94,8 @@ public class BaseCompressionHandler extends CompressionHandler { needed -= (stackSize - used - remainingFromStack); } - if (needed <= 0) { + if (needed <= 0) + { return 0; } } @@ -87,7 +104,8 @@ public class BaseCompressionHandler extends CompressionHandler { return needed; } - public int getLeftover() { + public int getLeftover() + { return this.leftover; } } diff --git a/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingManager.java b/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingManager.java index ba047c16..4a6fb748 100644 --- a/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingManager.java +++ b/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingManager.java @@ -13,27 +13,34 @@ import net.minecraft.world.World; import java.util.LinkedList; import java.util.List; -public class StorageBlockCraftingManager { +public class StorageBlockCraftingManager +{ private static final StorageBlockCraftingManager instance = new StorageBlockCraftingManager(); private List recipes = new LinkedList(); - public static StorageBlockCraftingManager getInstance() { + public static StorageBlockCraftingManager getInstance() + { return instance; } - public void addStorageBlockRecipes() { + public void addStorageBlockRecipes() + { this.recipes = new StorageBlockCraftingRecipeAssimilator().getPackingRecipes(); BloodMagic.instance.getLogger().info("Total number of compression recipes: " + this.recipes.size()); } - private static boolean isResultStackReversible(ItemStack stack, int gridSize, World world, List list) { - if (stack == null) { + private static boolean isResultStackReversible(ItemStack stack, int gridSize, World world, List list) + { + if (stack == null) + { return false; } - InventoryCrafting inventory = new InventoryCrafting(new Container() { - public boolean canInteractWith(EntityPlayer player) { + InventoryCrafting inventory = new InventoryCrafting(new Container() + { + public boolean canInteractWith(EntityPlayer player) + { return false; } }, 2, 2); @@ -41,71 +48,87 @@ public class StorageBlockCraftingManager { inventory.setInventorySlotContents(0, stack); ItemStack returnStack = StorageBlockCraftingManager.getInstance().findMatchingRecipe(inventory, world, list); - if (returnStack == null || returnStack.getItem() == null) { + if (returnStack == null || returnStack.getItem() == null) + { return false; } ItemStack compressedStack = null; - switch (gridSize) { - case 2: - compressedStack = get22Recipe(returnStack, world, list); - break; - case 3: - compressedStack = get33Recipe(returnStack, world, list); - break; + switch (gridSize) + { + case 2: + compressedStack = get22Recipe(returnStack, world, list); + break; + case 3: + compressedStack = get33Recipe(returnStack, world, list); + break; } return compressedStack != null && CompressionRegistry.areItemStacksEqual(stack, compressedStack); } - private static ItemStack getRecipe(ItemStack stack, World world, int gridSize, List list) { - InventoryCrafting inventory = new InventoryCrafting(new Container() { - public boolean canInteractWith(EntityPlayer player) { + private static ItemStack getRecipe(ItemStack stack, World world, int gridSize, List list) + { + InventoryCrafting inventory = new InventoryCrafting(new Container() + { + public boolean canInteractWith(EntityPlayer player) + { return false; } }, gridSize, gridSize); - for (int i = 0; i < inventory.getSizeInventory(); i++) { + for (int i = 0; i < inventory.getSizeInventory(); i++) + { inventory.setInventorySlotContents(i, stack); } return StorageBlockCraftingManager.getInstance().findMatchingRecipe(inventory, world, list); } - private static boolean has22Recipe(ItemStack stack, World world, List list) { + private static boolean has22Recipe(ItemStack stack, World world, List list) + { return get22Recipe(stack, world, list) != null; } - private static ItemStack get22Recipe(ItemStack stack, World world, List list) { + private static ItemStack get22Recipe(ItemStack stack, World world, List list) + { return getRecipe(stack, world, 2, list); } - private static boolean has33Recipe(ItemStack stack, World world, List list) { + private static boolean has33Recipe(ItemStack stack, World world, List list) + { return get33Recipe(stack, world, list) != null; } - private static ItemStack get33Recipe(ItemStack stack, World world, List list) { + private static ItemStack get33Recipe(ItemStack stack, World world, List list) + { return getRecipe(stack, world, 3, list); } - public ItemStack findMatchingRecipe(InventoryCrafting craftingInventory, World world) { + public ItemStack findMatchingRecipe(InventoryCrafting craftingInventory, World world) + { return this.findMatchingRecipe(craftingInventory, world, this.recipes); } - private ItemStack findMatchingRecipe(InventoryCrafting craftingInventory, World world, List list) { + private ItemStack findMatchingRecipe(InventoryCrafting craftingInventory, World world, List list) + { int i = 0; ItemStack itemstack = null; ItemStack itemstack1 = null; int j; - for (j = 0; j < craftingInventory.getSizeInventory(); ++j) { + for (j = 0; j < craftingInventory.getSizeInventory(); ++j) + { ItemStack itemstack2 = craftingInventory.getStackInSlot(j); - if (itemstack2 != null) { - if (i == 0) { + if (itemstack2 != null) + { + if (i == 0) + { itemstack = itemstack2; } - if (i == 1) { + if (i == 1) + { itemstack1 = itemstack2; } @@ -113,23 +136,28 @@ public class StorageBlockCraftingManager { } } - if (i == 2 && itemstack.getItem() == itemstack1.getItem() && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && itemstack.getItem().isRepairable()) { + if (i == 2 && itemstack.getItem() == itemstack1.getItem() && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && itemstack.getItem().isRepairable()) + { Item item = itemstack.getItem(); int j1 = item.getMaxDamage() - itemstack.getItemDamage(); int k = item.getMaxDamage() - itemstack1.getItemDamage(); int l = j1 + k + item.getMaxDamage() * 5 / 100; int i1 = item.getMaxDamage() - l; - if (i1 < 0) { + if (i1 < 0) + { i1 = 0; } return new ItemStack(itemstack.getItem(), 1, i1); - } else { - for (j = 0; j < list.size(); ++j) { + } else + { + for (j = 0; j < list.size(); ++j) + { IRecipe irecipe = (IRecipe) list.get(j); - if (irecipe.matches(craftingInventory, world)) { + if (irecipe.matches(craftingInventory, world)) + { return irecipe.getCraftingResult(craftingInventory); } } diff --git a/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingRecipeAssimilator.java b/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingRecipeAssimilator.java index 693547e0..816062a5 100644 --- a/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingRecipeAssimilator.java +++ b/src/main/java/WayofTime/bloodmagic/compress/StorageBlockCraftingRecipeAssimilator.java @@ -16,30 +16,38 @@ import net.minecraftforge.oredict.ShapelessOreRecipe; import java.util.*; -public class StorageBlockCraftingRecipeAssimilator { +public class StorageBlockCraftingRecipeAssimilator +{ - public List getPackingRecipes() { + public List getPackingRecipes() + { // grab all recipes potentially suitable for packing or unpacking List packingRecipes = new LinkedList(); List unpackingRecipes = new ArrayList(); - for (IRecipe recipe : getCraftingRecipes()) { + for (IRecipe recipe : getCraftingRecipes()) + { ItemStack output = recipe.getRecipeOutput(); - if (output == null || output.getItem() == null) continue; + if (output == null || output.getItem() == null) + continue; - if (output.stackSize == 1) { + if (output.stackSize == 1) + { PackingRecipe packingRecipe = getPackingRecipe(recipe); - if (packingRecipe != null) { + if (packingRecipe != null) + { packingRecipes.add(packingRecipe); } - } else if ((output.stackSize == 4 || output.stackSize == 9) && recipe.getRecipeSize() == 1) { + } else if ((output.stackSize == 4 || output.stackSize == 9) && recipe.getRecipeSize() == 1) + { unpackingRecipes.add(recipe); } } - // grab all packing recipes which accept the output of any of the unpacking recipes + // grab all packing recipes which accept the output of any of the + // unpacking recipes Container container = makeDummyContainer(); InventoryCrafting inventoryUnpack = new InventoryCrafting(container, 2, 2); @@ -49,61 +57,82 @@ public class StorageBlockCraftingRecipeAssimilator { List ret = new ArrayList(); - for (IRecipe recipeUnpack : unpackingRecipes) { + for (IRecipe recipeUnpack : unpackingRecipes) + { ItemStack unpacked = recipeUnpack.getRecipeOutput(); InventoryCrafting inventory = null; - for (Iterator it = packingRecipes.iterator(); it.hasNext(); ) { + for (Iterator it = packingRecipes.iterator(); it.hasNext();) + { PackingRecipe recipePack = it.next(); - // check if the packing recipe accepts the unpacking recipe's output + // check if the packing recipe accepts the unpacking recipe's + // output boolean matched = false; - if (recipePack.possibleInputs != null) { // the recipe could be parsed, use its inputs directly since that's faster - // verify recipe size + if (recipePack.possibleInputs != null) + { // the recipe could be parsed, use its inputs directly since + // that's faster + // verify recipe size - if (recipePack.inputCount != unpacked.stackSize) continue; + if (recipePack.inputCount != unpacked.stackSize) + continue; - // check if any of the input options matches the unpacked item stack + // check if any of the input options matches the unpacked + // item stack - for (ItemStack stack : recipePack.possibleInputs) { - if (areInputsIdentical(unpacked, stack)) { + for (ItemStack stack : recipePack.possibleInputs) + { + if (areInputsIdentical(unpacked, stack)) + { matched = true; break; } } - } else { // unknown IRecipe, check through the recipe conventionally - // verify recipe size for 3x3 to skip anything smaller quickly + } else + { // unknown IRecipe, check through the recipe conventionally + // verify recipe size for 3x3 to skip anything smaller + // quickly - if (unpacked.stackSize == 9 && recipePack.recipe.getRecipeSize() < 9) continue; + if (unpacked.stackSize == 9 && recipePack.recipe.getRecipeSize() < 9) + continue; - // initialize inventory late, but only once per unpack recipe + // initialize inventory late, but only once per unpack + // recipe - if (inventory == null) { - if (unpacked.stackSize == 4) { + if (inventory == null) + { + if (unpacked.stackSize == 4) + { inventory = inventory2x2; - } else { + } else + { inventory = inventory3x3; } - for (int i = 0; i < unpacked.stackSize; i++) { + for (int i = 0; i < unpacked.stackSize; i++) + { inventory.setInventorySlotContents(i, unpacked.copy()); } } - // check if the packing recipe accepts the unpacked item stack + // check if the packing recipe accepts the unpacked item + // stack matched = recipePack.recipe.matches(inventory, world); } - if (matched) { - // check if the unpacking recipe accepts the packing recipe's output + if (matched) + { + // check if the unpacking recipe accepts the packing + // recipe's output ItemStack packOutput = recipePack.recipe.getRecipeOutput(); inventoryUnpack.setInventorySlotContents(0, packOutput.copy()); - if (recipeUnpack.matches(inventoryUnpack, world)) { + if (recipeUnpack.matches(inventoryUnpack, world)) + { ret.add(recipePack.recipe); BloodMagic.instance.getLogger().info("Adding the following recipe to the Compression Handler: " + packOutput); it.remove(); @@ -116,33 +145,44 @@ public class StorageBlockCraftingRecipeAssimilator { } @SuppressWarnings("unchecked") - private List getCraftingRecipes() { + private List getCraftingRecipes() + { return CraftingManager.getInstance().getRecipeList(); } - private Container makeDummyContainer() { - return new Container() { + private Container makeDummyContainer() + { + return new Container() + { @Override - public boolean canInteractWith(EntityPlayer player) { + public boolean canInteractWith(EntityPlayer player) + { return true; } }; } - private PackingRecipe getPackingRecipe(IRecipe recipe) { - if (recipe.getRecipeSize() < 4) return null; + private PackingRecipe getPackingRecipe(IRecipe recipe) + { + if (recipe.getRecipeSize() < 4) + return null; List inputs; - if (recipe instanceof ShapedRecipes) { + if (recipe instanceof ShapedRecipes) + { inputs = Arrays.asList(((ShapedRecipes) recipe).recipeItems); - } else if (recipe instanceof ShapelessRecipes) { + } else if (recipe instanceof ShapelessRecipes) + { inputs = ((ShapelessRecipes) recipe).recipeItems; - } else if (recipe instanceof ShapedOreRecipe) { + } else if (recipe instanceof ShapedOreRecipe) + { inputs = Arrays.asList(((ShapedOreRecipe) recipe).getInput()); - } else if (recipe instanceof ShapelessOreRecipe) { + } else if (recipe instanceof ShapelessOreRecipe) + { inputs = ((ShapelessOreRecipe) recipe).getInput(); - } else { + } else + { return new PackingRecipe(recipe, null, -1); } @@ -150,65 +190,84 @@ public class StorageBlockCraftingRecipeAssimilator { int count = 0; - for (Object o : inputs) { - if (o != null) count++; + for (Object o : inputs) + { + if (o != null) + count++; } - if (count != 4 && count != 9) return null; + if (count != 4 && count != 9) + return null; // grab identical inputs List identicalInputs = getIdenticalInputs(inputs); - if (identicalInputs == null) return null; + if (identicalInputs == null) + return null; return new PackingRecipe(recipe, identicalInputs, count); } /** - * Determine the item stacks from the provided inputs which are suitable for every input element. - * - * @param inputs List of all inputs, null elements are being ignored. + * Determine the item stacks from the provided inputs which are suitable for + * every input element. + * + * @param inputs + * List of all inputs, null elements are being ignored. * @return List List of all options. */ @SuppressWarnings("unchecked") - private List getIdenticalInputs(List inputs) { + private List getIdenticalInputs(List inputs) + { List options = null; - for (Object input : inputs) { - if (input == null) continue; + for (Object input : inputs) + { + if (input == null) + continue; List offers; - if (input instanceof ItemStack) { + if (input instanceof ItemStack) + { offers = Collections.singletonList((ItemStack) input); - } else if (input instanceof List) { + } else if (input instanceof List) + { offers = (List) input; - if (offers.isEmpty()) return null; - } else { - throw new RuntimeException("invalid input: "+input.getClass()); + if (offers.isEmpty()) + return null; + } else + { + throw new RuntimeException("invalid input: " + input.getClass()); } - if (options == null) { + if (options == null) + { options = new ArrayList(offers); continue; } - for (Iterator it = options.iterator(); it.hasNext(); ) { + for (Iterator it = options.iterator(); it.hasNext();) + { ItemStack stackReq = it.next(); boolean found = false; - for (ItemStack stackCmp : offers) { - if (areInputsIdentical(stackReq, stackCmp)) { + for (ItemStack stackCmp : offers) + { + if (areInputsIdentical(stackReq, stackCmp)) + { found = true; break; } } - if (!found) { + if (!found) + { it.remove(); - if (options.isEmpty()) return null; + if (options.isEmpty()) + return null; } } } @@ -216,9 +275,11 @@ public class StorageBlockCraftingRecipeAssimilator { return options; } - private boolean areInputsIdentical(ItemStack a, ItemStack b) { + private boolean areInputsIdentical(ItemStack a, ItemStack b) + { - try { + try + { if (a.getItem() != b.getItem()) return false; @@ -226,21 +287,24 @@ public class StorageBlockCraftingRecipeAssimilator { int dmgB = b.getItemDamage(); return dmgA == dmgB || dmgA == OreDictionary.WILDCARD_VALUE || dmgB == OreDictionary.WILDCARD_VALUE; - } catch (NullPointerException e) { + } catch (NullPointerException e) + { BloodMagic.instance.getLogger().error("A mod in this instance has registered an item with a null input. Known problem mods are:"); -// String err = ""; -// for (String problem : problemMods) -// err += (err.length() > 0 ? ", " : "") + problem; -// BloodMagic.instance.getLogger().error(err); + // String err = ""; + // for (String problem : problemMods) + // err += (err.length() > 0 ? ", " : "") + problem; + // BloodMagic.instance.getLogger().error(err); return false; } } - private static class PackingRecipe { - PackingRecipe(IRecipe recipe, List possibleInputs, int inputCount) { + private static class PackingRecipe + { + PackingRecipe(IRecipe recipe, List possibleInputs, int inputCount) + { this.recipe = recipe; this.possibleInputs = possibleInputs; this.inputCount = inputCount; diff --git a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityBloodLight.java b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityBloodLight.java index 47fedde7..11226e43 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityBloodLight.java +++ b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntityBloodLight.java @@ -13,24 +13,28 @@ import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fml.common.registry.IThrowableEntity; -public class EntityBloodLight extends EntityThrowable implements IThrowableEntity, IEntityAdditionalSpawnData { +public class EntityBloodLight extends EntityThrowable implements IThrowableEntity, IEntityAdditionalSpawnData +{ public EntityLivingBase shootingEntity; protected int ticksInAir = 0; protected int maxTicksInAir = 600; - public EntityBloodLight(World world) { + public EntityBloodLight(World world) + { super(world); this.setSize(0.5F, 0.5F); } - public EntityBloodLight(World world, double x, double y, double z) { + public EntityBloodLight(World world, double x, double y, double z) + { super(world); this.setSize(0.5F, 0.5F); this.setPosition(x, y, z); } - public EntityBloodLight(World world, EntityLivingBase player) { + public EntityBloodLight(World world, EntityLivingBase player) + { super(world, player); shootingEntity = player; float par3 = 0.8F; @@ -47,17 +51,20 @@ public class EntityBloodLight extends EntityThrowable implements IThrowableEntit } @Override - protected float getGravityVelocity() { + protected float getGravityVelocity() + { return 0F; } @Override - protected float getVelocity() { + protected float getVelocity() + { return 1F; } @Override - public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8) { + public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8) + { float var9 = MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5); var1 /= var9; var3 /= var9; @@ -77,27 +84,33 @@ public class EntityBloodLight extends EntityThrowable implements IThrowableEntit } @Override - public void onUpdate() { + public void onUpdate() + { super.onUpdate(); - if (this.ticksExisted > this.maxTicksInAir) { + if (this.ticksExisted > this.maxTicksInAir) + { setDead(); } } @Override - protected void onImpact(MovingObjectPosition mop) { - if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null) { - if (mop.entityHit == shootingEntity) { + protected void onImpact(MovingObjectPosition mop) + { + if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null) + { + if (mop.entityHit == shootingEntity) + { return; } this.onImpact(mop.entityHit); - } - else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + } else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { EnumFacing sideHit = mop.sideHit; BlockPos blockPos = mop.getBlockPos().offset(sideHit); - if (worldObj.isAirBlock(blockPos)) { + if (worldObj.isAirBlock(blockPos)) + { worldObj.setBlockState(blockPos, ModBlocks.bloodLight.getDefaultState()); } } @@ -105,70 +118,84 @@ public class EntityBloodLight extends EntityThrowable implements IThrowableEntit this.setDead(); } - protected void onImpact(Entity mop) { - if (mop == shootingEntity && ticksInAir > 3) { + protected void onImpact(Entity mop) + { + if (mop == shootingEntity && ticksInAir > 3) + { shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1); this.setDead(); - } - else { - if (mop instanceof EntityLivingBase) { + } else + { + if (mop instanceof EntityLivingBase) + { ((EntityLivingBase) mop).setRevengeTarget(shootingEntity); doDamage(1, mop); } } - if (worldObj.isAirBlock(new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ))) { + if (worldObj.isAirBlock(new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ))) + { worldObj.setBlockState(new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ), Blocks.fire.getDefaultState()); } -// spawnHitParticles("magicCrit", 8); + // spawnHitParticles("magicCrit", 8); this.setDead(); } - protected void doDamage(int i, Entity mop) { + protected void doDamage(int i, Entity mop) + { mop.attackEntityFrom(this.getDamageSource(), i); } - public DamageSource getDamageSource() { + public DamageSource getDamageSource() + { return DamageSource.causeMobDamage(shootingEntity); } @Override - public void writeSpawnData(ByteBuf data) { + public void writeSpawnData(ByteBuf data) + { data.writeByte(this.ticksInAir); } @Override - public void readSpawnData(ByteBuf data) { + public void readSpawnData(ByteBuf data) + { this.ticksInAir = data.readByte(); } @Override - public void writeEntityToNBT(NBTTagCompound nbt) { + public void writeEntityToNBT(NBTTagCompound nbt) + { super.writeEntityToNBT(nbt); nbt.setInteger(Constants.NBT.PROJECTILE_TICKS_IN_AIR, ticksInAir); nbt.setInteger(Constants.NBT.PROJECTILE_MAX_TICKS_IN_AIR, maxTicksInAir); } @Override - public void readEntityFromNBT(NBTTagCompound nbt) { + public void readEntityFromNBT(NBTTagCompound nbt) + { super.readEntityFromNBT(nbt); ticksInAir = nbt.getInteger(Constants.NBT.PROJECTILE_TICKS_IN_AIR); maxTicksInAir = nbt.getInteger(Constants.NBT.PROJECTILE_MAX_TICKS_IN_AIR); } @Override - protected boolean canTriggerWalking() { + protected boolean canTriggerWalking() + { return false; } @Override - public boolean canBeCollidedWith() { + public boolean canBeCollidedWith() + { return false; } @Override - public void setThrower(Entity entity) { - if (entity instanceof EntityLivingBase) this.shootingEntity = (EntityLivingBase) entity; + public void setThrower(Entity entity) + { + if (entity instanceof EntityLivingBase) + this.shootingEntity = (EntityLivingBase) entity; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemActivationCrystal.java b/src/main/java/WayofTime/bloodmagic/item/ItemActivationCrystal.java index f38fd9de..d127d2b5 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemActivationCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemActivationCrystal.java @@ -11,11 +11,13 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class ItemActivationCrystal extends ItemBindable { +public class ItemActivationCrystal extends ItemBindable +{ - public static String[] names = {"weak", "awakened", "creative"}; + public static String[] names = { "weak", "awakened", "creative" }; - public ItemActivationCrystal() { + public ItemActivationCrystal() + { super(); setUnlocalizedName(Constants.Mod.MODID + ".activationCrystal."); @@ -24,26 +26,30 @@ public class ItemActivationCrystal extends ItemBindable { } @Override - public String getUnlocalizedName(ItemStack stack) { + public String getUnlocalizedName(ItemStack stack) + { return super.getUnlocalizedName(stack) + names[stack.getItemDamage()]; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) { + public void getSubItems(Item id, CreativeTabs creativeTab, List list) + { for (int i = 0; i < names.length; i++) list.add(new ItemStack(id, 1, i)); } @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) + { tooltip.add(TextHelper.localize("tooltip.BloodMagic.activationCrystal." + names[stack.getItemDamage()])); super.addInformation(stack, player, tooltip, advanced); } - public int getCrystalLevel(ItemStack stack) { + public int getCrystalLevel(ItemStack stack) + { return stack.getItemDamage() > 1 ? Integer.MAX_VALUE : stack.getItemDamage() + 1; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemAltarMaker.java b/src/main/java/WayofTime/bloodmagic/item/ItemAltarMaker.java index c56b36cc..a4f6ef61 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemAltarMaker.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemAltarMaker.java @@ -24,11 +24,13 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class ItemAltarMaker extends Item implements IAltarManipulator { +public class ItemAltarMaker extends Item implements IAltarManipulator +{ private EnumAltarTier tierToBuild = EnumAltarTier.ONE; - public ItemAltarMaker() { + public ItemAltarMaker() + { super(); setUnlocalizedName(Constants.Mod.MODID + ".altarMaker"); setCreativeTab(BloodMagic.tabBloodMagic); @@ -38,19 +40,22 @@ public class ItemAltarMaker extends Item implements IAltarManipulator { @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) + { stack = NBTHelper.checkNBT(stack); tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.currentTier", stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1)); } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { if (!player.capabilities.isCreativeMode || world.isRemote) return stack; stack = NBTHelper.checkNBT(stack); - if (player.isSneaking()) { + if (player.isSneaking()) + { if (stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) >= EnumAltarTier.MAXTIERS - 1) stack.getTagCompound().setInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER, 0); else @@ -65,7 +70,8 @@ public class ItemAltarMaker extends Item implements IAltarManipulator { if (mop == null || mop.typeOfHit == MovingObjectPosition.MovingObjectType.MISS || mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) return stack; - if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && world.getBlockState(mop.getBlockPos()).getBlock() instanceof BlockAltar) { + if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && world.getBlockState(mop.getBlockPos()).getBlock() instanceof BlockAltar) + { ChatUtil.sendNoSpam(player, TextHelper.localizeEffect("chat.BloodMagic.altarMaker.building", tierToBuild)); buildAltar(world, mop.getBlockPos()); @@ -76,18 +82,22 @@ public class ItemAltarMaker extends Item implements IAltarManipulator { return stack; } - public void setTierToBuild(EnumAltarTier tierToBuild) { + public void setTierToBuild(EnumAltarTier tierToBuild) + { this.tierToBuild = tierToBuild; } - public void buildAltar(World world, BlockPos pos) { + public void buildAltar(World world, BlockPos pos) + { - if (world.isRemote) return; + if (world.isRemote) + return; if (tierToBuild == EnumAltarTier.ONE) return; - for (AltarComponent altarComponent : tierToBuild.getAltarComponents()) { + for (AltarComponent altarComponent : tierToBuild.getAltarComponents()) + { BlockPos componentPos = pos.add(altarComponent.getOffset()); Block blockForComponent = Utils.getBlockForComponent(altarComponent.getComponent()); @@ -97,7 +107,8 @@ public class ItemAltarMaker extends Item implements IAltarManipulator { ((IBloodAltar) world.getTileEntity(pos)).checkTier(); } - public String destroyAltar(EntityPlayer player) { + public String destroyAltar(EntityPlayer player) + { World world = player.worldObj; if (world.isRemote) return ""; @@ -106,9 +117,12 @@ public class ItemAltarMaker extends Item implements IAltarManipulator { BlockPos pos = mop.getBlockPos(); EnumAltarTier altarTier = BloodAltar.getAltarTier(world, pos); - if (altarTier.equals(EnumAltarTier.ONE)) return "" + altarTier.toInt(); - else { - for (AltarComponent altarComponent : altarTier.getAltarComponents()) { + if (altarTier.equals(EnumAltarTier.ONE)) + return "" + altarTier.toInt(); + else + { + for (AltarComponent altarComponent : altarTier.getAltarComponents()) + { BlockPos componentPos = pos.add(altarComponent.getOffset()); world.setBlockToAir(componentPos); diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBindable.java b/src/main/java/WayofTime/bloodmagic/item/ItemBindable.java index 2c9707da..27016912 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBindable.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBindable.java @@ -23,47 +23,65 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class ItemBindable extends Item implements IBindable { +public class ItemBindable extends Item implements IBindable +{ private int lpUsed; - public ItemBindable() { + public ItemBindable() + { super(); setCreativeTab(BloodMagic.tabBloodMagic); setMaxStackSize(1); } - public static boolean syphonBatteries(ItemStack stack, EntityPlayer player, int damageToBeDone) { - if (!player.worldObj.isRemote) { + public static boolean syphonBatteries(ItemStack stack, EntityPlayer player, int damageToBeDone) + { + if (!player.worldObj.isRemote) + { return NetworkHelper.syphonAndDamage(NetworkHelper.getSoulNetwork(player, player.worldObj), damageToBeDone); - } else { + } else + { double posX = player.posX; double posY = player.posY; double posZ = player.posZ; -// SpellHelper.sendIndexedParticleToAllAround(player.worldObj, posX, posY, posZ, 20, player.worldObj.provider.getDimensionId(), 4, posX, posY, posZ); + // SpellHelper.sendIndexedParticleToAllAround(player.worldObj, posX, + // posY, posZ, 20, player.worldObj.provider.getDimensionId(), 4, + // posX, posY, posZ); player.worldObj.playSoundEffect((double) ((float) player.posX + 0.5F), (double) ((float) player.posY + 0.5F), (double) ((float) player.posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.8F); } return true; } - public static void hurtPlayer(EntityPlayer user, int energySyphoned) { - if (energySyphoned < 100 && energySyphoned > 0) { - if (!user.capabilities.isCreativeMode) { - user.attackEntityFrom(BloodMagicAPI.getDamageSource(), 0F); // Emulate an attack + public static void hurtPlayer(EntityPlayer user, int energySyphoned) + { + if (energySyphoned < 100 && energySyphoned > 0) + { + if (!user.capabilities.isCreativeMode) + { + user.attackEntityFrom(BloodMagicAPI.getDamageSource(), 0F); // Emulate + // an + // attack user.setHealth(user.getHealth() - 1); if (user.getHealth() <= 0.0005f) user.onDeath(BloodMagicAPI.getDamageSource()); } - } else if (energySyphoned >= 100) { - if (!user.capabilities.isCreativeMode) { - for (int i = 0; i < ((energySyphoned + 99) / 100); i++) { - user.attackEntityFrom(BloodMagicAPI.getDamageSource(), 0F); // Emulate an attack + } else if (energySyphoned >= 100) + { + if (!user.capabilities.isCreativeMode) + { + for (int i = 0; i < ((energySyphoned + 99) / 100); i++) + { + user.attackEntityFrom(BloodMagicAPI.getDamageSource(), 0F); // Emulate + // an + // attack user.setHealth(user.getHealth() - 1); - if (user.getHealth() <= 0.0005f) { + if (user.getHealth() <= 0.0005f) + { user.onDeath(BloodMagicAPI.getDamageSource()); break; } @@ -74,7 +92,8 @@ public class ItemBindable extends Item implements IBindable { @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) + { NBTHelper.checkNBT(stack); if (!Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID))) @@ -82,21 +101,25 @@ public class ItemBindable extends Item implements IBindable { } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { BindableHelper.checkAndSetItemOwner(stack, player); return stack; } @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) + { BindableHelper.checkAndSetItemOwner(stack, player); return false; } - protected void damagePlayer(World world, EntityPlayer player, int damage) { - if (world != null) { + protected void damagePlayer(World world, EntityPlayer player, int damage) + { + if (world != null) + { double posX = player.posX; double posY = player.posY; double posZ = player.posZ; @@ -108,26 +131,33 @@ public class ItemBindable extends Item implements IBindable { for (int l = 0; l < 8; ++l) world.spawnParticle(EnumParticleTypes.REDSTONE, posX + Math.random() - Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), f1, f2, f3); } - for (int i = 0; i < damage; i++) { - player.attackEntityFrom(BloodMagicAPI.getDamageSource(), 0F); // Emulate an attack + for (int i = 0; i < damage; i++) + { + player.attackEntityFrom(BloodMagicAPI.getDamageSource(), 0F); // Emulate + // an + // attack player.setHealth(player.getHealth() - 1); - if (player.getHealth() <= 0.0005) { + if (player.getHealth() <= 0.0005) + { player.inventory.dropAllItems(); break; } } } - public int getLPUsed() { + public int getLPUsed() + { return this.lpUsed; } - protected void setLPUsed(int lpUsed) { + protected void setLPUsed(int lpUsed) + { this.lpUsed = lpUsed; } - public String getBindableOwner(ItemStack stack) { + public String getBindableOwner(ItemStack stack) + { stack = NBTHelper.checkNBT(stack); return stack.getTagCompound().getString(Constants.NBT.OWNER_UUID); @@ -136,7 +166,8 @@ public class ItemBindable extends Item implements IBindable { // IBindable @Override - public boolean onBind(EntityPlayer player, ItemStack stack) { + public boolean onBind(EntityPlayer player, ItemStack stack) + { return true; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java b/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java index de6bca87..c9d685dd 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java @@ -19,27 +19,32 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class ItemBloodOrb extends ItemBindable implements IBloodOrb, IBindable { +public class ItemBloodOrb extends ItemBindable implements IBloodOrb, IBindable +{ - public ItemBloodOrb() { + public ItemBloodOrb() + { setUnlocalizedName(Constants.Mod.MODID + ".orb."); setHasSubtypes(true); } @Override - public String getUnlocalizedName(ItemStack stack) { + public String getUnlocalizedName(ItemStack stack) + { return super.getUnlocalizedName(stack) + OrbRegistry.getOrb(stack.getItemDamage()).getName(); } @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) { + public void getSubItems(Item id, CreativeTabs creativeTab, List list) + { for (int i = 0; i < OrbRegistry.getSize(); i++) list.add(new ItemStack(id, 1, i)); } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { super.onItemRightClick(stack, world, player); if (world == null) @@ -49,7 +54,8 @@ public class ItemBloodOrb extends ItemBindable implements IBloodOrb, IBindable { double posY = player.posY; double posZ = player.posZ; world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); -// SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.getDimensionId(), 4, posX, posY, posZ); + // SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, + // 20, world.provider.getDimensionId(), 4, posX, posY, posZ); if (PlayerHelper.isFakePlayer(player)) return stack; @@ -70,7 +76,8 @@ public class ItemBloodOrb extends ItemBindable implements IBloodOrb, IBindable { @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) + { tooltip.add(StatCollector.translateToLocal("tooltip.BloodMagic.orb.desc")); if (advanced) @@ -80,36 +87,42 @@ public class ItemBloodOrb extends ItemBindable implements IBloodOrb, IBindable { } @Override - public ItemStack getContainerItem(ItemStack stack) { + public ItemStack getContainerItem(ItemStack stack) + { return stack; } @Override - public boolean hasContainerItem(ItemStack stack) { + public boolean hasContainerItem(ItemStack stack) + { return true; } // IBindable @Override - public boolean onBind(EntityPlayer player, ItemStack stack) { + public boolean onBind(EntityPlayer player, ItemStack stack) + { return true; } // IBloodOrb @Override - public BloodOrb getOrb(int meta) { + public BloodOrb getOrb(int meta) + { return OrbRegistry.getOrb(meta); } @Override - public int getMaxEssence(int meta) { + public int getMaxEssence(int meta) + { return OrbRegistry.getOrb(meta).getCapacity(); } @Override - public int getOrbLevel(int meta) { + public int getOrbLevel(int meta) + { return OrbRegistry.getOrb(meta).getTier(); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBloodShard.java b/src/main/java/WayofTime/bloodmagic/item/ItemBloodShard.java index 8d74443c..8e6a4b1f 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBloodShard.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBloodShard.java @@ -10,11 +10,13 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class ItemBloodShard extends Item { +public class ItemBloodShard extends Item +{ public String[] names = { "weak", "demon" }; - public ItemBloodShard() { + public ItemBloodShard() + { super(); setCreativeTab(BloodMagic.tabBloodMagic); @@ -24,13 +26,15 @@ public class ItemBloodShard extends Item { @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) { + public void getSubItems(Item id, CreativeTabs creativeTab, List list) + { for (int i = 0; i < names.length; i++) list.add(new ItemStack(id, 1, i)); } @Override - public String getUnlocalizedName(ItemStack stack) { + public String getUnlocalizedName(ItemStack stack) + { return super.getUnlocalizedName(stack) + names[stack.getItemDamage()]; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java index 52862ce7..b2c06f52 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java @@ -19,21 +19,25 @@ import net.minecraft.world.World; import java.util.List; import java.util.Set; -public class ItemBoundAxe extends ItemBoundTool { +public class ItemBoundAxe extends ItemBoundTool +{ private static final Set EFFECTIVE_ON = Sets.newHashSet(Blocks.planks, Blocks.bookshelf, Blocks.log, Blocks.log2, Blocks.chest, Blocks.pumpkin, Blocks.lit_pumpkin, Blocks.melon_block, Blocks.ladder); - public ItemBoundAxe() { + public ItemBoundAxe() + { super("axe", 5, EFFECTIVE_ON); } @Override - public float getStrVsBlock(ItemStack stack, Block block) { + public float getStrVsBlock(ItemStack stack, Block block) + { return block.getMaterial() != Material.wood && block.getMaterial() != Material.plants && block.getMaterial() != Material.vine ? super.getStrVsBlock(stack, block) : 12F; } @Override - protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) { + protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) + { boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(player); int fortuneLvl = EnchantmentHelper.getFortuneModifier(player); int range = (int) (charge * 0.25); @@ -42,20 +46,26 @@ public class ItemBoundAxe extends ItemBoundTool { BlockPos playerPos = player.getPosition().add(0, -1, 0); - for (int i = -range; i <= range; i++) { - for (int j = -range; j <= range; j++) { - for (int k = -range; k <= range; k++) { + for (int i = -range; i <= range; i++) + { + for (int j = -range; j <= range; j++) + { + for (int k = -range; k <= range; k++) + { BlockPos blockPos = playerPos.add(i, j, k); Block block = world.getBlockState(blockPos).getBlock(); int blockMeta = block.getMetaFromState(world.getBlockState(blockPos)); - if (block != null && block.getBlockHardness(world, blockPos) != -1) { + if (block != null && block.getBlockHardness(world, blockPos) != -1) + { float strengthVsBlock = getStrVsBlock(stack, block); - if (strengthVsBlock > 1.1F || block instanceof BlockLeavesBase && world.canMineBlockBody(player, blockPos)) { + if (strengthVsBlock > 1.1F || block instanceof BlockLeavesBase && world.canMineBlockBody(player, blockPos)) + { if (silkTouch && block.canSilkHarvest(world, blockPos, world.getBlockState(blockPos), player)) drops.add(new ItemStackWrapper(block, 1, blockMeta)); - else { + else + { List itemDrops = block.getDrops(world, blockPos, world.getBlockState(blockPos), fortuneLvl); if (itemDrops != null) @@ -75,7 +85,8 @@ public class ItemBoundAxe extends ItemBoundTool { } @Override - public Multimap getAttributeModifiers(ItemStack stack) { + public Multimap getAttributeModifiers(ItemStack stack) + { Multimap multimap = super.getAttributeModifiers(stack); multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Weapon modifier", 7, 0)); return multimap; diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java index 17a7e3c0..94797b60 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java @@ -20,26 +20,31 @@ import net.minecraft.world.World; import java.util.List; import java.util.Set; -public class ItemBoundPickaxe extends ItemBoundTool { +public class ItemBoundPickaxe extends ItemBoundTool +{ private static final Set EFFECTIVE_ON = Sets.newHashSet(Blocks.activator_rail, Blocks.coal_ore, Blocks.cobblestone, Blocks.detector_rail, Blocks.diamond_block, Blocks.diamond_ore, Blocks.double_stone_slab, Blocks.golden_rail, Blocks.gold_block, Blocks.gold_ore, Blocks.ice, Blocks.iron_block, Blocks.iron_ore, Blocks.lapis_block, Blocks.lapis_ore, Blocks.lit_redstone_ore, Blocks.mossy_cobblestone, Blocks.netherrack, Blocks.packed_ice, Blocks.rail, Blocks.redstone_ore, Blocks.sandstone, Blocks.red_sandstone, Blocks.stone, Blocks.stone_slab); - public ItemBoundPickaxe() { + public ItemBoundPickaxe() + { super("pickaxe", 5, EFFECTIVE_ON); } @Override - public boolean canHarvestBlock(Block blockIn) { + public boolean canHarvestBlock(Block blockIn) + { return true; } @Override - public float getStrVsBlock(ItemStack stack, Block block) { + public float getStrVsBlock(ItemStack stack, Block block) + { return block.getMaterial() != Material.iron && block.getMaterial() != Material.anvil && block.getMaterial() != Material.rock ? super.getStrVsBlock(stack, block) : 12F; } @Override - protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) { + protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) + { boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(player); int fortuneLvl = EnchantmentHelper.getFortuneModifier(player); int range = (int) (charge * 0.25); @@ -48,20 +53,26 @@ public class ItemBoundPickaxe extends ItemBoundTool { BlockPos playerPos = player.getPosition().add(0, -1, 0); - for (int i = -range; i <= range; i++) { - for (int j = -range; j <= range; j++) { - for (int k = -range; k <= range; k++) { + for (int i = -range; i <= range; i++) + { + for (int j = -range; j <= range; j++) + { + for (int k = -range; k <= range; k++) + { BlockPos blockPos = playerPos.add(i, j, k); Block block = world.getBlockState(blockPos).getBlock(); int blockMeta = block.getMetaFromState(world.getBlockState(blockPos)); - if (block != null && block.getBlockHardness(world, blockPos) != -1) { + if (block != null && block.getBlockHardness(world, blockPos) != -1) + { float strengthVsBlock = getStrVsBlock(stack, block); - if (strengthVsBlock > 1.1F && world.canMineBlockBody(player, blockPos)) { + if (strengthVsBlock > 1.1F && world.canMineBlockBody(player, blockPos)) + { if (silkTouch && block.canSilkHarvest(world, blockPos, world.getBlockState(blockPos), player)) drops.add(new ItemStackWrapper(block, 1, blockMeta)); - else { + else + { List itemDrops = block.getDrops(world, blockPos, world.getBlockState(blockPos), fortuneLvl); if (itemDrops != null) @@ -81,7 +92,8 @@ public class ItemBoundPickaxe extends ItemBoundTool { } @Override - public Multimap getAttributeModifiers(ItemStack stack) { + public Multimap getAttributeModifiers(ItemStack stack) + { Multimap multimap = super.getAttributeModifiers(stack); multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Weapon modifier", 5, 0)); return multimap; diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java index f1eaba9a..dd6d77c2 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java @@ -17,21 +17,25 @@ import net.minecraft.world.World; import java.util.List; import java.util.Set; -public class ItemBoundShovel extends ItemBoundTool { +public class ItemBoundShovel extends ItemBoundTool +{ private static final Set EFFECTIVE_ON = Sets.newHashSet(Blocks.clay, Blocks.dirt, Blocks.farmland, Blocks.grass, Blocks.gravel, Blocks.mycelium, Blocks.sand, Blocks.snow, Blocks.snow_layer, Blocks.soul_sand); - public ItemBoundShovel() { + public ItemBoundShovel() + { super("shovel", 5, EFFECTIVE_ON); } @Override - public boolean canHarvestBlock(Block blockIn) { + public boolean canHarvestBlock(Block blockIn) + { return blockIn == Blocks.snow_layer || blockIn == Blocks.snow; } @Override - protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) { + protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) + { boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(player); int fortuneLvl = EnchantmentHelper.getFortuneModifier(player); int range = (int) (charge * 0.25); @@ -40,20 +44,26 @@ public class ItemBoundShovel extends ItemBoundTool { BlockPos playerPos = player.getPosition().add(0, -1, 0); - for (int i = -range; i <= range; i++) { - for (int j = -range; j <= range; j++) { - for (int k = -range; k <= range; k++) { + for (int i = -range; i <= range; i++) + { + for (int j = -range; j <= range; j++) + { + for (int k = -range; k <= range; k++) + { BlockPos blockPos = playerPos.add(i, j, k); Block block = world.getBlockState(blockPos).getBlock(); int blockMeta = block.getMetaFromState(world.getBlockState(blockPos)); - if (block != null && block.getBlockHardness(world, blockPos) != -1) { + if (block != null && block.getBlockHardness(world, blockPos) != -1) + { float strengthVsBlock = getStrVsBlock(stack, block); - if (strengthVsBlock > 1.1F && world.canMineBlockBody(player, blockPos)) { + if (strengthVsBlock > 1.1F && world.canMineBlockBody(player, blockPos)) + { if (silkTouch && block.canSilkHarvest(world, blockPos, world.getBlockState(blockPos), player)) drops.add(new ItemStackWrapper(block, 1, blockMeta)); - else { + else + { List itemDrops = block.getDrops(world, blockPos, world.getBlockState(blockPos), fortuneLvl); if (itemDrops != null) @@ -73,7 +83,8 @@ public class ItemBoundShovel extends ItemBoundTool { } @Override - public Multimap getAttributeModifiers(ItemStack stack) { + public Multimap getAttributeModifiers(ItemStack stack) + { Multimap multimap = super.getAttributeModifiers(stack); multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Weapon modifier", 1, 0)); return multimap; diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java index e2be985b..ee800fbc 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java @@ -25,11 +25,13 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class ItemBoundSword extends ItemSword { +public class ItemBoundSword extends ItemSword +{ private int lpUsed; - public ItemBoundSword() { + public ItemBoundSword() + { super(ModItems.boundToolMaterial); setUnlocalizedName(Constants.Mod.MODID + ".bound.sword"); @@ -40,9 +42,11 @@ public class ItemBoundSword extends ItemSword { } @Override - public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft) { + public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft) + { - if (!playerIn.isSneaking() && getActivated(stack)) { + if (!playerIn.isSneaking() && getActivated(stack)) + { int i = this.getMaxItemUseDuration(stack) - timeLeft; BoundToolEvent.Release event = new BoundToolEvent.Release(playerIn, stack, i); if (MinecraftForge.EVENT_BUS.post(event)) @@ -50,27 +54,30 @@ public class ItemBoundSword extends ItemSword { i = event.charge; - //TODO Make conical charge blast + // TODO Make conical charge blast Explosion explosion = new Explosion(worldIn, playerIn, playerIn.posX, playerIn.posY, playerIn.posZ, (float) (i * 0.5), true, true); - if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(worldIn, explosion)) return; + if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(worldIn, explosion)) + return; explosion.doExplosionA(); explosion.doExplosionB(true); } } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { BindableHelper.checkAndSetItemOwner(stack, player); -// if (!world.isRemote) + // if (!world.isRemote) { if (player.isSneaking()) setActivated(stack, !getActivated(stack)); if (getActivated(stack) && ItemBindable.syphonBatteries(stack, player, lpUsed)) return stack; - if (!player.isSneaking() && getActivated(stack)) { + if (!player.isSneaking() && getActivated(stack)) + { BoundToolEvent.Charge event = new BoundToolEvent.Charge(player, stack); if (MinecraftForge.EVENT_BUS.post(event)) return event.result; @@ -83,10 +90,14 @@ public class ItemBoundSword extends ItemSword { } @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { - if (getActivated(stack)) { - if (target != null || attacker != null) { - if (target instanceof EntityLiving) { + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) + { + if (getActivated(stack)) + { + if (target != null || attacker != null) + { + if (target instanceof EntityLiving) + { if (!target.isPotionActive(Potion.weakness)) target.addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 2)); } @@ -105,13 +116,15 @@ public class ItemBoundSword extends ItemSword { } @Override - public EnumAction getItemUseAction(ItemStack stack) { + public EnumAction getItemUseAction(ItemStack stack) + { return EnumAction.BLOCK; } @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) + { NBTHelper.checkNBT(stack); if (StatCollector.canTranslate("tooltip.BloodMagic.bound.sword.desc")) @@ -125,11 +138,13 @@ public class ItemBoundSword extends ItemSword { tooltip.add(TextHelper.getFormattedText(String.format(StatCollector.translateToLocal("tooltip.BloodMagic.currentOwner"), stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)))); } - private boolean getActivated(ItemStack stack) { + private boolean getActivated(ItemStack stack) + { return stack.getItemDamage() > 0; } - private ItemStack setActivated(ItemStack stack, boolean activated) { + private ItemStack setActivated(ItemStack stack, boolean activated) + { stack.setItemDamage(activated ? 1 : 0); return stack; diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java index 9e5e7e8a..01b08c55 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java @@ -25,7 +25,8 @@ import java.util.List; import java.util.Set; @Getter -public class ItemBoundTool extends ItemBindable { +public class ItemBoundTool extends ItemBindable +{ private Set effectiveBlocks; protected final String tooltipBase; @@ -36,7 +37,8 @@ public class ItemBoundTool extends ItemBindable { public final int chargeTime = 30; - public ItemBoundTool(String name, int lpUsed, Set effectiveBlocks) { + public ItemBoundTool(String name, int lpUsed, Set effectiveBlocks) + { super(); setUnlocalizedName(Constants.Mod.MODID + ".bound." + name); setHasSubtypes(true); @@ -48,36 +50,43 @@ public class ItemBoundTool extends ItemBindable { this.effectiveBlocks = effectiveBlocks; } - public ItemBoundTool(String name, int lpUsed) { + public ItemBoundTool(String name, int lpUsed) + { this(name, lpUsed, null); } @Override - public float getStrVsBlock(ItemStack stack, Block block) { + public float getStrVsBlock(ItemStack stack, Block block) + { return this.effectiveBlocks.contains(block) ? 8.0F : 1.0F; } @Override - public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { - if (entityIn instanceof EntityPlayer && getActivated(stack) && isSelected && isBeingHeldDown() && stack == ((EntityPlayer) entityIn).getCurrentEquippedItem()) { + public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) + { + if (entityIn instanceof EntityPlayer && getActivated(stack) && isSelected && isBeingHeldDown() && stack == ((EntityPlayer) entityIn).getCurrentEquippedItem()) + { EntityPlayer player = (EntityPlayer) entityIn; heldDownCount = Math.min(player.getItemInUseDuration(), chargeTime); } } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { BindableHelper.checkAndSetItemOwner(stack, player); -// if (!world.isRemote) + // if (!world.isRemote) { if (player.isSneaking()) setActivated(stack, !getActivated(stack)); -// if (getActivated(stack) && ItemBindable.syphonBatteries(stack, player, getLPUsed())) -// return stack; + // if (getActivated(stack) && ItemBindable.syphonBatteries(stack, + // player, getLPUsed())) + // return stack; - if (!player.isSneaking() && getActivated(stack)) { + if (!player.isSneaking() && getActivated(stack)) + { BoundToolEvent.Charge event = new BoundToolEvent.Charge(player, stack); if (MinecraftForge.EVENT_BUS.post(event)) return event.result; @@ -91,7 +100,8 @@ public class ItemBoundTool extends ItemBindable { } @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) + { if (BindableHelper.checkAndSetItemOwner(stack, player) && ItemBindable.syphonBatteries(stack, player, getLPUsed())) return false; @@ -99,15 +109,18 @@ public class ItemBoundTool extends ItemBindable { } @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) + { this.onItemRightClick(stack, world, player); return false; } @Override - public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft) { - if (!playerIn.isSneaking() && getActivated(stack)) { + public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft) + { + if (!playerIn.isSneaking() && getActivated(stack)) + { int i = this.getMaxItemUseDuration(stack) - timeLeft; BoundToolEvent.Release event = new BoundToolEvent.Release(playerIn, stack, i); if (MinecraftForge.EVENT_BUS.post(event)) @@ -120,33 +133,39 @@ public class ItemBoundTool extends ItemBindable { } } - protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) { + protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) + { } @Override - public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn) { + public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn) + { return stack; } @Override - public int getMaxItemUseDuration(ItemStack stack) { + public int getMaxItemUseDuration(ItemStack stack) + { return 72000; } @Override - public EnumAction getItemUseAction(ItemStack stack) { + public EnumAction getItemUseAction(ItemStack stack) + { return EnumAction.BOW; } @Override - public int getItemEnchantability() { + public int getItemEnchantability() + { return 50; } @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) + { if (StatCollector.canTranslate(tooltipBase + "desc")) tooltip.add(TextHelper.localizeEffect(tooltipBase + "desc")); @@ -159,22 +178,27 @@ public class ItemBoundTool extends ItemBindable { } @Override - public boolean showDurabilityBar(ItemStack stack) { + public boolean showDurabilityBar(ItemStack stack) + { return getActivated(stack) && beingHeldDown; } @Override - public double getDurabilityForDisplay(ItemStack stack) { + public double getDurabilityForDisplay(ItemStack stack) + { return ((double) -Math.min(getHeldDownCount(), chargeTime) / chargeTime) + 1; } - protected static void dropStacks(Multiset drops, World world, BlockPos posToDrop) { - for (Multiset.Entry entry : drops.entrySet()) { + protected static void dropStacks(Multiset drops, World world, BlockPos posToDrop) + { + for (Multiset.Entry entry : drops.entrySet()) + { int count = entry.getCount(); ItemStackWrapper stack = entry.getElement(); int maxStackSize = stack.item.getItemStackLimit(stack.toStack(1)); - while (count >= maxStackSize) { + while (count >= maxStackSize) + { world.spawnEntityInWorld(new EntityItem(world, posToDrop.getX(), posToDrop.getY(), posToDrop.getZ(), stack.toStack(maxStackSize))); count -= maxStackSize; } @@ -184,11 +208,13 @@ public class ItemBoundTool extends ItemBindable { } } - public boolean getActivated(ItemStack stack) { + public boolean getActivated(ItemStack stack) + { return stack.getItemDamage() > 0; } - public ItemStack setActivated(ItemStack stack, boolean activated) { + public ItemStack setActivated(ItemStack stack, boolean activated) + { stack.setItemDamage(activated ? 1 : 0); return stack; diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBucketEssence.java b/src/main/java/WayofTime/bloodmagic/item/ItemBucketEssence.java index 1756e68c..435429ce 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBucketEssence.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBucketEssence.java @@ -6,9 +6,11 @@ import WayofTime.bloodmagic.registry.ModBlocks; import net.minecraft.init.Items; import net.minecraft.item.ItemBucket; -public class ItemBucketEssence extends ItemBucket { +public class ItemBucketEssence extends ItemBucket +{ - public ItemBucketEssence() { + public ItemBucketEssence() + { super(ModBlocks.lifeEssence); setUnlocalizedName(Constants.Mod.MODID + ".bucket.lifeEssence"); diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemComponent.java b/src/main/java/WayofTime/bloodmagic/item/ItemComponent.java index a5d20324..afd4d835 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemComponent.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemComponent.java @@ -13,7 +13,8 @@ import net.minecraftforge.fml.relauncher.SideOnly; import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.Constants; -public class ItemComponent extends Item { +public class ItemComponent extends Item +{ @Getter private static ArrayList names = new ArrayList(); @@ -28,7 +29,8 @@ public class ItemComponent extends Item { public static final String REAGENT_SIGHT = "reagentSight"; public static final String REAGENT_BINDING = "reagentBinding"; - public ItemComponent() { + public ItemComponent() + { super(); setUnlocalizedName(Constants.Mod.MODID + ".baseComponent."); @@ -38,7 +40,8 @@ public class ItemComponent extends Item { buildItemList(); } - private void buildItemList() { + private void buildItemList() + { names.add(0, REAGENT_WATER); names.add(1, REAGENT_LAVA); names.add(2, REAGENT_AIR); @@ -51,18 +54,21 @@ public class ItemComponent extends Item { } @Override - public String getUnlocalizedName(ItemStack stack) { + public String getUnlocalizedName(ItemStack stack) + { return super.getUnlocalizedName(stack) + names.get(stack.getItemDamage()); } @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) { + public void getSubItems(Item id, CreativeTabs creativeTab, List list) + { for (int i = 0; i < names.size(); i++) list.add(new ItemStack(id, 1, i)); } - public static ItemStack getStack(String name) { + public static ItemStack getStack(String name) + { return new ItemStack(ModItems.itemComponent, 1, names.indexOf(name)); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemDaggerOfSacrifice.java b/src/main/java/WayofTime/bloodmagic/item/ItemDaggerOfSacrifice.java index fc29a769..0828789d 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemDaggerOfSacrifice.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemDaggerOfSacrifice.java @@ -18,9 +18,11 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.world.World; -public class ItemDaggerOfSacrifice extends Item { +public class ItemDaggerOfSacrifice extends Item +{ - public ItemDaggerOfSacrifice() { + public ItemDaggerOfSacrifice() + { super(); setUnlocalizedName(Constants.Mod.MODID + ".daggerOfSacrifice"); setCreativeTab(BloodMagic.tabBloodMagic); @@ -29,7 +31,8 @@ public class ItemDaggerOfSacrifice extends Item { } @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) + { if (target == null || attacker == null || attacker.worldObj.isRemote || (attacker instanceof EntityPlayer && !(attacker instanceof EntityPlayerMP))) return false; @@ -39,14 +42,19 @@ public class ItemDaggerOfSacrifice extends Item { if (target.isDead || target.getHealth() < 0.5F) return false; - //TODO Make these configurable + // TODO Make these configurable int lifeEssence = 500; - if (target instanceof EntityVillager) lifeEssence = 2000; - else if (target instanceof EntitySlime) lifeEssence = 150; - else if (target instanceof EntityEnderman) lifeEssence = 200; - else if (target instanceof EntityAnimal) lifeEssence = 250; + if (target instanceof EntityVillager) + lifeEssence = 2000; + else if (target instanceof EntitySlime) + lifeEssence = 150; + else if (target instanceof EntityEnderman) + lifeEssence = 200; + else if (target instanceof EntityAnimal) + lifeEssence = 250; - if (findAndFillAltar(attacker.worldObj, target, lifeEssence)) { + if (findAndFillAltar(attacker.worldObj, target, lifeEssence)) + { double posX = target.posX; double posY = target.posY; double posZ = target.posZ; @@ -58,10 +66,12 @@ public class ItemDaggerOfSacrifice extends Item { return false; } - public boolean findAndFillAltar(World world, EntityLivingBase sacrifice, int amount) { + public boolean findAndFillAltar(World world, EntityLivingBase sacrifice, int amount) + { IBloodAltar bloodAltar = findBloodAltar(world, sacrifice.getPosition()); - if (bloodAltar != null) { + if (bloodAltar != null) + { bloodAltar.sacrificialDaggerCall(amount, true); bloodAltar.startCycle(); return true; @@ -70,12 +80,16 @@ public class ItemDaggerOfSacrifice extends Item { return false; } - public IBloodAltar findBloodAltar(World world, BlockPos blockPos) { + public IBloodAltar findBloodAltar(World world, BlockPos blockPos) + { TileEntity tileEntity; - for (int i = -2; i <= 2; i++) { - for (int j = -2; j <= 2; j++) { - for (int k = -2; k <= 1; k++) { + for (int i = -2; i <= 2; i++) + { + for (int j = -2; j <= 2; j++) + { + for (int k = -2; k <= 1; k++) + { tileEntity = world.getTileEntity(blockPos.add(i, k, j)); if ((tileEntity instanceof IBloodAltar)) diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemInscriptionTool.java b/src/main/java/WayofTime/bloodmagic/item/ItemInscriptionTool.java index ecdba461..97bcf219 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemInscriptionTool.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemInscriptionTool.java @@ -19,9 +19,11 @@ import java.util.Arrays; import java.util.List; // TODO - NBT based damage -public class ItemInscriptionTool extends ItemBindable { +public class ItemInscriptionTool extends ItemBindable +{ - public ItemInscriptionTool() { + public ItemInscriptionTool() + { super(); setLPUsed(100); @@ -30,23 +32,27 @@ public class ItemInscriptionTool extends ItemBindable { } @Override - public String getUnlocalizedName(ItemStack stack) { + public String getUnlocalizedName(ItemStack stack) + { return super.getUnlocalizedName(stack) + EnumRuneType.values()[stack.getItemDamage()]; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) { + public void getSubItems(Item id, CreativeTabs creativeTab, List list) + { for (int i = 1; i < EnumRuneType.values().length; i++) list.add(new ItemStack(id, 1, i)); } @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) + { IBlockState state = world.getBlockState(pos); - if (state.getBlock() instanceof BlockRitualStone && !((BlockRitualStone)state.getBlock()).isRuneType(world, pos, getType(stack))) { + if (state.getBlock() instanceof BlockRitualStone && !((BlockRitualStone) state.getBlock()).isRuneType(world, pos, getType(stack))) + { world.setBlockState(pos, state.withProperty(((BlockRitualStone) state.getBlock()).getStringProp(), getType(stack).getName())); return true; } @@ -56,12 +62,14 @@ public class ItemInscriptionTool extends ItemBindable { @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) + { list.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.BloodMagic.inscriber.desc")))); super.addInformation(stack, player, list, advanced); } - public EnumRuneType getType(ItemStack stack) { + public EnumRuneType getType(ItemStack stack) + { return EnumRuneType.values()[stack.getItemDamage()]; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java b/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java index 7076b703..a23082f0 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java @@ -32,393 +32,466 @@ import WayofTime.bloodmagic.tile.TileMasterRitualStone; import WayofTime.bloodmagic.util.ChatUtil; import WayofTime.bloodmagic.util.helper.TextHelper; -public class ItemRitualDiviner extends Item { +public class ItemRitualDiviner extends Item +{ - public static final String tooltipBase = "tooltip.BloodMagic.diviner."; + public static final String tooltipBase = "tooltip.BloodMagic.diviner."; - public ItemRitualDiviner() { - setUnlocalizedName(Constants.Mod.MODID + ".ritualDiviner"); - setCreativeTab(BloodMagic.tabBloodMagic); - setHasSubtypes(true); - setMaxStackSize(1); - } + public ItemRitualDiviner() + { + setUnlocalizedName(Constants.Mod.MODID + ".ritualDiviner"); + setCreativeTab(BloodMagic.tabBloodMagic); + setHasSubtypes(true); + setMaxStackSize(1); + } - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { - if (addRuneToRitual(stack, world, pos, player)) { - //TODO: Have the diviner automagically build the ritual - } - - return false; - } + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) + { + if (addRuneToRitual(stack, world, pos, player)) + { + // TODO: Have the diviner automagically build the ritual + } - /** - * Adds a single rune to the ritual. - * - * @param world - * - - * @param pos - * - Block Position of the MRS. - * @return - True if a rune was successfully added - */ - public boolean addRuneToRitual(ItemStack stack, World world, BlockPos pos, EntityPlayer player) { - TileEntity tile = world.getTileEntity(pos); + return false; + } - if (tile instanceof TileMasterRitualStone) { - Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(stack)); - if (ritual != null) { - EnumFacing direction = getDirection(stack); - for (RitualComponent component : ritual.getComponents()) { - if (!canPlaceRitualStone(component.getRuneType(), stack)) { - return false; - } - BlockPos offset = component.getOffset(direction); - BlockPos newPos = pos.add(offset); - IBlockState state = world.getBlockState(newPos); - Block block = state.getBlock(); - if (block instanceof IRitualStone) { // TODO: Check tile - // entity as well. - if (((IRitualStone) block).isRuneType(world, newPos, component.getRuneType())) { - continue; - } else { - // Replace existing ritual stone - int meta = component.getRuneType().ordinal(); - IBlockState newState = ModBlocks.ritualStone.getStateFromMeta(meta); - world.setBlockState(newPos, newState); - return true; - } - } else if (block.isAir(world, newPos)) { - if (!consumeStone(stack, world, player)) { - return false; - } - int meta = component.getRuneType().ordinal(); - IBlockState newState = ModBlocks.ritualStone.getStateFromMeta(meta); - world.setBlockState(newPos, newState); - return true; - } else { - return false; // TODO: Possibly replace the block with a - // ritual stone - } - } - } - } + /** + * Adds a single rune to the ritual. + * + * @param world + * - + * @param pos + * - Block Position of the MRS. + * @return - True if a rune was successfully added + */ + public boolean addRuneToRitual(ItemStack stack, World world, BlockPos pos, EntityPlayer player) + { + TileEntity tile = world.getTileEntity(pos); - return false; - } + if (tile instanceof TileMasterRitualStone) + { + Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(stack)); + if (ritual != null) + { + EnumFacing direction = getDirection(stack); + for (RitualComponent component : ritual.getComponents()) + { + if (!canPlaceRitualStone(component.getRuneType(), stack)) + { + return false; + } + BlockPos offset = component.getOffset(direction); + BlockPos newPos = pos.add(offset); + IBlockState state = world.getBlockState(newPos); + Block block = state.getBlock(); + if (block instanceof IRitualStone) + { // TODO: Check tile + // entity as well. + if (((IRitualStone) block).isRuneType(world, newPos, component.getRuneType())) + { + continue; + } else + { + // Replace existing ritual stone + int meta = component.getRuneType().ordinal(); + IBlockState newState = ModBlocks.ritualStone.getStateFromMeta(meta); + world.setBlockState(newPos, newState); + return true; + } + } else if (block.isAir(world, newPos)) + { + if (!consumeStone(stack, world, player)) + { + return false; + } + int meta = component.getRuneType().ordinal(); + IBlockState newState = ModBlocks.ritualStone.getStateFromMeta(meta); + world.setBlockState(newPos, newState); + return true; + } else + { + return false; // TODO: Possibly replace the block with a + // ritual stone + } + } + } + } - // TODO: Make this work for any IRitualStone - public boolean consumeStone(ItemStack stack, World world, EntityPlayer player) { - ItemStack[] inventory = player.inventory.mainInventory; - for (int i = 0; i < inventory.length; i++) { - ItemStack newStack = inventory[i]; - if (newStack == null) { - continue; - } - Item item = newStack.getItem(); - if (item instanceof ItemBlock) { - Block block = ((ItemBlock) item).getBlock(); - if (block == ModBlocks.ritualStone) { - newStack.stackSize--; - if (newStack.stackSize <= 0) { - inventory[i] = null; - } + return false; + } - return true; - } - } - } + // TODO: Make this work for any IRitualStone + public boolean consumeStone(ItemStack stack, World world, EntityPlayer player) + { + ItemStack[] inventory = player.inventory.mainInventory; + for (int i = 0; i < inventory.length; i++) + { + ItemStack newStack = inventory[i]; + if (newStack == null) + { + continue; + } + Item item = newStack.getItem(); + if (item instanceof ItemBlock) + { + Block block = ((ItemBlock) item).getBlock(); + if (block == ModBlocks.ritualStone) + { + newStack.stackSize--; + if (newStack.stackSize <= 0) + { + inventory[i] = null; + } - return false; - } + return true; + } + } + } - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { - Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(stack)); - if (ritual != null) { - tooltip.add(TextHelper.localize("tooltip.BloodMagic.diviner.currentRitual") + TextHelper.localize(ritual.getUnlocalizedName())); + return false; + } - boolean sneaking = Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT); + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) + { + Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(stack)); + if (ritual != null) + { + tooltip.add(TextHelper.localize("tooltip.BloodMagic.diviner.currentRitual") + TextHelper.localize(ritual.getUnlocalizedName())); - if (sneaking) { - tooltip.add(TextHelper.localize(tooltipBase + "currentDirection", getDirection(stack))); - tooltip.add(""); - ArrayList componentList = ritual.getComponents(); + boolean sneaking = Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT); - int blankRunes = 0; - int airRunes = 0; - int waterRunes = 0; - int fireRunes = 0; - int earthRunes = 0; - int duskRunes = 0; - int dawnRunes = 0; - int totalRunes = 0; + if (sneaking) + { + tooltip.add(TextHelper.localize(tooltipBase + "currentDirection", getDirection(stack))); + tooltip.add(""); + ArrayList componentList = ritual.getComponents(); - for (RitualComponent component : componentList) { - totalRunes++; - switch (component.getRuneType()) { - case BLANK: - blankRunes++; - break; - case AIR: - airRunes++; - break; - case EARTH: - earthRunes++; - break; - case FIRE: - fireRunes++; - break; - case WATER: - waterRunes++; - break; - case DUSK: - duskRunes++; - break; - case DAWN: - dawnRunes++; - break; - } - } + int blankRunes = 0; + int airRunes = 0; + int waterRunes = 0; + int fireRunes = 0; + int earthRunes = 0; + int duskRunes = 0; + int dawnRunes = 0; + int totalRunes = 0; - if (blankRunes > 0) { - tooltip.add(TextHelper.localize(tooltipBase + "blankRune", blankRunes)); - } - if (waterRunes > 0) { - tooltip.add(TextHelper.localize(tooltipBase + "waterRune", waterRunes)); - } - if (airRunes > 0) { - tooltip.add(TextHelper.localize(tooltipBase + "airRune", airRunes)); - } - if (fireRunes > 0) { - tooltip.add(TextHelper.localize(tooltipBase + "fireRune", fireRunes)); - } - if (earthRunes > 0) { - tooltip.add(TextHelper.localize(tooltipBase + "earthRune", earthRunes)); - } - if (duskRunes > 0) { - tooltip.add(TextHelper.localize(tooltipBase + "duskRune", duskRunes)); - } - if (dawnRunes > 0) { - tooltip.add(TextHelper.localize(tooltipBase + "dawnRune", dawnRunes)); - } + for (RitualComponent component : componentList) + { + totalRunes++; + switch (component.getRuneType()) + { + case BLANK: + blankRunes++; + break; + case AIR: + airRunes++; + break; + case EARTH: + earthRunes++; + break; + case FIRE: + fireRunes++; + break; + case WATER: + waterRunes++; + break; + case DUSK: + duskRunes++; + break; + case DAWN: + dawnRunes++; + break; + } + } - tooltip.add(""); - tooltip.add(TextHelper.localize(tooltipBase + "totalRune", totalRunes)); - } else { - tooltip.add(""); - tooltip.add(TextHelper.localize(tooltipBase + "extraInfo")); - } - } - } + if (blankRunes > 0) + { + tooltip.add(TextHelper.localize(tooltipBase + "blankRune", blankRunes)); + } + if (waterRunes > 0) + { + tooltip.add(TextHelper.localize(tooltipBase + "waterRune", waterRunes)); + } + if (airRunes > 0) + { + tooltip.add(TextHelper.localize(tooltipBase + "airRune", airRunes)); + } + if (fireRunes > 0) + { + tooltip.add(TextHelper.localize(tooltipBase + "fireRune", fireRunes)); + } + if (earthRunes > 0) + { + tooltip.add(TextHelper.localize(tooltipBase + "earthRune", earthRunes)); + } + if (duskRunes > 0) + { + tooltip.add(TextHelper.localize(tooltipBase + "duskRune", duskRunes)); + } + if (dawnRunes > 0) + { + tooltip.add(TextHelper.localize(tooltipBase + "dawnRune", dawnRunes)); + } - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + tooltip.add(""); + tooltip.add(TextHelper.localize(tooltipBase + "totalRune", totalRunes)); + } else + { + tooltip.add(""); + tooltip.add(TextHelper.localize(tooltipBase + "extraInfo")); + } + } + } - if (player.isSneaking() && !world.isRemote) { - cycleRitual(stack, player); - } + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { - return stack; - } + if (player.isSneaking() && !world.isRemote) + { + cycleRitual(stack, player); + } - @Override - public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) { - if (entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) entityLiving; + return stack; + } - if (!player.isSwingInProgress) { - if (player.isSneaking()) { - cycleRitualBackwards(stack, player); - } else { - cycleDirection(stack, player); - } - } - } + @Override + public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) + { + if (entityLiving instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) entityLiving; - return false; - } + if (!player.isSwingInProgress) + { + if (player.isSneaking()) + { + cycleRitualBackwards(stack, player); + } else + { + cycleDirection(stack, player); + } + } + } - public void cycleDirection(ItemStack stack, EntityPlayer player) { - EnumFacing direction = getDirection(stack); - EnumFacing newDirection; - switch (direction) { - case NORTH: - newDirection = EnumFacing.EAST; - break; - case EAST: - newDirection = EnumFacing.SOUTH; - break; - case SOUTH: - newDirection = EnumFacing.WEST; - break; - case WEST: - newDirection = EnumFacing.NORTH; - break; - default: - newDirection = EnumFacing.NORTH; - } + return false; + } - setDirection(stack, newDirection); - notifyDirectionChange(newDirection, player); - } + public void cycleDirection(ItemStack stack, EntityPlayer player) + { + EnumFacing direction = getDirection(stack); + EnumFacing newDirection; + switch (direction) + { + case NORTH: + newDirection = EnumFacing.EAST; + break; + case EAST: + newDirection = EnumFacing.SOUTH; + break; + case SOUTH: + newDirection = EnumFacing.WEST; + break; + case WEST: + newDirection = EnumFacing.NORTH; + break; + default: + newDirection = EnumFacing.NORTH; + } - public void notifyDirectionChange(EnumFacing direction, EntityPlayer player) { - ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentDirection", direction.getName())); - } + setDirection(stack, newDirection); + notifyDirectionChange(newDirection, player); + } - public void setDirection(ItemStack stack, EnumFacing direction) { - if (!stack.hasTagCompound()) { - stack.setTagCompound(new NBTTagCompound()); - } + public void notifyDirectionChange(EnumFacing direction, EntityPlayer player) + { + ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentDirection", direction.getName())); + } - NBTTagCompound tag = stack.getTagCompound(); + public void setDirection(ItemStack stack, EnumFacing direction) + { + if (!stack.hasTagCompound()) + { + stack.setTagCompound(new NBTTagCompound()); + } - tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex()); - } + NBTTagCompound tag = stack.getTagCompound(); - public EnumFacing getDirection(ItemStack stack) { - if (!stack.hasTagCompound()) { - stack.setTagCompound(new NBTTagCompound()); - return EnumFacing.NORTH; - } + tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex()); + } - NBTTagCompound tag = stack.getTagCompound(); + public EnumFacing getDirection(ItemStack stack) + { + if (!stack.hasTagCompound()) + { + stack.setTagCompound(new NBTTagCompound()); + return EnumFacing.NORTH; + } - return EnumFacing.VALUES[tag.getInteger(Constants.NBT.DIRECTION)]; - } + NBTTagCompound tag = stack.getTagCompound(); - /** - * Cycles the selected ritual to the next available ritual that is enabled. - * - * @param stack - * - The ItemStack of the ritual diviner - * @param player - * - The player using the ritual diviner - */ - public void cycleRitual(ItemStack stack, EntityPlayer player) { - String key = getCurrentRitual(stack); - List idList = RitualRegistry.getOrderedIds(); - String firstId = ""; - boolean foundId = false; - boolean foundFirst = false; + return EnumFacing.VALUES[tag.getInteger(Constants.NBT.DIRECTION)]; + } - for (String str : idList) { - Ritual ritual = RitualRegistry.getRitualForId(str); - - if (!RitualRegistry.ritualEnabled(ritual) || !canDivinerPerformRitual(stack, ritual)) { - continue; - } + /** + * Cycles the selected ritual to the next available ritual that is enabled. + * + * @param stack + * - The ItemStack of the ritual diviner + * @param player + * - The player using the ritual diviner + */ + public void cycleRitual(ItemStack stack, EntityPlayer player) + { + String key = getCurrentRitual(stack); + List idList = RitualRegistry.getOrderedIds(); + String firstId = ""; + boolean foundId = false; + boolean foundFirst = false; - if (!foundFirst) { - firstId = str; - foundFirst = true; - } + for (String str : idList) + { + Ritual ritual = RitualRegistry.getRitualForId(str); - if (foundId) { - setCurrentRitual(stack, str); - notifyRitualChange(str, player); - return; - } else { - if (str.equals(key)) { - foundId = true; - continue; - } - } - } + if (!RitualRegistry.ritualEnabled(ritual) || !canDivinerPerformRitual(stack, ritual)) + { + continue; + } - if (foundFirst) { - setCurrentRitual(stack, firstId); - notifyRitualChange(firstId, player); - } - } + if (!foundFirst) + { + firstId = str; + foundFirst = true; + } - /** - * Does the same as cycleRitual but instead cycles backwards. - * - * @param stack - * @param player - */ - public void cycleRitualBackwards(ItemStack stack, EntityPlayer player) { - String key = getCurrentRitual(stack); - List idList = RitualRegistry.getOrderedIds(); - String firstId = ""; - boolean foundId = false; - boolean foundFirst = false; + if (foundId) + { + setCurrentRitual(stack, str); + notifyRitualChange(str, player); + return; + } else + { + if (str.equals(key)) + { + foundId = true; + continue; + } + } + } - for (int i = idList.size() - 1; i >= 0; i--) { - String str = idList.get(i); - Ritual ritual = RitualRegistry.getRitualForId(str); + if (foundFirst) + { + setCurrentRitual(stack, firstId); + notifyRitualChange(firstId, player); + } + } - if (!RitualRegistry.ritualEnabled(ritual) || !canDivinerPerformRitual(stack, ritual)) { - continue; - } + /** + * Does the same as cycleRitual but instead cycles backwards. + * + * @param stack + * @param player + */ + public void cycleRitualBackwards(ItemStack stack, EntityPlayer player) + { + String key = getCurrentRitual(stack); + List idList = RitualRegistry.getOrderedIds(); + String firstId = ""; + boolean foundId = false; + boolean foundFirst = false; - if (!foundFirst) { - firstId = str; - foundFirst = true; - } + for (int i = idList.size() - 1; i >= 0; i--) + { + String str = idList.get(i); + Ritual ritual = RitualRegistry.getRitualForId(str); - if (foundId) { - setCurrentRitual(stack, str); - notifyRitualChange(str, player); - return; - } else { - if (str.equals(key)) { - foundId = true; - continue; - } - } - } + if (!RitualRegistry.ritualEnabled(ritual) || !canDivinerPerformRitual(stack, ritual)) + { + continue; + } - if (foundFirst) { - setCurrentRitual(stack, firstId); - notifyRitualChange(firstId, player); - } - } + if (!foundFirst) + { + firstId = str; + foundFirst = true; + } - public boolean canDivinerPerformRitual(ItemStack stack, Ritual ritual) { - return true; - } + if (foundId) + { + setCurrentRitual(stack, str); + notifyRitualChange(str, player); + return; + } else + { + if (str.equals(key)) + { + foundId = true; + continue; + } + } + } - public void notifyRitualChange(String key, EntityPlayer player) { - Ritual ritual = RitualRegistry.getRitualForId(key); - if (ritual != null) { - ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentRitual") + TextHelper.localize(ritual.getUnlocalizedName())); - } - } + if (foundFirst) + { + setCurrentRitual(stack, firstId); + notifyRitualChange(firstId, player); + } + } - public void setCurrentRitual(ItemStack stack, String key) { - if (!stack.hasTagCompound()) { - stack.setTagCompound(new NBTTagCompound()); - } + public boolean canDivinerPerformRitual(ItemStack stack, Ritual ritual) + { + return true; + } - NBTTagCompound tag = stack.getTagCompound(); + public void notifyRitualChange(String key, EntityPlayer player) + { + Ritual ritual = RitualRegistry.getRitualForId(key); + if (ritual != null) + { + ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentRitual") + TextHelper.localize(ritual.getUnlocalizedName())); + } + } - tag.setString(Constants.NBT.CURRENT_RITUAL, key); - } + public void setCurrentRitual(ItemStack stack, String key) + { + if (!stack.hasTagCompound()) + { + stack.setTagCompound(new NBTTagCompound()); + } - public String getCurrentRitual(ItemStack stack) { - if (!stack.hasTagCompound()) { - stack.setTagCompound(new NBTTagCompound()); - } + NBTTagCompound tag = stack.getTagCompound(); - NBTTagCompound tag = stack.getTagCompound(); - return tag.getString(Constants.NBT.CURRENT_RITUAL); - } + tag.setString(Constants.NBT.CURRENT_RITUAL, key); + } - public boolean canPlaceRitualStone(EnumRuneType rune, ItemStack stack) { - int meta = stack.getItemDamage(); - switch (rune) { - case BLANK: - case AIR: - case EARTH: - case FIRE: - case WATER: - return true; - case DUSK: - return meta >= 1; - case DAWN: - return meta >= 2; - } + public String getCurrentRitual(ItemStack stack) + { + if (!stack.hasTagCompound()) + { + stack.setTagCompound(new NBTTagCompound()); + } - return false; - } + NBTTagCompound tag = stack.getTagCompound(); + return tag.getString(Constants.NBT.CURRENT_RITUAL); + } + + public boolean canPlaceRitualStone(EnumRuneType rune, ItemStack stack) + { + int meta = stack.getItemDamage(); + switch (rune) + { + case BLANK: + case AIR: + case EARTH: + case FIRE: + case WATER: + return true; + case DUSK: + return meta >= 1; + case DAWN: + return meta >= 2; + } + + return false; + } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemSacrificialDagger.java b/src/main/java/WayofTime/bloodmagic/item/ItemSacrificialDagger.java index f901a59f..d7bf3dac 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemSacrificialDagger.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemSacrificialDagger.java @@ -29,10 +29,12 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.Arrays; import java.util.List; -public class ItemSacrificialDagger extends Item { - public static String[] names = {"normal", "creative"}; +public class ItemSacrificialDagger extends Item +{ + public static String[] names = { "normal", "creative" }; - public ItemSacrificialDagger() { + public ItemSacrificialDagger() + { super(); setUnlocalizedName(Constants.Mod.MODID + ".sacrificialDagger."); @@ -43,54 +45,64 @@ public class ItemSacrificialDagger extends Item { } @Override - public String getUnlocalizedName(ItemStack stack) { + public String getUnlocalizedName(ItemStack stack) + { return super.getUnlocalizedName(stack) + names[stack.getItemDamage()]; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) { + public void getSubItems(Item id, CreativeTabs creativeTab, List list) + { for (int i = 0; i < names.length; i++) list.add(new ItemStack(id, 1, i)); } @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) + { list.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.BloodMagic.sacrificialDagger.desc")))); } @Override - public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int itemInUseCount) { + public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int itemInUseCount) + { PlayerSacrificeHelper.sacrificePlayerHealth(player); } @Override - public int getMaxItemUseDuration(ItemStack stack) { + public int getMaxItemUseDuration(ItemStack stack) + { return 72000; } @Override - public EnumAction getItemUseAction(ItemStack stack) { + public EnumAction getItemUseAction(ItemStack stack) + { return EnumAction.BOW; } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { if (PlayerHelper.isFakePlayer(player)) return stack; - if (this.canUseForSacrifice(stack)) { + if (this.canUseForSacrifice(stack)) + { player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); return stack; } - if (!player.capabilities.isCreativeMode) { + if (!player.capabilities.isCreativeMode) + { SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(player, true, true, 2); if (MinecraftForge.EVENT_BUS.post(evt)) return stack; - if (evt.shouldDrainHealth) { + if (evt.shouldDrainHealth) + { player.hurtResistantTime = 0; player.attackEntityFrom(BloodMagicAPI.getDamageSource(), 2.0F); } @@ -120,7 +132,8 @@ public class ItemSacrificialDagger extends Item { return stack; } - private void findAndFillAltar(World world, EntityPlayer player, int amount) { + private void findAndFillAltar(World world, EntityPlayer player, int amount) + { BlockPos pos = player.getPosition(); IBloodAltar altarEntity = getAltar(world, pos); @@ -131,16 +144,21 @@ public class ItemSacrificialDagger extends Item { altarEntity.startCycle(); } - public IBloodAltar getAltar(World world, BlockPos pos) { + public IBloodAltar getAltar(World world, BlockPos pos) + { TileEntity tileEntity; - for (int i = -2; i <= 2; i++) { - for (int j = -2; j <= 2; j++) { - for (int k = -2; k <= 1; k++) { + for (int i = -2; i <= 2; i++) + { + for (int j = -2; j <= 2; j++) + { + for (int k = -2; k <= 1; k++) + { BlockPos newPos = pos.add(i, j, k); tileEntity = world.getTileEntity(newPos); - if (tileEntity instanceof IBloodAltar) { + if (tileEntity instanceof IBloodAltar) + { return (IBloodAltar) tileEntity; } } @@ -151,28 +169,33 @@ public class ItemSacrificialDagger extends Item { } @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { + public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) + { if (!world.isRemote && entity instanceof EntityPlayer) this.setUseForSacrifice(stack, this.isPlayerPreparedForSacrifice(world, (EntityPlayer) entity)); } - public boolean isPlayerPreparedForSacrifice(World world, EntityPlayer player) { + public boolean isPlayerPreparedForSacrifice(World world, EntityPlayer player) + { return !world.isRemote && (PlayerSacrificeHelper.getPlayerIncense(player) > 0); } - public boolean canUseForSacrifice(ItemStack stack) { + public boolean canUseForSacrifice(ItemStack stack) + { stack = NBTHelper.checkNBT(stack); return stack.getTagCompound().getBoolean(Constants.NBT.SACRIFICE); } - public void setUseForSacrifice(ItemStack stack, boolean sacrifice) { + public void setUseForSacrifice(ItemStack stack, boolean sacrifice) + { stack = NBTHelper.checkNBT(stack); stack.getTagCompound().setBoolean(Constants.NBT.SACRIFICE, sacrifice); } @Override @SideOnly(Side.CLIENT) - public boolean hasEffect(ItemStack stack) { + public boolean hasEffect(ItemStack stack) + { return this.canUseForSacrifice(stack) || super.hasEffect(stack); } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemSlate.java b/src/main/java/WayofTime/bloodmagic/item/ItemSlate.java index 4478feb1..281dab6e 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemSlate.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemSlate.java @@ -13,11 +13,13 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.Arrays; import java.util.List; -public class ItemSlate extends Item { +public class ItemSlate extends Item +{ public String[] names = { "blank", "reinforced", "imbued", "demonic", "ethereal" }; - public ItemSlate() { + public ItemSlate() + { super(); setCreativeTab(BloodMagic.tabBloodMagic); @@ -27,19 +29,22 @@ public class ItemSlate extends Item { @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) { + public void getSubItems(Item id, CreativeTabs creativeTab, List list) + { for (int i = 0; i < names.length; i++) list.add(new ItemStack(id, 1, i)); } @Override - public String getUnlocalizedName(ItemStack stack) { + public String getUnlocalizedName(ItemStack stack) + { return super.getUnlocalizedName(stack) + names[stack.getItemDamage()]; } @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) + { list.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.BloodMagic.slate.desc")))); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemTelepositionFocus.java b/src/main/java/WayofTime/bloodmagic/item/ItemTelepositionFocus.java index 6254dec7..95356c5c 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemTelepositionFocus.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemTelepositionFocus.java @@ -20,11 +20,13 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.Arrays; import java.util.List; -public class ItemTelepositionFocus extends ItemBindable { +public class ItemTelepositionFocus extends ItemBindable +{ - public static String[] names = {"weak", "enhanced", "reinforced", "demonic"}; + public static String[] names = { "weak", "enhanced", "reinforced", "demonic" }; - public ItemTelepositionFocus() { + public ItemTelepositionFocus() + { super(); setUnlocalizedName(Constants.Mod.MODID + ".focus."); @@ -34,19 +36,22 @@ public class ItemTelepositionFocus extends ItemBindable { } @Override - public String getUnlocalizedName(ItemStack stack) { + public String getUnlocalizedName(ItemStack stack) + { return super.getUnlocalizedName(stack) + names[stack.getItemDamage()]; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) { + public void getSubItems(Item id, CreativeTabs creativeTab, List list) + { for (int i = 0; i < names.length; i++) list.add(new ItemStack(id, 1, i)); } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { if (BindableHelper.checkAndSetItemOwner(stack, player)) if (player.isSneaking()) return stack; @@ -56,7 +61,8 @@ public class ItemTelepositionFocus extends ItemBindable { @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) + { tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localize("tooltip.BloodMagic.telepositionfocus." + names[stack.getItemDamage()])))); super.addInformation(stack, player, tooltip, advanced); @@ -68,17 +74,20 @@ public class ItemTelepositionFocus extends ItemBindable { tooltip.add(String.format(StatCollector.translateToLocal("tooltip.alchemy.dimension"), tag.getInteger(Constants.NBT.DIMENSION_ID))); } - public World getWorld(ItemStack stack) { + public World getWorld(ItemStack stack) + { stack = NBTHelper.checkNBT(stack); return DimensionManager.getWorld(stack.getTagCompound().getInteger(Constants.NBT.DIMENSION_ID)); } - public BlockPos getBlockPos(ItemStack stack) { + public BlockPos getBlockPos(ItemStack stack) + { stack = NBTHelper.checkNBT(stack); return new BlockPos(stack.getTagCompound().getInteger(Constants.NBT.X_COORD), stack.getTagCompound().getInteger(Constants.NBT.Y_COORD), stack.getTagCompound().getInteger(Constants.NBT.Z_COORD)); } - public ItemStack setBlockPos(ItemStack stack, World world, BlockPos pos) { + public ItemStack setBlockPos(ItemStack stack, World world, BlockPos pos) + { NBTTagCompound itemTag = stack.getTagCompound(); itemTag.setInteger(Constants.NBT.X_COORD, pos.getX()); itemTag.setInteger(Constants.NBT.Y_COORD, pos.getY()); diff --git a/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java b/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java index 98ed2e97..80ebfbb9 100644 --- a/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java +++ b/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java @@ -7,11 +7,13 @@ import net.minecraft.entity.Entity; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; -public class ItemLivingArmour extends ItemArmor { +public class ItemLivingArmour extends ItemArmor +{ - public static String[] names = {"helmet", "chest", "legs", "boots"}; + public static String[] names = { "helmet", "chest", "legs", "boots" }; - public ItemLivingArmour(int armorType) { + public ItemLivingArmour(int armorType) + { super(ItemArmor.ArmorMaterial.IRON, 0, armorType); setUnlocalizedName(Constants.Mod.MODID + ".livingArmour."); setMaxDamage(250); @@ -19,22 +21,25 @@ public class ItemLivingArmour extends ItemArmor { } @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { - if (this == ModItems.livingArmourChest - || this == ModItems.livingArmourHelmet - || this == ModItems.livingArmourBoots) { + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) + { + if (this == ModItems.livingArmourChest || this == ModItems.livingArmourHelmet || this == ModItems.livingArmourBoots) + { return "bloodmagic:models/armor/boundArmour_layer_1.png"; } - if (this == ModItems.livingArmourLegs) { + if (this == ModItems.livingArmourLegs) + { return "bloodmagic:models/armor/boundArmour_layer_2.png"; - } else { + } else + { return null; } } @Override - public String getUnlocalizedName(ItemStack stack) { + public String getUnlocalizedName(ItemStack stack) + { return super.getUnlocalizedName(stack) + names[armorType]; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockBloodRune.java b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockBloodRune.java index 949ce9f5..acc3e786 100644 --- a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockBloodRune.java +++ b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockBloodRune.java @@ -5,20 +5,24 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -public class ItemBlockBloodRune extends ItemBlock { +public class ItemBlockBloodRune extends ItemBlock +{ - public ItemBlockBloodRune(Block block) { + public ItemBlockBloodRune(Block block) + { super(block); setHasSubtypes(true); } @Override - public String getUnlocalizedName(ItemStack stack) { + public String getUnlocalizedName(ItemStack stack) + { return super.getUnlocalizedName(stack) + BlockBloodRune.names[stack.getItemDamage()]; } @Override - public int getMetadata(int meta) { + public int getMetadata(int meta) + { return meta; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockBloodStoneBrick.java b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockBloodStoneBrick.java index 019cc333..1110f22c 100644 --- a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockBloodStoneBrick.java +++ b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockBloodStoneBrick.java @@ -5,20 +5,24 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -public class ItemBlockBloodStoneBrick extends ItemBlock { +public class ItemBlockBloodStoneBrick extends ItemBlock +{ - public ItemBlockBloodStoneBrick(Block block) { + public ItemBlockBloodStoneBrick(Block block) + { super(block); setHasSubtypes(true); } @Override - public String getUnlocalizedName(ItemStack stack) { + public String getUnlocalizedName(ItemStack stack) + { return super.getUnlocalizedName(stack) + BlockBloodStoneBrick.names[stack.getItemDamage()]; } @Override - public int getMetadata(int meta) { + public int getMetadata(int meta) + { return meta; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockCrystal.java b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockCrystal.java index 37cbb982..9c551f62 100644 --- a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockCrystal.java @@ -5,20 +5,24 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -public class ItemBlockCrystal extends ItemBlock { +public class ItemBlockCrystal extends ItemBlock +{ - public ItemBlockCrystal(Block block) { + public ItemBlockCrystal(Block block) + { super(block); setHasSubtypes(true); } @Override - public String getUnlocalizedName(ItemStack stack) { + public String getUnlocalizedName(ItemStack stack) + { return super.getUnlocalizedName(stack) + BlockCrystal.names[stack.getItemDamage()]; } @Override - public int getMetadata(int meta) { + public int getMetadata(int meta) + { return meta; } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockPedestal.java b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockPedestal.java index 99cb607b..9ec43862 100644 --- a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockPedestal.java +++ b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockPedestal.java @@ -5,21 +5,25 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -public class ItemBlockPedestal extends ItemBlock { +public class ItemBlockPedestal extends ItemBlock +{ - public ItemBlockPedestal(Block block) { + public ItemBlockPedestal(Block block) + { super(block); setHasSubtypes(true); } @Override - public String getUnlocalizedName(ItemStack stack) { + public String getUnlocalizedName(ItemStack stack) + { return super.getUnlocalizedName(stack) + BlockPedestal.names[stack.getItemDamage()]; } @Override - public int getMetadata(int meta) { + public int getMetadata(int meta) + { return meta; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockRitualController.java b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockRitualController.java index 8d9be4dd..6e3661a3 100644 --- a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockRitualController.java +++ b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockRitualController.java @@ -5,21 +5,25 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -public class ItemBlockRitualController extends ItemBlock { +public class ItemBlockRitualController extends ItemBlock +{ - public ItemBlockRitualController(Block block) { + public ItemBlockRitualController(Block block) + { super(block); setHasSubtypes(true); } @Override - public String getUnlocalizedName(ItemStack stack) { + public String getUnlocalizedName(ItemStack stack) + { return super.getUnlocalizedName(stack) + BlockRitualController.names[stack.getItemDamage()]; } @Override - public int getMetadata(int meta) { + public int getMetadata(int meta) + { return meta; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockRitualStone.java b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockRitualStone.java index c1e76864..e1894f33 100644 --- a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockRitualStone.java @@ -5,20 +5,24 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -public class ItemBlockRitualStone extends ItemBlock { +public class ItemBlockRitualStone extends ItemBlock +{ - public ItemBlockRitualStone(Block block) { + public ItemBlockRitualStone(Block block) + { super(block); setHasSubtypes(true); } @Override - public String getUnlocalizedName(ItemStack stack) { + public String getUnlocalizedName(ItemStack stack) + { return super.getUnlocalizedName(stack) + BlockRitualStone.names[stack.getItemDamage()]; } @Override - public int getMetadata(int meta) { + public int getMetadata(int meta) + { return meta; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSacrifice.java b/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSacrifice.java index 713ac670..e9fbf81e 100644 --- a/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSacrifice.java +++ b/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSacrifice.java @@ -16,12 +16,14 @@ import net.minecraft.world.World; import java.util.List; -public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator { +public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator +{ public final int CONVERSION = 100; // How much LP per heart public final int CAPACITY = 10000; // Max LP storage - public ItemPackSacrifice() { + public ItemPackSacrifice() + { super(ArmorMaterial.CHAIN, 0, 1); setUnlocalizedName(Constants.Mod.MODID + ".pack.sacrifice"); @@ -29,16 +31,20 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator { } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { if (world.isRemote) return stack; MovingObjectPosition position = this.getMovingObjectPositionFromPlayer(world, player, false); - if (position == null) { + if (position == null) + { return super.onItemRightClick(stack, world, player); - } else { - if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + } else + { + if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { TileEntity tile = world.getTileEntity(position.getBlockPos()); if (!(tile instanceof TileAltar)) @@ -46,10 +52,12 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator { TileAltar altar = (TileAltar) tile; - if (!altar.isActive()) { + if (!altar.isActive()) + { int amount = this.getStoredLP(stack); - if (amount > 0) { + if (amount > 0) + { int filledAmount = altar.fillMainTank(amount); amount -= filledAmount; setStoredLP(stack, amount); @@ -63,18 +71,21 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator { } @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) + { return Constants.Mod.DOMAIN + "models/armor/bloodPack_layer_1.png"; } @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) + { stack = NBTHelper.checkNBT(stack); list.add(TextHelper.localize("tooltip.BloodMagic.pack.sacrifice.desc")); list.add(TextHelper.localize("tooltip.BloodMagic.pack.stored", getStoredLP(stack))); } - public void addLP(ItemStack stack, int toAdd) { + public void addLP(ItemStack stack, int toAdd) + { stack = NBTHelper.checkNBT(stack); if (toAdd < 0) @@ -86,12 +97,14 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator { setStoredLP(stack, getStoredLP(stack) + toAdd); } - public void setStoredLP(ItemStack stack, int lp) { + public void setStoredLP(ItemStack stack, int lp) + { stack = NBTHelper.checkNBT(stack); stack.getTagCompound().setInteger(Constants.NBT.STORED_LP, lp); } - public int getStoredLP(ItemStack stack) { + public int getStoredLP(ItemStack stack) + { stack = NBTHelper.checkNBT(stack); return stack.getTagCompound().getInteger(Constants.NBT.STORED_LP); } diff --git a/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSelfSacrifice.java b/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSelfSacrifice.java index 3ce13a99..b0137de8 100644 --- a/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSelfSacrifice.java +++ b/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSelfSacrifice.java @@ -17,14 +17,17 @@ import net.minecraft.world.World; import java.util.List; -public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulator { +public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulator +{ public final int CONVERSION = 100; // How much LP per half heart public final int CAPACITY = 10000; // Max LP storage public final int INTERVAL = 20; // How often the pack syphons - public final float HEALTHREQ = 0.5f; // How much health is required for the pack to syphon (0 - 1) + public final float HEALTHREQ = 0.5f; // How much health is required for the + // pack to syphon (0 - 1) - public ItemPackSelfSacrifice() { + public ItemPackSelfSacrifice() + { super(ArmorMaterial.CHAIN, 0, 1); setUnlocalizedName(Constants.Mod.MODID + ".pack.selfSacrifice"); @@ -32,16 +35,20 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { if (world.isRemote) return stack; MovingObjectPosition position = this.getMovingObjectPositionFromPlayer(world, player, false); - if (position == null) { + if (position == null) + { return super.onItemRightClick(stack, world, player); - } else { - if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + } else + { + if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { TileEntity tile = world.getTileEntity(position.getBlockPos()); if (!(tile instanceof TileAltar)) @@ -49,10 +56,12 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato TileAltar altar = (TileAltar) tile; - if (!altar.isActive()) { + if (!altar.isActive()) + { int amount = this.getStoredLP(stack); - if (amount > 0) { + if (amount > 0) + { int filledAmount = altar.fillMainTank(amount); amount -= filledAmount; setStoredLP(stack, amount); @@ -66,31 +75,36 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato } @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) + { if (world.isRemote || player.capabilities.isCreativeMode) return; boolean shouldSyphon = player.getHealth() / player.getMaxHealth() > HEALTHREQ && getStoredLP(stack) < CAPACITY; - if (shouldSyphon & world.getTotalWorldTime() % INTERVAL == 0) { + if (shouldSyphon & world.getTotalWorldTime() % INTERVAL == 0) + { NetworkHelper.getSoulNetwork(player, world).hurtPlayer(1.0F); addLP(stack, CONVERSION); } } @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) + { return Constants.Mod.DOMAIN + "models/armor/bloodPack_layer_1.png"; } @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) + { stack = NBTHelper.checkNBT(stack); list.add(TextHelper.localize("tooltip.BloodMagic.pack.selfSacrifice.desc")); list.add(TextHelper.localize("tooltip.BloodMagic.pack.stored", getStoredLP(stack))); } - public void addLP(ItemStack stack, int toAdd) { + public void addLP(ItemStack stack, int toAdd) + { stack = NBTHelper.checkNBT(stack); if (toAdd < 0) @@ -102,12 +116,14 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato setStoredLP(stack, getStoredLP(stack) + toAdd); } - public void setStoredLP(ItemStack stack, int lp) { + public void setStoredLP(ItemStack stack, int lp) + { stack = NBTHelper.checkNBT(stack); stack.getTagCompound().setInteger(Constants.NBT.STORED_LP, lp); } - public int getStoredLP(ItemStack stack) { + public int getStoredLP(ItemStack stack) + { stack = NBTHelper.checkNBT(stack); return stack.getTagCompound().getInteger(Constants.NBT.STORED_LP); } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilAir.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilAir.java index b536b22b..f4453d99 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilAir.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilAir.java @@ -5,23 +5,28 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.Vec3; import net.minecraft.world.World; -public class ItemSigilAir extends ItemSigilBase { +public class ItemSigilAir extends ItemSigilBase +{ - public ItemSigilAir() { + public ItemSigilAir() + { super("air", 50); } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (!world.isRemote && !isUnusable(stack)) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { + if (!world.isRemote && !isUnusable(stack)) + { Vec3 vec = player.getLookVec(); double wantedVelocity = 1.7; // TODO - Revisit after potions -// if (player.isPotionActive(ModPotions.customPotionBoost)) { -// int amplifier = player.getActivePotionEffect(ModPotions.customPotionBoost).getAmplifier(); -// wantedVelocity += (1 + amplifier) * (0.35); -// } + // if (player.isPotionActive(ModPotions.customPotionBoost)) { + // int amplifier = + // player.getActivePotionEffect(ModPotions.customPotionBoost).getAmplifier(); + // wantedVelocity += (1 + amplifier) * (0.35); + // } player.motionX = vec.xCoord * wantedVelocity; player.motionY = vec.yCoord * wantedVelocity; diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBase.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBase.java index 3d91bee2..3877c22c 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBase.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBase.java @@ -18,13 +18,15 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; @Getter -public class ItemSigilBase extends ItemBindable implements ISigil { +public class ItemSigilBase extends ItemBindable implements ISigil +{ protected final String tooltipBase; private final String name; private boolean toggleable; - public ItemSigilBase(String name, int lpUsed) { + public ItemSigilBase(String name, int lpUsed) + { super(); setUnlocalizedName(Constants.Mod.MODID + ".sigil." + name); @@ -34,19 +36,22 @@ public class ItemSigilBase extends ItemBindable implements ISigil { this.tooltipBase = "tooltip.BloodMagic.sigil." + name + "."; } - public ItemSigilBase(String name) { + public ItemSigilBase(String name) + { this(name, 0); } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { super.onItemRightClick(stack, world, player); return stack; } @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) + { super.onItemRightClick(stack, world, player); return false; @@ -54,7 +59,8 @@ public class ItemSigilBase extends ItemBindable implements ISigil { @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) + { if (StatCollector.canTranslate(tooltipBase + "desc")) tooltip.add(TextHelper.localizeEffect(tooltipBase + "desc")); @@ -62,28 +68,33 @@ public class ItemSigilBase extends ItemBindable implements ISigil { super.addInformation(stack, player, tooltip, advanced); } - public void setToggleable() { + public void setToggleable() + { this.toggleable = true; } - public boolean isUnusable(ItemStack stack) { + public boolean isUnusable(ItemStack stack) + { NBTHelper.checkNBT(stack); return stack.getTagCompound().getBoolean(Constants.NBT.UNUSABLE); } - public ItemStack setUnusable(ItemStack stack, boolean unusable) { + public ItemStack setUnusable(ItemStack stack, boolean unusable) + { NBTHelper.checkNBT(stack); stack.getTagCompound().setBoolean(Constants.NBT.UNUSABLE, unusable); return stack; } - public boolean getActivated(ItemStack stack) { + public boolean getActivated(ItemStack stack) + { return stack.getItemDamage() > 0; } - public ItemStack setActivated(ItemStack stack, boolean activated) { + public ItemStack setActivated(ItemStack stack, boolean activated) + { if (this.toggleable) stack.setItemDamage(activated ? 1 : 0); diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBloodLight.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBloodLight.java index 56ae2dac..7f82b84a 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBloodLight.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBloodLight.java @@ -10,14 +10,17 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; -public class ItemSigilBloodLight extends ItemSigilBase { +public class ItemSigilBloodLight extends ItemSigilBase +{ - public ItemSigilBloodLight() { + public ItemSigilBloodLight() + { super("bloodLight", 10); } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { if (BindableHelper.checkAndSetItemOwner(stack, player) && ItemBindable.syphonBatteries(stack, player, getLPUsed() * 5) && !world.isRemote) world.spawnEntityInWorld(new EntityBloodLight(world, player)); @@ -25,13 +28,17 @@ public class ItemSigilBloodLight extends ItemSigilBase { } @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) { - if (world.isRemote) return false; + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) + { + if (world.isRemote) + return false; - if (BindableHelper.checkAndSetItemOwner(stack, player) && ItemBindable.syphonBatteries(stack, player, getLPUsed())) { + if (BindableHelper.checkAndSetItemOwner(stack, player) && ItemBindable.syphonBatteries(stack, player, getLPUsed())) + { BlockPos newPos = blockPos.offset(side); - if (world.isAirBlock(newPos)) { + if (world.isAirBlock(newPos)) + { world.setBlockState(newPos, ModBlocks.bloodLight.getDefaultState()); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilCompression.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilCompression.java index 24c960b7..db5ea0bf 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilCompression.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilCompression.java @@ -6,20 +6,24 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public class ItemSigilCompression extends ItemSigilToggleable { +public class ItemSigilCompression extends ItemSigilToggleable +{ - public ItemSigilCompression() { + public ItemSigilCompression() + { super("compression", 200); } - //TODO REWRITE all compression stuff if someone has time - //TODO for now, there is a semi-working system in place + // TODO REWRITE all compression stuff if someone has time + // TODO for now, there is a semi-working system in place @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) + { ItemStack compressedStack = CompressionRegistry.compressInventory(player.inventory.mainInventory, world); - if (compressedStack != null) { + if (compressedStack != null) + { EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, compressedStack); world.spawnEntityInWorld(entityItem); } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java index 95f4d339..5e0c09f4 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java @@ -14,33 +14,41 @@ import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.util.ChatUtil; import WayofTime.bloodmagic.util.helper.TextHelper; -public class ItemSigilDivination extends ItemSigilBase implements IAltarReader { +public class ItemSigilDivination extends ItemSigilBase implements IAltarReader +{ - public ItemSigilDivination() { + public ItemSigilDivination() + { super("divination"); } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { if (PlayerHelper.isFakePlayer(player)) return stack; super.onItemRightClick(stack, world, player); - if (!world.isRemote) { + if (!world.isRemote) + { MovingObjectPosition position = getMovingObjectPositionFromPlayer(world, player, false); int currentEssence = NetworkHelper.getSoulNetwork(BindableHelper.getOwnerUUID(stack), world).getCurrentEssence(); - if (position == null) { + if (position == null) + { ChatUtil.sendNoSpam(player, new ChatComponentText(TextHelper.localize(tooltipBase + "currentEssence", currentEssence))); return stack; - } else { - if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + } else + { + if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { TileEntity tile = world.getTileEntity(position.getBlockPos()); - if (tile != null && tile instanceof IBloodAltar) { + if (tile != null && tile instanceof IBloodAltar) + { IBloodAltar altar = (IBloodAltar) tile; int tier = altar.getTier().ordinal() + 1; currentEssence = altar.getCurrentBlood(); @@ -48,7 +56,8 @@ public class ItemSigilDivination extends ItemSigilBase implements IAltarReader { altar.checkTier(); ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentAltarTier", tier), TextHelper.localize(tooltipBase + "currentEssence", currentEssence), TextHelper.localize(tooltipBase + "currentAltarCapacity", capacity)); - } else { + } else + { ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentEssence", currentEssence)); } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilElementalAffinity.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilElementalAffinity.java index 0e169be7..7a8ed872 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilElementalAffinity.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilElementalAffinity.java @@ -6,14 +6,17 @@ import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; -public class ItemSigilElementalAffinity extends ItemSigilToggleable { +public class ItemSigilElementalAffinity extends ItemSigilToggleable +{ - public ItemSigilElementalAffinity() { + public ItemSigilElementalAffinity() + { super("elementalAffinity", 200); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) + { player.fallDistance = 0; player.extinguish(); player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 2, 1, true, false)); diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilEnderSeverance.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilEnderSeverance.java index f2c8efbe..1bc55b72 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilEnderSeverance.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilEnderSeverance.java @@ -11,16 +11,20 @@ import net.minecraft.world.World; import java.util.List; -public class ItemSigilEnderSeverance extends ItemSigilToggleable { +public class ItemSigilEnderSeverance extends ItemSigilToggleable +{ - public ItemSigilEnderSeverance() { + public ItemSigilEnderSeverance() + { super("enderSeverance", 200); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) + { List entityList = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(player.posX - 4.5, player.posY - 4.5, player.posZ - 4.5, player.posX + 4.5, player.posY + 4.5, player.posZ + 4.5)); - for (Entity entity : entityList) { + for (Entity entity : entityList) + { if (entity instanceof EntityEnderman) ((EntityEnderman) entity).addPotionEffect(new PotionEffect(ModPotions.planarBinding.id, 40, 0)); } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilFastMiner.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilFastMiner.java index e0adcf09..e2f3d968 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilFastMiner.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilFastMiner.java @@ -6,14 +6,17 @@ import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; -public class ItemSigilFastMiner extends ItemSigilToggleable { +public class ItemSigilFastMiner extends ItemSigilToggleable +{ - public ItemSigilFastMiner() { + public ItemSigilFastMiner() + { super("fastMiner", 100); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) + { player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 2, 0, true, false)); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilGreenGrove.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilGreenGrove.java index e6038266..b8d682d1 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilGreenGrove.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilGreenGrove.java @@ -10,15 +10,19 @@ import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import net.minecraftforge.common.IPlantable; -public class ItemSigilGreenGrove extends ItemSigilToggleable { +public class ItemSigilGreenGrove extends ItemSigilToggleable +{ - public ItemSigilGreenGrove() { + public ItemSigilGreenGrove() + { super("greenGrove", 150); } @Override - public boolean onSigilUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) { - if (applyBonemeal(stack, world, blockPos)) { + public boolean onSigilUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) + { + if (applyBonemeal(stack, world, blockPos)) + { world.playAuxSFX(2005, blockPos, 0); return true; } @@ -27,21 +31,27 @@ public class ItemSigilGreenGrove extends ItemSigilToggleable { } @Override - public void onSigilUpdate(ItemStack stack, World worldIn, EntityPlayer player, int itemSlot, boolean isSelected) { + public void onSigilUpdate(ItemStack stack, World worldIn, EntityPlayer player, int itemSlot, boolean isSelected) + { int range = 3; int verticalRange = 2; int posX = (int) Math.round(player.posX - 0.5f); int posY = (int) player.posY; int posZ = (int) Math.round(player.posZ - 0.5f); - for (int ix = posX - range; ix <= posX + range; ix++) { - for (int iz = posZ - range; iz <= posZ + range; iz++) { - for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++) { + for (int ix = posX - range; ix <= posX + range; ix++) + { + for (int iz = posZ - range; iz <= posZ + range; iz++) + { + for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++) + { BlockPos blockPos = new BlockPos(ix, iy, iz); Block block = worldIn.getBlockState(blockPos).getBlock(); - if (block instanceof IPlantable || block instanceof IGrowable) { - if (worldIn.rand.nextInt(50) == 0) { + if (block instanceof IPlantable || block instanceof IGrowable) + { + if (worldIn.rand.nextInt(50) == 0) + { IBlockState preBlockState = worldIn.getBlockState(blockPos); block.updateTick(worldIn, blockPos, worldIn.getBlockState(blockPos), worldIn.rand); @@ -54,21 +64,27 @@ public class ItemSigilGreenGrove extends ItemSigilToggleable { } } - private boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target) { + private boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target) + { return worldIn instanceof net.minecraft.world.WorldServer && applyBonemeal(stack, worldIn, target, net.minecraftforge.common.util.FakePlayerFactory.getMinecraft((net.minecraft.world.WorldServer) worldIn)); } - private boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target, EntityPlayer player) { + private boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target, EntityPlayer player) + { IBlockState iblockstate = worldIn.getBlockState(target); int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, worldIn, target, iblockstate, stack); - if (hook != 0) return hook > 0; + if (hook != 0) + return hook > 0; - if (iblockstate.getBlock() instanceof IGrowable) { + if (iblockstate.getBlock() instanceof IGrowable) + { IGrowable igrowable = (IGrowable) iblockstate.getBlock(); - if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote)) { - if (!worldIn.isRemote) { + if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote)) + { + if (!worldIn.isRemote) + { if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate)) igrowable.grow(worldIn, worldIn.rand, target, iblockstate); } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilHaste.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilHaste.java index 3c14c453..e98531be 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilHaste.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilHaste.java @@ -6,14 +6,17 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; -public class ItemSigilHaste extends ItemSigilToggleable { +public class ItemSigilHaste extends ItemSigilToggleable +{ - public ItemSigilHaste() { + public ItemSigilHaste() + { super("haste", 250); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) + { player.addPotionEffect(new PotionEffect(ModPotions.boost.id, 2, 0, true, false)); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilLava.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilLava.java index 4069dedc..0fcfcd63 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilLava.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilLava.java @@ -14,40 +14,50 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; -public class ItemSigilLava extends ItemSigilBase { +public class ItemSigilLava extends ItemSigilBase +{ - public ItemSigilLava() { + public ItemSigilLava() + { super("lava", 1000); } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (!world.isRemote && !isUnusable(stack)) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { + if (!world.isRemote && !isUnusable(stack)) + { MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, false); - if (movingobjectposition != null) { + if (movingobjectposition != null) + { ItemStack ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(player, world, stack, movingobjectposition); - if (ret != null) return ret; + if (ret != null) + return ret; - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { BlockPos blockpos = movingobjectposition.getBlockPos(); - if (!world.isBlockModifiable(player, blockpos)) { + if (!world.isBlockModifiable(player, blockpos)) + { return stack; } - if (!player.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, stack)) { + if (!player.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, stack)) + { return stack; } - BlockPos blockpos1 = blockpos.offset(movingobjectposition.sideHit); - if (!player.canPlayerEdit(blockpos1, movingobjectposition.sideHit, stack)) { + if (!player.canPlayerEdit(blockpos1, movingobjectposition.sideHit, stack)) + { return stack; } - if (this.canPlaceLava(world, blockpos1) && syphonBatteries(stack, player, getLPUsed()) && this.tryPlaceLava(world, blockpos1)) { + if (this.canPlaceLava(world, blockpos1) && syphonBatteries(stack, player, getLPUsed()) && this.tryPlaceLava(world, blockpos1)) + { return stack; } } @@ -61,54 +71,66 @@ public class ItemSigilLava extends ItemSigilBase { } @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) { - if (world.isRemote || !BindableHelper.checkAndSetItemOwner(stack, player) || player.isSneaking() || isUnusable(stack)) { + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) + { + if (world.isRemote || !BindableHelper.checkAndSetItemOwner(stack, player) || player.isSneaking() || isUnusable(stack)) + { return false; } - if (!world.canMineBlockBody(player, blockPos)) { + if (!world.canMineBlockBody(player, blockPos)) + { return false; } TileEntity tile = world.getTileEntity(blockPos); - if (tile instanceof IFluidHandler) { + if (tile instanceof IFluidHandler) + { FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000); int amount = ((IFluidHandler) tile).fill(side, fluid, false); - if (amount > 0 && syphonBatteries(stack, player, getLPUsed())) { + if (amount > 0 && syphonBatteries(stack, player, getLPUsed())) + { ((IFluidHandler) tile).fill(side, fluid, true); } return false; } -// else if (tile instanceof TESocket) { -// return false; -// } + // else if (tile instanceof TESocket) { + // return false; + // } BlockPos newPos = blockPos.offset(side); - if (!player.canPlayerEdit(newPos, side, stack)) { + if (!player.canPlayerEdit(newPos, side, stack)) + { return false; } - if (this.canPlaceLava(world, newPos) && syphonBatteries(stack, player, getLPUsed())) { + if (this.canPlaceLava(world, newPos) && syphonBatteries(stack, player, getLPUsed())) + { return this.tryPlaceLava(world, newPos); } return false; } - public boolean canPlaceLava(World world, BlockPos blockPos) { - if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock().getMaterial().isSolid()) { + public boolean canPlaceLava(World world, BlockPos blockPos) + { + if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock().getMaterial().isSolid()) + { return false; - } else if ((world.getBlockState(blockPos).getBlock() == Blocks.lava || world.getBlockState(blockPos).getBlock() == Blocks.flowing_lava) && world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)) == 0) { + } else if ((world.getBlockState(blockPos).getBlock() == Blocks.lava || world.getBlockState(blockPos).getBlock() == Blocks.flowing_lava) && world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)) == 0) + { return false; - } else { + } else + { world.setBlockState(blockPos, Blocks.lava.getBlockState().getBaseState(), 3); return true; } } - public boolean tryPlaceLava(World worldIn, BlockPos pos) { + public boolean tryPlaceLava(World worldIn, BlockPos pos) + { Material material = worldIn.getBlockState(pos).getBlock().getMaterial(); return worldIn.isAirBlock(pos) && !material.isSolid(); diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilMagnetism.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilMagnetism.java index fcd43e06..2f0271b9 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilMagnetism.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilMagnetism.java @@ -9,14 +9,17 @@ import net.minecraft.world.World; import java.util.List; -public class ItemSigilMagnetism extends ItemSigilToggleable { +public class ItemSigilMagnetism extends ItemSigilToggleable +{ - public ItemSigilMagnetism() { + public ItemSigilMagnetism() + { super("magnetism", 50); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) + { int range = 5; int verticalRange = 5; float posX = Math.round(player.posX); @@ -25,14 +28,18 @@ public class ItemSigilMagnetism extends ItemSigilToggleable { List entities = player.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.fromBounds(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range)); List xpOrbs = player.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, AxisAlignedBB.fromBounds(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range)); - for (EntityItem entity : entities) { - if (entity != null && !world.isRemote) { + for (EntityItem entity : entities) + { + if (entity != null && !world.isRemote) + { entity.onCollideWithPlayer(player); } } - for (EntityXPOrb xpOrb : xpOrbs) { - if (xpOrb != null && !world.isRemote) { + for (EntityXPOrb xpOrb : xpOrbs) + { + if (xpOrb != null && !world.isRemote) + { xpOrb.onCollideWithPlayer(player); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilPhantomBridge.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilPhantomBridge.java index fe27bba8..e785badf 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilPhantomBridge.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilPhantomBridge.java @@ -9,14 +9,17 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.world.World; -public class ItemSigilPhantomBridge extends ItemSigilToggleable { +public class ItemSigilPhantomBridge extends ItemSigilToggleable +{ - public ItemSigilPhantomBridge() { + public ItemSigilPhantomBridge() + { super("phantomBridge", 100); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) + { if (!player.onGround && !player.isSneaking()) return; @@ -33,21 +36,27 @@ public class ItemSigilPhantomBridge extends ItemSigilToggleable { int posY = (int) player.posY; int posZ = (int) Math.round(player.posZ - 0.5f); - for (int ix = posX - range; ix <= posX + range; ix++) { - for (int iz = posZ - range; iz <= posZ + range; iz++) { + for (int ix = posX - range; ix <= posX + range; ix++) + { + for (int iz = posZ - range; iz <= posZ + range; iz++) + { BlockPos blockPos = new BlockPos(ix, posY + verticalOffset, iz); Block block = world.getBlockState(blockPos).getBlock(); - if (world.isAirBlock(blockPos)) { + if (world.isAirBlock(blockPos)) + { world.setBlockState(blockPos, ModBlocks.phantomBlock.getDefaultState(), 3); TileEntity tile = world.getTileEntity(blockPos); - if (tile instanceof TilePhantomBlock) { + if (tile instanceof TilePhantomBlock) + { ((TilePhantomBlock) tile).setDuration(100); } - } else if (block == ModBlocks.phantomBlock) { + } else if (block == ModBlocks.phantomBlock) + { TileEntity tile = world.getTileEntity(blockPos); - if (tile instanceof TilePhantomBlock) { + if (tile instanceof TilePhantomBlock) + { ((TilePhantomBlock) tile).setDuration(100); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSeer.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSeer.java index 77908d7d..b544dcd1 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSeer.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSeer.java @@ -15,50 +15,61 @@ import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.util.ChatUtil; import WayofTime.bloodmagic.util.helper.TextHelper; -public class ItemSigilSeer extends ItemSigilBase implements IAltarReader { +public class ItemSigilSeer extends ItemSigilBase implements IAltarReader +{ - public ItemSigilSeer() { + public ItemSigilSeer() + { super("seer"); } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { if (PlayerHelper.isFakePlayer(player)) return stack; super.onItemRightClick(stack, world, player); - if (!world.isRemote) { + if (!world.isRemote) + { MovingObjectPosition position = getMovingObjectPositionFromPlayer(world, player, false); int currentEssence = NetworkHelper.getSoulNetwork(BindableHelper.getOwnerUUID(stack), world).getCurrentEssence(); - if (position == null) { + if (position == null) + { ChatUtil.sendNoSpam(player, new ChatComponentText(TextHelper.localize(tooltipBase + "currentEssence", currentEssence))); return stack; - } else { - if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + } else + { + if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { TileEntity tile = world.getTileEntity(position.getBlockPos()); - if (tile != null && tile instanceof IBloodAltar) { + if (tile != null && tile instanceof IBloodAltar) + { IBloodAltar altar = (IBloodAltar) tile; int tier = altar.getTier().ordinal() + 1; currentEssence = altar.getCurrentBlood(); int capacity = altar.getCapacity(); altar.checkTier(); - if (tile instanceof IInventory) { - if (((IInventory) tile).getStackInSlot(0) != null) { + if (tile instanceof IInventory) + { + if (((IInventory) tile).getStackInSlot(0) != null) + { int progress = altar.getProgress(); int totalLiquidRequired = altar.getLiquidRequired() * ((IInventory) tile).getStackInSlot(0).stackSize; int consumptionRate = (int) (altar.getConsumptionRate() * (altar.getConsumptionMultiplier() + 1)); ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentAltarProgress", progress, totalLiquidRequired), TextHelper.localize(tooltipBase + "currentAltarConsumptionRate", consumptionRate), TextHelper.localize(tooltipBase + "currentAltarTier", tier), TextHelper.localize(tooltipBase + "currentEssence", currentEssence), TextHelper.localize(tooltipBase + "currentAltarCapacity", capacity)); - } - else { + } else + { ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentAltarTier", tier), TextHelper.localize(tooltipBase + "currentEssence", currentEssence), TextHelper.localize(tooltipBase + "currentAltarCapacity", capacity)); } } - } else { + } else + { ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentEssence", currentEssence)); } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSuppression.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSuppression.java index 9432a8c1..e03929af 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSuppression.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSuppression.java @@ -9,24 +9,31 @@ import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fluids.IFluidBlock; -public class ItemSigilSuppression extends ItemSigilToggleable { +public class ItemSigilSuppression extends ItemSigilToggleable +{ - public ItemSigilSuppression() { + public ItemSigilSuppression() + { super("suppression", 400); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) + { int x = (int) player.posX; int y = (int) player.posY; int z = (int) player.posZ; final int radius = 5; final int refresh = 100; - for (int i = -radius; i <= radius; i++) { - for (int j = -radius; j <= radius; j++) { - for (int k = -radius; k <= radius; k++) { - if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f)) { + for (int i = -radius; i <= radius; i++) + { + for (int j = -radius; j <= radius; j++) + { + for (int k = -radius; k <= radius; k++) + { + if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f)) + { continue; } @@ -35,7 +42,8 @@ public class ItemSigilSuppression extends ItemSigilToggleable { if (isBlockLiquid(block) && world.getTileEntity(blockPos) == null) TileSpectralBlock.createSpectralBlock(world, blockPos, refresh); - else { + else + { TileEntity tile = world.getTileEntity(blockPos); if (tile instanceof TileSpectralBlock) ((TileSpectralBlock) tile).resetDuration(refresh); @@ -45,7 +53,8 @@ public class ItemSigilSuppression extends ItemSigilToggleable { } } - private boolean isBlockLiquid(Block block) { + private boolean isBlockLiquid(Block block) + { return (block instanceof IFluidBlock || block.getMaterial().isLiquid()); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilToggleable.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilToggleable.java index d44efb9e..4381af7b 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilToggleable.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilToggleable.java @@ -15,16 +15,19 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class ItemSigilToggleable extends ItemSigilBase { +public class ItemSigilToggleable extends ItemSigilBase +{ - public ItemSigilToggleable(String name, int lpUsed) { + public ItemSigilToggleable(String name, int lpUsed) + { super(name, lpUsed); setToggleable(); } @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) + { super.addInformation(stack, player, tooltip, advanced); if (getActivated(stack)) tooltip.add(TextHelper.localize("tooltip.BloodMagic.activated")); @@ -33,8 +36,10 @@ public class ItemSigilToggleable extends ItemSigilBase { } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (!world.isRemote && !isUnusable(stack)) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { + if (!world.isRemote && !isUnusable(stack)) + { if (player.isSneaking()) setActivated(stack, !getActivated(stack)); if (getActivated(stack) && ItemBindable.syphonBatteries(stack, player, getLPUsed())) @@ -45,22 +50,28 @@ public class ItemSigilToggleable extends ItemSigilBase { } @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) + { if (BindableHelper.checkAndSetItemOwner(stack, player) && ItemBindable.syphonBatteries(stack, player, getLPUsed())) return onSigilUseFirst(stack, player, world, blockPos, side, hitX, hitY, hitZ); return false; } - public boolean onSigilUseFirst(ItemStack itemStack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onSigilUseFirst(ItemStack itemStack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) + { return false; } @Override - public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { - if (!worldIn.isRemote && entityIn instanceof EntityPlayerMP && getActivated(stack)) { - if (worldIn.getWorldTime() % 100 == 0) { - if (!ItemBindable.syphonBatteries(stack, (EntityPlayer) entityIn, getLPUsed())) { + public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) + { + if (!worldIn.isRemote && entityIn instanceof EntityPlayerMP && getActivated(stack)) + { + if (worldIn.getWorldTime() % 100 == 0) + { + if (!ItemBindable.syphonBatteries(stack, (EntityPlayer) entityIn, getLPUsed())) + { setActivated(stack, false); } } @@ -69,5 +80,7 @@ public class ItemSigilToggleable extends ItemSigilBase { } } - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {} + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) + { + } } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilVoid.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilVoid.java index 02565a1e..2a0905b1 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilVoid.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilVoid.java @@ -12,42 +12,54 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidHandler; -public class ItemSigilVoid extends ItemSigilBase { +public class ItemSigilVoid extends ItemSigilBase +{ - public ItemSigilVoid() { + public ItemSigilVoid() + { super("void", 50); } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (!world.isRemote && !isUnusable(stack)) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { + if (!world.isRemote && !isUnusable(stack)) + { MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, true); - if (movingobjectposition != null) { + if (movingobjectposition != null) + { ItemStack ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(player, world, stack, movingobjectposition); - if (ret != null) return ret; + if (ret != null) + return ret; - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { BlockPos blockpos = movingobjectposition.getBlockPos(); - if (!world.isBlockModifiable(player, blockpos)) { + if (!world.isBlockModifiable(player, blockpos)) + { return stack; } - if (!player.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, stack)) { + if (!player.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, stack)) + { return stack; } - if (!player.canPlayerEdit(blockpos, movingobjectposition.sideHit, stack)) { + if (!player.canPlayerEdit(blockpos, movingobjectposition.sideHit, stack)) + { return stack; } - if (world.getBlockState(blockpos).getBlock().getMaterial().isLiquid() && syphonBatteries(stack, player, getLPUsed())) { + if (world.getBlockState(blockpos).getBlock().getMaterial().isLiquid() && syphonBatteries(stack, player, getLPUsed())) + { world.setBlockToAir(blockpos); return stack; } } - } else { + } else + { return stack; } @@ -59,20 +71,25 @@ public class ItemSigilVoid extends ItemSigilBase { } @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) { - if (world.isRemote || !BindableHelper.checkAndSetItemOwner(stack, player) || player.isSneaking() || isUnusable(stack)) { + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) + { + if (world.isRemote || !BindableHelper.checkAndSetItemOwner(stack, player) || player.isSneaking() || isUnusable(stack)) + { return false; } - if (!world.canMineBlockBody(player, blockPos)) { + if (!world.canMineBlockBody(player, blockPos)) + { return false; } TileEntity tile = world.getTileEntity(blockPos); - if (tile instanceof IFluidHandler) { + if (tile instanceof IFluidHandler) + { FluidStack amount = ((IFluidHandler) tile).drain(side, 1000, false); - if (amount != null && amount.amount > 0 && syphonBatteries(stack, player, getLPUsed())) { + if (amount != null && amount.amount > 0 && syphonBatteries(stack, player, getLPUsed())) + { ((IFluidHandler) tile).drain(side, 1000, true); return true; } @@ -82,11 +99,13 @@ public class ItemSigilVoid extends ItemSigilBase { BlockPos newPos = blockPos.offset(side); - if (!player.canPlayerEdit(newPos, side, stack)) { + if (!player.canPlayerEdit(newPos, side, stack)) + { return false; } - if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && syphonBatteries(stack, player, getLPUsed())) { + if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && syphonBatteries(stack, player, getLPUsed())) + { world.setBlockToAir(newPos); return true; } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWater.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWater.java index b53086f1..999bd345 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWater.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWater.java @@ -15,39 +15,50 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; -public class ItemSigilWater extends ItemSigilBase { +public class ItemSigilWater extends ItemSigilBase +{ - public ItemSigilWater() { + public ItemSigilWater() + { super("water", 100); } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (!world.isRemote && !isUnusable(stack)) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { + if (!world.isRemote && !isUnusable(stack)) + { MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, false); - if (movingobjectposition != null) { + if (movingobjectposition != null) + { ItemStack ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(player, world, stack, movingobjectposition); - if (ret != null) return ret; + if (ret != null) + return ret; - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { BlockPos blockpos = movingobjectposition.getBlockPos(); - if (!world.isBlockModifiable(player, blockpos)) { + if (!world.isBlockModifiable(player, blockpos)) + { return stack; } - if (!player.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, stack)) { + if (!player.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, stack)) + { return stack; } BlockPos blockpos1 = blockpos.offset(movingobjectposition.sideHit); - if (!player.canPlayerEdit(blockpos1, movingobjectposition.sideHit, stack)) { + if (!player.canPlayerEdit(blockpos1, movingobjectposition.sideHit, stack)) + { return stack; } - if (this.canPlaceWater(world, blockpos1) && syphonBatteries(stack, player, getLPUsed()) && this.tryPlaceWater(world, blockpos1)) { + if (this.canPlaceWater(world, blockpos1) && syphonBatteries(stack, player, getLPUsed()) && this.tryPlaceWater(world, blockpos1)) + { return stack; } } @@ -61,72 +72,90 @@ public class ItemSigilWater extends ItemSigilBase { } @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) { - if (world.isRemote || !BindableHelper.checkAndSetItemOwner(stack, player) || player.isSneaking() || isUnusable(stack)) { + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) + { + if (world.isRemote || !BindableHelper.checkAndSetItemOwner(stack, player) || player.isSneaking() || isUnusable(stack)) + { return false; } - if (!world.canMineBlockBody(player, blockPos)) { + if (!world.canMineBlockBody(player, blockPos)) + { return false; } TileEntity tile = world.getTileEntity(blockPos); - if (tile instanceof IFluidHandler) { + if (tile instanceof IFluidHandler) + { FluidStack fluid = new FluidStack(FluidRegistry.WATER, 1000); int amount = ((IFluidHandler) tile).fill(side, fluid, false); - if (amount > 0 && syphonBatteries(stack, player, getLPUsed())) { + if (amount > 0 && syphonBatteries(stack, player, getLPUsed())) + { ((IFluidHandler) tile).fill(side, fluid, true); } return false; } -// else if (tile instanceof TESocket) { -// return false; -// } + // else if (tile instanceof TESocket) { + // return false; + // } BlockPos newPos = blockPos.offset(side); - if (!player.canPlayerEdit(newPos, side, stack)) { + if (!player.canPlayerEdit(newPos, side, stack)) + { return false; } - if (this.canPlaceWater(world, newPos) && syphonBatteries(stack, player, getLPUsed())) { + if (this.canPlaceWater(world, newPos) && syphonBatteries(stack, player, getLPUsed())) + { return this.tryPlaceWater(world, newPos); } return false; } - public boolean canPlaceWater(World world, BlockPos blockPos) { - if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock().getMaterial().isSolid()) { + public boolean canPlaceWater(World world, BlockPos blockPos) + { + if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock().getMaterial().isSolid()) + { return false; - } else if ((world.getBlockState(blockPos).getBlock() == Blocks.water || world.getBlockState(blockPos).getBlock() == Blocks.flowing_water) && world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)) == 0) { + } else if ((world.getBlockState(blockPos).getBlock() == Blocks.water || world.getBlockState(blockPos).getBlock() == Blocks.flowing_water) && world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)) == 0) + { return false; - } else { + } else + { return true; } } - public boolean tryPlaceWater(World worldIn, BlockPos pos) { + public boolean tryPlaceWater(World worldIn, BlockPos pos) + { Material material = worldIn.getBlockState(pos).getBlock().getMaterial(); boolean flag = !material.isSolid(); - if (!worldIn.isAirBlock(pos) && !flag) { + if (!worldIn.isAirBlock(pos) && !flag) + { return false; - } else { - if (worldIn.provider.doesWaterVaporize()) { + } else + { + if (worldIn.provider.doesWaterVaporize()) + { int i = pos.getX(); int j = pos.getY(); int k = pos.getZ(); worldIn.playSoundEffect((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), "random.fizz", 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F); - for (int l = 0; l < 8; ++l) { + for (int l = 0; l < 8; ++l) + { worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D, 0); } - } else { - if (!worldIn.isRemote && flag && !material.isLiquid()) { + } else + { + if (!worldIn.isRemote && flag && !material.isLiquid()) + { worldIn.destroyBlock(pos, true); } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWhirlwind.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWhirlwind.java index 90f92310..e7ed3de1 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWhirlwind.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWhirlwind.java @@ -6,14 +6,17 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; -public class ItemSigilWhirlwind extends ItemSigilToggleable { +public class ItemSigilWhirlwind extends ItemSigilToggleable +{ - public ItemSigilWhirlwind() { + public ItemSigilWhirlwind() + { super("whirlwind", 250); } @Override - public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) { + public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) + { player.addPotionEffect(new PotionEffect(ModPotions.whirlwind.id, 2, 0, true, false)); } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java b/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java index c594fff9..84c348f1 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/LivingArmour.java @@ -12,122 +12,144 @@ import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.StatTracker; -public class LivingArmour { +public class LivingArmour +{ - public HashMap trackerMap = new HashMap(); - public HashMap upgradeMap = new HashMap(); + public HashMap trackerMap = new HashMap(); + public HashMap upgradeMap = new HashMap(); - /** - * Ticks the upgrades and stat trackers, passing in the world and player as - * well as the LivingArmour - * - * @param world - * @param player - */ - public void onTick(World world, EntityPlayer player) { - for (Entry entry : upgradeMap.entrySet()) { - LivingArmourUpgrade upgrade = entry.getValue(); + /** + * Ticks the upgrades and stat trackers, passing in the world and player as + * well as the LivingArmour + * + * @param world + * @param player + */ + public void onTick(World world, EntityPlayer player) + { + for (Entry entry : upgradeMap.entrySet()) + { + LivingArmourUpgrade upgrade = entry.getValue(); - if (upgrade == null) { - continue; - } + if (upgrade == null) + { + continue; + } - upgrade.onTick(world, player, this); - } + upgrade.onTick(world, player, this); + } - for (Entry entry : trackerMap.entrySet()) { - StatTracker tracker = entry.getValue(); + for (Entry entry : trackerMap.entrySet()) + { + StatTracker tracker = entry.getValue(); - if (tracker == null) { - continue; - } + if (tracker == null) + { + continue; + } - tracker.onTick(world, player, this); //TODO: Check if the upgrades need to be updated. - } - } + tracker.onTick(world, player, this); // TODO: Check if the upgrades + // need to be updated. + } + } - public void readFromNBT(NBTTagCompound tag) { - NBTTagList upgradeTags = tag.getTagList("upgrades", 10); - if (upgradeTags != null) { - for (int i = 0; i < upgradeTags.tagCount(); i++) { - NBTTagCompound upgradeTag = upgradeTags.getCompoundTagAt(i); - String key = upgradeTag.getString("key"); - int level = upgradeTag.getInteger("level"); - NBTTagCompound nbtTag = upgradeTag.getCompoundTag("upgrade"); - LivingArmourHandler.generateUpgradeFromKey(key, level, nbtTag); - } - } + public void readFromNBT(NBTTagCompound tag) + { + NBTTagList upgradeTags = tag.getTagList("upgrades", 10); + if (upgradeTags != null) + { + for (int i = 0; i < upgradeTags.tagCount(); i++) + { + NBTTagCompound upgradeTag = upgradeTags.getCompoundTagAt(i); + String key = upgradeTag.getString("key"); + int level = upgradeTag.getInteger("level"); + NBTTagCompound nbtTag = upgradeTag.getCompoundTag("upgrade"); + LivingArmourHandler.generateUpgradeFromKey(key, level, nbtTag); + } + } - for (Class clazz : LivingArmourHandler.trackers) { - try { - Constructor ctor = clazz.getConstructor(); - Object obj = ctor.newInstance(); - if (!(obj instanceof StatTracker)) { - // ????? - } - StatTracker tracker = (StatTracker) obj; - String key = tracker.getUniqueIdentifier(); - NBTTagCompound trackerTag = tag.getCompoundTag(key); - if (!trackerTag.hasNoTags()) { - tracker.readFromNBT(trackerTag); - } - trackerMap.put(key, tracker); - } catch (Exception e) { - e.printStackTrace(); - } - } - } + for (Class clazz : LivingArmourHandler.trackers) + { + try + { + Constructor ctor = clazz.getConstructor(); + Object obj = ctor.newInstance(); + if (!(obj instanceof StatTracker)) + { + // ????? + } + StatTracker tracker = (StatTracker) obj; + String key = tracker.getUniqueIdentifier(); + NBTTagCompound trackerTag = tag.getCompoundTag(key); + if (!trackerTag.hasNoTags()) + { + tracker.readFromNBT(trackerTag); + } + trackerMap.put(key, tracker); + } catch (Exception e) + { + e.printStackTrace(); + } + } + } - public void writeToNBT(NBTTagCompound tag, boolean forceWrite) { - NBTTagList tags = new NBTTagList(); + public void writeToNBT(NBTTagCompound tag, boolean forceWrite) + { + NBTTagList tags = new NBTTagList(); - for (Entry entry : upgradeMap.entrySet()) { - NBTTagCompound upgradeTag = new NBTTagCompound(); + for (Entry entry : upgradeMap.entrySet()) + { + NBTTagCompound upgradeTag = new NBTTagCompound(); - LivingArmourUpgrade upgrade = entry.getValue(); - NBTTagCompound nbtTag = new NBTTagCompound(); - upgrade.writeToNBT(nbtTag); + LivingArmourUpgrade upgrade = entry.getValue(); + NBTTagCompound nbtTag = new NBTTagCompound(); + upgrade.writeToNBT(nbtTag); - upgradeTag.setString("key", upgrade.getUniqueIdentifier()); - upgradeTag.setInteger("level", upgrade.getUpgradeLevel()); - upgradeTag.setTag("upgrade", nbtTag); + upgradeTag.setString("key", upgrade.getUniqueIdentifier()); + upgradeTag.setInteger("level", upgrade.getUpgradeLevel()); + upgradeTag.setTag("upgrade", nbtTag); - tags.appendTag(upgradeTag); - } + tags.appendTag(upgradeTag); + } - tag.setTag("upgrades", tags); + tag.setTag("upgrades", tags); - for (Entry entry : trackerMap.entrySet()) { - StatTracker tracker = entry.getValue(); + for (Entry entry : trackerMap.entrySet()) + { + StatTracker tracker = entry.getValue(); - if (tracker == null) { - continue; - } + if (tracker == null) + { + continue; + } - String key = tracker.getUniqueIdentifier(); + String key = tracker.getUniqueIdentifier(); - if (forceWrite || tracker.isDirty()) { - NBTTagCompound trackerTag = new NBTTagCompound(); - tracker.writeToNBT(trackerTag); + if (forceWrite || tracker.isDirty()) + { + NBTTagCompound trackerTag = new NBTTagCompound(); + tracker.writeToNBT(trackerTag); - tag.setTag(key, trackerTag); + tag.setTag(key, trackerTag); - tracker.resetDirty(); - } - } - } + tracker.resetDirty(); + } + } + } - /** - * Writes the LivingArmour to the NBTTag. This will only write the trackers - * that are dirty. - * - * @param tag - */ - public void writeDirtyToNBT(NBTTagCompound tag) { - writeToNBT(tag, false); - } + /** + * Writes the LivingArmour to the NBTTag. This will only write the trackers + * that are dirty. + * + * @param tag + */ + public void writeDirtyToNBT(NBTTagCompound tag) + { + writeToNBT(tag, false); + } - public void writeToNBT(NBTTagCompound tag) { - writeToNBT(tag, true); - } + public void writeToNBT(NBTTagCompound tag) + { + writeToNBT(tag, true); + } } diff --git a/src/main/java/WayofTime/bloodmagic/network/BloodMagicPacketHandler.java b/src/main/java/WayofTime/bloodmagic/network/BloodMagicPacketHandler.java index c7117c6d..085152bf 100644 --- a/src/main/java/WayofTime/bloodmagic/network/BloodMagicPacketHandler.java +++ b/src/main/java/WayofTime/bloodmagic/network/BloodMagicPacketHandler.java @@ -9,23 +9,28 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.relauncher.Side; -public class BloodMagicPacketHandler { +public class BloodMagicPacketHandler +{ public static final SimpleNetworkWrapper INSTANCE = new SimpleNetworkWrapper(Constants.Mod.MODID); - public static void init() { + public static void init() + { INSTANCE.registerMessage(ChatUtil.PacketNoSpamChat.Handler.class, ChatUtil.PacketNoSpamChat.class, 0, Side.CLIENT); } - public static void sendToAllAround(IMessage message, TileEntity te, int range) { + public static void sendToAllAround(IMessage message, TileEntity te, int range) + { INSTANCE.sendToAllAround(message, new NetworkRegistry.TargetPoint(te.getWorld().provider.getDimensionId(), te.getPos().getX(), te.getPos().getY(), te.getPos().getZ(), range)); } - public static void sendToAllAround(IMessage message, TileEntity te) { + public static void sendToAllAround(IMessage message, TileEntity te) + { sendToAllAround(message, te, 64); } - public static void sendTo(IMessage message, EntityPlayerMP player) { + public static void sendTo(IMessage message, EntityPlayerMP player) + { INSTANCE.sendTo(message, player); } } diff --git a/src/main/java/WayofTime/bloodmagic/potion/PotionBloodMagic.java b/src/main/java/WayofTime/bloodmagic/potion/PotionBloodMagic.java index c66e9357..87e07d66 100644 --- a/src/main/java/WayofTime/bloodmagic/potion/PotionBloodMagic.java +++ b/src/main/java/WayofTime/bloodmagic/potion/PotionBloodMagic.java @@ -3,9 +3,11 @@ package WayofTime.bloodmagic.potion; import net.minecraft.potion.Potion; import net.minecraft.util.ResourceLocation; -public class PotionBloodMagic extends Potion { +public class PotionBloodMagic extends Potion +{ - public PotionBloodMagic(String name, ResourceLocation texture, boolean badEffect, int potionColor, int iconIndexX, int iconIndexY) { + public PotionBloodMagic(String name, ResourceLocation texture, boolean badEffect, int potionColor, int iconIndexX, int iconIndexY) + { super(texture, badEffect, potionColor); this.setPotionName(name); this.setIconIndex(iconIndexX, iconIndexY); diff --git a/src/main/java/WayofTime/bloodmagic/potion/PotionEventHandlers.java b/src/main/java/WayofTime/bloodmagic/potion/PotionEventHandlers.java index 67d72f00..a2d1d63f 100644 --- a/src/main/java/WayofTime/bloodmagic/potion/PotionEventHandlers.java +++ b/src/main/java/WayofTime/bloodmagic/potion/PotionEventHandlers.java @@ -18,33 +18,40 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import java.util.List; -public class PotionEventHandlers { +public class PotionEventHandlers +{ - public PotionEventHandlers() { + public PotionEventHandlers() + { MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent - public void onLivingJumpEvent(LivingEvent.LivingJumpEvent event) { - if (event.entityLiving.isPotionActive(ModPotions.boost)) { + public void onLivingJumpEvent(LivingEvent.LivingJumpEvent event) + { + if (event.entityLiving.isPotionActive(ModPotions.boost)) + { int i = event.entityLiving.getActivePotionEffect(ModPotions.boost).getAmplifier(); event.entityLiving.motionY += (0.1f) * (2 + i); } -// if (event.entityLiving.isPotionActive(ModPotions.heavyHeart)) { -// event.entityLiving.motionY = 0; -// } + // if (event.entityLiving.isPotionActive(ModPotions.heavyHeart)) { + // event.entityLiving.motionY = 0; + // } } @SubscribeEvent - public void onEntityUpdate(LivingEvent.LivingUpdateEvent event) { + public void onEntityUpdate(LivingEvent.LivingUpdateEvent event) + { - if (event.entityLiving.isPotionActive(ModPotions.boost)) { + if (event.entityLiving.isPotionActive(ModPotions.boost)) + { int i = event.entityLiving.getActivePotionEffect(ModPotions.boost).getAmplifier(); { float percentIncrease = (i + 1) * 0.05f; - if (event.entityLiving instanceof EntityPlayer) { + if (event.entityLiving instanceof EntityPlayer) + { EntityPlayer entityPlayer = (EntityPlayer) event.entityLiving; entityPlayer.stepHeight = 1.0f; @@ -54,37 +61,44 @@ public class PotionEventHandlers { } } - if (event.entityLiving.isPotionActive(ModPotions.whirlwind)) { + if (event.entityLiving.isPotionActive(ModPotions.whirlwind)) + { int d0 = 3; AxisAlignedBB axisAlignedBB = AxisAlignedBB.fromBounds(event.entityLiving.posX - 0.5, event.entityLiving.posY - 0.5, event.entityLiving.posZ - 0.5, event.entityLiving.posX + 0.5, event.entityLiving.posY + 0.5, event.entityLiving.posZ + 0.5).expand(d0, d0, d0); List entityList = event.entityLiving.worldObj.getEntitiesWithinAABB(Entity.class, axisAlignedBB); - for (Object thing : entityList) { + for (Object thing : entityList) + { Entity projectile = (Entity) thing; - if (projectile == null) continue; - if (!(projectile instanceof IProjectile)) continue; + if (projectile == null) + continue; + if (!(projectile instanceof IProjectile)) + continue; Entity throwingEntity = null; - if (projectile instanceof EntityArrow) throwingEntity = ((EntityArrow) projectile).shootingEntity; + if (projectile instanceof EntityArrow) + throwingEntity = ((EntityArrow) projectile).shootingEntity; else if (projectile instanceof EntityThrowable) throwingEntity = ((EntityThrowable) projectile).getThrower(); - if (throwingEntity != null && throwingEntity.equals(event.entityLiving)) continue; + if (throwingEntity != null && throwingEntity.equals(event.entityLiving)) + continue; double delX = projectile.posX - event.entityLiving.posX; double delY = projectile.posY - event.entityLiving.posY; double delZ = projectile.posZ - event.entityLiving.posZ; - double angle = (delX * projectile.motionX + delY * projectile.motionY + delZ * projectile.motionZ) / - (Math.sqrt(delX * delX + delY * delY + delZ * delZ) * Math.sqrt(projectile.motionX * projectile.motionX + projectile.motionY * projectile.motionY + projectile.motionZ * projectile.motionZ)); + double angle = (delX * projectile.motionX + delY * projectile.motionY + delZ * projectile.motionZ) / (Math.sqrt(delX * delX + delY * delY + delZ * delZ) * Math.sqrt(projectile.motionX * projectile.motionX + projectile.motionY * projectile.motionY + projectile.motionZ * projectile.motionZ)); angle = Math.acos(angle); - if (angle < 3 * (Math.PI / 4)) continue; //angle is < 135 degrees + if (angle < 3 * (Math.PI / 4)) + continue; // angle is < 135 degrees - if (throwingEntity != null) { + if (throwingEntity != null) + { delX = -projectile.posX + throwingEntity.posX; delY = -projectile.posY + (throwingEntity.posY + throwingEntity.getEyeHeight()); delZ = -projectile.posZ + throwingEntity.posZ; @@ -104,11 +118,14 @@ public class PotionEventHandlers { } @SubscribeEvent - public void onEntityDrop(LivingDropsEvent event) { - if (event.source.getDamageType().equals("player")) { + public void onEntityDrop(LivingDropsEvent event) + { + if (event.source.getDamageType().equals("player")) + { double rand = Math.random(); - if (!(event.entityLiving instanceof EntityAnimal)) { + if (!(event.entityLiving instanceof EntityAnimal)) + { PotionEffect effect = event.entityLiving.getActivePotionEffect(Potion.weakness); if (effect != null) @@ -120,14 +137,17 @@ public class PotionEventHandlers { } @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onPlayerDamageEvent(LivingAttackEvent event) { + public void onPlayerDamageEvent(LivingAttackEvent event) + { if (event.entityLiving.isPotionActive(ModPotions.whirlwind) && event.isCancelable() && event.source.isProjectile()) event.setCanceled(true); } @SubscribeEvent - public void onEndermanTeleportEvent(EnderTeleportEvent event) { - if (event.entityLiving.isPotionActive(ModPotions.planarBinding) && event.isCancelable()) { + public void onEndermanTeleportEvent(EnderTeleportEvent event) + { + if (event.entityLiving.isPotionActive(ModPotions.planarBinding) && event.isCancelable()) + { event.setCanceled(true); } } diff --git a/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java b/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java index d5a134ab..22462d0c 100644 --- a/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java +++ b/src/main/java/WayofTime/bloodmagic/proxy/ClientProxy.java @@ -15,17 +15,20 @@ import net.minecraftforge.client.model.obj.OBJLoader; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.RenderingRegistry; -public class ClientProxy extends CommonProxy { +public class ClientProxy extends CommonProxy +{ private InventoryRenderHelper renderHelper; @Override - public InventoryRenderHelper getRenderHelper() { + public InventoryRenderHelper getRenderHelper() + { return renderHelper; } @Override - public void preInit() { + public void preInit() + { renderHelper = new InventoryRenderHelper(Constants.Mod.DOMAIN); @@ -38,12 +41,14 @@ public class ClientProxy extends CommonProxy { } @Override - public void init() { + public void init() + { RenderingRegistry.registerEntityRenderingHandler(EntityBloodLight.class, new RenderEntityBloodLight(Minecraft.getMinecraft().getRenderManager())); } @Override - public void postInit() { + public void postInit() + { } } diff --git a/src/main/java/WayofTime/bloodmagic/proxy/CommonProxy.java b/src/main/java/WayofTime/bloodmagic/proxy/CommonProxy.java index cefeb685..2ca6a1e4 100644 --- a/src/main/java/WayofTime/bloodmagic/proxy/CommonProxy.java +++ b/src/main/java/WayofTime/bloodmagic/proxy/CommonProxy.java @@ -2,21 +2,26 @@ package WayofTime.bloodmagic.proxy; import WayofTime.bloodmagic.util.helper.InventoryRenderHelper; -public class CommonProxy { +public class CommonProxy +{ - public InventoryRenderHelper getRenderHelper() { + public InventoryRenderHelper getRenderHelper() + { return null; } - public void preInit() { + public void preInit() + { } - public void init() { + public void init() + { } - public void postInit() { + public void postInit() + { } } diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java b/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java index af274d52..c55e8044 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java @@ -12,7 +12,8 @@ import net.minecraft.item.ItemBlock; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fml.common.registry.GameRegistry; -public class ModBlocks { +public class ModBlocks +{ public static Block altar; public static Block bloodRune; public static Block ritualController; @@ -30,7 +31,8 @@ public class ModBlocks { public static Block crystal; public static Block bloodStoneBrick; - public static void init() { + public static void init() + { FluidRegistry.registerFluid(BlockLifeEssence.getLifeEssence()); lifeEssence = registerBlock(new BlockLifeEssence()); @@ -51,7 +53,8 @@ public class ModBlocks { initTiles(); } - public static void initTiles() { + public static void initTiles() + { GameRegistry.registerTileEntity(TileAltar.class, Constants.Mod.MODID + ":" + TileAltar.class.getSimpleName()); GameRegistry.registerTileEntity(TileImperfectRitualStone.class, Constants.Mod.MODID + ":" + TileImperfectRitualStone.class.getSimpleName()); GameRegistry.registerTileEntity(TileMasterRitualStone.class, Constants.Mod.MODID + ":" + TileMasterRitualStone.class.getSimpleName()); @@ -61,7 +64,8 @@ public class ModBlocks { GameRegistry.registerTileEntity(TilePhantomBlock.class, Constants.Mod.MODID + ":" + TilePhantomBlock.class.getSimpleName()); } - public static void initRenders() { + public static void initRenders() + { InventoryRenderHelper renderHelper = BloodMagic.proxy.getRenderHelper(); renderHelper.fluidRender(lifeEssence); @@ -97,25 +101,29 @@ public class ModBlocks { renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(phantomBlock)); } - private static Block registerBlock(Block block, Class itemBlock, String name) { + private static Block registerBlock(Block block, Class itemBlock, String name) + { if (!ConfigHandler.blockBlacklist.contains(name)) GameRegistry.registerBlock(block, itemBlock, name); return block; } - private static Block registerBlock(Block block, Class itemBlock) { + private static Block registerBlock(Block block, Class itemBlock) + { return registerBlock(block, itemBlock, block.getClass().getSimpleName()); } - private static Block registerBlock(Block block, String name) { + private static Block registerBlock(Block block, String name) + { if (!ConfigHandler.blockBlacklist.contains(name)) GameRegistry.registerBlock(block, name); return block; } - private static Block registerBlock(Block block) { + private static Block registerBlock(Block block) + { return registerBlock(block, block.getClass().getSimpleName()); } } diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModCompatibility.java b/src/main/java/WayofTime/bloodmagic/registry/ModCompatibility.java index 2c1e3a1a..1860aad9 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModCompatibility.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModCompatibility.java @@ -6,14 +6,17 @@ import net.minecraftforge.fml.common.Loader; import java.util.ArrayList; -public class ModCompatibility { +public class ModCompatibility +{ private static ArrayList compatibilities = new ArrayList(); - public static void registerModCompat() { + public static void registerModCompat() + { compatibilities.add(new CompatibilityJustEnoughItems()); - for (ICompatibility compat : compatibilities) { + for (ICompatibility compat : compatibilities) + { if (compat.enableCompat() && Loader.isModLoaded(compat.getModId())) compat.loadCompatibility(); } diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModEntities.java b/src/main/java/WayofTime/bloodmagic/registry/ModEntities.java index 5432c804..44056f17 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModEntities.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModEntities.java @@ -4,9 +4,11 @@ import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.entity.projectile.EntityBloodLight; import net.minecraftforge.fml.common.registry.EntityRegistry; -public class ModEntities { +public class ModEntities +{ - public static void init() { + public static void init() + { int id = 0; EntityRegistry.registerModEntity(EntityBloodLight.class, "BloodLight", id++, BloodMagic.instance, 64, 20, true); diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModItems.java b/src/main/java/WayofTime/bloodmagic/registry/ModItems.java index 49405af6..38465e2c 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModItems.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModItems.java @@ -15,7 +15,8 @@ import WayofTime.bloodmagic.item.gear.ItemPackSelfSacrifice; import WayofTime.bloodmagic.item.sigil.*; import WayofTime.bloodmagic.util.helper.InventoryRenderHelper; -public class ModItems { +public class ModItems +{ public static Item bloodOrb; public static BloodOrb orbWeak; @@ -63,7 +64,7 @@ public class ModItems { public static Item itemComponent; public static Item bloodShard; - + public static Item livingArmourHelmet; public static Item livingArmourChest; public static Item livingArmourLegs; @@ -73,7 +74,8 @@ public class ModItems { public static Item.ToolMaterial boundToolMaterial = EnumHelper.addToolMaterial("BoundToolMaterial", 4, 0, 12, 8, 50); - public static void init() { + public static void init() + { bloodOrb = registerItem(new ItemBloodOrb()); orbWeak = new BloodOrb("weak", 1, 5000); OrbRegistry.registerOrb(orbWeak); @@ -100,7 +102,7 @@ public class ModItems { daggerOfSacrifice = registerItem(new ItemDaggerOfSacrifice()); ritualDiviner = registerItem(new ItemRitualDiviner()); - + boundSword = registerItem(new ItemBoundSword()); boundPickaxe = registerItem(new ItemBoundPickaxe()); boundAxe = registerItem(new ItemBoundAxe()); @@ -127,7 +129,7 @@ public class ModItems { itemComponent = registerItem(new ItemComponent()); bloodShard = registerItem(new ItemBloodShard()); - + livingArmourHelmet = registerItem(new ItemLivingArmour(0), "ItemLivingArmourHelmet"); livingArmourChest = registerItem(new ItemLivingArmour(1), "ItemLivingArmourChest"); livingArmourLegs = registerItem(new ItemLivingArmour(2), "ItemLivingArmourLegs"); @@ -136,7 +138,8 @@ public class ModItems { altarMaker = registerItem(new ItemAltarMaker()); } - public static void initRenders() { + public static void initRenders() + { InventoryRenderHelper renderHelper = BloodMagic.proxy.getRenderHelper(); renderHelper.itemRenderAll(bloodOrb); @@ -171,7 +174,7 @@ public class ModItems { renderHelper.itemRender(packSacrifice); renderHelper.itemRender(packSelfSacrifice); renderHelper.itemRender(daggerOfSacrifice); - + renderHelper.itemRender(ritualDiviner, 0); renderHelper.itemRender(boundSword, 0); @@ -211,8 +214,8 @@ public class ModItems { renderHelper.itemRender(sigilEnderSeverance, 0); renderHelper.itemRender(sigilEnderSeverance, 1); - for(int i = 0 ; i < ItemComponent.getNames().size() ; i++) - renderHelper.itemRender(itemComponent, i); + for (int i = 0; i < ItemComponent.getNames().size(); i++) + renderHelper.itemRender(itemComponent, i); renderHelper.itemRender(bloodShard, 0); renderHelper.itemRender(bloodShard, 1); @@ -225,14 +228,16 @@ public class ModItems { renderHelper.itemRender(altarMaker); } - private static Item registerItem(Item item, String name) { + private static Item registerItem(Item item, String name) + { if (!ConfigHandler.itemBlacklist.contains(name)) GameRegistry.registerItem(item, name); return item; } - private static Item registerItem(Item item) { + private static Item registerItem(Item item) + { return registerItem(item, item.getClass().getSimpleName()); } } diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModPotions.java b/src/main/java/WayofTime/bloodmagic/registry/ModPotions.java index 99366836..4ae0b630 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModPotions.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModPotions.java @@ -8,7 +8,8 @@ import net.minecraft.util.ResourceLocation; import WayofTime.bloodmagic.potion.PotionBloodMagic; import WayofTime.bloodmagic.potion.PotionEventHandlers; -public class ModPotions { +public class ModPotions +{ public static Potion drowning; public static Potion boost; @@ -16,31 +17,43 @@ public class ModPotions { public static Potion whirlwind; public static Potion planarBinding; - public static void init() { - if (Potion.potionTypes.length < 256) extendPortionArray(); + public static void init() + { + if (Potion.potionTypes.length < 256) + extendPortionArray(); new PotionEventHandlers(); - //TODO FUTURE MAKE POTION TEXTURES + // TODO FUTURE MAKE POTION TEXTURES -// final String resourceLocation = Constants.Mod.MODID + ":textures/potions/"; + // final String resourceLocation = Constants.Mod.MODID + + // ":textures/potions/"; -// drowning = new PotionBloodMagic("Drowning", new ResourceLocation(resourceLocation + drowning.getName().toLowerCase()), true, 0, 0, 0); + // drowning = new PotionBloodMagic("Drowning", new + // ResourceLocation(resourceLocation + + // drowning.getName().toLowerCase()), true, 0, 0, 0); boost = new PotionBloodMagic("Boost", new ResourceLocation("boost") -// new ResourceLocation(resourceLocation + boost.getName().toLowerCase()) - , false, 0, 0, 0); + // new ResourceLocation(resourceLocation + + // boost.getName().toLowerCase()) + , false, 0, 0, 0); whirlwind = new PotionBloodMagic("Whirlwind", new ResourceLocation("whirlwind"), false, 0, 0, 0); planarBinding = new PotionBloodMagic("Planar Binding", new ResourceLocation("planarBinding"), false, 0, 0, 0); -// heavyHeart = new PotionBloodMagic("Heavy Heart", new ResourceLocation(resourceLocation + heavyHeart.getName().toLowerCase()), true, 0, 0, 0); + // heavyHeart = new PotionBloodMagic("Heavy Heart", new + // ResourceLocation(resourceLocation + + // heavyHeart.getName().toLowerCase()), true, 0, 0, 0); } - public static void extendPortionArray() { + public static void extendPortionArray() + { Potion[] potionTypes; - for (Field f : Potion.class.getDeclaredFields()) { + for (Field f : Potion.class.getDeclaredFields()) + { f.setAccessible(true); - try { - if (f.getName().equals("potionTypes") || f.getName().equals("field_76425_a")) { + try + { + if (f.getName().equals("potionTypes") || f.getName().equals("field_76425_a")) + { Field field = Field.class.getDeclaredField("modifiers"); field.setAccessible(true); field.setInt(f, f.getModifiers() & ~Modifier.FINAL); @@ -50,7 +63,8 @@ public class ModPotions { System.arraycopy(potionTypes, 0, newPotionTypes, 0, potionTypes.length); f.set(null, newPotionTypes); } - } catch (Exception e) { + } catch (Exception e) + { System.err.println(e); } } diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java b/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java index fa818112..07322d09 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModRecipes.java @@ -22,77 +22,83 @@ import WayofTime.bloodmagic.compress.StorageBlockCraftingManager; import WayofTime.bloodmagic.item.ItemComponent; import net.minecraftforge.oredict.RecipeSorter; -public class ModRecipes { +public class ModRecipes +{ - public static void init() { - RecipeSorter.register(Constants.Mod.DOMAIN + "shapedorb", ShapedBloodOrbRecipe.class, RecipeSorter.Category.SHAPED, "before:minecraft:shapeless"); - RecipeSorter.register(Constants.Mod.DOMAIN + ":shapelessorb", ShapelessBloodOrbRecipe.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless"); + public static void init() + { + RecipeSorter.register(Constants.Mod.DOMAIN + "shapedorb", ShapedBloodOrbRecipe.class, RecipeSorter.Category.SHAPED, "before:minecraft:shapeless"); + RecipeSorter.register(Constants.Mod.DOMAIN + ":shapelessorb", ShapelessBloodOrbRecipe.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless"); - addCraftingRecipes(); - addAltarRecipes(); - addAlchemyArrayRecipes(); - } + addCraftingRecipes(); + addAltarRecipes(); + addAlchemyArrayRecipes(); + } - public static void addCraftingRecipes() { - GameRegistry.addRecipe(new ShapedBloodOrbRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), "xox", "oSo", "xox", 'S', OrbRegistry.getOrbStack(ModItems.orbMagician), 'o', new ItemStack(Items.redstone), 'x', new ItemStack(Items.glowstone_dust))); - // Added for testing - GameRegistry.addRecipe(new ShapelessBloodOrbRecipe(new ItemStack(Items.gold_ingot), new ItemStack(ModItems.slate, 1, 1), OrbRegistry.getOrbStack(ModItems.orbApprentice))); - GameRegistry.addRecipe(new ShapedBloodOrbRecipe(new ItemStack(Items.diamond), " ", " s ", " o ", 's', new ItemStack(ModItems.slate), 'o', OrbRegistry.getOrbStack(ModItems.orbWeak))); + public static void addCraftingRecipes() + { + GameRegistry.addRecipe(new ShapedBloodOrbRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), "xox", "oSo", "xox", 'S', OrbRegistry.getOrbStack(ModItems.orbMagician), 'o', new ItemStack(Items.redstone), 'x', new ItemStack(Items.glowstone_dust))); + // Added for testing + GameRegistry.addRecipe(new ShapelessBloodOrbRecipe(new ItemStack(Items.gold_ingot), new ItemStack(ModItems.slate, 1, 1), OrbRegistry.getOrbStack(ModItems.orbApprentice))); + GameRegistry.addRecipe(new ShapedBloodOrbRecipe(new ItemStack(Items.diamond), " ", " s ", " o ", 's', new ItemStack(ModItems.slate), 'o', OrbRegistry.getOrbStack(ModItems.orbWeak))); - GameRegistry.addRecipe(new ItemStack(ModItems.ritualDiviner), "dfd", "ase", "dwd", 'f', EnumRuneType.FIRE.getScribeStack(), 'a', EnumRuneType.AIR.getScribeStack(), 'w', EnumRuneType.WATER.getScribeStack(), 'e', EnumRuneType.EARTH.getScribeStack(), 'd', new ItemStack(Items.diamond), 's', new ItemStack(Items.stick)); - } + GameRegistry.addRecipe(new ItemStack(ModItems.ritualDiviner), "dfd", "ase", "dwd", 'f', EnumRuneType.FIRE.getScribeStack(), 'a', EnumRuneType.AIR.getScribeStack(), 'w', EnumRuneType.WATER.getScribeStack(), 'e', EnumRuneType.EARTH.getScribeStack(), 'd', new ItemStack(Items.diamond), 's', new ItemStack(Items.stick)); + } - public static void addAltarRecipes() { - // ONE - AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(OrbRegistry.getOrbStack(ModItems.orbWeak), OrbRegistry.getOrbStack(ModItems.orbWeak), EnumAltarTier.ONE, 5000, 2, 1, true)); - AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Items.diamond), OrbRegistry.getOrbStack(ModItems.orbWeak), EnumAltarTier.ONE, 2000, 2, 1, false)); - AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Blocks.stone), new ItemStack(ModItems.slate), EnumAltarTier.ONE, 1000, 5, 5, false)); + public static void addAltarRecipes() + { + // ONE + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(OrbRegistry.getOrbStack(ModItems.orbWeak), OrbRegistry.getOrbStack(ModItems.orbWeak), EnumAltarTier.ONE, 5000, 2, 1, true)); + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Items.diamond), OrbRegistry.getOrbStack(ModItems.orbWeak), EnumAltarTier.ONE, 2000, 2, 1, false)); + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Blocks.stone), new ItemStack(ModItems.slate), EnumAltarTier.ONE, 1000, 5, 5, false)); - // TWO - AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Items.emerald), OrbRegistry.getOrbStack(ModItems.orbApprentice), EnumAltarTier.TWO, 5000, 2, 1, false)); - AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(ModItems.slate), new ItemStack(ModItems.slate, 1, 1), EnumAltarTier.TWO, 2000, 5, 5, false)); + // TWO + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Items.emerald), OrbRegistry.getOrbStack(ModItems.orbApprentice), EnumAltarTier.TWO, 5000, 2, 1, false)); + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(ModItems.slate), new ItemStack(ModItems.slate, 1, 1), EnumAltarTier.TWO, 2000, 5, 5, false)); - // THREE - AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Blocks.gold_block), OrbRegistry.getOrbStack(ModItems.orbMagician), EnumAltarTier.THREE, 25000, 2, 1, false)); - AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(ModItems.slate, 1, 1), new ItemStack(ModItems.slate, 1, 2), EnumAltarTier.THREE, 5000, 15, 10, false)); - AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Blocks.obsidian), EnumRuneType.EARTH.getScribeStack(), EnumAltarTier.THREE, 1000, 5, 5, false)); - AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Blocks.lapis_block), EnumRuneType.WATER.getScribeStack(), EnumAltarTier.THREE, 1000, 5, 5, false)); - AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Items.magma_cream), EnumRuneType.FIRE.getScribeStack(), EnumAltarTier.THREE, 1000, 5, 5, false)); - AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Items.ghast_tear), EnumRuneType.AIR.getScribeStack(), EnumAltarTier.THREE, 1000, 5, 5, false)); + // THREE + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Blocks.gold_block), OrbRegistry.getOrbStack(ModItems.orbMagician), EnumAltarTier.THREE, 25000, 2, 1, false)); + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(ModItems.slate, 1, 1), new ItemStack(ModItems.slate, 1, 2), EnumAltarTier.THREE, 5000, 15, 10, false)); + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Blocks.obsidian), EnumRuneType.EARTH.getScribeStack(), EnumAltarTier.THREE, 1000, 5, 5, false)); + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Blocks.lapis_block), EnumRuneType.WATER.getScribeStack(), EnumAltarTier.THREE, 1000, 5, 5, false)); + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Items.magma_cream), EnumRuneType.FIRE.getScribeStack(), EnumAltarTier.THREE, 1000, 5, 5, false)); + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Items.ghast_tear), EnumRuneType.AIR.getScribeStack(), EnumAltarTier.THREE, 1000, 5, 5, false)); - // FOUR - AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(ModItems.slate, 1, 2), new ItemStack(ModItems.slate, 1, 3), EnumAltarTier.FOUR, 15000, 20, 20, false)); - AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Blocks.coal_block), EnumRuneType.DUSK.getScribeStack(), EnumAltarTier.FOUR, 2000, 20, 10, false)); + // FOUR + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(ModItems.slate, 1, 2), new ItemStack(ModItems.slate, 1, 3), EnumAltarTier.FOUR, 15000, 20, 20, false)); + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Blocks.coal_block), EnumRuneType.DUSK.getScribeStack(), EnumAltarTier.FOUR, 2000, 20, 10, false)); - // FIVE - AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(ModItems.slate, 1, 3), new ItemStack(ModItems.slate, 1, 4), EnumAltarTier.FIVE, 30000, 40, 100, false)); + // FIVE + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(ModItems.slate, 1, 3), new ItemStack(ModItems.slate, 1, 4), EnumAltarTier.FIVE, 30000, 40, 100, false)); - // SIX - AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(ModBlocks.crystal), OrbRegistry.getOrbStack(ModItems.orbTranscendent), EnumAltarTier.SIX, 200000, 100, 200, false)); - AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Blocks.glowstone), EnumRuneType.DAWN.getScribeStack(), EnumAltarTier.SIX, 200000, 100, 200, false)); - } + // SIX + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(ModBlocks.crystal), OrbRegistry.getOrbStack(ModItems.orbTranscendent), EnumAltarTier.SIX, 200000, 100, 200, false)); + AltarRecipeRegistry.registerRecipe(new AltarRecipeRegistry.AltarRecipe(new ItemStack(Blocks.glowstone), EnumRuneType.DAWN.getScribeStack(), EnumAltarTier.SIX, 200000, 100, 200, false)); + } - public static void addAlchemyArrayRecipes() { - AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.diamond_sword), new AlchemyArrayEffectBinding(new ItemStack(ModItems.boundSword)), new BindingAlchemyCircleRenderer()); - AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.diamond_axe), new AlchemyArrayEffectBinding(new ItemStack(ModItems.boundAxe))); - AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.diamond_pickaxe), new AlchemyArrayEffectBinding(new ItemStack(ModItems.boundPickaxe))); - AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.diamond_shovel), new AlchemyArrayEffectBinding(new ItemStack(ModItems.boundShovel))); - AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_WATER), new ItemStack(ModItems.slate), new ItemStack(ModItems.sigilWater), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/WaterSigil.png")); - AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_LAVA), new ItemStack(ModItems.slate), new ItemStack(ModItems.sigilLava), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/LavaSigil.png")); - AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_AIR), new ItemStack(ModItems.slate, 1, 1), new ItemStack(ModItems.sigilAir), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/AirSigil.png")); - AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_FASTMINER), new ItemStack(ModItems.slate, 1, 1), new ItemStack(ModItems.sigilFastMiner), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/FastMinerSigil.png")); - AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_VOID), new ItemStack(ModItems.slate, 1, 1), new ItemStack(ModItems.sigilVoid), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/VoidSigil.png")); - AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_GROWTH), new ItemStack(ModItems.slate, 1, 1), new ItemStack(ModItems.sigilGreenGrove), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/GrowthSigil.png")); - AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_AFFINITY), new ItemStack(ModItems.slate, 1, 2), new ItemStack(ModItems.sigilElementalAffinity), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/ElementalAffinitySigil.png")); - AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_SIGHT), new ItemStack(ModItems.slate, 1, 1), new ItemStack(ModItems.sigilSeer), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png")); - } + public static void addAlchemyArrayRecipes() + { + AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.diamond_sword), new AlchemyArrayEffectBinding(new ItemStack(ModItems.boundSword)), new BindingAlchemyCircleRenderer()); + AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.diamond_axe), new AlchemyArrayEffectBinding(new ItemStack(ModItems.boundAxe))); + AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.diamond_pickaxe), new AlchemyArrayEffectBinding(new ItemStack(ModItems.boundPickaxe))); + AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.diamond_shovel), new AlchemyArrayEffectBinding(new ItemStack(ModItems.boundShovel))); + AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_WATER), new ItemStack(ModItems.slate), new ItemStack(ModItems.sigilWater), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/WaterSigil.png")); + AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_LAVA), new ItemStack(ModItems.slate), new ItemStack(ModItems.sigilLava), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/LavaSigil.png")); + AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_AIR), new ItemStack(ModItems.slate, 1, 1), new ItemStack(ModItems.sigilAir), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/AirSigil.png")); + AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_FASTMINER), new ItemStack(ModItems.slate, 1, 1), new ItemStack(ModItems.sigilFastMiner), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/FastMinerSigil.png")); + AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_VOID), new ItemStack(ModItems.slate, 1, 1), new ItemStack(ModItems.sigilVoid), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/VoidSigil.png")); + AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_GROWTH), new ItemStack(ModItems.slate, 1, 1), new ItemStack(ModItems.sigilGreenGrove), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/GrowthSigil.png")); + AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_AFFINITY), new ItemStack(ModItems.slate, 1, 2), new ItemStack(ModItems.sigilElementalAffinity), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/ElementalAffinitySigil.png")); + AlchemyArrayRecipeRegistry.registerCraftingRecipe(ItemComponent.getStack(ItemComponent.REAGENT_SIGHT), new ItemStack(ModItems.slate, 1, 1), new ItemStack(ModItems.sigilSeer), new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png")); + } - public static void addCompressionHandlers() { - StorageBlockCraftingManager.getInstance().addStorageBlockRecipes(); - CompressionRegistry.registerHandler(new BaseCompressionHandler(new ItemStack(Items.glowstone_dust, 4, 0), new ItemStack(Blocks.glowstone), 64)); - CompressionRegistry.registerHandler(new BaseCompressionHandler(new ItemStack(Items.snowball, 4, 0), new ItemStack(Blocks.snow), 8)); - CompressionRegistry.registerHandler(new AdvancedCompressionHandler()); + public static void addCompressionHandlers() + { + StorageBlockCraftingManager.getInstance().addStorageBlockRecipes(); + CompressionRegistry.registerHandler(new BaseCompressionHandler(new ItemStack(Items.glowstone_dust, 4, 0), new ItemStack(Blocks.glowstone), 64)); + CompressionRegistry.registerHandler(new BaseCompressionHandler(new ItemStack(Items.snowball, 4, 0), new ItemStack(Blocks.snow), 8)); + CompressionRegistry.registerHandler(new AdvancedCompressionHandler()); - CompressionRegistry.registerItemThreshold(new ItemStack(Blocks.cobblestone), 64); - } + CompressionRegistry.registerItemThreshold(new ItemStack(Blocks.cobblestone), 64); + } } diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModRituals.java b/src/main/java/WayofTime/bloodmagic/registry/ModRituals.java index 7a622faa..12471c16 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModRituals.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModRituals.java @@ -13,7 +13,8 @@ import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitualRain; import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitualResistance; import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitualZombie; -public class ModRituals { +public class ModRituals +{ public static Ritual testRitual; public static Ritual waterRitual; @@ -25,19 +26,21 @@ public class ModRituals { public static ImperfectRitual imperfectResistance; public static ImperfectRitual imperfectZombie; - public static void initRituals() { + public static void initRituals() + { testRitual = new RitualTest(); waterRitual = new RitualWater(); lavaRitual = new RitualLava(); greenGroveRitual = new RitualGreenGrove(); - + RitualRegistry.registerRitual(testRitual, testRitual.getName()); RitualRegistry.registerRitual(waterRitual, waterRitual.getName()); RitualRegistry.registerRitual(lavaRitual, lavaRitual.getName()); RitualRegistry.registerRitual(greenGroveRitual, greenGroveRitual.getName()); } - public static void initImperfectRituals() { + public static void initImperfectRituals() + { imperfectNight = new ImperfectRitualNight(); ImperfectRitualRegistry.registerRitual(imperfectNight); imperfectRain = new ImperfectRitualRain(); diff --git a/src/main/java/WayofTime/bloodmagic/render/RenderEntityBloodLight.java b/src/main/java/WayofTime/bloodmagic/render/RenderEntityBloodLight.java index accab83c..a48dbd08 100644 --- a/src/main/java/WayofTime/bloodmagic/render/RenderEntityBloodLight.java +++ b/src/main/java/WayofTime/bloodmagic/render/RenderEntityBloodLight.java @@ -10,14 +10,17 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -public class RenderEntityBloodLight extends Render { +public class RenderEntityBloodLight extends Render +{ - public RenderEntityBloodLight(RenderManager renderManager) { + public RenderEntityBloodLight(RenderManager renderManager) + { super(renderManager); this.shadowSize = 0.0F; } - public void renderEntityAt(EntityBloodLight entity, double x, double y, double z, float fq, float pticks) { + public void renderEntityAt(EntityBloodLight entity, double x, double y, double z, float fq, float pticks) + { GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); GlStateManager.enableRescaleNormal(); @@ -37,12 +40,14 @@ public class RenderEntityBloodLight extends Render { } @Override - public void doRender(EntityBloodLight entityBloodLight, double d, double d1, double d2, float f, float f1) { + public void doRender(EntityBloodLight entityBloodLight, double d, double d1, double d2, float f, float f1) + { renderEntityAt(entityBloodLight, d, d1, d2, f, f1); } @Override - protected ResourceLocation getEntityTexture(EntityBloodLight entityBloodLight) { + protected ResourceLocation getEntityTexture(EntityBloodLight entityBloodLight) + { return TextureMap.locationBlocksTexture; } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualGreenGrove.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualGreenGrove.java index bbcbd0f9..cfcb4e9a 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualGreenGrove.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualGreenGrove.java @@ -17,74 +17,88 @@ import WayofTime.bloodmagic.api.ritual.Ritual; import WayofTime.bloodmagic.api.ritual.RitualComponent; import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -public class RitualGreenGrove extends Ritual { +public class RitualGreenGrove extends Ritual +{ - public static final String GROW_RANGE = "growing"; - public RitualGreenGrove() { - super("ritualGreenGrove", 0, 1000, "ritual." + Constants.Mod.MODID + ".greenGroveRitual"); - addBlockRange(GROW_RANGE, new BlockPos[] { new BlockPos(-1, 2, -1), new BlockPos(1, 2, 1) }); - } + public static final String GROW_RANGE = "growing"; - @Override - public void performRitual(IMasterRitualStone masterRitualStone) { - World world = masterRitualStone.getWorld(); - SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner(), world); - int currentEssence = network.getCurrentEssence(); + public RitualGreenGrove() + { + super("ritualGreenGrove", 0, 1000, "ritual." + Constants.Mod.MODID + ".greenGroveRitual"); + addBlockRange(GROW_RANGE, new BlockPos[] { new BlockPos(-1, 2, -1), new BlockPos(1, 2, 1) }); + } - if (currentEssence < getRefreshCost()) - return; - - int maxGrowths = currentEssence / getRefreshCost(); - int totalGrowths = 0; + @Override + public void performRitual(IMasterRitualStone masterRitualStone) + { + World world = masterRitualStone.getWorld(); + SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner(), world); + int currentEssence = network.getCurrentEssence(); - BlockPos[] growingRange = getBlockRange(GROW_RANGE); + if (currentEssence < getRefreshCost()) + return; - for (int i = growingRange[0].getX(); i <= growingRange[1].getX(); i++) { - for (int j = growingRange[0].getY(); j <= growingRange[1].getY(); j++) { - for (int k = growingRange[0].getZ(); k <= growingRange[1].getZ(); k++) { - BlockPos newPos = masterRitualStone.getPos().add(i, j, k); - IBlockState state = world.getBlockState(newPos); - Block block = state.getBlock(); - if (block instanceof IPlantable || block instanceof IGrowable) { - block.updateTick(world, newPos, state, new Random()); - totalGrowths++; - } - - if (totalGrowths >= maxGrowths) { - break; - } - } - - if (totalGrowths >= maxGrowths) { - break; - } - } - - if (totalGrowths >= maxGrowths) { - break; - } - } - - network.syphon(totalGrowths * getRefreshCost()); - } + int maxGrowths = currentEssence / getRefreshCost(); + int totalGrowths = 0; - @Override - public int getRefreshTime() { - return 20; - } + BlockPos[] growingRange = getBlockRange(GROW_RANGE); - @Override - public int getRefreshCost() { - return 20; - } + for (int i = growingRange[0].getX(); i <= growingRange[1].getX(); i++) + { + for (int j = growingRange[0].getY(); j <= growingRange[1].getY(); j++) + { + for (int k = growingRange[0].getZ(); k <= growingRange[1].getZ(); k++) + { + BlockPos newPos = masterRitualStone.getPos().add(i, j, k); + IBlockState state = world.getBlockState(newPos); + Block block = state.getBlock(); + if (block instanceof IPlantable || block instanceof IGrowable) + { + block.updateTick(world, newPos, state, new Random()); + totalGrowths++; + } - @Override - public ArrayList getComponents() { - ArrayList components = new ArrayList(); + if (totalGrowths >= maxGrowths) + { + break; + } + } - this.addCornerRunes(components, 1, 0, EnumRuneType.EARTH); - this.addParallelRunes(components, 1, 0, EnumRuneType.WATER); + if (totalGrowths >= maxGrowths) + { + break; + } + } - return components; - } + if (totalGrowths >= maxGrowths) + { + break; + } + } + + network.syphon(totalGrowths * getRefreshCost()); + } + + @Override + public int getRefreshTime() + { + return 20; + } + + @Override + public int getRefreshCost() + { + return 20; + } + + @Override + public ArrayList getComponents() + { + ArrayList components = new ArrayList(); + + this.addCornerRunes(components, 1, 0, EnumRuneType.EARTH); + this.addParallelRunes(components, 1, 0, EnumRuneType.WATER); + + return components; + } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualLava.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualLava.java index 7c49705a..67cd4641 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualLava.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualLava.java @@ -13,44 +13,51 @@ import WayofTime.bloodmagic.api.ritual.Ritual; import WayofTime.bloodmagic.api.ritual.RitualComponent; import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -public class RitualLava extends Ritual { +public class RitualLava extends Ritual +{ - public RitualLava() { - super("ritualLava", 0, 10000, "ritual." + Constants.Mod.MODID + ".lavaRitual"); - } + public RitualLava() + { + super("ritualLava", 0, 10000, "ritual." + Constants.Mod.MODID + ".lavaRitual"); + } - @Override - public void performRitual(IMasterRitualStone masterRitualStone) { - World world = masterRitualStone.getWorld(); - SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner(), world); - int currentEssence = network.getCurrentEssence(); - - if(currentEssence < getRefreshCost()) - return; - - BlockPos pos = masterRitualStone.getPos().up(); - if(world.isAirBlock(pos)) { - world.setBlockState(pos, Blocks.lava.getDefaultState()); - network.syphon(getRefreshCost()); - } - } + @Override + public void performRitual(IMasterRitualStone masterRitualStone) + { + World world = masterRitualStone.getWorld(); + SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner(), world); + int currentEssence = network.getCurrentEssence(); - @Override - public int getRefreshTime() { - return 1; - } + if (currentEssence < getRefreshCost()) + return; - @Override - public int getRefreshCost() { - return 500; - } + BlockPos pos = masterRitualStone.getPos().up(); + if (world.isAirBlock(pos)) + { + world.setBlockState(pos, Blocks.lava.getDefaultState()); + network.syphon(getRefreshCost()); + } + } - @Override - public ArrayList getComponents() { - ArrayList components = new ArrayList(); + @Override + public int getRefreshTime() + { + return 1; + } + + @Override + public int getRefreshCost() + { + return 500; + } + + @Override + public ArrayList getComponents() + { + ArrayList components = new ArrayList(); this.addParallelRunes(components, 1, 0, EnumRuneType.FIRE); - + return components; - } + } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualTest.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualTest.java index 57ba250e..014b831c 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualTest.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualTest.java @@ -9,20 +9,24 @@ import net.minecraft.util.ChatComponentText; import java.util.ArrayList; -public class RitualTest extends Ritual { +public class RitualTest extends Ritual +{ - public RitualTest() { + public RitualTest() + { super("ritualTest", 0, 1000, "ritual." + Constants.Mod.MODID + ".testRitual"); } @Override - public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player) { + public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player) + { player.addChatComponentMessage(new ChatComponentText("ritual started")); return true; } @Override - public void performRitual(IMasterRitualStone masterRitualStone) { + public void performRitual(IMasterRitualStone masterRitualStone) + { EntityPlayer player = PlayerHelper.getPlayerFromUUID(masterRitualStone.getOwner()); if (player != null) @@ -30,7 +34,8 @@ public class RitualTest extends Ritual { } @Override - public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType) { + public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType) + { EntityPlayer player = PlayerHelper.getPlayerFromUUID(masterRitualStone.getOwner()); if (player != null) @@ -38,12 +43,14 @@ public class RitualTest extends Ritual { } @Override - public int getRefreshCost() { + public int getRefreshCost() + { return 0; } @Override - public ArrayList getComponents() { + public ArrayList getComponents() + { ArrayList components = new ArrayList(); components.add(new RitualComponent(new BlockPos(1, 0, 1), EnumRuneType.AIR)); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualWater.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualWater.java index 1f8ec70f..2b6bfdf0 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualWater.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualWater.java @@ -13,44 +13,51 @@ import WayofTime.bloodmagic.api.ritual.Ritual; import WayofTime.bloodmagic.api.ritual.RitualComponent; import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -public class RitualWater extends Ritual { +public class RitualWater extends Ritual +{ - public RitualWater() { - super("ritualWater", 0, 500, "ritual." + Constants.Mod.MODID + ".waterRitual"); - } + public RitualWater() + { + super("ritualWater", 0, 500, "ritual." + Constants.Mod.MODID + ".waterRitual"); + } - @Override - public void performRitual(IMasterRitualStone masterRitualStone) { - World world = masterRitualStone.getWorld(); - SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner(), world); - int currentEssence = network.getCurrentEssence(); - - if(currentEssence < getRefreshCost()) - return; - - BlockPos pos = masterRitualStone.getPos().up(); - if(world.isAirBlock(pos)) { - world.setBlockState(pos, Blocks.water.getDefaultState()); - network.syphon(getRefreshCost()); - } - } + @Override + public void performRitual(IMasterRitualStone masterRitualStone) + { + World world = masterRitualStone.getWorld(); + SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner(), world); + int currentEssence = network.getCurrentEssence(); - @Override - public int getRefreshTime() { - return 1; - } + if (currentEssence < getRefreshCost()) + return; - @Override - public int getRefreshCost() { - return 25; - } + BlockPos pos = masterRitualStone.getPos().up(); + if (world.isAirBlock(pos)) + { + world.setBlockState(pos, Blocks.water.getDefaultState()); + network.syphon(getRefreshCost()); + } + } - @Override - public ArrayList getComponents() { - ArrayList components = new ArrayList(); + @Override + public int getRefreshTime() + { + return 1; + } + + @Override + public int getRefreshCost() + { + return 25; + } + + @Override + public ArrayList getComponents() + { + ArrayList components = new ArrayList(); this.addCornerRunes(components, 1, 0, EnumRuneType.WATER); - + return components; - } + } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualDay.java b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualDay.java index ad417860..4258775f 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualDay.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualDay.java @@ -6,14 +6,17 @@ import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -public class ImperfectRitualDay extends ImperfectRitual { +public class ImperfectRitualDay extends ImperfectRitual +{ - public ImperfectRitualDay() { + public ImperfectRitualDay() + { super("day", new BlockStack(Blocks.gold_block), 5000, true); } @Override - public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) { + public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) + { if (!imperfectRitualStone.getWorld().isRemote) imperfectRitualStone.getWorld().setWorldTime((imperfectRitualStone.getWorld().getWorldTime() / 24000) * 24000); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualNight.java b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualNight.java index 1ede45a7..cde50d2b 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualNight.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualNight.java @@ -6,14 +6,17 @@ import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -public class ImperfectRitualNight extends ImperfectRitual { +public class ImperfectRitualNight extends ImperfectRitual +{ - public ImperfectRitualNight() { + public ImperfectRitualNight() + { super("night", new BlockStack(Blocks.lapis_block), 100, true); } @Override - public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) { + public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) + { if (!imperfectRitualStone.getWorld().isRemote) imperfectRitualStone.getWorld().setWorldTime((imperfectRitualStone.getWorld().getWorldTime() / 24000) * 24000 + 13800); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualRain.java b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualRain.java index 7a7316a8..d6ba3fae 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualRain.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualRain.java @@ -6,19 +6,24 @@ import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -public class ImperfectRitualRain extends ImperfectRitual { +public class ImperfectRitualRain extends ImperfectRitual +{ - public ImperfectRitualRain() { + public ImperfectRitualRain() + { super("rain", new BlockStack(Blocks.water), 5000, true); } @Override - public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) { - if (!imperfectRitualStone.getWorld().isRemote) { + public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) + { + if (!imperfectRitualStone.getWorld().isRemote) + { imperfectRitualStone.getWorld().getWorldInfo().setRaining(true); } - if (imperfectRitualStone.getWorld().isRemote) { + if (imperfectRitualStone.getWorld().isRemote) + { imperfectRitualStone.getWorld().setRainStrength(1.0F); imperfectRitualStone.getWorld().setThunderStrength(1.0F); } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualResistance.java b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualResistance.java index 7b5282fb..a0999490 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualResistance.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualResistance.java @@ -8,14 +8,17 @@ import net.minecraft.init.Blocks; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; -public class ImperfectRitualResistance extends ImperfectRitual { +public class ImperfectRitualResistance extends ImperfectRitual +{ - public ImperfectRitualResistance() { + public ImperfectRitualResistance() + { super("resistance", new BlockStack(Blocks.bedrock), 5000); } @Override - public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) { + public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) + { player.addPotionEffect(new PotionEffect(Potion.resistance.id, 1200, 1)); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualZombie.java b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualZombie.java index dd000ac2..74b74078 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualZombie.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualZombie.java @@ -9,14 +9,17 @@ import net.minecraft.init.Blocks; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; -public class ImperfectRitualZombie extends ImperfectRitual { +public class ImperfectRitualZombie extends ImperfectRitual +{ - public ImperfectRitualZombie() { + public ImperfectRitualZombie() + { super("zombie", new BlockStack(Blocks.coal_block), 5000); } @Override - public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) { + public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) + { EntityZombie zombie = new EntityZombie(imperfectRitualStone.getWorld()); zombie.setPosition(imperfectRitualStone.getPos().getX() + 0.5, imperfectRitualStone.getPos().getY() + 2.1, imperfectRitualStone.getPos().getZ() + 0.5); zombie.addPotionEffect(new PotionEffect(Potion.fireResistance.getId(), 2000)); diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyArray.java b/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyArray.java index 22c6f0c4..a7e3ff65 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyArray.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyArray.java @@ -8,66 +8,78 @@ import net.minecraft.util.ITickable; import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect; import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry; -public class TileAlchemyArray extends TileInventory implements ITickable { +public class TileAlchemyArray extends TileInventory implements ITickable +{ - public boolean isActive = false; - public int activeCounter = 0; + public boolean isActive = false; + public int activeCounter = 0; - public TileAlchemyArray() { - super(2, "alchemyArray"); - } + public TileAlchemyArray() + { + super(2, "alchemyArray"); + } - @Override - public void readFromNBT(NBTTagCompound tagCompound) { - super.readFromNBT(tagCompound); - this.isActive = tagCompound.getBoolean("isActive"); - this.activeCounter = tagCompound.getInteger("activeCounter"); - } + @Override + public void readFromNBT(NBTTagCompound tagCompound) + { + super.readFromNBT(tagCompound); + this.isActive = tagCompound.getBoolean("isActive"); + this.activeCounter = tagCompound.getInteger("activeCounter"); + } - @Override - public void writeToNBT(NBTTagCompound tagCompound) { - super.writeToNBT(tagCompound); - tagCompound.setBoolean("isActive", isActive); - tagCompound.setInteger("activeCounter", activeCounter); - } + @Override + public void writeToNBT(NBTTagCompound tagCompound) + { + super.writeToNBT(tagCompound); + tagCompound.setBoolean("isActive", isActive); + tagCompound.setInteger("activeCounter", activeCounter); + } - @Override - public void update() { - if (isActive && attemptCraft()) { - activeCounter++; - } else { - isActive = false; - activeCounter = 0; - } - } + @Override + public void update() + { + if (isActive && attemptCraft()) + { + activeCounter++; + } else + { + isActive = false; + activeCounter = 0; + } + } - public boolean attemptCraft() { - AlchemyArrayEffect effect = AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(this.getStackInSlot(0), this.getStackInSlot(1)); - if (effect != null) { - isActive = true; + public boolean attemptCraft() + { + AlchemyArrayEffect effect = AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(this.getStackInSlot(0), this.getStackInSlot(1)); + if (effect != null) + { + isActive = true; - if (effect.update(this, this.activeCounter)) { - this.decrStackSize(0, 1); - this.decrStackSize(1, 1); - this.worldObj.setBlockToAir(getPos()); - } + if (effect.update(this, this.activeCounter)) + { + this.decrStackSize(0, 1); + this.decrStackSize(1, 1); + this.worldObj.setBlockToAir(getPos()); + } - return true; - } + return true; + } - return false; - } + return false; + } - @Override - public Packet getDescriptionPacket() { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeToNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(pos, this.getBlockMetadata(), nbttagcompound); - } + @Override + public Packet getDescriptionPacket() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(pos, this.getBlockMetadata(), nbttagcompound); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { - super.onDataPacket(net, packet); - readFromNBT(packet.getNbtCompound()); - } + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) + { + super.onDataPacket(net, packet); + readFromNBT(packet.getNbtCompound()); + } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileAltar.java b/src/main/java/WayofTime/bloodmagic/tile/TileAltar.java index 7f59be38..339a1cfa 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileAltar.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileAltar.java @@ -13,196 +13,231 @@ import WayofTime.bloodmagic.altar.BloodAltar; import WayofTime.bloodmagic.api.altar.EnumAltarTier; import WayofTime.bloodmagic.api.altar.IBloodAltar; -public class TileAltar extends TileInventory implements IBloodAltar, ITickable, IFluidTank, IFluidHandler { +public class TileAltar extends TileInventory implements IBloodAltar, ITickable, IFluidTank, IFluidHandler +{ - private BloodAltar bloodAltar; - - public TileAltar() { + private BloodAltar bloodAltar; + + public TileAltar() + { super(1, "altar"); this.bloodAltar = new BloodAltar(this); } @Override - public void readFromNBT(NBTTagCompound tagCompound) { + public void readFromNBT(NBTTagCompound tagCompound) + { super.readFromNBT(tagCompound); NBTTagCompound altarTag = tagCompound.getCompoundTag("bloodAltar"); - + this.bloodAltar.readFromNBT(altarTag); } @Override - public void writeToNBT(NBTTagCompound tagCompound) { + public void writeToNBT(NBTTagCompound tagCompound) + { super.writeToNBT(tagCompound); NBTTagCompound altarTag = new NBTTagCompound(); this.bloodAltar.writeToNBT(altarTag); - + tagCompound.setTag("bloodAltar", altarTag); } @Override - public void update() { + public void update() + { bloodAltar.update(); } @Override - public void sacrificialDaggerCall(int amount, boolean isSacrifice) { + public void sacrificialDaggerCall(int amount, boolean isSacrifice) + { bloodAltar.sacrificialDaggerCall(amount, isSacrifice); } @Override - public boolean isItemValidForSlot(int slot, ItemStack itemstack) { + public boolean isItemValidForSlot(int slot, ItemStack itemstack) + { return slot == 0; } - // IFluidHandler @Override - public FluidTankInfo[] getTankInfo(EnumFacing from) { + public FluidTankInfo[] getTankInfo(EnumFacing from) + { return new FluidTankInfo[0]; } @Override - public int fill(EnumFacing from, FluidStack resource, boolean doFill) { + public int fill(EnumFacing from, FluidStack resource, boolean doFill) + { return 0; } @Override - public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) { + public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) + { return null; } @Override - public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) { + public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) + { return null; } @Override - public boolean canFill(EnumFacing from, Fluid fluid) { + public boolean canFill(EnumFacing from, Fluid fluid) + { return false; } @Override - public boolean canDrain(EnumFacing from, Fluid fluid) { + public boolean canDrain(EnumFacing from, Fluid fluid) + { return false; } // IFluidTank @Override - public FluidStack getFluid() { + public FluidStack getFluid() + { return bloodAltar.getFluid(); } @Override - public int getFluidAmount() { + public int getFluidAmount() + { return bloodAltar.getFluidAmount(); } @Override - public FluidTankInfo getInfo() { + public FluidTankInfo getInfo() + { return new FluidTankInfo(this); } @Override - public int fill(FluidStack resource, boolean doFill) { + public int fill(FluidStack resource, boolean doFill) + { return 0; } @Override - public FluidStack drain(int maxDrain, boolean doDrain) { + public FluidStack drain(int maxDrain, boolean doDrain) + { return null; } - @Override - public int getCapacity() { - return bloodAltar.getCapacity(); - } - - @Override - public int getCurrentBlood() { - return bloodAltar.getCurrentBlood(); - } - - @Override - public EnumAltarTier getTier() { - return bloodAltar.getTier(); - } - - @Override - public int getProgress() { - return bloodAltar.getProgress(); - } - - @Override - public float getSacrificeMultiplier() { - return bloodAltar.getSacrificeMultiplier(); - } - - @Override - public float getSelfSacrificeMultiplier() { - return bloodAltar.getSelfSacrificeMultiplier(); - } - - @Override - public float getOrbMultiplier() { - return bloodAltar.getOrbMultiplier(); - } - - @Override - public float getDislocationMultiplier() { - return bloodAltar.getDislocationMultiplier(); - } + @Override + public int getCapacity() + { + return bloodAltar.getCapacity(); + } @Override - public float getConsumptionMultiplier() { + public int getCurrentBlood() + { + return bloodAltar.getCurrentBlood(); + } + + @Override + public EnumAltarTier getTier() + { + return bloodAltar.getTier(); + } + + @Override + public int getProgress() + { + return bloodAltar.getProgress(); + } + + @Override + public float getSacrificeMultiplier() + { + return bloodAltar.getSacrificeMultiplier(); + } + + @Override + public float getSelfSacrificeMultiplier() + { + return bloodAltar.getSelfSacrificeMultiplier(); + } + + @Override + public float getOrbMultiplier() + { + return bloodAltar.getOrbMultiplier(); + } + + @Override + public float getDislocationMultiplier() + { + return bloodAltar.getDislocationMultiplier(); + } + + @Override + public float getConsumptionMultiplier() + { return bloodAltar.getConsumptionMultiplier(); } @Override - public float getConsumptionRate() { + public float getConsumptionRate() + { return bloodAltar.getConsumptionRate(); } @Override - public int getLiquidRequired() { + public int getLiquidRequired() + { return bloodAltar.getLiquidRequired(); } - @Override - public int getBufferCapacity() { - return bloodAltar.getBufferCapacity(); - } + @Override + public int getBufferCapacity() + { + return bloodAltar.getBufferCapacity(); + } - @Override - public void startCycle() { - bloodAltar.startCycle(); - } + @Override + public void startCycle() + { + bloodAltar.startCycle(); + } - @Override - public void checkTier() { - bloodAltar.checkTier(); - } + @Override + public void checkTier() + { + bloodAltar.checkTier(); + } - @Override - public void requestPauseAfterCrafting(int cooldown) { - bloodAltar.requestPauseAfterCrafting(cooldown); - } + @Override + public void requestPauseAfterCrafting(int cooldown) + { + bloodAltar.requestPauseAfterCrafting(cooldown); + } - @Override - public boolean isActive() { - return bloodAltar.isActive(); - } + @Override + public boolean isActive() + { + return bloodAltar.isActive(); + } - @Override - public int fillMainTank(int amount) { - return bloodAltar.fillMainTank(amount); - } - - @Override - public void setActive(){ - bloodAltar.setActive(); - } + @Override + public int fillMainTank(int amount) + { + return bloodAltar.fillMainTank(amount); + } + + @Override + public void setActive() + { + bloodAltar.setActive(); + } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileImperfectRitualStone.java b/src/main/java/WayofTime/bloodmagic/tile/TileImperfectRitualStone.java index 75170134..5cf6ca96 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileImperfectRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileImperfectRitualStone.java @@ -12,14 +12,17 @@ import net.minecraft.util.BlockPos; import net.minecraft.world.World; @NoArgsConstructor -public class TileImperfectRitualStone extends TileEntity implements IImperfectRitualStone { +public class TileImperfectRitualStone extends TileEntity implements IImperfectRitualStone +{ // IImperfectRitualStone @Override - public boolean performRitual(World world, BlockPos pos, ImperfectRitual imperfectRitual, EntityPlayer player) { + public boolean performRitual(World world, BlockPos pos, ImperfectRitual imperfectRitual, EntityPlayer player) + { - if (imperfectRitual != null && ImperfectRitualRegistry.ritualEnabled(imperfectRitual)) { + if (imperfectRitual != null && ImperfectRitualRegistry.ritualEnabled(imperfectRitual)) + { NetworkHelper.getSoulNetwork(player, world).syphonAndDamage(imperfectRitual.getActivationCost()); if (imperfectRitual.onActivate(this, player)) if (imperfectRitual.isLightshow()) @@ -30,12 +33,14 @@ public class TileImperfectRitualStone extends TileEntity implements IImperfectRi } @Override - public World getWorld() { + public World getWorld() + { return super.getWorld(); } @Override - public BlockPos getPos() { + public BlockPos getPos() + { return super.getPos(); } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileInventory.java b/src/main/java/WayofTime/bloodmagic/tile/TileInventory.java index 8f9faa05..42a4bc0f 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileInventory.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileInventory.java @@ -17,22 +17,27 @@ import net.minecraft.util.IChatComponent; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -public class TileInventory extends TileEntity implements IInventory { +public class TileInventory extends TileEntity implements IInventory +{ protected int[] syncedSlots = new int[0]; private ItemStack[] inventory; private int size; private String name; - public TileInventory(int size, String name) { + public TileInventory(int size, String name) + { this.inventory = new ItemStack[size]; this.size = size; this.name = name; } - private boolean isSyncedSlot(int slot) { - for (int s : this.syncedSlots) { - if (s == slot) { + private boolean isSyncedSlot(int slot) + { + for (int s : this.syncedSlots) + { + if (s == slot) + { return true; } } @@ -40,17 +45,21 @@ public class TileInventory extends TileEntity implements IInventory { } @Override - public void readFromNBT(NBTTagCompound tagCompound) { + public void readFromNBT(NBTTagCompound tagCompound) + { super.readFromNBT(tagCompound); NBTTagList tags = tagCompound.getTagList("Items", 10); inventory = new ItemStack[getSizeInventory()]; - for (int i = 0; i < tags.tagCount(); i++) { - if (!isSyncedSlot(i)) { + for (int i = 0; i < tags.tagCount(); i++) + { + if (!isSyncedSlot(i)) + { NBTTagCompound data = tags.getCompoundTagAt(i); byte j = data.getByte("Slot"); - if (j >= 0 && j < inventory.length) { + if (j >= 0 && j < inventory.length) + { inventory[j] = ItemStack.loadItemStackFromNBT(data); } } @@ -58,12 +67,15 @@ public class TileInventory extends TileEntity implements IInventory { } @Override - public void writeToNBT(NBTTagCompound tagCompound) { + public void writeToNBT(NBTTagCompound tagCompound) + { super.writeToNBT(tagCompound); NBTTagList tags = new NBTTagList(); - for (int i = 0; i < inventory.length; i++) { - if ((inventory[i] != null) && !isSyncedSlot(i)) { + for (int i = 0; i < inventory.length; i++) + { + if ((inventory[i] != null) && !isSyncedSlot(i)) + { NBTTagCompound data = new NBTTagCompound(); data.setByte("Slot", (byte) i); inventory[i].writeToNBT(data); @@ -75,46 +87,55 @@ public class TileInventory extends TileEntity implements IInventory { } @Override - public Packet getDescriptionPacket() { + public Packet getDescriptionPacket() + { NBTTagCompound nbt = new NBTTagCompound(); writeToNBT(nbt); return new S35PacketUpdateTileEntity(getPos(), -999, nbt); } @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) + { super.onDataPacket(net, pkt); readFromNBT(pkt.getNbtCompound()); } @Override - public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) { + public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) + { return oldState.getBlock() != newState.getBlock(); } - public void dropItems() { + public void dropItems() + { InventoryHelper.dropInventoryItems(getWorld(), getPos(), this); } // IInventory @Override - public int getSizeInventory() { + public int getSizeInventory() + { return size; } @Override - public ItemStack getStackInSlot(int index) { + public ItemStack getStackInSlot(int index) + { return inventory[index]; } @Override - public ItemStack decrStackSize(int index, int count) { - if (inventory[index] != null) { + public ItemStack decrStackSize(int index, int count) + { + if (inventory[index] != null) + { if (!worldObj.isRemote) worldObj.markBlockForUpdate(this.pos); - if (inventory[index].stackSize <= count) { + if (inventory[index].stackSize <= count) + { ItemStack itemStack = inventory[index]; inventory[index] = null; markDirty(); @@ -133,8 +154,10 @@ public class TileInventory extends TileEntity implements IInventory { } @Override - public ItemStack removeStackFromSlot(int slot) { - if (inventory[slot] != null) { + public ItemStack removeStackFromSlot(int slot) + { + if (inventory[slot] != null) + { ItemStack itemStack = inventory[slot]; setInventorySlotContents(slot, null); return itemStack; @@ -143,7 +166,8 @@ public class TileInventory extends TileEntity implements IInventory { } @Override - public void setInventorySlotContents(int slot, ItemStack stack) { + public void setInventorySlotContents(int slot, ItemStack stack) + { inventory[slot] = stack; if (stack != null && stack.stackSize > getInventoryStackLimit()) stack.stackSize = getInventoryStackLimit(); @@ -153,64 +177,76 @@ public class TileInventory extends TileEntity implements IInventory { } @Override - public int getInventoryStackLimit() { + public int getInventoryStackLimit() + { return 64; } @Override - public boolean isUseableByPlayer(EntityPlayer player) { + public boolean isUseableByPlayer(EntityPlayer player) + { return true; } @Override - public void openInventory(EntityPlayer player) { + public void openInventory(EntityPlayer player) + { } @Override - public void closeInventory(EntityPlayer player) { + public void closeInventory(EntityPlayer player) + { } @Override - public boolean isItemValidForSlot(int index, ItemStack stack) { + public boolean isItemValidForSlot(int index, ItemStack stack) + { return true; } @Override - public int getField(int id) { + public int getField(int id) + { return 0; } @Override - public void setField(int id, int value) { + public void setField(int id, int value) + { } @Override - public int getFieldCount() { + public int getFieldCount() + { return 0; } @Override - public void clear() { + public void clear() + { this.inventory = new ItemStack[size]; } // IWorldNameable @Override - public String getName() { + public String getName() + { return StatCollector.translateToLocal("tile.BloodMagic." + name + ".name"); } @Override - public boolean hasCustomName() { + public boolean hasCustomName() + { return true; } @Override - public IChatComponent getDisplayName() { + public IChatComponent getDisplayName() + { return new ChatComponentTranslation("tile.BloodMagic." + name + ".name"); } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java b/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java index 7657542e..e692825b 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java @@ -29,171 +29,197 @@ import net.minecraftforge.fml.common.eventhandler.Event; @Getter @NoArgsConstructor -public class TileMasterRitualStone extends TileEntity implements IMasterRitualStone, ITickable { +public class TileMasterRitualStone extends TileEntity implements IMasterRitualStone, ITickable +{ - public static final int UPDATE_TIME = 20; + public static final int UPDATE_TIME = 20; - private String owner; - private boolean active; - private int activeTime; - private int cooldown; - private Ritual currentRitual; - @Setter - private EnumFacing direction = EnumFacing.NORTH; + private String owner; + private boolean active; + private int activeTime; + private int cooldown; + private Ritual currentRitual; + @Setter + private EnumFacing direction = EnumFacing.NORTH; - @Override - public void update() { - if (getCurrentRitual() != null && isActive()) { - if (activeTime % getCurrentRitual().getRefreshTime() == 0) - performRitual(getWorld(), getPos()); + @Override + public void update() + { + if (getCurrentRitual() != null && isActive()) + { + if (activeTime % getCurrentRitual().getRefreshTime() == 0) + performRitual(getWorld(), getPos()); - activeTime++; - } - } + activeTime++; + } + } - @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - owner = tag.getString(Constants.NBT.OWNER_UUID); - currentRitual = RitualRegistry.getRitualForId(tag.getString(Constants.NBT.CURRENT_RITUAL)); - active = tag.getBoolean(Constants.NBT.IS_RUNNING); - activeTime = tag.getInteger(Constants.NBT.RUNTIME); - direction = EnumFacing.VALUES[tag.getInteger(Constants.NBT.DIRECTION)]; - } + @Override + public void readFromNBT(NBTTagCompound tag) + { + super.readFromNBT(tag); + owner = tag.getString(Constants.NBT.OWNER_UUID); + currentRitual = RitualRegistry.getRitualForId(tag.getString(Constants.NBT.CURRENT_RITUAL)); + active = tag.getBoolean(Constants.NBT.IS_RUNNING); + activeTime = tag.getInteger(Constants.NBT.RUNTIME); + direction = EnumFacing.VALUES[tag.getInteger(Constants.NBT.DIRECTION)]; + } - @Override - public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(tag); - String ritualId = RitualRegistry.getIdForRitual(getCurrentRitual()); - tag.setString(Constants.NBT.OWNER_UUID, Strings.isNullOrEmpty(getOwner()) ? "" : getOwner()); - tag.setString(Constants.NBT.CURRENT_RITUAL, Strings.isNullOrEmpty(ritualId) ? "" : ritualId); - tag.setBoolean(Constants.NBT.IS_RUNNING, isActive()); - tag.setInteger(Constants.NBT.RUNTIME, getActiveTime()); - tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex()); - } + @Override + public void writeToNBT(NBTTagCompound tag) + { + super.writeToNBT(tag); + String ritualId = RitualRegistry.getIdForRitual(getCurrentRitual()); + tag.setString(Constants.NBT.OWNER_UUID, Strings.isNullOrEmpty(getOwner()) ? "" : getOwner()); + tag.setString(Constants.NBT.CURRENT_RITUAL, Strings.isNullOrEmpty(ritualId) ? "" : ritualId); + tag.setBoolean(Constants.NBT.IS_RUNNING, isActive()); + tag.setInteger(Constants.NBT.RUNTIME, getActiveTime()); + tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex()); + } - @Override - public boolean activateRitual(ItemStack activationCrystal, EntityPlayer activator, Ritual ritual) { + @Override + public boolean activateRitual(ItemStack activationCrystal, EntityPlayer activator, Ritual ritual) + { - if (PlayerHelper.isFakePlayer(activator)) - return false; + if (PlayerHelper.isFakePlayer(activator)) + return false; - activationCrystal = NBTHelper.checkNBT(activationCrystal); - String crystalOwner = activationCrystal.getTagCompound().getString(Constants.NBT.OWNER_UUID); + activationCrystal = NBTHelper.checkNBT(activationCrystal); + String crystalOwner = activationCrystal.getTagCompound().getString(Constants.NBT.OWNER_UUID); - if (!Strings.isNullOrEmpty(crystalOwner) && ritual != null) { - if (activationCrystal.getItem() instanceof ItemActivationCrystal) { - int crystalLevel = ((ItemActivationCrystal) activationCrystal.getItem()).getCrystalLevel(activationCrystal); - if (RitualHelper.canCrystalActivate(ritual, crystalLevel)) { + if (!Strings.isNullOrEmpty(crystalOwner) && ritual != null) + { + if (activationCrystal.getItem() instanceof ItemActivationCrystal) + { + int crystalLevel = ((ItemActivationCrystal) activationCrystal.getItem()).getCrystalLevel(activationCrystal); + if (RitualHelper.canCrystalActivate(ritual, crystalLevel)) + { - SoulNetwork network = NetworkHelper.getSoulNetwork(crystalOwner, getWorld()); + SoulNetwork network = NetworkHelper.getSoulNetwork(crystalOwner, getWorld()); - if (network.getCurrentEssence() < ritual.getActivationCost()) { - ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.weak"); - return false; - } + if (network.getCurrentEssence() < ritual.getActivationCost()) + { + ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.weak"); + return false; + } - if (currentRitual != null) - currentRitual.stopRitual(this, Ritual.BreakType.ACTIVATE); + if (currentRitual != null) + currentRitual.stopRitual(this, Ritual.BreakType.ACTIVATE); - RitualEvent.RitualActivatedEvent event = new RitualEvent.RitualActivatedEvent(this, crystalOwner, ritual, activator, activationCrystal, crystalLevel); + RitualEvent.RitualActivatedEvent event = new RitualEvent.RitualActivatedEvent(this, crystalOwner, ritual, activator, activationCrystal, crystalLevel); - if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) { - ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.prevent"); - return false; - } + if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) + { + ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.prevent"); + return false; + } - if (ritual.activateRitual(this, activator)) { - network.syphon(ritual.getActivationCost()); - ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.activate"); - this.active = true; - this.owner = crystalOwner; // Set the owner of the - // ritual to the crystal's - // owner - this.currentRitual = ritual; + if (ritual.activateRitual(this, activator)) + { + network.syphon(ritual.getActivationCost()); + ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.activate"); + this.active = true; + this.owner = crystalOwner; // Set the owner of the + // ritual to the crystal's + // owner + this.currentRitual = ritual; - return true; - } - } - } - } else { - ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.notValid"); - } + return true; + } + } + } + } else + { + ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.notValid"); + } - return false; - } + return false; + } - @Override - public void performRitual(World world, BlockPos pos) { - if (getCurrentRitual() != null && RitualRegistry.ritualEnabled(getCurrentRitual()) && RitualHelper.checkValidRitual(getWorld(), getPos(), RitualRegistry.getIdForRitual(currentRitual), getDirection())) { - RitualEvent.RitualRunEvent event = new RitualEvent.RitualRunEvent(this, getOwner(), getCurrentRitual()); + @Override + public void performRitual(World world, BlockPos pos) + { + if (getCurrentRitual() != null && RitualRegistry.ritualEnabled(getCurrentRitual()) && RitualHelper.checkValidRitual(getWorld(), getPos(), RitualRegistry.getIdForRitual(currentRitual), getDirection())) + { + RitualEvent.RitualRunEvent event = new RitualEvent.RitualRunEvent(this, getOwner(), getCurrentRitual()); - if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) - return; + if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) + return; - SoulNetwork network = NetworkHelper.getSoulNetwork(getOwner(), getWorld()); - network.syphonAndDamage(getCurrentRitual().getRefreshCost()); - getCurrentRitual().performRitual(this); - } - } + SoulNetwork network = NetworkHelper.getSoulNetwork(getOwner(), getWorld()); + network.syphonAndDamage(getCurrentRitual().getRefreshCost()); + getCurrentRitual().performRitual(this); + } + } - @Override - public void stopRitual(Ritual.BreakType breakType) { - if (getCurrentRitual() != null) { - RitualEvent.RitualStopEvent event = new RitualEvent.RitualStopEvent(this, getOwner(), getCurrentRitual(), breakType); + @Override + public void stopRitual(Ritual.BreakType breakType) + { + if (getCurrentRitual() != null) + { + RitualEvent.RitualStopEvent event = new RitualEvent.RitualStopEvent(this, getOwner(), getCurrentRitual(), breakType); - if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) - return; + if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) + return; - getCurrentRitual().stopRitual(this, breakType); - this.currentRitual = null; - this.active = false; - this.activeTime = 0; - } - } + getCurrentRitual().stopRitual(this, breakType); + this.currentRitual = null; + this.active = false; + this.activeTime = 0; + } + } - @Override - public int getCooldown() { - return cooldown; - } + @Override + public int getCooldown() + { + return cooldown; + } - @Override - public void setCooldown(int cooldown) { - this.cooldown = cooldown; - } + @Override + public void setCooldown(int cooldown) + { + this.cooldown = cooldown; + } - @Override - public void setActive(boolean active) { - this.active = active; - } + @Override + public void setActive(boolean active) + { + this.active = active; + } - @Override - public EnumFacing getDirection() { - return direction; - } + @Override + public EnumFacing getDirection() + { + return direction; + } - @Override - public boolean areTanksEmpty() { - return false; - } + @Override + public boolean areTanksEmpty() + { + return false; + } - @Override - public int getRunningTime() { - return activeTime; - } + @Override + public int getRunningTime() + { + return activeTime; + } - @Override - public String getOwner() { - return owner; - } + @Override + public String getOwner() + { + return owner; + } - @Override - public World getWorld() { - return super.getWorld(); - } + @Override + public World getWorld() + { + return super.getWorld(); + } - @Override - public BlockPos getPos() { - return super.getPos(); - } + @Override + public BlockPos getPos() + { + return super.getPos(); + } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TilePhantomBlock.java b/src/main/java/WayofTime/bloodmagic/tile/TilePhantomBlock.java index e826d779..9a28fdfb 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TilePhantomBlock.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TilePhantomBlock.java @@ -5,35 +5,42 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ITickable; -public class TilePhantomBlock extends TileEntity implements ITickable { +public class TilePhantomBlock extends TileEntity implements ITickable +{ private int ticksRemaining; - public TilePhantomBlock() { + public TilePhantomBlock() + { } @Override - public void readFromNBT(NBTTagCompound tagCompound) { + public void readFromNBT(NBTTagCompound tagCompound) + { super.readFromNBT(tagCompound); ticksRemaining = tagCompound.getInteger(Constants.NBT.TICKS_REMAINING); } @Override - public void writeToNBT(NBTTagCompound tagCompound) { + public void writeToNBT(NBTTagCompound tagCompound) + { super.writeToNBT(tagCompound); tagCompound.setInteger(Constants.NBT.TICKS_REMAINING, ticksRemaining); } @Override - public void update() { + public void update() + { ticksRemaining--; - if (ticksRemaining <= 0) { + if (ticksRemaining <= 0) + { worldObj.setBlockToAir(pos); } } - public void setDuration(int duration) { + public void setDuration(int duration) + { ticksRemaining = duration; } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TilePlinth.java b/src/main/java/WayofTime/bloodmagic/tile/TilePlinth.java index 7fd93b67..634878e7 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TilePlinth.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TilePlinth.java @@ -1,8 +1,10 @@ package WayofTime.bloodmagic.tile; -public class TilePlinth extends TileInventory { +public class TilePlinth extends TileInventory +{ - public TilePlinth() { + public TilePlinth() + { super(1, "plinth"); } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileSpectralBlock.java b/src/main/java/WayofTime/bloodmagic/tile/TileSpectralBlock.java index 75a31512..cd4eb3b7 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileSpectralBlock.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileSpectralBlock.java @@ -11,17 +11,20 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.ITickable; import net.minecraft.world.World; -public class TileSpectralBlock extends TileEntity implements ITickable { +public class TileSpectralBlock extends TileEntity implements ITickable +{ private int ticksRemaining; private String containedBlockName; private int containedBlockMeta; - public TileSpectralBlock() { + public TileSpectralBlock() + { } @Override - public void readFromNBT(NBTTagCompound tagCompound) { + public void readFromNBT(NBTTagCompound tagCompound) + { super.readFromNBT(tagCompound); ticksRemaining = tagCompound.getInteger(Constants.NBT.TICKS_REMAINING); containedBlockName = tagCompound.getString(Constants.NBT.CONTAINED_BLOCK_NAME); @@ -29,7 +32,8 @@ public class TileSpectralBlock extends TileEntity implements ITickable { } @Override - public void writeToNBT(NBTTagCompound tagCompound) { + public void writeToNBT(NBTTagCompound tagCompound) + { super.writeToNBT(tagCompound); tagCompound.setInteger(Constants.NBT.TICKS_REMAINING, ticksRemaining); tagCompound.setString(Constants.NBT.CONTAINED_BLOCK_NAME, containedBlockName); @@ -37,28 +41,35 @@ public class TileSpectralBlock extends TileEntity implements ITickable { } @Override - public void update() { + public void update() + { ticksRemaining--; - if (ticksRemaining <= 0) { + if (ticksRemaining <= 0) + { returnContainedBlock(); } } - private void setContainedBlockInfo(IBlockState blockState) { + private void setContainedBlockInfo(IBlockState blockState) + { containedBlockName = blockState.getBlock().getUnlocalizedName().substring(5); containedBlockMeta = blockState.getBlock().getMetaFromState(blockState); } - private void setDuration(int duration) { + private void setDuration(int duration) + { ticksRemaining = duration; } - public void resetDuration(int reset) { - if (ticksRemaining < reset) ticksRemaining = reset; + public void resetDuration(int reset) + { + if (ticksRemaining < reset) + ticksRemaining = reset; } - public void returnContainedBlock() { + public void returnContainedBlock() + { Block block = null; if (!Strings.isNullOrEmpty(containedBlockName)) @@ -68,8 +79,10 @@ public class TileSpectralBlock extends TileEntity implements ITickable { worldObj.markBlockForUpdate(pos); } - public static void createSpectralBlock(World world, BlockPos blockPos, int duration) { - if (world.isAirBlock(blockPos)) return; + public static void createSpectralBlock(World world, BlockPos blockPos, int duration) + { + if (world.isAirBlock(blockPos)) + return; IBlockState cachedState = world.getBlockState(blockPos); world.setBlockState(blockPos, ModBlocks.spectralBlock.getDefaultState()); TileSpectralBlock tile = (TileSpectralBlock) world.getTileEntity(blockPos); diff --git a/src/main/java/WayofTime/bloodmagic/util/ChatUtil.java b/src/main/java/WayofTime/bloodmagic/util/ChatUtil.java index 840d3b28..0b13fc20 100644 --- a/src/main/java/WayofTime/bloodmagic/util/ChatUtil.java +++ b/src/main/java/WayofTime/bloodmagic/util/ChatUtil.java @@ -15,121 +15,147 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -public class ChatUtil { +public class ChatUtil +{ private static final int DELETION_ID = 2525277; private static int lastAdded; - private static void sendNoSpamMessages(IChatComponent[] messages) { + private static void sendNoSpamMessages(IChatComponent[] messages) + { GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI(); - for (int i = DELETION_ID + messages.length - 1; i <= lastAdded; i++) { + for (int i = DELETION_ID + messages.length - 1; i <= lastAdded; i++) + { chat.deleteChatLine(i); } - for (int i = 0; i < messages.length; i++) { + for (int i = 0; i < messages.length; i++) + { chat.printChatMessageWithOptionalDeletion(messages[i], DELETION_ID + i); } lastAdded = DELETION_ID + messages.length - 1; } /** - * Returns a standard {@link ChatComponentText} for the given {@link String}. - * - * @param s The string to wrap. - * + * Returns a standard {@link ChatComponentText} for the given {@link String} + * . + * + * @param s + * The string to wrap. + * * @return An {@link IChatComponent} containing the string. */ - public static IChatComponent wrap(String s) { + public static IChatComponent wrap(String s) + { return new ChatComponentText(s); } /** * @see #wrap(String) */ - public static IChatComponent[] wrap(String... s) { + public static IChatComponent[] wrap(String... s) + { IChatComponent[] ret = new IChatComponent[s.length]; - for (int i = 0; i < ret.length; i++) { + for (int i = 0; i < ret.length; i++) + { ret[i] = wrap(s[i]); } return ret; } /** - * Returns a translatable chat component for the given string and format args. - * - * @param s The string to format - * @param args The args to apply to the format + * Returns a translatable chat component for the given string and format + * args. + * + * @param s + * The string to format + * @param args + * The args to apply to the format */ - public static IChatComponent wrapFormatted(String s, Object... args) { + public static IChatComponent wrapFormatted(String s, Object... args) + { return new ChatComponentTranslation(s, args); } /** * Simply sends the passed lines to the player in a chat message. - * - * @param player The player to send the chat to - * @param lines The lines to send + * + * @param player + * The player to send the chat to + * @param lines + * The lines to send */ - public static void sendChat(EntityPlayer player, String... lines) { + public static void sendChat(EntityPlayer player, String... lines) + { sendChat(player, wrap(lines)); } /** * Localizes the lines before sending them. - * + * * @see #sendChat(EntityPlayer, String...) */ - public static void sendChatUnloc(EntityPlayer player, String... unlocLines) { + public static void sendChatUnloc(EntityPlayer player, String... unlocLines) + { sendChat(player, TextHelper.localizeAll(unlocLines)); } /** * Sends all passed chat components to the player. - * - * @param player The player to send the chat lines to. - * @param lines The {@link IChatComponent chat components} to send.yes + * + * @param player + * The player to send the chat lines to. + * @param lines + * The {@link IChatComponent chat components} to send.yes */ - public static void sendChat(EntityPlayer player, IChatComponent... lines) { - for (IChatComponent c : lines) { + public static void sendChat(EntityPlayer player, IChatComponent... lines) + { + for (IChatComponent c : lines) + { player.addChatComponentMessage(c); } } /** * Localizes the strings before sending them. - * + * * @see #sendNoSpamClient(String...) */ - public static void sendNoSpamClientUnloc(String... unlocLines) { + public static void sendNoSpamClientUnloc(String... unlocLines) + { sendNoSpamClient(TextHelper.localizeAll(unlocLines)); } /** - * Same as {@link #sendNoSpamClient(IChatComponent...)}, but wraps the Strings - * automatically. - * - * @param lines The chat lines to send - * + * Same as {@link #sendNoSpamClient(IChatComponent...)}, but wraps the + * Strings automatically. + * + * @param lines + * The chat lines to send + * * @see #wrap(String) */ - public static void sendNoSpamClient(String... lines) { + public static void sendNoSpamClient(String... lines) + { sendNoSpamClient(wrap(lines)); } /** * Skips the packet sending, unsafe to call on servers. - * + * * @see #sendNoSpam(EntityPlayerMP, IChatComponent...) */ - public static void sendNoSpamClient(IChatComponent... lines) { + public static void sendNoSpamClient(IChatComponent... lines) + { sendNoSpamMessages(lines); } /** * Localizes the strings before sending them. - * + * * @see #sendNoSpam(EntityPlayer, String...) */ - public static void sendNoSpamUnloc(EntityPlayer player, String... unlocLines) { + public static void sendNoSpamUnloc(EntityPlayer player, String... unlocLines) + { sendNoSpam(player, TextHelper.localizeAll(unlocLines)); } @@ -137,28 +163,32 @@ public class ChatUtil { * @see #wrap(String) * @see #sendNoSpam(EntityPlayer, IChatComponent...) */ - public static void sendNoSpam(EntityPlayer player, String... lines) { + public static void sendNoSpam(EntityPlayer player, String... lines) + { sendNoSpam(player, wrap(lines)); } /** * First checks if the player is instanceof {@link EntityPlayerMP} before * casting. - * + * * @see #sendNoSpam(EntityPlayerMP, IChatComponent...) */ - public static void sendNoSpam(EntityPlayer player, IChatComponent... lines) { - if (player instanceof EntityPlayerMP) { + public static void sendNoSpam(EntityPlayer player, IChatComponent... lines) + { + if (player instanceof EntityPlayerMP) + { sendNoSpam((EntityPlayerMP) player, lines); } } /** * Localizes the strings before sending them. - * + * * @see #sendNoSpam(EntityPlayerMP, String...) */ - public static void sendNoSpamUnloc(EntityPlayerMP player, String... unlocLines) { + public static void sendNoSpamUnloc(EntityPlayerMP player, String... unlocLines) + { sendNoSpam(player, TextHelper.localizeAll(unlocLines)); } @@ -166,62 +196,75 @@ public class ChatUtil { * @see #wrap(String) * @see #sendNoSpam(EntityPlayerMP, IChatComponent...) */ - public static void sendNoSpam(EntityPlayerMP player, String... lines) { + public static void sendNoSpam(EntityPlayerMP player, String... lines) + { sendNoSpam(player, wrap(lines)); } /** * Sends a chat message to the client, deleting past messages also sent via * this method. - * + * * Credit to RWTema for the idea - * - * @param player The player to send the chat message to - * @param lines The chat lines to send. + * + * @param player + * The player to send the chat message to + * @param lines + * The chat lines to send. */ - public static void sendNoSpam(EntityPlayerMP player, IChatComponent... lines) { + public static void sendNoSpam(EntityPlayerMP player, IChatComponent... lines) + { if (lines.length > 0) BloodMagicPacketHandler.INSTANCE.sendTo(new PacketNoSpamChat(lines), player); } /** * @author tterrag1098 - * + * * Ripped from EnderCore (and slightly altered) */ - public static class PacketNoSpamChat implements IMessage { + public static class PacketNoSpamChat implements IMessage + { private IChatComponent[] chatLines; - public PacketNoSpamChat() { + public PacketNoSpamChat() + { chatLines = new IChatComponent[0]; } - private PacketNoSpamChat(IChatComponent... lines) { + private PacketNoSpamChat(IChatComponent... lines) + { // this is guaranteed to be >1 length by accessing methods this.chatLines = lines; } @Override - public void toBytes(ByteBuf buf) { + public void toBytes(ByteBuf buf) + { buf.writeInt(chatLines.length); - for (IChatComponent c : chatLines) { + for (IChatComponent c : chatLines) + { ByteBufUtils.writeUTF8String(buf, IChatComponent.Serializer.componentToJson(c)); } } @Override - public void fromBytes(ByteBuf buf) { + public void fromBytes(ByteBuf buf) + { chatLines = new IChatComponent[buf.readInt()]; - for (int i = 0; i < chatLines.length; i++) { + for (int i = 0; i < chatLines.length; i++) + { chatLines[i] = IChatComponent.Serializer.jsonToComponent(ByteBufUtils.readUTF8String(buf)); } } - public static class Handler implements IMessageHandler { + public static class Handler implements IMessageHandler + { @Override - public IMessage onMessage(PacketNoSpamChat message, MessageContext ctx) { + public IMessage onMessage(PacketNoSpamChat message, MessageContext ctx) + { sendNoSpamMessages(message.chatLines); return null; } diff --git a/src/main/java/WayofTime/bloodmagic/util/Utils.java b/src/main/java/WayofTime/bloodmagic/util/Utils.java index d4f0fcb2..e74550a9 100644 --- a/src/main/java/WayofTime/bloodmagic/util/Utils.java +++ b/src/main/java/WayofTime/bloodmagic/util/Utils.java @@ -9,14 +9,19 @@ import WayofTime.bloodmagic.api.altar.EnumAltarComponent; import WayofTime.bloodmagic.registry.ModBlocks; import WayofTime.bloodmagic.tile.TileInventory; -public class Utils { +public class Utils +{ - public static boolean isInteger(String integer) { - try { + public static boolean isInteger(String integer) + { + try + { Integer.parseInt(integer); - } catch (NumberFormatException e) { + } catch (NumberFormatException e) + { return false; - } catch (NullPointerException e) { + } catch (NullPointerException e) + { return false; } // only got here if we didn't return false @@ -24,27 +29,35 @@ public class Utils { } /** - * Used for inserting an ItemStack with a stacksize of 1 to a tile's inventory at slot 0. - * Returns {@code true} if the ItemStack is inserted, {@code false} otherwise - * + * Used for inserting an ItemStack with a stacksize of 1 to a tile's + * inventory at slot 0. Returns {@code true} if the ItemStack is inserted, + * {@code false} otherwise + * * EG: Block Altar - * - * @param tile - The {@link TileInventory} to input the item to - * @param player - The player to take the item from. + * + * @param tile + * - The {@link TileInventory} to input the item to + * @param player + * - The player to take the item from. */ - public static boolean insertItemToTile(TileInventory tile, EntityPlayer player) { + public static boolean insertItemToTile(TileInventory tile, EntityPlayer player) + { return insertItemToTile(tile, player, 0); } - - public static boolean insertItemToTile(TileInventory tile, EntityPlayer player, int slot) { - if (tile.getStackInSlot(slot) == null && player.getHeldItem() != null) { + + public static boolean insertItemToTile(TileInventory tile, EntityPlayer player, int slot) + { + if (tile.getStackInSlot(slot) == null && player.getHeldItem() != null) + { ItemStack input = player.getHeldItem().copy(); input.stackSize = 1; player.getHeldItem().stackSize--; tile.setInventorySlotContents(slot, input); return true; - } else if (tile.getStackInSlot(slot) != null && player.getHeldItem() == null) { - if (!tile.getWorld().isRemote) { + } else if (tile.getStackInSlot(slot) != null && player.getHeldItem() == null) + { + if (!tile.getWorld().isRemote) + { EntityItem invItem = new EntityItem(tile.getWorld(), player.posX, player.posY + 0.25, player.posZ, tile.getStackInSlot(slot)); tile.getWorld().spawnEntityInWorld(invItem); } @@ -55,15 +68,24 @@ public class Utils { return false; } - public static Block getBlockForComponent(EnumAltarComponent component) { - switch (component) { - case GLOWSTONE: return Blocks.glowstone; - case BLOODSTONE: return ModBlocks.bloodStoneBrick; - case BEACON: return Blocks.beacon; - case BLOODRUNE: return ModBlocks.bloodRune; - case CRYSTAL: return ModBlocks.crystal; - case NOTAIR: return Blocks.stonebrick; - default: return Blocks.air; + public static Block getBlockForComponent(EnumAltarComponent component) + { + switch (component) + { + case GLOWSTONE: + return Blocks.glowstone; + case BLOODSTONE: + return ModBlocks.bloodStoneBrick; + case BEACON: + return Blocks.beacon; + case BLOODRUNE: + return ModBlocks.bloodRune; + case CRYSTAL: + return ModBlocks.crystal; + case NOTAIR: + return Blocks.stonebrick; + default: + return Blocks.air; } } } diff --git a/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java b/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java index 419314b9..e4fc9139 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java @@ -21,17 +21,21 @@ import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -public class EventHandler { +public class EventHandler +{ @SubscribeEvent - public void onEntityDeath(LivingHurtEvent event) { + public void onEntityDeath(LivingHurtEvent event) + { int chestIndex = 2; - if (event.source.getEntity() instanceof EntityPlayer && !PlayerHelper.isFakePlayer((EntityPlayer) event.source.getEntity())) { + if (event.source.getEntity() instanceof EntityPlayer && !PlayerHelper.isFakePlayer((EntityPlayer) event.source.getEntity())) + { EntityPlayer player = (EntityPlayer) event.source.getEntity(); - if (player.getCurrentArmor(chestIndex) != null && player.getCurrentArmor(chestIndex).getItem() instanceof ItemPackSacrifice) { + if (player.getCurrentArmor(chestIndex) != null && player.getCurrentArmor(chestIndex).getItem() instanceof ItemPackSacrifice) + { ItemPackSacrifice pack = (ItemPackSacrifice) player.getCurrentArmor(chestIndex).getItem(); boolean shouldSyphon = pack.getStoredLP(player.getCurrentArmor(chestIndex)) < pack.CAPACITY; @@ -44,7 +48,8 @@ public class EventHandler { } @SubscribeEvent - public void onBucketFill(FillBucketEvent event) { + public void onBucketFill(FillBucketEvent event) + { if (event.current.getItem() != Items.bucket) return; @@ -52,7 +57,8 @@ public class EventHandler { Block block = event.world.getBlockState(event.target.getBlockPos()).getBlock(); - if (block != null && (block.equals(ModBlocks.lifeEssence)) && block.getMetaFromState(event.world.getBlockState(event.target.getBlockPos())) == 0) { + if (block != null && (block.equals(ModBlocks.lifeEssence)) && block.getMetaFromState(event.world.getBlockState(event.target.getBlockPos())) == 0) + { event.world.setBlockToAir(event.target.getBlockPos()); result = new ItemStack(ModItems.bucketEssence); } @@ -65,17 +71,22 @@ public class EventHandler { } @SubscribeEvent - public void harvestEvent(PlayerEvent.HarvestCheck event) { - if (event.block != null && event.block instanceof BlockAltar && event.entityPlayer != null && event.entityPlayer instanceof EntityPlayerMP && event.entityPlayer.getCurrentEquippedItem() != null && event.entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemAltarMaker) { + public void harvestEvent(PlayerEvent.HarvestCheck event) + { + if (event.block != null && event.block instanceof BlockAltar && event.entityPlayer != null && event.entityPlayer instanceof EntityPlayerMP && event.entityPlayer.getCurrentEquippedItem() != null && event.entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemAltarMaker) + { ItemAltarMaker altarMaker = (ItemAltarMaker) event.entityPlayer.getCurrentEquippedItem().getItem(); ChatUtil.sendNoSpam(event.entityPlayer, TextHelper.localizeEffect("chat.BloodMagic.altarMaker.destroy", altarMaker.destroyAltar(event.entityPlayer))); } } @SubscribeEvent - public void onBlockBreak(BlockEvent.BreakEvent event) { - if (!event.world.isRemote && event.getPlayer() != null) { - if (event.getPlayer().capabilities.isCreativeMode && event.getPlayer().getCurrentEquippedItem() != null && event.getPlayer().getCurrentEquippedItem().getItem() instanceof ItemBoundSword) { + public void onBlockBreak(BlockEvent.BreakEvent event) + { + if (!event.world.isRemote && event.getPlayer() != null) + { + if (event.getPlayer().capabilities.isCreativeMode && event.getPlayer().getCurrentEquippedItem() != null && event.getPlayer().getCurrentEquippedItem().getItem() instanceof ItemBoundSword) + { event.setCanceled(true); } } diff --git a/src/main/java/WayofTime/bloodmagic/util/helper/InventoryRenderHelper.java b/src/main/java/WayofTime/bloodmagic/util/helper/InventoryRenderHelper.java index 00d45bed..399653cb 100644 --- a/src/main/java/WayofTime/bloodmagic/util/helper/InventoryRenderHelper.java +++ b/src/main/java/WayofTime/bloodmagic/util/helper/InventoryRenderHelper.java @@ -14,36 +14,42 @@ import net.minecraftforge.client.model.ModelLoader; /** * @author TehNut - * + * * The goal of this class is to make registering the inventory renders * for your Items/Blocks a much simpler and easier process. - * - * You must call this at the post initialization stage on - * the clientside only. - * - * If you pass a Block through here that uses the default - * ItemBlock, you should specify a custom name. + * + * You must call this at the post initialization stage on the clientside + * only. + * + * If you pass a Block through here that uses the default ItemBlock, you + * should specify a custom name. */ -public class InventoryRenderHelper { +public class InventoryRenderHelper +{ /** - * This is the base string for your resources. It will usually be - * your modid in all lowercase with a colon at the end. + * This is the base string for your resources. It will usually be your modid + * in all lowercase with a colon at the end. */ private final String domain; - public InventoryRenderHelper(String domain) { + public InventoryRenderHelper(String domain) + { this.domain = domain; } /** * Registers a Model for the given Item and meta. - * - * @param item - Item to register Model for - * @param meta - Meta of Item - * @param name - Name of the model JSON + * + * @param item + * - Item to register Model for + * @param meta + * - Meta of Item + * @param name + * - Name of the model JSON */ - public void itemRender(Item item, int meta, String name) { + public void itemRender(Item item, int meta, String name) + { String resName = domain + name; ModelBakery.addVariantName(item, resName); @@ -52,83 +58,103 @@ public class InventoryRenderHelper { /** * Shorthand of {@code itemRender(Item, int, String)} - * - * @param item - Item to register Model for - * @param meta - Meta of Item + * + * @param item + * - Item to register Model for + * @param meta + * - Meta of Item */ - public void itemRender(Item item, int meta) { + public void itemRender(Item item, int meta) + { itemRender(item, meta, getClassName(item) + meta); } - public void itemRender(Item item, String name) { + public void itemRender(Item item, String name) + { itemRender(item, 0, name); } /** * Shorthand of {@code itemRender(Item, int)} - * - * @param item - Item to register Model for + * + * @param item + * - Item to register Model for */ - public void itemRender(Item item) { + public void itemRender(Item item) + { itemRender(item, 0, getClassName(item)); } /** - * Registers a model for the item across all Meta's that get used for the item - * - * @param item - Item to register Model for + * Registers a model for the item across all Meta's that get used for the + * item + * + * @param item + * - Item to register Model for */ - public void itemRenderAll(Item item) { + public void itemRenderAll(Item item) + { final Item toRender = item; - ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() { + ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() + { @Override - public ModelResourceLocation getModelLocation(ItemStack stack) { + public ModelResourceLocation getModelLocation(ItemStack stack) + { return new ModelResourceLocation(domain + getClassName(toRender), "inventory"); } }); } - public void itemRenderToggle(Item item, String name) { + public void itemRenderToggle(Item item, String name) + { itemRender(item, 0, name + "_deactivated"); itemRender(item, 1, name + "_activated"); } - public void fluidRender(Block block) { + public void fluidRender(Block block) + { final Block toRender = block; ModelBakery.addVariantName(InventoryRenderHelper.getItemFromBlock(block)); - ModelLoader.setCustomMeshDefinition(InventoryRenderHelper.getItemFromBlock(block), new ItemMeshDefinition() { + ModelLoader.setCustomMeshDefinition(InventoryRenderHelper.getItemFromBlock(block), new ItemMeshDefinition() + { @Override - public ModelResourceLocation getModelLocation(ItemStack stack) { + public ModelResourceLocation getModelLocation(ItemStack stack) + { return new ModelResourceLocation(Constants.Mod.DOMAIN + toRender.getClass().getSimpleName(), "fluid"); } }); - ModelLoader.setCustomStateMapper(block, new StateMapperBase() { + ModelLoader.setCustomStateMapper(block, new StateMapperBase() + { @Override - protected ModelResourceLocation getModelResourceLocation(IBlockState state) { + protected ModelResourceLocation getModelResourceLocation(IBlockState state) + { return new ModelResourceLocation(domain + toRender.getClass().getSimpleName(), "fluid"); } }); } /** - * @param block - Block to get Item of - * + * @param block + * - Block to get Item of + * * @return - The ItemBlock that corresponds to the Block. */ - public static Item getItemFromBlock(Block block) { + public static Item getItemFromBlock(Block block) + { return Item.getItemFromBlock(block); } /** * Finds the class name of the given Item. If handed an ItemBlock, it will * use the class name of the contained Block. - * + * * @return The class name of the given Item */ - private static String getClassName(Item item) { + private static String getClassName(Item item) + { return item instanceof ItemBlock ? Block.getBlockFromItem(item).getClass().getSimpleName() : item.getClass().getSimpleName(); } } diff --git a/src/main/java/WayofTime/bloodmagic/util/helper/TextHelper.java b/src/main/java/WayofTime/bloodmagic/util/helper/TextHelper.java index afd8cfa2..99231402 100644 --- a/src/main/java/WayofTime/bloodmagic/util/helper/TextHelper.java +++ b/src/main/java/WayofTime/bloodmagic/util/helper/TextHelper.java @@ -6,21 +6,26 @@ import org.apache.commons.lang3.text.WordUtils; import java.util.ArrayList; import java.util.List; -public class TextHelper { +public class TextHelper +{ - public static String getFormattedText(String string) { + public static String getFormattedText(String string) + { return string.replaceAll("&", "\u00A7"); } - public static String localize(String input, Object... format) { + public static String localize(String input, Object... format) + { return StatCollector.translateToLocalFormatted(input, format); } - public static String localizeEffect(String input, Object... format) { + public static String localizeEffect(String input, Object... format) + { return getFormattedText(localize(input, format)); } - public static String[] localizeAll(String[] input) { + public static String[] localizeAll(String[] input) + { String[] ret = new String[input.length]; for (int i = 0; i < input.length; i++) ret[i] = localize(input[i]); @@ -28,7 +33,8 @@ public class TextHelper { return ret; } - public static String[] localizeAllEffect(String[] input) { + public static String[] localizeAllEffect(String[] input) + { String[] ret = new String[input.length]; for (int i = 0; i < input.length; i++) ret[i] = localizeEffect(input[i]); @@ -36,7 +42,8 @@ public class TextHelper { return ret; } - public static ArrayList localizeAll(List input) { + public static ArrayList localizeAll(List input) + { ArrayList ret = new ArrayList(input.size()); for (int i = 0; i < input.size(); i++) ret.add(i, localize(input.get(i))); @@ -44,7 +51,8 @@ public class TextHelper { return ret; } - public static ArrayList localizeAllEffect(List input) { + public static ArrayList localizeAllEffect(List input) + { ArrayList ret = new ArrayList(input.size()); for (int i = 0; i < input.size(); i++) ret.add(i, localizeEffect(input.get(i))); @@ -52,11 +60,13 @@ public class TextHelper { return ret; } - public static String[] cutLongString(String string, int characters) { + public static String[] cutLongString(String string, int characters) + { return WordUtils.wrap(string, characters, "/cut", false).split("/cut"); } - public static String[] cutLongString(String string) { + public static String[] cutLongString(String string) + { return cutLongString(string, 30); } }