added uu matter recipe provider hook and some examples (#3072)
* added uu matter recipe provider hook and some examples * added uu matter recipe provider hook and some examples * fix formatting Co-authored-by: modmuss50 <modmuss50@gmail.com>
This commit is contained in:
parent
39f2fa9229
commit
ac7f8c8496
13 changed files with 165 additions and 146 deletions
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* This file is part of RebornCore, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2022 TeamReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package reborncore.common.recipes;
|
||||
|
||||
import net.minecraft.advancement.Advancement;
|
||||
import net.minecraft.advancement.CriterionMerger;
|
||||
import net.minecraft.advancement.criterion.RecipeUnlockedCriterion;
|
||||
import net.minecraft.data.server.recipe.RecipeJsonProvider;
|
||||
import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.recipe.book.CraftingRecipeCategory;
|
||||
import net.minecraft.recipe.book.RecipeCategory;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class PaddedShapedRecipeJsonBuilder extends ShapedRecipeJsonBuilder {
|
||||
|
||||
public PaddedShapedRecipeJsonBuilder(RecipeCategory category, ItemConvertible output, int outputCount) {
|
||||
super(category, output, outputCount);
|
||||
}
|
||||
|
||||
public static PaddedShapedRecipeJsonBuilder create(RecipeCategory category, ItemConvertible output) {
|
||||
return create(category, output, 1);
|
||||
}
|
||||
|
||||
public static PaddedShapedRecipeJsonBuilder create(RecipeCategory category, ItemConvertible output, int outputCount) {
|
||||
return new PaddedShapedRecipeJsonBuilder(category, output, outputCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void offerTo(Consumer<RecipeJsonProvider> exporter, Identifier recipeId) {
|
||||
validate(recipeId);
|
||||
advancementBuilder.parent(ROOT).criterion("has_the_recipe", RecipeUnlockedCriterion.create(recipeId)).rewards(net.minecraft.advancement.AdvancementRewards.Builder.recipe(recipeId)).criteriaMerger(CriterionMerger.OR);
|
||||
String group = this.group == null ? "" : this.group;
|
||||
exporter.accept(new PaddedShapedRecipeJsonProvider(recipeId, output, count, group, getCraftingCategory(category), pattern, inputs, advancementBuilder,
|
||||
new Identifier(recipeId.getNamespace(), "recipes/" + category.getName() + "/" + recipeId.getPath())));
|
||||
}
|
||||
|
||||
static class PaddedShapedRecipeJsonProvider extends PaddedShapedRecipeJsonBuilder.ShapedRecipeJsonProvider {
|
||||
|
||||
public PaddedShapedRecipeJsonProvider(Identifier recipeId, Item output, int resultCount, String group, CraftingRecipeCategory category, List<String> pattern, Map<Character, Ingredient> inputs, Advancement.Builder advancementBuilder, Identifier advancementId) {
|
||||
super(recipeId, output, resultCount, group, category, pattern, inputs, advancementBuilder, advancementId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return PaddedShapedRecipe.PADDED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,17 @@ accessWidener v2 named
|
|||
accessible method net/minecraft/recipe/ShapedRecipe readSymbols (Lcom/google/gson/JsonObject;)Ljava/util/Map;
|
||||
accessible method net/minecraft/recipe/ShapedRecipe getPattern (Lcom/google/gson/JsonArray;)[Ljava/lang/String;
|
||||
accessible method net/minecraft/recipe/ShapedRecipe createPatternMatrix ([Ljava/lang/String;Ljava/util/Map;II)Lnet/minecraft/util/collection/DefaultedList;
|
||||
accessible method net/minecraft/recipe/ShapedRecipe matchesPattern (Lnet/minecraft/inventory/CraftingInventory;IIZ)Z
|
||||
|
||||
accessible class net/minecraft/data/server/recipe/ShapedRecipeJsonBuilder$ShapedRecipeJsonProvider
|
||||
accessible method net/minecraft/data/server/recipe/ShapedRecipeJsonBuilder validate (Lnet/minecraft/util/Identifier;)V
|
||||
accessible field net/minecraft/data/server/recipe/ShapedRecipeJsonBuilder advancementBuilder Lnet/minecraft/advancement/Advancement$Builder;
|
||||
accessible field net/minecraft/data/server/recipe/ShapedRecipeJsonBuilder output Lnet/minecraft/item/Item;
|
||||
accessible field net/minecraft/data/server/recipe/ShapedRecipeJsonBuilder count I
|
||||
accessible field net/minecraft/data/server/recipe/ShapedRecipeJsonBuilder group Ljava/lang/String;
|
||||
accessible field net/minecraft/data/server/recipe/ShapedRecipeJsonBuilder pattern Ljava/util/List;
|
||||
accessible field net/minecraft/data/server/recipe/ShapedRecipeJsonBuilder inputs Ljava/util/Map;
|
||||
accessible field net/minecraft/data/server/recipe/ShapedRecipeJsonBuilder category Lnet/minecraft/recipe/book/RecipeCategory;
|
||||
|
||||
accessible class net/minecraft/recipe/Ingredient$Entry
|
||||
accessible class net/minecraft/recipe/Ingredient$TagEntry
|
||||
|
@ -21,7 +32,6 @@ accessible field net/minecraft/block/FluidBlock fluid Lnet/minecraft
|
|||
accessible method net/minecraft/world/gen/foliage/FoliagePlacerType register (Ljava/lang/String;Lcom/mojang/serialization/Codec;)Lnet/minecraft/world/gen/foliage/FoliagePlacerType;
|
||||
accessible method net/minecraft/recipe/RecipeManager getAllOfType (Lnet/minecraft/recipe/RecipeType;)Ljava/util/Map;
|
||||
accessible field net/minecraft/screen/ScreenHandler listeners Ljava/util/List;
|
||||
accessible method net/minecraft/recipe/ShapedRecipe matchesPattern (Lnet/minecraft/inventory/CraftingInventory;IIZ)Z
|
||||
|
||||
accessible field net/minecraft/structure/pool/StructurePool elements Lit/unimi/dsi/fastutil/objects/ObjectArrayList;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue