Polymorph (Fabric/Forge/Quilt)

Polymorph (Fabric/Forge/Quilt)

99M Downloads

Polymorph stops my mods Recipe mixin from working as intended.

xanthian opened this issue ยท 1 comments

commented

my mod (Variant sticks and stuff)
adds stick variants for each vanilla wood type (and associated crafts)

rather than breaking the vanilla recipe for other plank > stick I use the following :

  @Shadow
    private <C extends Inventory, T extends Recipe<C>> Map<Identifier, Recipe<C>> getAllOfType(RecipeType<T> type) {
        return null;
    }

    /**
     * @author Paulevs - Amended by Grend (mostly) & Xanthian (a bit)
     * @reason mc janky crafting manager recipe ordering
     **/
    @Overwrite
    public <C extends Inventory, T extends Recipe<C>> Optional<T> getFirstMatch(RecipeType<T> type, C inventory, World world) {
        Collection<Recipe<C>> values = getAllOfType(type).values();

        List<Recipe<C>> recipes = new ArrayList<>(values);

        recipes.sort((first, second) -> {
            boolean isMine = first.getId().getNamespace().equals(Init.MOD_ID);
            return (isMine ^ second.getId().getNamespace().equals(Init.MOD_ID)) ? (isMine ? -1 : 1) : 0;
        });

        return (Optional<T>) recipes.stream().filter(recipe -> recipe.matches(inventory, world)).findFirst();
    }
}`

Only when Polymorph is installed does it force the vanilla stick to be the primary result, obviously it can be selected via the Polymorph button, but its not ideal.
Not likely anything can be done to resolve this but, figured it was worth a look.
commented

I've changed Polymorph's own recipe ordering to prefer modded recipes over vanilla ones, this should have your intended effect now in terms of what players should see as the default.