forked from LeavesMC/Leaves
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48e7fd2
commit d5dfe0d
Showing
2 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: violetc <[email protected]> | ||
Date: Tue, 27 Jun 2023 14:07:00 +0800 | ||
Subject: [PATCH] Shave snow layers | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/world/item/ShovelItem.java b/src/main/java/net/minecraft/world/item/ShovelItem.java | ||
index c7195f2e12bbd6545f7bffcc2b4ba5cc3d48df20..b8e160b78a9a6d4f73c9becef6ec0b17858b271f 100644 | ||
--- a/src/main/java/net/minecraft/world/item/ShovelItem.java | ||
+++ b/src/main/java/net/minecraft/world/item/ShovelItem.java | ||
@@ -11,10 +11,12 @@ import net.minecraft.tags.BlockTags; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.context.UseOnContext; | ||
+import net.minecraft.world.item.enchantment.EnchantmentHelper; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.minecraft.world.level.block.CampfireBlock; | ||
+import net.minecraft.world.level.block.SnowLayerBlock; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.gameevent.GameEvent; | ||
|
||
@@ -34,6 +36,22 @@ public class ShovelItem extends DiggerItem { | ||
return InteractionResult.PASS; | ||
} else { | ||
Player player = context.getPlayer(); | ||
+ // Leaves start - shaveSnowLayers | ||
+ if (top.leavesmc.leaves.LeavesConfig.shaveSnowLayers && blockState.is(Blocks.SNOW)) { | ||
+ int layers = blockState.getValue(SnowLayerBlock.LAYERS); | ||
+ level.setBlock(blockPos, layers > 1 ? blockState.setValue(SnowLayerBlock.LAYERS, layers - 1) : Blocks.AIR.defaultBlockState(), 11); | ||
+ Block.popResource(level, blockPos, new ItemStack(EnchantmentHelper.hasSilkTouch(context.getItemInHand()) ? Items.SNOW : Items.SNOWBALL)); | ||
+ level.playSound(player, blockPos, SoundEvents.SNOW_BREAK, SoundSource.BLOCKS, 1.0F, 1.0F); | ||
+ | ||
+ if(player != null) { | ||
+ context.getItemInHand().hurtAndBreak(1, player, (p) -> { | ||
+ p.broadcastBreakEvent(context.getHand()); | ||
+ }); | ||
+ } | ||
+ | ||
+ return InteractionResult.SUCCESS; | ||
+ } | ||
+ // Leaves end - shaveSnowLayers | ||
BlockState blockState2 = FLATTENABLES.get(blockState.getBlock()); | ||
BlockState blockState3 = null; | ||
Runnable afterAction = null; // Paper |