mirror of
https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git
synced 2024-11-25 13:56:14 +00:00
43 lines
2.3 KiB
Diff
43 lines
2.3 KiB
Diff
--- a/net/minecraft/world/level/block/CaveVines.java
|
|
+++ b/net/minecraft/world/level/block/CaveVines.java
|
|
@@ -19,6 +19,13 @@
|
|
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);
|
|
@@ -26,7 +33,24 @@
|
|
|
|
static EnumInteractionResult use(@Nullable Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) {
|
|
if ((Boolean) iblockdata.getValue(CaveVines.BERRIES)) {
|
|
- Block.popResource(world, blockposition, new ItemStack(Items.GLOW_BERRIES, 1));
|
|
+ // CraftBukkit start
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, (IBlockData) iblockdata.setValue(CaveVines.BERRIES, false))) {
|
|
+ return EnumInteractionResult.SUCCESS;
|
|
+ }
|
|
+
|
|
+ if (entity instanceof EntityHuman) {
|
|
+ PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(world, blockposition, (EntityHuman) entity, net.minecraft.world.EnumHand.MAIN_HAND, Collections.singletonList(new ItemStack(Items.GLOW_BERRIES, 1)));
|
|
+ if (event.isCancelled()) {
|
|
+ return EnumInteractionResult.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(world, blockposition, CraftItemStack.asNMSCopy(itemStack));
|
|
+ }
|
|
+ } else {
|
|
+ Block.popResource(world, blockposition, new ItemStack(Items.GLOW_BERRIES, 1));
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
float f = MathHelper.randomBetween(world.random, 0.8F, 1.2F);
|
|
|
|
world.playSound((EntityHuman) null, blockposition, SoundEffects.CAVE_VINES_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, f);
|