From a9e1194e191f173f0d87d1d149fbc6a9abcf0bfe Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sat, 11 Jun 2016 16:11:51 +1000 Subject: [PATCH] SPIGOT-2387: Magma does not provide a block for EntityDamageEvent. By: md_5 --- paper-server/nms-patches/BlockCactus.patch | 4 +--- paper-server/nms-patches/BlockMagma.patch | 10 ++++++++++ .../bukkit/craftbukkit/event/CraftEventFactory.java | 6 ++++-- 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 paper-server/nms-patches/BlockMagma.patch diff --git a/paper-server/nms-patches/BlockCactus.patch b/paper-server/nms-patches/BlockCactus.patch index 951d5a9bbd..7c9fc0e4b4 100644 --- a/paper-server/nms-patches/BlockCactus.patch +++ b/paper-server/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/paper-server/nms-patches/BlockMagma.patch b/paper-server/nms-patches/BlockMagma.patch new file mode 100644 index 0000000000..701c36cfb9 --- /dev/null +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 119e97d27b..7061881ce6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/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)); }