SPIGOT-7744: Fix exception for shooting projectiles with flame enchantment
By: Doc <nachito94@msn.com>
This commit is contained in:
@@ -1,29 +1,36 @@
|
||||
--- a/net/minecraft/world/item/enchantment/effects/Ignite.java
|
||||
+++ b/net/minecraft/world/item/enchantment/effects/Ignite.java
|
||||
@@ -8,6 +8,10 @@
|
||||
@@ -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 +22,15 @@
|
||||
@@ -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
|
||||
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(enchantediteminuse.owner().getBukkitEntity(), entity.getBukkitEntity(), this.duration.calculate(i));
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
|
||||
+ 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));
|
||||
+ }
|
||||
+
|
||||
+ if (combustEvent.isCancelled()) {
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(entityCombustEvent);
|
||||
+ if (entityCombustEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ entity.igniteForSeconds(combustEvent.getDuration(), false);
|
||||
+
|
||||
+ entity.igniteForSeconds(entityCombustEvent.getDuration(), false);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user