From 9c42db3436d45bc54200249416c74903135ab32f Mon Sep 17 00:00:00 2001 From: Gugle Date: Tue, 26 Mar 2024 19:35:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=82=E5=B8=B8=E7=9A=84?= =?UTF-8?q?=E7=89=A9=E5=93=81=E5=8E=8B=E7=BC=A9/=E7=B2=89=E7=A2=8E?= =?UTF-8?q?=E9=85=8D=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recipe/SmashRecipesGenerator.java | 20 ++++++++++++++++++- .../recipe/StampingRecipesGenerator.java | 1 - .../anvil/predicate/HasItemIngredient.java | 7 +++++++ .../anvilcraft/event/ServerEventListener.java | 3 ++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/SmashRecipesGenerator.java b/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/SmashRecipesGenerator.java index 87620093e..e719d1b9e 100644 --- a/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/SmashRecipesGenerator.java +++ b/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/SmashRecipesGenerator.java @@ -11,6 +11,7 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; import java.util.function.Consumer; @@ -25,13 +26,30 @@ public static void buildRecipes(Consumer exporter) { smash(Items.NETHER_STAR, ModItems.NETHER_STAR_SHARD, 4, exporter); smash(ModItems.HOLLOW_MAGNET_BLOCK, ModItems.MAGNET_INGOT, 8, exporter); smash(ModItems.MAGNET_BLOCK, ModItems.MAGNET_INGOT, 9, exporter); + smash(Items.MELON, Items.MELON_SLICE, 9, exporter); + smash(Items.SNOW_BLOCK, Items.SNOWBALL, 4, exporter); + smash(Items.CLAY, Items.CLAY_BALL, 4, exporter); + smash(Items.PRISMARINE, Items.PRISMARINE_SHARD, 4, exporter); + smash(Items.PRISMARINE_BRICKS, Items.PRISMARINE, 9, exporter); + smash(Items.GLOWSTONE, Items.GLOWSTONE_DUST, 4, exporter); + smash(Items.QUARTZ_BLOCK, Items.QUARTZ, 4, exporter); + smash(Items.DRIPSTONE_BLOCK, Items.POINTED_DRIPSTONE, 4, exporter); + smash(Items.AMETHYST_BLOCK, Items.AMETHYST_SHARD, 4, exporter); + smash(Items.HONEYCOMB_BLOCK, Items.HONEYCOMB, 4, exporter); + AnvilRecipe.Builder.create(RecipeCategory.MISC) + .hasBlock(Blocks.IRON_TRAPDOOR) + .hasItemIngredient(Items.HONEY_BLOCK) + .hasItemIngredient(Items.GLASS_BOTTLE) + .spawnItem(new Vec3(0.0, -1.0, 0.0), Items.HONEY_BOTTLE, 4) + .unlockedBy(MyRecipesGenerator.hasItem(Items.HONEY_BLOCK), FabricRecipeProvider.has(Items.HONEY_BLOCK)) + .save(exporter, AnvilCraft.of("smash/" + BuiltInRegistries.ITEM.getKey(Items.HONEY_BLOCK).getPath() + "_2_" + BuiltInRegistries.ITEM.getKey(Items.HONEY_BOTTLE).getPath())); } public static void smash(Item item, @NotNull Item item1, int count, Consumer exporter) { AnvilRecipe.Builder.create(RecipeCategory.MISC) .hasBlock(Blocks.IRON_TRAPDOOR) .hasItemIngredient(item) - .spawnItem(item1, count) + .spawnItem(new Vec3(0.0, -1.0, 0.0), item1, count) .unlockedBy(MyRecipesGenerator.hasItem(item), FabricRecipeProvider.has(item)) .save(exporter, AnvilCraft.of("smash/" + BuiltInRegistries.ITEM.getKey(item).getPath() + "_2_" + BuiltInRegistries.ITEM.getKey(item1).getPath())); } diff --git a/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/StampingRecipesGenerator.java b/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/StampingRecipesGenerator.java index d6b25f124..e3df7f5c8 100644 --- a/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/StampingRecipesGenerator.java +++ b/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/StampingRecipesGenerator.java @@ -37,7 +37,6 @@ public static void buildRecipes(Consumer exporter) { .hasBlock(Blocks.PISTON.defaultBlockState().setValue(PistonBaseBlock.FACING, Direction.UP)) .hasItemIngredient(Items.MILK_BUCKET) .spawnItem(ModItems.CREAM) - .spawnItem(Items.BUCKET) .unlockedBy(MyRecipesGenerator.hasItem(Items.MILK_BUCKET), FabricRecipeProvider.has(Items.MILK_BUCKET)) .save(exporter, AnvilCraft.of("stamping/cream")); AnvilRecipe.Builder.create(RecipeCategory.MISC) diff --git a/src/main/java/dev/dubhe/anvilcraft/data/recipe/anvil/predicate/HasItemIngredient.java b/src/main/java/dev/dubhe/anvilcraft/data/recipe/anvil/predicate/HasItemIngredient.java index 754e33535..1f717624b 100644 --- a/src/main/java/dev/dubhe/anvilcraft/data/recipe/anvil/predicate/HasItemIngredient.java +++ b/src/main/java/dev/dubhe/anvilcraft/data/recipe/anvil/predicate/HasItemIngredient.java @@ -67,6 +67,13 @@ public boolean process(@NotNull AnvilCraftingContainer container) { ItemStack item = entity.getItem(); if (this.matchItem.matches(item)) { int count = this.matchItem.count.getMin() != null ? this.matchItem.count.getMin() : 1; + if (item.getItem().hasCraftingRemainingItem()) { + assert item.getItem().getCraftingRemainingItem() != null; + ItemStack stack = new ItemStack(item.getItem().getCraftingRemainingItem(), count); + Vec3 vec3 = pos.getCenter().add(this.offset); + ItemEntity itemEntity = new ItemEntity(level, vec3.x, vec3.y, vec3.z, stack, 0.0, 0.0, 0.0); + level.addFreshEntity(itemEntity); + } item.shrink(count); entity.setItem(item.copy()); return true; diff --git a/src/main/java/dev/dubhe/anvilcraft/event/ServerEventListener.java b/src/main/java/dev/dubhe/anvilcraft/event/ServerEventListener.java index 4a1d1fb6c..a63407d6b 100644 --- a/src/main/java/dev/dubhe/anvilcraft/event/ServerEventListener.java +++ b/src/main/java/dev/dubhe/anvilcraft/event/ServerEventListener.java @@ -73,6 +73,7 @@ public static void processRecipes(@NotNull MinecraftServer server) { public static @Nullable Pair> processRecipes(ResourceLocation id, @NotNull Recipe oldRecipe) { ItemStack result = oldRecipe.getResultItem(new RegistryAccess.ImmutableRegistryAccess(List.of())); if (result.is(Items.IRON_TRAPDOOR)) return null; + if (result.is(Items.PRISMARINE)) return null; ResourceLocation location = AnvilCraft.of("compress/" + id.getPath()); if (oldRecipe instanceof ShapelessRecipe recipe) { if (recipe.getIngredients().size() == 1) { @@ -115,7 +116,7 @@ private static Pair> getResourceLocationRecipePair(I public static boolean isIngredientsSame(@NotNull List ingredients) { Ingredient ingredient = ingredients.get(0); for (Ingredient ingredient1 : ingredients) { - if (ingredient1.equals(ingredient)) continue; + if (ingredient1.toJson().equals(ingredient.toJson())) continue; return false; } return true;