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;
}
java类net.minecraft.nbt.NBTUtil的实例源码
PacketDescription.java 文件源码
项目:pnc-repressurized
阅读 20
收藏 0
点赞 0
评论 0
ItemSkull.java 文件源码
项目:DecompiledMinecraft
阅读 25
收藏 0
点赞 0
评论 0
/**
* 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;
}
}
TileEntitySkull.java 文件源码
项目:DecompiledMinecraft
阅读 20
收藏 0
点赞 0
评论 0
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();
}
}
}
}
ItemSkull.java 文件源码
项目:DecompiledMinecraft
阅读 18
收藏 0
点赞 0
评论 0
/**
* 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;
}
}
TileEntitySkull.java 文件源码
项目:DecompiledMinecraft
阅读 21
收藏 0
点赞 0
评论 0
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();
}
}
}
}
ChunkLoadingHandler.java 文件源码
项目:Simple-Chunks
阅读 22
收藏 0
点赞 0
评论 0
@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);
}
}
}
ChunkLoadingHandler.java 文件源码
项目:Simple-Chunks
阅读 28
收藏 0
点赞 0
评论 0
@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;
}
ItemSkull.java 文件源码
项目:BaseClient
阅读 19
收藏 0
点赞 0
评论 0
/**
* 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;
}
}
TileEntitySkull.java 文件源码
项目:BaseClient
阅读 20
收藏 0
点赞 0
评论 0
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();
}
}
}
}
ItemSkull.java 文件源码
项目:BaseClient
阅读 19
收藏 0
点赞 0
评论 0
/**
* 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;
}
}
TileEntitySkull.java 文件源码
项目:BaseClient
阅读 20
收藏 0
点赞 0
评论 0
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();
}
}
}
}
ItemSkull.java 文件源码
项目:Backmemed
阅读 19
收藏 0
点赞 0
评论 0
/**
* 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;
}
}
TileEntityEndGateway.java 文件源码
项目:Backmemed
阅读 28
收藏 0
点赞 0
评论 0
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;
}
TileEntitySkull.java 文件源码
项目:Backmemed
阅读 18
收藏 0
点赞 0
评论 0
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();
}
}
}
}
EntityStatue.java 文件源码
项目:Mods
阅读 16
收藏 0
点赞 0
评论 0
@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);
}
ItemSkull.java 文件源码
项目:CustomWorldGen
阅读 22
收藏 0
点赞 0
评论 0
/**
* 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;
}
}
TileEntityEndGateway.java 文件源码
项目:CustomWorldGen
阅读 32
收藏 0
点赞 0
评论 0
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;
}
TileEntitySkull.java 文件源码
项目:CustomWorldGen
阅读 20
收藏 0
点赞 0
评论 0
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();
}
}
}
}
ExtendedPlayer.java 文件源码
项目:CrystalMod
阅读 18
收藏 0
点赞 0
评论 0
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;
}
ExtendedPlayer.java 文件源码
项目:CrystalMod
阅读 21
收藏 0
点赞 0
评论 0
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;
}
}
BlockTelePortal.java 文件源码
项目:CrystalMod
阅读 17
收藏 0
点赞 0
评论 0
@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;
}
BlockMemorial.java 文件源码
项目:Gravestone-mod-Extended
阅读 19
收藏 0
点赞 0
评论 0
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;
}
BlockMemorial.java 文件源码
项目:Gravestone-mod-Extended
阅读 18
收藏 0
点赞 0
评论 0
@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;
}
BuildBlock.java 文件源码
项目:MC-Prefab
阅读 20
收藏 0
点赞 0
评论 0
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;
}
ItemSkull.java 文件源码
项目:ExpandedRailsMod
阅读 22
收藏 0
点赞 0
评论 0
/**
* 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;
}
}
ItemSkull.java 文件源码
项目:Cauldron
阅读 18
收藏 0
点赞 0
评论 0
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_);
}
BlockSkull.java 文件源码
项目:Cauldron
阅读 22
收藏 0
点赞 0
评论 0
@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;
}
TileEntitySkull.java 文件源码
项目:Cauldron
阅读 23
收藏 0
点赞 0
评论 0
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();
}
}
}
ItemSkull.java 文件源码
项目:Cauldron
阅读 19
收藏 0
点赞 0
评论 0
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_);
}
BlockSkull.java 文件源码
项目:Cauldron
阅读 25
收藏 0
点赞 0
评论 0
@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;
}