From 9110d55396fee2c9a4e583adc3b8f7cca7bf9dda Mon Sep 17 00:00:00 2001 From: Gugle Date: Sun, 28 Apr 2024 12:19:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BB=A3=E7=A0=81=E9=A3=8E?= =?UTF-8?q?=E6=A0=BC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recipe/SmithingRecipesLoader.java | 40 +++++++++++-------- .../transform/FinishedMobTransformRecipe.java | 3 ++ .../transform/MobTransformContainer.java | 3 ++ .../recipe/transform/MobTransformRecipe.java | 12 ++++++ .../kubejs/recipe/AnvilCraftRecipeSchema.java | 5 ++- .../recipe/builder/SelectOneBuilder.java | 3 ++ .../AnvilCraftRecipeComponents.java | 4 +- .../item/RoyalUpgradeTemplateItem.java | 3 ++ 8 files changed, 54 insertions(+), 19 deletions(-) diff --git a/common/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/SmithingRecipesLoader.java b/common/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/SmithingRecipesLoader.java index d76146f2d..f7521f829 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/SmithingRecipesLoader.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/SmithingRecipesLoader.java @@ -10,23 +10,31 @@ import net.minecraft.world.item.crafting.Ingredient; public class SmithingRecipesLoader { + /** + * 初始化 + * + * @param provider 提供器 + */ public static void init(RegistrateRecipeProvider provider) { SmithingTransformRecipeBuilder - .smithing( - Ingredient.of(ModItems.ROYAL_STEEL_UPGRADE_SMITHING_TEMPLATE), - Ingredient.of(ModItems.ANVIL_HAMMER), - Ingredient.of(ModBlocks.ROYAL_STEEL_BLOCK), - RecipeCategory.TOOLS, - ModItems.ROYAL_ANVIL_HAMMER.asItem() - ).unlocks( - AnvilCraftDatagen.hasItem(ModItems.ANVIL_HAMMER), - AnvilCraftDatagen.has(ModItems.ANVIL_HAMMER) - ).unlocks( - AnvilCraftDatagen.hasItem(ModItems.ROYAL_STEEL_UPGRADE_SMITHING_TEMPLATE), - AnvilCraftDatagen.has(ModItems.ROYAL_STEEL_UPGRADE_SMITHING_TEMPLATE) - ).save( - provider, - new ResourceLocation("anvilcraft", "anvil_hammer_upgrade") - ); + .smithing( + Ingredient.of(ModItems.ROYAL_STEEL_UPGRADE_SMITHING_TEMPLATE), + Ingredient.of(ModItems.ANVIL_HAMMER), + Ingredient.of(ModBlocks.ROYAL_STEEL_BLOCK), + RecipeCategory.TOOLS, + ModItems.ROYAL_ANVIL_HAMMER.asItem() + ) + .unlocks( + AnvilCraftDatagen.hasItem(ModItems.ANVIL_HAMMER), + AnvilCraftDatagen.has(ModItems.ANVIL_HAMMER) + ) + .unlocks( + AnvilCraftDatagen.hasItem(ModItems.ROYAL_STEEL_UPGRADE_SMITHING_TEMPLATE), + AnvilCraftDatagen.has(ModItems.ROYAL_STEEL_UPGRADE_SMITHING_TEMPLATE) + ) + .save( + provider, + new ResourceLocation("anvilcraft", "anvil_hammer_upgrade") + ); } } diff --git a/common/src/main/java/dev/dubhe/anvilcraft/data/recipe/transform/FinishedMobTransformRecipe.java b/common/src/main/java/dev/dubhe/anvilcraft/data/recipe/transform/FinishedMobTransformRecipe.java index ddebb39c2..a662b5026 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/data/recipe/transform/FinishedMobTransformRecipe.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/data/recipe/transform/FinishedMobTransformRecipe.java @@ -16,6 +16,9 @@ public class FinishedMobTransformRecipe implements FinishedRecipe { private final Advancement.Builder advancement; private final ResourceLocation advancementId; + /** + * 生物转化配方 + */ public FinishedMobTransformRecipe( MobTransformRecipe recipe, Advancement.Builder advancement, diff --git a/common/src/main/java/dev/dubhe/anvilcraft/data/recipe/transform/MobTransformContainer.java b/common/src/main/java/dev/dubhe/anvilcraft/data/recipe/transform/MobTransformContainer.java index 7786b66b1..fb0efc92b 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/data/recipe/transform/MobTransformContainer.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/data/recipe/transform/MobTransformContainer.java @@ -17,6 +17,9 @@ public class MobTransformContainer implements Container { private final Entity entity; private final RandomSource random; + /** + * 生物转化容器 + */ public MobTransformContainer(Level level, BlockPos pos, Entity entity) { this.level = level; this.random = this.level.getRandom(); diff --git a/common/src/main/java/dev/dubhe/anvilcraft/data/recipe/transform/MobTransformRecipe.java b/common/src/main/java/dev/dubhe/anvilcraft/data/recipe/transform/MobTransformRecipe.java index 2930b2ee1..cf7339421 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/data/recipe/transform/MobTransformRecipe.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/data/recipe/transform/MobTransformRecipe.java @@ -49,6 +49,9 @@ public class MobTransformRecipe implements Recipe { private List results; private final ItemStack iconSrc; + /** + * 生物转化配方 + */ public MobTransformRecipe( ResourceLocation id, ItemStack iconSrc, @@ -79,6 +82,9 @@ public boolean matches(@NotNull MobTransformContainer container, @NotNull Level return ItemStack.EMPTY; } + /** + * 结果 + */ public EntityType result(RandomSource randomSource) { if (results.size() == 1) return results.get(0).resultEntityType(); List sorted = new ArrayList<>(results.stream() @@ -207,6 +213,9 @@ public Builder icon(ItemStack iconSrc) { return this; } + /** + * 构造 + */ public MobTransformRecipe build() { MobTransformRecipe r = new MobTransformRecipe(id, iconSrc); r.inputEntityType = inputEntityType; @@ -214,6 +223,9 @@ public MobTransformRecipe build() { return r; } + /** + * 完成 + */ public FinishedMobTransformRecipe finish() { this.advancement .parent(ROOT_RECIPE_ADVANCEMENT) diff --git a/common/src/main/java/dev/dubhe/anvilcraft/integration/kubejs/recipe/AnvilCraftRecipeSchema.java b/common/src/main/java/dev/dubhe/anvilcraft/integration/kubejs/recipe/AnvilCraftRecipeSchema.java index ffeafdc5f..bd15a199a 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/integration/kubejs/recipe/AnvilCraftRecipeSchema.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/integration/kubejs/recipe/AnvilCraftRecipeSchema.java @@ -559,6 +559,7 @@ public AnvilCraftRecipeJs icon(OutputItem outputItem) { RecipeKey ICON = ItemComponents.OUTPUT.key("icon").optional(OutputItem.of(ModItems.ROYAL_STEEL_NUGGET)); - RecipeSchema SCHEMA = new RecipeSchema(AnvilCraftRecipeJs.class, AnvilCraftRecipeJs::new, OUTCOMES, PREDICATES, ICON) - .constructor(((recipe, schemaType, keys, from) -> recipe.id(from.getValue(recipe, ID))), ID); + RecipeSchema SCHEMA = new RecipeSchema( + AnvilCraftRecipeJs.class, AnvilCraftRecipeJs::new, OUTCOMES, PREDICATES, ICON + ).constructor(((recipe, schemaType, keys, from) -> recipe.id(from.getValue(recipe, ID))), ID); } diff --git a/common/src/main/java/dev/dubhe/anvilcraft/integration/kubejs/recipe/builder/SelectOneBuilder.java b/common/src/main/java/dev/dubhe/anvilcraft/integration/kubejs/recipe/builder/SelectOneBuilder.java index 3a54b0daa..4d85314d1 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/integration/kubejs/recipe/builder/SelectOneBuilder.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/integration/kubejs/recipe/builder/SelectOneBuilder.java @@ -162,6 +162,9 @@ public SelectOneBuilder spawnItem(Vec3 offset, double chance, ItemStack result) return addOutcome(spawnItem); } + /** + * KubeJS + */ public SelectOne build() { SelectOne selectOne = new SelectOne(); outcomes.forEach(selectOne::add); diff --git a/common/src/main/java/dev/dubhe/anvilcraft/integration/kubejs/recipe/components/AnvilCraftRecipeComponents.java b/common/src/main/java/dev/dubhe/anvilcraft/integration/kubejs/recipe/components/AnvilCraftRecipeComponents.java index 442b4c041..bcb6172af 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/integration/kubejs/recipe/components/AnvilCraftRecipeComponents.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/integration/kubejs/recipe/components/AnvilCraftRecipeComponents.java @@ -35,7 +35,9 @@ public JsonElement write(RecipeJS recipe, ResourceLocation value) { @Override public ResourceLocation read(RecipeJS recipe, Object from) { - return from instanceof CharSequence c ? ResourceLocation.tryParse(c.toString()) : ResourceLocation.tryParse(String.valueOf(from)); + return from instanceof CharSequence c + ? ResourceLocation.tryParse(c.toString()) + : ResourceLocation.tryParse(String.valueOf(from)); } @Override diff --git a/common/src/main/java/dev/dubhe/anvilcraft/item/RoyalUpgradeTemplateItem.java b/common/src/main/java/dev/dubhe/anvilcraft/item/RoyalUpgradeTemplateItem.java index 416579592..840d7510c 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/item/RoyalUpgradeTemplateItem.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/item/RoyalUpgradeTemplateItem.java @@ -36,6 +36,9 @@ public class RoyalUpgradeTemplateItem extends SmithingTemplateItem { "item/empty_slot_block" ); + /** + * @param properties 物品属性 + */ public RoyalUpgradeTemplateItem(@SuppressWarnings("unused") Properties properties) { super(APPLIES_TO, UPGRADE_INGREDIENTS,