geforkt von Mirrors/Paper
SPIGOT-6645: Call EntityChangeBlockEvent before PlayerHarvestBlockEvent
By: Brokkonaut <hannos17@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
1e8509d8ef
Commit
8650786dad
@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/world/level/block/CaveVines.java
|
--- a/net/minecraft/world/level/block/CaveVines.java
|
||||||
+++ b/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.level.block.state.properties.BlockStateBoolean;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
|
||||||
@ -22,6 +22,10 @@
|
|||||||
if ((Boolean) iblockdata.get(CaveVines.BERRIES)) {
|
if ((Boolean) iblockdata.get(CaveVines.BERRIES)) {
|
||||||
- Block.a(world, blockposition, new ItemStack(Items.GLOW_BERRIES, 1));
|
- Block.a(world, blockposition, new ItemStack(Items.GLOW_BERRIES, 1));
|
||||||
+ // CraftBukkit start
|
+ // 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) {
|
+ if (entity instanceof EntityHuman) {
|
||||||
+ PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(world, blockposition, (EntityHuman) entity, Collections.singletonList(new ItemStack(Items.GLOW_BERRIES, 1)));
|
+ PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(world, blockposition, (EntityHuman) entity, Collections.singletonList(new ItemStack(Items.GLOW_BERRIES, 1)));
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
@ -38,11 +42,3 @@
|
|||||||
float f = MathHelper.b(world.random, 0.8F, 1.2F);
|
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);
|
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 {
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren