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;
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import net.minecraft.recipe.RecipeSerializer
|
|||
import net.minecraft.recipe.book.RecipeCategory
|
||||
import net.minecraft.registry.RegistryWrapper
|
||||
import net.minecraft.util.Identifier
|
||||
import reborncore.common.recipes.PaddedShapedRecipeJsonBuilder
|
||||
import techreborn.TechReborn
|
||||
import techreborn.datagen.recipes.TechRebornRecipesProvider
|
||||
import techreborn.init.TRContent
|
||||
|
@ -85,6 +86,7 @@ class CraftingRecipesProvider extends TechRebornRecipesProvider {
|
|||
}
|
||||
generateToolRecipes()
|
||||
generateArmorRecipes()
|
||||
generateUuMatterRecipes()
|
||||
}
|
||||
|
||||
def generateToolRecipes() {
|
||||
|
@ -182,6 +184,62 @@ class CraftingRecipesProvider extends TechRebornRecipesProvider {
|
|||
}
|
||||
}
|
||||
|
||||
def generateUuMatterRecipes() {
|
||||
String rootDir = "crafting_table/uu_matter/"
|
||||
String dir
|
||||
// dusts
|
||||
dir = rootDir + "dust/"
|
||||
createPureUuMatterPaddedRecipe(RecipeCategory.MISC, TRContent.Dusts.ALUMINUM)
|
||||
.pattern("UUU")
|
||||
.pattern("U ")
|
||||
.pattern(" ")
|
||||
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, recipeNameString(dir, null, TRContent.Dusts.ALUMINUM)))
|
||||
createPureUuMatterPaddedRecipe(RecipeCategory.MISC, TRContent.Dusts.CHROME)
|
||||
.pattern("UUU")
|
||||
.pattern("UU ")
|
||||
.pattern(" U ")
|
||||
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, recipeNameString(dir, null, TRContent.Dusts.CHROME)))
|
||||
createPureUuMatterPaddedRecipe(RecipeCategory.MISC, TRContent.Dusts.PLATINUM)
|
||||
.pattern("UUU")
|
||||
.pattern("UU ")
|
||||
.pattern(" ")
|
||||
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, recipeNameString(dir, null, TRContent.Dusts.PLATINUM)))
|
||||
createPureUuMatterPaddedRecipe(RecipeCategory.MISC, TRContent.Dusts.TITANIUM)
|
||||
.pattern("UUU")
|
||||
.pattern("U U")
|
||||
.pattern(" ")
|
||||
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, recipeNameString(dir, null, TRContent.Dusts.TITANIUM)))
|
||||
// nuggets
|
||||
dir = rootDir + "nugget/"
|
||||
createPureUuMatterPaddedRecipe(RecipeCategory.MISC, TRContent.Nuggets.NETHERITE)
|
||||
.pattern("UUU")
|
||||
.pattern("UUU")
|
||||
.pattern("UU ")
|
||||
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, recipeNameString(dir, null, TRContent.Nuggets.NETHERITE)))
|
||||
// raw ores
|
||||
dir = rootDir + "raw/"
|
||||
createPureUuMatterPaddedRecipe(RecipeCategory.MISC, Items.RAW_COPPER)
|
||||
.pattern("U ")
|
||||
.pattern(" ")
|
||||
.pattern(" U ")
|
||||
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, recipeNameString(dir, null, Items.RAW_COPPER)))
|
||||
createPureUuMatterPaddedRecipe(RecipeCategory.MISC, TRContent.RawMetals.LEAD)
|
||||
.pattern(" ")
|
||||
.pattern("U ")
|
||||
.pattern("U ")
|
||||
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, recipeNameString(dir, null, TRContent.RawMetals.LEAD)))
|
||||
createPureUuMatterPaddedRecipe(RecipeCategory.MISC, TRContent.RawMetals.TIN)
|
||||
.pattern(" ")
|
||||
.pattern(" U ")
|
||||
.pattern(" U")
|
||||
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, recipeNameString(dir, null, TRContent.RawMetals.TIN)))
|
||||
createPureUuMatterPaddedRecipe(RecipeCategory.MISC, TRContent.RawMetals.TUNGSTEN)
|
||||
.pattern("UUU")
|
||||
.pattern("UUU")
|
||||
.pattern(" ")
|
||||
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, recipeNameString(dir, null, TRContent.RawMetals.TUNGSTEN)))
|
||||
}
|
||||
|
||||
def static recipeNameString(String prefix, def input, def output, String source = null, String result = null) {
|
||||
StringBuilder s = new StringBuilder()
|
||||
s.append(prefix)
|
||||
|
@ -344,5 +402,11 @@ class CraftingRecipesProvider extends TechRebornRecipesProvider {
|
|||
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, materialTypeString(prefix, material, type, TechRebornRecipesProvider::getNamePart1)))
|
||||
}
|
||||
|
||||
def static createPureUuMatterPaddedRecipe(RecipeCategory category, ItemConvertible output) {
|
||||
var input = TRContent.Parts.UU_MATTER
|
||||
return PaddedShapedRecipeJsonBuilder.create(category, output, 1)
|
||||
.input('U' as char, createIngredient(input))
|
||||
.criterion(getCriterionName(input), getCriterionConditions(input))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"type": "reborncore:padded",
|
||||
"pattern": [
|
||||
"UUU",
|
||||
"U ",
|
||||
" "
|
||||
],
|
||||
"key": {
|
||||
"U": {
|
||||
"item": "techreborn:uu_matter"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "techreborn:aluminum_dust"
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"type": "reborncore:padded",
|
||||
"pattern": [
|
||||
"UUU",
|
||||
"UU ",
|
||||
" U "
|
||||
],
|
||||
"key": {
|
||||
"U": {
|
||||
"item": "techreborn:uu_matter"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "techreborn:chrome_dust"
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"type": "reborncore:padded",
|
||||
"pattern": [
|
||||
"UUU",
|
||||
"UU ",
|
||||
" "
|
||||
],
|
||||
"key": {
|
||||
"U": {
|
||||
"item": "techreborn:uu_matter"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "techreborn:platinum_dust"
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"type": "reborncore:padded",
|
||||
"pattern": [
|
||||
"UUU",
|
||||
"U U",
|
||||
" "
|
||||
],
|
||||
"key": {
|
||||
"U": {
|
||||
"item": "techreborn:uu_matter"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "techreborn:titanium_dust"
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"type": "reborncore:padded",
|
||||
"pattern": [
|
||||
"UUU",
|
||||
"UUU",
|
||||
"UU "
|
||||
],
|
||||
"key": {
|
||||
"U": {
|
||||
"item": "techreborn:uu_matter"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "techreborn:netherite_nugget"
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"type": "reborncore:padded",
|
||||
"pattern": [
|
||||
"U ",
|
||||
" ",
|
||||
" U "
|
||||
],
|
||||
"key": {
|
||||
"U": {
|
||||
"item": "techreborn:uu_matter"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "minecraft:raw_copper"
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"type": "reborncore:padded",
|
||||
"pattern": [
|
||||
" ",
|
||||
"U ",
|
||||
"U "
|
||||
],
|
||||
"key": {
|
||||
"U": {
|
||||
"item": "techreborn:uu_matter"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "techreborn:raw_lead"
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"type": "reborncore:padded",
|
||||
"pattern": [
|
||||
" ",
|
||||
" U ",
|
||||
" U"
|
||||
],
|
||||
"key": {
|
||||
"U": {
|
||||
"item": "techreborn:uu_matter"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "techreborn:raw_tin"
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"type": "reborncore:padded",
|
||||
"pattern": [
|
||||
"UUU",
|
||||
"UUU",
|
||||
" "
|
||||
],
|
||||
"key": {
|
||||
"U": {
|
||||
"item": "techreborn:uu_matter"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "techreborn:raw_tungsten"
|
||||
}
|
||||
}
|
|
@ -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…
Reference in a new issue