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


Java NBTUtil類代碼示例

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


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

示例1: writeNBT

import net.minecraft.nbt.NBTUtil; //導入依賴的package包/類
public NBTTagCompound writeNBT(NBTTagCompound compound) {
    compound.setTag("Pos", NBTUtil.createPosTag(pos));
    compound.setInteger("SyncType", type.ordinal());
    compound.setInteger("Length", values.length);
    ByteBuf buf = Unpooled.buffer();
    NBTTagList list = new NBTTagList();
    for (int i = 0; i < types.length; i++) {
        NBTTagCompound element = new NBTTagCompound();
        element.setByte("Type", types[i]);
        buf.clear();
        PacketUpdateGui.writeField(buf, values[i], types[i]);
        element.setByteArray("Value", Arrays.copyOf(buf.array(), buf.writerIndex()));
        list.appendTag(element);
    }
    buf.release();
    compound.setTag("Data", list);
    compound.setTag("Extra", extraData);

    return compound;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:21,代碼來源:PacketDescription.java

示例2: updateItemStackNBT

import net.minecraft.nbt.NBTUtil; //導入依賴的package包/類
/**
 * Called when an ItemStack with NBT data is read to potentially that ItemStack's NBT data
 */
public boolean updateItemStackNBT(NBTTagCompound nbt)
{
    super.updateItemStackNBT(nbt);

    if (nbt.hasKey("SkullOwner", 8) && nbt.getString("SkullOwner").length() > 0)
    {
        GameProfile gameprofile = new GameProfile((UUID)null, nbt.getString("SkullOwner"));
        gameprofile = TileEntitySkull.updateGameprofile(gameprofile);
        nbt.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
        return true;
    }
    else
    {
        return false;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:20,代碼來源:ItemSkull.java

示例3: readFromNBT

import net.minecraft.nbt.NBTUtil; //導入依賴的package包/類
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);
    this.skullType = compound.getByte("SkullType");
    this.skullRotation = compound.getByte("Rot");

    if (this.skullType == 3)
    {
        if (compound.hasKey("Owner", 10))
        {
            this.playerProfile = NBTUtil.readGameProfileFromNBT(compound.getCompoundTag("Owner"));
        }
        else if (compound.hasKey("ExtraType", 8))
        {
            String s = compound.getString("ExtraType");

            if (!StringUtils.isNullOrEmpty(s))
            {
                this.playerProfile = new GameProfile((UUID)null, s);
                this.updatePlayerProfile();
            }
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:25,代碼來源:TileEntitySkull.java

示例4: ticketsLoaded

import net.minecraft.nbt.NBTUtil; //導入依賴的package包/類
@Override
public void ticketsLoaded(List<ForgeChunkManager.Ticket> tickets, World world)
{
	for (ForgeChunkManager.Ticket ticket : tickets)
	{
		BlockPos ticketPosition = NBTUtil.getPosFromTag(ticket.getModData().getCompoundTag("position"));
		TileEntity te = world.getTileEntity(ticketPosition);
		if (te instanceof TileEntityChunkLoader)
		{
			TileEntityChunkLoader loader = (TileEntityChunkLoader) te;
			loader.setChunkTicket(ticket);
			loader.forceChunks();
		}
		else
		{
			ForgeChunkManager.releaseTicket(ticket);
		}
	}
}
 
開發者ID:DarkMorford,項目名稱:Simple-Chunks,代碼行數:20,代碼來源:ChunkLoadingHandler.java

示例5: playerTicketsLoaded

import net.minecraft.nbt.NBTUtil; //導入依賴的package包/類
@Override
public ListMultimap<String, ForgeChunkManager.Ticket> playerTicketsLoaded(ListMultimap<String, ForgeChunkManager.Ticket> tickets, World world)
{
	// We don't care what order the tickets are in, but filter out the invalid ones
	ListMultimap<String, ForgeChunkManager.Ticket> validTickets = ArrayListMultimap.create();

	for (String playerName : tickets.keySet())
	{
		List<ForgeChunkManager.Ticket> playerTickets = new ArrayList<>();

		for (ForgeChunkManager.Ticket tkt : tickets.get(playerName))
		{
			BlockPos ticketPosition = NBTUtil.getPosFromTag(tkt.getModData().getCompoundTag("position"));
			TileEntity te = world.getTileEntity(ticketPosition);
			if (te instanceof TileEntityChunkLoader)
			{
				playerTickets.add(tkt);
			}
		}

		validTickets.putAll(playerName, playerTickets);
	}

	return validTickets;
}
 
開發者ID:DarkMorford,項目名稱:Simple-Chunks,代碼行數:26,代碼來源:ChunkLoadingHandler.java

示例6: updateItemStackNBT

import net.minecraft.nbt.NBTUtil; //導入依賴的package包/類
/**
 * Called when an ItemStack with NBT data is read to potentially that ItemStack's NBT data
 */
public boolean updateItemStackNBT(NBTTagCompound nbt)
{
    super.updateItemStackNBT(nbt);

    if (nbt.hasKey("SkullOwner", 8) && !StringUtils.isBlank(nbt.getString("SkullOwner")))
    {
        GameProfile gameprofile = new GameProfile((UUID)null, nbt.getString("SkullOwner"));
        gameprofile = TileEntitySkull.updateGameprofile(gameprofile);
        nbt.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
        return true;
    }
    else
    {
        return false;
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:20,代碼來源:ItemSkull.java

示例7: writeToNBT

import net.minecraft.nbt.NBTUtil; //導入依賴的package包/類
public NBTTagCompound writeToNBT(NBTTagCompound compound)
{
    super.writeToNBT(compound);
    compound.setLong("Age", this.age);

    if (this.exitPortal != null)
    {
        compound.setTag("ExitPortal", NBTUtil.createPosTag(this.exitPortal));
    }

    if (this.exactTeleport)
    {
        compound.setBoolean("ExactTeleport", this.exactTeleport);
    }

    return compound;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:18,代碼來源:TileEntityEndGateway.java

示例8: writeEntityToNBT

import net.minecraft.nbt.NBTUtil; //導入依賴的package包/類
@Override
public void writeEntityToNBT(NBTTagCompound compound) {
	try {
		NBTTagCompound tag= this.data;
		if (tag != null)
		compound.setTag("Entity", tag);
	}
	catch(Exception e){
		
	}
	compound.setShort("TicksLeft", (short) this.ticksLeft);
	if(this.profile != null) {
		compound.setTag("Profile", NBTUtil.writeGameProfile(new NBTTagCompound(), this.profile));
	}
	compound.setBoolean("Player", this.player);
	compound.setBoolean("UseArm", this.useHand);
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:18,代碼來源:EntityStatue.java

示例9: updateItemStackNBT

import net.minecraft.nbt.NBTUtil; //導入依賴的package包/類
/**
 * Called when an ItemStack with NBT data is read to potentially that ItemStack's NBT data
 */
public boolean updateItemStackNBT(NBTTagCompound nbt)
{
    super.updateItemStackNBT(nbt);

    if (nbt.hasKey("SkullOwner", 8) && !nbt.getString("SkullOwner").isEmpty())
    {
        GameProfile gameprofile = new GameProfile((UUID)null, nbt.getString("SkullOwner"));
        gameprofile = TileEntitySkull.updateGameprofile(gameprofile);
        nbt.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
        return true;
    }
    else
    {
        return false;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:20,代碼來源:ItemSkull.java

示例10: writeToNBT

import net.minecraft.nbt.NBTUtil; //導入依賴的package包/類
public NBTTagCompound writeToNBT() {
	NBTTagCompound properties = new NBTTagCompound();
	properties.setTag("Inventory", inventory.serializeNBT());
	
	if(ItemStackTools.isValid(openBackpack)){
		properties.setTag("OpenBackpack", openBackpack.serializeNBT());
	}
	
	properties.setInteger("EnhancementXP", enhancementXP);		
	properties.setInteger("RadiationTime", radiationTime.getValue());
	properties.setInteger("IntellectTimer", intellectTimer.getValue());
	
	properties.setBoolean("Mini", isMini);
	if(playerDisguiseUUID !=null){
		properties.setTag("DisguiseUUID", NBTUtil.createUUIDTag(playerDisguiseUUID));
	}
	return properties;
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:19,代碼來源:ExtendedPlayer.java

示例11: readFromNBT

import net.minecraft.nbt.NBTUtil; //導入依賴的package包/類
public void readFromNBT(NBTTagCompound properties) {
	inventory.deserializeNBT(properties.getCompoundTag("Inventory"));
	if(properties.hasKey("OpenBackpack")){
		try{
			setOpenBackpack(ItemStackTools.loadFromNBT(properties.getCompoundTag("OpenBackpack")));
		}catch(Exception e){
			setOpenBackpack(ItemStackTools.getEmptyStack());
		}
	} else {
		setOpenBackpack(ItemStackTools.getEmptyStack());
	}
	enhancementXP = properties.getInteger("EnhancementXP");				
	radiationTime.setValue(properties.getInteger("RadiationTime"));	
	intellectTimer.setValue(properties.getInteger("IntellectTimer"));
	
	isMini = properties.getBoolean("Mini");
	if(properties.hasKey("DisguiseUUID")){
		playerDisguiseUUID = NBTUtil.getUUIDFromTag(properties.getCompoundTag("DisguiseUUID"));
	} else {
		playerDisguiseUUID = null;
	}
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:23,代碼來源:ExtendedPlayer.java

示例12: onBlockActivated

import net.minecraft.nbt.NBTUtil; //導入依賴的package包/類
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
   {
	if(worldIn.isRemote)return true;
	TileEntity tile = worldIn.getTileEntity(pos);
	if(tile == null || !(tile instanceof TileTelePortal)) return false;
	ItemStack stack = player.getHeldItem(hand);
	if(ItemStackTools.isValid(stack)){
		if(stack.getItem() == ModItems.miscCard && stack.getMetadata() == CardType.TELEPORT_PORTAL.getMetadata()){
			if(ItemNBTHelper.verifyExistance(stack, "PortalPos")){
				BlockPos portalPos = NBTUtil.getPosFromTag(ItemNBTHelper.getCompound(stack).getCompoundTag("PortalPos"));
				int dim = ItemNBTHelper.getInteger(stack, "PortalDim", 0);
				TileTelePortal portal = (TileTelePortal)tile;
				portal.otherPortalPos = portalPos;
				portal.otherPortalDim = dim;
				ModLogger.info("Set link to "+portalPos);
				return true;
			}
		}
	}
	return false;
   }
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:23,代碼來源:BlockTelePortal.java

示例13: getBlockItemStackWithoutInfo

import net.minecraft.nbt.NBTUtil; //導入依賴的package包/類
private ItemStack getBlockItemStackWithoutInfo(World world, BlockPos pos) {
    ItemStack itemStack = new ItemStack(Item.getItemFromBlock(this), 1);
    TileEntityMemorial tileEntity = (TileEntityMemorial) world.getTileEntity(pos);

    if (tileEntity != null) {
        itemStack.setItemDamage(tileEntity.getGraveTypeNum());
        NBTTagCompound nbt = new NBTTagCompound();
        nbt.setBoolean("Mossy", tileEntity.isMossy());
        if (tileEntity.getPlayerProfile() != null) {
            nbt.setTag("Owner", NBTUtil.writeGameProfile(new NBTTagCompound(), tileEntity.getPlayerProfile()));
        }

        itemStack.setTagCompound(nbt);
    }

    return itemStack;
}
 
開發者ID:NightKosh,項目名稱:Gravestone-mod-Extended,代碼行數:18,代碼來源:BlockMemorial.java

示例14: getPickBlock

import net.minecraft.nbt.NBTUtil; //導入依賴的package包/類
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
    ItemStack itemStack = new ItemStack(Item.getItemFromBlock(this), 1);
    TileEntityMemorial tileEntity = (TileEntityMemorial) world.getTileEntity(pos);

    if (tileEntity != null) {
        if (itemStack != null) {
            itemStack.setItemDamage(tileEntity.getGraveTypeNum());
            NBTTagCompound nbt = new NBTTagCompound();
            nbt.setBoolean("Mossy", tileEntity.isMossy());
            if (tileEntity.getPlayerProfile() != null) {
                nbt.setTag("Owner", NBTUtil.writeGameProfile(new NBTTagCompound(), tileEntity.getPlayerProfile()));
            }

            itemStack.setTagCompound(nbt);
        }
    }
    return itemStack;
}
 
開發者ID:NightKosh,項目名稱:Gravestone-mod-Extended,代碼行數:20,代碼來源:BlockMemorial.java

示例15: getBlockStateFromDataTag

import net.minecraft.nbt.NBTUtil; //導入依賴的package包/類
public IBlockState getBlockStateFromDataTag()
{
	IBlockState state = null;
	
	if (!this.blockStateData.equals(""))
	{
		NBTTagCompound tag = this.getBlockStateDataTag();
		
		if (tag != null)
		{
			state = NBTUtil.readBlockState(tag.getCompoundTag("tag"));
		}
	}
	
	return state;
}
 
開發者ID:Brian-Wuest,項目名稱:MC-Prefab,代碼行數:17,代碼來源:BuildBlock.java


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