Run formatter
This commit is contained in:
parent
61c44a831b
commit
08258fd6ef
606 changed files with 13464 additions and 22975 deletions
|
@ -5,15 +5,12 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class DemonWillHolder
|
||||
{
|
||||
public class DemonWillHolder {
|
||||
public HashMap<EnumDemonWillType, Double> willMap = new HashMap<EnumDemonWillType, Double>();
|
||||
|
||||
public double addWill(EnumDemonWillType type, double amount, double max)
|
||||
{
|
||||
public double addWill(EnumDemonWillType type, double amount, double max) {
|
||||
double current = 0;
|
||||
if (willMap.containsKey(type))
|
||||
{
|
||||
if (willMap.containsKey(type)) {
|
||||
current = willMap.get(type);
|
||||
}
|
||||
|
||||
|
@ -23,29 +20,22 @@ public class DemonWillHolder
|
|||
return added;
|
||||
}
|
||||
|
||||
public void addWill(EnumDemonWillType type, double amount)
|
||||
{
|
||||
if (willMap.containsKey(type))
|
||||
{
|
||||
public void addWill(EnumDemonWillType type, double amount) {
|
||||
if (willMap.containsKey(type)) {
|
||||
willMap.put(type, amount + willMap.get(type));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
willMap.put(type, amount);
|
||||
}
|
||||
}
|
||||
|
||||
public double drainWill(EnumDemonWillType type, double amount)
|
||||
{
|
||||
if (willMap.containsKey(type))
|
||||
{
|
||||
public double drainWill(EnumDemonWillType type, double amount) {
|
||||
if (willMap.containsKey(type)) {
|
||||
double current = willMap.get(type);
|
||||
double reduced = Math.min(current, amount);
|
||||
|
||||
if (reduced >= current)
|
||||
{
|
||||
if (reduced >= current) {
|
||||
willMap.remove(type);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
willMap.put(type, current - reduced);
|
||||
}
|
||||
|
||||
|
@ -55,45 +45,37 @@ public class DemonWillHolder
|
|||
return 0;
|
||||
}
|
||||
|
||||
public double getWill(EnumDemonWillType type)
|
||||
{
|
||||
if (willMap.containsKey(type))
|
||||
{
|
||||
public double getWill(EnumDemonWillType type) {
|
||||
if (willMap.containsKey(type)) {
|
||||
return willMap.get(type);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound tag, String key)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tag, String key) {
|
||||
NBTTagCompound willTag = tag.getCompoundTag(key);
|
||||
|
||||
willMap.clear();
|
||||
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
{
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values()) {
|
||||
double amount = willTag.getDouble("EnumWill" + type.getName());
|
||||
if (amount > 0)
|
||||
{
|
||||
if (amount > 0) {
|
||||
willMap.put(type, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tag, String key)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tag, String key) {
|
||||
NBTTagCompound willTag = new NBTTagCompound();
|
||||
for (Entry<EnumDemonWillType, Double> entry : willMap.entrySet())
|
||||
{
|
||||
for (Entry<EnumDemonWillType, Double> entry : willMap.entrySet()) {
|
||||
willTag.setDouble("EnumWill" + entry.getKey().getName(), entry.getValue());
|
||||
}
|
||||
|
||||
tag.setTag(key, willTag);
|
||||
}
|
||||
|
||||
public void clearWill()
|
||||
{
|
||||
public void clearWill() {
|
||||
willMap.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package WayofTime.bloodmagic.api.soul;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum EnumDemonWillType implements IStringSerializable
|
||||
{
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumDemonWillType implements IStringSerializable {
|
||||
DEFAULT("default"),
|
||||
CORROSIVE("corrosive"),
|
||||
DESTRUCTIVE("destructive"),
|
||||
|
@ -14,20 +13,17 @@ public enum EnumDemonWillType implements IStringSerializable
|
|||
|
||||
public final String name;
|
||||
|
||||
EnumDemonWillType(String name)
|
||||
{
|
||||
EnumDemonWillType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,11 @@ package WayofTime.bloodmagic.api.soul;
|
|||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IDemonWill
|
||||
{
|
||||
public interface IDemonWill {
|
||||
/**
|
||||
* Obtains the amount of Will an ItemStack contains.
|
||||
*
|
||||
* @param willStack
|
||||
* - The stack to retrieve the Will from
|
||||
*
|
||||
*
|
||||
* @param willStack - The stack to retrieve the Will from
|
||||
* @return - The amount of Will an ItemStack contains
|
||||
*/
|
||||
double getWill(EnumDemonWillType type, ItemStack willStack);
|
||||
|
@ -19,11 +16,9 @@ public interface IDemonWill
|
|||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @param willStack - The ItemStack of the Will
|
||||
* @param will - The amount of will to set the stack to
|
||||
*/
|
||||
void setWill(EnumDemonWillType type, ItemStack willStack, double will);
|
||||
|
||||
|
@ -33,12 +28,9 @@ public interface IDemonWill
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* @param willStack - The ItemStack of the will
|
||||
* @param drainAmount - The amount of Will to drain
|
||||
* @return The amount of will drained.
|
||||
*/
|
||||
double drainWill(EnumDemonWillType type, ItemStack willStack, double drainAmount);
|
||||
|
@ -49,12 +41,9 @@ public interface IDemonWill
|
|||
/**
|
||||
* 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
|
||||
* - The amount of Will to create the Stack with.
|
||||
*
|
||||
*
|
||||
* @param meta - The meta of the ItemStack to create
|
||||
* @param number - The amount of Will to create the Stack with.
|
||||
* @return - An ItemStack with the set amount of Will
|
||||
*/
|
||||
ItemStack createWill(int meta, double number);
|
||||
|
|
|
@ -2,10 +2,8 @@ package WayofTime.bloodmagic.api.soul;
|
|||
|
||||
/**
|
||||
* Implement this interface on a block that can accept and store Demonic Will.
|
||||
*
|
||||
*/
|
||||
public interface IDemonWillConduit
|
||||
{
|
||||
public interface IDemonWillConduit {
|
||||
int getWeight();
|
||||
|
||||
double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill);
|
||||
|
|
|
@ -2,23 +2,18 @@ package WayofTime.bloodmagic.api.soul;
|
|||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IDemonWillGem
|
||||
{
|
||||
public interface IDemonWillGem {
|
||||
/**
|
||||
*
|
||||
* @param willGemStack
|
||||
* - The ItemStack for this demon will gem.
|
||||
* @param willStack
|
||||
* - The ItemStack for the will. Item should extend IDemonWill
|
||||
* @param willGemStack - The ItemStack for this demon will gem.
|
||||
* @param willStack - The ItemStack for the will. Item should extend IDemonWill
|
||||
* @return - The remainder willStack after the will has been absorbed into
|
||||
* the gem. Return null if there is no will left in the stack.
|
||||
* the gem. Return null if there is no will left in the stack.
|
||||
*/
|
||||
ItemStack fillDemonWillGem(ItemStack willGemStack, ItemStack willStack);
|
||||
|
||||
/**
|
||||
* Returns the number of souls that are left in the soul gem. Returns a
|
||||
* double because souls can be fractionally drained.
|
||||
*
|
||||
*/
|
||||
double getWill(EnumDemonWillType type, ItemStack willGemStack);
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import net.minecraft.item.ItemStack;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public interface IDemonWillWeapon
|
||||
{
|
||||
public interface IDemonWillWeapon {
|
||||
List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting);
|
||||
}
|
||||
|
|
|
@ -2,14 +2,11 @@ package WayofTime.bloodmagic.api.soul;
|
|||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IDiscreteDemonWill
|
||||
{
|
||||
public interface IDiscreteDemonWill {
|
||||
/**
|
||||
* Obtains the amount of Will an ItemStack contains.
|
||||
*
|
||||
* @param soulStack
|
||||
* - The stack to retrieve the Will from
|
||||
*
|
||||
*
|
||||
* @param soulStack - The stack to retrieve the Will from
|
||||
* @return - The amount of Will an ItemStack contains
|
||||
*/
|
||||
double getWill(ItemStack soulStack);
|
||||
|
@ -18,32 +15,25 @@ public interface IDiscreteDemonWill
|
|||
* 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
|
||||
*
|
||||
*
|
||||
* @param willStack - The ItemStack of the will
|
||||
* @param drainAmount - The amount of Will to drain
|
||||
* @return The amount of will drained.
|
||||
*/
|
||||
double drainWill(ItemStack willStack, double drainAmount);
|
||||
|
||||
/**
|
||||
* Gets the discrete number for this demonic will.
|
||||
*
|
||||
* @param willStack
|
||||
* - The ItemStack of the will
|
||||
*
|
||||
*
|
||||
* @param willStack - The ItemStack of the will
|
||||
* @return - The discrete number for the given stack.
|
||||
*/
|
||||
double getDiscretization(ItemStack willStack);
|
||||
|
||||
/**
|
||||
* Obtains the type of will this is.
|
||||
*
|
||||
* @param willStack
|
||||
* - The ItemStack of the will
|
||||
*
|
||||
*
|
||||
* @param willStack - The ItemStack of the will
|
||||
* @return - The type of will this is.
|
||||
*/
|
||||
EnumDemonWillType getType(ItemStack willStack);
|
||||
|
|
|
@ -10,30 +10,22 @@ import net.minecraft.util.NonNullList;
|
|||
* Monster Souls and Soul Gems, etc. The Soul Network's helper methods are found
|
||||
* in {@link WayofTime.bloodmagic.api.util.helper.NetworkHelper}
|
||||
*/
|
||||
public class PlayerDemonWillHandler
|
||||
{
|
||||
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
|
||||
*
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
public static double getTotalDemonWill(EnumDemonWillType type, EntityPlayer player) {
|
||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||
double souls = 0;
|
||||
|
||||
for (ItemStack stack : inventory)
|
||||
{
|
||||
if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type)
|
||||
{
|
||||
for (ItemStack stack : inventory) {
|
||||
if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type) {
|
||||
souls += ((IDemonWill) stack.getItem()).getWill(type, stack);
|
||||
} else if (stack.getItem() instanceof IDemonWillGem)
|
||||
{
|
||||
} else if (stack.getItem() instanceof IDemonWillGem) {
|
||||
souls += ((IDemonWillGem) stack.getItem()).getWill(type, stack);
|
||||
}
|
||||
}
|
||||
|
@ -41,16 +33,13 @@ public class PlayerDemonWillHandler
|
|||
return souls;
|
||||
}
|
||||
|
||||
public static EnumDemonWillType getLargestWillType(EntityPlayer player)
|
||||
{
|
||||
public static EnumDemonWillType getLargestWillType(EntityPlayer player) {
|
||||
EnumDemonWillType type = EnumDemonWillType.DEFAULT;
|
||||
double max = getTotalDemonWill(type, player);
|
||||
|
||||
for (EnumDemonWillType testType : EnumDemonWillType.values())
|
||||
{
|
||||
for (EnumDemonWillType testType : EnumDemonWillType.values()) {
|
||||
double value = getTotalDemonWill(testType, player);
|
||||
if (value > max)
|
||||
{
|
||||
if (value > max) {
|
||||
type = testType;
|
||||
}
|
||||
}
|
||||
|
@ -60,23 +49,17 @@ public class PlayerDemonWillHandler
|
|||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
public static boolean isDemonWillFull(EnumDemonWillType type, EntityPlayer player) {
|
||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||
|
||||
boolean hasGem = false;
|
||||
for (ItemStack stack : inventory)
|
||||
{
|
||||
if (stack.getItem() instanceof IDemonWillGem)
|
||||
{
|
||||
for (ItemStack stack : inventory) {
|
||||
if (stack.getItem() instanceof IDemonWillGem) {
|
||||
hasGem = true;
|
||||
if (((IDemonWillGem) stack.getItem()).getWill(type, stack) < ((IDemonWillGem) stack.getItem()).getMaxWill(type, stack))
|
||||
return false;
|
||||
|
@ -88,33 +71,26 @@ public class PlayerDemonWillHandler
|
|||
|
||||
/**
|
||||
* Consumes Will from the inventory of a given player
|
||||
*
|
||||
* @param player
|
||||
* - The player to consume the will of
|
||||
* @param amount
|
||||
* - The amount of will to consume
|
||||
*
|
||||
*
|
||||
* @param player - The player to consume the will of
|
||||
* @param amount - The amount of will to consume
|
||||
* @return - The amount of will consumed.
|
||||
*/
|
||||
public static double consumeDemonWill(EnumDemonWillType type, EntityPlayer player, double amount)
|
||||
{
|
||||
public static double consumeDemonWill(EnumDemonWillType type, EntityPlayer player, double amount) {
|
||||
double consumed = 0;
|
||||
|
||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||
|
||||
for (int i = 0; i < inventory.size(); i++)
|
||||
{
|
||||
for (int i = 0; i < inventory.size(); i++) {
|
||||
if (consumed >= amount)
|
||||
return consumed;
|
||||
|
||||
ItemStack stack = inventory.get(i);
|
||||
if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type)
|
||||
{
|
||||
if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type) {
|
||||
consumed += ((IDemonWill) stack.getItem()).drainWill(type, stack, amount - consumed);
|
||||
if (((IDemonWill) stack.getItem()).getWill(type, stack) <= 0)
|
||||
inventory.set(i, ItemStack.EMPTY);
|
||||
} else if (stack.getItem() instanceof IDemonWillGem)
|
||||
{
|
||||
} else if (stack.getItem() instanceof IDemonWillGem) {
|
||||
consumed += ((IDemonWillGem) stack.getItem()).drainWill(type, stack, amount - consumed, true);
|
||||
}
|
||||
}
|
||||
|
@ -125,25 +101,19 @@ public class PlayerDemonWillHandler
|
|||
/**
|
||||
* Adds an IDemonWill contained in an ItemStack to one of the Soul Gems in
|
||||
* the player's inventory.
|
||||
*
|
||||
* @param player
|
||||
* - The player to add will to
|
||||
* @param willStack
|
||||
* - ItemStack that contains an IDemonWill to be added
|
||||
*
|
||||
*
|
||||
* @param player - 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 willStack)
|
||||
{
|
||||
public static ItemStack addDemonWill(EntityPlayer player, ItemStack willStack) {
|
||||
if (willStack.isEmpty())
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||
|
||||
for (ItemStack stack : inventory)
|
||||
{
|
||||
if (stack.getItem() instanceof IDemonWillGem)
|
||||
{
|
||||
for (ItemStack stack : inventory) {
|
||||
if (stack.getItem() instanceof IDemonWillGem) {
|
||||
ItemStack newStack = ((IDemonWillGem) stack.getItem()).fillDemonWillGem(stack, willStack);
|
||||
if (newStack.isEmpty())
|
||||
return ItemStack.EMPTY;
|
||||
|
@ -156,25 +126,18 @@ public class PlayerDemonWillHandler
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
public static double addDemonWill(EnumDemonWillType type, EntityPlayer player, double amount) {
|
||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||
double remaining = amount;
|
||||
|
||||
for (ItemStack stack : inventory)
|
||||
{
|
||||
if (stack.getItem() instanceof IDemonWillGem)
|
||||
{
|
||||
for (ItemStack stack : inventory) {
|
||||
if (stack.getItem() instanceof IDemonWillGem) {
|
||||
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true);
|
||||
if (remaining <= 0)
|
||||
break;
|
||||
|
@ -187,27 +150,19 @@ public class PlayerDemonWillHandler
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
public static double addDemonWill(EnumDemonWillType type, EntityPlayer player, double amount, ItemStack ignored) {
|
||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||
double remaining = amount;
|
||||
|
||||
for (ItemStack stack : inventory)
|
||||
{
|
||||
if (!stack.equals(ignored) && stack.getItem() instanceof IDemonWillGem)
|
||||
{
|
||||
for (ItemStack stack : inventory) {
|
||||
if (!stack.equals(ignored) && stack.getItem() instanceof IDemonWillGem) {
|
||||
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true);
|
||||
|
||||
if (remaining <= 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue