From ed2f6b4efc9aba0f28679de57a564b5120378d2f Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Mon, 27 Feb 2023 20:34:19 +1100 Subject: [PATCH] #1142: Calculate explosion damage separately for each affected EntityComplexPart Currently the Ender Dragon takes roughly 3x the explosion damage when compared to vanilla 1.19.3. This is caused by a single damage value being calculated for the EntityEnderDragon and then being uniformly applied to every EntityComplexPart belonging to that dragon. This is resolved by restoring the vanilla behavior of calculating explosion damage separately for each EntityComplexPart. By: Jacob Martin --- .../net/minecraft/world/level/Explosion.patch | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch b/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch index 236663e05..4974f7b1b 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/Explosion.patch @@ -45,7 +45,7 @@ this.level.gameEvent(this.source, GameEvent.EXPLODE, new Vec3D(this.x, this.y, this.z)); Set set = Sets.newHashSet(); boolean flag = true; -@@ -211,7 +226,36 @@ +@@ -211,7 +226,39 @@ double d12 = (double) getSeenPercent(vec3d, entity); double d13 = (1.0D - d7) * d12; @@ -67,8 +67,11 @@ + + if (entity instanceof EntityEnderDragon) { + for (EntityComplexPart entityComplexPart : ((EntityEnderDragon) entity).subEntities) { -+ if (list.contains(entityComplexPart)) { -+ entityComplexPart.hurt(this.getDamageSource(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f2 + 1.0D))); ++ // Calculate damage separately for each EntityComplexPart ++ double d7part; ++ if (list.contains(entityComplexPart) && (d7part = Math.sqrt(entityComplexPart.distanceToSqr(vec3d)) / f2) <= 1.0D) { ++ double d13part = (1.0D - d7part) * getSeenPercent(vec3d, entityComplexPart); ++ entityComplexPart.hurt(this.getDamageSource(), (float) ((int) ((d13part * d13part + d13part) / 2.0D * 7.0D * (double) f2 + 1.0D))); + } + } + } else { @@ -83,7 +86,7 @@ double d14 = d13; if (entity instanceof EntityLiving) { -@@ -254,6 +298,51 @@ +@@ -254,6 +301,51 @@ SystemUtils.shuffle(this.toBlow, this.level.random); ObjectListIterator objectlistiterator = this.toBlow.iterator(); @@ -135,7 +138,7 @@ while (objectlistiterator.hasNext()) { BlockPosition blockposition = (BlockPosition) objectlistiterator.next(); -@@ -272,8 +361,8 @@ +@@ -272,8 +364,8 @@ TileEntity tileentity = iblockdata.hasBlockEntity() ? this.level.getBlockEntity(blockposition) : null; LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder(worldserver)).withRandom(this.level.random).withParameter(LootContextParameters.ORIGIN, Vec3D.atCenterOf(blockposition)).withParameter(LootContextParameters.TOOL, ItemStack.EMPTY).withOptionalParameter(LootContextParameters.BLOCK_ENTITY, tileentity).withOptionalParameter(LootContextParameters.THIS_ENTITY, this.source); @@ -146,7 +149,7 @@ } iblockdata.spawnAfterBreak(worldserver, blockposition, ItemStack.EMPTY, flag2); -@@ -305,7 +394,11 @@ +@@ -305,7 +397,11 @@ BlockPosition blockposition2 = (BlockPosition) objectlistiterator1.next(); if (this.random.nextInt(3) == 0 && this.level.getBlockState(blockposition2).isAir() && this.level.getBlockState(blockposition2.below()).isSolidRender(this.level, blockposition2.below())) { @@ -159,7 +162,7 @@ } } } -@@ -317,6 +410,7 @@ +@@ -317,6 +413,7 @@ } private static void addBlockDrops(ObjectArrayList> objectarraylist, ItemStack itemstack, BlockPosition blockposition) {