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


Java NBTTagCompound.getTag方法代碼示例

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


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

示例1: deSerialize

import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
public static Tuple<List<BrewEffect>, List<PotionEffect>> deSerialize(NBTTagCompound compound) {
	List<PotionEffect> potionEffects = PotionUtils.getEffectsFromTag(compound);
	List<BrewEffect> brewEffects = new ArrayList<>();
	Tuple<List<BrewEffect>, List<PotionEffect>> tuple = new Tuple<>(brewEffects, potionEffects);

	NBTTagList list = (NBTTagList) compound.getTag(BREW_DATA);
	for (int i = 0, size = list.tagCount(); i < size; i++) {
		NBTTagCompound tag = list.getCompoundTagAt(i);
		IBrew brew = BrewRegistry.getRegisteredBrew(tag.getString(BREW_ID));
		int duration = tag.getInteger(BREW_DURATION);
		int amplifier = tag.getInteger(BREW_AMPLIFIER);
		brewEffects.add(new BrewEffect(brew, duration, amplifier));
	}

	return tuple;
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:17,代碼來源:BrewUtils.java

示例2: getChildTag

import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
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;
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:27,代碼來源:NbtTagValue.java

示例3: readFromNBT

import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound compound) {
	super.readFromNBT(compound);
	if (compound.hasKey("Attributes")) {
		NBTTagCompound attrs = compound.getCompoundTag("Attributes");
		NBTTagList attrList = (NBTTagList) compound.getTag("AttributesList");
		for (String key : attrs.getKeySet())
			this.attributes.put(TF2Attribute.attributes[Integer.parseInt(key)], attrs.getInteger(key));
		for (int i = 0; i < attrList.tagCount(); i++)
			this.attributeList[i] = TF2Attribute.attributes[attrList.getIntAt(i)];
	}
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:13,代碼來源:TileEntityUpgrades.java

示例4: getExplosionTag

import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
public static NBTBase getExplosionTag(ItemStack stack, String key)
{
    if (stack.hasTagCompound())
    {
        NBTTagCompound nbttagcompound = stack.getTagCompound().getCompoundTag("Explosion");

        if (nbttagcompound != null)
        {
            return nbttagcompound.getTag(key);
        }
    }

    return null;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:15,代碼來源:ItemFireworkCharge.java

示例5: initializeStructureData

import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
protected void initializeStructureData(World worldIn)
{
    if (this.structureData == null)
    {
        this.structureData = (MapGenStructureData)worldIn.loadItemData(MapGenStructureData.class, this.getStructureName());

        if (this.structureData == null)
        {
            this.structureData = new MapGenStructureData(this.getStructureName());
            worldIn.setItemData(this.getStructureName(), this.structureData);
        }
        else
        {
            NBTTagCompound nbttagcompound = this.structureData.getTagCompound();

            for (String s : nbttagcompound.getKeySet())
            {
                NBTBase nbtbase = nbttagcompound.getTag(s);

                if (nbtbase.getId() == 10)
                {
                    NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbtbase;

                    if (nbttagcompound1.hasKey("ChunkX") && nbttagcompound1.hasKey("ChunkZ"))
                    {
                        int i = nbttagcompound1.getInteger("ChunkX");
                        int j = nbttagcompound1.getInteger("ChunkZ");
                        StructureStart structurestart = MapGenStructureIO.getStructureStart(nbttagcompound1, worldIn);

                        if (structurestart != null)
                        {
                            this.structureMap.put(ChunkPos.asLong(i, j), structurestart);
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:40,代碼來源:MapGenStructure.java

示例6: readFromNBT

import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound nbt) 
{
	NBTTagList list = (NBTTagList)nbt.getTag("tiles");
	tiles = new TreeMap<TilePos,Tile>();
	
	for(int i=0; i<list.tagCount(); i++)
	{
		NBTTagCompound entry = list.getCompoundTagAt(i);
		Tile tile = Tile.readFromNBT(entry, world);
	}
}
 
開發者ID:stuebz88,項目名稱:modName,代碼行數:13,代碼來源:TileList.java

示例7: addValue

import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
public static float addValue(float value, NBTTagCompound attributelist, String effect) {
	for(String name : attributelist.getKeySet()) {
		NBTBase tag = attributelist.getTag(name);
		if (tag instanceof NBTTagFloat) {
			TF2Attribute attribute = attributes[Integer.parseInt(name)];
			if (attribute != null && attribute.effect.equals(effect))
				if (attribute.typeOfValue == Type.ADDITIVE)
					value += ((NBTTagFloat) tag).getFloat();
				else
					value *= ((NBTTagFloat) tag).getFloat();
		}
	}
	return value;
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:15,代碼來源:TF2Attribute.java

示例8: loadIdCounts

import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
/**
 * Loads the idCounts Map from the 'idcounts' file.
 */
private void loadIdCounts()
{
    try
    {
        this.idCounts.clear();

        if (this.saveHandler == null)
        {
            return;
        }

        File file1 = this.saveHandler.getMapFileFromName("idcounts");

        if (file1 != null && file1.exists())
        {
            DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1));
            NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream);
            datainputstream.close();

            for (String s : nbttagcompound.getKeySet())
            {
                NBTBase nbtbase = nbttagcompound.getTag(s);

                if (nbtbase instanceof NBTTagShort)
                {
                    NBTTagShort nbttagshort = (NBTTagShort)nbtbase;
                    short short1 = nbttagshort.getShort();
                    this.idCounts.put(s, Short.valueOf(short1));
                }
            }
        }
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:41,代碼來源:MapStorage.java

示例9: initializeStructureData

import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
protected void initializeStructureData(World worldIn)
{
    if (this.structureData == null)
    {
        this.structureData = (MapGenStructureData)worldIn.getPerWorldStorage().getOrLoadData(MapGenStructureData.class, this.getStructureName());

        if (this.structureData == null)
        {
            this.structureData = new MapGenStructureData(this.getStructureName());
            worldIn.getPerWorldStorage().setData(this.getStructureName(), this.structureData);
        }
        else
        {
            NBTTagCompound nbttagcompound = this.structureData.getTagCompound();

            for (String s : nbttagcompound.getKeySet())
            {
                NBTBase nbtbase = nbttagcompound.getTag(s);

                if (nbtbase.getId() == 10)
                {
                    NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbtbase;

                    if (nbttagcompound1.hasKey("ChunkX") && nbttagcompound1.hasKey("ChunkZ"))
                    {
                        int i = nbttagcompound1.getInteger("ChunkX");
                        int j = nbttagcompound1.getInteger("ChunkZ");
                        StructureStart structurestart = MapGenStructureIO.getStructureStart(nbttagcompound1, worldIn);

                        if (structurestart != null)
                        {
                            this.structureMap.put(ChunkPos.asLong(i, j), structurestart);
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:40,代碼來源:MapGenStructure.java

示例10: readItemsFromNBT

import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
public static NonNullList<Pair<Integer, ItemStack>> readItemsFromNBT(NBTTagCompound tagCompound)
{
    NonNullList<Pair<Integer, ItemStack>> items = NonNullList.create();

    NBTTagList nbtList = tagCompound.getTagList("Items", 10);

    for (int i = 0; i < nbtList.tagCount(); ++i)
    {
        NBTTagCompound nbtTagCompound = nbtList.getCompoundTagAt(i);
        NBTBase nbt = nbtTagCompound.getTag("Slot");
        int j;
        if (nbt instanceof NBTTagByte)
        {
            j = nbtTagCompound.getByte("Slot") & 255;
        } else
        {
            j = nbtTagCompound.getShort("Slot");
        }

        if (j >= 0)
        {
            ItemStack itemstack = new ItemStack(nbtTagCompound);
            items.add(Pair.of(j, itemstack));
        }
    }

    return items;
}
 
開發者ID:cubex2,項目名稱:chesttransporter,代碼行數:29,代碼來源:Util.java

示例11: isValidInput

import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
public static boolean isValidInput(ItemStack input, ItemStack modifier)
{
	if (input == null || modifier == null || modifier.getItem() != Items.DIAMOND)
		return false;
	
	for (SocketRecipe recipe : recipes)
	{
		if (recipe.input.isAssignableFrom(input.getItem().getClass()))
		{
			NBTTagCompound tag = input.getTagCompound();
			if (tag == null || !tag.hasKey("sockets"))
				return false;
			
			NBTTagCompound socketTag = (NBTTagCompound) tag.getTag("sockets");
			int availableSockets = 0;
			for (int i = 0 ; i < socketTag.getInteger("number"); i++)
			{
				if (socketTag.getString("socket-"+i) == "none")
					availableSockets++;
			}
			
			if (availableSockets > 0)
				return true;
		}
	}
	
	return false;
}
 
開發者ID:MikeLydeamore,項目名稱:Jewelcrafting,代碼行數:29,代碼來源:SocketRecipe.java

示例12: readFromNBT

import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound compound) {
	super.readFromNBT(compound);
	NBTBase energyTag = compound.getTag("energy");
	if (energyTag!=null) {
		try {
			CapabilityEnergy.ENERGY.getStorage().readNBT(CapabilityEnergy.ENERGY, energyStorage, null, energyTag);
		} catch (Throwable t) {}
	}
	
}
 
開發者ID:elytra,項目名稱:Thermionics,代碼行數:12,代碼來源:TileEntityCableRF.java

示例13: readFromNBT

import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound compound) {
	NBTTagList list = (NBTTagList) compound.getTag(QuantumHandler.NBT_TAG);
	list.forEach(stackList -> {
		NBTTagList stacks = (NBTTagList) ((NBTTagCompound) stackList).getTag("list");
		UUID key = ((NBTTagCompound) stackList).getUniqueId("key");
		if(key != null) {
			getEntanglement(key).clear();
			stacks.forEach(tag -> getEntanglement(key).add(new ItemStack((NBTTagCompound) tag)));
		}
	});
}
 
開發者ID:ArekkuusuJerii,項目名稱:Solar,代碼行數:13,代碼來源:WorldQuantumData.java

示例14: getEnchantments

import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
public NBTTagList getEnchantments(ItemStack stack)
{
    NBTTagCompound nbttagcompound = stack.getTagCompound();
    return nbttagcompound != null && nbttagcompound.hasKey("StoredEnchantments", 9) ? (NBTTagList)nbttagcompound.getTag("StoredEnchantments") : new NBTTagList();
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:6,代碼來源:ItemEnchantedBook.java

示例15: spawnNewEntity

import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
private Entity spawnNewEntity(Entity entityIn, boolean spawn)
{
    if (this.getRandomEntity() != null)
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        entityIn.writeToNBTOptional(nbttagcompound);

        for (String s : this.getRandomEntity().nbtData.getKeySet())
        {
            NBTBase nbtbase = this.getRandomEntity().nbtData.getTag(s);
            nbttagcompound.setTag(s, nbtbase.copy());
        }

        entityIn.readFromNBT(nbttagcompound);

        if (entityIn.worldObj != null && spawn)
        {
            entityIn.worldObj.spawnEntityInWorld(entityIn);
        }

        NBTTagCompound nbttagcompound2;

        for (Entity entity = entityIn; nbttagcompound.hasKey("Riding", 10); nbttagcompound = nbttagcompound2)
        {
            nbttagcompound2 = nbttagcompound.getCompoundTag("Riding");
            Entity entity1 = EntityList.createEntityByName(nbttagcompound2.getString("id"), entityIn.worldObj);

            if (entity1 != null)
            {
                NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                entity1.writeToNBTOptional(nbttagcompound1);

                for (String s1 : nbttagcompound2.getKeySet())
                {
                    NBTBase nbtbase1 = nbttagcompound2.getTag(s1);
                    nbttagcompound1.setTag(s1, nbtbase1.copy());
                }

                entity1.readFromNBT(nbttagcompound1);
                entity1.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);

                if (entityIn.worldObj != null && spawn)
                {
                    entityIn.worldObj.spawnEntityInWorld(entity1);
                }

                entity.mountEntity(entity1);
            }

            entity = entity1;
        }
    }
    else if (entityIn instanceof EntityLivingBase && entityIn.worldObj != null && spawn)
    {
        if (entityIn instanceof EntityLiving)
        {
            ((EntityLiving)entityIn).onInitialSpawn(entityIn.worldObj.getDifficultyForLocation(new BlockPos(entityIn)), (IEntityLivingData)null);
        }

        entityIn.worldObj.spawnEntityInWorld(entityIn);
    }

    return entityIn;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:65,代碼來源:MobSpawnerBaseLogic.java


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