diff --git a/changelog.txt b/changelog.txt index 9dee5bf4..17a916d3 100644 --- a/changelog.txt +++ b/changelog.txt @@ -8,6 +8,7 @@ Version 2.1.0-67 - 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. - 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 diff --git a/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWill.java b/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWill.java index 43b5cf46..f9d5f23f 100644 --- a/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWill.java +++ b/src/main/java/WayofTime/bloodmagic/api/soul/IDemonWill.java @@ -12,7 +12,7 @@ public interface IDemonWill * * @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. @@ -22,7 +22,7 @@ public interface IDemonWill * @param will * - 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 @@ -35,7 +35,7 @@ public interface IDemonWill * * @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 @@ -49,4 +49,6 @@ public interface IDemonWill * @return - An ItemStack with the set amount of Will */ ItemStack createWill(int meta, double number); + + EnumDemonWillType getType(ItemStack stack); } diff --git a/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java b/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java index fe3b6a26..000a1e26 100644 --- a/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java +++ b/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java @@ -30,9 +30,9 @@ public class PlayerDemonWillHandler { 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) { souls += ((IDemonWillGem) stack.getItem()).getWill(type, stack); @@ -112,10 +112,10 @@ public class PlayerDemonWillHandler ItemStack stack = inventory[i]; 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); - if (((IDemonWill) stack.getItem()).getWill(stack) <= 0) + consumed += ((IDemonWill) stack.getItem()).drainWill(type, stack, amount - consumed); + if (((IDemonWill) stack.getItem()).getWill(type, stack) <= 0) inventory[i] = null; } else if (stack.getItem() instanceof IDemonWillGem) { diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemMonsterSoul.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemMonsterSoul.java index 2b855d32..b4d870e7 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemMonsterSoul.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemMonsterSoul.java @@ -2,6 +2,7 @@ package WayofTime.bloodmagic.item.soul; import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import WayofTime.bloodmagic.api.soul.IDemonWill; import WayofTime.bloodmagic.api.util.helper.NBTHelper; import WayofTime.bloodmagic.client.IVariantProvider; @@ -13,6 +14,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; + import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; @@ -21,7 +23,7 @@ import java.util.List; public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvider { - public static String[] names = { "base" }; + public static String[] names = { "base", "corrosive", "destructive", "vengeful", "steadfast" }; public ItemMonsterSoul() { @@ -53,14 +55,25 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide { if (!stack.hasTagCompound()) 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); } @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); NBTTagCompound tag = soulStack.getTagCompound(); @@ -69,22 +82,24 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide } @Override - public void setWill(ItemStack soulStack, double souls) + public void setWill(EnumDemonWillType type, ItemStack soulStack, double souls) { NBTHelper.checkNBT(soulStack); NBTTagCompound tag = soulStack.getTagCompound(); + soulStack.setItemDamage(type.ordinal()); + tag.setDouble(Constants.NBT.SOULS, souls); } @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); - setWill(soulStack, souls - soulsDrained); + setWill(type, soulStack, souls - soulsDrained); return soulsDrained; } @@ -92,8 +107,8 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide @Override public ItemStack createWill(int meta, double number) { - ItemStack soulStack = new ItemStack(this, 1, meta); - setWill(soulStack, number); + ItemStack soulStack = new ItemStack(this, 1, meta % 5); + setWill(getType(soulStack), soulStack, number); return soulStack; } @@ -101,7 +116,11 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide public List> getVariants() { List> ret = new ArrayList>(); - ret.add(new ImmutablePair(0, "type=monstersoul")); + for (int i = 0; i < names.length; i++) + { + String name = names[i]; + ret.add(new ImmutablePair(i, "type=" + name)); + } return ret; } } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientAxe.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientAxe.java index 492042d5..255ac5d9 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientAxe.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientAxe.java @@ -374,11 +374,13 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP IDemonWill soul = ((IDemonWill) ModItems.MONSTER_SOUL); + EnumDemonWillType type = this.getCurrentType(stack); + for (int i = 0; i <= looting; i++) { 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); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientPickaxe.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientPickaxe.java index b2fd79dd..9ccef5ad 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientPickaxe.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientPickaxe.java @@ -374,11 +374,13 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon IDemonWill soul = ((IDemonWill) ModItems.MONSTER_SOUL); + EnumDemonWillType type = this.getCurrentType(stack); + for (int i = 0; i <= looting; i++) { 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); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientShovel.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientShovel.java index 948de1c8..664afb3e 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientShovel.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientShovel.java @@ -374,11 +374,13 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I IDemonWill soul = ((IDemonWill) ModItems.MONSTER_SOUL); + EnumDemonWillType type = this.getCurrentType(stack); + for (int i = 0; i <= looting; i++) { 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); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java index 8b99b28a..bbc5cc5d 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java @@ -346,11 +346,13 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM IDemonWill soul = ((IDemonWill) ModItems.MONSTER_SOUL); + EnumDemonWillType type = this.getCurrentType(stack); + for (int i = 0; i <= looting; i++) { 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); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java index 4b310765..4e6adfa5 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java @@ -153,7 +153,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I if (soulStack != null && soulStack.getItem() instanceof IDemonWill) { EnumDemonWillType thisType = this.getCurrentType(soulGemStack); - if (thisType != EnumDemonWillType.DEFAULT) + if (thisType != ((IDemonWill) soulStack.getItem()).getType(soulStack)) { return soulStack; } @@ -162,11 +162,11 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I if (soulsLeft < getMaxWill(thisType, soulGemStack)) { - double newSoulsLeft = Math.min(soulsLeft + soul.getWill(soulStack), getMaxWill(thisType, soulGemStack)); - soul.drainWill(soulStack, newSoulsLeft - soulsLeft); + double newSoulsLeft = Math.min(soulsLeft + soul.getWill(thisType, soulStack), getMaxWill(thisType, soulGemStack)); + soul.drainWill(thisType, soulStack, newSoulsLeft - soulsLeft); setWill(thisType, soulGemStack, newSoulsLeft); - if (soul.getWill(soulStack) <= 0) + if (soul.getWill(thisType, soulStack) <= 0) { return null; } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileSoulForge.java b/src/main/java/WayofTime/bloodmagic/tile/TileSoulForge.java index 5ee006c1..183f8516 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileSoulForge.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileSoulForge.java @@ -79,7 +79,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil return; } - double soulsInGem = getWill(); + double soulsInGem = getWill(EnumDemonWillType.DEFAULT); List inputList = new ArrayList(); @@ -107,7 +107,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil { 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; } - public double getWill() + public double getWill(EnumDemonWillType type) { ItemStack soulStack = getStackInSlot(soulSlot); if (soulStack != null) { - if (soulStack.getItem() instanceof IDemonWill) + if (soulStack.getItem() instanceof IDemonWill && ((IDemonWill) soulStack.getItem()).getType(soulStack) == type) { IDemonWill soul = (IDemonWill) soulStack.getItem(); - return soul.getWill(soulStack); + return soul.getWill(type, soulStack); } if (soulStack.getItem() instanceof IDemonWillGem) { IDemonWillGem soul = (IDemonWillGem) soulStack.getItem(); - return soul.getWill(EnumDemonWillType.DEFAULT, soulStack); + return soul.getWill(type, soulStack); } } return 0; } - public double consumeSouls(double requested) + public double consumeSouls(EnumDemonWillType type, double requested) { ItemStack soulStack = getStackInSlot(soulSlot); if (soulStack != null) { - if (soulStack.getItem() instanceof IDemonWill) + if (soulStack.getItem() instanceof IDemonWill && ((IDemonWill) soulStack.getItem()).getType(soulStack) == type) { IDemonWill soul = (IDemonWill) soulStack.getItem(); - double souls = soul.drainWill(soulStack, requested); - if (soul.getWill(soulStack) <= 0) + double souls = soul.drainWill(type, soulStack, requested); + if (soul.getWill(type, soulStack) <= 0) { setInventorySlotContents(soulSlot, null); } @@ -231,7 +231,7 @@ public class TileSoulForge extends TileInventory implements ITickable, IDemonWil if (soulStack.getItem() instanceof IDemonWillGem) { IDemonWillGem soul = (IDemonWillGem) soulStack.getItem(); - return soul.drainWill(EnumDemonWillType.DEFAULT, soulStack, requested, true); + return soul.drainWill(type, soulStack, requested, true); } } diff --git a/src/main/java/WayofTime/bloodmagic/util/handler/event/WillHandler.java b/src/main/java/WayofTime/bloodmagic/util/handler/event/WillHandler.java index cc6f1148..0192e3a6 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/event/WillHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/event/WillHandler.java @@ -51,10 +51,10 @@ public class WillHandler if (stack != null && stack.getItem() instanceof IDemonWill) { EntityPlayer player = event.getEntityPlayer(); - + EnumDemonWillType pickupType = ((IDemonWill) stack.getItem()).getType(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; event.setResult(Event.Result.ALLOW); @@ -108,8 +108,15 @@ public class WillHandler for (ItemStack willStack : droppedSouls) { 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(); } diff --git a/src/main/resources/assets/bloodmagic/blockstates/item/ItemMonsterSoul.json b/src/main/resources/assets/bloodmagic/blockstates/item/ItemMonsterSoul.json index d9d3497b..0b39b117 100644 --- a/src/main/resources/assets/bloodmagic/blockstates/item/ItemMonsterSoul.json +++ b/src/main/resources/assets/bloodmagic/blockstates/item/ItemMonsterSoul.json @@ -6,7 +6,27 @@ }, "variants": { "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": { "layer0": "bloodmagic:items/BaseMonsterSoul" } diff --git a/src/main/resources/assets/bloodmagic/lang/en_US.lang b/src/main/resources/assets/bloodmagic/lang/en_US.lang index e5ddcd28..07ffce4c 100644 --- a/src/main/resources/assets/bloodmagic/lang/en_US.lang +++ b/src/main/resources/assets/bloodmagic/lang/en_US.lang @@ -114,6 +114,10 @@ item.BloodMagic.demonCrystal.crystalVengeful.name=Vengeful Will Crystal item.BloodMagic.demonCrystal.crystalSteadfast.name=Steadfast Will Crystal 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.bloodLight.name=Sigil of the Blood Lamp