aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/CaveVines.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/CaveVines.java.patch')
-rw-r--r--patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/CaveVines.java.patch44
1 files changed, 44 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/CaveVines.java.patch b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/CaveVines.java.patch
new file mode 100644
index 0000000000..8557f597ed
--- /dev/null
+++ b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/level/block/CaveVines.java.patch
@@ -0,0 +1,44 @@
+--- a/net/minecraft/world/level/block/CaveVines.java
++++ b/net/minecraft/world/level/block/CaveVines.java
+@@ -18,14 +18,38 @@
+ import net.minecraft.world.level.gameevent.GameEvent;
+ import net.minecraft.world.phys.shapes.VoxelShape;
+
++// CraftBukkit start
++import java.util.Collections;
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++import org.bukkit.craftbukkit.inventory.CraftItemStack;
++import org.bukkit.event.player.PlayerHarvestBlockEvent;
++// CraftBukkit end
++
+ public interface CaveVines {
+
+ VoxelShape SHAPE = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D);
+ BooleanProperty BERRIES = BlockStateProperties.BERRIES;
+
+- static InteractionResult use(@Nullable Entity entity, BlockState blockstate, Level level, BlockPos blockpos) {
+- if ((Boolean) blockstate.getValue(CaveVines.BERRIES)) {
+- Block.popResource(level, blockpos, new ItemStack(Items.GLOW_BERRIES, 1));
++ static InteractionResult use(@Nullable Entity entity, IBlockData state, Level level, BlockPos pos) {
++ if ((Boolean) state.getValue(CaveVines.BERRIES)) {
++ // CraftBukkit start
++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, (IBlockData) state.setValue(CaveVines.BERRIES, false))) {
++ return InteractionResult.SUCCESS;
++ }
++
++ if (entity instanceof Player) {
++ PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(level, pos, (Player) entity, net.minecraft.world.EnumHand.MAIN_HAND, Collections.singletonList(new ItemStack(Items.GLOW_BERRIES, 1)));
++ if (event.isCancelled()) {
++ return InteractionResult.SUCCESS; // We need to return a success either way, because making it PASS or FAIL will result in a bug where cancelling while harvesting w/ block in hand places block
++ }
++ for (org.bukkit.inventory.ItemStack itemStack : event.getItemsHarvested()) {
++ Block.popResource(level, pos, CraftItemStack.asNMSCopy(itemStack));
++ }
++ } else {
++ Block.popResource(level, pos, new ItemStack(Items.GLOW_BERRIES, 1));
++ }
++ // CraftBukkit end
++
+ float f = Mth.randomBetween(level.random, 0.8F, 1.2F);
+
+ level.playSound((Player) null, blockpos, SoundEvents.CAVE_VINES_PICK_BERRIES, SoundSource.BLOCKS, 1.0F, f);