mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-02 11:22:01 +01:00
SPIGOT-7744: Fix exception for shooting projectiles with flame enchantment
By: Doc <nachito94@msn.com>
This commit is contained in:
parent
1498e34f2c
commit
8a61d81e90
@ -14,7 +14,33 @@
|
|||||||
public abstract class EntityArrow extends IProjectile {
|
public abstract class EntityArrow extends IProjectile {
|
||||||
|
|
||||||
private static final double ARROW_BASE_DAMAGE = 2.0D;
|
private static final double ARROW_BASE_DAMAGE = 2.0D;
|
||||||
@@ -242,7 +249,7 @@
|
@@ -86,7 +93,14 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
protected EntityArrow(EntityTypes<? extends EntityArrow> entitytypes, double d0, double d1, double d2, World world, ItemStack itemstack, @Nullable ItemStack itemstack1) {
|
||||||
|
+ // CraftBukkit start - handle the owner before the rest of things
|
||||||
|
+ this(entitytypes, d0, d1, d2, world, itemstack, itemstack1, null);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ protected EntityArrow(EntityTypes<? extends EntityArrow> entitytypes, double d0, double d1, double d2, World world, ItemStack itemstack, @Nullable ItemStack itemstack1, @Nullable EntityLiving ownerEntity) {
|
||||||
|
this(entitytypes, world);
|
||||||
|
+ this.setOwner(ownerEntity);
|
||||||
|
+ // CraftBukkit end
|
||||||
|
this.pickupItemStack = itemstack.copy();
|
||||||
|
this.setCustomName((IChatBaseComponent) itemstack.get(DataComponents.CUSTOM_NAME));
|
||||||
|
Unit unit = (Unit) itemstack.remove(DataComponents.INTANGIBLE_PROJECTILE);
|
||||||
|
@@ -116,8 +130,8 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
protected EntityArrow(EntityTypes<? extends EntityArrow> entitytypes, EntityLiving entityliving, World world, ItemStack itemstack, @Nullable ItemStack itemstack1) {
|
||||||
|
- this(entitytypes, entityliving.getX(), entityliving.getEyeY() - 0.10000000149011612D, entityliving.getZ(), world, itemstack, itemstack1);
|
||||||
|
- this.setOwner(entityliving);
|
||||||
|
+ this(entitytypes, entityliving.getX(), entityliving.getEyeY() - 0.10000000149011612D, entityliving.getZ(), world, itemstack, itemstack1, entityliving); // CraftBukkit
|
||||||
|
+ // this.setOwner(entityliving); // SPIGOT-7744 - Moved to the above constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSoundEvent(SoundEffect soundeffect) {
|
||||||
|
@@ -242,7 +256,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object != null && !flag) {
|
if (object != null && !flag) {
|
||||||
@ -23,7 +49,7 @@
|
|||||||
|
|
||||||
this.hasImpulse = true;
|
this.hasImpulse = true;
|
||||||
if (projectiledeflection != ProjectileDeflection.NONE) {
|
if (projectiledeflection != ProjectileDeflection.NONE) {
|
||||||
@@ -333,7 +340,7 @@
|
@@ -333,7 +347,7 @@
|
||||||
protected void tickDespawn() {
|
protected void tickDespawn() {
|
||||||
++this.life;
|
++this.life;
|
||||||
if (this.life >= 1200) {
|
if (this.life >= 1200) {
|
||||||
@ -32,7 +58,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -380,7 +387,7 @@
|
@@ -380,7 +394,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) {
|
if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) {
|
||||||
@ -41,7 +67,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,7 +408,13 @@
|
@@ -401,7 +415,13 @@
|
||||||
int k = entity.getRemainingFireTicks();
|
int k = entity.getRemainingFireTicks();
|
||||||
|
|
||||||
if (this.isOnFire() && !flag) {
|
if (this.isOnFire() && !flag) {
|
||||||
@ -56,7 +82,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (entity.hurt(damagesource, (float) i)) {
|
if (entity.hurt(damagesource, (float) i)) {
|
||||||
@@ -447,7 +460,7 @@
|
@@ -447,7 +467,7 @@
|
||||||
|
|
||||||
this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
|
this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
|
||||||
if (this.getPierceLevel() <= 0) {
|
if (this.getPierceLevel() <= 0) {
|
||||||
@ -65,7 +91,7 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
entity.setRemainingFireTicks(k);
|
entity.setRemainingFireTicks(k);
|
||||||
@@ -458,7 +471,7 @@
|
@@ -458,7 +478,7 @@
|
||||||
this.spawnAtLocation(this.getPickupItem(), 0.1F);
|
this.spawnAtLocation(this.getPickupItem(), 0.1F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +100,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -614,7 +627,7 @@
|
@@ -614,7 +634,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbttagcompound.contains("weapon", 10)) {
|
if (nbttagcompound.contains("weapon", 10)) {
|
||||||
@ -83,7 +109,7 @@
|
|||||||
} else {
|
} else {
|
||||||
this.firedFromWeapon = null;
|
this.firedFromWeapon = null;
|
||||||
}
|
}
|
||||||
@@ -627,34 +640,30 @@
|
@@ -627,34 +647,30 @@
|
||||||
Entity entity1 = entity;
|
Entity entity1 = entity;
|
||||||
byte b0 = 0;
|
byte b0 = 0;
|
||||||
|
|
||||||
@ -129,7 +155,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.pickup = entityarrow_pickupstatus;
|
this.pickup = entityarrow_pickupstatus;
|
||||||
@@ -663,9 +672,24 @@
|
@@ -663,9 +679,24 @@
|
||||||
@Override
|
@Override
|
||||||
public void playerTouch(EntityHuman entityhuman) {
|
public void playerTouch(EntityHuman entityhuman) {
|
||||||
if (!this.level().isClientSide && (this.inGround || this.isNoPhysics()) && this.shakeTime <= 0) {
|
if (!this.level().isClientSide && (this.inGround || this.isNoPhysics()) && this.shakeTime <= 0) {
|
||||||
|
@ -1,29 +1,36 @@
|
|||||||
--- a/net/minecraft/world/item/enchantment/effects/Ignite.java
|
--- a/net/minecraft/world/item/enchantment/effects/Ignite.java
|
||||||
+++ b/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.item.enchantment.LevelBasedValue;
|
||||||
import net.minecraft.world.phys.Vec3D;
|
import net.minecraft.world.phys.Vec3D;
|
||||||
|
|
||||||
+// CraftBukkit start
|
+// CraftBukkit start
|
||||||
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||||
|
+import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
+// CraftBukkit end
|
+// CraftBukkit end
|
||||||
+
|
+
|
||||||
public record Ignite(LevelBasedValue duration) implements EnchantmentEntityEffect {
|
public record Ignite(LevelBasedValue duration) implements EnchantmentEntityEffect {
|
||||||
|
|
||||||
public static final MapCodec<Ignite> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
public static final MapCodec<Ignite> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
||||||
@@ -18,7 +22,15 @@
|
@@ -18,7 +23,21 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(WorldServer worldserver, int i, EnchantedItemInUse enchantediteminuse, Entity entity, Vec3D vec3d) {
|
public void apply(WorldServer worldserver, int i, EnchantedItemInUse enchantediteminuse, Entity entity, Vec3D vec3d) {
|
||||||
- entity.igniteForSeconds(this.duration.calculate(i));
|
- entity.igniteForSeconds(this.duration.calculate(i));
|
||||||
+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
|
+ // 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));
|
+ EntityCombustEvent entityCombustEvent;
|
||||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
|
+ 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;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+ entity.igniteForSeconds(combustEvent.getDuration(), false);
|
+
|
||||||
|
+ entity.igniteForSeconds(entityCombustEvent.getDuration(), false);
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user