testserver/patches/server/0740-call-EntityDamageByBlo...

36 lines
2.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 21 Jul 2021 11:46:28 -0700
Subject: [PATCH] call EntityDamageByBlockEvent for campfires
diff --git a/src/main/java/net/minecraft/world/level/block/CampfireBlock.java b/src/main/java/net/minecraft/world/level/block/CampfireBlock.java
index 2519a0f511f0a6065459cd2fe2d9a3e68e55d222..2c334ce3fc3cf86704dee9397166119a3b5f17e2 100644
--- a/src/main/java/net/minecraft/world/level/block/CampfireBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CampfireBlock.java
@@ -93,7 +93,9 @@ public class CampfireBlock extends BaseEntityBlock implements SimpleWaterloggedB
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
if (!entity.fireImmune() && (Boolean) state.getValue(CampfireBlock.LIT) && entity instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity) entity)) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); // Paper
entity.hurt(DamageSource.IN_FIRE, (float) this.fireDamage);
+ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = null; // Paper
}
super.entityInside(state, world, pos, entity);
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index d01d4ca873f8225d3503ecb102ce2eb7bfced421..622a0f23db838b839f76722df0e5480ec927b4a2 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -1009,6 +1009,10 @@ public class CraftEventFactory {
cause = DamageCause.HOT_FLOOR;
} else if (source == DamageSource.MAGIC) {
cause = DamageCause.MAGIC;
+ // Paper start
+ } else if (source == DamageSource.IN_FIRE) {
+ cause = DamageCause.FIRE;
+ // Paper end
} else {
throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager, source.msgId));
}