PGM icon indicating copy to clipboard operation
PGM copied to clipboard

Custom Crafting doesnt work if the recipe is already used by a vanilla recipe

Open RuedigerLP opened this issue 5 years ago • 7 comments

e.g.

<shaped override="false">
    <result material="water bucket"/>
    <shape>
        <row>I.I</row>
        <row>.I.</row>
    </shape>
    <ingredient symbol="I">iron ingot</ingredient>
</shaped>

RuedigerLP avatar Dec 11 '19 20:12 RuedigerLP

Have you tried setting override to true? This disables the vanilla recipe.

From the docs:

Disable all vanilla recipes for the same item. This is just a convenient alternative to the element.

Pugzy avatar Dec 14 '19 11:12 Pugzy

Yes, doesn't work either, i think override just disables the vanilla crafting recipe of the result item.

RuedigerLP avatar Dec 15 '19 12:12 RuedigerLP

The recent changes to the CraftingModule have caused this 6d43acaa44e6601dd357c5f52d9d2335bdc6bafc.

Previously disabled recipes were removed, then new recipes added after. This new implementation adds new recipes first but checks for disabled ones when crafting. This means that a recipe can be both added and disabled. The result of this is that you are unable to change the recipe for a vanilla item whilst disabling the vanilla one.

Within the example in the OP I'm not sure why that exact XML would ever be needed as it changes neither the recipe or output.

I'm not sure if the matches check on the crafted items would allow you to craft slightly updated items such as those with names, lore, enchantments, etc. But this should be fixed regardless.

Pugzy avatar Dec 15 '19 13:12 Pugzy

@Pugzy

Within the example in the OP I'm not sure why that exact XML would ever be needed as it changes neither the recipe or output.

The output in the OP is a water bucket rather than an empty bucket.

Brottweiler avatar Dec 15 '19 16:12 Brottweiler

The changes prior to https://github.com/Electroid/PGM/issues/68 resulted in a NPE similar to the below on the next method.

java.lang.NullPointerException
        at org.bukkit.craftbukkit.v1_8_R3.inventory.RecipeIterator.next(RecipeIterator.java:50) ~[sportpaper.jar:git-SportPaper-"374af6d"]
        at org.bukkit.craftbukkit.v1_8_R3.inventory.RecipeIterator.next(RecipeIterator.java:1) ~[sportpaper.jar:git-SportPaper-"374af6d"]
        at tc.oc.pgm.crafting.CraftingMatchModule.enable(CraftingMatchModule.java:27) ~[?:?]

I can't wrap my head around what causes this at either a PGM or CraftBukkit level. If this could be resolved the implementation could be reverted resolving this issue.

Pugzy avatar Dec 26 '19 10:12 Pugzy

So I have tired this again recently and this would produce the wanted outcome.

 <crafting>
     <shaped override="false">
        <result material="water bucket" amount="1"/>
            <shape>
                <row>...</row>
                <row>G.G</row>
                <row>.G.</row>
            </shape>
        <ingredient symbol="G">iron ingot</ingredient>
    </shaped>
    <shaped override="false">
        <result material="water bucket" amount="1"/>
            <shape>
                <row>G.G</row>
                <row>.G.</row>
                <row>...</row>
            </shape>
        <ingredient symbol="G">iron ingot</ingredient>
    </shaped>
</crafting>

RuedigerLP avatar Aug 06 '21 12:08 RuedigerLP

@RuedigerLP you do not need to add a recipe for every possible place in the crafting table that the recipe can be placed on, you define a shape and the shape can be placed anywhere:

<shape>
    <row>I.I</row>
    <row>.I.</row>
</shape>
<ingredient symbol="I">iron ingot</ingredient>

should work directly, and allow for crafting the bucker in any position (bottom or lower) of the crafting table

Pablete1234 avatar Aug 06 '21 21:08 Pablete1234