当前位置: 首页>>代码示例>>Java>>正文


Java NBTTagCompound类代码示例

本文整理汇总了Java中net.minecraft.nbt.NBTTagCompound的典型用法代码示例。如果您正苦于以下问题:Java NBTTagCompound类的具体用法?Java NBTTagCompound怎么用?Java NBTTagCompound使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NBTTagCompound类属于net.minecraft.nbt包,在下文中一共展示了NBTTagCompound类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: storeTEInStack

import net.minecraft.nbt.NBTTagCompound; //导入依赖的package包/类
private ItemStack storeTEInStack(ItemStack stack, TileEntity te)
{
    NBTTagCompound nbttagcompound = te.writeToNBT(new NBTTagCompound());

    if (stack.getItem() == Items.SKULL && nbttagcompound.hasKey("Owner"))
    {
        NBTTagCompound nbttagcompound2 = nbttagcompound.getCompoundTag("Owner");
        NBTTagCompound nbttagcompound3 = new NBTTagCompound();
        nbttagcompound3.setTag("SkullOwner", nbttagcompound2);
        stack.setTagCompound(nbttagcompound3);
        return stack;
    }
    else
    {
        stack.setTagInfo("BlockEntityTag", nbttagcompound);
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        NBTTagList nbttaglist = new NBTTagList();
        nbttaglist.appendTag(new NBTTagString("(+NBT)"));
        nbttagcompound1.setTag("Lore", nbttaglist);
        stack.setTagInfo("display", nbttagcompound1);
        return stack;
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:24,代码来源:Minecraft.java

示例2: merge

import net.minecraft.nbt.NBTTagCompound; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void merge(NBTTagCompound nbt, NBTTagCompound other) {
	Iterator<String> iterator = other.func_150296_c().iterator();

	while (iterator.hasNext()) {
		String s = iterator.next();
		NBTBase nbtbase = other.getTag(s);

		if (nbtbase.getId() == 10) {
			if (nbt.hasKey(s, 10)) {
				NBTTagCompound nbttagcompound1 = nbt.getCompoundTag(s);
				merge(nbttagcompound1, (NBTTagCompound) nbtbase);
			} else
				nbt.setTag(s, nbtbase.copy());
		} else
			nbt.setTag(s, nbtbase.copy());
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:19,代码来源:ItemArmourStand.java

示例3: EntityFireworkRocket

import net.minecraft.nbt.NBTTagCompound; //导入依赖的package包/类
public EntityFireworkRocket(World worldIn, double x, double y, double z, ItemStack givenItem)
{
    super(worldIn);
    this.fireworkAge = 0;
    this.setSize(0.25F, 0.25F);
    this.setPosition(x, y, z);
    int i = 1;

    if (givenItem != null && givenItem.hasTagCompound())
    {
        this.dataWatcher.updateObject(8, givenItem);
        NBTTagCompound nbttagcompound = givenItem.getTagCompound();
        NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Fireworks");

        if (nbttagcompound1 != null)
        {
            i += nbttagcompound1.getByte("Flight");
        }
    }

    this.motionX = this.rand.nextGaussian() * 0.001D;
    this.motionZ = this.rand.nextGaussian() * 0.001D;
    this.motionY = 0.05D;
    this.lifetime = 10 * i + this.rand.nextInt(6) + this.rand.nextInt(7);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:26,代码来源:EntityFireworkRocket.java

示例4: writeStructureComponentsToNBT

import net.minecraft.nbt.NBTTagCompound; //导入依赖的package包/类
public NBTTagCompound writeStructureComponentsToNBT(int chunkX, int chunkZ)
{
    if (MapGenStructureIO.getStructureStartName(this) == null) // This is just a more friendly error instead of the 'Null String' below
    {
        throw new RuntimeException("StructureStart \"" + this.getClass().getName() + "\" missing ID Mapping, Modder see MapGenStructureIO");
    }
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    nbttagcompound.setString("id", MapGenStructureIO.getStructureStartName(this));
    nbttagcompound.setInteger("ChunkX", chunkX);
    nbttagcompound.setInteger("ChunkZ", chunkZ);
    nbttagcompound.setTag("BB", this.boundingBox.toNBTTagIntArray());
    NBTTagList nbttaglist = new NBTTagList();

    for (StructureComponent structurecomponent : this.components)
    {
        nbttaglist.appendTag(structurecomponent.createStructureBaseNBT());
    }

    nbttagcompound.setTag("Children", nbttaglist);
    this.writeToNBT(nbttagcompound);
    return nbttagcompound;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:23,代码来源:StructureStart.java

示例5: load

import net.minecraft.nbt.NBTTagCompound; //导入依赖的package包/类
public void load(NBTTagCompound nbt) {
	byte[] regs = nbt.getByteArray("regs");
	addr1 = regs[0];
	addr2 = regs[1];
	sectorSize = regs[2];
	numSectors1 = regs[3];
	numSectors2 = regs[4];
	sector1 = regs[5];
	sector2 = regs[6];
	if(nbt.hasKey("mappedDrive"))
		mappedDrive = nbt.getString("mappedDrive");
	else
		mappedDrive = null;
	if(nbt.hasKey("sectorReadPos"))
		sectorReadPos = nbt.getInteger("sectorReadPos");
	else
		sectorReadPos = -1;
	if(nbt.hasKey("sectorWritePos"))
		sectorWritePos = nbt.getInteger("sectorWritePos");
	else
		sectorWritePos = -1;
	if(nbt.hasKey("sectorBuffer"))
		sectorBuffer = nbt.getByteArray("sectorBuffer");
	else
		sectorBuffer = null;
}
 
开发者ID:SolraBizna,项目名称:j6502,代码行数:27,代码来源:MMU.java

示例6: load

import net.minecraft.nbt.NBTTagCompound; //导入依赖的package包/类
/**
 * Load inventory data from NBT tag
 * @param inventory Target inventory
 * @param tag tag to load
 * @param seed Loading seed
 */
private static void load(IInventory inventory, NBTTagCompound tag, long seed) {
    if (tag == null || !Configurator.NATIVE_LOOT) {
        return;
    }
    Random random = new Random(seed);
    NBTTagList items = tag.getTagList("Items", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < items.tagCount() && i < inventory.getSizeInventory(); ++i) {
        NBTTagCompound stackTag = items.getCompoundTagAt(i);
        String itemName = stackTag.getString("id").replaceAll(".*:", "");
        itemName = itemName.isEmpty() ? String.valueOf(stackTag.getShort("id")) : itemName;
        Pattern iPattern = Pattern.compile(Pattern.quote(itemName), Pattern.CASE_INSENSITIVE);
        UItem item = Utils.select(UItems.items.select(iPattern), random.nextLong());
        byte count = items.getCompoundTagAt(i).getByte("Count");
        int damage = items.getCompoundTagAt(i).getShort("Damage");
        int slot = stackTag.hasKey("Slot", Constants.NBT.TAG_BYTE) ? stackTag.getByte("Slot") : i;
        slot = (slot < 0 || slot >= inventory.getSizeInventory()) ? i : slot;
        if (item != null && count > 0 && UItems.getPossibleMeta(item).contains(damage)) {
            inventory.setInventorySlotContents(slot, new UItemStack(item, count, damage).getItemStack());
        }
    }
}
 
开发者ID:ternsip,项目名称:StructPro,代码行数:28,代码来源:Tiles.java

示例7: handleData

import net.minecraft.nbt.NBTTagCompound; //导入依赖的package包/类
@Override
public void handleData(NBTTagCompound data) 
{
	PacketType type = PacketType.registry.get(data.getShort("requestID"));
	NBTTagCompound dataTag = VoidNetwork.handlers.get(data.getShort("requestID")).handleRequest(data.getString("requester"));
	if (dataTag == null)
	{
		return;
	}
	
	if (MC.getSide() == Side.SERVER)
	{
		EntityPlayerMP to = Players.getPlayerByUsername(data.getString("requester"));
		VoidNetwork.sendDataToClient(type, dataTag, to);
	}
	else
	{
		VoidNetwork.sendDataToServer(type, dataTag);
	}
}
 
开发者ID:V0idWa1k3r,项目名称:VoidApi,代码行数:21,代码来源:HandlerRequest.java

示例8: objectivesToNbt

import net.minecraft.nbt.NBTTagCompound; //导入依赖的package包/类
protected NBTTagList objectivesToNbt()
{
    NBTTagList nbttaglist = new NBTTagList();

    for (ScoreObjective scoreobjective : this.theScoreboard.getScoreObjectives())
    {
        if (scoreobjective.getCriteria() != null)
        {
            NBTTagCompound nbttagcompound = new NBTTagCompound();
            nbttagcompound.setString("Name", scoreobjective.getName());
            nbttagcompound.setString("CriteriaName", scoreobjective.getCriteria().getName());
            nbttagcompound.setString("DisplayName", scoreobjective.getDisplayName());
            nbttagcompound.setString("RenderType", scoreobjective.getRenderType().getRenderType());
            nbttaglist.appendTag(nbttagcompound);
        }
    }

    return nbttaglist;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:20,代码来源:ScoreboardSaveData.java

示例9: describeContents

import net.minecraft.nbt.NBTTagCompound; //导入依赖的package包/类
public String describeContents(ItemStack bundleOrPattern, int depth) {
	NBTTagCompound nbt = bundleOrPattern.getTagCompound();
	
	if (nbt == null || !nbt.hasKey("Items")) {
		return "Combines multiple items for automation. See Bundler/Unbundler";
	}
	
	ArrayList<String> itemStrings = new ArrayList<String>();
	String prefix = "";
	
	for (int i = 0; i < depth; ++i)
		prefix += "  ";
	
	for (ItemStack stack : getItemsFromBundle(bundleOrPattern)) {
		Item item = stack.getItem();
		itemStrings.add(prefix + stack.stackSize+" "+item.getItemStackDisplayName(stack));
		if (item == RezolveMod.BUNDLE_ITEM) {
			itemStrings.add(describeContents(stack, depth + 1));
		}
	}
	
	return String.join("\n", itemStrings);
}
 
开发者ID:astronautlabs,项目名称:rezolve,代码行数:24,代码来源:BundleItem.java

示例10: WeightedRandomMinecart

import net.minecraft.nbt.NBTTagCompound; //导入依赖的package包/类
private WeightedRandomMinecart(NBTTagCompound tagCompound, String type, int weight)
{
    super(weight);

    if (type.equals("Minecart"))
    {
        if (tagCompound != null)
        {
            type = EntityMinecart.EnumMinecartType.byNetworkID(tagCompound.getInteger("Type")).getName();
        }
        else
        {
            type = "MinecartRideable";
        }
    }

    this.nbtData = tagCompound;
    this.entityType = type;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:20,代码来源:MobSpawnerBaseLogic.java

示例11: saveData

import net.minecraft.nbt.NBTTagCompound; //导入依赖的package包/类
/**
 * Saves the given MapDataBase to disk.
 */
private void saveData(WorldSavedData p_75747_1_)
{
    if (this.saveHandler != null)
    {
        try
        {
            File file1 = this.saveHandler.getMapFileFromName(p_75747_1_.mapName);

            if (file1 != null)
            {
                NBTTagCompound nbttagcompound = new NBTTagCompound();
                p_75747_1_.writeToNBT(nbttagcompound);
                NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                nbttagcompound1.setTag("data", nbttagcompound);
                FileOutputStream fileoutputstream = new FileOutputStream(file1);
                CompressedStreamTools.writeCompressed(nbttagcompound1, fileoutputstream);
                fileoutputstream.close();
            }
        }
        catch (Exception exception)
        {
            exception.printStackTrace();
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:29,代码来源:MapStorage.java

示例12: readEntityFromNBT

import net.minecraft.nbt.NBTTagCompound; //导入依赖的package包/类
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
    super.readEntityFromNBT(tagCompund);

    if (tagCompund.hasKey("Potion", 10))
    {
        this.potionDamage = ItemStack.loadItemStackFromNBT(tagCompund.getCompoundTag("Potion"));
    }
    else
    {
        this.setPotionDamage(tagCompund.getInteger("potionValue"));
    }

    if (this.potionDamage == null)
    {
        this.setDead();
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:22,代码来源:EntityPotion.java

示例13: getHighestSoundType

import net.minecraft.nbt.NBTTagCompound; //导入依赖的package包/类
public static SoundType getHighestSoundType(ItemStack stack){
	double max = 0;
	SoundType type = null;
	NBTTagCompound itemTag = ItemUtil.getOrCreateTag(stack);
	if (itemTag.hasKey(SOUNDS_TAG)) {
		NBTTagCompound container = stack.getTagCompound().getCompoundTag(SOUNDS_TAG);
		for (SoundType t : SoundType.getSoundTypes()){
			if (container.hasKey(t.getTag())){
				if (container.getDouble(t.getTag()) > max){
					max = container.getDouble(t.getTag());
					type = t;
				}
			}
		}
	}
	return type;
}
 
开发者ID:TeamMelodium,项目名称:Melodium,代码行数:18,代码来源:ItemCompositionPaper.java

示例14: writeEntityToNBT

import net.minecraft.nbt.NBTTagCompound; //导入依赖的package包/类
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound compound)
{
    super.writeEntityToNBT(compound);
    IBlockState iblockstate = this.getHeldBlockState();

    if (iblockstate != null)
    {
        compound.setShort("carried", (short)Block.getIdFromBlock(iblockstate.getBlock()));
        compound.setShort("carriedData", (short)iblockstate.getBlock().getMetaFromState(iblockstate));
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:EntityEnderman.java

示例15: getHoverEvent

import net.minecraft.nbt.NBTTagCompound; //导入依赖的package包/类
protected HoverEvent getHoverEvent()
{
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    String s = EntityList.getEntityString(this);
    nbttagcompound.setString("id", this.getUniqueID().toString());

    if (s != null)
    {
        nbttagcompound.setString("type", s);
    }

    nbttagcompound.setString("name", this.getName());
    return new HoverEvent(HoverEvent.Action.SHOW_ENTITY, new ChatComponentText(nbttagcompound.toString()));
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:15,代码来源:Entity.java


注:本文中的net.minecraft.nbt.NBTTagCompound类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。