org.bukkit.block.banner.Pattern#net.minecraft.nbt.NBTTagList源码实例Demo

下面列出了org.bukkit.block.banner.Pattern#net.minecraft.nbt.NBTTagList 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: litematica   文件: MaterialCache.java
protected void readMapFromNBT(NBTTagCompound nbt, String tagName, IdentityHashMap<IBlockState, ItemStack> map)
{
    if (nbt.hasKey(tagName, Constants.NBT.TAG_LIST))
    {
        NBTTagList list = nbt.getTagList(tagName, Constants.NBT.TAG_COMPOUND);
        final int count = list.tagCount();

        for (int i = 0; i < count; ++i)
        {
            NBTTagCompound tag = list.getCompoundTagAt(i);

            if (tag.hasKey("Block", Constants.NBT.TAG_COMPOUND) &&
                tag.hasKey("Item", Constants.NBT.TAG_COMPOUND))
            {
                IBlockState state = NBTUtil.readBlockState(tag.getCompoundTag("Block"));

                if (state != null)
                {
                    ItemStack stack = new ItemStack(tag.getCompoundTag("Item"));
                    this.buildItemsForStates.put(state, stack);
                }
            }
        }
    }
}
 
@Override
public void writeToNBT(NBTTagCompound tag){
    super.writeToNBT(tag);
    tag.setBoolean("clawClosing", shouldClawClose);
    tag.setFloat("clawProgress", clawProgress);
    tag.setFloat("speed", speed);
    tag.setBoolean("drilled", hasDrilledStack);
    tag.setBoolean("lasered", hasLaseredStack);
    // Write the ItemStacks in the inventory to NBT
    NBTTagList tagList = new NBTTagList();
    for(int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
        if(inventory[currentIndex] != null) {
            NBTTagCompound tagCompound = new NBTTagCompound();
            tagCompound.setByte("Slot", (byte)currentIndex);
            inventory[currentIndex].writeToNBT(tagCompound);
            tagList.appendTag(tagCompound);
        }
    }
    tag.setTag("Items", tagList);
}
 
源代码3 项目: NotEnoughItems   文件: ContainerPotionCreator.java
@SuppressWarnings ("unchecked")
@Override
public void handleInputPacket(PacketCustom packet) {
    ItemStack potion = potionInv.getStackInSlot(0);
    if (potion == null) {
        return;
    }

    boolean add = packet.readBoolean();
    Potion effect = Potion.getPotionById(packet.readUByte());

    NBTTagList effects = potion.getTagCompound().getTagList("CustomPotionEffects", 10);
    NBTTagList newEffects = new NBTTagList();
    for (int i = 0; i < effects.tagCount(); i++) {
        NBTTagCompound tag = effects.getCompoundTagAt(i);
        PotionEffect e = PotionEffect.readCustomPotionEffectFromNBT(tag);
        if (e.getPotion() != effect) {
            newEffects.appendTag(tag);
        }
    }
    if (add) {
        newEffects.appendTag(new PotionEffect(effect, packet.readInt(), packet.readUByte()).writeCustomPotionEffectToNBT(new NBTTagCompound()));
    }
    potion.getTagCompound().setTag("CustomPotionEffects", newEffects);
}
 
源代码4 项目: PneumaticCraft   文件: HackableHandler.java
@Override
public void loadNBTData(NBTTagCompound compound){
    hackables = null;
    NBTTagList tagList = compound.getTagList("hackables", 10);
    for(int i = 0; i < tagList.tagCount(); i++) {
        String hackableId = tagList.getCompoundTagAt(i).getString("id");
        Class<? extends IHackableEntity> hackableClass = PneumaticCraftAPIHandler.getInstance().stringToEntityHackables.get(hackableId);
        if(hackableClass != null) {
            try {
                if(hackables == null) hackables = new ArrayList<IHackableEntity>();
                hackables.add(hackableClass.newInstance());
            } catch(Exception e) {
                e.printStackTrace();
            }
        } else {
            Log.warning("hackable \"" + hackableId + "\" not found when constructing from nbt. Was it deleted?");
        }
    }
}
 
