diff --git a/build.gradle b/build.gradle index 646b3816..93480952 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ buildscript { plugins { id "net.minecraftforge.gradle.forge" version "2.0.2" id 'com.matthewprenger.cursegradle' version '1.0.7' - id 'net.franz-becker.gradle-lombok' version '1.5' + id 'io.franzbecker.gradle-lombok' version '1.6' } apply plugin: 'maven-publish' @@ -110,12 +110,16 @@ lombok { sha256 = "e0a471be03e1e6b02bf019480cec7a3ac9801702bf7bf62f15d077ad4df8dd5d" } -import net.franz_becker.gradle.lombok.task.DelombokTask +import io.franzbecker.gradle.lombok.task.DelombokTask task delombok(type: DelombokTask) { args("src/main/java", "-d", "build/sources/delomboked/java") } +task delombokHelp(type: DelombokTask) { + args "--help" +} + tasks.eclipse.dependsOn installLombok jar { diff --git a/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourUpgrade.java b/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourUpgrade.java index 28781588..3aed341f 100644 --- a/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourUpgrade.java +++ b/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourUpgrade.java @@ -35,7 +35,7 @@ public abstract class LivingArmourUpgrade } /** - * Percentage of damage blocked. This stacks multiplicatively with other + * Percentage of damage blocked. This stacks multiplicities with other * upgrades. * * @return 0 for no damage blocked, 1 for full damage blocked @@ -54,9 +54,6 @@ public abstract class LivingArmourUpgrade public abstract String getUnlocalizedName(); - /** - * @return - */ public abstract int getMaxTier(); public abstract int getCostOfUpgrade(); @@ -67,7 +64,7 @@ public abstract class LivingArmourUpgrade public Multimap getAttributeModifiers() { - return HashMultimap.create(); + return HashMultimap.create(); } public abstract void writeToNBT(NBTTagCompound tag); diff --git a/src/main/java/WayofTime/bloodmagic/api/registry/AlchemyArrayRecipeRegistry.java b/src/main/java/WayofTime/bloodmagic/api/registry/AlchemyArrayRecipeRegistry.java index 887bf0f6..88f732c5 100644 --- a/src/main/java/WayofTime/bloodmagic/api/registry/AlchemyArrayRecipeRegistry.java +++ b/src/main/java/WayofTime/bloodmagic/api/registry/AlchemyArrayRecipeRegistry.java @@ -53,9 +53,7 @@ public class AlchemyArrayRecipeRegistry { arrayRecipe.catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect); if (circleRenderer != null) - { arrayRecipe.circleRenderer = circleRenderer; - } return; } } @@ -89,15 +87,7 @@ public class AlchemyArrayRecipeRegistry 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); - } - + AlchemyCircleRenderer circleRenderer = arrayResource == null ? defaultRenderer : new AlchemyCircleRenderer(arrayResource); registerRecipe(inputStack, catalystStack, arrayEffect, circleRenderer); } @@ -109,16 +99,13 @@ public class AlchemyArrayRecipeRegistry 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; - } } } @@ -133,11 +120,7 @@ public class AlchemyArrayRecipeRegistry { 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 arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack); // TODO: Decide if a copy should be returned. } return null; @@ -149,9 +132,7 @@ public class AlchemyArrayRecipeRegistry { AlchemyArrayRecipe arrayRecipe = entry.getValue(); if (arrayRecipe.doesInputMatchRecipe(inputStack)) - { return arrayRecipe.circleRenderer; - } } return defaultRenderer; @@ -181,14 +162,12 @@ public class AlchemyArrayRecipeRegistry * inputStack. * * @param comparedStack - * @return - true if the ItemStack is a compatible item + * - The stack to compare with + * + * @return - True if the ItemStack is a compatible item */ - public boolean doesInputMatchRecipe(ItemStack comparedStack) - { - if (comparedStack == null || this.inputStack == null) - return false; - - return this.inputStack.isItemEqual(comparedStack); + public boolean doesInputMatchRecipe(ItemStack comparedStack) { + return !(comparedStack == null || this.inputStack == null) && this.inputStack.isItemEqual(comparedStack); } /** @@ -196,27 +175,23 @@ public class AlchemyArrayRecipeRegistry * * @param comparedStack * The catalyst that is being checked - * @return + * + * @return - The effect */ public AlchemyArrayEffect getAlchemyArrayEffectForCatalyst(@Nullable ItemStack comparedStack) { for (Entry entry : catalystMap.entrySet()) { ItemStack catalystStack = entry.getKey().toStack(); + if (comparedStack == null && catalystStack == null) - { return entry.getValue(); - } if (comparedStack == null || catalystStack == null) - { continue; - } if (catalystStack.isItemEqual(comparedStack)) - { return entry.getValue(); - } } return null; diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/Ritual.java b/src/main/java/WayofTime/bloodmagic/api/ritual/Ritual.java index e64dbfb5..ef65716a 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/Ritual.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/Ritual.java @@ -86,9 +86,9 @@ public abstract class Ritual public abstract void performRitual(IMasterRitualStone masterRitualStone); /** - * Called when the ritual is stopped for a given {@link BreakType}. + * Called when the ritual is stopped for a given {@link Ritual.BreakType}. * - * {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(BreakType)} + * {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(Ritual.BreakType)} * * @param masterRitualStone * - The {@link IMasterRitualStone} that the ritual is bound to diff --git a/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWill.java b/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWill.java index c1394e74..1ee09c54 100644 --- a/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWill.java +++ b/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWill.java @@ -4,27 +4,49 @@ import net.minecraft.item.ItemStack; public interface IDemonWill { - public double getWill(ItemStack soulStack); + /** + * Obtains the amount of Will an ItemStack contains. + * + * @param willStack + * - The stack to retrieve the Will from + * + * @return - The amount of Will an ItemStack contains + */ + double getWill(ItemStack willStack); - public void setWill(ItemStack willStack, double will); + /** + * Sets the amount of Will in a given ItemStack. + * + * @param willStack + * - The ItemStack of the Will + * @param will + * - The amount of will to set the stack to + */ + void setWill(ItemStack willStack, double will); /** * Drains the demonic will from the willStack. If all of the will is * drained, the willStack will be removed. * * @param willStack + * - The ItemStack of the will * @param drainAmount + * - The amount of Will to drain + * * @return The amount of will drained. */ - public double drainWill(ItemStack willStack, double drainAmount); + double drainWill(ItemStack willStack, double drainAmount); /** * Creates a new ItemStack with the specified number of will. Implementation * should respect the number requested. * * @param meta + * - The meta of the ItemStack to create * @param number - * @return + * - The amount of Will to create the Stack with. + * + * @return - An ItemStack with the set amount of Will */ - public ItemStack createWill(int meta, double number); + ItemStack createWill(int meta, double number); } diff --git a/src/main/java/WayofTime/bloodmagic/api/soul/IDiscreteDemonWill.java b/src/main/java/WayofTime/bloodmagic/api/soul/IDiscreteDemonWill.java index 62de0076..32d659da 100644 --- a/src/main/java/WayofTime/bloodmagic/api/soul/IDiscreteDemonWill.java +++ b/src/main/java/WayofTime/bloodmagic/api/soul/IDiscreteDemonWill.java @@ -4,26 +4,47 @@ import net.minecraft.item.ItemStack; public interface IDiscreteDemonWill { - public double getWill(ItemStack soulStack); + /** + * Obtains the amount of Will an ItemStack contains. + * + * @param soulStack + * - The stack to retrieve the Will from + * + * @return - The amount of Will an ItemStack contains + */ + double getWill(ItemStack soulStack); /** * Drains the demonic will from the willStack. If all of the will is * drained, the willStack will be removed. Will only drain in discrete * amounts, determined by getDiscretization. - * + * * @param willStack + * - The ItemStack of the will * @param drainAmount + * - The amount of Will to drain + * * @return The amount of will drained. */ - public double drainWill(ItemStack willStack, double drainAmount); + double drainWill(ItemStack willStack, double drainAmount); /** * Gets the discrete number for this demonic will. - * + * * @param willStack - * @return + * - The ItemStack of the will + * + * @return - The discrete number for the given stack. */ - public double getDiscretization(ItemStack willStack); + double getDiscretization(ItemStack willStack); - public EnumDemonWillType getType(ItemStack willStack); + /** + * Obtains the type of will this is. + * + * @param willStack + * - The ItemStack of the will + * + * @return - The type of will this is. + */ + EnumDemonWillType getType(ItemStack willStack); } diff --git a/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java b/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java index 29492ec5..48d578ec 100644 --- a/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java +++ b/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java @@ -7,28 +7,30 @@ import net.minecraft.item.ItemStack; * This class provides several helper methods in order to handle soul * consumption and use for a player. This refers to the Soul System, meaning * Monster Souls and Soul Gems, etc. The Soul Network's helper methods are found - * in WayofTime.bloodmagic.api.network - * - * @author WayofTime - * + * in {@link WayofTime.bloodmagic.api.network.SoulNetwork} */ public class PlayerDemonWillHandler { + /** + * Gets the total amount of Will a player contains in their inventory + * + * @param type + * - The type of Will to check for + * @param player + * - The player to check the will of + * + * @return - The amount of will the player contains + */ public static double getTotalDemonWill(EnumDemonWillType type, EntityPlayer player) { ItemStack[] inventory = player.inventory.mainInventory; double souls = 0; - for (int i = 0; i < inventory.length; i++) - { - ItemStack stack = inventory[i]; - if (stack != null) - { - if (stack.getItem() instanceof IDemonWill) - { + for (ItemStack stack : inventory) { + if (stack != null) { + if (stack.getItem() instanceof IDemonWill) { souls += ((IDemonWill) stack.getItem()).getWill(stack); - } else if (stack.getItem() instanceof IDemonWillGem) - { + } else if (stack.getItem() instanceof IDemonWillGem) { souls += ((IDemonWillGem) stack.getItem()).getWill(type, stack); } } @@ -38,28 +40,25 @@ public class PlayerDemonWillHandler } /** - * Checks if the player's Tartaric gems are completely full. If so, it will - * return true. - * + * Checks if the player's Tartaric gems are completely full. + * + * @param type + * - The type of Will to check for + * @param player + * - The player to check the Will of + * + * @return - True if all Will containers are full, false if not. */ public static boolean isDemonWillFull(EnumDemonWillType type, EntityPlayer player) { ItemStack[] inventory = player.inventory.mainInventory; boolean hasGem = false; - for (int i = 0; i < inventory.length; i++) - { - ItemStack stack = inventory[i]; - if (stack != null) - { - if (stack.getItem() instanceof IDemonWillGem) - { - hasGem = true; - if (((IDemonWillGem) stack.getItem()).getWill(type, stack) < ((IDemonWillGem) stack.getItem()).getMaxWill(type, stack)) - { - return false; - } - } + for (ItemStack stack : inventory) { + if (stack != null && stack.getItem() instanceof IDemonWillGem) { + hasGem = true; + if (((IDemonWillGem) stack.getItem()).getWill(type, stack) < ((IDemonWillGem) stack.getItem()).getMaxWill(type, stack)) + return false; } } @@ -67,10 +66,14 @@ public class PlayerDemonWillHandler } /** - * + * Consumes Will from the inventory of a given player + * * @param player + * - The player to consume the will of * @param amount - * @return - amount consumed + * - The amount of will to consume + * + * @return - The amount of will consumed. */ public static double consumeDemonWill(EnumDemonWillType type, EntityPlayer player, double amount) { @@ -81,9 +84,7 @@ public class PlayerDemonWillHandler for (int i = 0; i < inventory.length; i++) { if (consumed >= amount) - { return consumed; - } ItemStack stack = inventory[i]; if (stack != null) @@ -92,9 +93,7 @@ public class PlayerDemonWillHandler { consumed += ((IDemonWill) stack.getItem()).drainWill(stack, amount - consumed); if (((IDemonWill) stack.getItem()).getWill(stack) <= 0) - { inventory[i] = null; - } } else if (stack.getItem() instanceof IDemonWillGem) { consumed += ((IDemonWillGem) stack.getItem()).drainWill(type, stack, amount - consumed); @@ -110,82 +109,91 @@ public class PlayerDemonWillHandler * the player's inventory. * * @param player - * @param soulStack - * - ItemStack that contains an IDemonWill to be added - * @return + * - The player to add will to + * @param willStack + * - ItemStack that contains an IDemonWill to be added + * + * @return - The modified willStack */ - public static ItemStack addDemonWill(EntityPlayer player, ItemStack soulStack) + public static ItemStack addDemonWill(EntityPlayer player, ItemStack willStack) { - if (soulStack == null) - { + if (willStack == null) return null; - } ItemStack[] inventory = player.inventory.mainInventory; - for (int i = 0; i < inventory.length; i++) + for (ItemStack stack : inventory) { - ItemStack stack = inventory[i]; - if (stack != null) + if (stack != null && stack.getItem() instanceof IDemonWillGem) { - if (stack.getItem() instanceof IDemonWillGem) - { - ItemStack newStack = ((IDemonWillGem) stack.getItem()).fillDemonWillGem(stack, soulStack); - if (newStack == null) - { - return null; - } - } + ItemStack newStack = ((IDemonWillGem) stack.getItem()).fillDemonWillGem(stack, willStack); + if (newStack == null) + return null; } } - return soulStack; + return willStack; } + /** + * Adds an IDiscreteDemonWill contained in an ItemStack to one of the Soul Gems in + * the player's inventory. + * + * @param type + * - The type of Will to add + * @param player + * - The player to check the Will of + * @param amount + * - The amount of will to add + * + * @return - The amount of will added + */ public static double addDemonWill(EnumDemonWillType type, EntityPlayer player, double amount) { ItemStack[] inventory = player.inventory.mainInventory; double remaining = amount; - for (int i = 0; i < inventory.length; i++) + for (ItemStack stack : inventory) { - ItemStack stack = inventory[i]; - if (stack != null) + if (stack != null && stack.getItem() instanceof IDemonWillGem) { - if (stack.getItem() instanceof IDemonWillGem) - { - remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining); - - if (remaining <= 0) - { - break; - } - } + remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining); + if (remaining <= 0) + break; } } return amount - remaining; } + /** + * Adds an IDiscreteDemonWill contained in an ItemStack to one of the Soul Gems in + * the player's inventory while ignoring a specified stack. + * + * @param type + * - The type of Will to add + * @param player + * - The player to check the Will of + * @param amount + * - The amount of will to add + * @param ignored + * - A stack to ignore + * + * @return - The amount of will added + */ public static double addDemonWill(EnumDemonWillType type, EntityPlayer player, double amount, ItemStack ignored) { ItemStack[] inventory = player.inventory.mainInventory; double remaining = amount; - for (int i = 0; i < inventory.length; i++) + for (ItemStack stack : inventory) { - ItemStack stack = inventory[i]; - if (stack != null && !stack.equals(ignored)) + if (stack != null && !stack.equals(ignored) && stack.getItem() instanceof IDemonWillGem) { - if (stack.getItem() instanceof IDemonWillGem) - { - remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining); + remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining); - if (remaining <= 0) - { - break; - } - } + if (remaining <= 0) + break; } } diff --git a/src/main/java/WayofTime/bloodmagic/api/teleport/ChunkPairSerializable.java b/src/main/java/WayofTime/bloodmagic/api/teleport/ChunkPairSerializable.java index 35bf837b..fe2db561 100644 --- a/src/main/java/WayofTime/bloodmagic/api/teleport/ChunkPairSerializable.java +++ b/src/main/java/WayofTime/bloodmagic/api/teleport/ChunkPairSerializable.java @@ -9,11 +9,10 @@ import net.minecraft.util.BlockPos; @ToString @EqualsAndHashCode +@Getter public class ChunkPairSerializable implements Serializable { - @Getter private int chunkXPos; - @Getter private int chunkZPos; public ChunkPairSerializable(int chunkXPos, int chunkZPos) @@ -35,34 +34,4 @@ public class ChunkPairSerializable implements Serializable public BlockPos getChunkCenter(){ return getChunkCenter(64); } - - @Override - public boolean equals(Object o) - { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ChunkPairSerializable that = (ChunkPairSerializable) o; - - if (chunkXPos != that.chunkXPos) return false; - return chunkZPos == that.chunkZPos; - - } - - @Override - public int hashCode() - { - int result = chunkXPos; - result = 31 * result + chunkZPos; - return result; - } - - @Override - public String toString() - { - return "ChunkPairSerializable{" + - "chunkXPos=" + chunkXPos + - ", chunkZPos=" + chunkZPos + - '}'; - } } diff --git a/src/main/java/WayofTime/bloodmagic/routing/DefaultItemFilter.java b/src/main/java/WayofTime/bloodmagic/routing/DefaultItemFilter.java index 555fdae7..9d47639b 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/DefaultItemFilter.java +++ b/src/main/java/WayofTime/bloodmagic/routing/DefaultItemFilter.java @@ -52,8 +52,9 @@ public class DefaultItemFilter implements IItemFilter * managing receives an ItemStack. Should only really be called by the Input * filter via it's transfer method. * - * @param stack - * - + * @param inputStack + * - The stack to transfer + * * @return - The remainder of the stack after it has been absorbed into the * inventory. */ diff --git a/src/main/java/WayofTime/bloodmagic/routing/IItemFilter.java b/src/main/java/WayofTime/bloodmagic/routing/IItemFilter.java index 6965c7a7..5ac0ceda 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/IItemFilter.java +++ b/src/main/java/WayofTime/bloodmagic/routing/IItemFilter.java @@ -8,27 +8,28 @@ import net.minecraft.util.EnumFacing; public interface IItemFilter { - public void initializeFilter(List filteredList, IInventory inventory, EnumFacing side, boolean isFilterOutput); + void initializeFilter(List filteredList, IInventory inventory, EnumFacing side, boolean isFilterOutput); /** * This method is only called when the output inventory this filter is * managing receives an ItemStack. Should only really be called by the Input * filter via it's transfer method. * - * @param stack - * - + * @param inputStack + * - The stack to filter + * * @return - The remainder of the stack after it has been absorbed into the * inventory. */ - public ItemStack transferStackThroughOutputFilter(ItemStack inputStack); + ItemStack transferStackThroughOutputFilter(ItemStack inputStack); /** * This method is only called on an input filter to transfer ItemStacks from * the input inventory to the output inventory. */ - public int transferThroughInputFilter(IItemFilter outputFilter, int maxTransfer); + int transferThroughInputFilter(IItemFilter outputFilter, int maxTransfer); - public boolean doesStackMatchFilter(ItemStack testStack); + boolean doesStackMatchFilter(ItemStack testStack); - public boolean doStacksMatch(ItemStack filterStack, ItemStack testStack); + boolean doStacksMatch(ItemStack filterStack, ItemStack testStack); } diff --git a/src/main/java/WayofTime/bloodmagic/routing/TestItemFilter.java b/src/main/java/WayofTime/bloodmagic/routing/TestItemFilter.java index fa743ad4..78642545 100644 --- a/src/main/java/WayofTime/bloodmagic/routing/TestItemFilter.java +++ b/src/main/java/WayofTime/bloodmagic/routing/TestItemFilter.java @@ -162,8 +162,8 @@ public class TestItemFilter implements IItemFilter * managing receives an ItemStack. Should only really be called by the Input * filter via it's transfer method. * - * @param stack - * - + * @param inputStack + * - The stack to transfer * @return - The remainder of the stack after it has been absorbed into the * inventory. */