Search in sources :

Example 6 with ArmorStandEquipHandler

use of net.mcft.copy.betterstorage.api.stand.ArmorStandEquipHandler in project BetterStorage by copygirl.

the class TileEntityArmorStand method read.

public void read(NBTTagCompound compound) {
    rotation = compound.getByte("rotation");
    clearItems();
    NBTBase itemsTag = compound.getTag("Items");
    if (itemsTag instanceof NBTTagList) {
        // Backward compatibility.
        NBTTagList items = (NBTTagList) itemsTag;
        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);
            }
        }
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) Set(java.util.Set) NBTBase(net.minecraft.nbt.NBTBase) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ArmorStandEquipHandler(net.mcft.copy.betterstorage.api.stand.ArmorStandEquipHandler) EnumArmorStandRegion(net.mcft.copy.betterstorage.api.stand.EnumArmorStandRegion) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ArmorStandEquipHandler (net.mcft.copy.betterstorage.api.stand.ArmorStandEquipHandler)6 EnumArmorStandRegion (net.mcft.copy.betterstorage.api.stand.EnumArmorStandRegion)6 ItemStack (net.minecraft.item.ItemStack)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 Set (java.util.Set)1 TileEntityArmorStand (net.mcft.copy.betterstorage.tile.stand.TileEntityArmorStand)1 NBTBase (net.minecraft.nbt.NBTBase)1 NBTTagList (net.minecraft.nbt.NBTTagList)1