From eaba4e6cc23d4bcacaf65ae423f8318d131c6ad7 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Fri, 29 Jan 2016 21:19:59 -0500 Subject: [PATCH] Made it so that Demon Will will be voided if the player's tartaric gems are all full. --- .../api/soul/PlayerDemonWillHandler.java | 27 +++++++++++++++++++ .../item/soul/ItemSentientSword.java | 5 ++-- .../bloodmagic/util/handler/EventHandler.java | 2 +- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java b/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java index f51c910a..53c789ca 100644 --- a/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java +++ b/src/main/java/WayofTime/bloodmagic/api/soul/PlayerDemonWillHandler.java @@ -37,6 +37,33 @@ public class PlayerDemonWillHandler return souls; } + /** + * Checks if the player's Tartaric gems are completely full. If so, it will + * return true. + * + */ + public static boolean isDemonWillFull(EntityPlayer player) + { + ItemStack[] inventory = player.inventory.mainInventory; + + for (int i = 0; i < inventory.length; i++) + { + ItemStack stack = inventory[i]; + if (stack != null) + { + if (stack.getItem() instanceof IDemonWillGem) + { + if (((IDemonWillGem) stack.getItem()).getWill(stack) < ((IDemonWillGem) stack.getItem()).getMaxWill(stack)) + { + return false; + } + } + } + } + + return true; + } + /** * * @param player diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java index 2b732cb1..0eec1fb1 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java @@ -1,6 +1,7 @@ package WayofTime.bloodmagic.item.soul; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import net.minecraft.entity.Entity; @@ -94,7 +95,7 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon { NBTHelper.checkNBT(stack); - tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.sentientSword.desc")); + tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.BloodMagic.sentientSword.desc")))); if (getActivated(stack)) tooltip.add(TextHelper.localize("tooltip.BloodMagic.activated")); @@ -155,7 +156,7 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon for (int i = 0; i <= looting; i++) { - if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.3) + if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4) { ItemStack soulStack = soul.createWill(0, this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)); soulList.add(soulStack); diff --git a/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java b/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java index adcdacd6..b16945d7 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java @@ -392,7 +392,7 @@ public class EventHandler ItemStack remainder = PlayerDemonWillHandler.addDemonWill(player, stack); - if (remainder == null || ((IDemonWill) stack.getItem()).getWill(stack) < 0.0001) + if (remainder == null || ((IDemonWill) stack.getItem()).getWill(stack) < 0.0001 || PlayerDemonWillHandler.isDemonWillFull(player)) { stack.stackSize = 0; event.setResult(Result.ALLOW);