Adding new crafting recipe

VixikHD

Member
How can I add new crafting recipe to the crafting manager?


Code:
        Collection<Item> goldenAppleIngredients = Arrays.asList(
                Item.get(Item.AIR),
                Item.get(Item.GOLD_INGOT),
                Item.get(Item.AIR),
                Item.get(Item.GOLD_INGOT),
                Item.get(Item.APPLE),
                Item.get(Item.GOLD_INGOT),
                Item.get(Item.AIR),
                Item.get(Item.GOLD_INGOT),
                Item.get(Item.AIR));

        getServer().getCraftingManager().registerShapelessRecipe(new ShapelessRecipe(Item.get(Item.GOLDEN_APPLE), goldenAppleIngredients));
I've tried this code, but it does not work.

It should make golden apple from these ingredients:

 
Should work with this code


Item goldenapple = new Item(Item.GOLDEN_APPLE);
String[] shapeList = {" X ", "XYX", " X "};
HashMap<Character, Item> itemsToAdd = new HashMap<Character, Item>();
itemsToAdd.put('X', Item.get(Item.GOLD_IGNOT));
itemsToAdd.put('Y', Item.get(Item.APPLE));
ArrayList<Item> itemarray = new ArrayList<Item>();
itemarray.add(goldenapple);
ShapedRecipe recipe = new ShapedRecipe(goldenapple, shapeList, itemsToAdd, itemarray);
this.getServer().addRecipe(recipe);









How can I add new crafting recipe to the crafting manager?


Code:
        Collection<Item> goldenAppleIngredients = Arrays.asList(
                Item.get(Item.AIR),
                Item.get(Item.GOLD_INGOT),
                Item.get(Item.AIR),
                Item.get(Item.GOLD_INGOT),
                Item.get(Item.APPLE),
                Item.get(Item.GOLD_INGOT),
                Item.get(Item.AIR),
                Item.get(Item.GOLD_INGOT),
                Item.get(Item.AIR));

        getServer().getCraftingManager().registerShapelessRecipe(new ShapelessRecipe(Item.get(Item.GOLDEN_APPLE), goldenAppleIngredients));
I've tried this code, but it does not work.

It should make golden apple from these ingredients:

 

tomcruizin

New Member
Hey gang, hope your all well in 2024, just wondering why adding recipe's doesn't work in 2024, am I stupid? Yes, why does this not work lol...

( I added every crafting recipe register function a fella could find)


Java:
        // is based off a diamond sword      
        Item customWeapon = Item.get(gsWeapon.getId(), gsWeapon.getDamage(), 1);

        customWeapon.setCustomName(gsWeapon.getName());



        String[] shape = { " A ", " A ", " S " };

        Map<Character, Item> ingredients = new HashMap<>();

        ingredients.put('A', Item.get(Item.APPLE));

        ingredients.put('A', Item.get(Item.APPLE));

        ingredients.put('S', Item.get(Item.STICK));



        ArrayList<Item> itemarray = new ArrayList<Item>();

        itemarray.add(customWeapon);

        // Pass the customWeapon instance as the first parameter to the ShapedRecipe constructor

        ShapedRecipe recipe = new ShapedRecipe(customWeapon, shape, ingredients, itemarray);

        CamodKitPlugin.getInstance().getServer().getCraftingManager().registerShapedRecipe(recipe);

        CamodKitPlugin.getInstance().getServer().getCraftingManager().registerRecipe(recipe);

        CamodKitPlugin.getInstance().getServer().addRecipe(recipe);
 
Last edited:
Top