for (int i = 0; i < items.tagCount(); i++) {
NBTTagCompound item = items.getCompoundTagAt(i);
int slot = item.getByte("Slot") & 255;
if ((slot < 0) || (slot >= EnumArmorStandRegion.values().length)) continue;
EnumArmorStandRegion region = EnumArmorStandRegion.values()[slot];
ArmorStandEquipHandler handler = BetterStorageArmorStand.getEquipHandler(
region, VanillaArmorStandEquipHandler.ID);
if (handler != null)
setItem(handler, ItemStack.loadItemStackFromNBT(item));
}
} else {
NBTTagCompound items = (NBTTagCompound)itemsTag;
for (EnumArmorStandRegion region : EnumArmorStandRegion.values()) {
NBTTagCompound regionItems = items.getCompoundTag(region.toString());
for (String id : (Set<String>)regionItems.func_150296_c()) {
ItemStack item = ItemStack.loadItemStackFromNBT(regionItems.getCompoundTag(id));
ArmorStandEquipHandler handler = BetterStorageArmorStand.getEquipHandler(region, id);
setItem(handler, item);
}
}
}
}