Making costum use of costum items for crafting new costum items

Discussion in 'Plugin Development' started by rojofuerte, May 4, 2022.

Thread Status:
Not open for further replies.
  1. Offline

    rojofuerte

    Hello!!
    I'm triying to make a simple sword using an Item in specific is a stick with its META name being Stick of Truth

    Here is what i have done.
    Code:
    import org.bukkit.inventory.ItemFlag;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.ShapedRecipe;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.event.world.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    import org.bukkit.Bukkit;
    import org.bukkit.Material;
    import org.bukkit.NamespacedKey;
    import org.bukkit.attribute.Attribute;
    import org.bukkit.attribute.AttributeModifier;
    import org.bukkit.enchantments.Enchantment;
    
    public class ItemManager {
    
        public static ItemStack wand;
        public static ItemStack swordt;
        public static void init() {
            createWand();
            createSword();
        }
    
        /* Item frame */
        ItemStack item0;
        ItemStack item1;
    
        private static void createWand() {
            ItemStack item0 = new ItemStack(Material.STICK, 1);
            ItemMeta meta0 = item0.getItemMeta();
            meta0.setDisplayName("Stick of Truth");
            List<String> lore = new ArrayList<>();
            lore.add("This strange stick feels");
            lore.add("like it surge with a strange power");
            meta0.setLore(lore);
            meta0.addEnchant(Enchantment.LUCK, 1, false);
            meta0.addItemFlags(ItemFlag.HIDE_ENCHANTS);
            item0.setItemMeta(meta0);
            wand = item0;
        
            //Shape recipe
            ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("wand"), item0);
        
            sr.shape("  R", " G ", "D  ");
        
            sr.setIngredient('R', Material.REDSTONE);
            sr.setIngredient('G', Material.GOLD_INGOT);
            sr.setIngredient('D', Material.DIAMOND);
            Bukkit.getServer().addRecipe(sr);
    
        }
    
        private static void createSword() {
            ItemStack item1 = new ItemStack(Material.DIAMOND_SWORD, 1);
            ItemMeta meta1 = item1.getItemMeta();
            meta1.setDisplayName("Sword of Truth");
            List<String> lore = new ArrayList<>();
            lore.add("This sword althoug powerful");
            lore.add("seems incomplete");
            meta1.setLore(lore);
            meta1.addEnchant(Enchantment.LUCK, 1, false);
            meta1.addItemFlags(ItemFlag.HIDE_ENCHANTS);
            meta1.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, new AttributeModifier("GENERIC_ATTACK_DAMAGE", 20, AttributeModifier.Operation.ADD_NUMBER));
            meta1.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
            item1.setItemMeta(meta1);
            swordt = item1;
        
            String itemN = "Stick of Truth";
        
            if (){
            
            }
        }
    }
    I will try using an 'if' for cheking if an item with that name is on the crafting table
    but i think this will make able for everyone with an anvil to craft the sword.
     
  2. Offline

    Shqep

Thread Status:
Not open for further replies.

Share This Page