|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | + |
| 3 | +Date: Tue, 27 Jun 2023 14:07:00 +0800 |
| 4 | +Subject: [PATCH] Shave snow layers |
| 5 | + |
| 6 | + |
| 7 | +diff --git a/src/main/java/net/minecraft/world/item/ShovelItem.java b/src/main/java/net/minecraft/world/item/ShovelItem.java |
| 8 | +index c7195f2e12bbd6545f7bffcc2b4ba5cc3d48df20..b8e160b78a9a6d4f73c9becef6ec0b17858b271f 100644 |
| 9 | +--- a/src/main/java/net/minecraft/world/item/ShovelItem.java |
| 10 | ++++ b/src/main/java/net/minecraft/world/item/ShovelItem.java |
| 11 | +@@ -11,10 +11,12 @@ import net.minecraft.tags.BlockTags; |
| 12 | + import net.minecraft.world.InteractionResult; |
| 13 | + import net.minecraft.world.entity.player.Player; |
| 14 | + import net.minecraft.world.item.context.UseOnContext; |
| 15 | ++import net.minecraft.world.item.enchantment.EnchantmentHelper; |
| 16 | + import net.minecraft.world.level.Level; |
| 17 | + import net.minecraft.world.level.block.Block; |
| 18 | + import net.minecraft.world.level.block.Blocks; |
| 19 | + import net.minecraft.world.level.block.CampfireBlock; |
| 20 | ++import net.minecraft.world.level.block.SnowLayerBlock; |
| 21 | + import net.minecraft.world.level.block.state.BlockState; |
| 22 | + import net.minecraft.world.level.gameevent.GameEvent; |
| 23 | + |
| 24 | +@@ -34,6 +36,22 @@ public class ShovelItem extends DiggerItem { |
| 25 | + return InteractionResult.PASS; |
| 26 | + } else { |
| 27 | + Player player = context.getPlayer(); |
| 28 | ++ // Leaves start - shaveSnowLayers |
| 29 | ++ if (top.leavesmc.leaves.LeavesConfig.shaveSnowLayers && blockState.is(Blocks.SNOW)) { |
| 30 | ++ int layers = blockState.getValue(SnowLayerBlock.LAYERS); |
| 31 | ++ level.setBlock(blockPos, layers > 1 ? blockState.setValue(SnowLayerBlock.LAYERS, layers - 1) : Blocks.AIR.defaultBlockState(), 11); |
| 32 | ++ Block.popResource(level, blockPos, new ItemStack(EnchantmentHelper.hasSilkTouch(context.getItemInHand()) ? Items.SNOW : Items.SNOWBALL)); |
| 33 | ++ level.playSound(player, blockPos, SoundEvents.SNOW_BREAK, SoundSource.BLOCKS, 1.0F, 1.0F); |
| 34 | ++ |
| 35 | ++ if(player != null) { |
| 36 | ++ context.getItemInHand().hurtAndBreak(1, player, (p) -> { |
| 37 | ++ p.broadcastBreakEvent(context.getHand()); |
| 38 | ++ }); |
| 39 | ++ } |
| 40 | ++ |
| 41 | ++ return InteractionResult.SUCCESS; |
| 42 | ++ } |
| 43 | ++ // Leaves end - shaveSnowLayers |
| 44 | + BlockState blockState2 = FLATTENABLES.get(blockState.getBlock()); |
| 45 | + BlockState blockState3 = null; |
| 46 | + Runnable afterAction = null; // Paper |
0 commit comments