Search in sources :

Example 6 with NBTTagIntArray

use of net.minecraft.nbt.NBTTagIntArray in project VoodooCraft by Mod-DevCafeTeam.

the class CapabilityGlyphs method serializeNBT.

@Override
public NBTTagCompound serializeNBT() {
    NBTTagCompound nbt = new NBTTagCompound();
    int[] ids = new int[knownGlyphs.size()];
    for (int i = 0; i < knownGlyphs.size(); i++) ids[i] = knownGlyphs.get(i).ordinal();
    NBTTagIntArray glyphIDs = new NBTTagIntArray(ids);
    nbt.setTag("glyphs", glyphIDs);
    return nbt;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagIntArray(net.minecraft.nbt.NBTTagIntArray)

Example 7 with NBTTagIntArray

use of net.minecraft.nbt.NBTTagIntArray in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class StorageAirshipCounter method readNBT.

@Override
public void readNBT(Capability<IAirshipCounterCapability> capability, IAirshipCounterCapability instance, EnumFacing side, NBTBase nbt) {
    NBTTagIntArray tag = (NBTTagIntArray) nbt;
    instance.setAirshipCount(tag.getIntArray()[0]);
    instance.setAirshipCountEver(tag.getIntArray()[1]);
}
Also used : NBTTagIntArray(net.minecraft.nbt.NBTTagIntArray)

Example 8 with NBTTagIntArray

use of net.minecraft.nbt.NBTTagIntArray in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ControlEventsCommon method onAttachCapabilityEventItem.

@SubscribeEvent
public void onAttachCapabilityEventItem(AttachCapabilitiesEvent event) {
    if (event instanceof AttachCapabilitiesEvent.Item) {
        AttachCapabilitiesEvent.Item itemEvent = (AttachCapabilitiesEvent.Item) event;
        ItemStack stack = itemEvent.getItemStack();
        if (itemEvent.getItem() instanceof ItemRelayWire) {
            //				System.out.println("Obama?");
            event.addCapability(new ResourceLocation(ValkyrienWarfareControlMod.MODID, "LastRelay"), new ICapabilitySerializable<NBTTagIntArray>() {

                ICapabilityLastRelay inst = ValkyrienWarfareControlMod.lastRelayCapability.getDefaultInstance();

                @Override
                public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
                    return capability == ValkyrienWarfareControlMod.lastRelayCapability;
                }

                @Override
                public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
                    return capability == ValkyrienWarfareControlMod.lastRelayCapability ? ValkyrienWarfareControlMod.lastRelayCapability.<T>cast(inst) : null;
                }

                @Override
                public NBTTagIntArray serializeNBT() {
                    return (NBTTagIntArray) ValkyrienWarfareControlMod.lastRelayCapability.getStorage().writeNBT(ValkyrienWarfareControlMod.lastRelayCapability, inst, null);
                }

                @Override
                public void deserializeNBT(NBTTagIntArray nbt) {
                    ValkyrienWarfareControlMod.lastRelayCapability.getStorage().readNBT(ValkyrienWarfareControlMod.lastRelayCapability, inst, null, nbt);
                }
            });
        }
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) NBTTagIntArray(net.minecraft.nbt.NBTTagIntArray) AttachCapabilitiesEvent(net.minecraftforge.event.AttachCapabilitiesEvent) ItemRelayWire(ValkyrienWarfareControl.Item.ItemRelayWire) ResourceLocation(net.minecraft.util.ResourceLocation) ICapabilityLastRelay(ValkyrienWarfareControl.Capability.ICapabilityLastRelay) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

NBTTagIntArray (net.minecraft.nbt.NBTTagIntArray)8 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 NBTTagList (net.minecraft.nbt.NBTTagList)4 Map (java.util.Map)3 NBTBase (net.minecraft.nbt.NBTBase)3 NBTTagString (net.minecraft.nbt.NBTTagString)3 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 List (java.util.List)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 NBTTagInt (net.minecraft.nbt.NBTTagInt)2 NBTTagLong (net.minecraft.nbt.NBTTagLong)2 NBTTagShort (net.minecraft.nbt.NBTTagShort)2 ICapabilityLastRelay (ValkyrienWarfareControl.Capability.ICapabilityLastRelay)1 ItemRelayWire (ValkyrienWarfareControl.Item.ItemRelayWire)1 JsonElement (com.google.gson.JsonElement)1 JsonPrimitive (com.google.gson.JsonPrimitive)1