當前位置: 首頁>>代碼示例>>Java>>正文


Java NBTTagList.getCompoundTagAt方法代碼示例

本文整理匯總了Java中net.minecraft.nbt.NBTTagList.getCompoundTagAt方法的典型用法代碼示例。如果您正苦於以下問題:Java NBTTagList.getCompoundTagAt方法的具體用法?Java NBTTagList.getCompoundTagAt怎麽用?Java NBTTagList.getCompoundTagAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.nbt.NBTTagList的用法示例。


在下文中一共展示了NBTTagList.getCompoundTagAt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readUpdateTag

import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
public void readUpdateTag(NBTTagCompound tag)
{
    dustList = getListFromByteArray(tag.getByteArray("Symbols"));

    NBTTagList list = tag.getTagList("Items", 10);
    for (int i = 0; i < list.tagCount(); ++i) {
        NBTTagCompound stackTag = list.getCompoundTagAt(i);
        int slot = stackTag.getByte("Slot") & 255;
        this.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(stackTag));
    }

    if (tag.hasKey("CustomName", 8)) {
        this.setCustomName(tag.getString("CustomName"));
    }

}
 
開發者ID:Drazuam,項目名稱:RunicArcana,代碼行數:17,代碼來源:TileEntityChalkBase.java

示例2: readFromNBT

import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
public void readFromNBT(NBTTagCompound tagCompound) {
	super.tileEntityReadFromNBT(tagCompound);
	NBTTagList tagList = tagCompound.getTagList("Items", 3);
	machineItemStacks = new ItemStack[getSizeInventory()];

	for(int i = 0; i < tagList.tagCount(); ++i) {
		NBTTagCompound tagCompund1 = tagList.getCompoundTagAt(i);
		byte b = tagCompund1.getByte("Slot");
		if(b >= 0 && b < machineItemStacks.length)
			machineItemStacks[b] = ItemStack.loadItemStackFromNBT(tagCompund1);
	}
	machineBurnTime = tagCompound.getShort("BurnTime");
	machineCookTime = tagCompound.getShort("CookTime");
	if(getItemBurnTimeElectrical(machineItemStacks[2]) != 0)
		currentBurnTime = getItemBurnTimeElectrical(machineItemStacks[2]);
	else
		currentBurnTime = getItemBurnTimeBurning(machineItemStacks[3]);

	if(tagCompound.hasKey("CustomName", 8)) {
		machineName = tagCompound.getString("CustomName");
	}
}
 
開發者ID:viddeno,項目名稱:Technical,代碼行數:23,代碼來源:TileEntityPump.java

示例3: readScores

