mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 06:24:06 +01:00
55 lines
2.6 KiB
Diff
55 lines
2.6 KiB
Diff
--- a/net/minecraft/server/BlockSoil.java
|
|
+++ b/net/minecraft/server/BlockSoil.java
|
|
@@ -4,6 +4,11 @@
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.event.entity.EntityInteractEvent;
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
+// CraftBukkit end
|
|
+
|
|
public class BlockSoil extends Block {
|
|
|
|
public static final BlockStateInteger MOISTURE = BlockStateInteger.of("moisture", 0, 7);
|
|
@@ -45,14 +50,38 @@
|
|
}
|
|
|
|
public void fallOn(World world, BlockPosition blockposition, Entity entity, float f) {
|
|
+ super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage.
|
|
if (!world.isClientSide && world.random.nextFloat() < f - 0.5F && entity instanceof EntityLiving && (entity instanceof EntityHuman || world.getGameRules().getBoolean("mobGriefing")) && entity.width * entity.width * entity.length > 0.512F) {
|
|
+ // CraftBukkit start - Interact soil
|
|
+ org.bukkit.event.Cancellable cancellable;
|
|
+ if (entity instanceof EntityHuman) {
|
|
+ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
|
|
+ } else {
|
|
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
|
+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
|
|
+ }
|
|
+
|
|
+ if (cancellable.isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT, 0).isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
b(world, blockposition);
|
|
}
|
|
|
|
- super.fallOn(world, blockposition, entity, f);
|
|
+ // super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved up
|
|
}
|
|
|
|
protected static void b(World world, BlockPosition blockposition) {
|
|
+ // CraftBukkit start
|
|
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
+ if (CraftEventFactory.callBlockFadeEvent(block, Blocks.DIRT).isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
|
|
AxisAlignedBB axisalignedbb = BlockSoil.c.a(blockposition);
|
|
List list = world.getEntities((Entity) null, axisalignedbb);
|