源代码5 项目: Gadomancy   文件: GrowingNodeBehavior.java
public void writeToNBT(NBTTagCompound nbtTagCompound) {
    nbtTagCompound.setBoolean("overallSaturated", isSaturated);
    nbtTagCompound.setDouble("overallHappiness", overallHappiness);
    if(lastFedAspect != null) {
        nbtTagCompound.setString("lastFedAspect", lastFedAspect.getTag());
        nbtTagCompound.setInteger("lastFedRow", lastFedRow);
    }

    NBTTagList list = new NBTTagList();
    for(Aspect a : aspectSaturation.keySet()) {
        double saturation = aspectSaturation.get(a);
        NBTTagCompound compound = new NBTTagCompound();
        compound.setString("aspectName", a.getTag());
        compound.setDouble("aspectSaturation", saturation);
        list.appendTag(compound);
    }
    nbtTagCompound.setTag("saturationValues", list);
}
 
源代码6 项目: enderutilities   文件: ItemRuler.java
public void toggleAlwaysRenderSelectedLocation(ItemStack rulerStack)
{
    ItemStack moduleStack = this.getSelectedModuleStack(rulerStack, ModuleType.TYPE_MEMORY_CARD_MISC);

    if (moduleStack.isEmpty() == false)
    {
        int selected = this.getLocationSelection(rulerStack);
        NBTTagList tagList = NBTUtils.getTagList(moduleStack, TAG_WRAPPER, TAG_LOCATIONS, Constants.NBT.TAG_COMPOUND, true);
        NBTTagCompound tag = tagList.getCompoundTagAt(selected);

        NBTUtils.toggleBoolean(tag, TAG_RENDER_WITH_ALL);

        if (selected >= tagList.tagCount())
        {
            tagList = NBTUtils.insertToTagList(tagList, tag, selected);
        }
        else
        {
            tagList.set(selected, tag);
        }

        NBTUtils.setTagList(moduleStack, TAG_WRAPPER, TAG_LOCATIONS, tagList);

        this.setSelectedModuleStack(rulerStack, ModuleType.TYPE_MEMORY_CARD_MISC, moduleStack);
    }
}
 
@Override
public void readFromNBT(NBTTagCompound tag){
    super.readFromNBT(tag);
    inputDir = ForgeDirection.getOrientation(tag.getInteger("inputDir"));
    redstoneMode = tag.getInteger("redstoneMode");
    leaveMaterial = tag.getBoolean("leaveMaterial");

    NBTTagList tagList = tag.getTagList("Inventory", 10);
    inventory = new ItemStack[inventory.length];
    for(int i = 0; i < tagList.tagCount(); ++i) {
        NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
        byte slot = tagCompound.getByte("Slot");
        if(slot >= 0 && slot < inventory.length) {
            inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
        }
    }
}
 
源代码8 项目: Wizardry   文件: PacketSendSpellToBook.java
public PacketSendSpellToBook(List<List<ModuleInstance>> compiledSpell, Set<CommonWorktableModule> commonModules) {
	if (compiledSpell == null || commonModules == null) return;

	NBTTagList compiledList = new NBTTagList();
	for (List<ModuleInstance> moduleList : compiledSpell) {
		for (ModuleInstance module : moduleList)
			compiledList.appendTag(module.serialize());
	}
	moduleList = compiledList;

	NBTTagList commonList = new NBTTagList();
	for (CommonWorktableModule commonModule : commonModules) {
		commonList.appendTag(commonModule.serializeNBT());
	}
	this.commonModules = commonList;
}
 
