Search in sources :

Example 91 with NBTTagCompound

use of net.minecraft.server.v1_15_R1.NBTTagCompound in project Essentials by EssentialsX.

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 92 with NBTTagCompound

use of net.minecraft.server.v1_15_R1.NBTTagCompound in project Essentials by EssentialsX.

the class v1_8_R2SpawnerProvider method setEntityType.

@Override
public ItemStack setEntityType(ItemStack is, EntityType type) {
    net.minecraft.server.v1_8_R2.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_R2.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_8_R2.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack)

Example 93 with NBTTagCompound

use of net.minecraft.server.v1_15_R1.NBTTagCompound in project Ublisk by Derkades.

the class Item method setNBTValue.

public Item setNBTValue(String key, boolean bool) {
    NBTTagCompound compound = this.getNBT();
    compound.setBoolean(key, bool);
    return this.setNBT(compound);
}
Also used : NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound)

Example 94 with NBTTagCompound

use of net.minecraft.server.v1_15_R1.NBTTagCompound in project Ublisk by Derkades.

the class CustomItem method fromItem.

public static CustomItem fromItem(Item item) {
    if (item.getType() != CUSTOM_ITEM) {
        throw new IllegalArgumentException("The provided item is not a custom item.");
    }
    NBTTagCompound nbt = item.getNBT();
    if (!nbt.hasKey(UbliskNBT.IDENTIFIER.toString())) {
        throw new IllegalArgumentException("The provided item does not have an item identifier in its NBT");
    }
    String identifier = nbt.getString(UbliskNBT.IDENTIFIER.toString());
    return new CustomItem(identifier, true);
}
Also used : NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) NBTTagString(net.minecraft.server.v1_12_R1.NBTTagString)

Example 95 with NBTTagCompound

use of net.minecraft.server.v1_15_R1.NBTTagCompound in project Ublisk by Derkades.

the class Sword method getItemStack.

@Override
public ItemStack getItemStack() {
    Item item = new Item(this.getMaterial()).setName(this.getColoredName()).setLore(this.getLore());
    NBTTagList modifiers = new NBTTagList();
    NBTTagCompound damage = new NBTTagCompound();
    damage.setString("AttributeName", "generic.attackDamage");
    damage.setString("Name", "generic.attackDamage");
    damage.setDouble("Amount", this.getDamage());
    damage.setInt("Operation", 1);
    damage.setInt("UUIDLeast", 652);
    damage.setInt("UUIDMost", 12098);
    modifiers.add(damage);
    if (this.getMovementSpeed() != -1) {
        NBTTagCompound speed = new NBTTagCompound();
        speed.setString("AttributeName", "generic.movementSpeed");
        speed.setString("Name", "generic.movementSpeed");
        speed.setDouble("Amount", this.getMovementSpeed());
        speed.setInt("Operation", 1);
        speed.setInt("UUIDLeast", 652);
        speed.setInt("UUIDMost", 12098);
        modifiers.add(speed);
    }
    if (this.getAttackSpeed().getValue() != -1) {
        NBTTagCompound attackSpeed = new NBTTagCompound();
        attackSpeed.setString("AttributeName", "generic.attackSpeed");
        attackSpeed.setString("Name", "generic.attackSpeed");
        attackSpeed.setDouble("Amount", this.getAttackSpeed().getValue());
        attackSpeed.setInt("Operation", 1);
        attackSpeed.setInt("UUIDLeast", 652);
        attackSpeed.setInt("UUIDMost", 12098);
        modifiers.add(attackSpeed);
    }
    if (this.getKnockbackResistance() != -1) {
        NBTTagCompound knockback = new NBTTagCompound();
        knockback.setString("AttributeName", "generic.knockbackResistance");
        knockback.setString("Name", "generic.knockbackResistance");
        knockback.setDouble("Amount", this.getKnockbackResistance());
        knockback.setInt("Operation", 1);
        knockback.setInt("UUIDLeast", 652);
        knockback.setInt("UUIDMost", 12098);
        modifiers.add(knockback);
    }
    NBTTagCompound compound = item.getNBT();
    compound.set("AttributeModifiers", modifiers);
    compound.setInt("HideFlags", 7);
    compound.setBoolean("Unbreakable", true);
    item.setNBT(compound);
    item.setDamage(this.getDamage());
    return item.getItemStack();
}
Also used : NBTTagList(net.minecraft.server.v1_12_R1.NBTTagList) Item(xyz.derkades.ublisk.utils.inventory.Item) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound)

Aggregations

ItemStack (org.bukkit.inventory.ItemStack)46 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 ItemMeta (org.bukkit.inventory.meta.ItemMeta)29 NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)27 ArrayList (java.util.ArrayList)24 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)14 NBTTagCompound (net.minecraft.server.v1_9_R2.NBTTagCompound)13 NBTTagCompound (net.minecraft.server.v1_10_R1.NBTTagCompound)12 NBTTagCompound (net.minecraft.server.v1_11_R1.NBTTagCompound)12 NBTTagCompound (net.minecraft.server.v1_9_R1.NBTTagCompound)10 TagCompound (de.keyle.knbt.TagCompound)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 PreparedStatement (java.sql.PreparedStatement)8 HashMap (java.util.HashMap)8 NBTTagCompound (net.minecraft.server.v1_8_R1.NBTTagCompound)8 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)8