Search in sources :

Example 41 with NBTTagCompound

use of net.minecraft.server.v1_10_R1.NBTTagCompound in project Denizen-For-Bukkit by DenizenScript.

the class BlockHelper_v1_8_R3 method getNbtData.

@Override
public CompoundTag getNbtData(Block block) {
    TileEntity tileEntity = ((CraftBlockState) block.getState()).getTileEntity();
    if (tileEntity == null) {
        return null;
    }
    NBTTagCompound nbtTagCompound = new NBTTagCompound();
    tileEntity.b(new NBTTagCompound());
    return CompoundTag_v1_8_R3.fromNMSTag(nbtTagCompound);
}
Also used : TileEntity(net.minecraft.server.v1_8_R3.TileEntity) CraftBlockState(org.bukkit.craftbukkit.v1_8_R3.block.CraftBlockState) NBTTagCompound(net.minecraft.server.v1_8_R3.NBTTagCompound)

Example 42 with NBTTagCompound

use of net.minecraft.server.v1_10_R1.NBTTagCompound in project Denizen-For-Bukkit by DenizenScript.

the class ItemHelper_v1_11_R1 method setSkullSkin.

@Override
public ItemStack setSkullSkin(ItemStack itemStack, PlayerProfile playerProfile) {
    GameProfile gameProfile = new GameProfile(playerProfile.getUniqueId(), playerProfile.getName());
    if (playerProfile.hasTexture()) {
        gameProfile.getProperties().get("textures").clear();
        if (playerProfile.getTextureSignature() != null) {
            gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature()));
        } else {
            gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture()));
        }
    }
    net.minecraft.server.v1_11_R1.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tag = nmsItemStack.hasTag() ? nmsItemStack.getTag() : new NBTTagCompound();
    tag.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameProfile));
    nmsItemStack.setTag(tag);
    return CraftItemStack.asBukkitCopy(nmsItemStack);
}
Also used : GameProfile(com.mojang.authlib.GameProfile) CompoundTag_v1_11_R1(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_11_R1) NBTTagCompound(net.minecraft.server.v1_11_R1.NBTTagCompound) Property(com.mojang.authlib.properties.Property)

Example 43 with NBTTagCompound

use of net.minecraft.server.v1_10_R1.NBTTagCompound in project Denizen-For-Bukkit by DenizenScript.

the class ItemHelper_v1_9_R2 method addNbtData.

@Override
public ItemStack addNbtData(ItemStack itemStack, String key, Tag value) {
    net.minecraft.server.v1_9_R2.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tag = nmsItemStack.hasTag() ? nmsItemStack.getTag() : new NBTTagCompound();
    CompoundTag compound = CompoundTag_v1_9_R2.fromNMSTag(tag).createBuilder().put(key, value).build();
    nmsItemStack.setTag(((CompoundTag_v1_9_R2) compound).toNMSTag());
    return CraftItemStack.asBukkitCopy(nmsItemStack);
}
Also used : CompoundTag_v1_9_R2(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_9_R2) NBTTagCompound(net.minecraft.server.v1_9_R2.NBTTagCompound)

Example 44 with NBTTagCompound

use of net.minecraft.server.v1_10_R1.NBTTagCompound in project Denizen-For-Bukkit by DenizenScript.

the class ItemHelper_v1_9_R2 method setSkullSkin.

@Override
public ItemStack setSkullSkin(ItemStack itemStack, PlayerProfile playerProfile) {
    GameProfile gameProfile = new GameProfile(playerProfile.getUniqueId(), playerProfile.getName());
    if (playerProfile.hasTexture()) {
        gameProfile.getProperties().get("textures").clear();
        if (playerProfile.getTextureSignature() != null) {
            gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature()));
        } else {
            gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture()));
        }
    }
    net.minecraft.server.v1_9_R2.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tag = nmsItemStack.hasTag() ? nmsItemStack.getTag() : new NBTTagCompound();
    tag.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameProfile));
    nmsItemStack.setTag(tag);
    return CraftItemStack.asBukkitCopy(nmsItemStack);
}
Also used : GameProfile(com.mojang.authlib.GameProfile) CompoundTag_v1_9_R2(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_9_R2) NBTTagCompound(net.minecraft.server.v1_9_R2.NBTTagCompound) Property(com.mojang.authlib.properties.Property)

Example 45 with NBTTagCompound

use of net.minecraft.server.v1_10_R1.NBTTagCompound in project Denizen-For-Bukkit by DenizenScript.

the class ItemHelper_v1_10_R1 method setSkullSkin.

@Override
public ItemStack setSkullSkin(ItemStack itemStack, PlayerProfile playerProfile) {
    GameProfile gameProfile = new GameProfile(playerProfile.getUniqueId(), playerProfile.getName());
    if (playerProfile.hasTexture()) {
        gameProfile.getProperties().get("textures").clear();
        if (playerProfile.getTextureSignature() != null) {
            gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature()));
        } else {
            gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture()));
        }
    }
    net.minecraft.server.v1_10_R1.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tag = nmsItemStack.hasTag() ? nmsItemStack.getTag() : new NBTTagCompound();
    tag.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameProfile));
    nmsItemStack.setTag(tag);
    return CraftItemStack.asBukkitCopy(nmsItemStack);
}
Also used : GameProfile(com.mojang.authlib.GameProfile) NBTTagCompound(net.minecraft.server.v1_10_R1.NBTTagCompound) CompoundTag_v1_10_R1(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_10_R1) Property(com.mojang.authlib.properties.Property)

Aggregations

ItemStack (org.bukkit.inventory.ItemStack)35 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 Map (java.util.Map)30 ArrayList (java.util.ArrayList)21 ItemMeta (org.bukkit.inventory.meta.ItemMeta)21 NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)19 NBTTagCompound (net.minecraft.server.v1_10_R1.NBTTagCompound)12 NBTTagCompound (net.minecraft.server.v1_11_R1.NBTTagCompound)12 NBTTagCompound (net.minecraft.server.v1_9_R2.NBTTagCompound)12 NBTTagCompound (net.minecraft.server.v1_9_R1.NBTTagCompound)10 TagCompound (de.keyle.knbt.TagCompound)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 HashMap (java.util.HashMap)8 NBTTagCompound (net.minecraft.server.v1_8_R1.NBTTagCompound)8 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)7 CraftItemStack (org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack)7 NBTTagString (net.minecraft.server.v1_12_R1.NBTTagString)6