源代码9 项目: PneumaticCraft   文件: SemiBlockManager.java
@SubscribeEvent
public void onChunkSave(ChunkDataEvent.Save event){
    Map<ChunkPosition, ISemiBlock> map = semiBlocks.get(event.getChunk());
    if(map != null && map.size() > 0) {
        NBTTagList tagList = new NBTTagList();
        for(Map.Entry<ChunkPosition, ISemiBlock> entry : map.entrySet()) {
            NBTTagCompound t = new NBTTagCompound();
            entry.getValue().writeToNBT(t);
            t.setInteger("x", entry.getKey().chunkPosX);
            t.setInteger("y", entry.getKey().chunkPosY);
            t.setInteger("z", entry.getKey().chunkPosZ);
            t.setString("type", getKeyForSemiBlock(entry.getValue()));
            tagList.appendTag(t);
        }
        event.getData().setTag("SemiBlocks", tagList);
    }
}
 
@Override
public void readFromNBT (NBTTagCompound tag) {
    super.readFromNBT(tag);

    NBTTagList list = tag.getTagList("Items", Constants.NBT.TAG_COMPOUND);
    furnaceItemStacks = new ItemStack[getSizeInventory()];

    for (int i = 0, n = list.tagCount(); i < n; i++) {
        NBTTagCompound itemTag = list.getCompoundTagAt(i);
        byte slot = itemTag.getByte("Slot");

        if (slot >= 0 && slot < furnaceItemStacks.length)
            furnaceItemStacks[slot] = ItemStack.loadItemStackFromNBT(itemTag);
    }

    furnaceBurnTime = tag.getShort("BurnTime");
    furnaceCookTime = tag.getShort("CookTime");
    currentItemBurnTime = getItemBurnTime(furnaceItemStacks[SLOT_FUEL]);

    if (tag.hasKey("CustomName", Constants.NBT.TAG_STRING))
        customName = tag.getString("CustomName");
}
 
源代码11 项目: OpenPeripheral-Integration   文件: ModuleVanilla.java
public static Object listEnchantments(NBTTagList ench) {
	List<Map<String, Object>> response = Lists.newArrayList();
	for (int i = 0; i < ench.tagCount(); ++i) {
		NBTTagCompound enchTag = ench.getCompoundTagAt(i);
		short id = enchTag.getShort("id");
		short lvl = enchTag.getShort("lvl");

		final Enchantment enchantment = Enchantment.enchantmentsList[id];
		if (enchantment != null) {
			Map<String, Object> entry = Maps.newHashMap();
			entry.put("name", enchantment.getName());
			entry.put("level", lvl);
			entry.put("fullName", enchantment.getTranslatedName(lvl));
			response.add(entry);
		}
	}
	return response;
}
 
@Override
public NBTTagCompound writeToNBT(NBTTagCompound data) {
    super.writeToNBT(data);
    data.setBoolean("Active", isActive);
    data.setBoolean("WasActive", wasActiveAndNeedUpdate);
    data.setFloat("FuelUnitsLeft", fuelUnitsLeft);
    data.setInteger("MaxProgress", maxProgressDuration);
    if (maxProgressDuration > 0) {
        data.setInteger("Progress", currentProgress);
        NBTTagList itemOutputs = new NBTTagList();
        for (ItemStack itemStack : outputsList) {
            itemOutputs.appendTag(itemStack.writeToNBT(new NBTTagCompound()));
        }
        data.setTag("Outputs", itemOutputs);
    }
    return data;
}
 
源代码13 项目: PneumaticCraft   文件: TileEntityAirCompressor.java
@Override
public void writeToNBT(NBTTagCompound nbtTagCompound){

    super.writeToNBT(nbtTagCompound);

    nbtTagCompound.setInteger("burnTime", burnTime);
    nbtTagCompound.setInteger("maxBurn", maxBurnTime);
    nbtTagCompound.setInteger("redstoneMode", redstoneMode);
    // Write the ItemStacks in the inventory to NBT
    NBTTagList tagList = new NBTTagList();
    for(int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
        if(inventory[currentIndex] != null) {
            NBTTagCompound tagCompound = new NBTTagCompound();
            tagCompound.setByte("Slot", (byte)currentIndex);
            inventory[currentIndex].writeToNBT(tagCompound);
            tagList.appendTag(tagCompound);
        }
    }
    nbtTagCompound.setTag("Items", tagList);
}
 
