From a54085d1dcd4bd4432488c74a6310cec830b5d64 Mon Sep 17 00:00:00 2001 From: Gugle Date: Tue, 12 Mar 2024 18:39:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=85=8D=E6=96=B9=E4=B8=AD?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/generator/recipe/CompactionRecipesGenerator.java | 2 +- .../data/generator/recipe/SqueezeRecipesGenerator.java | 4 ++-- .../dev/dubhe/anvilcraft/event/ServerEventListener.java | 8 ++++---- .../anvilcraft/mixin/event/FallingBlockEntityMixin.java | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/CompactionRecipesGenerator.java b/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/CompactionRecipesGenerator.java index af48475ac..feb85a942 100644 --- a/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/CompactionRecipesGenerator.java +++ b/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/CompactionRecipesGenerator.java @@ -28,7 +28,7 @@ public static void buildRecipes(Consumer exporter) { } public static void compaction(Block block, @NotNull Block block1, @NotNull Block block2, Consumer exporter) { - BlockAnvilRecipeBuilder.block(RecipeCategory.MISC, block2.defaultBlockState()) + BlockAnvilRecipeBuilder.block(RecipeCategory.MISC, Blocks.AIR.defaultBlockState(), block2.defaultBlockState()) .component(block) .component(block1) .unlockedBy(MyRecipesGenerator.hasItem(block.asItem()), FabricRecipeProvider.has(block.asItem())) diff --git a/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/SqueezeRecipesGenerator.java b/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/SqueezeRecipesGenerator.java index 6f3478636..9acc1aec9 100644 --- a/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/SqueezeRecipesGenerator.java +++ b/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/SqueezeRecipesGenerator.java @@ -26,12 +26,12 @@ public static void buildRecipes(Consumer exporter) { .save(exporter, AnvilCraft.of("squeeze/magma_block_lava_cauldron_1")); BlockAnvilRecipeBuilder.block(RecipeCategory.MISC, Blocks.NETHERRACK.defaultBlockState(), ModBlocks.LAVA_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 2)) .component(Blocks.MAGMA_BLOCK) - .component(Component.of(Component.Value.of(Blocks.LAVA_CAULDRON).with("level", 1))) + .component(Component.of(Component.Value.of(ModBlocks.LAVA_CAULDRON).with("level", 1))) .unlockedBy(MyRecipesGenerator.hasItem(Items.WET_SPONGE), FabricRecipeProvider.has(Items.WET_SPONGE)) .save(exporter, AnvilCraft.of("squeeze/magma_block_lava_cauldron_2")); BlockAnvilRecipeBuilder.block(RecipeCategory.MISC, Blocks.NETHERRACK.defaultBlockState(), Blocks.LAVA_CAULDRON.defaultBlockState()) .component(Blocks.MAGMA_BLOCK) - .component(Component.of(Component.Value.of(Blocks.LAVA_CAULDRON).with("level", 2))) + .component(Component.of(Component.Value.of(ModBlocks.LAVA_CAULDRON).with("level", 2))) .unlockedBy(MyRecipesGenerator.hasItem(Items.WET_SPONGE), FabricRecipeProvider.has(Items.WET_SPONGE)) .save(exporter, AnvilCraft.of("squeeze/magma_block_lava_cauldron_3")); diff --git a/src/main/java/dev/dubhe/anvilcraft/event/ServerEventListener.java b/src/main/java/dev/dubhe/anvilcraft/event/ServerEventListener.java index 289a22ea9..c2e7a840f 100644 --- a/src/main/java/dev/dubhe/anvilcraft/event/ServerEventListener.java +++ b/src/main/java/dev/dubhe/anvilcraft/event/ServerEventListener.java @@ -14,6 +14,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.*; import net.minecraft.world.level.block.Blocks; import org.jetbrains.annotations.NotNull; @@ -65,12 +66,13 @@ 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 (oldRecipe instanceof ShapelessRecipe recipe) { if (recipe.getIngredients().size() == 1) { ResourceLocation location = AnvilCraft.of("smash/" + id.getPath()); Ingredient ingredient = recipe.getIngredients().get(0); TagIngredient ingredient1 = TagIngredient.of(ingredient); - ItemStack result = recipe.getResultItem(new RegistryAccess.ImmutableRegistryAccess(List.of())); ItemAnvilRecipe recipe1 = new ItemAnvilRecipe( location, NonNullList.withSize(1, ingredient1), @@ -82,8 +84,7 @@ public static void processRecipes(@NotNull MinecraftServer server) { ); return new Pair<>(location, recipe1); } - } - if (oldRecipe instanceof ShapedRecipe recipe) { + } else if (oldRecipe instanceof ShapedRecipe recipe) { List ingredients = recipe.getIngredients(); if (isIngredientsSame(ingredients)) { if (recipe.getHeight() != recipe.getWidth()) return null; @@ -92,7 +93,6 @@ public static void processRecipes(@NotNull MinecraftServer server) { Ingredient ingredient = recipe.getIngredients().get(0); TagIngredient ingredient1 = TagIngredient.of(ingredient); int ingredientCount = recipe.getIngredients().size(); - ItemStack result = recipe.getResultItem(new RegistryAccess.ImmutableRegistryAccess(List.of())); ItemAnvilRecipe recipe1 = new ItemAnvilRecipe( location, NonNullList.withSize(ingredientCount, ingredient1), diff --git a/src/main/java/dev/dubhe/anvilcraft/mixin/event/FallingBlockEntityMixin.java b/src/main/java/dev/dubhe/anvilcraft/mixin/event/FallingBlockEntityMixin.java index e9a37e6e4..6693dc3f0 100644 --- a/src/main/java/dev/dubhe/anvilcraft/mixin/event/FallingBlockEntityMixin.java +++ b/src/main/java/dev/dubhe/anvilcraft/mixin/event/FallingBlockEntityMixin.java @@ -30,15 +30,15 @@ public abstract class FallingBlockEntityMixin { @Unique private final FallingBlockEntity ths = (FallingBlockEntity) (Object) this; - @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD) - private void anvilFallOnGround(CallbackInfo ci, Block block, BlockPos blockPos, boolean bl, boolean bl2, double d) { + @Inject(method = "tick", at = @At(value = "INVOKE", ordinal = 10, target = "Lnet/minecraft/world/entity/item/FallingBlockEntity;level()Lnet/minecraft/world/level/Level;"), locals = LocalCapture.CAPTURE_FAILHARD) + private void anvilFallOnGround(CallbackInfo ci, Block block, BlockPos blockPos) { if (ths.level().isClientSide()) return; if (!this.blockState.is(BlockTags.ANVIL)) return; AnvilFallOnLandEvent event = new AnvilFallOnLandEvent(ths.level(), blockPos, ths); AnvilCraft.EVENT_BUS.post(event); if (event.isAnvilDamage()) { BlockState state = AnvilBlock.damage(this.blockState); - if (state != null) this.blockState = state; + if (state != null) ths.level().setBlock(blockPos, state, 3); else this.cancelDrop = true; } }