diff options
author | Wesley Wolfe <weswolf@aol.com> | 2012-12-04 18:30:10 -0600 |
---|---|---|
committer | Wesley Wolfe <weswolf@aol.com> | 2012-12-04 22:38:51 -0600 |
commit | b854320fc8967e4d58979d20bbcdd00b2af3d81f (patch) | |
tree | 48740050e7e12941e6c8969cab84b7978c0baa86 /src/main/java | |
parent | 4dadf0e2b5ecb7a2644e2feb71e3a7ab1194ec84 (diff) | |
download | craftbukkit-b854320fc8967e4d58979d20bbcdd00b2af3d81f.tar craftbukkit-b854320fc8967e4d58979d20bbcdd00b2af3d81f.tar.gz craftbukkit-b854320fc8967e4d58979d20bbcdd00b2af3d81f.tar.lz craftbukkit-b854320fc8967e4d58979d20bbcdd00b2af3d81f.tar.xz craftbukkit-b854320fc8967e4d58979d20bbcdd00b2af3d81f.zip |
Fire EntityFormBlockEvent for FallingBlocks. Adds BUKKIT-3078
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityFallingBlock.java | 17 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java | 2 |
2 files changed, 14 insertions, 5 deletions
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java index 4142650a..2f142ae1 100644 --- a/src/main/java/net/minecraft/server/EntityFallingBlock.java +++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java @@ -3,7 +3,10 @@ package net.minecraft.server; import java.util.ArrayList; import java.util.Iterator; -import org.bukkit.event.entity.EntityDamageEvent; // CraftBukkit +//CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.EntityDamageEvent; +// CraftBukkit end public class EntityFallingBlock extends Entity { @@ -81,7 +84,7 @@ public class EntityFallingBlock extends Entity { int k = MathHelper.floor(this.locZ); if (this.c == 1) { - if (this.c == 1 && this.world.getTypeId(i, j, k) == this.id) { + if (this.c == 1 && this.world.getTypeId(i, j, k) == this.id && this.world.getData(i, j, k) == this.data && !CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, 0, 0).isCancelled()) { // CraftBukkit - compare data and call event this.world.setTypeId(i, j, k, 0); } else { this.die(); @@ -95,7 +98,13 @@ public class EntityFallingBlock extends Entity { this.motY *= -0.5D; if (this.world.getTypeId(i, j, k) != Block.PISTON_MOVING.id) { this.die(); - if (!this.e && this.world.mayPlace(this.id, i, j, k, true, 1, (Entity) null) && !BlockSand.canFall(this.world, i, j - 1, k) && this.world.setTypeIdAndData(i, j, k, this.id, this.data)) { + // CraftBukkit start + if (!this.e && this.world.mayPlace(this.id, i, j, k, true, 1, (Entity) null) && !BlockSand.canFall(this.world, i, j - 1, k) /* mimic the false conditions of setTypeIdAndData */ && i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000 && j > 0 && j < 256 && !(this.world.getTypeId(i, j, k) == this.id && this.world.getData(i, j, k) == this.data)) { + if (CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, this.id, this.data).isCancelled()) { + return; + } + this.world.setTypeIdAndData(i, j, k, this.id, this.data); + // CraftBukkit end if (Block.byId[this.id] instanceof BlockSand) { ((BlockSand) Block.byId[this.id]).a_(this.world, i, j, k, this.data); } @@ -129,7 +138,7 @@ public class EntityFallingBlock extends Entity { // CraftBukkit start int damage = Math.min(MathHelper.d((float) i * this.fallHurtAmount), this.fallHurtMax); - EntityDamageEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDamageEvent(this, entity, EntityDamageEvent.DamageCause.FALLING_BLOCK, damage); + EntityDamageEvent event = CraftEventFactory.callEntityDamageEvent(this, entity, EntityDamageEvent.DamageCause.FALLING_BLOCK, damage); if (event.isCancelled()) { continue; } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index a840111f..a323f6fb 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -463,7 +463,7 @@ public class CraftEventFactory { } public static EntityChangeBlockEvent callEntityChangeBlockEvent(org.bukkit.entity.Entity entity, Block block, Material material, int data) { - EntityChangeBlockEvent event = new EntityChangeBlockEvent((LivingEntity) entity, block, material, (byte) data); + EntityChangeBlockEvent event = new EntityChangeBlockEvent(entity, block, material, (byte) data); entity.getServer().getPluginManager().callEvent(event); return event; } |