Search in sources :

Example 6 with NBTTagInt

use of net.minecraft.nbt.NBTTagInt in project minecolonies by Minecolonies.

the class AbstractCombinedItemHandler method serializeNBT.

@SuppressWarnings(RAWTYPES)
@Override
public NBTTagCompound serializeNBT() {
    final NBTTagCompound compound = new NBTTagCompound();
    int index = 0;
    final NBTTagList handlerList = new NBTTagList();
    final NBTTagList indexList = new NBTTagList();
    for (final IItemHandlerModifiable handlerModifiable : handlers) {
        if (handlerModifiable instanceof INBTSerializable) {
            final INBTSerializable serializable = (INBTSerializable) handlerModifiable;
            handlerList.appendTag(serializable.serializeNBT());
            indexList.appendTag(new NBTTagInt(index));
        }
        index++;
    }
    compound.setTag(NBT_KEY_HANDLERS, handlerList);
    if (hasCustomName()) {
        compound.setString(NBT_KEY_NAME, customName);
    }
    return compound;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) NBTTagInt(net.minecraft.nbt.NBTTagInt) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) INBTSerializable(net.minecraftforge.common.util.INBTSerializable)

Aggregations

NBTTagInt (net.minecraft.nbt.NBTTagInt)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 NBTTagList (net.minecraft.nbt.NBTTagList)5 List (java.util.List)2 Map (java.util.Map)2 NBTBase (net.minecraft.nbt.NBTBase)2 NBTTagByte (net.minecraft.nbt.NBTTagByte)2 NBTTagByteArray (net.minecraft.nbt.NBTTagByteArray)2 NBTTagDouble (net.minecraft.nbt.NBTTagDouble)2 NBTTagFloat (net.minecraft.nbt.NBTTagFloat)2 NBTTagIntArray (net.minecraft.nbt.NBTTagIntArray)2 NBTTagLong (net.minecraft.nbt.NBTTagLong)2 NBTTagShort (net.minecraft.nbt.NBTTagShort)2 NBTTagString (net.minecraft.nbt.NBTTagString)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 SecurityStationCCIDs (logisticspipes.network.packets.block.SecurityStationCCIDs)1