Made the aspected Sentient Tools drop their corresponding Will type on killing enemies. #753

This commit is contained in:
WayofTime 2016-11-02 12:16:24 -04:00
parent 6c4fe34152
commit 655c2880dc
13 changed files with 103 additions and 42 deletions

View file

@ -8,6 +8,7 @@ Version 2.1.0-67
- Finished the Augments for the Ritual of the Feathered Knife. - Finished the Augments for the Ritual of the Feathered Knife.
- Changed the Ritual of the Feathered Knife so it respects the Tough Palms Living Armour Upgrade. - Changed the Ritual of the Feathered Knife so it respects the Tough Palms Living Armour Upgrade.
- Fixed the Ritual of the Feathered Knife so that its health threshold is percent-based. - Fixed the Ritual of the Feathered Knife so that its health threshold is percent-based.
- Made the aspected Sentient Tools drop their corresponding Will type on killing enemies.
------------------------------------------------------ ------------------------------------------------------
Version 2.1.0-66 Version 2.1.0-66

View file

@ -12,7 +12,7 @@ public interface IDemonWill
* *
* @return - The amount of Will an ItemStack contains * @return - The amount of Will an ItemStack contains
*/ */
double getWill(ItemStack willStack); double getWill(EnumDemonWillType type, ItemStack willStack);
/** /**
* Sets the amount of Will in a given ItemStack. * Sets the amount of Will in a given ItemStack.
@ -22,7 +22,7 @@ public interface IDemonWill
* @param will * @param will
* - The amount of will to set the stack to * - The amount of will to set the stack to
*/ */
void setWill(ItemStack willStack, double will); void setWill(EnumDemonWillType type, ItemStack willStack, double will);
/** /**
* Drains the demonic will from the willStack. If all of the will is * Drains the demonic will from the willStack. If all of the will is
@ -35,7 +35,7 @@ public interface IDemonWill
* *
* @return The amount of will drained. * @return The amount of will drained.
*/ */
double drainWill(ItemStack willStack, double drainAmount); double drainWill(EnumDemonWillType type, ItemStack willStack, double drainAmount);
/** /**
* Creates a new ItemStack with the specified number of will. Implementation * Creates a new ItemStack with the specified number of will. Implementation
@ -49,4 +49,6 @@ public interface IDemonWill
* @return - An ItemStack with the set amount of Will * @return - An ItemStack with the set amount of Will
*/ */
ItemStack createWill(int meta, double number); ItemStack createWill(int meta, double number);
EnumDemonWillType getType(ItemStack stack);
} }

View file

