11package  com .junnio .polycoin .recipe ;
22
3+ import  com .junnio .polycoin .PoLymCoin ;
4+ import  com .mojang .serialization .Codec ;
35import  com .mojang .serialization .MapCodec ;
46import  com .mojang .serialization .codecs .RecordCodecBuilder ;
57import  net .minecraft .item .ItemStack ;
68import  net .minecraft .network .RegistryByteBuf ;
79import  net .minecraft .network .codec .PacketCodec ;
810import  net .minecraft .recipe .*;
911import  net .minecraft .recipe .book .RecipeBookCategory ;
12+ import  net .minecraft .recipe .input .CraftingRecipeInput ;
1013import  net .minecraft .registry .RegistryWrapper ;
14+ import  net .minecraft .util .Identifier ;
1115import  net .minecraft .world .World ;
1216
13- public  record  PolymTableCraftingRecipe  (Ingredient  inputItem , ItemStack  output ) implements  Recipe <PolymTableCraftingRecipeInput > {
17+ import  java .util .Map ;
18+ 
19+ public  class  PolymTableCraftingRecipe  implements  Recipe <CraftingRecipeInput > {
20+ 
21+     private  final  Ingredient  inputA ;
22+     private  final  Ingredient  inputB ;
23+     private  final  ItemStack  outputStack ;
24+     public  PolymTableCraftingRecipe (Ingredient  inputA , Ingredient  inputB , ItemStack  outputStack ) {
25+         this .inputA  = inputA ;
26+         this .inputB  = inputB ;
27+         this .outputStack  = outputStack ;
28+     }
29+     public  Ingredient  getInputA () {
30+         return  inputA ;
31+     }
32+ 
33+     public  Ingredient  getInputB () {
34+         return  inputB ;
35+     }
36+     public  ItemStack  getOutputStack () {
37+         return  outputStack ;
38+     }
1439    @ Override 
15-     public  boolean  matches (PolymTableCraftingRecipeInput  input , World  world ) {
16-         if  (!(input  instanceof  PolymTableCraftingRecipeInput )) {
17-             return  false ;
18-         }
19-         if (world .isClient ()) {
20-             return  false ;
21-         }
22-         return  inputItem .test (input .getStackInSlot (0 ));
40+     public  boolean  matches (CraftingRecipeInput  input , World  world ) {
41+         if  (input .size () < 2 ) return  false ;
42+         return  inputA .equals (input .getStackInSlot (0 )) && inputB .equals (input .getStackInSlot (1 ));
2343    }
2444
2545    @ Override 
26-     public  ItemStack  craft (PolymTableCraftingRecipeInput  input , RegistryWrapper .WrapperLookup  registries ) {
27-         return  output .copy ();
46+     public  ItemStack  craft (CraftingRecipeInput  input , RegistryWrapper .WrapperLookup  registries ) {
47+         return  outputStack .copy ();
2848    }
2949
3050    @ Override 
31-     public  RecipeSerializer <?  extends   Recipe < PolymTableCraftingRecipeInput >>  getSerializer () {
32-         return  ModRecipes . POLYM_CRAFTING_SERIALIZER ;
51+     public  boolean   isIgnoredInRecipeBook () {
52+         return  Recipe . super . isIgnoredInRecipeBook () ;
3353    }
3454
3555    @ Override 
36-     public  RecipeType <? extends  Recipe <PolymTableCraftingRecipeInput >> getType () {
37-         return  ModRecipes .POLYM_CRAFTING_TYPE ;
56+     public  RecipeSerializer <? extends  Recipe <CraftingRecipeInput >> getSerializer () {
57+         return  PolymRecipeSerializer .INSTANCE ;
58+     }
59+ 
60+     @ Override 
61+     public  RecipeType <? extends  Recipe <CraftingRecipeInput >> getType () {
62+         return  Type .INSTANCE ;
3863    }
3964
4065    @ Override 
@@ -46,27 +71,10 @@ public IngredientPlacement getIngredientPlacement() {
4671    public  RecipeBookCategory  getRecipeBookCategory () {
4772        return  null ;
4873    }
49- 
50-     public  static  class  Serializer  implements  RecipeSerializer <PolymTableCraftingRecipe > {
51-         public  static  final  MapCodec <PolymTableCraftingRecipe > CODEC  = RecordCodecBuilder .mapCodec (inst  -> inst .group (
52-                 Ingredient .CODEC .fieldOf ("ingredient" ).forGetter (PolymTableCraftingRecipe ::inputItem ),
53-                 ItemStack .CODEC .fieldOf ("result" ).forGetter (PolymTableCraftingRecipe ::output )
54-         ).apply (inst , PolymTableCraftingRecipe ::new ));
55- 
56-         public  static  final  PacketCodec <RegistryByteBuf , PolymTableCraftingRecipe > STREAM_CODEC  =
57-                 PacketCodec .tuple (
58-                         Ingredient .PACKET_CODEC , PolymTableCraftingRecipe ::inputItem ,
59-                         ItemStack .PACKET_CODEC , PolymTableCraftingRecipe ::output ,
60-                         PolymTableCraftingRecipe ::new );
61- 
62-         @ Override 
63-         public  MapCodec <PolymTableCraftingRecipe > codec () {
64-             return  CODEC ;
65-         }
66- 
67-         @ Override 
68-         public  PacketCodec <RegistryByteBuf , PolymTableCraftingRecipe > packetCodec () {
69-             return  STREAM_CODEC ;
70-         }
74+     public  static  class  Type  implements  RecipeType <PolymTableCraftingRecipe > {
75+         // Define ExampleRecipe.Type as a singleton by making its constructor private and exposing an instance. 
76+         private  Type () {}
77+         public  static  final  Type  INSTANCE  = new  Type ();
78+         public  static  final  String  ID  = "two_slot_recipe" ;
7179    }
7280}
0 commit comments