Skip to content

Commit

Permalink
修复配方中存在的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed Mar 12, 2024
1 parent 46e36d9 commit a54085d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void buildRecipes(Consumer<FinishedRecipe> exporter) {
}

public static void compaction(Block block, @NotNull Block block1, @NotNull Block block2, Consumer<FinishedRecipe> 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()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public static void buildRecipes(Consumer<FinishedRecipe> 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"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -65,12 +66,13 @@ public static void processRecipes(@NotNull MinecraftServer server) {
}

public static @Nullable Pair<ResourceLocation, Recipe<?>> 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),
Expand All @@ -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<Ingredient> ingredients = recipe.getIngredients();
if (isIngredientsSame(ingredients)) {
if (recipe.getHeight() != recipe.getWidth()) return null;
Expand All @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit a54085d

Please sign in to comment.