@Override public NamedBinaryTag getMetadata(int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(new BlockPosition(x, y, z)); if (tileEntity == null) { return null; } NBTTagCompound nmsTag = new NBTTagCompound(); tileEntity.save(nmsTag); nmsTag.remove("x"); nmsTag.remove("y"); nmsTag.remove("z"); return NBTHelper.getNBTFromNMSTagCompound(null, nmsTag); }
@Override public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); nbttagcompound.setBoolean("Valid", this.hasMoreThanTwoComponents); }
public void setInt(String tag, int value) { nbt.setInt(tag, value); }
@Override public void setItemStackNMS(org.bukkit.inventory.ItemStack stack) { ItemStack newItem = CraftItemStack.asNMSCopy(stack); // ItemStack.a is returned if the stack is null, invalid or the material is not an Item if (newItem == null || newItem == ItemStack.a) { newItem = new ItemStack(Blocks.BEDROCK); } if (newItem.getTag() == null) { newItem.setTag(new NBTTagCompound()); } NBTTagCompound display = newItem.getTag().getCompound("display"); // Returns a new NBTTagCompound if not existing if (!newItem.getTag().hasKey("display")) { newItem.getTag().set("display", display); } NBTTagList tagList = new NBTTagList(); tagList.add(new NBTTagString(ItemUtils.ANTISTACK_LORE)); // Antistack lore display.set("Lore", tagList); newItem.setCount(1); setItemStack(newItem); }
CustomHitbox(Location location, BukkitBall ball) { super(((CraftWorld) location.getWorld()).getHandle()); this.ball = ball; final World mcWorld = ((CraftWorld) location.getWorld()).getHandle(); this.setPosition(location.getX(), location.getY(), location.getZ()); mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.a(compound); this.getSpigotEntity().setCustomName("ResourceBallsPlugin"); this.getSpigotEntity().setCustomNameVisible(false); }
private Entity createEntity(MinecraftKey entityResource, NBTTagCompound optionalMeta) { // Note that the entity position is not set by this method Class<? extends Entity> entityClass = EntityTypes.b.get(entityResource); if (entityClass == null) { TerrainControl.log(LogMarker.WARN, "Unknown entity name: {}", entityResource); return null; } NBTTagCompound copy = optionalMeta == null ? new NBTTagCompound() : (NBTTagCompound) optionalMeta.clone(); copy.setString("id", entityResource.toString()); Entity entity = EntityTypes.a(copy, world); if (entity instanceof EntityInsentient) { ((EntityInsentient) entity).persistent = true; } return entity; }
NBTTagCompound nmsTag = new NBTTagCompound(); NamedBinaryTag[] childTags = (NamedBinaryTag[]) compoundTag.getValue(); for (NamedBinaryTag tag : childTags) case TAG_String: case TAG_Int_Array: nmsTag.set(tag.getName(), createTagNms(tag.getType(), tag.getValue())); break; case TAG_List: nmsTag.set(tag.getName(), getNMSFromNBTTagList(tag)); break; case TAG_Compound: nmsTag.set(tag.getName(), getNMSFromNBTTagCompound(tag)); break; default:
public void reset() { nbt = new NBTTagCompound(); }
@Override public void setBlock(int x, int y, int z, LocalMaterialData material, NamedBinaryTag tag) { setBlock(x, y, z, material); if (tag == null) return; // Convert NamedBinaryTag to a native nms tag NBTTagCompound nmsTag = NBTHelper.getNMSFromNBTTagCompound(tag); // Add the id and position to it nmsTag.setString("id", material.withDefaultBlockData().getName()); nmsTag.setInt("x", x); nmsTag.setInt("y", y); nmsTag.setInt("z", z); // Update to current Minecraft format (maybe we want to do this at // server startup instead, and then save the result?) nmsTag = this.dataConverter.a(DataConverterTypes.BLOCK_ENTITY, nmsTag, -1); // Add that data to the current tile entity in the world TileEntity tileEntity = world.getTileEntity(new BlockPosition(x, y, z)); if (tileEntity != null) { tileEntity.load(nmsTag); } else { TerrainControl.log(LogMarker.DEBUG, "Skipping tile entity with id {}, cannot be placed at {},{},{} on id {}", nmsTag.getString("id"), x, y, z, getMaterial(x, y, z)); } }
public byte[] getByteArray(String tag) { return nbt.getByteArray(tag); }
@Override public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); this.hasMoreThanTwoComponents = nbttagcompound.getBoolean("Valid"); } }
this.setPosition(location.getX(), location.getY(), location.getZ()); mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM); final NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("invulnerable", true); compound.setBoolean("Invisible", true); compound.setBoolean("PersistenceRequired", true); compound.setBoolean("NoBasePlate", true); this.a(compound); this.getSpigotEntity().setCustomName("ResourceBallsPlugin");