Skip to content

Commit deed66e

Browse files
committed
Shave snow layers (#29)
1 parent cfc314c commit deed66e

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

patches/server/0004-Leaves-Server-Config-And-Command.patch

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ index a53514f2c510b29f596c361de7bc0b405c27e964..269c7ba0707db4fdc45a70000e0be892
128128
.withRequiredArg()
129129
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
130130
new file mode 100644
131-
index 0000000000000000000000000000000000000000..f901ec32a948fa9705dc53389a279bd466a02fa3
131+
index 0000000000000000000000000000000000000000..4d8063f34c91ec4fe5a926f9d46555ce0d5bd8d9
132132
--- /dev/null
133133
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
134-
@@ -0,0 +1,762 @@
134+
@@ -0,0 +1,767 @@
135135
+package top.leavesmc.leaves;
136136
+
137137
+import com.destroystokyo.paper.util.SneakyThrow;
@@ -719,6 +719,11 @@ index 0000000000000000000000000000000000000000..f901ec32a948fa9705dc53389a279bd4
719719
+ mendingCompatibilityInfinity = getBoolean("settings.modify.mending-compatibility-infinity", mendingCompatibilityInfinity);
720720
+ }
721721
+
722+
+ public static boolean shaveSnowLayers = true;
723+
+ private static void shaveSnowLayers() {
724+
+ shaveSnowLayers = getBoolean("settings.modify.shave-snow-layers", shaveSnowLayers);
725+
+ }
726+
+
722727
+ public static final class WorldConfig {
723728
+
724729
+ public final String worldName;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: violetc <[email protected]>
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

Comments
 (0)