源代码14 项目: mocreaturesdev   文件: MoCEntityWyvern.java
@Override
public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
	super.writeEntityToNBT(nbttagcompound);
	nbttagcompound.setBoolean("Saddle", getIsRideable());
	nbttagcompound.setBoolean("Chested", getIsChested());
	nbttagcompound.setByte("ArmorType", getArmorType());
	nbttagcompound.setBoolean("isSitting", getIsSitting());
	if (getIsChested() && localchest != null)
	{
		NBTTagList nbttaglist = new NBTTagList();
		for (int i = 0; i < localchest.getSizeInventory(); i++)
		{
			localstack = localchest.getStackInSlot(i);
			if (localstack != null)
			{
				NBTTagCompound nbttagcompound1 = new NBTTagCompound();
				nbttagcompound1.setByte("Slot", (byte) i);
				localstack.writeToNBT(nbttagcompound1);
				nbttaglist.appendTag(nbttagcompound1);
			}
		}
		nbttagcompound.setTag("Items", nbttaglist);
	}

}
 
源代码15 项目: NotEnoughItems   文件: ContainerPotionCreator.java
@SuppressWarnings("unchecked")
@Override
public void handleInputPacket(PacketCustom packet) {
    ItemStack potion = potionInv.getStackInSlot(0);
    if (potion == null)
        return;

    boolean add = packet.readBoolean();
    int effectID = packet.readUByte();

    NBTTagList effects = potion.getTagCompound().getTagList("CustomPotionEffects", 10);
    NBTTagList newEffects = new NBTTagList();
    for(int i = 0; i < effects.tagCount(); i++) {
        NBTTagCompound tag = effects.getCompoundTagAt(i);
        PotionEffect e = PotionEffect.readCustomPotionEffectFromNBT(tag);
        if(e.getPotionID() != effectID)
            newEffects.appendTag(tag);
    }
    if(add)
        newEffects.appendTag(new PotionEffect(effectID, packet.readInt(), packet.readUByte()).writeCustomPotionEffectToNBT(new NBTTagCompound()));
    potion.getTagCompound().setTag("CustomPotionEffects", newEffects);
}
 
源代码16 项目: Logistics-Pipes-2   文件: LPRoutedItem.java
public static LPRoutedItem readFromNBT(NBTTagCompound compound, TileGenericPipe holder) {
	double x = compound.getDouble("posX");
	double y = compound.getDouble("posY");
	double z = compound.getDouble("posZ");
	UUID id = compound.getUniqueId("UID");
	ItemStack content = new ItemStack(compound.getCompoundTag("inventory"));
	int ticks = compound.getInteger("ticks");
	Deque<EnumFacing> routingInfo = new ArrayDeque<>();
	NBTTagList routeList = (NBTTagList) compound.getTag("route");
	for(Iterator<NBTBase> i = routeList.iterator(); i.hasNext();) {
		NBTTagCompound node = (NBTTagCompound) i.next();
		EnumFacing nodeTuple = EnumFacing.values()[node.getInteger("heading")];
		routingInfo.add(nodeTuple);
	}
	LPRoutedItem item = new LPRoutedItem(x, y, z, content, ticks, id);
	item.setHeading(EnumFacing.VALUES[compound.getInteger("heading")]);
	item.setHolding(holder);
	item.route = routingInfo;
	return item;
}
 
