當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。