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.
This commit is contained in:
AEon - Tobias 2018-08-18 03:13:00 +02:00 committed by Nick Ignoffo
parent 92e3333701
commit 3d3ce53ddd

View file

@ -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<T extends TileEntity> extends ElementTileInformation<T> {
private final boolean simple;
@ -24,23 +27,38 @@ public abstract class ElementDivinedInformation<T extends TileEntity> 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<ItemStack> 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;
}
}