From 3d3ce53dddd1d8c79d5b93d78607e1652f5305c8 Mon Sep 17 00:00:00 2001 From: AEon - Tobias Date: Sat, 18 Aug 2018 03:13:00 +0200 Subject: [PATCH] Fix: Interaction Sigil of Holding + Seer/Divination Sigil (no render) (#1391) * Seer Sigil and Sigil of Divination now work properly when placed inside the Sigil of Holding closes #1285 * cleanup * Cleanup. --- .../element/ElementDivinedInformation.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/WayofTime/bloodmagic/client/hud/element/ElementDivinedInformation.java b/src/main/java/WayofTime/bloodmagic/client/hud/element/ElementDivinedInformation.java index c8244775..8563e015 100644 --- a/src/main/java/WayofTime/bloodmagic/client/hud/element/ElementDivinedInformation.java +++ b/src/main/java/WayofTime/bloodmagic/client/hud/element/ElementDivinedInformation.java @@ -1,12 +1,15 @@ package WayofTime.bloodmagic.client.hud.element; import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; +import WayofTime.bloodmagic.item.sigil.ItemSigilHolding; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumHand; +import java.util.List; + public abstract class ElementDivinedInformation extends ElementTileInformation { private final boolean simple; @@ -24,23 +27,38 @@ public abstract class ElementDivinedInformation extends El if (simple) { if (sigilStack.getItem() == RegistrarBloodMagicItems.SIGIL_DIVINATION) flag = true; + else flag = isFlagSigilHolding(sigilStack, true); if (!flag) { sigilStack = player.getHeldItem(EnumHand.OFF_HAND); if (sigilStack.getItem() == RegistrarBloodMagicItems.SIGIL_DIVINATION) flag = true; + else flag = isFlagSigilHolding(sigilStack, true); } + } else { if (sigilStack.getItem() == RegistrarBloodMagicItems.SIGIL_SEER) flag = true; + else flag = isFlagSigilHolding(sigilStack, false); if (!flag) { sigilStack = player.getHeldItem(EnumHand.OFF_HAND); if (sigilStack.getItem() == RegistrarBloodMagicItems.SIGIL_SEER) flag = true; + else flag = isFlagSigilHolding(sigilStack, false); } } - return super.shouldRender(minecraft) && flag; } + + private boolean isFlagSigilHolding(ItemStack sigilStack, boolean simple) { + if (sigilStack.getItem() instanceof ItemSigilHolding) { + List internalInv = ItemSigilHolding.getInternalInventory(sigilStack); + int currentSlot = ItemSigilHolding.getCurrentItemOrdinal(sigilStack); + if(internalInv != null && !internalInv.get(currentSlot).isEmpty()) { + return (internalInv.get(currentSlot).getItem() == RegistrarBloodMagicItems.SIGIL_SEER && !simple) || (internalInv.get(currentSlot).getItem() == RegistrarBloodMagicItems.SIGIL_DIVINATION && simple); + } + } + return false; + } }