Java 类net.minecraft.nbt.NBTTagInt 实例源码

项目:Loot-Slash-Conquer    文件:CapabilityChunkLevel.java   
@SubscribeEvent
public static void onChunkLoad(ChunkDataEvent.Load event)
{
    World world = event.getWorld();
    ChunkPos chunkPos = event.getChunk().getPos();

    IChunkLevelHolder chunkLevelHolder = getChunkLevelHolder(world);
    ChunkLevel chunkLevel = new ChunkLevel(world, chunkPos, getAreaLevel(world, chunkPos));

    NBTTagCompound nbt = event.getData();

    if (nbt.hasKey(ID.toString(), Constants.NBT.TAG_INT))
    {
        NBTTagInt levelTag = (NBTTagInt) nbt.getTag(ID.toString());
        chunkLevel.deserializeNBT(levelTag);
    }

    chunkLevelHolder.setChunkLevel(null, chunkLevel);
}
项目:Backmemed    文件:NbtTagValue.java   
private static NBTBase getChildTag(NBTBase p_getChildTag_0_, String p_getChildTag_1_)
{
    if (p_getChildTag_0_ instanceof NBTTagCompound)
    {
        NBTTagCompound nbttagcompound = (NBTTagCompound)p_getChildTag_0_;
        return nbttagcompound.getTag(p_getChildTag_1_);
    }
    else if (p_getChildTag_0_ instanceof NBTTagList)
    {
        NBTTagList nbttaglist = (NBTTagList)p_getChildTag_0_;

        if (p_getChildTag_1_.equals("count"))
        {
            return new NBTTagInt(nbttaglist.tagCount());
        }
        else
        {
            int i = Config.parseInt(p_getChildTag_1_, -1);
            return i < 0 ? null : nbttaglist.get(i);
        }
    }
    else
    {
        return null;
    }
}
项目:Mods    文件:TF2EventsCommon.java   
@Override
public NBTTagCompound serializeNBT() {
    NBTTagCompound nbt=new NBTTagCompound();
    nbt.setInteger("Event", eventFlag);
    NBTTagCompound items=new NBTTagCompound();
    nbt.setTag("Items", items);
    NBTTagList bannersS = new NBTTagList();
    for(BlockPos pos:banners){

        NBTTagList coords = new NBTTagList();
        coords.appendTag(new NBTTagInt(pos.getX()));
        coords.appendTag(new NBTTagInt(pos.getY()));
        coords.appendTag(new NBTTagInt(pos.getZ()));
        bannersS.appendTag(coords);
    }
    nbt.setTag("Banners", bannersS);
    for(Entry<String,MerchantRecipeList> entry:lostItems.entrySet()){
        items.setTag(entry.getKey(), entry.getValue().getRecipiesAsTags());
    }
    return nbt;
}
项目:ExtraUtilities    文件:TileEntityEnderThermicLavaPump.java   
public void readFromNBT(final NBTTagCompound par1NBTTagCompound) {
    super.readFromNBT(par1NBTTagCompound);
    if (par1NBTTagCompound.hasKey("block_no") && par1NBTTagCompound.getTag("block_no") instanceof NBTTagInt) {
        this.b = par1NBTTagCompound.getInteger("block_no");
    }
    else {
        LogHelper.info("Extra Utilities: Problem loading EnderPump TileEntity Tag (block_no)", new Object[0]);
    }
    if (par1NBTTagCompound.hasKey("chunk_no") && par1NBTTagCompound.getTag("chunk_no") instanceof NBTTagByte) {
        this.chunk_no = par1NBTTagCompound.getByte("chunk_no");
    }
    else {
        LogHelper.info("Extra Utilities: Problem loading EnderPump TileEntity Tag (chunk_no)", new Object[0]);
    }
    if (this.chunk_no == -128) {
        this.finished = true;
    }
    else {
        this.setChunk(this.chunk_no);
    }
    this.tank.readFromNBT(par1NBTTagCompound.getCompoundTag("tank"));
    this.init = true;
}
项目:TeleToro    文件:ItemTeletoryPortalLinker.java   
private void linkPortalWithOrigin(EntityPlayer player, World world, ItemStack stack, ControlBlockLocation thisPortal,
        PortalLinkerOrigin remoteInfo) {

    ControlBlockLocation remotePortal = findControllerBlock(world, remoteInfo.pos, STANDARD_SIZER);

    stack.setTagInfo("origin", new NBTTagLong(0));
    stack.setTagInfo("dimid", new NBTTagInt(0));

    if (remotePortal == null) {
        return;
    }

    linkPortalTo(world, thisPortal, remotePortal, remoteInfo.dimId, remoteInfo.side);
    linkPortalTo(world, remotePortal, thisPortal, player.dimension, getSide(player, thisPortal));

    playSound(player);
    stack.damageItem(1, player);
}
项目:ToroHealth    文件:ClientProxy.java   
@Override
public void displayDamageDealt(EntityLivingBase entity) {

    if (!entity.world.isRemote) {
        return;
    }

    if (!ConfigurationHandler.showDamageParticles) {
        return;
    }

    int currentHealth = (int) Math.ceil(entity.getHealth());

    if (entity.getEntityData().hasKey("health")) {
        int entityHealth = ((NBTTagInt) entity.getEntityData().getTag("health")).getInt();

        if (entityHealth != currentHealth) {
            displayParticle(entity, (int) entityHealth - currentHealth);
        }
    }

    entity.getEntityData().setTag("health", new NBTTagInt(currentHealth));
}
项目:Minecraft-Flux    文件:MCFluxEvents.java   
@SubscribeEvent
public static void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent e) {
    if (MCFlux.UPDATE_CHECK_FINISHED && !MCFlux.NEWER_VERSION.isEmpty() && e.player instanceof EntityPlayerMP)
        MCFluxNetwork.to(Msg.newVersion(MCFlux.NEWER_VERSION), (EntityPlayerMP) e.player);
    if (SpecialEventHandler.getEventStatus() == SpecialEventHandler.EventStatus.DOWNLOADED) {
        final SpecialEventReceiver ser = e.player.getCapability(SpecialEventReceiver.SELF_CAP, null);
        if (ser != null) {
            final int[] seids = SpecialEventHandler.getEventIDs();
            for (int l : seids) {
                if (ser.alreadyReceived(l))
                    continue;
                final ItemStack is = new ItemStack(MCFluxResources.SPECIAL);
                is.setTagInfo("seid", new NBTTagInt(l));
                e.player.dropItem(is, false, true);
                ser.addReceived(l);
            }
        }
    }
}
项目:T.E.C.H    文件:TileEntityConveyor.java   
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
    super.writeToNBT(compound);
    NBTTagCompound itemsMap = new NBTTagCompound();
    NBTTagList keys = new NBTTagList();
    NBTTagList values = new NBTTagList();
    itemsMap.setInteger("size", itemMap.size());
    for (Map.Entry<Integer, Integer> ent : itemMap.entrySet()) {
        NBTTagInt key = new NBTTagInt(ent.getKey());
        NBTTagInt value = new NBTTagInt(ent.getValue());
        keys.appendTag(key);
        values.appendTag(value);
    }
    itemsMap.setTag("keys", keys);
    itemsMap.setTag("values", values);
    compound.setTag("itemsMap", itemsMap);
    compound.setTag("items", itemStackHandler.serializeNBT());
    return compound;
}
项目:TaleCraft    文件:UndoRegion.java   
public NBTTagCompound toNBT(){
    NBTTagCompound tag = new NBTTagCompound();
    tag.setInteger("x", xPos);
    tag.setInteger("y", yPos);
    tag.setInteger("z", zPos);

    tag.setInteger("width", width);
    tag.setInteger("height", height);
    tag.setInteger("length", length);

    tag.setInteger("world", world.provider.getDimension());

    NBTTagList list = new NBTTagList();
    for(IBlockState state : blocks){
        list.appendTag(new NBTTagInt(Block.getStateId(state)));
    }
    tag.setTag("blocks", list);
    return tag;
}
项目:TaleCraft    文件:NBTHelper.java   
private static void asJson(NBTBase tag, StringBuilder builder) {
    switch(tag.getId()) {
    case NBT.TAG_BYTE: builder.append(((NBTTagByte)tag).getByte()).append('b'); break;
    case NBT.TAG_SHORT: builder.append(((NBTTagShort)tag).getByte()).append('b'); break;
    case NBT.TAG_INT: builder.append(((NBTTagInt)tag).getInt()); break;
    case NBT.TAG_LONG: builder.append(((NBTTagLong)tag).getByte()).append('l'); break;
    case NBT.TAG_FLOAT: builder.append(((NBTTagFloat)tag).getFloat()).append('f'); break;
    case NBT.TAG_DOUBLE: builder.append(((NBTTagDouble)tag).getDouble()).append('d'); break;
    case NBT.TAG_STRING: builder.append('"').append(((NBTTagString)tag).getString()).append('"'); break;
    case NBT.TAG_BYTE_ARRAY: builder.append(Arrays.toString(((NBTTagByteArray)tag).getByteArray())); break;
    case NBT.TAG_INT_ARRAY: builder.append(Arrays.toString(((NBTTagIntArray)tag).getIntArray())); break;
    case NBT.TAG_COMPOUND: asJson((NBTTagCompound) tag, builder); break;
    case NBT.TAG_LIST: asJson((NBTTagList) tag, builder); break;
    }

}
项目:CivCraft    文件:TechTree.java   
private Tech(NBTTagCompound nbt, String name) {
    this.name = name;
    NBTTagList parents = nbt.getTagList("parents", Lib.NBT.STRING);
    for (int idx = 0; idx < parents.tagCount(); idx++) {
        String parentName = parents.getStringTagAt(idx);
        Tech parent = TechTree.this.getTech(parentName);
        addRequirement(parent);
    }
    NBTTagList sciencePacks = nbt.getTagList("sciencePacks", Lib.NBT.INTEGER);
    int[] required = new int[sciencePacks.tagCount()];
    for (int idx = 0; idx < sciencePacks.tagCount(); idx++) {
        required[idx] = ((NBTTagInt) sciencePacks.get(idx)).getInt();
    }
    this.sciencePacks = required;
    leafTech = nbt.getBoolean("leaf");
    if (leafTech)
        setLeafTech();
}
项目:CivCraft    文件:ConfigCompat.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void addTechs(AddTechs t) {
    TechTree tree = t.tree;
    NBTTagCompound n = t.treeNBTCompound;
    NBTTagCompound techs = n.getCompoundTag("techs");

    for (Object key : techs.getKeySet()) {
        NBTTagCompound tech = techs.getCompoundTag((String) key);
        // Almost directly copied from new TechTree.Tech()
        Tech techAdded = tree.addTech((String) key);
        NBTTagList nbtparents = tech.getTagList("parents", Lib.NBT.STRING);
        for (int idx = 0; idx < nbtparents.tagCount(); idx++) {
            String parentName = nbtparents.getStringTagAt(idx);
            Tech parent = tree.getTech(parentName);
            techAdded.addRequirement(parent);
        }
        NBTTagList sciencePacks = tech.getTagList("sciencePacks", Lib.NBT.INTEGER);
        int[] required = new int[sciencePacks.tagCount()];
        for (int idx = 0; idx < sciencePacks.tagCount(); idx++) {
            required[idx] = ((NBTTagInt) sciencePacks.get(idx)).getInt();
        }
        techAdded.setSciencePacksNeeded(required);
        if (tech.getBoolean("leaf"))
            techAdded.setLeafTech();
    }
}
项目:ToggleBlocks    文件:BlockChangeBlock.java   
public static void updateRemainingChangeBlocks(ItemStack stack, World world)
{
    ControllerInfo info = new ControllerInfo(stack);
    if (info.initialized)
    {
        int x = info.x, y = info.y, z = info.z;
        TileEntity entity = world.getTileEntity(x, y, z);
        if (entity instanceof IToggleController)
        {
            IToggleController controller = (IToggleController) entity;
            int max = controller.getMaxChangeBlocks();
            int remaining = max != -1 ? controller.getMaxChangeBlocks() - controller.getRegisteredChangeBlockCount() : -1;
            if (remaining == 0)
                stack.stackSize = 0;
            stack.setTagInfo(REMAINING_CHANGE_BLOCKS, new NBTTagInt(remaining));
        }
    }
}
项目:copycore    文件:NbtUtils.java   
/** Creates and returns a primitive NBT tag from a value.
 *  If the value already is an NBT tag, it is returned instead. */
