Reworked Tartaric Gems so that they contain specific demon will types (work for the future)
This commit is contained in:
parent
e681085d8b
commit
035ba94976
|
@ -90,6 +90,7 @@ public class Constants
|
||||||
public static final String SOUL_SWORD_ACTIVE_DRAIN = "soulSwordActiveDrain";
|
public static final String SOUL_SWORD_ACTIVE_DRAIN = "soulSwordActiveDrain";
|
||||||
public static final String SOUL_SWORD_DROP = "soulSwordDrop";
|
public static final String SOUL_SWORD_DROP = "soulSwordDrop";
|
||||||
public static final String SOUL_SWORD_STATIC_DROP = "soulSwordStaticDrop";
|
public static final String SOUL_SWORD_STATIC_DROP = "soulSwordStaticDrop";
|
||||||
|
public static final String WILL_TYPE = "demonWillType";
|
||||||
|
|
||||||
public static final String SOUL_FORGE_BURN = "burnTime";
|
public static final String SOUL_FORGE_BURN = "burnTime";
|
||||||
public static final String SOUL_FORGE_CONSUMED = "consumedSouls";
|
public static final String SOUL_FORGE_CONSUMED = "consumedSouls";
|
||||||
|
|
|
@ -19,14 +19,12 @@ public interface IDemonWillGem
|
||||||
* Returns the number of souls that are left in the soul gem. Returns a
|
* Returns the number of souls that are left in the soul gem. Returns a
|
||||||
* double because souls can be fractionally drained.
|
* double because souls can be fractionally drained.
|
||||||
*
|
*
|
||||||
* @param willGemStack
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public double getWill(ItemStack willGemStack);
|
public double getWill(EnumDemonWillType type, ItemStack willGemStack);
|
||||||
|
|
||||||
public void setWill(ItemStack willGemStack, double amount);
|
public void setWill(EnumDemonWillType type, ItemStack willGemStack, double amount);
|
||||||
|
|
||||||
public int getMaxWill(ItemStack willGemStack);
|
public int getMaxWill(EnumDemonWillType type, ItemStack willGemStack);
|
||||||
|
|
||||||
public double drainWill(ItemStack stack, double drainAmount);
|
public double drainWill(EnumDemonWillType type, ItemStack stack, double drainAmount);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import net.minecraft.item.ItemStack;
|
||||||
*/
|
*/
|
||||||
public class PlayerDemonWillHandler
|
public class PlayerDemonWillHandler
|
||||||
{
|
{
|
||||||
public static double getTotalDemonWill(EntityPlayer player)
|
public static double getTotalDemonWill(EnumDemonWillType type, EntityPlayer player)
|
||||||
{
|
{
|
||||||
ItemStack[] inventory = player.inventory.mainInventory;
|
ItemStack[] inventory = player.inventory.mainInventory;
|
||||||
double souls = 0;
|
double souls = 0;
|
||||||
|
@ -29,7 +29,7 @@ public class PlayerDemonWillHandler
|
||||||
souls += ((IDemonWill) stack.getItem()).getWill(stack);
|
souls += ((IDemonWill) stack.getItem()).getWill(stack);
|
||||||
} else if (stack.getItem() instanceof IDemonWillGem)
|
} else if (stack.getItem() instanceof IDemonWillGem)
|
||||||
{
|
{
|
||||||
souls += ((IDemonWillGem) stack.getItem()).getWill(stack);
|
souls += ((IDemonWillGem) stack.getItem()).getWill(type, stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class PlayerDemonWillHandler
|
||||||
* return true.
|
* return true.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static boolean isDemonWillFull(EntityPlayer player)
|
public static boolean isDemonWillFull(EnumDemonWillType type, EntityPlayer player)
|
||||||
{
|
{
|
||||||
ItemStack[] inventory = player.inventory.mainInventory;
|
ItemStack[] inventory = player.inventory.mainInventory;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class PlayerDemonWillHandler
|
||||||
if (stack.getItem() instanceof IDemonWillGem)
|
if (stack.getItem() instanceof IDemonWillGem)
|
||||||
{
|
{
|
||||||
hasGem = true;
|
hasGem = true;
|
||||||
if (((IDemonWillGem) stack.getItem()).getWill(stack) < ((IDemonWillGem) stack.getItem()).getMaxWill(stack))
|
if (((IDemonWillGem) stack.getItem()).getWill(type, stack) < ((IDemonWillGem) stack.getItem()).getMaxWill(type, stack))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public class PlayerDemonWillHandler
|
||||||
* @param amount
|
* @param amount
|
||||||
* @return - amount consumed
|
* @return - amount consumed
|
||||||
*/
|
*/
|
||||||
public static double consumeDemonWill(EntityPlayer player, double amount)
|
public static double consumeDemonWill(EnumDemonWillType type, EntityPlayer player, double amount)
|
||||||
{
|
{
|
||||||
double consumed = 0;
|
double consumed = 0;
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ public class PlayerDemonWillHandler
|
||||||
}
|
}
|
||||||
} else if (stack.getItem() instanceof IDemonWillGem)
|
} else if (stack.getItem() instanceof IDemonWillGem)
|
||||||
{
|
{
|
||||||
consumed += ((IDemonWillGem) stack.getItem()).drainWill(stack, amount - consumed);
|
consumed += ((IDemonWillGem) stack.getItem()).drainWill(type, stack, amount - consumed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ public class PlayerDemonWillHandler
|
||||||
return soulStack;
|
return soulStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double addDemonWill(EntityPlayer player, double amount)
|
public static double addDemonWill(EnumDemonWillType type, EntityPlayer player, double amount)
|
||||||
{
|
{
|
||||||
ItemStack[] inventory = player.inventory.mainInventory;
|
ItemStack[] inventory = player.inventory.mainInventory;
|
||||||
double remaining = amount;
|
double remaining = amount;
|
||||||
|
@ -154,9 +154,9 @@ public class PlayerDemonWillHandler
|
||||||
{
|
{
|
||||||
if (stack.getItem() instanceof IDemonWillGem)
|
if (stack.getItem() instanceof IDemonWillGem)
|
||||||
{
|
{
|
||||||
double souls = ((IDemonWillGem) stack.getItem()).getWill(stack);
|
double souls = ((IDemonWillGem) stack.getItem()).getWill(type, stack);
|
||||||
double fill = Math.min(((IDemonWillGem) stack.getItem()).getMaxWill(stack) - souls, remaining);
|
double fill = Math.min(((IDemonWillGem) stack.getItem()).getMaxWill(type, stack) - souls, remaining);
|
||||||
((IDemonWillGem) stack.getItem()).setWill(stack, fill + souls);
|
((IDemonWillGem) stack.getItem()).setWill(type, stack, fill + souls);
|
||||||
remaining -= fill;
|
remaining -= fill;
|
||||||
|
|
||||||
if (remaining <= 0)
|
if (remaining <= 0)
|
||||||
|
@ -170,7 +170,7 @@ public class PlayerDemonWillHandler
|
||||||
return amount - remaining;
|
return amount - remaining;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double addDemonWill(EntityPlayer player, double amount, ItemStack ignored)
|
public static double addDemonWill(EnumDemonWillType type, EntityPlayer player, double amount, ItemStack ignored)
|
||||||
{
|
{
|
||||||
ItemStack[] inventory = player.inventory.mainInventory;
|
ItemStack[] inventory = player.inventory.mainInventory;
|
||||||
double remaining = amount;
|
double remaining = amount;
|
||||||
|
@ -182,9 +182,9 @@ public class PlayerDemonWillHandler
|
||||||
{
|
{
|
||||||
if (stack.getItem() instanceof IDemonWillGem)
|
if (stack.getItem() instanceof IDemonWillGem)
|
||||||
{
|
{
|
||||||
double souls = ((IDemonWillGem) stack.getItem()).getWill(stack);
|
double souls = ((IDemonWillGem) stack.getItem()).getWill(type, stack);
|
||||||
double fill = Math.min(((IDemonWillGem) stack.getItem()).getMaxWill(stack) - souls, remaining);
|
double fill = Math.min(((IDemonWillGem) stack.getItem()).getMaxWill(type, stack) - souls, remaining);
|
||||||
((IDemonWillGem) stack.getItem()).setWill(stack, fill + souls);
|
((IDemonWillGem) stack.getItem()).setWill(type, stack, fill + souls);
|
||||||
remaining -= fill;
|
remaining -= fill;
|
||||||
|
|
||||||
if (remaining <= 0)
|
if (remaining <= 0)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.projectile.EntityArrow;
|
import net.minecraft.entity.projectile.EntityArrow;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||||
|
|
||||||
public class EntitySentientArrow extends EntityArrow
|
public class EntitySentientArrow extends EntityArrow
|
||||||
|
@ -37,7 +38,7 @@ public class EntitySentientArrow extends EntityArrow
|
||||||
{
|
{
|
||||||
if (this.shootingEntity instanceof EntityPlayer)
|
if (this.shootingEntity instanceof EntityPlayer)
|
||||||
{
|
{
|
||||||
PlayerDemonWillHandler.addDemonWill((EntityPlayer) this.shootingEntity, reimbursedAmountOnHit);
|
PlayerDemonWillHandler.addDemonWill(EnumDemonWillType.DEFAULT, (EntityPlayer) this.shootingEntity, reimbursedAmountOnHit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import WayofTime.bloodmagic.BloodMagic;
|
import WayofTime.bloodmagic.BloodMagic;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
|
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||||
import WayofTime.bloodmagic.registry.ModItems;
|
import WayofTime.bloodmagic.registry.ModItems;
|
||||||
|
@ -33,6 +34,11 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor
|
||||||
setCreativeTab(BloodMagic.tabBloodMagic);
|
setCreativeTab(BloodMagic.tabBloodMagic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EnumDemonWillType getDemonWillTypeConsumed(ItemStack stack)
|
||||||
|
{
|
||||||
|
return EnumDemonWillType.DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot)
|
public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot)
|
||||||
{
|
{
|
||||||
|
@ -140,11 +146,13 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor
|
||||||
{
|
{
|
||||||
EntityPlayer player = (EntityPlayer) entity;
|
EntityPlayer player = (EntityPlayer) entity;
|
||||||
|
|
||||||
|
EnumDemonWillType type = getDemonWillTypeConsumed(stack);
|
||||||
|
|
||||||
double willRequired = this.getCostModifier(stack) * damage;
|
double willRequired = this.getCostModifier(stack) * damage;
|
||||||
double willLeft = PlayerDemonWillHandler.getTotalDemonWill(player);
|
double willLeft = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||||
if (willLeft >= willRequired)
|
if (willLeft >= willRequired)
|
||||||
{
|
{
|
||||||
PlayerDemonWillHandler.consumeDemonWill(player, willRequired);
|
PlayerDemonWillHandler.consumeDemonWill(type, player, willRequired);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
this.revertArmour(player, stack);
|
this.revertArmour(player, stack);
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import WayofTime.bloodmagic.BloodMagic;
|
import WayofTime.bloodmagic.BloodMagic;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
|
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||||
import WayofTime.bloodmagic.item.armour.ItemSentientArmour;
|
import WayofTime.bloodmagic.item.armour.ItemSentientArmour;
|
||||||
|
|
||||||
|
@ -28,6 +29,11 @@ public class ItemSentientArmourGem extends Item
|
||||||
setMaxStackSize(1);
|
setMaxStackSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EnumDemonWillType getCurrentType(ItemStack stack)
|
||||||
|
{
|
||||||
|
return EnumDemonWillType.DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||||
{
|
{
|
||||||
|
@ -46,7 +52,7 @@ public class ItemSentientArmourGem extends Item
|
||||||
ItemSentientArmour.revertAllArmour(player);
|
ItemSentientArmour.revertAllArmour(player);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
double will = PlayerDemonWillHandler.getTotalDemonWill(player);
|
double will = PlayerDemonWillHandler.getTotalDemonWill(getCurrentType(stack), player);
|
||||||
|
|
||||||
int bracket = getWillBracket(will);
|
int bracket = getWillBracket(will);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.api.iface.IActivatable;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.SharedMonsterAttributes;
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
|
@ -19,6 +18,8 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import WayofTime.bloodmagic.BloodMagic;
|
import WayofTime.bloodmagic.BloodMagic;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
|
import WayofTime.bloodmagic.api.iface.IActivatable;
|
||||||
|
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||||
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
||||||
import WayofTime.bloodmagic.api.soul.IDemonWillWeapon;
|
import WayofTime.bloodmagic.api.soul.IDemonWillWeapon;
|
||||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||||
|
@ -46,6 +47,11 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IA
|
||||||
setCreativeTab(BloodMagic.tabBloodMagic);
|
setCreativeTab(BloodMagic.tabBloodMagic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EnumDemonWillType getCurrentType(ItemStack stack)
|
||||||
|
{
|
||||||
|
return EnumDemonWillType.DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||||
{
|
{
|
||||||
|
@ -54,7 +60,7 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IA
|
||||||
|
|
||||||
if (getActivated(stack))
|
if (getActivated(stack))
|
||||||
{
|
{
|
||||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(player);
|
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(getCurrentType(stack), player);
|
||||||
int level = getLevel(stack, soulsRemaining);
|
int level = getLevel(stack, soulsRemaining);
|
||||||
|
|
||||||
double drain = level >= 0 ? soulDrainPerSwing[level] : 0;
|
double drain = level >= 0 ? soulDrainPerSwing[level] : 0;
|
||||||
|
@ -119,7 +125,8 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IA
|
||||||
double drain = this.getDrainOfActivatedSword(stack);
|
double drain = this.getDrainOfActivatedSword(stack);
|
||||||
if (drain > 0)
|
if (drain > 0)
|
||||||
{
|
{
|
||||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(player);
|
EnumDemonWillType type = getCurrentType(stack);
|
||||||
|
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||||
|
|
||||||
if (drain > soulsRemaining)
|
if (drain > soulsRemaining)
|
||||||
{
|
{
|
||||||
|
@ -127,7 +134,7 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IA
|
||||||
return false;
|
return false;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
PlayerDemonWillHandler.consumeDemonWill(player, drain);
|
PlayerDemonWillHandler.consumeDemonWill(type, player, drain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import WayofTime.bloodmagic.BloodMagic;
|
import WayofTime.bloodmagic.BloodMagic;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
|
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||||
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
||||||
import WayofTime.bloodmagic.api.soul.IDemonWillGem;
|
import WayofTime.bloodmagic.api.soul.IDemonWillGem;
|
||||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||||
|
@ -42,10 +43,11 @@ public class ItemSoulGem extends Item implements IDemonWillGem
|
||||||
@Override
|
@Override
|
||||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||||
{
|
{
|
||||||
double drain = Math.min(this.getWill(stack), this.getMaxWill(stack) / 10);
|
EnumDemonWillType type = this.getCurrentType(stack);
|
||||||
|
double drain = Math.min(this.getWill(type, stack), this.getMaxWill(type, stack) / 10);
|
||||||
|
|
||||||
double filled = PlayerDemonWillHandler.addDemonWill(player, drain, stack);
|
double filled = PlayerDemonWillHandler.addDemonWill(type, player, drain, stack);
|
||||||
this.drainWill(stack, filled);
|
this.drainWill(type, stack, filled);
|
||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +60,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem
|
||||||
{
|
{
|
||||||
ItemStack emptyStack = new ItemStack(this, 1, i);
|
ItemStack emptyStack = new ItemStack(this, 1, i);
|
||||||
ItemStack fullStack = new ItemStack(this, 1, i);
|
ItemStack fullStack = new ItemStack(this, 1, i);
|
||||||
setWill(fullStack, getMaxWill(fullStack));
|
setWill(EnumDemonWillType.DEFAULT, fullStack, getMaxWill(EnumDemonWillType.DEFAULT, fullStack));
|
||||||
list.add(emptyStack);
|
list.add(emptyStack);
|
||||||
list.add(fullStack);
|
list.add(fullStack);
|
||||||
}
|
}
|
||||||
|
@ -68,8 +70,9 @@ public class ItemSoulGem extends Item implements IDemonWillGem
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
|
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
|
||||||
{
|
{
|
||||||
|
EnumDemonWillType type = this.getCurrentType(stack);
|
||||||
tooltip.add(TextHelper.localize("tooltip.BloodMagic.soulGem." + names[stack.getItemDamage()]));
|
tooltip.add(TextHelper.localize("tooltip.BloodMagic.soulGem." + names[stack.getItemDamage()]));
|
||||||
tooltip.add(TextHelper.localize("tooltip.BloodMagic.will", getWill(stack)));
|
tooltip.add(TextHelper.localize("tooltip.BloodMagic.will", getWill(type, stack)));
|
||||||
|
|
||||||
super.addInformation(stack, player, tooltip, advanced);
|
super.addInformation(stack, player, tooltip, advanced);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +86,13 @@ public class ItemSoulGem extends Item implements IDemonWillGem
|
||||||
@Override
|
@Override
|
||||||
public double getDurabilityForDisplay(ItemStack stack)
|
public double getDurabilityForDisplay(ItemStack stack)
|
||||||
{
|
{
|
||||||
return 1.0 - (getWill(stack) / (double) getMaxWill(stack));
|
EnumDemonWillType type = this.getCurrentType(stack);
|
||||||
|
double maxWill = getMaxWill(type, stack);
|
||||||
|
if (maxWill <= 0)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 1.0 - (getWill(type, stack) / maxWill);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -91,15 +100,16 @@ public class ItemSoulGem extends Item implements IDemonWillGem
|
||||||
{
|
{
|
||||||
if (soulStack != null && soulStack.getItem() instanceof IDemonWill)
|
if (soulStack != null && soulStack.getItem() instanceof IDemonWill)
|
||||||
{
|
{
|
||||||
|
EnumDemonWillType thisType = this.getCurrentType(soulGemStack);
|
||||||
IDemonWill soul = (IDemonWill) soulStack.getItem();
|
IDemonWill soul = (IDemonWill) soulStack.getItem();
|
||||||
double soulsLeft = getWill(soulGemStack);
|
double soulsLeft = getWill(thisType, soulGemStack);
|
||||||
|
|
||||||
if (soulsLeft < getMaxWill(soulGemStack))
|
if (soulsLeft < getMaxWill(thisType, soulGemStack))
|
||||||
{
|
{
|
||||||
double newSoulsLeft = Math.min(soulsLeft + soul.getWill(soulStack), getMaxWill(soulGemStack));
|
double newSoulsLeft = Math.min(soulsLeft + soul.getWill(soulStack), getMaxWill(thisType, soulGemStack));
|
||||||
soul.drainWill(soulStack, newSoulsLeft - soulsLeft);
|
soul.drainWill(soulStack, newSoulsLeft - soulsLeft);
|
||||||
|
|
||||||
setWill(soulGemStack, newSoulsLeft);
|
setWill(thisType, soulGemStack, newSoulsLeft);
|
||||||
if (soul.getWill(soulStack) <= 0)
|
if (soul.getWill(soulStack) <= 0)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -111,9 +121,12 @@ public class ItemSoulGem extends Item implements IDemonWillGem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getWill(ItemStack soulGemStack)
|
public double getWill(EnumDemonWillType type, ItemStack soulGemStack)
|
||||||
{
|
{
|
||||||
NBTHelper.checkNBT(soulGemStack);
|
if (!type.equals(getCurrentType(soulGemStack)))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
NBTTagCompound tag = soulGemStack.getTagCompound();
|
NBTTagCompound tag = soulGemStack.getTagCompound();
|
||||||
|
|
||||||
|
@ -121,9 +134,9 @@ public class ItemSoulGem extends Item implements IDemonWillGem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setWill(ItemStack soulGemStack, double souls)
|
public void setWill(EnumDemonWillType type, ItemStack soulGemStack, double souls)
|
||||||
{
|
{
|
||||||
NBTHelper.checkNBT(soulGemStack);
|
setCurrentType(type, soulGemStack);
|
||||||
|
|
||||||
NBTTagCompound tag = soulGemStack.getTagCompound();
|
NBTTagCompound tag = soulGemStack.getTagCompound();
|
||||||
|
|
||||||
|
@ -131,19 +144,24 @@ public class ItemSoulGem extends Item implements IDemonWillGem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double drainWill(ItemStack soulGemStack, double drainAmount)
|
public double drainWill(EnumDemonWillType type, ItemStack soulGemStack, double drainAmount)
|
||||||
{
|
{
|
||||||
double souls = getWill(soulGemStack);
|
double souls = getWill(type, soulGemStack);
|
||||||
|
|
||||||
double soulsDrained = Math.min(drainAmount, souls);
|
double soulsDrained = Math.min(drainAmount, souls);
|
||||||
setWill(soulGemStack, souls - soulsDrained);
|
setWill(type, soulGemStack, souls - soulsDrained);
|
||||||
|
|
||||||
return soulsDrained;
|
return soulsDrained;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxWill(ItemStack soulGemStack)
|
public int getMaxWill(EnumDemonWillType type, ItemStack soulGemStack)
|
||||||
{
|
{
|
||||||
|
if (!type.equals(getCurrentType(soulGemStack)))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
switch (soulGemStack.getMetadata())
|
switch (soulGemStack.getMetadata())
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -159,4 +177,27 @@ public class ItemSoulGem extends Item implements IDemonWillGem
|
||||||
}
|
}
|
||||||
return 64;
|
return 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EnumDemonWillType getCurrentType(ItemStack soulGemStack)
|
||||||
|
{
|
||||||
|
NBTHelper.checkNBT(soulGemStack);
|
||||||
|
|
||||||
|
NBTTagCompound tag = soulGemStack.getTagCompound();
|
||||||
|
|
||||||
|
if (!tag.hasKey(tag.getString(Constants.NBT.WILL_TYPE)))
|
||||||
|
{
|
||||||
|
return EnumDemonWillType.DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentType(EnumDemonWillType type, ItemStack soulGemStack)
|
||||||
|
{
|
||||||
|
NBTHelper.checkNBT(soulGemStack);
|
||||||
|
|
||||||
|
NBTTagCompound tag = soulGemStack.getTagCompound();
|
||||||
|
|
||||||
|
tag.setString(Constants.NBT.WILL_TYPE, type.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,9 +63,6 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo
|
||||||
conduitList.add(newPos.subtract(getPos()));
|
conduitList.add(newPos.subtract(getPos()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("List size: " + conduitList.size());
|
|
||||||
System.out.println("Current amount: " + getCurrentWill(EnumDemonWillType.DEFAULT));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internalCounter++;
|
internalCounter++;
|
||||||
|
@ -79,19 +76,22 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo
|
||||||
if (stack.getItem() instanceof IDemonWillGem)
|
if (stack.getItem() instanceof IDemonWillGem)
|
||||||
{
|
{
|
||||||
IDemonWillGem gemItem = (IDemonWillGem) stack.getItem();
|
IDemonWillGem gemItem = (IDemonWillGem) stack.getItem();
|
||||||
if (willMap.containsKey(EnumDemonWillType.DEFAULT))
|
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||||
{
|
{
|
||||||
double current = willMap.get(EnumDemonWillType.DEFAULT);
|
if (willMap.containsKey(type))
|
||||||
double fillAmount = Math.min(gemDrainRate, Math.min(current, gemItem.getMaxWill(stack) - gemItem.getWill(stack)));
|
|
||||||
if (fillAmount > 0)
|
|
||||||
{
|
{
|
||||||
gemItem.setWill(stack, fillAmount + gemItem.getWill(stack));
|
double current = willMap.get(type);
|
||||||
if (willMap.get(EnumDemonWillType.DEFAULT) - fillAmount <= 0)
|
double fillAmount = Math.min(gemDrainRate, Math.min(current, gemItem.getMaxWill(type, stack) - gemItem.getWill(type, stack)));
|
||||||
|
if (fillAmount > 0)
|
||||||
{
|
{
|
||||||
willMap.remove(EnumDemonWillType.DEFAULT);
|
gemItem.setWill(type, stack, fillAmount + gemItem.getWill(type, stack));
|
||||||
} else
|
if (willMap.get(type) - fillAmount <= 0)
|
||||||
{
|
{
|
||||||
willMap.put(EnumDemonWillType.DEFAULT, willMap.get(EnumDemonWillType.DEFAULT) - fillAmount);
|
willMap.remove(type);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
willMap.put(type, willMap.get(type) - fillAmount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,16 +105,19 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo
|
||||||
if (stack.getItem() instanceof IDemonWillGem)
|
if (stack.getItem() instanceof IDemonWillGem)
|
||||||
{
|
{
|
||||||
IDemonWillGem gemItem = (IDemonWillGem) stack.getItem();
|
IDemonWillGem gemItem = (IDemonWillGem) stack.getItem();
|
||||||
if (!willMap.containsKey(EnumDemonWillType.DEFAULT))
|
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||||
{
|
{
|
||||||
willMap.put(EnumDemonWillType.DEFAULT, 0d);
|
if (!willMap.containsKey(type))
|
||||||
}
|
{
|
||||||
|
willMap.put(type, 0d);
|
||||||
|
}
|
||||||
|
|
||||||
if (willMap.get(EnumDemonWillType.DEFAULT) < maxWill)
|
if (willMap.get(type) < maxWill)
|
||||||
{
|
{
|
||||||
double drainAmount = Math.min(maxWill - willMap.get(EnumDemonWillType.DEFAULT), gemDrainRate);
|
double drainAmount = Math.min(maxWill - willMap.get(type), gemDrainRate);
|
||||||
double drained = gemItem.drainWill(stack, drainAmount);
|
double drained = gemItem.drainWill(type, stack, drainAmount);
|
||||||
willMap.put(EnumDemonWillType.DEFAULT, willMap.get(EnumDemonWillType.DEFAULT) + drained);
|
willMap.put(type, willMap.get(type) + drained);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil
|
||||||
if (soulStack.getItem() instanceof IDemonWillGem)
|
if (soulStack.getItem() instanceof IDemonWillGem)
|
||||||
{
|
{
|
||||||
IDemonWillGem soul = (IDemonWillGem) soulStack.getItem();
|
IDemonWillGem soul = (IDemonWillGem) soulStack.getItem();
|
||||||
return soul.getWill(soulStack);
|
return soul.getWill(EnumDemonWillType.DEFAULT, soulStack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil
|
||||||
if (soulStack.getItem() instanceof IDemonWillGem)
|
if (soulStack.getItem() instanceof IDemonWillGem)
|
||||||
{
|
{
|
||||||
IDemonWillGem soul = (IDemonWillGem) soulStack.getItem();
|
IDemonWillGem soul = (IDemonWillGem) soulStack.getItem();
|
||||||
return soul.drainWill(soulStack, requested);
|
return soul.drainWill(EnumDemonWillType.DEFAULT, soulStack, requested);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,8 +258,8 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil
|
||||||
|
|
||||||
IDemonWillGem willGem = (IDemonWillGem) stack.getItem();
|
IDemonWillGem willGem = (IDemonWillGem) stack.getItem();
|
||||||
|
|
||||||
double maxWill = willGem.getMaxWill(stack);
|
double maxWill = willGem.getMaxWill(type, stack);
|
||||||
double current = willGem.getWill(stack);
|
double current = willGem.getWill(type, stack);
|
||||||
|
|
||||||
if (!doFill)
|
if (!doFill)
|
||||||
{
|
{
|
||||||
|
@ -270,11 +270,11 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil
|
||||||
|
|
||||||
if (amount < filled)
|
if (amount < filled)
|
||||||
{
|
{
|
||||||
willGem.setWill(stack, current + amount);
|
willGem.setWill(type, stack, current + amount);
|
||||||
filled = amount;
|
filled = amount;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
willGem.setWill(stack, maxWill);
|
willGem.setWill(type, stack, maxWill);
|
||||||
}
|
}
|
||||||
|
|
||||||
return filled;
|
return filled;
|
||||||
|
@ -292,7 +292,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil
|
||||||
IDemonWillGem willGem = (IDemonWillGem) stack.getItem();
|
IDemonWillGem willGem = (IDemonWillGem) stack.getItem();
|
||||||
|
|
||||||
double drained = amount;
|
double drained = amount;
|
||||||
double current = willGem.getWill(stack);
|
double current = willGem.getWill(type, stack);
|
||||||
if (current < drained)
|
if (current < drained)
|
||||||
{
|
{
|
||||||
drained = current;
|
drained = current;
|
||||||
|
@ -300,7 +300,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil
|
||||||
|
|
||||||
if (doDrain)
|
if (doDrain)
|
||||||
{
|
{
|
||||||
drained = willGem.drainWill(stack, drained);
|
drained = willGem.drainWill(type, stack, drained);
|
||||||
}
|
}
|
||||||
|
|
||||||
return drained;
|
return drained;
|
||||||
|
|
|
@ -47,6 +47,7 @@ import WayofTime.bloodmagic.api.event.TeleposeEvent;
|
||||||
import WayofTime.bloodmagic.api.iface.IBindable;
|
import WayofTime.bloodmagic.api.iface.IBindable;
|
||||||
import WayofTime.bloodmagic.api.iface.IUpgradeTrainer;
|
import WayofTime.bloodmagic.api.iface.IUpgradeTrainer;
|
||||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||||
|
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||||
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
||||||
import WayofTime.bloodmagic.api.soul.IDemonWillWeapon;
|
import WayofTime.bloodmagic.api.soul.IDemonWillWeapon;
|
||||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||||
|
@ -623,7 +624,7 @@ public class EventHandler
|
||||||
|
|
||||||
ItemStack remainder = PlayerDemonWillHandler.addDemonWill(player, stack);
|
ItemStack remainder = PlayerDemonWillHandler.addDemonWill(player, stack);
|
||||||
|
|
||||||
if (remainder == null || ((IDemonWill) stack.getItem()).getWill(stack) < 0.0001 || PlayerDemonWillHandler.isDemonWillFull(player))
|
if (remainder == null || ((IDemonWill) stack.getItem()).getWill(stack) < 0.0001 || PlayerDemonWillHandler.isDemonWillFull(EnumDemonWillType.DEFAULT, player))
|
||||||
{
|
{
|
||||||
stack.stackSize = 0;
|
stack.stackSize = 0;
|
||||||
event.setResult(Result.ALLOW);
|
event.setResult(Result.ALLOW);
|
||||||
|
|
Loading…
Reference in a new issue