Search in sources :

Example 11 with NBTTagCompound

use of net.minecraft.server.v1_8_R2.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 12 with NBTTagCompound

use of net.minecraft.server.v1_8_R2.NBTTagCompound in project Essentials by drtshock.

the class v1_8_R1SpawnerProvider method getEntityType.

@Override
public EntityType getEntityType(ItemStack is) {
    net.minecraft.server.v1_8_R1.ItemStack itemStack;
    CraftItemStack craftStack = CraftItemStack.asCraftCopy(is);
    itemStack = CraftItemStack.asNMSCopy(craftStack);
    NBTTagCompound tag = itemStack.getTag();
    if (tag == null || !tag.hasKey("BlockEntityTag")) {
        throw new IllegalArgumentException();
    }
    String name = tag.getCompound("BlockEntityTag").getString("EntityId");
    return EntityType.fromName(name);
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_8_R1.NBTTagCompound)

Example 13 with NBTTagCompound

use of net.minecraft.server.v1_8_R2.NBTTagCompound in project Essentials by drtshock.

the class v1_8_R1SpawnerProvider method setEntityType.

@Override
public ItemStack setEntityType(ItemStack is, EntityType type) {
    net.minecraft.server.v1_8_R1.ItemStack itemStack;
    CraftItemStack craftStack = CraftItemStack.asCraftCopy(is);
    itemStack = CraftItemStack.asNMSCopy(craftStack);
    NBTTagCompound tag = itemStack.getTag();
    if (tag == null) {
        tag = new NBTTagCompound();
        itemStack.setTag(tag);
    }
    if (!tag.hasKey("BlockEntityTag")) {
        tag.set("BlockEntityTag", new NBTTagCompound());
    }
    tag = itemStack.getTag().getCompound("BlockEntityTag");
    tag.setString("EntityId", type.getName());
    ItemStack bukkitItemStack = CraftItemStack.asCraftMirror(itemStack).clone();
    return setDisplayName(bukkitItemStack, type);
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_8_R1.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)4 Property (com.mojang.authlib.properties.Property)4 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)3 CompoundTag_v1_10_R1 (net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_10_R1)2 CompoundTag_v1_11_R1 (net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_11_R1)2 CompoundTag_v1_8_R3 (net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_8_R3)2 CompoundTag_v1_9_R2 (net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_9_R2)2 NBTTagCompound (net.minecraft.server.v1_10_R1.NBTTagCompound)2 NBTTagCompound (net.minecraft.server.v1_11_R1.NBTTagCompound)2 NBTTagCompound (net.minecraft.server.v1_8_R1.NBTTagCompound)2 NBTTagCompound (net.minecraft.server.v1_8_R2.NBTTagCompound)2 NBTTagCompound (net.minecraft.server.v1_9_R2.NBTTagCompound)2 CraftItemStack (org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack)2 CraftItemStack (org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemStack)2 ItemStack (org.bukkit.inventory.ItemStack)2 TileEntity (net.minecraft.server.v1_8_R3.TileEntity)1 CraftBlockState (org.bukkit.craftbukkit.v1_8_R3.block.CraftBlockState)1