@ -30,9 +30,9 @@ public class PlayerDemonWillHandler
{ {
if (stack != null) if (stack != null)
{ {
if (stack.getItem() instanceof IDemonWill) if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type)
{ {
souls += ((IDemonWill) stack.getItem()).getWill(stack); 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); souls += ((IDemonWillGem) stack.getItem()).getWill(type, stack);
@ -112,10 +112,10 @@ public class PlayerDemonWillHandler
ItemStack stack = inventory[i]; ItemStack stack = inventory[i];
if (stack != null) if (stack != null)
{ {
if (stack.getItem() instanceof IDemonWill) if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type)
{ {
consumed += ((IDemonWill) stack.getItem()).drainWill(stack, amount - consumed); consumed += ((IDemonWill) stack.getItem()).drainWill(type, stack, amount - consumed);
if (((IDemonWill) stack.getItem()).getWill(stack) <= 0) if (((IDemonWill) stack.getItem()).getWill(type, stack) <= 0)
inventory[i] = null; inventory[i] = null;
} else if (stack.getItem() instanceof IDemonWillGem) } else if (stack.getItem() instanceof IDemonWillGem)
{ {

View file

@ -2,6 +2,7 @@ package WayofTime.bloodmagic.item.soul;
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.util.helper.NBTHelper; import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.client.IVariantProvider;
@ -13,6 +14,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@ -21,7 +23,7 @@ import java.util.List;
public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvider public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvider
{ {
public static String[] names = { "base" }; public static String[] names = { "base", "corrosive", "destructive", "vengeful", "steadfast" };
public ItemMonsterSoul() public ItemMonsterSoul()
{ {
@ -53,14 +55,25 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide
{ {
if (!stack.hasTagCompound()) if (!stack.hasTagCompound())
return; return;
tooltip.add(TextHelper.localize("tooltip.BloodMagic.will", getWill(stack))); tooltip.add(TextHelper.localize("tooltip.BloodMagic.will", getWill(getType(stack), stack)));
super.addInformation(stack, player, tooltip, advanced); super.addInformation(stack, player, tooltip, advanced);
} }
@Override @Override
public double getWill(ItemStack soulStack) public EnumDemonWillType getType(ItemStack stack)
{ {
return EnumDemonWillType.values()[stack.getItemDamage() % 5];
}
@Override
public double getWill(EnumDemonWillType type, ItemStack soulStack)
{
if (type != this.getType(soulStack))
{
return 0;
}
NBTHelper.checkNBT(soulStack); NBTHelper.checkNBT(soulStack);
NBTTagCompound tag = soulStack.getTagCompound(); NBTTagCompound tag = soulStack.getTagCompound();
@ -69,22 +82,24 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide
} }
@Override @Override
public void setWill(ItemStack soulStack, double souls) public void setWill(EnumDemonWillType type, ItemStack soulStack, double souls)
{ {
NBTHelper.checkNBT(soulStack); NBTHelper.checkNBT(soulStack);
NBTTagCompound tag = soulStack.getTagCompound(); NBTTagCompound tag = soulStack.getTagCompound();
soulStack.setItemDamage(type.ordinal());
tag.setDouble(Constants.NBT.SOULS, souls); tag.setDouble(Constants.NBT.SOULS, souls);
} }
@Override @Override
public double drainWill(ItemStack soulStack, double drainAmount) public double drainWill(EnumDemonWillType type, ItemStack soulStack, double drainAmount)
{ {
double souls = getWill(soulStack); double souls = getWill(type, soulStack);
double soulsDrained = Math.min(drainAmount, souls); double soulsDrained = Math.min(drainAmount, souls);
setWill(soulStack, souls - soulsDrained); setWill(type, soulStack, souls - soulsDrained);
return soulsDrained; return soulsDrained;
} }
@ -92,8 +107,8 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide
@Override @Override
public ItemStack createWill(int meta, double number) public ItemStack createWill(int meta, double number)
{ {
ItemStack soulStack = new ItemStack(this, 1, meta); ItemStack soulStack = new ItemStack(this, 1, meta % 5);
setWill(soulStack, number); setWill(getType(soulStack), soulStack, number);
return soulStack; return soulStack;
} }
@ -101,7 +116,11 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide
public List<Pair<Integer, String>> getVariants() public List<Pair<Integer, String>> getVariants()
{ {
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>(); List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
ret.add(new ImmutablePair<Integer, String>(0, "type=monstersoul")); for (int i = 0; i < names.length; i++)
{
String name = names[i];
ret.add(new ImmutablePair<Integer, String>(i, "type=" + name));
}
return ret; return ret;
} }
} }

View file

@ -374,11 +374,13 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
IDemonWill soul = ((IDemonWill) ModItems.MONSTER_SOUL); IDemonWill soul = ((IDemonWill) ModItems.MONSTER_SOUL);
EnumDemonWillType type = this.getCurrentType(stack);
for (int i = 0; i <= looting; i++) for (int i = 0; i <= looting; i++)
{ {
if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4) if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4)
{ {
ItemStack soulStack = soul.createWill(0, willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
soulList.add(soulStack); soulList.add(soulStack);
} }
} }

View file

@ -374,11 +374,13 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
IDemonWill soul = ((IDemonWill) ModItems.MONSTER_SOUL); IDemonWill soul = ((IDemonWill) ModItems.MONSTER_SOUL);
EnumDemonWillType type = this.getCurrentType(stack);
for (int i = 0; i <= looting; i++) for (int i = 0; i <= looting; i++)
{ {
if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4) if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4)
{ {
ItemStack soulStack = soul.createWill(0, willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
soulList.add(soulStack); soulList.add(soulStack);
} }
} }

View file

@ -374,11 +374,13 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
IDemonWill soul = ((IDemonWill) ModItems.MONSTER_SOUL); IDemonWill soul = ((IDemonWill) ModItems.MONSTER_SOUL);
EnumDemonWillType type = this.getCurrentType(stack);
for (int i = 0; i <= looting; i++) for (int i = 0; i <= looting; i++)
{ {
if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4) if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4)
{ {
ItemStack soulStack = soul.createWill(0, willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
soulList.add(soulStack); soulList.add(soulStack);
} }
} }

View file

@ -346,11 +346,13 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
IDemonWill soul = ((IDemonWill) ModItems.MONSTER_SOUL); IDemonWill soul = ((IDemonWill) ModItems.MONSTER_SOUL);
EnumDemonWillType type = this.getCurrentType(stack);
for (int i = 0; i <= looting; i++) for (int i = 0; i <= looting; i++)
{ {
if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4) if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4)
{ {
ItemStack soulStack = soul.createWill(0, willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
soulList.add(soulStack); soulList.add(soulStack);
} }
} }

View file

@ -153,7 +153,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
if (soulStack != null && soulStack.getItem() instanceof IDemonWill) if (soulStack != null && soulStack.getItem() instanceof IDemonWill)
{ {
EnumDemonWillType thisType = this.getCurrentType(soulGemStack); EnumDemonWillType thisType = this.getCurrentType(soulGemStack);
if (thisType != EnumDemonWillType.DEFAULT) if (thisType != ((IDemonWill) soulStack.getItem()).getType(soulStack))
{ {
return soulStack; return soulStack;
} }
@ -162,11 +162,11 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
if (soulsLeft < getMaxWill(thisType, soulGemStack)) if (soulsLeft < getMaxWill(thisType, soulGemStack))
{ {
double newSoulsLeft = Math.min(soulsLeft + soul.getWill(soulStack), getMaxWill(thisType, soulGemStack)); double newSoulsLeft = Math.min(soulsLeft + soul.getWill(thisType, soulStack), getMaxWill(thisType, soulGemStack));
soul.drainWill(soulStack, newSoulsLeft - soulsLeft); soul.drainWill(thisType, soulStack, newSoulsLeft - soulsLeft);
setWill(thisType, soulGemStack, newSoulsLeft); setWill(thisType, soulGemStack, newSoulsLeft);
if (soul.getWill(soulStack) <= 0) if (soul.getWill(thisType, soulStack) <= 0)
{ {
return null; return null;
} }

View file

@ -79,7 +79,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil
return; return;
} }
double soulsInGem = getWill(); double soulsInGem = getWill(EnumDemonWillType.DEFAULT);
List<ItemStack> inputList = new ArrayList<ItemStack>(); List<ItemStack> inputList = new ArrayList<ItemStack>();
@ -107,7 +107,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil
{ {
if (!worldObj.isRemote && soulsInGem >= recipe.getMinimumSouls()) if (!worldObj.isRemote && soulsInGem >= recipe.getMinimumSouls())
{ {
consumeSouls(requiredSouls); consumeSouls(EnumDemonWillType.DEFAULT, requiredSouls);
} }
} }
@ -189,39 +189,39 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil
return false; return false;
} }
public double getWill() public double getWill(EnumDemonWillType type)
{ {
ItemStack soulStack = getStackInSlot(soulSlot); ItemStack soulStack = getStackInSlot(soulSlot);
if (soulStack != null) if (soulStack != null)
{ {
if (soulStack.getItem() instanceof IDemonWill) if (soulStack.getItem() instanceof IDemonWill && ((IDemonWill) soulStack.getItem()).getType(soulStack) == type)
{ {
IDemonWill soul = (IDemonWill) soulStack.getItem(); IDemonWill soul = (IDemonWill) soulStack.getItem();
return soul.getWill(soulStack); return soul.getWill(type, soulStack);
} }
if (soulStack.getItem() instanceof IDemonWillGem) if (soulStack.getItem() instanceof IDemonWillGem)
{ {
IDemonWillGem soul = (IDemonWillGem) soulStack.getItem(); IDemonWillGem soul = (IDemonWillGem) soulStack.getItem();
return soul.getWill(EnumDemonWillType.DEFAULT, soulStack); return soul.getWill(type, soulStack);
} }
} }
return 0; return 0;
} }
public double consumeSouls(double requested) public double consumeSouls(EnumDemonWillType type, double requested)
{ {
ItemStack soulStack = getStackInSlot(soulSlot); ItemStack soulStack = getStackInSlot(soulSlot);
if (soulStack != null) if (soulStack != null)
{ {
if (soulStack.getItem() instanceof IDemonWill) if (soulStack.getItem() instanceof IDemonWill && ((IDemonWill) soulStack.getItem()).getType(soulStack) == type)
{ {
IDemonWill soul = (IDemonWill) soulStack.getItem(); IDemonWill soul = (IDemonWill) soulStack.getItem();
double souls = soul.drainWill(soulStack, requested); double souls = soul.drainWill(type, soulStack, requested);
if (soul.getWill(soulStack) <= 0) if (soul.getWill(type, soulStack) <= 0)
{ {
setInventorySlotContents(soulSlot, null); setInventorySlotContents(soulSlot, null);
} }
@ -231,7 +231,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(EnumDemonWillType.DEFAULT, soulStack, requested, true); return soul.drainWill(type, soulStack, requested, true);
} }
} }

View file

@ -51,10 +51,10 @@ public class WillHandler
if (stack != null && stack.getItem() instanceof IDemonWill) if (stack != null && stack.getItem() instanceof IDemonWill)
{ {
EntityPlayer player = event.getEntityPlayer(); EntityPlayer player = event.getEntityPlayer();
EnumDemonWillType pickupType = ((IDemonWill) stack.getItem()).getType(stack);
ItemStack remainder = PlayerDemonWillHandler.addDemonWill(player, stack); ItemStack remainder = PlayerDemonWillHandler.addDemonWill(player, stack);
if (remainder == null || ((IDemonWill) stack.getItem()).getWill(stack) < 0.0001 || PlayerDemonWillHandler.isDemonWillFull(EnumDemonWillType.DEFAULT, player)) if (remainder == null || ((IDemonWill) stack.getItem()).getWill(pickupType, stack) < 0.0001 || PlayerDemonWillHandler.isDemonWillFull(pickupType, player))
{ {
stack.stackSize = 0; stack.stackSize = 0;
event.setResult(Event.Result.ALLOW); event.setResult(Event.Result.ALLOW);
@ -108,8 +108,15 @@ public class WillHandler
for (ItemStack willStack : droppedSouls) for (ItemStack willStack : droppedSouls)
{ {
remainder = PlayerDemonWillHandler.addDemonWill(player, willStack); remainder = PlayerDemonWillHandler.addDemonWill(player, willStack);
if (remainder != null && ((IDemonWill) remainder.getItem()).getWill(remainder) >= 0.0001)
event.getDrops().add(new EntityItem(attackedEntity.worldObj, attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, remainder)); if (remainder != null)
{
EnumDemonWillType pickupType = ((IDemonWill) remainder.getItem()).getType(remainder);
if (((IDemonWill) remainder.getItem()).getWill(pickupType, remainder) >= 0.0001)
{
event.getDrops().add(new EntityItem(attackedEntity.worldObj, attackedEntity.posX, attackedEntity.posY, attackedEntity.posZ, remainder));
}
}
} }
player.inventoryContainer.detectAndSendChanges(); player.inventoryContainer.detectAndSendChanges();
} }

View file

@ -6,7 +6,27 @@
}, },
"variants": { "variants": {
"type": { "type": {
"monstersoul": { "base": {
"textures": {
"layer0": "bloodmagic:items/BaseMonsterSoul"
}
},
"corrosive": {
"textures": {
"layer0": "bloodmagic:items/BaseMonsterSoul"
}
},
"destructive": {
"textures": {
"layer0": "bloodmagic:items/BaseMonsterSoul"
}
},
"vengeful": {
"textures": {
"layer0": "bloodmagic:items/BaseMonsterSoul"
}
},
"steadfast": {
"textures": { "textures": {
"layer0": "bloodmagic:items/BaseMonsterSoul" "layer0": "bloodmagic:items/BaseMonsterSoul"
} }

View file

@ -114,6 +114,10 @@ item.BloodMagic.demonCrystal.crystalVengeful.name=Vengeful Will Crystal
item.BloodMagic.demonCrystal.crystalSteadfast.name=Steadfast Will Crystal item.BloodMagic.demonCrystal.crystalSteadfast.name=Steadfast Will Crystal
item.BloodMagic.monsterSoul.base.name=Demonic Will item.BloodMagic.monsterSoul.base.name=Demonic Will
item.BloodMagic.monsterSoul.corrosive.name=Corrosive Demonic Will
item.BloodMagic.monsterSoul.destructive.name=Destructive Demonic Will
item.BloodMagic.monsterSoul.vengeful.name=Vengeful Demonic Will
item.BloodMagic.monsterSoul.steadfast.name=Steadfast Demonic Will
item.BloodMagic.sigil.air.name=Air Sigil item.BloodMagic.sigil.air.name=Air Sigil
item.BloodMagic.sigil.bloodLight.name=Sigil of the Blood Lamp item.BloodMagic.sigil.bloodLight.name=Sigil of the Blood Lamp