Add a inEffect NBT tag to the cloaks to prevent stack overflows with mods that deal damange when damaged. See #732

This commit is contained in:
Lizbeth Rika committed 2015-04-10 12:29:39 +01:00
1 parent 893cf4dc07
commit 87443b4003
1 file changed
+14 -1
@@ -41,6 +41,7 @@ public class ItemHolyCloak extends ItemBauble implements IBaubleRender {
private static ModelBiped model;
private static final String TAG_COOLDOWN = "cooldown";
private static final String TAG_IN_EFFECT = "inEffect";
public ItemHolyCloak() {
this(LibItemNames.HOLY_CLOAK);
@@ -57,11 +58,15 @@ public class ItemHolyCloak extends ItemBauble implements IBaubleRender {
EntityPlayer player = (EntityPlayer) event.entityLiving;
InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player);
ItemStack belt = baubles.getStackInSlot(3);
if(belt != null && belt.getItem() instanceof ItemHolyCloak) {
if(belt != null && belt.getItem() instanceof ItemHolyCloak && !isInEffect(belt)) {
ItemHolyCloak cloak = (ItemHolyCloak) belt.getItem();
int cooldown = getCooldown(belt);
// Used to prevent StackOverflows with mobs that deal damage when damaged
setInEffect(belt, true);
if(cooldown == 0 && cloak.effectOnDamage(event, player, belt))
setCooldown(belt, cloak.getCooldownTime(belt));
setInEffect(belt, false);
}
}
}
@@ -106,6 +111,14 @@ public class ItemHolyCloak extends ItemBauble implements IBaubleRender {
public static void setCooldown(ItemStack stack, int cooldown) {
ItemNBTHelper.setInt(stack, TAG_COOLDOWN, cooldown);
}
public static boolean isInEffect(ItemStack stack) {
return ItemNBTHelper.getBoolean(stack, TAG_IN_EFFECT, false);
}
public static void setInEffect(ItemStack stack, boolean effect) {
ItemNBTHelper.setBoolean(stack, TAG_IN_EFFECT, effect);
}
@SideOnly(Side.CLIENT)
ResourceLocation getRenderTexture() {