Paper/nms-patches/EntityFallingBlock.patch

46 lines
2.7 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityFallingBlock.java
+++ b/net/minecraft/server/EntityFallingBlock.java
2016-02-29 22:32:46 +01:00
@@ -4,6 +4,8 @@
import java.util.ArrayList;
import java.util.Iterator;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityFallingBlock extends Entity {
2015-02-26 23:41:06 +01:00
private IBlockData block;
2016-02-29 22:32:46 +01:00
@@ -64,7 +66,7 @@
if (this.ticksLived++ == 0) {
blockposition = new BlockPosition(this);
- if (this.world.getType(blockposition).getBlock() == block) {
+ if (this.world.getType(blockposition).getBlock() == block && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.AIR, 0).isCancelled()) {
this.world.setAir(blockposition);
2015-02-26 23:41:06 +01:00
} else if (!this.world.isClientSide) {
this.die();
@@ -93,7 +95,13 @@
if (iblockdata.getBlock() != Blocks.PISTON_EXTENSION) {
this.die();
2016-02-29 22:32:46 +01:00
if (!this.f) {
- if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null, (ItemStack) null) && !BlockFalling.i(this.world.getType(blockposition.down())) && this.world.setTypeAndData(blockposition, this.block, 3)) {
+ // CraftBukkit start
+ if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null, (ItemStack) null) && !BlockFalling.i(this.world.getType(blockposition.down()))) {
2015-02-26 23:41:06 +01:00
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.block.getBlock(), this.block.getBlock().toLegacyData(this.block)).isCancelled()) {
+ return;
+ }
+ this.world.setTypeAndData(blockposition, this.block, 3);
+ // CraftBukkit end
if (block instanceof BlockFalling) {
((BlockFalling) block).a_(this.world, blockposition);
}
2016-02-29 22:32:46 +01:00
@@ -152,7 +160,9 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
+ CraftEventFactory.entityDamage = this; // CraftBukkit
entity.damageEntity(damagesource, (float) Math.min(MathHelper.d((float) i * this.fallHurtAmount), this.fallHurtMax));
+ CraftEventFactory.entityDamage = null; // CraftBukkit
}
if (flag && (double) this.random.nextFloat() < 0.05000000074505806D + (double) i * 0.05D) {