public void reset() { nbt = new NBTTagCompound(); }
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; }
@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); }
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); }
@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); }
NBTTagCompound nmsTag = new NBTTagCompound(); NamedBinaryTag[] childTags = (NamedBinaryTag[]) compoundTag.getValue(); for (NamedBinaryTag tag : childTags)
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);