use of net.minecraft.server.v1_16_R2.NBTTagCompound in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_12_R1 method serialize.
@Override
public String serialize(org.bukkit.inventory.ItemStack itemStack) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
DataOutput dataOutput = new DataOutputStream(outputStream);
NBTTagCompound tagCompound = new NBTTagCompound();
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
if (nmsItem.isEmpty())
return "";
if (nmsItem != null) {
nmsItem.setCount(1);
nmsItem.save(tagCompound);
}
try {
NBTCompressedStreamTools.a(tagCompound, dataOutput);
} catch (Exception ex) {
return null;
}
return "*" + new String(Base64.getEncoder().encode(outputStream.toByteArray()));
}
use of net.minecraft.server.v1_16_R2.NBTTagCompound in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_12_R1 method serialize.
private void serialize(Inventory inventory, NBTTagCompound tagCompound) {
NBTTagList itemsList = new NBTTagList();
org.bukkit.inventory.ItemStack[] items = inventory.getContents();
for (int i = 0; i < items.length; ++i) {
if (items[i] != null) {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
nbtTagCompound.setByte("Slot", (byte) i);
CraftItemStack.asNMSCopy(items[i]).save(nbtTagCompound);
itemsList.add(nbtTagCompound);
}
}
tagCompound.setInt("Size", inventory.getSize());
tagCompound.set("Items", itemsList);
}
use of net.minecraft.server.v1_16_R2.NBTTagCompound in project Warlords by ebicep.
the class WarlordsPlayer method spawnJimmy.
public Zombie spawnJimmy(@Nonnull Location loc, @Nullable EntityEquipment inv) {
Zombie jimmy = loc.getWorld().spawn(loc, Zombie.class);
jimmy.setBaby(false);
jimmy.setCustomNameVisible(true);
// TODO add level and class into the name of this jimmy
jimmy.setCustomName(this.getSpec().getClassNameShortWithBrackets() + " " + this.getColoredName() + " " + ChatColor.RED + this.health + "❤");
jimmy.setMetadata("WARLORDS_PLAYER", new FixedMetadataValue(Warlords.getInstance(), this));
((EntityLiving) ((CraftEntity) jimmy).getHandle()).getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0);
((EntityLiving) ((CraftEntity) jimmy).getHandle()).getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(0);
// prevents jimmy from moving
net.minecraft.server.v1_8_R3.Entity nmsEn = ((CraftEntity) jimmy).getHandle();
NBTTagCompound compound = new NBTTagCompound();
nmsEn.c(compound);
compound.setByte("NoAI", (byte) 1);
nmsEn.f(compound);
if (inv != null) {
jimmy.getEquipment().setBoots(inv.getBoots());
jimmy.getEquipment().setLeggings(inv.getLeggings());
jimmy.getEquipment().setChestplate(inv.getChestplate());
jimmy.getEquipment().setHelmet(inv.getHelmet());
jimmy.getEquipment().setItemInHand(inv.getItemInHand());
} else {
jimmy.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
}
if (dead) {
jimmy.remove();
}
return jimmy;
}
use of net.minecraft.server.v1_16_R2.NBTTagCompound in project dynmap by webbukkit.
the class MapChunkCache115 method loadChunk.
// Load generic chunk from unloaded chunk
protected GenericChunk loadChunk(DynmapChunk chunk) {
CraftWorld cw = (CraftWorld) w;
NBTTagCompound nbt = null;
ChunkCoordIntPair cc = new ChunkCoordIntPair(chunk.x, chunk.z);
GenericChunk gc = null;
try {
nbt = cw.getHandle().getChunkProvider().playerChunkMap.read(cc);
} catch (IOException iox) {
}
if (nbt != null) {
gc = parseChunkFromNBT(new NBT.NBTCompound(nbt));
}
return gc;
}
use of net.minecraft.server.v1_16_R2.NBTTagCompound in project dynmap by webbukkit.
the class MapChunkCache116_2 method getLoadedChunk.
// Load generic chunk from existing and already loaded chunk
protected GenericChunk getLoadedChunk(DynmapChunk chunk) {
CraftWorld cw = (CraftWorld) w;
NBTTagCompound nbt = null;
GenericChunk gc = null;
if (cw.isChunkLoaded(chunk.x, chunk.z)) {
Chunk c = cw.getHandle().getChunkAt(chunk.x, chunk.z);
if ((c != null) && c.loaded) {
nbt = ChunkRegionLoader.saveChunk(cw.getHandle(), c);
}
if (nbt != null) {
gc = parseChunkFromNBT(new NBT.NBTCompound(nbt));
}
}
return gc;
}
Aggregations