|
4 | 4 | import dev.dubhe.anvilcraft.init.ModBlockTags;
|
5 | 5 | import dev.dubhe.anvilcraft.init.ModBlocks;
|
6 | 6 | import dev.dubhe.anvilcraft.init.ModRecipeTypes;
|
| 7 | +import dev.dubhe.anvilcraft.recipe.anvil.BlockCrushRecipe; |
7 | 8 | import dev.dubhe.anvilcraft.recipe.multiblock.MultiblockInput;
|
8 | 9 | import dev.dubhe.anvilcraft.util.AnvilUtil;
|
9 | 10 |
|
@@ -158,26 +159,18 @@ public class GiantAnvilLandingEventListener {
|
158 | 159 | processChorus(pos, state, level);
|
159 | 160 | }
|
160 | 161 | }));
|
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 | + ); |
181 | 174 | }
|
182 | 175 |
|
183 | 176 | private static void processChorus(BlockPos pos, BlockState state, Level level) {
|
|
0 commit comments