2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/BlockSoil.java
|
|
|
|
+++ b/net/minecraft/server/BlockSoil.java
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -3,6 +3,11 @@
|
|
|
|
import java.util.Iterator;
|
2014-11-25 22:32:16 +01:00
|
|
|
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 {
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
public static final BlockStateInteger MOISTURE = BlockProperties.aw;
|
|
|
|
@@ -58,26 +63,49 @@
|
2018-09-09 10:53:38 +02:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
if (!a((IWorldReader) worldserver, blockposition) && !worldserver.isRainingAt(blockposition.up())) {
|
|
|
|
if (i > 0) {
|
|
|
|
- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, i - 1), 2);
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, i - 1), 2); // CraftBukkit
|
|
|
|
} else if (!a((IBlockAccess) worldserver, blockposition)) {
|
|
|
|
fade(iblockdata, worldserver, blockposition);
|
2018-09-09 10:53:38 +02:00
|
|
|
}
|
2020-06-25 02:00:00 +02:00
|
|
|
} else if (i < 7) {
|
|
|
|
- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, 7), 2);
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, 7), 2); // CraftBukkit
|
2018-09-09 10:53:38 +02:00
|
|
|
}
|
2020-06-25 02:00:00 +02:00
|
|
|
|
|
|
|
}
|
2015-01-31 00:14:29 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2015-07-30 08:56:52 +02:00
|
|
|
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.
|
2019-06-21 12:00:00 +02:00
|
|
|
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) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit start - Interact soil
|
|
|
|
+ org.bukkit.event.Cancellable cancellable;
|
|
|
|
+ if (entity instanceof EntityHuman) {
|
2016-03-04 05:24:51 +01:00
|
|
|
+ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ } else {
|
|
|
|
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
|
|
|
+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (cancellable.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2019-04-23 04:00:00 +02:00
|
|
|
fade(world.getType(blockposition), world, blockposition);
|
2015-01-31 00:14:29 +01:00
|
|
|
}
|
2016-02-29 22:32:46 +01:00
|
|
|
|
|
|
|
- super.fallOn(world, blockposition, entity, f);
|
|
|
|
+ // super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved up
|
2015-01-31 00:14:29 +01:00
|
|
|
}
|
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
public static void fade(IBlockData iblockdata, World world, BlockPosition blockposition) {
|
2018-01-03 22:57:01 +01:00
|
|
|
+ // CraftBukkit start
|
2018-07-15 02:00:00 +02:00
|
|
|
+ if (CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) {
|
2018-01-03 22:57:01 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2018-08-26 04:00:00 +02:00
|
|
|
world.setTypeUpdate(blockposition, a(iblockdata, Blocks.DIRT.getBlockData(), world, blockposition));
|
2018-07-15 02:00:00 +02:00
|
|
|
}
|
|
|
|
|