mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 19:15:32 +01:00
65 lines
3.0 KiB
Diff
65 lines
3.0 KiB
Diff
--- ../work/decompile-8eb82bde/net/minecraft/server/BlockSoil.java 2015-01-31 10:14:10.936280376 +1100
|
|
+++ src/main/java/net/minecraft/server/BlockSoil.java 2015-01-31 10:14:10.936280376 +1100
|
|
@@ -3,6 +3,11 @@
|
|
import java.util.Iterator;
|
|
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);
|
|
@@ -34,6 +39,12 @@
|
|
if (i > 0) {
|
|
world.setTypeAndData(blockposition, iblockdata.set(BlockSoil.MOISTURE, Integer.valueOf(i - 1)), 2);
|
|
} else if (!this.d(world, 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());
|
|
}
|
|
} else if (i < 7) {
|
|
@@ -43,16 +54,35 @@
|
|
}
|
|
|
|
public void a(World world, BlockPosition blockposition, Entity entity, float f) {
|
|
+ super.a(world, blockposition, entity, f); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage.
|
|
if (entity instanceof EntityLiving) {
|
|
if (!world.isStatic && world.random.nextFloat() < f - 0.5F) {
|
|
if (!(entity instanceof EntityHuman) && !world.getGameRules().getBoolean("mobGriefing")) {
|
|
return;
|
|
}
|
|
|
|
+ // 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);
|
|
+ } 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.getX(), blockposition.getY(), blockposition.getZ(), Blocks.DIRT, 0).isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
|
|
}
|
|
|
|
- super.a(world, blockposition, entity, f);
|
|
+ // super.a(world, blockposition, entity, f); // CraftBukkit - moved up
|
|
}
|
|
}
|
|
|