Skip to content

Commit e39df7a

Browse files
大铁砧撼地粉碎
1 parent 72d40ed commit e39df7a

File tree

6 files changed

+67
-20
lines changed

6 files changed

+67
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"parent": "minecraft:recipes/root",
3+
"criteria": {
4+
"has_the_recipe": {
5+
"conditions": {
6+
"recipe": "anvilcraft:block_crush/end_dust"
7+
},
8+
"trigger": "minecraft:recipe_unlocked"
9+
}
10+
},
11+
"requirements": [
12+
[
13+
"has_the_recipe"
14+
]
15+
],
16+
"rewards": {
17+
"recipes": [
18+
"anvilcraft:block_crush/end_dust"
19+
]
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"parent": "minecraft:recipes/root",
3+
"criteria": {
4+
"has_the_recipe": {
5+
"conditions": {
6+
"recipe": "anvilcraft:block_crush/nether_dust"
7+
},
8+
"trigger": "minecraft:recipe_unlocked"
9+
}
10+
},
11+
"requirements": [
12+
[
13+
"has_the_recipe"
14+
]
15+
],
16+
"rewards": {
17+
"recipes": [
18+
"anvilcraft:block_crush/nether_dust"
19+
]
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "anvilcraft:block_crush",
3+
"input": "minecraft:end_stone",
4+
"result": "anvilcraft:end_dust"
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "anvilcraft:block_crush",
3+
"input": "minecraft:netherrack",
4+
"result": "anvilcraft:nether_dust"
5+
}

src/main/java/dev/dubhe/anvilcraft/data/recipe/BlockCrushRecipeLoader.java

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public static void init(RegistrateRecipeProvider provider) {
2727
blockCrush(provider, Blocks.DEEPSLATE_TILES, Blocks.CRACKED_DEEPSLATE_TILES);
2828
blockCrush(provider, Blocks.POLISHED_BLACKSTONE_BRICKS, Blocks.CRACKED_POLISHED_BLACKSTONE_BRICKS);
2929
blockCrush(provider, Blocks.SOUL_SOIL, Blocks.SOUL_SAND);
30+
blockCrush(provider, Blocks.NETHERRACK, ModBlocks.NETHER_DUST.get());
31+
blockCrush(provider, Blocks.END_STONE, ModBlocks.END_DUST.get());
3032
}
3133

3234
private static void blockCrush(RegistrateRecipeProvider provider, Block input, Block result) {

src/main/java/dev/dubhe/anvilcraft/event/giantanvil/GiantAnvilLandingEventListener.java

+13-20
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import dev.dubhe.anvilcraft.init.ModBlockTags;
55
import dev.dubhe.anvilcraft.init.ModBlocks;
66
import dev.dubhe.anvilcraft.init.ModRecipeTypes;
7+
import dev.dubhe.anvilcraft.recipe.anvil.BlockCrushRecipe;
78
import dev.dubhe.anvilcraft.recipe.multiblock.MultiblockInput;
89
import dev.dubhe.anvilcraft.util.AnvilUtil;
910

@@ -158,26 +159,18 @@ public class GiantAnvilLandingEventListener {
158159
processChorus(pos, state, level);
159160
}
160161
}));
161-
// behaviorDefs.add(new ShockBehaviorDefinition.SimpleBlock(Blocks.ANVIL,
162-
// (blockPosList, level) -> {
163-
// for (BlockPos pos : blockPosList) {
164-
// BlockPos pos1 = pos.mutable();
165-
// AnvilCraftingContext context = new AnvilCraftingContext(level, pos1, null);
166-
// Optional<AnvilRecipe> optional =
167-
// AnvilRecipeManager.getAnvilRecipeList().stream()
168-
// .filter(recipe ->
169-
// recipe.getAnvilRecipeType() ==
170-
// AnvilRecipeType.BLOCK_SMASH
171-
// && recipe.matches(context, level)
172-
// ).findFirst();
173-
// if (optional.isPresent()) {
174-
// AnvilRecipe recipe = optional.get();
175-
// recipe.craft(context.clearData());
176-
// level.destroyBlock(pos.below(), true);
177-
// }
178-
// }
179-
// })
180-
// );
162+
behaviorDefs.add(new ShockBehaviorDefinition.SimpleBlock(Blocks.ANVIL,
163+
(blockPosList, level) -> {
164+
for (BlockPos pos : blockPosList) {
165+
BlockState state = level.getBlockState(pos);
166+
BlockCrushRecipe.Input input = new BlockCrushRecipe.Input(state.getBlock());
167+
level.getRecipeManager().getRecipeFor(ModRecipeTypes.BLOCK_CRUSH_TYPE.get(), input, level).ifPresent(recipe -> {
168+
level.setBlockAndUpdate(pos, recipe.value().result.defaultBlockState());
169+
level.destroyBlock(pos, true);
170+
});
171+
}
172+
})
173+
);
181174
}
182175

183176
private static void processChorus(BlockPos pos, BlockState state, Level level) {

0 commit comments

Comments
 (0)