Solved Issues related to NMS

Discussion in 'Spigot Plugin Development' started by iO_5, Jul 28, 2018.

  1. why not (nms NBT damger):
    Code (java-1 (Unknown Language)):

    public class CreateItem {

        public static ItemStack aaa = new ItemStack(Material.DIAMOND_SWORD);
     
        public static void createArm(ItemStack itemStack, Material material, String itemName, List<String> lore, int damger, int speed) {
            ItemMeta itemMeta = itemStack.getItemMeta();
            itemMeta.setDisplayName(itemName);
            //itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
            itemMeta.setLore(lore);
            itemStack.setItemMeta(itemMeta);
            Vtest.itemNMS(aaa);
        }
    }

    import org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack;
    import org.bukkit.inventory.ItemStack;
    public class Vtest {
        public static void itemNMS(ItemStack itemStack) {
            ItemStack item = itemStack;
            net.minecraft.server.v1_11_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
            nmsStack.a("generic.attackDamage", new net.minecraft.server.v1_11_R1.AttributeModifier("attackDamage", 100, 0), net.minecraft.server.v1_11_R1.EnumItemSlot.MAINHAND);
            item = CraftItemStack.asBukkitCopy(nmsStack);
        }
    }
     

    Why can (nms NBT damger):
    Code (Text):

    public class Vtest {
        public static ItemStack aaa = new ItemStack(Material.DIAMOND_SWORD);
        public static void itemNMS(ItemStack itemStack) {
            net.minecraft.server.v1_11_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(aaa);
            nmsStack.a("generic.attackDamage", new net.minecraft.server.v1_11_R1.AttributeModifier("attackDamage", 100, 0), net.minecraft.server.v1_11_R1.EnumItemSlot.MAINHAND);
            aaa = CraftItemStack.asBukkitCopy(nmsStack);
        }
    }
     

    How to do?
    I want to easily create items and nns NBT.


    i has solve.
    i use return ItemStack.
     
    #1 iO_5, Jul 28, 2018
    Last edited: Jul 28, 2018