Skip to content

Commit

Permalink
Shave snow layers (LeavesMC#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china authored and Lumine1909 committed Apr 21, 2024
1 parent 48e7fd2 commit d5dfe0d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
9 changes: 7 additions & 2 deletions patches/server/0004-Leaves-Server-Config-And-Command.patch
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ index a53514f2c510b29f596c361de7bc0b405c27e964..269c7ba0707db4fdc45a70000e0be892
.withRequiredArg()
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..f901ec32a948fa9705dc53389a279bd466a02fa3
index 0000000000000000000000000000000000000000..4d8063f34c91ec4fe5a926f9d46555ce0d5bd8d9
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -0,0 +1,762 @@
@@ -0,0 +1,767 @@
+package top.leavesmc.leaves;
+
+import com.destroystokyo.paper.util.SneakyThrow;
Expand Down Expand Up @@ -719,6 +719,11 @@ index 0000000000000000000000000000000000000000..f901ec32a948fa9705dc53389a279bd4
+ mendingCompatibilityInfinity = getBoolean("settings.modify.mending-compatibility-infinity", mendingCompatibilityInfinity);
+ }
+
+ public static boolean shaveSnowLayers = true;
+ private static void shaveSnowLayers() {
+ shaveSnowLayers = getBoolean("settings.modify.shave-snow-layers", shaveSnowLayers);
+ }
+
+ public static final class WorldConfig {
+
+ public final String worldName;
Expand Down
46 changes: 46 additions & 0 deletions patches/server/0074-Shave-snow-layers.patch
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

0 comments on commit d5dfe0d

Please sign in to comment.