源代码17 项目: PneumaticCraft   文件: TileEntityVacuumPump.java
@Override
public void writeToNBT(NBTTagCompound tag){
    super.writeToNBT(tag);
    NBTTagCompound vacuum = new NBTTagCompound();
    vacuumHandler.writeToNBTI(vacuum);
    tag.setTag("vacuum", vacuum);
    tag.setBoolean("turning", turning);
    tag.setInteger("redstoneMode", redstoneMode);
    // Write the ItemStacks in the inventory to NBT
    NBTTagList tagList = new NBTTagList();
    for(int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
        if(inventory[currentIndex] != null) {
            NBTTagCompound tagCompound = new NBTTagCompound();
            tagCompound.setByte("Slot", (byte)currentIndex);
            inventory[currentIndex].writeToNBT(tagCompound);
            tagList.appendTag(tagCompound);
        }
    }
    tag.setTag("Items", tagList);
}
 
源代码18 项目: PneumaticCraft   文件: TileEntityAssemblyIOUnit.java
@Override
public void writeToNBT(NBTTagCompound tag){
    super.writeToNBT(tag);
    tag.setFloat("clawProgress", clawProgress);
    tag.setBoolean("clawClosing", shouldClawClose);
    tag.setByte("state", state);
    // Write the ItemStacks in the inventory to NBT
    NBTTagList tagList = new NBTTagList();
    for(int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
        if(inventory[currentIndex] != null) {
            NBTTagCompound tagCompound = new NBTTagCompound();
            tagCompound.setByte("Slot", (byte)currentIndex);
            inventory[currentIndex].writeToNBT(tagCompound);
            tagList.appendTag(tagCompound);
        }
    }
    tag.setTag("Items", tagList);
}
 
源代码19 项目: AdvancedMod   文件: TileEntityCamoMine.java
@Override
public void writeToNBT(NBTTagCompound tag){
    super.writeToNBT(tag);
    tag.setInteger("timer", timer);
    tag.setString("target", target);

    NBTTagList camoStackTag = new NBTTagList();
    for(int i = 0; i < camoStacks.length; i++) {
        ItemStack stack = camoStacks[i];
        if(stack != null) {
            NBTTagCompound t = new NBTTagCompound();
            stack.writeToNBT(t);
            t.setByte("index", (byte)i);
            camoStackTag.appendTag(t);
        }
    }
    tag.setTag("camoStacks", camoStackTag);
}
 
源代码20 项目: Minecoprocessors   文件: Processor.java
@Override
public NBTTagCompound writeToNBT() {
  NBTTagCompound c = new NBTTagCompound();
  c.setByteArray(NBT_STACK, stack);
  c.setByteArray(NBT_REGISTERS, registers);
  c.setByte(NBT_FAULTCODE, faultCode);
  c.setLong(NBT_FLAGS, packFlags());
  if (error != null) {
    c.setString(NBT_ERROR, error);
  }
  NBTTagList programTag = new NBTTagList();
  for (byte[] b : program) {
    programTag.appendTag(new NBTTagByteArray(b));
  }
  c.setTag(NBT_PROGRAM, programTag);

  NBTTagList labelTag = new NBTTagList();
  for (Label label : labels) {
    labelTag.appendTag(label.toNbt());
  }
  c.setTag(NBT_LABELS, labelTag);

  return c;
}
 
源代码21 项目: ToroQuest   文件: PlayerCivilization.java
private Set<QuestData> readQuests(NBTBase tag) {
	Set<QuestData> quests = new HashSet<QuestData>();
	if (tag == null || !(tag instanceof NBTTagList)) {
		return quests;
	}
	NBTTagList list = (NBTTagList) tag;
	for (int i = 0; i < list.tagCount(); i++) {
		QuestData d = new QuestData();
		d.readNBT(list.getCompoundTagAt(i), getPlayer());
		if (!d.isValid()) {
			continue;
		}
		quests.add(d);
	}
	return quests;
}
 
