Skip to content

QuickBench mixin prevents vanilla ServerPlacer$triggerRecipeCrafted from firing when crafting #16

@TelepathicGrunt

Description

@TelepathicGrunt

Environment

  • Minecraft: 1.20.1
  • QuickBench: v4.1.0+mc.1.20.1
  • Loader: Fabric
  • Java: 21
  • Mods: Impacts Bumblezone

To Reproduce

I am the Dev of Bumblezone mod and I gotten this bug report:

TelepathicGrunt/Bumblezone#556

The bug is when users craft Beehives in a Crafting Table, my advancement that would've triggered after crafting a number of that block is not completing. This confused me because my mod mixins to triggerRecipeCrafted method in ServerPlayer to know when a recipe is crafted and count up for my advancement trigger. It should've been foolproof as it is tied basically to when vanilla's recipe crafter trigger is fired.

Bumblezone/common/src/main/java/com/telepathicgrunt/the_bumblezone/mixin/entities/ServerPlayerMixin.java

Upon pulling QuickBench into my dev environment I found that mod is redirecting RecipeHolder$awardUsedRecipes to call some custom code for recipe book recipe unlocking. But by doing so, it has circumvented calling ServerPlayer$triggerRecipeCrafted which means vanilla's CriteriaTriggers.RECIPE_CRAFTED advancement trigger never gets called. QuickBench effectively broke all recipe trigger advancement datapacks and mods.

The problematic mixin that needs to call RecipeHolder$awardUsedRecipes OR call ServerPlayer$triggerRecipeCrafted to restore functionality to anyone using recipe crafted trigger

@Redirect(method = "checkTakeAchievements",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/RecipeHolder;awardUsedRecipes(Lnet/minecraft/world/entity/player/Player;Ljava/util/List;)V"))
public void no(final RecipeHolder instance, final Player player, final List<ItemStack> list) {
if (((CraftingInventoryDuck) craftSlots).getCheckMatrixChanges() &&
this.container instanceof RecipeHolder recipeHolder) {
var recipeUsed = recipeHolder.getRecipeUsed();
if (recipeUsed != null && !recipeUsed.isSpecial()) {
player.awardRecipes(Collections.singleton(recipeUsed));
}
}
}

In fact if you craft a pot using 4 sherds, vanilla should grant you and advancement but with QuickBench on, it does not:

Image Image

With QuickBench removed, the pot crafting from sherds grants the advancement properly. You can use this to test if the updated code fixed the issue.

Image

Expected results

Advancements using the recipe crafted trigger works properly

Logs, crash report, mod list or unmodified mod pack

N/A

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions