mirror of
https://github.com/LeavesMC/Leaves.git
synced 2026-01-04 15:41:31 +00:00
--------- Co-authored-by: MC_XiaoHei <xiaohei.xor7studio@foxmail.com> Co-authored-by: Bluemangoo <chenfy2006@qq.com>
78 lines
3.9 KiB
Diff
78 lines
3.9 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/src/main/java/net/minecraft/world/item/ShovelItem.java b/src/main/java/net/minecraft/world/item/ShovelItem.java
|
|
index 24f6a158e4759aac3be8da4cf5e0d40bd295355b..8c15f74cc5f3c4dfc499e6bdab75f10f66ea36b1 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ShovelItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ShovelItem.java
|
|
@@ -2,20 +2,25 @@ package net.minecraft.world.item;
|
|
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.ImmutableMap.Builder;
|
|
+
|
|
import java.util.Map;
|
|
+
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.sounds.SoundSource;
|
|
import net.minecraft.tags.BlockTags;
|
|
import net.minecraft.world.InteractionResult;
|
|
+import net.minecraft.world.entity.EquipmentSlot;
|
|
import net.minecraft.world.entity.LivingEntity;
|
|
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;
|
|
|
|
@@ -44,6 +49,24 @@ public class ShovelItem extends DiggerItem {
|
|
return InteractionResult.PASS;
|
|
} else {
|
|
Player player = context.getPlayer();
|
|
+ // Leaves start - shaveSnowLayers
|
|
+ if (org.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.getRandom(), player, () ->
|
|
+ player.broadcastBreakEvent(switch (context.getHand()) {
|
|
+ case MAIN_HAND -> EquipmentSlot.MAINHAND;
|
|
+ case OFF_HAND -> EquipmentSlot.OFFHAND;
|
|
+ }));
|
|
+ }
|
|
+
|
|
+ return InteractionResult.SUCCESS;
|
|
+ }
|
|
+ // Leaves end - shaveSnowLayers
|
|
BlockState blockState2 = FLATTENABLES.get(blockState.getBlock());
|
|
BlockState blockState3 = null;
|
|
Runnable afterAction = null; // Paper
|
|
@@ -52,11 +75,11 @@ public class ShovelItem extends DiggerItem {
|
|
blockState3 = blockState2;
|
|
} else if (blockState.getBlock() instanceof CampfireBlock && blockState.getValue(CampfireBlock.LIT)) {
|
|
afterAction = () -> { // Paper
|
|
- if (!level.isClientSide()) {
|
|
- level.levelEvent(null, 1009, blockPos, 0);
|
|
- }
|
|
+ if (!level.isClientSide()) {
|
|
+ level.levelEvent(null, 1009, blockPos, 0);
|
|
+ }
|
|
|
|
- CampfireBlock.dowse(context.getPlayer(), level, blockPos, blockState);
|
|
+ CampfireBlock.dowse(context.getPlayer(), level, blockPos, blockState);
|
|
}; // Paper
|
|
blockState3 = blockState.setValue(CampfireBlock.LIT, Boolean.valueOf(false));
|
|
}
|