Java 类net.minecraft.nbt.NBTUtil 实例源码

项目:pnc-repressurized    文件:PacketDescription.java   
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;
}
项目:DecompiledMinecraft    文件:ItemSkull.java   
/**
 * 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;
    }
}
项目:DecompiledMinecraft    文件:TileEntitySkull.java   
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();
            }
        }
    }
}
项目:DecompiledMinecraft    文件:ItemSkull.java   
/**
 * 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;
    }
}
项目:DecompiledMinecraft    文件:TileEntitySkull.java   
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();
            }
        }
    }
}
项目:Simple-Chunks    文件:ChunkLoadingHandler.java   
@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);
        }
    }
}
项目:Simple-Chunks    文件:ChunkLoadingHandler.java   
@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;
}
项目:BaseClient    文件:ItemSkull.java   
/**
 * 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;
    }
}
项目:BaseClient    文件:TileEntitySkull.java   
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();
            }
        }
    }
}
项目:BaseClient    文件:ItemSkull.java   
/**
 * 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;
    }
}
项目:BaseClient    文件:TileEntitySkull.java   
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();
            }
        }
    }
}
项目:Backmemed    文件:ItemSkull.java   
/**
 * 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;
    }
}
项目:Backmemed    文件:TileEntityEndGateway.java   
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;
}
项目:Backmemed    文件:TileEntitySkull.java   
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();
            }
        }
    }
}
项目:Mods    文件:EntityStatue.java   
@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);
}
项目:CustomWorldGen    文件:ItemSkull.java   
/**
 * 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;
    }
}
项目:CustomWorldGen    文件:TileEntityEndGateway.java   
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;
}
项目:CustomWorldGen    文件:TileEntitySkull.java   
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();
            }
        }
    }
}
项目:CrystalMod    文件:ExtendedPlayer.java   
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;
}
项目:CrystalMod    文件:ExtendedPlayer.java   
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;
    }
}
项目:CrystalMod    文件:BlockTelePortal.java   
@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;
   }
项目:Gravestone-mod-Extended    文件:BlockMemorial.java   
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;
}
项目:Gravestone-mod-Extended    文件:BlockMemorial.java   
@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;
}
项目:MC-Prefab    文件:BuildBlock.java   
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;
}
项目:ExpandedRailsMod    文件:ItemSkull.java   
/**
 * 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;
    }
}
项目:Cauldron    文件:ItemSkull.java   
public String getItemStackDisplayName(ItemStack p_77653_1_)
{
    if (p_77653_1_.getItemDamage() == 3 && p_77653_1_.hasTagCompound())
    {
        if (p_77653_1_.getTagCompound().hasKey("SkullOwner", 10))
        {
            return StatCollector.translateToLocalFormatted("item.skull.player.name", new Object[] {NBTUtil.func_152459_a(p_77653_1_.getTagCompound().getCompoundTag("SkullOwner")).getName()});
        }

        if (p_77653_1_.getTagCompound().hasKey("SkullOwner", 8))
        {
            return StatCollector.translateToLocalFormatted("item.skull.player.name", new Object[] {p_77653_1_.getTagCompound().getString("SkullOwner")});
        }
    }

    return super.getItemStackDisplayName(p_77653_1_);
}
项目:Cauldron    文件:BlockSkull.java   
@Override
public ArrayList<ItemStack> getDrops(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, int p_149749_6_, int fortune)
{
    ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
    {
        if ((p_149749_6_ & 8) == 0)
        {
            ItemStack itemstack = new ItemStack(Items.skull, 1, this.getDamageValue(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_));
            TileEntitySkull tileentityskull = (TileEntitySkull)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);

            if (tileentityskull == null) return ret;

            if (tileentityskull.func_145904_a() == 3 && tileentityskull.func_152108_a() != null)
            {
                itemstack.setTagCompound(new NBTTagCompound());
                NBTTagCompound nbttagcompound = new NBTTagCompound();
                NBTUtil.func_152460_a(nbttagcompound, tileentityskull.func_152108_a());
                itemstack.getTagCompound().setTag("SkullOwner", nbttagcompound);
            }

            ret.add(itemstack);
        }
    }
    return ret;
}
项目:Cauldron    文件:TileEntitySkull.java   
public void readFromNBT(NBTTagCompound p_145839_1_)
{
    super.readFromNBT(p_145839_1_);
    this.field_145908_a = p_145839_1_.getByte("SkullType");
    this.field_145910_i = p_145839_1_.getByte("Rot");

    if (this.field_145908_a == 3)
    {
        if (p_145839_1_.hasKey("Owner", 10))
        {
            this.field_152110_j = NBTUtil.func_152459_a(p_145839_1_.getCompoundTag("Owner"));
        }
        else if (p_145839_1_.hasKey("ExtraType", 8) && !StringUtils.isNullOrEmpty(p_145839_1_.getString("ExtraType")))
        {
            this.field_152110_j = new GameProfile((UUID)null, p_145839_1_.getString("ExtraType"));
            this.func_152109_d();
        }
    }
}
项目:Cauldron    文件:ItemSkull.java   
public String getItemStackDisplayName(ItemStack p_77653_1_)
{
    if (p_77653_1_.getItemDamage() == 3 && p_77653_1_.hasTagCompound())
    {
        if (p_77653_1_.getTagCompound().hasKey("SkullOwner", 10))
        {
            return StatCollector.translateToLocalFormatted("item.skull.player.name", new Object[] {NBTUtil.func_152459_a(p_77653_1_.getTagCompound().getCompoundTag("SkullOwner")).getName()});
        }

        if (p_77653_1_.getTagCompound().hasKey("SkullOwner", 8))
        {
            return StatCollector.translateToLocalFormatted("item.skull.player.name", new Object[] {p_77653_1_.getTagCompound().getString("SkullOwner")});
        }
    }

    return super.getItemStackDisplayName(p_77653_1_);
}
项目:Cauldron    文件:BlockSkull.java   
@Override
public ArrayList<ItemStack> getDrops(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, int p_149749_6_, int fortune)
{
    ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
    {
        if ((p_149749_6_ & 8) == 0)
        {
            ItemStack itemstack = new ItemStack(Items.skull, 1, this.getDamageValue(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_));
            TileEntitySkull tileentityskull = (TileEntitySkull)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);

            if (tileentityskull == null) return ret;

            if (tileentityskull.func_145904_a() == 3 && tileentityskull.func_152108_a() != null)
            {
                itemstack.setTagCompound(new NBTTagCompound());
                NBTTagCompound nbttagcompound = new NBTTagCompound();
                NBTUtil.func_152460_a(nbttagcompound, tileentityskull.func_152108_a());
                itemstack.getTagCompound().setTag("SkullOwner", nbttagcompound);
            }

            ret.add(itemstack);
        }
    }
    return ret;
}
项目:Cauldron    文件:TileEntitySkull.java   
public void readFromNBT(NBTTagCompound p_145839_1_)
{
    super.readFromNBT(p_145839_1_);
    this.field_145908_a = p_145839_1_.getByte("SkullType");
    this.field_145910_i = p_145839_1_.getByte("Rot");

    if (this.field_145908_a == 3)
    {
        if (p_145839_1_.hasKey("Owner", 10))
        {
            this.field_152110_j = NBTUtil.func_152459_a(p_145839_1_.getCompoundTag("Owner"));
        }
        else if (p_145839_1_.hasKey("ExtraType", 8) && !StringUtils.isNullOrEmpty(p_145839_1_.getString("ExtraType")))
        {
            this.field_152110_j = new GameProfile((UUID)null, p_145839_1_.getString("ExtraType"));
            this.func_152109_d();
        }
    }
}
项目:OpenBlocks    文件:EntityMiniMe.java   
private static GameProfile readOwner(NBTTagCompound tag) {
    if (tag.hasKey("owner", Constants.NBT.TAG_STRING)) {
        String ownerName = tag.getString("owner");
        return TileEntitySkull.updateGameprofile(new GameProfile((UUID)null, ownerName));
    } else if (tag.hasKey("OwnerUUID", Constants.NBT.TAG_STRING)) {
        final String uuidStr = tag.getString("OwnerUUID");
        try {
            UUID uuid = UUID.fromString(uuidStr);
            return new GameProfile(uuid, null);
        } catch (IllegalArgumentException e) {
            Log.warn(e, "Failed to parse UUID: %s", uuidStr);
        }
    } else if (tag.hasKey("Owner", Constants.NBT.TAG_COMPOUND)) { return NBTUtil.readGameProfileFromNBT(tag.getCompoundTag("Owner")); }

    return null;
}
项目:OpenBlocks    文件:TileEntityGoldenEgg.java   
@Override
public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);

    if (nbt.hasKey("owner", Constants.NBT.TAG_STRING)) {
        String ownerName = nbt.getString("owner");

        this.owner = TileEntitySkull.updateGameprofile(new GameProfile(null, ownerName));
    } else if (nbt.hasKey("OwnerUUID", Constants.NBT.TAG_STRING)) {
        final String uuidStr = nbt.getString("OwnerUUID");
        try {
            UUID uuid = UUID.fromString(uuidStr);
            this.owner = new GameProfile(uuid, null);
        } catch (IllegalArgumentException e) {
            Log.warn(e, "Failed to parse UUID: %s", uuidStr);
        }
    } else if (nbt.hasKey("Owner", Constants.NBT.TAG_COMPOUND)) {
        this.owner = NBTUtil.readGameProfileFromNBT(nbt.getCompoundTag("Owner"));
    }

}
项目:Hats    文件:TileEntityHatStand.java   
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tag)
{
    super.writeToNBT(tag);
    tag.setBoolean("hasBase", hasBase);
    tag.setInteger("head", head);
    tag.setBoolean("hasStand", hasStand);
    tag.setBoolean("isOnFloor", isOnFloor);
    tag.setInteger("orientation", orientation);
    tag.setInteger("sideOn", sideOn);

    tag.setString("hatName", hatName);
    tag.setInteger("colourR", colourR);
    tag.setInteger("colourG", colourG);
    tag.setInteger("colourB", colourB);
    tag.setInteger("alpha", alpha);

    if (this.gameProfile != null)
    {
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        NBTUtil.writeGameProfile(nbttagcompound1, this.gameProfile);
        tag.setTag("headNameProfile", nbttagcompound1);
    }
    return tag;
}
项目:pnc-repressurized    文件:PacketDescription.java   
public PacketDescription(NBTTagCompound compound) {
    super(NBTUtil.getPosFromTag(compound.getCompoundTag("Pos")));
    type = IDescSynced.Type.values()[compound.getInteger("SyncType")];
    values = new Object[compound.getInteger("Length")];
    types = new byte[values.length];
    NBTTagList list = compound.getTagList("Data", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < values.length; i++) {
        NBTTagCompound element = list.getCompoundTagAt(i);
        types[i] = element.getByte("Type");
        byte[] b = element.getByteArray("Value");
        values[i] = PacketUpdateGui.readField(Unpooled.wrappedBuffer(b), types[i]);
    }
    extraData = compound.getCompoundTag("Extra");
}
项目:Uranium    文件:CraftBlock.java   
public Collection<ItemStack> getDrops() {
    List<ItemStack> drops = new ArrayList<ItemStack>();

    net.minecraft.block.Block block = this.getNMSBlock();
    if (block != Blocks.air) {
        byte data = getData();
        // based on nms.Block.dropNaturally
        int count = block.quantityDroppedWithBonus(0, chunk.getHandle().worldObj.rand);
        for (int i = 0; i < count; ++i) {
            Item item = block.getItemDropped(data, chunk.getHandle().worldObj.rand, 0);
            if (item != null) {
                // Skulls are special, their data is based on the tile entity
                if (Blocks.skull == block) {
                    net.minecraft.item.ItemStack nmsStack = new net.minecraft.item.ItemStack(item, 1, block.getDamageValue(chunk.getHandle().worldObj, x, y, z));
                    TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().worldObj.getTileEntity(x, y, z);

                    if (tileentityskull.func_145904_a() == 3 && tileentityskull.func_152108_a() != null) {
                        nmsStack.setTagCompound(new NBTTagCompound());
                        NBTTagCompound nbttagcompound = new NBTTagCompound();

                        NBTUtil.func_152460_a(nbttagcompound, tileentityskull.func_152108_a());
                        nmsStack.getTagCompound().setTag("SkullOwner", nbttagcompound);
                    }

                    drops.add(CraftItemStack.asBukkitCopy(nmsStack));
                    // We don't want to drop cocoa blocks, we want to drop cocoa beans.
                } else if (Blocks.cocoa == block) {
                    int dropAmount = (BlockCocoa.func_149987_c(data) >= 2 ? 3 : 1);
                    for (int j = 0; j < dropAmount; ++j) {
                        drops.add(new ItemStack(Material.INK_SACK, 1, (short) 3));
                    }
                } else {
                    drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.damageDropped(data)));
                }
            }
        }
    }
    return drops;
}
项目:Uranium    文件:CraftMetaSkull.java   
@Override
void applyToItem(net.minecraft.nbt.NBTTagCompound tag) {
    super.applyToItem(tag);

    if (hasOwner()) {
        NBTTagCompound owner = new NBTTagCompound();
        NBTUtil.func_152460_a(owner, profile);
        tag.setTag(SKULL_OWNER.NBT, owner);
    }
}
项目:DecompiledMinecraft    文件:BlockSkull.java   
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    if (!worldIn.isRemote)
    {
        if (!((Boolean)state.getValue(NODROP)).booleanValue())
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntitySkull)
            {
                TileEntitySkull tileentityskull = (TileEntitySkull)tileentity;
                ItemStack itemstack = new ItemStack(Items.skull, 1, this.getDamageValue(worldIn, pos));

                if (tileentityskull.getSkullType() == 3 && tileentityskull.getPlayerProfile() != null)
                {
                    itemstack.setTagCompound(new NBTTagCompound());
                    NBTTagCompound nbttagcompound = new NBTTagCompound();
                    NBTUtil.writeGameProfile(nbttagcompound, tileentityskull.getPlayerProfile());
                    itemstack.getTagCompound().setTag("SkullOwner", nbttagcompound);
                }

                spawnAsEntity(worldIn, pos, itemstack);
            }
        }

        super.breakBlock(worldIn, pos, state);
    }
}
项目:DecompiledMinecraft    文件:TileEntitySkull.java   
public void writeToNBT(NBTTagCompound compound)
{
    super.writeToNBT(compound);
    compound.setByte("SkullType", (byte)(this.skullType & 255));
    compound.setByte("Rot", (byte)(this.skullRotation & 255));

    if (this.playerProfile != null)
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        NBTUtil.writeGameProfile(nbttagcompound, this.playerProfile);
        compound.setTag("Owner", nbttagcompound);
    }
}
项目:DecompiledMinecraft    文件:CommandTestFor.java   
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 1)
    {
        throw new WrongUsageException("commands.testfor.usage", new Object[0]);
    }
    else
    {
        Entity entity = func_175768_b(sender, args[0]);
        NBTTagCompound nbttagcompound = null;

        if (args.length >= 2)
        {
            try
            {
                nbttagcompound = JsonToNBT.getTagFromJson(buildString(args, 1));
            }
            catch (NBTException nbtexception)
            {
                throw new CommandException("commands.testfor.tagError", new Object[] {nbtexception.getMessage()});
            }
        }

        if (nbttagcompound != null)
        {
            NBTTagCompound nbttagcompound1 = new NBTTagCompound();
            entity.writeToNBT(nbttagcompound1);

            if (!NBTUtil.func_181123_a(nbttagcompound, nbttagcompound1, true))
            {
                throw new CommandException("commands.testfor.failure", new Object[] {entity.getName()});
            }
        }

        notifyOperators(sender, this, "commands.testfor.success", new Object[] {entity.getName()});
    }
}