源代码22 项目: NewHorizonsCoreMod   文件: TileEntityBabyChest.java
@Override
public void writeToNBT(NBTTagCompound pNBTTagCompound)
{
    super.writeToNBT(pNBTTagCompound);

    NBTTagList tNBTTaglist = new NBTTagList();
    for (int i = 0; i < _mInventory.length; i++)
    {
        if (_mInventory[i] != null)
        {
            NBTTagCompound nbttagcompound1 = new NBTTagCompound();
            nbttagcompound1.setByte("Slot", (byte) i);
            _mInventory[i].writeToNBT(nbttagcompound1);
            tNBTTaglist.appendTag(nbttagcompound1);
        }
    }

    pNBTTagCompound.setTag("Items", tNBTTaglist);
    pNBTTagCompound.setByte("facing", (byte)_mOrientation.ordinal() );
}
 
源代码23 项目: PneumaticCraft   文件: TileEntityElevatorBase.java
@Override
public void readFromNBT(NBTTagCompound tag){
    super.readFromNBT(tag);
    extension = tag.getFloat("extension");
    targetExtension = tag.getFloat("targetExtension");
    redstoneMode = tag.getInteger("redstoneMode");
    if(!tag.hasKey("maxFloorHeight")) {//backwards compatibility implementation.
        updateMaxElevatorHeight();
    } else {
        maxFloorHeight = tag.getInteger("maxFloorHeight");
    }
    for(int i = 0; i < 6; i++) {
        sidesConnected[i] = tag.getBoolean("sideConnected" + i);
    }

    // Read in the ItemStacks in the inventory from NBT
    NBTTagList tagList = tag.getTagList("Items", 10);
    inventory = new ItemStack[inventory.length];
    for(int i = 0; i < tagList.tagCount(); ++i) {
        NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
        byte slot = tagCompound.getByte("Slot");
        if(slot >= 0 && slot < inventory.length) {
            inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
        }
    }
}
 
源代码24 项目: PneumaticCraft   文件: TileEntityAerialInterface.java
@Override
public void readFromNBT(NBTTagCompound tag){

    super.readFromNBT(tag);
    // Read in the ItemStacks in the inventory from NBT

    redstoneMode = tag.getInteger("redstoneMode");
    feedMode = tag.getInteger("feedMode");
    setPlayer(tag.getString("playerName"), tag.getString("playerUUID"));
    isConnectedToPlayer = tag.getBoolean("connected");
    if(tag.hasKey("curXpFluid")) curXpFluid = FluidRegistry.getFluid(tag.getString("curXpFluid"));
    if(energyRF != null) readRF(tag);

    NBTTagList tagList = tag.getTagList("Items", 10);
    inventory = new ItemStack[4];
    for(int i = 0; i < tagList.tagCount(); ++i) {
        NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
        byte slot = tagCompound.getByte("Slot");
        if(slot >= 0 && slot < inventory.length) {
            inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
        }
    }
    dispenserUpgradeInserted = getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE) > 0;
}
 
源代码25 项目: archimedes-ships   文件: MsgTileEntities.java
@Override
@SideOnly(Side.CLIENT)
public void handleClientSide(EntityPlayer player)
{
	if (ship != null && tagCompound != null)
	{
		NBTTagList list = tagCompound.getTagList("list", 10);
		for (int i = 0; i < list.tagCount(); i++)
		{
			NBTTagCompound nbt = list.getCompoundTagAt(i);
			if (nbt == null) continue;
			int x = nbt.getInteger("x");
			int y = nbt.getInteger("y");
			int z = nbt.getInteger("z");
			try
			{
				TileEntity te = ship.getShipChunk().getTileEntity(x, y, z);
				te.readFromNBT(nbt);
			} catch (Exception e)
			{
				e.printStackTrace();
			}
		}
		((MobileChunkClient) ship.getShipChunk()).getRenderer().markDirty();
	}
}
 
