0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-25 13:56:14 +00:00
craftbukkit/nms-patches/net/minecraft/world/item/enchantment/effects/Ignite.patch

38 lines
1.6 KiB
Diff

--- a/net/minecraft/world/item/enchantment/effects/Ignite.java
+++ b/net/minecraft/world/item/enchantment/effects/Ignite.java
@@ -8,6 +8,11 @@
import net.minecraft.world.item.enchantment.LevelBasedValue;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.entity.EntityCombustEvent;
+// CraftBukkit end
+
public record Ignite(LevelBasedValue duration) implements EnchantmentEntityEffect {
public static final MapCodec<Ignite> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
@@ -18,7 +23,21 @@
@Override
public void apply(WorldServer worldserver, int i, EnchantedItemInUse enchantediteminuse, Entity entity, Vec3D vec3d) {
- entity.igniteForSeconds(this.duration.calculate(i));
+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
+ EntityCombustEvent entityCombustEvent;
+ if (enchantediteminuse.owner() != null) {
+ entityCombustEvent = new EntityCombustByEntityEvent(enchantediteminuse.owner().getBukkitEntity(), entity.getBukkitEntity(), this.duration.calculate(i));
+ } else {
+ entityCombustEvent = new EntityCombustEvent(entity.getBukkitEntity(), this.duration.calculate(i));
+ }
+
+ org.bukkit.Bukkit.getPluginManager().callEvent(entityCombustEvent);
+ if (entityCombustEvent.isCancelled()) {
+ return;
+ }
+
+ entity.igniteForSeconds(entityCombustEvent.getDuration(), false);
+ // CraftBukkit end
}
@Override