summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2016-06-11 16:11:51 +1000
committermd_5 <git@md-5.net>2016-06-11 16:11:51 +1000
commitd5ecbd0e93a7a22d3631541c258635fdcc42a489 (patch)
tree2037fead4dc997db2684177a9c1f634117b3bbef
parent3ae3ea08f210b013a5746143c55deb06cfff5514 (diff)
downloadcraftbukkit-d5ecbd0e93a7a22d3631541c258635fdcc42a489.tar
craftbukkit-d5ecbd0e93a7a22d3631541c258635fdcc42a489.tar.gz
craftbukkit-d5ecbd0e93a7a22d3631541c258635fdcc42a489.tar.lz
craftbukkit-d5ecbd0e93a7a22d3631541c258635fdcc42a489.tar.xz
craftbukkit-d5ecbd0e93a7a22d3631541c258635fdcc42a489.zip
SPIGOT-2387: Magma does not provide a block for EntityDamageEvent.
-rw-r--r--nms-patches/BlockCactus.patch4
-rw-r--r--nms-patches/BlockMagma.patch10
-rw-r--r--src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java6
3 files changed, 15 insertions, 5 deletions
diff --git a/nms-patches/BlockCactus.patch b/nms-patches/BlockCactus.patch
index 951d5a9b..7c9fc0e4 100644
--- a/nms-patches/BlockCactus.patch
+++ b/nms-patches/BlockCactus.patch
@@ -21,13 +21,11 @@
world.setTypeAndData(blockposition, iblockdata1, 4);
iblockdata1.doPhysics(world, blockposition1, this);
} else {
-@@ -87,7 +90,9 @@
+@@ -87,6 +90,7 @@
}
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
+ CraftEventFactory.blockDamage = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit
entity.damageEntity(DamageSource.CACTUS, 1.0F);
-+ CraftEventFactory.blockDamage = null; // CraftBukkit
}
- public IBlockData fromLegacyData(int i) {
diff --git a/nms-patches/BlockMagma.patch b/nms-patches/BlockMagma.patch
new file mode 100644
index 00000000..701c36cf
--- /dev/null
+++ b/nms-patches/BlockMagma.patch
@@ -0,0 +1,10 @@
+--- a/net/minecraft/server/BlockMagma.java
++++ b/net/minecraft/server/BlockMagma.java
+@@ -17,6 +17,7 @@
+
+ public void stepOn(World world, BlockPosition blockposition, Entity entity) {
+ if (!entity.isFireProof() && entity instanceof EntityLiving && !EnchantmentManager.j((EntityLiving) entity)) {
++ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit
+ entity.damageEntity(DamageSource.HOT_FLOOR, 1.0F);
+ }
+
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 119e97d2..7061881c 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -483,8 +483,8 @@ public class CraftEventFactory {
event.getEntity().setLastDamageCause(event);
}
return event;
- } else if (source == DamageSource.LAVA || source == DamageSource.HOT_FLOOR) {
- EntityDamageEvent event = callEvent(new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), (source == DamageSource.LAVA) ? DamageCause.LAVA : DamageCause.HOT_FLOOR, modifiers, modifierFunctions));
+ } else if (source == DamageSource.LAVA) {
+ EntityDamageEvent event = callEvent(new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.LAVA, modifiers, modifierFunctions));
if (!event.isCancelled()) {
event.getEntity().setLastDamageCause(event);
}
@@ -495,6 +495,8 @@ public class CraftEventFactory {
blockDamage = null;
if (source == DamageSource.CACTUS) {
cause = DamageCause.CONTACT;
+ } else if (source == DamageSource.HOT_FLOOR) {
+ cause = DamageCause.HOT_FLOOR;
} else {
throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager, source.translationIndex));
}