SoulBound support for additional TC slots

(Travellers Belt and such)
This commit is contained in:
Ugachaga committed 2017-03-08 12:17:48 +07:00
1 parent d3a7a48985
commit fec73ec498
1 file changed
+38 -1
@@ -7,6 +7,8 @@ import io.netty.buffer.ByteBuf;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.*;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.*;
import net.minecraft.entity.item.EntityItem;
@@ -238,13 +240,48 @@ public class ArmorExtended implements IInventory
}
}
// --- EnderIO SoulBound enchant support
private static int soulBoundID = -6;
public static int getSoulBoundID() {
if (soulBoundID == -6) setSoulBoundID();
return soulBoundID;
}
private static void setSoulBoundID() {
for (Enchantment ench : Enchantment.enchantmentsList) {
if (ench != null && ench.getName().equals("enchantment.enderio.soulBound")) {
soulBoundID = ench.effectId;
return;
}
}
soulBoundID = -1;
}
public static boolean isSoulBounded(ItemStack stack) {
int soulBound = getSoulBoundID();
NBTTagList stackEnch = stack.getEnchantmentTagList();
if (soulBound >= 0 && stackEnch != null) {
for (int i = 0; i < stackEnch.tagCount(); i++) {
int id = stackEnch.getCompoundTagAt(i).getInteger("id");
if (id == soulBound) return true;
}
}
return false;
}
// ---
public void dropItems ()
{
EntityPlayer player = parent.get();
for (int i = 0; i < 4; ++i)
{
if (this.inventory[i] != null)
if (this.inventory[i] != null && !isSoulBounded(this.inventory[i]))
{
player.func_146097_a(this.inventory[i], true, false);
this.inventory[i] = null;