import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
protected void readScores(NBTTagList nbt)
{
    for (int i = 0; i < nbt.tagCount(); ++i)
    {
        NBTTagCompound nbttagcompound = nbt.getCompoundTagAt(i);
        ScoreObjective scoreobjective = this.theScoreboard.getObjective(nbttagcompound.getString("Objective"));
        String s = nbttagcompound.getString("Name");

        if (s.length() > 40)
        {
            s = s.substring(0, 40);
        }

        Score score = this.theScoreboard.getValueFromObjective(s, scoreobjective);
        score.setScorePoints(nbttagcompound.getInteger("Score"));

        if (nbttagcompound.hasKey("Locked"))
        {
            score.setLocked(nbttagcompound.getBoolean("Locked"));
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:23,代碼來源:ScoreboardSaveData.java

示例4: func_151475_a

import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
public static void func_151475_a(BaseAttributeMap p_151475_0_, NBTTagList p_151475_1_)
{
    for (int i = 0; i < p_151475_1_.tagCount(); ++i)
    {
        NBTTagCompound nbttagcompound = p_151475_1_.getCompoundTagAt(i);
        IAttributeInstance iattributeinstance = p_151475_0_.getAttributeInstanceByName(nbttagcompound.getString("Name"));

        if (iattributeinstance != null)
        {
            applyModifiersToAttributeInstance(iattributeinstance, nbttagcompound);
        }
        else
        {
            logger.warn("Ignoring unknown attribute \'" + nbttagcompound.getString("Name") + "\'");
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:18,代碼來源:SharedMonsterAttributes.java

示例5: getDestinations

import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
public static List<TeleportDestination> getDestinations(ItemStack stack) {
    List<TeleportDestination> destinations = new ArrayList<>();
    if (!stack.hasTagCompound()) {
        for (int i = 0; i < 8; i++) {
            destinations.add(null);
        }
    } else {
        NBTTagCompound tag = stack.getTagCompound();
        NBTTagList dests = tag.getTagList("dests", Constants.NBT.TAG_COMPOUND);
        for (int i = 0; i < 8; i++) {
            NBTTagCompound tc = i < dests.tagCount() ? dests.getCompoundTagAt(i) : null;
            if (tc != null && tc.hasKey("dim")) {
                destinations.add(new TeleportDestination(tc));
            } else {
                destinations.add(null);
            }
        }
    }
    return destinations;
}
 
開發者ID:McJty,項目名稱:MeeCreeps,代碼行數:21,代碼來源:PortalGunItem.java

示例6: loadInventoryFromNBT

import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
public void loadInventoryFromNBT(NBTTagList p_70486_1_)
{
    for (int i = 0; i < this.getSizeInventory(); ++i)
    {
        this.setInventorySlotContents(i, (ItemStack)null);
    }

    for (int k = 0; k < p_70486_1_.tagCount(); ++k)
    {
        NBTTagCompound nbttagcompound = p_70486_1_.getCompoundTagAt(k);
        int j = nbttagcompound.getByte("Slot") & 255;

        if (j >= 0 && j < this.getSizeInventory())
        {
            this.setInventorySlotContents(j, ItemStack.loadItemStackFromNBT(nbttagcompound));
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:19,代碼來源:InventoryEnderChest.java

示例7: readEntityFromNBT

import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
protected void readEntityFromNBT(NBTTagCompound tagCompund)
{
    super.readEntityFromNBT(tagCompund);
    NBTTagList nbttaglist = tagCompund.getTagList("Items", 10);
    this.minecartContainerItems = new ItemStack[this.getSizeInventory()];

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

        if (j >= 0 && j < this.minecartContainerItems.length)
        {
            this.minecartContainerItems[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:21,代碼來源:EntityMinecartContainer.java

示例8: fixTagCompound

import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
{
    if (!"MobSpawner".equals(compound.getString("id")))
    {
        return compound;
    }
    else
    {
        if (compound.hasKey("EntityId", 8))
        {
            String s = compound.getString("EntityId");
            NBTTagCompound nbttagcompound = compound.getCompoundTag("SpawnData");
            nbttagcompound.setString("id", s.isEmpty() ? "Pig" : s);
            compound.setTag("SpawnData", nbttagcompound);
            compound.removeTag("EntityId");
        }

        if (compound.hasKey("SpawnPotentials", 9))
        {
            NBTTagList nbttaglist = compound.getTagList("SpawnPotentials", 10);

            for (int i = 0; i < nbttaglist.tagCount(); ++i)
            {
                NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);

                if (nbttagcompound1.hasKey("Type", 8))
                {
                    NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompoundTag("Properties");
                    nbttagcompound2.setString("id", nbttagcompound1.getString("Type"));
                    nbttagcompound1.setTag("Entity", nbttagcompound2);
                    nbttagcompound1.removeTag("Type");
                    nbttagcompound1.removeTag("Properties");
                }
            }
        }

        return compound;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:40,代碼來源:SpawnerEntityTypes.java

示例9: readEntityFromNBT

import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
@Override
public void readEntityFromNBT(NBTTagCompound compound) {
	super.readEntityFromNBT(compound);
	UUID uuid = null;
	if (compound.hasKey("Owner")) {
		String s1 = compound.getString("Owner");
		uuid = getUUID(s1);
	}

	if (uuid != null) {
		try {
			setOwnerId(uuid);
			setTamed(true);
		}
		catch (Throwable var4) {
			setTamed(false);
		}
	}
	if (compound.hasKey("Item") && compound.getCompoundTag("Item") != null) {
		setHeldItemStack(new ItemStack(compound.getCompoundTag("Item")));
	}
	if (compound.hasKey("Chest")) {
		if (chestInventory == null) {
			chestInventory = new TempChest(compound.getInteger("ChestSize"));
		}
		NBTTagList tagList = compound.getTagList("Chest", 10);
		for (int i = 0; i < tagList.tagCount(); i++) {
			NBTTagCompound slotNBT = tagList.getCompoundTagAt(i);
			if (slotNBT != null) {
				chestInventory.setInventorySlotContents(slotNBT.getInteger("Slot"), new ItemStack(slotNBT));
			}
		}
	}
	if (isSitting() != compound.getBoolean("Sitting")) {
		setSitting(compound.getBoolean("Sitting"));
	}
}
 
開發者ID:p455w0rd,項目名稱:EndermanEvolution,代碼行數:38,代碼來源:EntityFrienderman.java

示例10: getEffects

import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
public List<PotionEffect> getEffects(ItemStack stack)
{
    if (stack.hasTagCompound() && stack.getTagCompound().hasKey("CustomPotionEffects", 9))
    {
        List<PotionEffect> list1 = Lists.<PotionEffect>newArrayList();
        NBTTagList nbttaglist = stack.getTagCompound().getTagList("CustomPotionEffects", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
            PotionEffect potioneffect = PotionEffect.readCustomPotionEffectFromNBT(nbttagcompound);

            if (potioneffect != null)
            {
                list1.add(potioneffect);
            }
        }

        return list1;
    }
    else
    {
        List<PotionEffect> list = (List)this.effectCache.get(Integer.valueOf(stack.getMetadata()));

        if (list == null)
        {
            list = PotionHelper.getPotionEffects(stack.getMetadata(), false);
            this.effectCache.put(Integer.valueOf(stack.getMetadata()), list);
        }

        return list;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:34,代碼來源:ItemPotion.java

示例11: readFromNBT

import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
/**
 * Reads from the given tag list and fills the slots in the inventory with the correct items.
 */
public void readFromNBT(NBTTagList nbtTagListIn)
{
    this.mainInventory.clear();
    this.armorInventory.clear();
    this.offHandInventory.clear();

    for (int i = 0; i < nbtTagListIn.tagCount(); ++i)
    {
        NBTTagCompound nbttagcompound = nbtTagListIn.getCompoundTagAt(i);
        int j = nbttagcompound.getByte("Slot") & 255;
        ItemStack itemstack = new ItemStack(nbttagcompound);

        if (!itemstack.func_190926_b())
        {
            if (j >= 0 && j < this.mainInventory.size())
            {
                this.mainInventory.set(j, itemstack);
            }
            else if (j >= 100 && j < this.armorInventory.size() + 100)
            {
                this.armorInventory.set(j - 100, itemstack);
            }
            else if (j >= 150 && j < this.offHandInventory.size() + 150)
            {
                this.offHandInventory.set(j - 150, itemstack);
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:33,代碼來源:InventoryPlayer.java

示例12: readFromNBT

import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound nbt) {
    NBTTagList list = nbt.getTagList("dimlist", Constants.NBT.TAG_COMPOUND);
    for (int i = 0 ; i < list.tagCount() ; i++) {
        NBTTagCompound tag = list.getCompoundTagAt(i);
        int dimensionId = tag.getInteger("dimension");
        DimensionData data = new DimensionData();
        data.readFromNBT(tag);
        dimensionDataMap.put(dimensionId, data);
    }
}
 
開發者ID:McJty,項目名稱:needtobreath,代碼行數:12,代碼來源:CleanAirManager.java

示例13: deserializeNBT

import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
@Override
public void deserializeNBT(NBTTagCompound nbt)
{
    this.calendar.setTime(nbt.getLong("calendar"));
    if (nbt.hasKey("packMost", Constants.NBT.TAG_LONG))
    {
        this.packID = new UUID(nbt.getLong("packMost"), nbt.getLong("packLeast"));
    }

    if (nbt.hasKey("pos"))
    {
        this.home = BlockPos.fromLong(nbt.getLong("pos"));
    }

    if (nbt.hasKey("offspring", Constants.NBT.TAG_LIST))
    {
        NBTTagList offspringList = nbt.getTagList("offspring", Constants.NBT.TAG_COMPOUND);
        this.offspringStats = new IAnimalStats[offspringList.tagCount()];
        for (int i = 0; i < offspringList.tagCount(); i++)
        {
            NBTTagCompound tag = offspringList.getCompoundTagAt(i);
            try
            {
                this.offspringStats[i] = (IAnimalStats) Class.forName(tag.getString("class")).newInstance();
                this.offspringStats[i].deserializeNBT(tag);
            }
            catch (Exception ignored)
            {

            }
        }
    }

    this.hunger = nbt.getFloat("hunger");
    this.thirst = nbt.getFloat("thirst");
    this.isSick = nbt.getBoolean("isSick");
    StreamSupport.stream(nbt.getTagList("familiarity", Constants.NBT.TAG_COMPOUND).spliterator(), false).map(n -> (NBTTagCompound)n).forEach(tag -> this.familiarityLevels.put(new UUID(tag.getLong("keyMost"), tag.getLong("keyLeast")), tag.getFloat("value")));
    StreamSupport.stream(nbt.getTagList("interaction", Constants.NBT.TAG_COMPOUND).spliterator(), false).map(n -> (NBTTagCompound)n).forEach(tag -> this.interactionMemory.put(new UUID(tag.getLong("keyMost"), tag.getLong("keyLeast")), tag.getBoolean("value")));
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:40,代碼來源:ExPAnimal.java

示例14: readSchematic

import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
/**
 * Read from schematic tag
 * @param tag Control tag
 * @throws IOException If schematic tag can not be read
 */
private void readSchematic(NBTTagCompound tag) throws IOException {
    String materials = tag.getString("Materials");
    if (!materials.equals("Alpha")) {
        throw new IOException("Materials of schematic is not an alpha: [" + materials + "]");
    }
    setWidth(tag.getShort("Width"));
    setHeight(tag.getShort("Height"));
    setLength(tag.getShort("Length"));
    String dimensions = "[W=" + getWidth() + ";H=" + getHeight() + ";L=" + getLength() + "]";
    String dimLimit = "[W=" + WIDTH_LIMIT + ";H=" + HEIGHT_LIMIT + ";L=" + LENGTH_LIMIT + "]";
    if (getWidth() <= 0 || getHeight() <= 0 || getLength() <= 0) {
        throw new IOException("Schematic has non-positive dimensions: " + dimensions);
    }
    if (getWidth() > WIDTH_LIMIT || getHeight() > HEIGHT_LIMIT || getLength() > LENGTH_LIMIT) {
        throw new IOException("Schematic dimensions are too large: " + dimensions + "/" + dimLimit);
    }
    int size = getSize();
    if (size > VOLUME_LIMIT) {
        throw new IOException("Schematic is too big: " + size + "/" + VOLUME_LIMIT);
    }
    byte[] addBlocks = tag.getByteArray("AddBlocks");
    byte[] blocksID = tag.getByteArray("Blocks");
    if (size != blocksID.length) {
        throw new IOException("Wrong schematic blocks length: " + blocksID.length + "/" + size);
    }
    setBlocks(compose(blocksID, addBlocks));
    setMetas(tag.getByteArray("Data"));
    if (size != getMetas().length) {
        throw new IOException("Wrong schematic metadata length: " + blocksID.length + "/" + size);
    }
    setTiles(new NBTTagCompound[size]);
    NBTTagList tileEntities = tag.getTagList("TileEntities", Constants.NBT.TAG_COMPOUND);
    for(int i = 0; i < tileEntities.tagCount(); i++) {
        NBTTagCompound tile = tileEntities.getCompoundTagAt(i);
        int x = tile.getInteger("x");
        int y = tile.getInteger("y");
        int z = tile.getInteger("z");
        int idx = getIndex(x, y, z);
        if (idx >= 0 && idx < size) {
            setTile(tile, idx);
        }
    }
}
 
開發者ID:ternsip,項目名稱:StructPro,代碼行數:49,代碼來源:Blueprint.java

示例15: readEntityFromNBT

import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
    super.readEntityFromNBT(tagCompund);
    this.setEatingHaystack(tagCompund.getBoolean("EatingHaystack"));
    this.setBreeding(tagCompund.getBoolean("Bred"));
    this.setChested(tagCompund.getBoolean("ChestedHorse"));
    this.setHasReproduced(tagCompund.getBoolean("HasReproduced"));
    this.setHorseType(tagCompund.getInteger("Type"));
    this.setHorseVariant(tagCompund.getInteger("Variant"));
    this.setTemper(tagCompund.getInteger("Temper"));
    this.setHorseTamed(tagCompund.getBoolean("Tame"));
    String s = "";

    if (tagCompund.hasKey("OwnerUUID", 8))
    {
        s = tagCompund.getString("OwnerUUID");
    }
    else
    {
        String s1 = tagCompund.getString("Owner");
        s = PreYggdrasilConverter.getStringUUIDFromName(s1);
    }

    if (s.length() > 0)
    {
        this.setOwnerId(s);
    }

    IAttributeInstance iattributeinstance = this.getAttributeMap().getAttributeInstanceByName("Speed");

    if (iattributeinstance != null)
    {
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(iattributeinstance.getBaseValue() * 0.25D);
    }

    if (this.isChested())
    {
        NBTTagList nbttaglist = tagCompund.getTagList("Items", 10);
        this.initHorseChest();

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

            if (j >= 2 && j < this.horseChest.getSizeInventory())
            {
                this.horseChest.setInventorySlotContents(j, ItemStack.loadItemStackFromNBT(nbttagcompound));
            }
        }
    }

    if (tagCompund.hasKey("ArmorItem", 10))
    {
        ItemStack itemstack = ItemStack.loadItemStackFromNBT(tagCompund.getCompoundTag("ArmorItem"));

        if (itemstack != null && isArmorItem(itemstack.getItem()))
        {
            this.horseChest.setInventorySlotContents(1, itemstack);
        }
    }

    if (tagCompund.hasKey("SaddleItem", 10))
    {
        ItemStack itemstack1 = ItemStack.loadItemStackFromNBT(tagCompund.getCompoundTag("SaddleItem"));

        if (itemstack1 != null && itemstack1.getItem() == Items.saddle)
        {
            this.horseChest.setInventorySlotContents(0, itemstack1);
        }
    }
    else if (tagCompund.getBoolean("Saddle"))
    {
        this.horseChest.setInventorySlotContents(0, new ItemStack(Items.saddle));
    }

    this.updateHorseSlots();
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:82,代碼來源:EntityHorse.java


注:本文中的net.minecraft.nbt.NBTTagList.getCompoundTagAt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。