diff options
author | Esoteric Enderman <[email protected]> | 2024-09-28 20:32:56 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-09-28 21:32:56 +0200 |
commit | 355b1cbaf6f0d6331476cb6e45291da647493dd1 (patch) | |
tree | 7c9976e61893fac5d41106a31513f6653ccf1947 /patches/server/0981-Moonrise-optimisation-patches.patch | |
parent | 7b031414984efcfe74e9aeb9db10a78e7af63b1a (diff) | |
download | Paper-355b1cbaf6f0d6331476cb6e45291da647493dd1.tar.gz Paper-355b1cbaf6f0d6331476cb6e45291da647493dd1.zip |
Add API for explosions to damage the explosion cause (#11180)
This intends to give plugin developers more control over explosions created using the World#createExplosion method, specifically by adding the option for explosions to damage the explosion cause (not the default behavior, and previously impossible to do, as far as I know). This is done by overloading existing methods with an extra `excludeSourceFromDamage` parameter.
Co-authored-by: Bjarne Koll <[email protected]>
Diffstat (limited to 'patches/server/0981-Moonrise-optimisation-patches.patch')
-rw-r--r-- | patches/server/0981-Moonrise-optimisation-patches.patch | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/patches/server/0981-Moonrise-optimisation-patches.patch b/patches/server/0981-Moonrise-optimisation-patches.patch index 4305cb9755..0e81124113 100644 --- a/patches/server/0981-Moonrise-optimisation-patches.patch +++ b/patches/server/0981-Moonrise-optimisation-patches.patch @@ -25574,7 +25574,7 @@ index 1d849ce4e2c85f149af25318b8ffb6dcef6c6788..12d86f27d04bffed8c3844e36b42fbc2 if (!list.equals(this.lastPassengers)) { diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 81f0a0dfefd9e1698548a68679dab0974921c37a..24d5e741aed1677d0df59c1455fbfc60a29e8e3c 100644 +index 342682178950c8986fb3c86924811089f4de887d..f910e37a8e7cd0358c149d84bafd941126a0b0f4 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -184,7 +184,7 @@ import org.bukkit.event.weather.LightningStrikeEvent; @@ -26106,7 +26106,7 @@ index 81f0a0dfefd9e1698548a68679dab0974921c37a..24d5e741aed1677d0df59c1455fbfc60 return false; } else { this.addFreshEntityWithPassengers(entity, reason); // CraftBukkit -@@ -1850,7 +2056,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1852,7 +2058,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } } @@ -26115,7 +26115,7 @@ index 81f0a0dfefd9e1698548a68679dab0974921c37a..24d5e741aed1677d0df59c1455fbfc60 bufferedwriter.write(String.format(Locale.ROOT, "block_entity_tickers: %d\n", this.blockEntityTickers.size())); bufferedwriter.write(String.format(Locale.ROOT, "block_ticks: %d\n", this.getBlockTicks().count())); bufferedwriter.write(String.format(Locale.ROOT, "fluid_ticks: %d\n", this.getFluidTicks().count())); -@@ -1899,7 +2105,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1901,7 +2107,7 @@ public class ServerLevel extends Level implements WorldGenLevel { BufferedWriter bufferedwriter2 = Files.newBufferedWriter(path1); try { @@ -26124,7 +26124,7 @@ index 81f0a0dfefd9e1698548a68679dab0974921c37a..24d5e741aed1677d0df59c1455fbfc60 } catch (Throwable throwable4) { if (bufferedwriter2 != null) { try { -@@ -1920,7 +2126,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1922,7 +2128,7 @@ public class ServerLevel extends Level implements WorldGenLevel { BufferedWriter bufferedwriter3 = Files.newBufferedWriter(path2); try { @@ -26133,7 +26133,7 @@ index 81f0a0dfefd9e1698548a68679dab0974921c37a..24d5e741aed1677d0df59c1455fbfc60 } catch (Throwable throwable6) { if (bufferedwriter3 != null) { try { -@@ -2062,7 +2268,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2064,7 +2270,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @VisibleForTesting public String getWatchdogStats() { @@ -26142,7 +26142,7 @@ index 81f0a0dfefd9e1698548a68679dab0974921c37a..24d5e741aed1677d0df59c1455fbfc60 return BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString(); }), this.blockEntityTickers.size(), ServerLevel.getTypeCount(this.blockEntityTickers, TickingBlockEntity::getType), this.getBlockTicks().count(), this.getFluidTicks().count(), this.gatherChunkSourceStats()); } -@@ -2092,15 +2298,25 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2094,15 +2300,25 @@ public class ServerLevel extends Level implements WorldGenLevel { @Override public LevelEntityGetter<Entity> getEntities() { org.spigotmc.AsyncCatcher.catchOp("Chunk getEntities call"); // Spigot @@ -26171,7 +26171,7 @@ index 81f0a0dfefd9e1698548a68679dab0974921c37a..24d5e741aed1677d0df59c1455fbfc60 } public void startTickingChunk(LevelChunk chunk) { -@@ -2120,34 +2336,47 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2122,34 +2338,47 @@ public class ServerLevel extends Level implements WorldGenLevel { @Override public void close() throws IOException { super.close(); @@ -26226,7 +26226,7 @@ index 81f0a0dfefd9e1698548a68679dab0974921c37a..24d5e741aed1677d0df59c1455fbfc60 } @Override -@@ -2173,7 +2402,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2175,7 +2404,7 @@ public class ServerLevel extends Level implements WorldGenLevel { CrashReportCategory crashreportsystemdetails = super.fillReportDetails(report); crashreportsystemdetails.setDetail("Loaded entity count", () -> { @@ -27715,12 +27715,12 @@ index bd20bea7f76a7307f1698fb2dfef37125032d166..141b748abe80402731cdaf14a3d36aa7 // Paper start - Affects Spawning API diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index b70ac21d8dc70fb1513ea7ce5270fb381552c29a..ad57bf49476192dea6a7367cbd0ad3f11e142e1b 100644 +index 2109257fde8606abda4f41427f690da3b96c0175..f696afd7e241bf1966a2d505b5d59bff824b43e4 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -75,6 +75,247 @@ public class Explosion { - public float yield; +@@ -76,6 +76,247 @@ public class Explosion { // CraftBukkit end + public boolean excludeSourceFromDamage = true; // Paper - Allow explosions to damage source + // Paper start - optimise collisions + private static final double[] CACHED_RAYS; @@ -27966,7 +27966,7 @@ index b70ac21d8dc70fb1513ea7ce5270fb381552c29a..ad57bf49476192dea6a7367cbd0ad3f1 public static DamageSource getDefaultDamageSource(Level world, @Nullable Entity source) { return world.damageSources().explosion(source, Explosion.getIndirectSourceEntityInternal(source)); } -@@ -167,68 +408,107 @@ public class Explosion { +@@ -168,68 +409,107 @@ public class Explosion { } // CraftBukkit end this.level.gameEvent(this.source, (Holder) GameEvent.EXPLODE, new Vec3(this.x, this.y, this.z)); @@ -28122,7 +28122,7 @@ index b70ac21d8dc70fb1513ea7ce5270fb381552c29a..ad57bf49476192dea6a7367cbd0ad3f1 float f2 = this.radius * 2.0F; i = Mth.floor(this.x - (double) f2 - 1.0D); -@@ -241,6 +521,10 @@ public class Explosion { +@@ -242,6 +522,10 @@ public class Explosion { Vec3 vec3d = new Vec3(this.x, this.y, this.z); Iterator iterator = list.iterator(); @@ -28133,7 +28133,7 @@ index b70ac21d8dc70fb1513ea7ce5270fb381552c29a..ad57bf49476192dea6a7367cbd0ad3f1 while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); -@@ -257,6 +541,7 @@ public class Explosion { +@@ -258,6 +542,7 @@ public class Explosion { d8 /= d11; d9 /= d11; d10 /= d11; @@ -28141,7 +28141,7 @@ index b70ac21d8dc70fb1513ea7ce5270fb381552c29a..ad57bf49476192dea6a7367cbd0ad3f1 if (this.damageCalculator.shouldDamageEntity(this, entity)) { // CraftBukkit start -@@ -272,6 +557,8 @@ public class Explosion { +@@ -273,6 +558,8 @@ public class Explosion { entity.lastDamageCancelled = false; @@ -28150,7 +28150,7 @@ index b70ac21d8dc70fb1513ea7ce5270fb381552c29a..ad57bf49476192dea6a7367cbd0ad3f1 if (entity instanceof EnderDragon) { for (EnderDragonPart entityComplexPart : ((EnderDragon) entity).subEntities) { // Calculate damage separately for each EntityComplexPart -@@ -280,16 +567,21 @@ public class Explosion { +@@ -281,16 +568,21 @@ public class Explosion { } } } else { @@ -28175,7 +28175,7 @@ index b70ac21d8dc70fb1513ea7ce5270fb381552c29a..ad57bf49476192dea6a7367cbd0ad3f1 double d13; if (entity instanceof LivingEntity) { -@@ -327,7 +619,11 @@ public class Explosion { +@@ -328,7 +620,11 @@ public class Explosion { } } } @@ -28188,7 +28188,7 @@ index b70ac21d8dc70fb1513ea7ce5270fb381552c29a..ad57bf49476192dea6a7367cbd0ad3f1 } public void finalizeExplosion(boolean particles) { -@@ -544,14 +840,14 @@ public class Explosion { +@@ -545,14 +841,14 @@ public class Explosion { private BlockInteraction() {} } // Paper start - Optimize explosions @@ -28207,7 +28207,7 @@ index b70ac21d8dc70fb1513ea7ce5270fb381552c29a..ad57bf49476192dea6a7367cbd0ad3f1 } diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index e5abde76c354c3dd9940dd4e5ae3fe8b6a2b4680..347334130e99dbf938d570bd36440a96f92d475a 100644 +index 16e721ac80ba21511bdeccfccd055f7700bda61f..7a592a3c5491fc19ab33287e1e60b869a618497c 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -81,6 +81,7 @@ import net.minecraft.world.level.storage.LevelData; @@ -28775,7 +28775,7 @@ index e5abde76c354c3dd9940dd4e5ae3fe8b6a2b4680..347334130e99dbf938d570bd36440a96 } // Paper end - Option to prevent armor stands from doing entity lookups -@@ -949,7 +1447,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -966,7 +1464,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } // Paper end - Perf: Optimize capturedTileEntities lookup // CraftBukkit end @@ -28784,7 +28784,7 @@ index e5abde76c354c3dd9940dd4e5ae3fe8b6a2b4680..347334130e99dbf938d570bd36440a96 } public void setBlockEntity(BlockEntity blockEntity) { -@@ -1039,28 +1537,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1056,28 +1554,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Override public List<Entity> getEntities(@Nullable Entity except, AABB box, Predicate<? super Entity> predicate) { this.getProfiler().incrementCounter("getEntities"); @@ -28818,7 +28818,7 @@ index e5abde76c354c3dd9940dd4e5ae3fe8b6a2b4680..347334130e99dbf938d570bd36440a96 } @Override -@@ -1075,36 +1558,77 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1092,36 +1575,77 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.getEntities(filter, box, predicate, result, Integer.MAX_VALUE); } @@ -32762,7 +32762,7 @@ index df15ce8d1da2737e339880d3d2f6731e0b92ca7f..b5644700878a3eda50a56cd2292c6ceb // Paper start - Adventure diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 50b84939eee044ddadca046079286a72de5c8e04..15e075fc3a9b18e62e04f41fcadbe62e05cd8c79 100644 +index e8404d5bad60b8fa290f334d3c64ee5503e01e5c..65c77bce55121c95bf2264e9058af73bcf22fc4b 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -461,10 +461,14 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -32824,7 +32824,7 @@ index 50b84939eee044ddadca046079286a72de5c8e04..15e075fc3a9b18e62e04f41fcadbe62e long chunkKey = chunkTickets.getLongKey(); SortedArraySet<Ticket<?>> tickets = chunkTickets.getValue(); -@@ -1295,12 +1286,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1297,12 +1288,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getViewDistance() { @@ -32839,7 +32839,7 @@ index 50b84939eee044ddadca046079286a72de5c8e04..15e075fc3a9b18e62e04f41fcadbe62e } public BlockMetadataStore getBlockMetadata() { -@@ -2438,17 +2429,20 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2440,17 +2431,20 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setSimulationDistance(final int simulationDistance) { |