public static NBTBase createTag(Object value) {
    if (value == null)
        throw new IllegalArgumentException("value is null");
    if (value instanceof NBTBase) return (NBTBase)value;
    if (value instanceof Byte)    return new NBTTagByte((Byte)value);
    if (value instanceof Short)   return new NBTTagShort((Short)value);
    if (value instanceof Integer) return new NBTTagInt((Integer)value);
    if (value instanceof Long)    return new NBTTagLong((Long)value);
    if (value instanceof Float)   return new NBTTagFloat((Float)value);
    if (value instanceof Double)  return new NBTTagDouble((Double)value);
    if (value instanceof String)  return new NBTTagString((String)value);
    if (value instanceof byte[])  return new NBTTagByteArray((byte[])value);
    if (value instanceof int[])   return new NBTTagIntArray((int[])value);
    throw new IllegalArgumentException("Can't create an NBT tag of value: " + value);
}
项目:CraftingManager    文件:ConvertNBTTagCompound.java   
public static Object getObject(NBTBase base)
{
    if(base instanceof NBTTagByte)
        return ((NBTTagByte)base).func_150290_f();
    if(base instanceof NBTTagShort)
        return ((NBTTagShort)base).func_150289_e();
    if(base instanceof NBTTagInt)
        return ((NBTTagInt)base).func_150287_d();
    if(base instanceof NBTTagLong)
        return ((NBTTagLong)base).func_150291_c();
    if(base instanceof NBTTagFloat)
        return ((NBTTagFloat)base).func_150288_h();
    if(base instanceof NBTTagDouble)
        return ((NBTTagDouble)base).func_150286_g();
    if(base instanceof NBTTagByteArray)
        return ((NBTTagByteArray)base).func_150292_c();
    if(base instanceof NBTTagString)
        return ((NBTTagString)base).func_150285_a_();
    if(base instanceof NBTTagList)
        return base;
    if(base instanceof NBTTagCompound)
        return ((NBTTagCompound)base);
    if(base instanceof NBTTagIntArray)
        return ((NBTTagIntArray)base).func_150302_c();
    return null;
}
项目:NBTEdit    文件:GuiEditNBT.java   
private static void setValidValue(Node<NamedNBT> node, String value){
    NamedNBT named = node.getObject();
    NBTBase base = named.getNBT();

    if (base instanceof NBTTagByte)
        named.setNBT(new NBTTagByte(ParseHelper.parseByte(value)));
    if (base instanceof NBTTagShort)
        named.setNBT(new NBTTagShort(ParseHelper.parseShort(value)));
    if (base instanceof NBTTagInt)
        named.setNBT(new NBTTagInt(ParseHelper.parseInt(value)));
    if (base instanceof NBTTagLong)
        named.setNBT(new NBTTagLong(ParseHelper.parseLong(value)));
    if(base instanceof NBTTagFloat)
        named.setNBT(new NBTTagFloat(ParseHelper.parseFloat(value)));
    if(base instanceof NBTTagDouble)
        named.setNBT(new NBTTagDouble(ParseHelper.parseDouble(value)));
    if(base instanceof NBTTagByteArray)
        named.setNBT(new NBTTagByteArray(ParseHelper.parseByteArray(value)));
    if(base instanceof NBTTagIntArray)
        named.setNBT(new NBTTagIntArray(ParseHelper.parseIntArray(value)));
    if (base instanceof NBTTagString)
        named.setNBT(new NBTTagString(value));
}
项目:Dota2Items    文件:EntityStats.java   
@Override
public void saveNBTData(NBTTagCompound compound) {
    compound.setFloat(TAG_MANA, getFloatMana());
    compound.setFloat(TAG_PARTIAL_HP, partialHalfHeart);
    compound.setFloat(TAG_RELIABLE_GOLD, getReliableGold());
    compound.setFloat(TAG_UNRELIABLE_GOLD, getUnreliableGold());
    NBTTagList buffsList = new NBTTagList();
    for (BuffInstance buffInst : appliedBuffs) {
        buffsList.appendTag(buffInst.toNBT());
    }
    compound.setTag(TAG_BUFFS, buffsList);
    NBTTagList attackersList = new NBTTagList();
    synchronized (playerAttackersIDs) {
        for (Integer playerID : playerAttackersIDs) {
            attackersList.appendTag(new NBTTagInt(TAG_ATTACKER_ID, playerID.intValue()));
        }
    }
    compound.setTag(TAG_ATTACKERS, attackersList);
}
项目:Dota2Items    文件:EntityStats.java   
@Override
public void loadNBTData(NBTTagCompound compound) {
    this.curMana = compound.getFloat(TAG_MANA);
    this.partialHalfHeart = compound.getFloat(TAG_PARTIAL_HP);
    this.reliableGold = compound.getFloat(TAG_RELIABLE_GOLD);
    this.unreliableGold = compound.getFloat(TAG_UNRELIABLE_GOLD);
    NBTTagList buffsList = compound.getTagList(TAG_BUFFS);
    for (int i = 0; i < buffsList.tagCount(); i++) {
        NBTTagCompound buffTag = (NBTTagCompound) buffsList.tagAt(i);
        BuffInstance buffInst = BuffInstance.fromNBT(buffTag, entity);
        addBuff(buffInst);
    }
    NBTTagList attackersList = compound.getTagList(TAG_ATTACKERS);
    for (int i = 0; i < attackersList.tagCount(); i++) {
        NBTTagInt playerID = (NBTTagInt) attackersList.tagAt(i);
        addPlayerAttackerID(playerID.data);
    }
}
项目:VillagerTweaks    文件:MagicHelper.java   
/**
 * Returns all valid golem enchantments in the given pumpkin.
 * 
 */
