mirror of
https://github.com/LeavesMC/Leaves.git
synced 2026-01-04 15:41:31 +00:00
Update 1.20.2 (#139)
This commit is contained in:
46
patches/server/0070-Shave-snow-layers.patch
Normal file
46
patches/server/0070-Shave-snow-layers.patch
Normal file
@@ -0,0 +1,46 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
||||
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 21212462e6b415e96536a27b2c009d1562f18946..b620a6fe52bd1f86ca24f79e1ebf8879aed33961 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
|
||||
Reference in New Issue
Block a user