1
1
package io .wispforest .owo .mixin .recipe_remainders ;
2
2
3
- import com .google .gson .JsonObject ;
3
+ import com .google .gson .JsonElement ;
4
4
import com .google .gson .JsonParseException ;
5
5
import com .google .gson .JsonPrimitive ;
6
+ import com .llamalad7 .mixinextras .sugar .Local ;
6
7
import com .mojang .serialization .JsonOps ;
7
8
import io .wispforest .owo .util .RecipeRemainderStorage ;
8
- import net .minecraft .inventory .Inventory ;
9
9
import net .minecraft .item .Item ;
10
10
import net .minecraft .item .ItemStack ;
11
- import net .minecraft .recipe .*;
11
+ import net .minecraft .recipe .Recipe ;
12
+ import net .minecraft .recipe .RecipeEntry ;
13
+ import net .minecraft .recipe .RecipeManager ;
14
+ import net .minecraft .recipe .RecipeType ;
12
15
import net .minecraft .recipe .input .RecipeInput ;
13
- import net .minecraft .registry . RegistryWrapper ;
16
+ import net .minecraft .resource . ResourceManager ;
14
17
import net .minecraft .util .Identifier ;
15
18
import net .minecraft .util .JsonHelper ;
16
- import net .minecraft .util .Util ;
17
19
import net .minecraft .util .collection .DefaultedList ;
20
+ import net .minecraft .util .profiler .Profiler ;
18
21
import net .minecraft .world .World ;
19
22
import org .spongepowered .asm .mixin .Mixin ;
20
23
import org .spongepowered .asm .mixin .injection .At ;
21
24
import org .spongepowered .asm .mixin .injection .Inject ;
25
+ import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
22
26
import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
23
27
import org .spongepowered .asm .mixin .injection .callback .LocalCapture ;
24
28
25
29
import java .util .HashMap ;
30
+ import java .util .Map ;
26
31
import java .util .Optional ;
27
32
28
33
@ Mixin (RecipeManager .class )
29
34
public abstract class RecipeManagerMixin {
30
35
31
- @ Inject (method = "deserialize" , at = @ At (value = "RETURN" ))
32
- private static void deserializeRecipeSpecificRemainders (Identifier id , JsonObject json , RegistryWrapper .WrapperLookup registryLookup , CallbackInfoReturnable <Recipe <?>> cir ) {
36
+ @ Inject (method = "apply(Ljava/util/Map;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/recipe/RecipeEntry;<init>(Lnet/minecraft/util/Identifier;Lnet/minecraft/recipe/Recipe;)V" ))
37
+ private void deserializeRecipeSpecificRemainders (Map <Identifier , JsonElement > map , ResourceManager resourceManager , Profiler profiler , CallbackInfo ci , @ Local Map .Entry <Identifier , JsonElement > entry ) {
38
+ var json = entry .getValue ().getAsJsonObject ();
33
39
if (!json .has ("owo:remainders" )) return ;
34
40
35
41
var remainders = new HashMap <Item , ItemStack >();
@@ -46,7 +52,7 @@ private static void deserializeRecipeSpecificRemainders(Identifier id, JsonObjec
46
52
}
47
53
48
54
if (remainders .isEmpty ()) return ;
49
- RecipeRemainderStorage .store (id , remainders );
55
+ RecipeRemainderStorage .store (entry . getKey () , remainders );
50
56
}
51
57
52
58
@ Inject (method = "getRemainingStacks" , at = @ At (value = "RETURN" , ordinal = 0 ), locals = LocalCapture .CAPTURE_FAILHARD )
0 commit comments