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();
}
}
}
java类net.minecraft.nbt.NBTUtil的实例源码
TileEntitySkull.java 文件源码
项目:Cauldron
阅读 24
收藏 0
点赞 0
评论 0
EntityMiniMe.java 文件源码
项目:OpenBlocks
阅读 19
收藏 0
点赞 0
评论 0
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;
}
TileEntityGoldenEgg.java 文件源码
项目:OpenBlocks
阅读 21
收藏 0
点赞 0
评论 0
@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"));
}
}
TileEntityHatStand.java 文件源码
项目:Hats
阅读 19
收藏 0
点赞 0
评论 0
@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;
}
PacketDescription.java 文件源码
项目:pnc-repressurized
阅读 25
收藏 0
点赞 0
评论 0
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");
}
CraftBlock.java 文件源码
项目:Uranium
阅读 26
收藏 0
点赞 0
评论 0
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;
}
CraftMetaSkull.java 文件源码
项目:Uranium
阅读 24
收藏 0
点赞 0
评论 0
@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);
}
}
BlockSkull.java 文件源码
项目:DecompiledMinecraft
阅读 23
收藏 0
点赞 0
评论 0
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);
}
}
TileEntitySkull.java 文件源码
项目:DecompiledMinecraft
阅读 19
收藏 0
点赞 0
评论 0
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);
}
}
CommandTestFor.java 文件源码
项目:DecompiledMinecraft
阅读 23
收藏 0
点赞 0
评论 0
/**
* 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()});
}
}