3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-22 14:28:09 +01:00
Paper/nms-patches/BlockSoil.patch

59 Zeilen
2.7 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/BlockSoil.java
+++ b/net/minecraft/server/BlockSoil.java
2016-05-10 13:47:39 +02:00
@@ -4,6 +4,11 @@
2016-11-17 02:41:03 +01:00
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);
2016-06-25 03:54:17 +02:00
@@ -35,6 +40,12 @@
if (i > 0) {
world.setTypeAndData(blockposition, iblockdata.set(BlockSoil.MOISTURE, Integer.valueOf(i - 1)), 2);
2016-11-17 02:41:03 +01:00
} else if (!this.c(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
2016-11-17 02:41:03 +01:00
this.b(world, blockposition);
}
} else if (i < 7) {
2016-11-17 02:41:03 +01:00
@@ -44,11 +55,29 @@
}
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.
2016-02-29 22:32:46 +01:00
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);
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);
+ }
+
2016-02-29 22:32:46 +01:00
+ if (cancellable.isCancelled()) {
+ return;
+ }
+
2016-07-08 03:12:40 +02:00
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT, 0).isCancelled()) {
2016-02-29 22:32:46 +01:00
+ return;
+ }
+ // CraftBukkit end
2016-11-17 02:41:03 +01:00
this.b(world, blockposition);
}
2016-02-29 22:32:46 +01:00
- super.fallOn(world, blockposition, entity, f);
+ // super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved up
}
2016-11-17 02:41:03 +01:00
private void b(World world, BlockPosition blockposition) {