3333import net .minecraft .world .inventory .CraftingContainer ;
3434import net .minecraft .world .inventory .ResultContainer ;
3535import net .minecraft .world .inventory .Slot ;
36+ import net .minecraft .world .item .Item ;
3637import net .minecraft .world .item .ItemStack ;
3738import net .minecraft .world .item .crafting .CraftingRecipe ;
3839import net .minecraft .world .item .crafting .Recipe ;
@@ -51,6 +52,11 @@ public final class MixinHooks {
5152 private static final MethodHandle recipe$assemble = Reflector .virtual (Recipe .class , "method_8116" ,
5253 MethodType .methodType (ItemStack .class , Container .class , RegistryAccess .class ));
5354
55+ private static final MethodHandle item$onCraftedBy = Reflector .virtual (
56+ Item .class , MethodType .methodType (void .class , ItemStack .class , Level .class , Player .class ),
57+ "method_54465" , "method_7843"
58+ );
59+
5460 public static boolean hascachedrecipe = false ;
5561
5662 public static Recipe <CraftingContainer > lastRecipe ;
@@ -64,11 +70,7 @@ public static void slotChangedCraftingGrid(Level level, CraftingContainer inv, R
6470 if (recipe == null || !recipe .value ().matches (inv , level )) recipe = findRecipe (inv , level );
6571
6672 if (recipe != null ) {
67- try {
68- itemstack = (ItemStack ) recipe$assemble .invoke (recipe .value (), inv , level .registryAccess ());
69- } catch (Throwable t ) {
70- throw new AssertionError (t );
71- }
73+ itemstack = durian (recipe$assemble , recipe .value (), inv , level .registryAccess ());
7274 }
7375
7476 result .setItem (0 , itemstack );
@@ -89,7 +91,7 @@ public static ItemStack handleShiftCraft(Player player, AbstractContainerMenu co
8991 ItemStack recipeOutput = resultSlot .getItem ().copy ();
9092 outputCopy = recipeOutput .copy ();
9193
92- recipeOutput .getItem (). onCraftedBy ( recipeOutput , player .level (), player );
94+ durian ( item$onCraftedBy , recipeOutput .getItem (), recipeOutput , player .level (), player );
9395
9496 if (!player .level ().isClientSide && !((ContainerAccessor ) container ).insert (recipeOutput , outStart , outEnd , true )) {
9597 duck .setCheckMatrixChanges (true );
@@ -128,4 +130,12 @@ public static RecipeHolder<CraftingRecipe> findRecipe(CraftingContainer inv, Lev
128130 public static <C extends Container , T extends Recipe <C >> RecipeHolder <T > coerce (RecipeHolder <?> in ) {
129131 return (RecipeHolder <T >) in ;
130132 }
133+
134+ public static <T > T durian (MethodHandle handle , Object ... objects ) {
135+ try {
136+ return (T ) handle .invokeWithArguments (objects );
137+ } catch (Throwable t ) {
138+ throw new AssertionError (t );
139+ }
140+ }
131141}
0 commit comments