当前位置: 首页>>代码示例>>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;未经允许,请勿转载。