public static int[] getEnchantmentIds(ItemStack itemStack) {
    int[] enchants = null;

    if (itemStack.getItem() == Item.getItemFromBlock(Blocks.pumpkin)) {
        // Get a tagList of type 3 (integers)
        NBTTagList tag = itemStack.hasTagCompound() ? itemStack.getTagCompound().getTagList(MagicHelper.GolemEnchantmentsNBTKey, 3) : null;

        // Loads the enchantments
        if (tag != null && !tag.hasNoTags()) {
            enchants = new int[tag.tagCount()]; 
            for (int i = 0; i < enchants.length; i++) {
                int enchId = ((NBTTagInt)tag.get(i)).getInt();
                enchants[i] = enchId;
            }
        }

    }

    return enchants;
}
项目:Industrial-Foregoing    文件:ItemSplitterTile.java   
public ItemSplitterTile() {
    super(ItemSplitterTile.class.getName().hashCode());
    input = this.addSimpleInventory(3, "input", EnumDyeColor.BLUE, "input items", new BoundingRectangle(18, 25, 18, 18 * 3), (stack, integer) -> true, (stack, integer) -> false, true, 0);
    fakeOut = this.addSimpleInventory(0, "out", EnumDyeColor.ORANGE, "output items", new BoundingRectangle(30, 90, 0, 0), (stack, integer) -> false, (stack, integer) -> false, false, 0);
    tick = 1;
    size = 1;
    registerSyncIntPart("size", nbtTagInt -> size = nbtTagInt.getInt(), () -> new NBTTagInt(size), SyncProviderLevel.GUI);
}
项目:harshencastle    文件:HarshenTemplate.java   
private NBTTagList writeInts(int... values)
{
    NBTTagList nbttaglist = new NBTTagList();

    for (int i : values)
    {
        nbttaglist.appendTag(new NBTTagInt(i));
    }

    return nbttaglist;
}
项目:Anima-Mundi    文件:CapabilityAnima.java   
@Override
public void readNBT(Capability<IAnimaStorage> capability, IAnimaStorage instance, EnumFacing side, NBTBase nbt)
{
    if(!(instance instanceof AnimaStorage))
        throw new IllegalArgumentException("Can not deserialize to an instance that isn't the default implementation");
    ((AnimaStorage) instance).energy = ((NBTTagInt) nbt).getInt();
}
项目:Thermionics    文件:DefaultHeatStorageSerializer.java   
@Override
public NBTBase writeNBT(Capability<IHeatStorage> capability, IHeatStorage instance, EnumFacing side) {
    return new NBTTagInt(instance.getHeatStored());
    //NBTTagCompound tag = new NBTTagCompound();
    //tag.setInteger("enthalpy", instance.getHeatStored());
    //return tag;
}
项目:Thermionics    文件:DefaultHeatStorageSerializer.java   
@Override
public void readNBT(Capability<IHeatStorage> capability, IHeatStorage instance, EnumFacing side, NBTBase nbt) {
    if (nbt instanceof NBTTagCompound) {
        NBTTagCompound tag = (NBTTagCompound)nbt;

        int toReceive = tag.getInteger("enthalpy") - instance.getHeatStored();
        instance.receiveHeat(toReceive, false);
    }

    if (nbt instanceof NBTTagInt) {
        instance.receiveHeat(((NBTTagInt)nbt).getInt(), false);
    }
}
项目:Thermionics    文件:TileEntityMashTun.java   
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagIn) {
    NBTTagCompound tagOut = super.writeToNBT(tagIn);
    tagOut.setTag("inputtank", CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.writeNBT(inputTank, null));
    tagOut.setTag("outputtank", CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.writeNBT(outputTank, null));
    tagOut.setTag("heatstorage", Thermionics.CAPABILITY_HEATSTORAGE.writeNBT(heat, null));
    tagOut.setTag("inventory", CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.writeNBT(items, null));

    tagOut.setTag("cooldown", new NBTTagInt(cooldown));

    return tagOut;
}
项目:Backmemed    文件:DragonFightManager.java   
public NBTTagCompound getCompound()
{
    NBTTagCompound nbttagcompound = new NBTTagCompound();

    if (this.dragonUniqueId != null)
    {
        nbttagcompound.setUniqueId("DragonUUID", this.dragonUniqueId);
    }

    nbttagcompound.setBoolean("DragonKilled", this.dragonKilled);
    nbttagcompound.setBoolean("PreviouslyKilled", this.previouslyKilled);

    if (this.exitPortalLocation != null)
    {
        nbttagcompound.setTag("ExitPortalLocation", NBTUtil.createPosTag(this.exitPortalLocation));
    }

    NBTTagList nbttaglist = new NBTTagList();
    Iterator iterator = this.gateways.iterator();

    while (iterator.hasNext())
    {
        int i = ((Integer)iterator.next()).intValue();
        nbttaglist.appendTag(new NBTTagInt(i));
    }

    nbttagcompound.setTag("Gateways", nbttaglist);
    return nbttagcompound;
}
项目:Backmemed    文件:Template.java   
private NBTTagList writeInts(int... values)
{
    NBTTagList nbttaglist = new NBTTagList();

    for (int i : values)
    {
        nbttaglist.appendTag(new NBTTagInt(i));
    }

    return nbttaglist;
}
项目:Mods    文件:TileEntityUpgrades.java   
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
    super.writeToNBT(compound);
    NBTTagCompound attrs = new NBTTagCompound();
    NBTTagList attrList = new NBTTagList();
    compound.setTag("Attributes", attrs);
    compound.setTag("AttributesList", attrList);
    for (TF2Attribute attr : this.attributeList)
        if (attr != null) {
            attrList.appendTag(new NBTTagInt(attr.id));
            attrs.setInteger(String.valueOf(attr.id), this.attributes.get(attr));
        }

    return compound;
}
项目:CustomWorldGen    文件:DragonFightManager.java   
public NBTTagCompound getCompound()
{
    NBTTagCompound nbttagcompound = new NBTTagCompound();

    if (this.dragonUniqueId != null)
    {
        nbttagcompound.setUniqueId("DragonUUID", this.dragonUniqueId);
    }

    nbttagcompound.setBoolean("DragonKilled", this.dragonKilled);
    nbttagcompound.setBoolean("PreviouslyKilled", this.previouslyKilled);

    if (this.exitPortalLocation != null)
    {
        nbttagcompound.setTag("ExitPortalLocation", NBTUtil.createPosTag(this.exitPortalLocation));
    }

    NBTTagList nbttaglist = new NBTTagList();
    Iterator iterator = this.gateways.iterator();

    while (iterator.hasNext())
    {
        int i = ((Integer)iterator.next()).intValue();
        nbttaglist.appendTag(new NBTTagInt(i));
    }

    nbttagcompound.setTag("Gateways", nbttaglist);
    return nbttagcompound;
}
项目:CustomWorldGen    文件:Template.java   
private NBTTagList writeInts(int... values)
{
    NBTTagList nbttaglist = new NBTTagList();

    for (int i : values)
    {
        nbttaglist.appendTag(new NBTTagInt(i));
    }

    return nbttaglist;
}
项目:NemesisSystem    文件:DiscoveryUtil.java   
public static ItemStack createUnreadBook() {
    ItemStack book = new ItemStack(Items.WRITTEN_BOOK, 1);
    NBTTagCompound bookNbt = new NBTTagCompound();
    bookNbt.setTag(NBT_UNREAD_DISCOVERY, new NBTTagInt(nextBookID++));
    book.setTagCompound(bookNbt);
    book.setStackDisplayName("Unread Nemesis Book");
    return book;
}
项目:ExtraUtilities    文件:WidgetTextData.java   
public static Object getNBTBaseData(final NBTBase nbt) {
    if (nbt == null) {
        return null;
    }
    switch (nbt.getId()) {
        case 1: {
            return ((NBTTagByte)nbt).func_150290_f();
        }
        case 2: {
            return ((NBTTagShort)nbt).func_150289_e();
        }
        case 3: {
            return ((NBTTagInt)nbt).func_150287_d();
        }
        case 4: {
            return ((NBTTagLong)nbt).func_150291_c();
        }
        case 5: {
            return ((NBTTagFloat)nbt).func_150288_h();
        }
        case 6: {
            return ((NBTTagDouble)nbt).func_150286_g();
        }
        case 8: {
            return ((NBTTagString)nbt).func_150285_a_();
        }
        case 10: {
            return nbt;
        }
        default: {
            return null;
        }
    }
}
项目:ExtraUtilities    文件:WidgetTextData.java   
public static NBTBase getNBTBase(final Object o) {
    if (o instanceof Integer) {
        return (NBTBase)new NBTTagInt((Integer)o);
    }
    if (o instanceof Short) {
        return (NBTBase)new NBTTagShort((Short)o);
    }
    if (o instanceof Long) {
        return (NBTBase)new NBTTagLong((Long)o);
    }
    if (o instanceof String) {
        return (NBTBase)new NBTTagString((String)o);
    }
    if (o instanceof Double) {
        return (NBTBase)new NBTTagDouble((Double)o);
    }
    if (o instanceof Float) {
        return (NBTBase)new NBTTagFloat((Float)o);
    }
    if (o instanceof NBTTagCompound) {
        return (NBTBase)o;
    }
    if (o instanceof Byte) {
        return (NBTBase)new NBTTagByte((Byte)o);
    }
    LogHelper.debug("Can't find type for " + o, new Object[0]);
    throw null;
}
项目:wizards-of-lua    文件:NbtConverter.java   
private Map<Class<? extends NBTBase>, NbtMerger<? extends NBTBase>> getMergers() {
  if (mergers == null) {
    mergers = new HashMap<>();
    registerMerger(NBTTagByte.class, new NbtByteMerger(this));
    registerMerger(NBTTagCompound.class, new NbtCompoundMerger(this));
    registerMerger(NBTTagDouble.class, new NbtDoubleMerger(this));
    registerMerger(NBTTagFloat.class, new NbtFloatMerger(this));
    registerMerger(NBTTagInt.class, new NbtIntMerger(this));
    registerMerger(NBTTagList.class, new NbtListMerger(this));
    registerMerger(NBTTagLong.class, new NbtLongMerger(this));
    registerMerger(NBTTagShort.class, new NbtShortMerger(this));
    registerMerger(NBTTagString.class, new NbtStringMerger(this));
  }
  return mergers;
}
项目:wizards-of-lua    文件:NbtIntMerger.java   
@Override
public NBTTagInt merge(NBTTagInt nbt, Object data, String key, String path) {
  if (data instanceof Number) {
    return NbtConverter.toNbt(((Number) data).intValue());
  }
  throw converter.conversionException(path, data, "number");
}
项目:metamorph    文件:MorphingStorage.java   
@Override
public NBTBase writeNBT(Capability<IMorphing> capability, IMorphing instance, EnumFacing side)
{
    NBTTagCompound tag = new NBTTagCompound();
    NBTTagList acquired = new NBTTagList();
    NBTTagList favorites = new NBTTagList();
    tag.setTag("lastHealthRatio", new NBTTagFloat(instance.getLastHealthRatio()));

    if (instance.getCurrentMorph() != null)
    {
        NBTTagCompound morph = new NBTTagCompound();
        instance.getCurrentMorph().toNBT(morph);

        tag.setTag("Morph", morph);
    }

    tag.setTag("Morphs", acquired);
    tag.setTag("Favorites", favorites);

    for (AbstractMorph acquiredMorph : instance.getAcquiredMorphs())
    {
        NBTTagCompound acquiredTag = new NBTTagCompound();

        acquiredMorph.toNBT(acquiredTag);
        acquired.appendTag(acquiredTag);
    }

    for (Integer index : instance.getFavorites())
    {
        favorites.appendTag(new NBTTagInt(index.intValue()));
    }

    return tag;
}
项目:TheDragonLib    文件:SyncableVec3I.java   
@Override
public void toNBT(NBTTagCompound compound) {
    NBTTagList list = new NBTTagList();
    list.appendTag(new NBTTagInt(vec.x));
    list.appendTag(new NBTTagInt(vec.y));
    list.appendTag(new NBTTagInt(vec.z));

    compound.setTag("SyncableVec3I" + index, list);
}
项目:capability-rf-api    文件:RFCapabilities.java   
@Override
public void readNBT(Capability<T> capability, T instance, EnumFacing side, NBTBase nbt) {
    if (!(instance instanceof IMutableStorage))
        throw new RuntimeException("IEnergyStorage instance does not implement IMutableStorage");
    if (nbt != null && nbt instanceof NBTTagInt)
        ((IMutableStorage) instance).setEnergyStored(((NBTTagInt) nbt).getInt());
}
项目:TeleToro    文件:ItemTeletoryPortalLinker.java   
private void setOriginPortal(EntityPlayer player, ItemStack stack, ControlBlockLocation thisPortal) {
    stack.setTagInfo("origin", new NBTTagLong(thisPortal.pos.toLong()));
    stack.setTagInfo("dimid", new NBTTagInt(player.dimension));
    int side = getSide(player, thisPortal);
    stack.setTagInfo("side", new NBTTagInt(side));
    playSound(player);
}
项目:Mekfarm    文件:AnimalFarmEntity.java   
static ItemStack packageAnimal(ItemStack packageStack, EntityAnimal animal) {
    ItemStack stackCopy = (packageStack == null) ? new ItemStack(ItemsRegistry.animalPackage) : packageStack.copy();

    stackCopy.setTagInfo("hasAnimal", new NBTTagInt(1));
    NBTTagCompound animalCompound = new NBTTagCompound();
    animal.writeEntityToNBT(animalCompound);
    stackCopy.setTagInfo("animal", animalCompound);
    stackCopy.setTagInfo("animalClass", new NBTTagString(animal.getClass().getName()));
    stackCopy.setTagInfo("animalHealth", new NBTTagFloat(animal.getHealth()));
    return stackCopy;
}