源代码26 项目: PneumaticCraft   文件: DateEventHandler.java
public static void spawnFirework(World world, double x, double y, double z){
    ItemStack rocket = new ItemStack(Items.fireworks);

    ItemStack itemstack1 = getFireworkCharge();

    NBTTagCompound nbttagcompound = new NBTTagCompound();
    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
    NBTTagList nbttaglist = new NBTTagList();

    if(itemstack1 != null && itemstack1.getItem() == Items.firework_charge && itemstack1.hasTagCompound() && itemstack1.getTagCompound().hasKey("Explosion")) {
        nbttaglist.appendTag(itemstack1.getTagCompound().getCompoundTag("Explosion"));
    }

    nbttagcompound1.setTag("Explosions", nbttaglist);
    nbttagcompound1.setByte("Flight", (byte)2);
    nbttagcompound.setTag("Fireworks", nbttagcompound1);

    rocket.setTagCompound(nbttagcompound);

    EntityFireworkRocket entity = new EntityFireworkRocket(world, x, y, z, rocket);
    world.spawnEntityInWorld(entity);
}
 
源代码27 项目: Gadomancy   文件: TileArcanePackager.java
@Override
public void readFromNBT(NBTTagCompound compound) {
    super.readFromNBT(compound);

    contents = new ItemStack[getSizeInventory()];
    NBTTagList list = compound.getTagList("Items", 10);

    for (int i = 0; i < list.tagCount(); ++i) {
        NBTTagCompound slot = list.getCompoundTagAt(i);
        int j = slot.getByte("Slot") & 255;

        if (j >= 0 && j < contents.length) {
            contents[j] = ItemStack.loadItemStackFromNBT(slot);
        }
    }
}
 
源代码28 项目: AgriCraft   文件: TileEntitySeedStorage.java
@Override
protected void writeNBT(NBTTagCompound tag) {
    if (this.lockedSeed != null) {
        //add the locked SEED
        tag.setTag(AgriNBT.SEED, this.lockedSeed.toStack().writeToNBT(new NBTTagCompound()));
        if (this.slots != null) {
            //add the slots
            NBTTagList tagList = new NBTTagList();
            for (Map.Entry<Integer, SeedStorageSlot> entry : slots.entrySet()) {
                if (entry != null && entry.getValue() != null) {
                    NBTTagCompound slotTag = new NBTTagCompound();
                    entry.getValue().writeToNbt(slotTag);
                    tagList.appendTag(slotTag);
                }
            }
            tag.setTag(AgriNBT.INVENTORY, tagList);
        }
    }
    if (this.hasController()) {
        NBTHelper.addCoordsToNBT(this.controller.getCoordinates(), tag);
    }
}
 
源代码29 项目: Framez   文件: FrameMovementRegistry.java
public void readInfo(IMovingBlock block, NBTTagCompound tag) {

        if (!tag.hasKey("info"))
            return;

        NBTTagList l = tag.getTagList("info", new NBTTagCompound().getId());

        for (int i = 0; i < l.tagCount(); i++) {
            NBTTagCompound t = l.getCompoundTagAt(i);
            for (IMovementDataProvider p : dataProviders) {
                if (p.getID().equals(t.getString("___id"))) {
                    p.readMovementInfo(block, t);
                    break;
                }
            }
        }
    }
 
源代码30 项目: Kettle   文件: CraftMetaFirework.java
CraftMetaFirework(NBTTagCompound tag) {
    super(tag);

    if (!tag.hasKey(FIREWORKS.NBT)) {
        return;
    }

    NBTTagCompound fireworks = tag.getCompoundTag(FIREWORKS.NBT);

    power = 0xff & fireworks.getByte(FLIGHT.NBT);

    if (!fireworks.hasKey(EXPLOSIONS.NBT)) {
        return;
    }

    NBTTagList fireworkEffects = fireworks.getTagList(EXPLOSIONS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND);
    List<FireworkEffect> effects = this.effects = new ArrayList<FireworkEffect>(fireworkEffects.tagCount());

    for (int i = 0; i < fireworkEffects.tagCount(); i++) {
        effects.add(getEffect((NBTTagCompound) fireworkEffects.get(i)));
    }
}