mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-04 22:14:40 +01:00
68 lines
3.4 KiB
Diff
68 lines
3.4 KiB
Diff
--- a/net/minecraft/server/BlockSoil.java
|
|
+++ b/net/minecraft/server/BlockSoil.java
|
|
@@ -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 = BlockProperties.ap;
|
|
@@ -53,12 +58,12 @@
|
|
|
|
if (!a((IWorldReader) world, blockposition) && !world.isRainingAt(blockposition.up())) {
|
|
if (i > 0) {
|
|
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, i - 1), 2);
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(world, blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, i - 1), 2); // CraftBukkit
|
|
} else if (!a((IBlockAccess) world, blockposition)) {
|
|
fade(iblockdata, world, blockposition);
|
|
}
|
|
} else if (i < 7) {
|
|
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, 7), 2);
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(world, blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, 7), 2); // CraftBukkit
|
|
}
|
|
|
|
}
|
|
@@ -66,14 +71,37 @@
|
|
|
|
@Override
|
|
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(GameRules.MOB_GRIEFING)) && entity.getWidth() * entity.getWidth() * entity.getHeight() > 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.getBlockData()).isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
fade(world.getType(blockposition), world, blockposition);
|
|
}
|
|
|
|
- super.fallOn(world, blockposition, entity, f);
|
|
+ // super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved up
|
|
}
|
|
|
|
public static void fade(IBlockData iblockdata, World world, BlockPosition blockposition) {
|
|
+ // CraftBukkit start
|
|
+ if (CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
world.setTypeUpdate(blockposition, a(iblockdata, Blocks.DIRT.getBlockData(), world, blockposition));
|
|
}
|
|
|