SPIGOT-2387: Magma does not provide a block for EntityDamageEvent.

This commit is contained in:
md_5 2016-06-11 16:11:51 +10:00
parent 3ae3ea08f2
commit d5ecbd0e93
3 changed files with 15 additions and 5 deletions

View File

@ -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) {

View File

@ -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);
}

View File

@ -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));
}