From 25c384ac3846d325f23c3a0b9caae61680f0d2dd Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Wed, 23 Oct 2024 11:04:00 +0200 Subject: [PATCH] Breakpoint before projectile mess --- ...to-disable-ender-dragon-legacy-check.patch | 0 .../server/Add-entity-knockback-events.patch | 36 +++--- .../server/EnderDragon-Events.patch | 6 +- patches/server/Expand-Explosions-API.patch | 87 +++++++++++++ .../Implement-World.getEntity-UUID-API.patch | 0 .../InventoryCloseEvent-Reason-API.patch | 4 +- .../server/LivingEntity-Active-Item-API.patch | 0 .../server/PlayerReadyArrowEvent.patch | 0 .../server/RangedEntity-API.patch | 0 .../server/Vex-get-setSummoner-API.patch | 0 ...-more-information-to-Entity.toString.patch | 2 +- .../server/Expand-Explosions-API.patch | 116 ------------------ 12 files changed, 111 insertions(+), 140 deletions(-) rename patches/{unapplied => }/server/Add-config-to-disable-ender-dragon-legacy-check.patch (100%) rename patches/{unapplied => }/server/Add-entity-knockback-events.patch (93%) rename patches/{unapplied => }/server/EnderDragon-Events.patch (95%) create mode 100644 patches/server/Expand-Explosions-API.patch rename patches/{unapplied => }/server/Implement-World.getEntity-UUID-API.patch (100%) rename patches/{unapplied => }/server/InventoryCloseEvent-Reason-API.patch (99%) rename patches/{unapplied => }/server/LivingEntity-Active-Item-API.patch (100%) rename patches/{unapplied => }/server/PlayerReadyArrowEvent.patch (100%) rename patches/{unapplied => }/server/RangedEntity-API.patch (100%) rename patches/{unapplied => }/server/Vex-get-setSummoner-API.patch (100%) rename patches/{unapplied => }/server/add-more-information-to-Entity.toString.patch (96%) delete mode 100644 patches/unapplied/server/Expand-Explosions-API.patch diff --git a/patches/unapplied/server/Add-config-to-disable-ender-dragon-legacy-check.patch b/patches/server/Add-config-to-disable-ender-dragon-legacy-check.patch similarity index 100% rename from patches/unapplied/server/Add-config-to-disable-ender-dragon-legacy-check.patch rename to patches/server/Add-config-to-disable-ender-dragon-legacy-check.patch diff --git a/patches/unapplied/server/Add-entity-knockback-events.patch b/patches/server/Add-entity-knockback-events.patch similarity index 93% rename from patches/unapplied/server/Add-entity-knockback-events.patch rename to patches/server/Add-entity-knockback-events.patch index 602ea9e0f6..fddef5ab84 100644 --- a/patches/unapplied/server/Add-entity-knockback-events.patch +++ b/patches/server/Add-entity-knockback-events.patch @@ -97,9 +97,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java @@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab - if (f1 > 0.0F && target instanceof LivingEntity) { - LivingEntity entityliving = (LivingEntity) target; + if (f1 > 0.0F && target instanceof LivingEntity) { + entityliving = (LivingEntity) target; - entityliving.knockback((double) (f1 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit + entityliving.knockback((double) (f1 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // CraftBukkit // Paper - knockback events this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D)); @@ -123,7 +123,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/warden/SonicBoom.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/warden/SonicBoom.java @@ -0,0 +0,0 @@ public class SonicBoom extends Behavior { - if (target.hurt(world.damageSources().sonicBoom(entity), 10.0F)) { + if (target.hurtServer(world, world.damageSources().sonicBoom(entity), 10.0F)) { double d = 0.5 * (1.0 - target.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); double e = 2.5 * (1.0 - target.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); - target.push(vec33.x() * e, vec33.y() * d, vec33.z() * e); @@ -154,9 +154,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override - public void push(double deltaX, double deltaY, double deltaZ) { + public void push(double deltaX, double deltaY, double deltaZ, @Nullable Entity pushingEntity) { // Paper - override correct overload - if (false && !this.level().isClientSide && !this.isRemoved() && deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ > 0.0D) { // CraftBukkit - not needed - this.kill(); - this.dropItem((Entity) null); + Level world = this.level(); + + if (world instanceof ServerLevel worldserver) { diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java @@ -250,28 +250,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public abstract void explode(Vec3 pos); -diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java +diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/Explosion.java -+++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -0,0 +0,0 @@ public class Explosion { +--- a/src/main/java/net/minecraft/world/level/ServerExplosion.java ++++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java +@@ -0,0 +0,0 @@ public class ServerExplosion implements Explosion { // CraftBukkit start - Call EntityKnockbackEvent if (entity instanceof LivingEntity) { -- Vec3 result = entity.getDeltaMovement().add(vec3d1); -- org.bukkit.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), this.source, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.EXPLOSION, d13, vec3d1, result.x, result.y, result.z); +- Vec3 result = entity.getDeltaMovement().add(vec3d); +- org.bukkit.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), this.source, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.EXPLOSION, d6, vec3d, result.x, result.y, result.z); - - // SPIGOT-7640: Need to subtract entity movement from the event result, - // since the code below (the setDeltaMovement call as well as the hitPlayers map) - // want the vector to be the relative velocity will the event provides the absolute velocity -- vec3d1 = (event.isCancelled()) ? Vec3.ZERO : new Vec3(event.getFinalKnockback().getX(), event.getFinalKnockback().getY(), event.getFinalKnockback().getZ()).subtract(entity.getDeltaMovement()); -+ // Paper start - knockback events -+ io.papermc.paper.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), this.source, this.damageSource.getEntity() != null ? this.damageSource.getEntity() : this.source, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.EXPLOSION, d13, vec3d1); -+ vec3d1 = event.isCancelled() ? Vec3.ZERO : org.bukkit.craftbukkit.util.CraftVector.toNMS(event.getKnockback()); -+ // Paper end - knockback events +- vec3d = (event.isCancelled()) ? Vec3.ZERO : new Vec3(event.getFinalKnockback().getX(), event.getFinalKnockback().getY(), event.getFinalKnockback().getZ()).subtract(entity.getDeltaMovement()); ++ // Paper start - knockback events ++ io.papermc.paper.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), this.source, this.damageSource.getEntity() != null ? this.damageSource.getEntity() : this.source, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.EXPLOSION, d6, vec3d); ++ vec3d = event.isCancelled() ? Vec3.ZERO : org.bukkit.craftbukkit.util.CraftVector.toNMS(event.getKnockback()); ++ // Paper end - knockback events } // CraftBukkit end - entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d1)); + entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d)); diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java diff --git a/patches/unapplied/server/EnderDragon-Events.patch b/patches/server/EnderDragon-Events.patch similarity index 95% rename from patches/unapplied/server/EnderDragon-Events.patch rename to patches/server/EnderDragon-Events.patch index 2b49c0c29a..56c066317c 100644 --- a/patches/unapplied/server/EnderDragon-Events.patch +++ b/patches/server/EnderDragon-Events.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.flame.setParticle(ParticleTypes.DRAGON_BREATH); this.flame.addEffect(new MobEffectInstance(MobEffects.HARM)); + if (new com.destroystokyo.paper.event.entity.EnderDragonFlameEvent((org.bukkit.entity.EnderDragon) this.dragon.getBukkitEntity(), (org.bukkit.entity.AreaEffectCloud) this.flame.getBukkitEntity()).callEvent()) { // Paper - EnderDragon Events - this.dragon.level().addFreshEntity(this.flame); + world.addFreshEntity(this.flame); + // Paper start - EnderDragon Events + } else { + this.end(); @@ -28,10 +28,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java @@ -0,0 +0,0 @@ public class DragonStrafePlayerPhase extends AbstractDragonPhaseInstance { - DragonFireball dragonFireball = new DragonFireball(this.dragon.level(), this.dragon, vec34.normalize()); + DragonFireball dragonFireball = new DragonFireball(world, this.dragon, vec34.normalize()); dragonFireball.moveTo(o, p, q, 0.0F, 0.0F); + if (new com.destroystokyo.paper.event.entity.EnderDragonShootFireballEvent((org.bukkit.entity.EnderDragon) dragon.getBukkitEntity(), (org.bukkit.entity.DragonFireball) dragonFireball.getBukkitEntity()).callEvent()) // Paper - EnderDragon Events - this.dragon.level().addFreshEntity(dragonFireball); + world.addFreshEntity(dragonFireball); + else dragonFireball.discard(null); // Paper - EnderDragon Events this.fireballCharge = 0; if (this.currentPath != null) { diff --git a/patches/server/Expand-Explosions-API.patch b/patches/server/Expand-Explosions-API.patch new file mode 100644 index 0000000000..1442415b83 --- /dev/null +++ b/patches/server/Expand-Explosions-API.patch @@ -0,0 +1,87 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Wed, 20 Jun 2018 23:17:24 -0400 +Subject: [PATCH] Expand Explosions API + +Add Entity as a Source capability, and add more API choices, and on Location. + +Co-authored-by: Esoteric Enderman <90862990+EsotericEnderman@users.noreply.github.com> +Co-authored-by: Bjarne Koll + +diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/level/ServerLevel.java ++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + } + + public ServerExplosion explode0(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Level.ExplosionInteraction world_a, ParticleOptions particleparam, ParticleOptions particleparam1, Holder holder) { ++ // Paper start - Allow explosions to damage source ++ return this.explode0(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, world_a, particleparam, particleparam1, holder, null); ++ } ++ public ServerExplosion explode0(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Level.ExplosionInteraction world_a, ParticleOptions particleparam, ParticleOptions particleparam1, Holder holder, java.util.function.Consumer configurator) { ++ // Paper end - Allow explosions to damage source + // CraftBukkit end + Explosion.BlockInteraction explosion_effect; + +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + Explosion.BlockInteraction explosion_effect1 = explosion_effect; + Vec3 vec3d = new Vec3(d0, d1, d2); + ServerExplosion serverexplosion = new ServerExplosion(this, entity, damagesource, explosiondamagecalculator, vec3d, f, flag, explosion_effect1); ++ if (configurator != null) configurator.accept(serverexplosion);// Paper - Allow explosions to damage source + + serverexplosion.explode(); + // CraftBukkit start +diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/ServerExplosion.java ++++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java +@@ -0,0 +0,0 @@ public class ServerExplosion implements Explosion { + public boolean wasCanceled = false; + public float yield; + // CraftBukkit end ++ public boolean excludeSourceFromDamage = true; // Paper - Allow explosions to damage source + + public ServerExplosion(ServerLevel world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, Vec3 pos, float power, boolean createFire, Explosion.BlockInteraction destructionType) { + this.level = world; +@@ -0,0 +0,0 @@ public class ServerExplosion implements Explosion { + int l = Mth.floor(this.center.y + (double) f + 1.0D); + int i1 = Mth.floor(this.center.z - (double) f - 1.0D); + int j1 = Mth.floor(this.center.z + (double) f + 1.0D); +- List list = this.level.getEntities(this.source, new AABB((double) i, (double) k, (double) i1, (double) j, (double) l, (double) j1), (com.google.common.base.Predicate) entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities ++ List list = this.level.getEntities(excludeSourceFromDamage ? this.source : null, new AABB((double) i, (double) k, (double) i1, (double) j, (double) l, (double) j1), (com.google.common.base.Predicate) entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) { +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { + + @Override + public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source) { ++ // Paper start - expand explosion API ++ return this.createExplosion(x, y, z, power, setFire, breakBlocks, source, null); ++ } ++ public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source, Consumer configurator) { ++ // Paper end - expand explosion API + net.minecraft.world.level.Level.ExplosionInteraction explosionType; + if (!breakBlocks) { + explosionType = net.minecraft.world.level.Level.ExplosionInteraction.NONE; // Don't break blocks +@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { + } + + net.minecraft.world.entity.Entity entity = (source == null) ? null : ((CraftEntity) source).getHandle(); +- return !this.world.explode0(entity, Explosion.getDefaultDamageSource(this.world, entity), null, x, y, z, power, setFire, explosionType, ParticleTypes.EXPLOSION, ParticleTypes.EXPLOSION_EMITTER, SoundEvents.GENERIC_EXPLODE).wasCanceled; ++ return !this.world.explode0(entity, Explosion.getDefaultDamageSource(this.world, entity), null, x, y, z, power, setFire, explosionType, ParticleTypes.EXPLOSION, ParticleTypes.EXPLOSION_EMITTER, SoundEvents.GENERIC_EXPLODE, configurator).wasCanceled; // Paper - expand explosion API + } ++ // Paper start ++ @Override ++ public boolean createExplosion(Entity source, Location loc, float power, boolean setFire, boolean breakBlocks, boolean excludeSourceFromDamage) { ++ return this.createExplosion(loc.x(), loc.getY(), loc.getZ(), power, setFire, breakBlocks, source, e -> e.excludeSourceFromDamage = excludeSourceFromDamage); ++ } ++ // Paper end + + @Override + public boolean createExplosion(Location loc, float power) { diff --git a/patches/unapplied/server/Implement-World.getEntity-UUID-API.patch b/patches/server/Implement-World.getEntity-UUID-API.patch similarity index 100% rename from patches/unapplied/server/Implement-World.getEntity-UUID-API.patch rename to patches/server/Implement-World.getEntity-UUID-API.patch diff --git a/patches/unapplied/server/InventoryCloseEvent-Reason-API.patch b/patches/server/InventoryCloseEvent-Reason-API.patch similarity index 99% rename from patches/unapplied/server/InventoryCloseEvent-Reason-API.patch rename to patches/server/InventoryCloseEvent-Reason-API.patch index cbebea7f83..3fad3484bb 100644 --- a/patches/unapplied/server/InventoryCloseEvent-Reason-API.patch +++ b/patches/server/InventoryCloseEvent-Reason-API.patch @@ -10,7 +10,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/mai index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe for (net.minecraft.world.level.block.entity.BlockEntity tileentity : chunk.getBlockEntities().values()) { if (tileentity instanceof net.minecraft.world.Container) { for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((net.minecraft.world.Container) tileentity).getViewers())) { @@ -19,7 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } } -@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Spigot Start if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((org.bukkit.inventory.InventoryHolder) entity.getBukkitEntity()).getInventory().getViewers())) { diff --git a/patches/unapplied/server/LivingEntity-Active-Item-API.patch b/patches/server/LivingEntity-Active-Item-API.patch similarity index 100% rename from patches/unapplied/server/LivingEntity-Active-Item-API.patch rename to patches/server/LivingEntity-Active-Item-API.patch diff --git a/patches/unapplied/server/PlayerReadyArrowEvent.patch b/patches/server/PlayerReadyArrowEvent.patch similarity index 100% rename from patches/unapplied/server/PlayerReadyArrowEvent.patch rename to patches/server/PlayerReadyArrowEvent.patch diff --git a/patches/unapplied/server/RangedEntity-API.patch b/patches/server/RangedEntity-API.patch similarity index 100% rename from patches/unapplied/server/RangedEntity-API.patch rename to patches/server/RangedEntity-API.patch diff --git a/patches/unapplied/server/Vex-get-setSummoner-API.patch b/patches/server/Vex-get-setSummoner-API.patch similarity index 100% rename from patches/unapplied/server/Vex-get-setSummoner-API.patch rename to patches/server/Vex-get-setSummoner-API.patch diff --git a/patches/unapplied/server/add-more-information-to-Entity.toString.patch b/patches/server/add-more-information-to-Entity.toString.patch similarity index 96% rename from patches/unapplied/server/add-more-information-to-Entity.toString.patch rename to patches/server/add-more-information-to-Entity.toString.patch index dae89bf42a..3e86131d52 100644 --- a/patches/unapplied/server/add-more-information-to-Entity.toString.patch +++ b/patches/server/add-more-information-to-Entity.toString.patch @@ -17,4 +17,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return this.removalReason != null ? String.format(Locale.ROOT, "%s['%s'/%d, uuid='%s', l='%s', x=%.2f, y=%.2f, z=%.2f, cpos=%s, tl=%d, v=%b, removed=%s]", this.getClass().getSimpleName(), this.getName().getString(), this.id, this.uuid, s, this.getX(), this.getY(), this.getZ(), this.chunkPosition(), this.tickCount, this.valid, this.removalReason) : String.format(Locale.ROOT, "%s['%s'/%d, uuid='%s', l='%s', x=%.2f, y=%.2f, z=%.2f, cpos=%s, tl=%d, v=%b]", this.getClass().getSimpleName(), this.getName().getString(), this.id, this.uuid, s, this.getX(), this.getY(), this.getZ(), this.chunkPosition(), this.tickCount, this.valid); // Paper - add more info } - public boolean isInvulnerableTo(DamageSource damageSource) { + public final boolean isInvulnerableToBase(DamageSource damageSource) { diff --git a/patches/unapplied/server/Expand-Explosions-API.patch b/patches/unapplied/server/Expand-Explosions-API.patch deleted file mode 100644 index 0eae1dbf44..0000000000 --- a/patches/unapplied/server/Expand-Explosions-API.patch +++ /dev/null @@ -1,116 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Wed, 20 Jun 2018 23:17:24 -0400 -Subject: [PATCH] Expand Explosions API - -Add Entity as a Source capability, and add more API choices, and on Location. - -Co-authored-by: Esoteric Enderman <90862990+EsotericEnderman@users.noreply.github.com> -Co-authored-by: Bjarne Koll - -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { - } - - @Override -- public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType, ParticleOptions particle, ParticleOptions emitterParticle, Holder soundEvent) { -- Explosion explosion = this.explode(entity, damageSource, behavior, x, y, z, power, createFire, explosionSourceType, false, particle, emitterParticle, soundEvent); -+ // Paper start - Allow explosions to damage source -+ public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType, ParticleOptions particle, ParticleOptions emitterParticle, Holder soundEvent, java.util.function.Consumer configurator) { -+ Explosion explosion = this.explode(entity, damageSource, behavior, x, y, z, power, createFire, explosionSourceType, false, particle, emitterParticle, soundEvent, configurator); -+ // Paper end - Allow explosions to damage source - // CraftBukkit start - if (explosion.wasCanceled) { - return explosion; -diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/Explosion.java -+++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -0,0 +0,0 @@ public class Explosion { - public boolean wasCanceled = false; - public float yield; - // CraftBukkit end -+ public boolean excludeSourceFromDamage = true; // Paper - Allow explosions to damage source - - public static DamageSource getDefaultDamageSource(Level world, @Nullable Entity source) { - return world.damageSources().explosion(source, Explosion.getIndirectSourceEntityInternal(source)); -@@ -0,0 +0,0 @@ public class Explosion { - int i1 = Mth.floor(this.y + (double) f2 + 1.0D); - int j1 = Mth.floor(this.z - (double) f2 - 1.0D); - int k1 = Mth.floor(this.z + (double) f2 + 1.0D); -- List list = this.level.getEntities(this.source, new AABB((double) i, (double) l, (double) j1, (double) j, (double) i1, (double) k1), (com.google.common.base.Predicate) entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities -+ List list = this.level.getEntities(excludeSourceFromDamage ? this.source : null, new AABB((double) i, (double) l, (double) j1, (double) j, (double) i1, (double) k1), (com.google.common.base.Predicate) entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source - Vec3 vec3d = new Vec3(this.x, this.y, this.z); - Iterator iterator = list.iterator(); - -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - } - - public Explosion explode(@Nullable Entity entity, double x, double y, double z, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType) { -- return this.explode(entity, Explosion.getDefaultDamageSource(this, entity), (ExplosionDamageCalculator) null, x, y, z, power, createFire, explosionSourceType, ParticleTypes.EXPLOSION, ParticleTypes.EXPLOSION_EMITTER, SoundEvents.GENERIC_EXPLODE); -+ // Paper start - Allow explosions to damage source -+ return this.explode(entity, x, y, z, power, createFire, explosionSourceType, null); -+ } -+ public Explosion explode(@Nullable Entity entity, double x, double y, double z, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType, @Nullable Consumer configurator) { -+ return this.explode(entity, Explosion.getDefaultDamageSource(this, entity), (ExplosionDamageCalculator) null, x, y, z, power, createFire, explosionSourceType, ParticleTypes.EXPLOSION, ParticleTypes.EXPLOSION_EMITTER, SoundEvents.GENERIC_EXPLODE, configurator); -+ // Paper end - Allow explosions to damage source - } - - public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, Vec3 pos, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType) { -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - } - - public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType, ParticleOptions particle, ParticleOptions emitterParticle, Holder soundEvent) { -- return this.explode(entity, damageSource, behavior, x, y, z, power, createFire, explosionSourceType, true, particle, emitterParticle, soundEvent); -+ // Paper start - Allow explosions to damage source -+ return this.explode(entity, damageSource, behavior, x, y, z, power, createFire, explosionSourceType, particle, emitterParticle, soundEvent, null); -+ } -+ -+ public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType, ParticleOptions particle, ParticleOptions emitterParticle, Holder soundEvent, @Nullable Consumer configurator) { -+ return this.explode(entity, damageSource, behavior, x, y, z, power, createFire, explosionSourceType, true, particle, emitterParticle, soundEvent, configurator); -+ // Paper end - Allow explosions to damage source - } - - public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType, boolean particles, ParticleOptions particle, ParticleOptions emitterParticle, Holder soundEvent) { -+ // Paper start - Allow explosions to damage source -+ return this.explode(entity, damageSource, behavior, x, y, z, power, createFire, explosionSourceType, particle, emitterParticle, soundEvent, null); -+ } -+ public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType, boolean particles, ParticleOptions particle, ParticleOptions emitterParticle, Holder soundEvent, @Nullable Consumer configurator) { -+ // Paper end - Allow explosions to damage source - Explosion.BlockInteraction explosion_effect; - - switch (explosionSourceType.ordinal()) { -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - - Explosion.BlockInteraction explosion_effect1 = explosion_effect; - Explosion explosion = new Explosion(this, entity, damageSource, behavior, x, y, z, power, createFire, explosion_effect1, particle, emitterParticle, soundEvent); -+ if (configurator != null) configurator.accept(explosion); // Paper - Allow explosions to damage source - - explosion.explode(); - explosion.finalizeExplosion(particles); -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { - - return !this.world.explode(source == null ? null : ((CraftEntity) source).getHandle(), x, y, z, power, setFire, explosionType).wasCanceled; - } -+ // Paper start -+ @Override -+ public boolean createExplosion(Entity source, Location loc, float power, boolean setFire, boolean breakBlocks, boolean excludeSourceFromDamage) { -+ return !world.explode(source != null ? ((org.bukkit.craftbukkit.entity.CraftEntity) source).getHandle() : null, loc.getX(), loc.getY(), loc.getZ(), power, setFire, breakBlocks ? net.minecraft.world.level.Level.ExplosionInteraction.MOB : net.minecraft.world.level.Level.ExplosionInteraction.NONE, explosion -> { -+ explosion.excludeSourceFromDamage = excludeSourceFromDamage; -+ }).wasCanceled; -+ } -+ // Paper end - - @Override - public boolean createExplosion(Location loc, float power) {