From c851639c5050b9f99596ab768f7cb6161868c124 Mon Sep 17 00:00:00 2001 From: Brokkonaut Date: Mon, 19 Jul 2021 18:54:13 +1000 Subject: [PATCH] SPIGOT-6645: Call EntityChangeBlockEvent before PlayerHarvestBlockEvent --- .../minecraft/world/level/block/CaveVines.patch | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/nms-patches/net/minecraft/world/level/block/CaveVines.patch b/nms-patches/net/minecraft/world/level/block/CaveVines.patch index 2babaa141..6dc0cee91 100644 --- a/nms-patches/net/minecraft/world/level/block/CaveVines.patch +++ b/nms-patches/net/minecraft/world/level/block/CaveVines.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CaveVines.java +++ b/net/minecraft/world/level/block/CaveVines.java -@@ -15,17 +15,43 @@ +@@ -15,14 +15,39 @@ import net.minecraft.world.level.block.state.properties.BlockStateBoolean; import net.minecraft.world.phys.shapes.VoxelShape; @@ -22,6 +22,10 @@ if ((Boolean) iblockdata.get(CaveVines.BERRIES)) { - Block.a(world, blockposition, new ItemStack(Items.GLOW_BERRIES, 1)); + // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, (IBlockData) iblockdata.set(CaveVines.BERRIES, false)).isCancelled()) { ++ return EnumInteractionResult.SUCCESS; ++ } ++ + if (entity instanceof EntityHuman) { + PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(world, blockposition, (EntityHuman) entity, Collections.singletonList(new ItemStack(Items.GLOW_BERRIES, 1))); + if (event.isCancelled()) { @@ -38,11 +42,3 @@ float f = MathHelper.b(world.random, 0.8F, 1.2F); world.playSound((EntityHuman) null, blockposition, SoundEffects.CAVE_VINES_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, f); -+ // CraftBukkit start - call EntityChangeBlockEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, (IBlockData) iblockdata.set(CaveVines.BERRIES, false)).isCancelled()) { -+ return EnumInteractionResult.SUCCESS; -+ } -+ // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(CaveVines.BERRIES, false), 2); - return EnumInteractionResult.a(world.isClientSide); - } else {