Creation of 1.16.3 branch

Initial publishing of the 1.16.3 branch of the mod. A lot of systems are missing (such as Rituals and Living Armour), but enough is present for a decent Alpha release.
This commit is contained in:
WayofTime 2020-10-24 08:59:04 -04:00
parent 0e02b983f1
commit d617911d7a
1662 changed files with 18791 additions and 85075 deletions

View file

@ -0,0 +1,99 @@
package wayoftime.bloodmagic.will;
import java.util.HashMap;
import java.util.Map.Entry;
import net.minecraft.nbt.CompoundNBT;
public class DemonWillHolder
{
public HashMap<EnumDemonWillType, Double> willMap = new HashMap<>();
public double addWill(EnumDemonWillType type, double amount, double max)
{
double current = 0;
if (willMap.containsKey(type))
{
current = willMap.get(type);
}
double added = Math.min(max - current, amount);
addWill(type, amount);
return added;
}
public void addWill(EnumDemonWillType type, double amount)
{
if (willMap.containsKey(type))
{
willMap.put(type, amount + willMap.get(type));
} else
{
willMap.put(type, amount);
}
}
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)
{
willMap.remove(type);
} else
{
willMap.put(type, current - reduced);
}
return reduced;
}
return 0;
}
public double getWill(EnumDemonWillType type)
{
if (willMap.containsKey(type))
{
return willMap.get(type);
}
return 0;
}
public void readFromNBT(CompoundNBT tag, String key)
{
CompoundNBT willTag = tag.getCompound(key);
willMap.clear();
for (EnumDemonWillType type : EnumDemonWillType.values())
{
double amount = willTag.getDouble("EnumWill" + type.name());
if (amount > 0)
{
willMap.put(type, amount);
}
}
}
public void writeToNBT(CompoundNBT tag, String key)
{
CompoundNBT willTag = new CompoundNBT();
for (Entry<EnumDemonWillType, Double> entry : willMap.entrySet())
{
willTag.putDouble("EnumWill" + entry.getKey().name(), entry.getValue());
}
tag.put(key, willTag);
}
public void clearWill()
{
willMap.clear();
}
}

View file

@ -0,0 +1,33 @@
package wayoftime.bloodmagic.will;
import java.util.Locale;
import net.minecraft.util.IStringSerializable;
public enum EnumDemonWillType implements IStringSerializable
{
DEFAULT("default"),
CORROSIVE("corrosive"),
DESTRUCTIVE("destructive"),
VENGEFUL("vengeful"),
STEADFAST("steadfast");
public final String name;
EnumDemonWillType(String name)
{
this.name = name;
}
@Override
public String toString()
{
return name().toLowerCase(Locale.ENGLISH);
}
@Override
public String getString()
{
return this.toString();
}
}

View file

@ -0,0 +1,45 @@
package wayoftime.bloodmagic.will;
import net.minecraft.item.ItemStack;
public interface IDemonWill
{
/**
* 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(EnumDemonWillType type, ItemStack willStack);
/**
* 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
* @return True if successfully set.
*/
boolean setWill(EnumDemonWillType type, 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.
*/
double drainWill(EnumDemonWillType type, 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 - The amount of Will to create the Stack with.
* @return - An ItemStack with the set amount of Will
*/
ItemStack createWill(double number);
EnumDemonWillType getType(ItemStack stack);
}

View file

@ -0,0 +1,19 @@
package wayoftime.bloodmagic.will;
/**
* Implement this interface on a block that can accept and store Demonic Will.
*/
public interface IDemonWillConduit
{
int getWeight();
double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill);
double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain);
boolean canFill(EnumDemonWillType type);
boolean canDrain(EnumDemonWillType type);
double getCurrentWill(EnumDemonWillType type);
}

View file

@ -0,0 +1,29 @@
package wayoftime.bloodmagic.will;
import net.minecraft.item.ItemStack;
public interface IDemonWillGem
{
/**
* @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.
*/
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);
void setWill(EnumDemonWillType type, ItemStack willGemStack, double amount);
int getMaxWill(EnumDemonWillType type, ItemStack willGemStack);
double drainWill(EnumDemonWillType type, ItemStack stack, double drainAmount, boolean doDrain);
double fillWill(EnumDemonWillType type, ItemStack stack, double fillAmount, boolean doFill);
}

View file

@ -0,0 +1,11 @@
package wayoftime.bloodmagic.will;
import java.util.List;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
public interface IDemonWillWeapon
{
List<ItemStack> getRandomDemonWillDrop(LivingEntity killedEntity, LivingEntity attackingEntity, ItemStack stack, int looting);
}

View file

@ -0,0 +1,41 @@
package wayoftime.bloodmagic.will;
import net.minecraft.item.ItemStack;
public interface IDiscreteDemonWill
{
/**
* 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.
*/
double drainWill(ItemStack willStack, double drainAmount);
/**
* Gets the discrete number for this demonic 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
* @return - The type of will this is.
*/
EnumDemonWillType getType(ItemStack willStack);
}

View file

@ -0,0 +1,200 @@
package wayoftime.bloodmagic.will;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import wayoftime.bloodmagic.util.helper.NetworkHelper;
/**
* 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 {@link NetworkHelper}
*/
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, PlayerEntity 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)
{
souls += ((IDemonWill) stack.getItem()).getWill(type, stack);
} else if (stack.getItem() instanceof IDemonWillGem)
{
souls += ((IDemonWillGem) stack.getItem()).getWill(type, stack);
}
}
return souls;
}
public static EnumDemonWillType getLargestWillType(PlayerEntity player)
{
EnumDemonWillType type = EnumDemonWillType.DEFAULT;
double max = getTotalDemonWill(type, player);
for (EnumDemonWillType testType : EnumDemonWillType.values())
{
double value = getTotalDemonWill(testType, player);
if (value > max)
{
type = testType;
}
}
return type;
}
/**
* 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, PlayerEntity player)
{
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
boolean hasGem = false;
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;
}
}
return hasGem;
}
/**
* 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
* @return - The amount of will consumed.
*/
public static double consumeDemonWill(EnumDemonWillType type, PlayerEntity player, double amount)
{
double consumed = 0;
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
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)
{
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)
{
consumed += ((IDemonWillGem) stack.getItem()).drainWill(type, stack, amount - consumed, true);
}
}
return consumed;
}
/**
* 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
* @return - The modified willStack
*/
public static ItemStack addDemonWill(PlayerEntity player, ItemStack willStack)
{
if (willStack.isEmpty())
return ItemStack.EMPTY;
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
for (ItemStack stack : inventory)
{
if (stack.getItem() instanceof IDemonWillGem)
{
ItemStack newStack = ((IDemonWillGem) stack.getItem()).fillDemonWillGem(stack, willStack);
if (newStack.isEmpty())
return ItemStack.EMPTY;
}
}
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, PlayerEntity player, double amount)
{
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
double remaining = amount;
for (ItemStack stack : inventory)
{
if (stack.getItem() instanceof IDemonWillGem)
{
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true);
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, PlayerEntity 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)
{
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true);
if (remaining <= 0)
break;
}
}
return amount - remaining;
}
}