mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
--------- Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com> Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com> Co-authored-by: Helvetica Volubi <88063803+Suisuroru@users.noreply.github.com>
38 lines
2.3 KiB
Diff
38 lines
2.3 KiB
Diff
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/net/minecraft/world/item/ShovelItem.java b/net/minecraft/world/item/ShovelItem.java
|
|
index ba0609f4d9166e66599f9d4430885ab03d53ef41..c50ea91c477a9b59222faab629cdf32049899519 100644
|
|
--- a/net/minecraft/world/item/ShovelItem.java
|
|
+++ b/net/minecraft/world/item/ShovelItem.java
|
|
@@ -43,6 +43,26 @@ public class ShovelItem extends Item {
|
|
return InteractionResult.PASS;
|
|
} else {
|
|
Player player = context.getPlayer();
|
|
+ // Leaves start - shaveSnowLayers
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.shaveSnowLayers && blockState.is(Blocks.SNOW)) {
|
|
+ int layers = blockState.getValue(net.minecraft.world.level.block.SnowLayerBlock.LAYERS);
|
|
+ ItemStack tool = context.getItemInHand();
|
|
+ boolean hasSilkTouch = net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(level.registryAccess().lookupOrThrow(net.minecraft.core.registries.Registries.ENCHANTMENT).getOrThrow(net.minecraft.world.item.enchantment.Enchantments.SILK_TOUCH), tool) > 0;
|
|
+ BlockState shavedBlockState = layers > 1 ? blockState.setValue(net.minecraft.world.level.block.SnowLayerBlock.LAYERS, layers - 1) : Blocks.AIR.defaultBlockState();
|
|
+
|
|
+ level.setBlock(clickedPos, shavedBlockState, Block.UPDATE_ALL_IMMEDIATE);
|
|
+ level.gameEvent(GameEvent.BLOCK_CHANGE, clickedPos, GameEvent.Context.of(player, shavedBlockState));
|
|
+
|
|
+ Block.popResource(level, clickedPos, new ItemStack(hasSilkTouch ? Items.SNOW : Items.SNOWBALL));
|
|
+ level.playSound(player, clickedPos, SoundEvents.SNOW_BREAK, SoundSource.BLOCKS, 1.0F, 1.0F);
|
|
+
|
|
+ if (player != null) {
|
|
+ tool.hurtAndBreak(1, player, context.getHand());
|
|
+ }
|
|
+
|
|
+ return InteractionResult.SUCCESS;
|
|
+ }
|
|
+ // Leaves end - shaveSnowLayers
|
|
BlockState blockState1 = FLATTENABLES.get(blockState.getBlock());
|
|
BlockState blockState2 = null;
|
|
Runnable afterAction = null; // Paper
|