Search in sources :

Example 71 with NBTTagCompound

use of net.minecraft.server.v1_13_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()));
}
Also used : DataOutput(java.io.DataOutput) DataOutputStream(java.io.DataOutputStream) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Example 72 with NBTTagCompound

use of net.minecraft.server.v1_13_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);
}
Also used : NBTTagList(net.minecraft.server.v1_12_R1.NBTTagList) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Example 73 with NBTTagCompound

use of net.minecraft.server.v1_13_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;
}
Also used : Zombie(org.bukkit.entity.Zombie) NBTTagCompound(net.minecraft.server.v1_8_R3.NBTTagCompound) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) CraftEntity(org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity) ItemStack(org.bukkit.inventory.ItemStack)

Example 74 with NBTTagCompound

use of net.minecraft.server.v1_13_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;
}
Also used : ChunkCoordIntPair(net.minecraft.server.v1_15_R1.ChunkCoordIntPair) GenericChunk(org.dynmap.common.chunk.GenericChunk) NBTTagCompound(net.minecraft.server.v1_15_R1.NBTTagCompound) IOException(java.io.IOException) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld)

Example 75 with NBTTagCompound

use of net.minecraft.server.v1_13_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;
}
Also used : GenericChunk(org.dynmap.common.chunk.GenericChunk) NBTTagCompound(net.minecraft.server.v1_16_R2.NBTTagCompound) GenericChunk(org.dynmap.common.chunk.GenericChunk) DynmapChunk(org.dynmap.DynmapChunk) Chunk(net.minecraft.server.v1_16_R2.Chunk) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld)

Aggregations

NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)69 ItemStack (org.bukkit.inventory.ItemStack)60 Map (java.util.Map)41 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)39 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)38 ArrayList (java.util.ArrayList)37 ItemMeta (org.bukkit.inventory.meta.ItemMeta)35 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)33 CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)30 ListTag (com.wasteofplastic.org.jnbt.ListTag)30 StringTag (com.wasteofplastic.org.jnbt.StringTag)30 Tag (com.wasteofplastic.org.jnbt.Tag)30 NBTTagCompound (net.minecraft.server.v1_16_R2.NBTTagCompound)24 Nullable (javax.annotation.Nullable)21 NBTTagCompound (net.minecraft.server.v1_9_R2.NBTTagCompound)21 NBTTagCompound (net.minecraft.server.v1_10_R1.NBTTagCompound)20 NBTTagCompound (net.minecraft.server.v1_11_R1.NBTTagCompound)20 CraftItemStack (org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)20 NBTTagList (net.minecraft.server.v1_12_R1.NBTTagList)19 NBTTagCompound (net.minecraft.server.v1_15_R1.NBTTagCompound)18