From d5b723196748e7f5cae78cd618a9e4652e77ffeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=ADSollace?= Date: Mon, 12 Apr 2021 14:13:07 +0200 Subject: [PATCH] Recipe mappings (#1325) * Recipe mappings Co-authored-by: Joseph Burton * Update mappings/net/minecraft/recipe/Recipe.mapping Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> * Update mappings/net/minecraft/recipe/Recipe.mapping Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: YanisBft * Apply suggestions from code review Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com> Co-authored-by: liach <7806504+liach@users.noreply.github.com> Co-authored-by: YanisBft * Update mappings/net/minecraft/recipe/ShapedRecipe.mapping Co-authored-by: liach <7806504+liach@users.noreply.github.com> * Update mappings/net/minecraft/entity/player/PlayerInventory.mapping Co-authored-by: liach <7806504+liach@users.noreply.github.com> * Update mappings/net/minecraft/recipe/Recipe.mapping Co-authored-by: liach <7806504+liach@users.noreply.github.com> * Update mappings/net/minecraft/recipe/RecipeMatcher.mapping Co-authored-by: liach <7806504+liach@users.noreply.github.com> * Update mappings/net/minecraft/recipe/RecipeMatcher.mapping Co-authored-by: enbrain <69905075+enbrain@users.noreply.github.com> * Update mappings/net/minecraft/recipe/RecipeMatcher.mapping Co-authored-by: enbrain <69905075+enbrain@users.noreply.github.com> Co-authored-by: Joseph Burton Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com> Co-authored-by: YanisBft Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com> Co-authored-by: liach <7806504+liach@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: enbrain <69905075+enbrain@users.noreply.github.com> --- .../entity/player/PlayerInventory.mapping | 4 + .../net/minecraft/recipe/Ingredient.mapping | 2 +- .../minecraft/recipe/InputSlotFiller.mapping | 6 +- mappings/net/minecraft/recipe/Recipe.mapping | 31 ++++- .../net/minecraft/recipe/RecipeFinder.mapping | 48 ------- .../minecraft/recipe/RecipeMatcher.mapping | 120 ++++++++++++++++++ .../net/minecraft/recipe/ShapedRecipe.mapping | 47 +++++-- 7 files changed, 190 insertions(+), 68 deletions(-) delete mode 100644 mappings/net/minecraft/recipe/RecipeFinder.mapping create mode 100644 mappings/net/minecraft/recipe/RecipeMatcher.mapping diff --git a/mappings/net/minecraft/entity/player/PlayerInventory.mapping b/mappings/net/minecraft/entity/player/PlayerInventory.mapping index 43fbecadc7..7457e18d90 100644 --- a/mappings/net/minecraft/entity/player/PlayerInventory.mapping +++ b/mappings/net/minecraft/entity/player/PlayerInventory.mapping @@ -43,6 +43,10 @@ CLASS net/minecraft/class_1661 net/minecraft/entity/player/PlayerInventory METHOD method_7370 getBlockBreakingSpeed (Lnet/minecraft/class_2680;)F ARG 1 block METHOD method_7371 indexOf (Lnet/minecraft/class_1799;)I + COMMENT Given the item stack to search for, returns the equivalent slot index with a matching stack that is all of: + COMMENT not damaged, not enchanted, and not renamed. + COMMENT + COMMENT @return the index where a matching stack was found, or {@value #NOT_FOUND} ARG 1 stack METHOD method_7372 getArmorStack (I)Lnet/minecraft/class_1799; ARG 1 slot diff --git a/mappings/net/minecraft/recipe/Ingredient.mapping b/mappings/net/minecraft/recipe/Ingredient.mapping index e4d5cc73c4..f438c263ea 100644 --- a/mappings/net/minecraft/recipe/Ingredient.mapping +++ b/mappings/net/minecraft/recipe/Ingredient.mapping @@ -24,7 +24,7 @@ CLASS net/minecraft/class_1856 net/minecraft/recipe/Ingredient METHOD method_8094 (Lnet/minecraft/class_1799;)Lnet/minecraft/class_1856$class_1857; ARG 0 stack METHOD method_8096 cacheMatchingStacks ()V - METHOD method_8100 getIds ()Lit/unimi/dsi/fastutil/ints/IntList; + METHOD method_8100 getMatchingItemIds ()Lit/unimi/dsi/fastutil/ints/IntList; METHOD method_8101 ofStacks ([Lnet/minecraft/class_1799;)Lnet/minecraft/class_1856; ARG 0 stacks METHOD method_8102 fromJson (Lcom/google/gson/JsonElement;)Lnet/minecraft/class_1856; diff --git a/mappings/net/minecraft/recipe/InputSlotFiller.mapping b/mappings/net/minecraft/recipe/InputSlotFiller.mapping index 02021af25f..a497c536d6 100644 --- a/mappings/net/minecraft/recipe/InputSlotFiller.mapping +++ b/mappings/net/minecraft/recipe/InputSlotFiller.mapping @@ -1,10 +1,10 @@ CLASS net/minecraft/class_2955 net/minecraft/recipe/InputSlotFiller - FIELD field_13347 recipeFinder Lnet/minecraft/class_1662; - FIELD field_13348 craftingScreenHandler Lnet/minecraft/class_1729; + FIELD field_13347 matcher Lnet/minecraft/class_1662; + FIELD field_13348 handler Lnet/minecraft/class_1729; FIELD field_13349 LOGGER Lorg/apache/logging/log4j/Logger; FIELD field_13350 inventory Lnet/minecraft/class_1661; METHOD (Lnet/minecraft/class_1729;)V - ARG 1 craftingScreenHandler + ARG 1 handler METHOD method_12819 getAmountToFill (ZIZ)I ARG 1 craftAll ARG 2 limit diff --git a/mappings/net/minecraft/recipe/Recipe.mapping b/mappings/net/minecraft/recipe/Recipe.mapping index 6db610a3ec..0b3486c57f 100644 --- a/mappings/net/minecraft/recipe/Recipe.mapping +++ b/mappings/net/minecraft/recipe/Recipe.mapping @@ -1,22 +1,43 @@ CLASS net/minecraft/class_1860 net/minecraft/recipe/Recipe - METHOD method_17447 getRecipeKindIcon ()Lnet/minecraft/class_1799; + METHOD method_17447 createIcon ()Lnet/minecraft/class_1799; + COMMENT Creates the stack that is displayed on the recipe book tab containing this recipe, and on a toast when a recipe of this type is unlocked. + COMMENT Used in conjunction with {@link #getGroup()}. METHOD method_17716 getType ()Lnet/minecraft/class_3956; METHOD method_31583 (Lnet/minecraft/class_1856;)Z ARG 0 ingredient METHOD method_31584 isEmpty ()Z METHOD method_8110 getOutput ()Lnet/minecraft/class_1799; - METHOD method_8111 getRemainingStacks (Lnet/minecraft/class_1263;)Lnet/minecraft/class_2371; + METHOD method_8111 getRemainder (Lnet/minecraft/class_1263;)Lnet/minecraft/class_2371; + COMMENT Returns the remaining stacks to be left in the crafting grid after crafting is complete. + COMMENT Should return the same number of items as the input grid contains in the same order they're expected + COMMENT to appear in that grid. + COMMENT + COMMENT @implSpec Default implementation simply returns a grid of all empty stacks where all stacks from the + COMMENT input grid have been replaced with the result of calling {@link Item#getRecipeRemainder()} on them. ARG 1 inventory METHOD method_8112 getGroup ()Ljava/lang/String; + COMMENT Optional group this recipe belongs in. Used to group recipes into different categories by the recipe book. METHOD method_8113 fits (II)Z + COMMENT Determines whether this recipe's pattern will fit into the available crafting area. ARG 1 width ARG 2 height METHOD method_8114 getId ()Lnet/minecraft/class_2960; METHOD method_8115 matches (Lnet/minecraft/class_1263;Lnet/minecraft/class_1937;)Z - ARG 1 inv + COMMENT Determines whether this recipe matches the contents currently placed inside the available crafting grid. + ARG 1 inventory ARG 2 world METHOD method_8116 craft (Lnet/minecraft/class_1263;)Lnet/minecraft/class_1799; - ARG 1 inv - METHOD method_8117 getPreviewInputs ()Lnet/minecraft/class_2371; + COMMENT Crafts this recipe. + COMMENT + COMMENT

This method may perform side effects on the {@code inventory} argument.

+ COMMENT + COMMENT

This method should return a new item stack on each call.

+ COMMENT + COMMENT @return the resulting item stack + ARG 1 inventory + METHOD method_8117 getIngredients ()Lnet/minecraft/class_2371; + COMMENT The ingredients accepted as inputs for this recipe. Used by the recipe book + COMMENT when displaying a ghost form of this recipe on the crafting grid as well as for + COMMENT previewing the possible inputs in the book itself. METHOD method_8118 isIgnoredInRecipeBook ()Z METHOD method_8119 getSerializer ()Lnet/minecraft/class_1865; diff --git a/mappings/net/minecraft/recipe/RecipeFinder.mapping b/mappings/net/minecraft/recipe/RecipeFinder.mapping deleted file mode 100644 index 3eb0dcf42c..0000000000 --- a/mappings/net/minecraft/recipe/RecipeFinder.mapping +++ /dev/null @@ -1,48 +0,0 @@ -CLASS net/minecraft/class_1662 net/minecraft/recipe/RecipeFinder - FIELD field_7550 idToAmountMap Lit/unimi/dsi/fastutil/ints/Int2IntMap; - METHOD method_20478 addItem (Lnet/minecraft/class_1799;I)V - ARG 1 stack - ARG 2 count - METHOD method_7400 addItem (Lnet/minecraft/class_1799;)V - ARG 1 stack - METHOD method_7401 addItem (II)V - ARG 1 id - ARG 2 amount - METHOD method_7402 findRecipe (Lnet/minecraft/class_1860;Lit/unimi/dsi/fastutil/ints/IntList;)Z - ARG 1 recipe - ARG 2 outMatchingInputIds - METHOD method_7403 countRecipeCrafts (Lnet/minecraft/class_1860;ILit/unimi/dsi/fastutil/ints/IntList;)I - ARG 1 recipe - ARG 2 limit - ARG 3 outMatchingInputIds - METHOD method_7404 addNormalItem (Lnet/minecraft/class_1799;)V - ARG 1 stack - METHOD method_7405 getStackFromId (I)Lnet/minecraft/class_1799; - ARG 0 id - METHOD method_7406 findRecipe (Lnet/minecraft/class_1860;Lit/unimi/dsi/fastutil/ints/IntList;I)Z - ARG 1 recipe - ARG 2 outMatchingInputIds - ARG 3 amount - METHOD method_7407 countRecipeCrafts (Lnet/minecraft/class_1860;Lit/unimi/dsi/fastutil/ints/IntList;)I - ARG 1 recipe - ARG 2 outMatchingInputIds - METHOD method_7408 getItemId (Lnet/minecraft/class_1799;)I - ARG 0 stack - METHOD method_7409 clear ()V - METHOD method_7410 contains (I)Z - ARG 1 id - METHOD method_7411 take (II)I - ARG 1 id - ARG 2 amount - CLASS class_1663 Filter - FIELD field_7552 ingredients Ljava/util/List; - FIELD field_7555 recipe Lnet/minecraft/class_1860; - FIELD field_7556 ingredientCount I - METHOD (Lnet/minecraft/class_1662;Lnet/minecraft/class_1860;)V - ARG 2 recipe - METHOD method_7417 find (ILit/unimi/dsi/fastutil/ints/IntList;)Z - ARG 1 amount - ARG 2 outMatchingInputIds - METHOD method_7427 countCrafts (ILit/unimi/dsi/fastutil/ints/IntList;)I - ARG 1 limit - ARG 2 outMatchingInputIds diff --git a/mappings/net/minecraft/recipe/RecipeMatcher.mapping b/mappings/net/minecraft/recipe/RecipeMatcher.mapping new file mode 100644 index 0000000000..1fddf7cc26 --- /dev/null +++ b/mappings/net/minecraft/recipe/RecipeMatcher.mapping @@ -0,0 +1,120 @@ +CLASS net/minecraft/class_1662 net/minecraft/recipe/RecipeMatcher + COMMENT Matching class that matches a recipe to its required resources. + COMMENT This specifically does not check patterns (See {@link ShapedRecipe} for that). + FIELD field_7550 inputs Lit/unimi/dsi/fastutil/ints/Int2IntMap; + METHOD method_20478 addInput (Lnet/minecraft/class_1799;I)V + COMMENT Adds an item stack to the pool of available resources. + ARG 1 stack + ARG 2 maxCount + METHOD method_7400 addInput (Lnet/minecraft/class_1799;)V + COMMENT Adds a full item stack to the pool of available resources. + COMMENT + COMMENT

This is equivalent to calling {@code addInput(stack, Item.DEFAULT_MAX_COUNT)}.

+ ARG 1 stack + METHOD method_7401 addInput (II)V + COMMENT Adds an input to be used for recipe matching. + ARG 1 itemId + COMMENT the raw ID of the item to match + ARG 2 count + COMMENT the item's count + METHOD method_7402 match (Lnet/minecraft/class_1860;Lit/unimi/dsi/fastutil/ints/IntList;)Z + COMMENT Attempts to match the recipe against the collected inputs. + COMMENT Assumes only one output is required. + ARG 1 recipe + COMMENT the recipe to match against + ARG 2 output + COMMENT optional output list of item ids that were matched whilst evaluating the recipe conditions + METHOD method_7403 countCrafts (Lnet/minecraft/class_1860;ILit/unimi/dsi/fastutil/ints/IntList;)I + COMMENT Determines the number of crafts that can be produced for a recipe using the + COMMENT collected resources available to this crafter. + ARG 1 recipe + COMMENT the recipe to match against + ARG 2 limit + ARG 3 output + COMMENT optional output list of item ids that were matched whilst evaluating the recipe conditions + METHOD method_7404 addUnenchantedInput (Lnet/minecraft/class_1799;)V + COMMENT Adds a full item stack to the pool of available resources. + COMMENT + COMMENT

This is equivalent to calling {@code addInput(stack, Item.DEFAULT_MAX_COUNT)}.

+ ARG 1 stack + METHOD method_7405 getStackFromId (I)Lnet/minecraft/class_1799; + ARG 0 itemId + METHOD method_7406 match (Lnet/minecraft/class_1860;Lit/unimi/dsi/fastutil/ints/IntList;I)Z + COMMENT Attempts to match the recipe against the collected inputs. Will only succeed if there has been enough + COMMENT resources gathered to produce the requested number of outputs. + ARG 1 recipe + COMMENT the recipe to match against + ARG 2 output + COMMENT optional output list of item ids that were matched whilst evaluating the recipe conditions + ARG 3 multiplier + COMMENT the number of expected outputs + METHOD method_7407 countCrafts (Lnet/minecraft/class_1860;Lit/unimi/dsi/fastutil/ints/IntList;)I + COMMENT Determines the number of crafts that can be produced for a recipe using the + COMMENT collected resources available to this crafter. + ARG 1 recipe + COMMENT the recipe to match against + ARG 2 output + COMMENT optional output list of item ids that were matched whilst evaluating the recipe conditions + METHOD method_7408 getItemId (Lnet/minecraft/class_1799;)I + ARG 0 stack + METHOD method_7409 clear ()V + METHOD method_7410 contains (I)Z + COMMENT Determines whether a raw item id is present in the pool of crafting resources. + ARG 1 itemId + METHOD method_7411 consume (II)I + COMMENT Consumes a resource from the pool of available items. + ARG 1 itemId + COMMENT the raw id of the item being consumed + ARG 2 count + COMMENT the number of times that item must be consumed + CLASS class_1663 Matcher + FIELD field_7551 requiredItems [I + FIELD field_7552 ingredients Ljava/util/List; + FIELD field_7553 totalRequiredItems I + FIELD field_7555 recipe Lnet/minecraft/class_1860; + FIELD field_7556 totalIngredients I + FIELD field_7557 ingredientItemLookup Lit/unimi/dsi/fastutil/ints/IntList; + FIELD field_7558 requirementsMatrix Ljava/util/BitSet; + METHOD (Lnet/minecraft/class_1662;Lnet/minecraft/class_1860;)V + ARG 1 recipe + METHOD method_7413 addRequirement (ZI)V + ARG 1 reversed + ARG 2 itemId + METHOD method_7414 flipRequirement (ZII)V + ARG 1 reversed + ARG 2 itemIndex + ARG 3 ingredientIndex + METHOD method_7415 getMaximumCrafts ()I + METHOD method_7416 getRequirement (I)Z + ARG 1 itemId + METHOD method_7417 match (ILit/unimi/dsi/fastutil/ints/IntList;)Z + ARG 1 multiplier + ARG 2 output + METHOD method_7418 needsRequirement (ZII)Z + ARG 1 reversed + ARG 2 itemIndex + ARG 3 ingredientIndex + METHOD method_7419 getRequirementIndex (I)I + ARG 1 itemId + METHOD method_7420 getRequirementIndex (ZII)I + ARG 1 reversed + ARG 2 itemIndex + ARG 3 ingredientIndex + METHOD method_7421 unfulfillRequirement (I)V + ARG 1 itemId + METHOD method_7422 createItemRequirementList ()[I + METHOD method_7423 checkRequirements (I)Z + ARG 1 multiplier + METHOD method_7424 getRequirementIndex (ZI)I + ARG 1 reversed + ARG 2 itemId + METHOD method_7425 checkRequirement (ZII)Z + ARG 1 reversed + ARG 2 itemIndex + ARG 3 ingredientIndex + METHOD method_7426 isRequirementUnfulfilled (ZI)Z + ARG 1 reversed + ARG 2 itemId + METHOD method_7427 countCrafts (ILit/unimi/dsi/fastutil/ints/IntList;)I + ARG 1 minimum + ARG 2 output diff --git a/mappings/net/minecraft/recipe/ShapedRecipe.mapping b/mappings/net/minecraft/recipe/ShapedRecipe.mapping index 8fc8dd31ce..db62a6675b 100644 --- a/mappings/net/minecraft/recipe/ShapedRecipe.mapping +++ b/mappings/net/minecraft/recipe/ShapedRecipe.mapping @@ -1,6 +1,6 @@ CLASS net/minecraft/class_1869 net/minecraft/recipe/ShapedRecipe FIELD field_9051 id Lnet/minecraft/class_2960; - FIELD field_9052 inputs Lnet/minecraft/class_2371; + FIELD field_9052 input Lnet/minecraft/class_2371; FIELD field_9053 output Lnet/minecraft/class_1799; FIELD field_9054 height I FIELD field_9055 width I @@ -10,7 +10,7 @@ CLASS net/minecraft/class_1869 net/minecraft/recipe/ShapedRecipe ARG 2 group ARG 3 width ARG 4 height - ARG 5 ingredients + ARG 5 input ARG 6 output METHOD method_31585 (Lnet/minecraft/class_1856;)Z ARG 0 ingredient @@ -20,25 +20,50 @@ CLASS net/minecraft/class_1869 net/minecraft/recipe/ShapedRecipe ARG 0 json METHOD method_8145 getPattern (Lcom/google/gson/JsonArray;)[Ljava/lang/String; ARG 0 json - METHOD method_8146 combinePattern ([Ljava/lang/String;)[Ljava/lang/String; - ARG 0 lines - METHOD method_8148 getIngredients ([Ljava/lang/String;Ljava/util/Map;II)Lnet/minecraft/class_2371; + METHOD method_8146 removePadding ([Ljava/lang/String;)[Ljava/lang/String; + COMMENT Removes empty space from around the recipe pattern. + COMMENT + COMMENT

Turns patterns such as:

+ COMMENT
+		COMMENT {@code
+		COMMENT "   o"
+		COMMENT "   a"
+		COMMENT "    "
+		COMMENT }
+		COMMENT 
+ COMMENT Into: + COMMENT
+		COMMENT {@code
+		COMMENT "o"
+		COMMENT "a"
+		COMMENT }
+		COMMENT 
+ COMMENT + COMMENT @return a new recipe pattern with all leading and trailing empty rows/columns removed ARG 0 pattern - ARG 1 key + METHOD method_8148 createPatternMatrix ([Ljava/lang/String;Ljava/util/Map;II)Lnet/minecraft/class_2371; + COMMENT Compiles a pattern and series of symbols into a list of ingredients (the matrix) suitable for matching + COMMENT against a crafting grid. + ARG 0 pattern + ARG 1 symbols ARG 2 width ARG 3 height METHOD method_8150 getWidth ()I - METHOD method_8151 findNextIngredient (Ljava/lang/String;)I - ARG 0 pattern - METHOD method_8153 findNextIngredientReverse (Ljava/lang/String;)I + METHOD method_8151 findFirstSymbol (Ljava/lang/String;)I + ARG 0 line + METHOD method_8153 findLastSymbol (Ljava/lang/String;)I ARG 0 pattern METHOD method_8155 getItemStack (Lcom/google/gson/JsonObject;)Lnet/minecraft/class_1792; ARG 0 json - METHOD method_8157 getComponents (Lcom/google/gson/JsonObject;)Ljava/util/Map; + METHOD method_8157 readSymbols (Lcom/google/gson/JsonObject;)Ljava/util/Map; + COMMENT Reads the pattern symbols. + COMMENT + COMMENT @return a mapping from a symbol to the ingredient it represents ARG 0 json METHOD method_8158 getHeight ()I - METHOD method_8161 matchesSmall (Lnet/minecraft/class_1715;IIZ)Z + METHOD method_8161 matchesPattern (Lnet/minecraft/class_1715;IIZ)Z ARG 1 inv ARG 2 offsetX ARG 3 offsetY + ARG 4 flipped CLASS class_1870 Serializer