diff --git a/patches/server/0020-Optimised-Explosions.patch b/patches/server/0020-Optimised-Explosions.patch index 1687dab..dfb202f 100644 --- a/patches/server/0020-Optimised-Explosions.patch +++ b/patches/server/0020-Optimised-Explosions.patch @@ -142,7 +142,7 @@ index 0000000000000000000000000000000000000000..5c6d4124189d98421e2d6f351840c5d6 +} diff --git a/src/main/java/me/samsuik/sakura/explosion/SakuraExplosion.java b/src/main/java/me/samsuik/sakura/explosion/SakuraExplosion.java new file mode 100644 -index 0000000000000000000000000000000000000000..1819b24c90b4e58487cacce5eb0b3ee21c5a8f83 +index 0000000000000000000000000000000000000000..cecc88aa129e201ebe85f7ca9cfd73bc25f2f902 --- /dev/null +++ b/src/main/java/me/samsuik/sakura/explosion/SakuraExplosion.java @@ -0,0 +1,405 @@ @@ -286,14 +286,14 @@ index 0000000000000000000000000000000000000000..1819b24c90b4e58487cacce5eb0b3ee2 + } + + // The purpose of this is to make sure papers blockCache doesn't become outdated -+ // by flushing the map and removing stale entries from the recent cache array. -+ if (!foundBlocks.isEmpty()) { -+ if (getToBlow().isEmpty()) { -+ cleanBlockCache(foundBlocks); -+ } else { -+ invalidateBlockCache(blockCache, foundBlocks); -+ } ++ // by removing stale entries from the block cache map and the recent cache array. ++ if (!foundBlocks.isEmpty() && getToBlow().isEmpty()) { ++ markBlocksInCacheAsExplodable(foundBlocks); ++ } else { ++ this.blockCache.clear(); + } ++ ++ java.util.Arrays.fill(blockCache, null); + } + } + @@ -680,7 +680,7 @@ index ed0234d6a2718d35af635c4b74243bb2afd40769..2800af98260ebdab107466c596d2ec8c @Override diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 39c30a295df9dfbc3c861f1678a958ef2ed2ba93..e9d6c126b236cb0e29765e7febb52ba14f3b8c61 100644 +index 39c30a295df9dfbc3c861f1678a958ef2ed2ba93..a30bc7ed6b0ea1787ef9bf320a834e6d407762a4 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java @@ -55,14 +55,16 @@ public class Explosion { @@ -769,7 +769,7 @@ index 39c30a295df9dfbc3c861f1678a958ef2ed2ba93..e9d6c126b236cb0e29765e7febb52ba1 ++missedRays; } } -@@ -375,12 +388,80 @@ public class Explosion { +@@ -375,12 +388,67 @@ public class Explosion { return (float)missedRays / (float)totalRays; } // Paper end - optimise collisions @@ -791,29 +791,16 @@ index 39c30a295df9dfbc3c861f1678a958ef2ed2ba93..e9d6c126b236cb0e29765e7febb52ba1 + this.chunkCache = null; // Paper - optimise explosions + } + -+ protected void cleanBlockCache(List blocks) { ++ protected void markBlocksInCacheAsExplodable(List blocks) { + for (BlockPos blow : blocks) { + ExplosionBlockCache cache = blockCache.get(blow.asLong()); -+ // May be null if the cache is invalidated then retrieved from the ExplosionBlockCache[] ++ // May be null if the blockCache is cleared then retrieved from the recent cache + if (cache != null) { + cache.shouldExplode = null; + } + } + } + -+ protected void invalidateBlockCache(ExplosionBlockCache[] blockCaches, List blocks) { -+ for (BlockPos blow : blocks) { -+ final int cacheKey = -+ (blow.getX() & BLOCK_EXPLOSION_CACHE_MASK) | -+ (blow.getY() & BLOCK_EXPLOSION_CACHE_MASK) << (BLOCK_EXPLOSION_CACHE_SHIFT) | -+ (blow.getZ() & BLOCK_EXPLOSION_CACHE_MASK) << (BLOCK_EXPLOSION_CACHE_SHIFT + BLOCK_EXPLOSION_CACHE_SHIFT); -+ -+ blockCaches[cacheKey] = null; -+ } -+ -+ blockCache.clear(); -+ } -+ + protected boolean isDestructibleBlock(@Nullable BlockState state) { + if (state == null) { + return false; @@ -851,7 +838,7 @@ index 39c30a295df9dfbc3c861f1678a958ef2ed2ba93..e9d6c126b236cb0e29765e7febb52ba1 AABB axisalignedbb = entity.getBoundingBox(); double d0 = 1.0D / ((axisalignedbb.maxX - axisalignedbb.minX) * 2.0D + 1.0D); double d1 = 1.0D / ((axisalignedbb.maxY - axisalignedbb.minY) * 2.0D + 1.0D); -@@ -400,7 +481,11 @@ public class Explosion { +@@ -400,7 +468,11 @@ public class Explosion { double d10 = Mth.lerp(d7, axisalignedbb.minZ, axisalignedbb.maxZ); Vec3 vec3d1 = new Vec3(d8 + d3, d9, d10 + d4); @@ -864,7 +851,7 @@ index 39c30a295df9dfbc3c861f1678a958ef2ed2ba93..e9d6c126b236cb0e29765e7febb52ba1 ++i; } -@@ -429,7 +514,29 @@ public class Explosion { +@@ -429,7 +501,29 @@ public class Explosion { return; } // CraftBukkit end @@ -894,7 +881,7 @@ index 39c30a295df9dfbc3c861f1678a958ef2ed2ba93..e9d6c126b236cb0e29765e7febb52ba1 Set set = Sets.newHashSet(); boolean flag = true; -@@ -437,14 +544,7 @@ public class Explosion { +@@ -437,14 +531,7 @@ public class Explosion { int j; // Paper start - optimise explosions @@ -910,7 +897,7 @@ index 39c30a295df9dfbc3c861f1678a958ef2ed2ba93..e9d6c126b236cb0e29765e7febb52ba1 // use initial cache value that is most likely to be used: the source position final ExplosionBlockCache initialCache; { -@@ -541,10 +641,15 @@ public class Explosion { +@@ -541,10 +628,15 @@ public class Explosion { } this.toBlow.addAll(set); @@ -928,7 +915,7 @@ index 39c30a295df9dfbc3c861f1678a958ef2ed2ba93..e9d6c126b236cb0e29765e7febb52ba1 int l = Mth.floor(this.y - (double) f2 - 1.0D); int i1 = Mth.floor(this.y + (double) f2 + 1.0D); int j1 = Mth.floor(this.z - (double) f2 - 1.0D); -@@ -590,11 +695,11 @@ public class Explosion { +@@ -590,11 +682,11 @@ public class Explosion { for (EnderDragonPart entityComplexPart : ((EnderDragon) entity).subEntities) { // Calculate damage separately for each EntityComplexPart if (list.contains(entityComplexPart)) { @@ -942,7 +929,7 @@ index 39c30a295df9dfbc3c861f1678a958ef2ed2ba93..e9d6c126b236cb0e29765e7febb52ba1 } if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled -@@ -655,9 +760,7 @@ public class Explosion { +@@ -655,9 +747,7 @@ public class Explosion { } } @@ -953,7 +940,7 @@ index 39c30a295df9dfbc3c861f1678a958ef2ed2ba93..e9d6c126b236cb0e29765e7febb52ba1 } public void finalizeExplosion(boolean particles) { -@@ -725,6 +828,12 @@ public class Explosion { +@@ -725,6 +815,12 @@ public class Explosion { if (this.wasCanceled) { return; } @@ -966,7 +953,7 @@ index 39c30a295df9dfbc3c861f1678a958ef2ed2ba93..e9d6c126b236cb0e29765e7febb52ba1 // CraftBukkit end objectlistiterator = this.toBlow.iterator(); -@@ -871,15 +980,22 @@ public class Explosion { +@@ -871,15 +967,22 @@ public class Explosion { private BlockInteraction() {} } // Paper start - Optimize explosions diff --git a/patches/server/0030-Explosion-Durable-Blocks.patch b/patches/server/0030-Explosion-Durable-Blocks.patch index c463b29..f80ee81 100644 --- a/patches/server/0030-Explosion-Durable-Blocks.patch +++ b/patches/server/0030-Explosion-Durable-Blocks.patch @@ -124,7 +124,7 @@ index a8008c7550488be34b51f4280f5569170b1ebd1d..2e5a46b9d27b930870c68dbde93d8731 public String getDescriptionId() { return this.getOrCreateDescriptionId(); diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 87a61b091bb839460394e285e030244fd6140379..5b4286a53c0521c23fc4c36ecb5e53ca15dbfb15 100644 +index a30bc7ed6b0ea1787ef9bf320a834e6d407762a4..9a0716683709051b3c79d045e6db4bb5eeae464c 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java @@ -212,6 +212,17 @@ public class Explosion { @@ -145,7 +145,7 @@ index 87a61b091bb839460394e285e030244fd6140379..5b4286a53c0521c23fc4c36ecb5e53ca ret = new ExplosionBlockCache( key, pos, blockState, fluidState, (resistance.orElse(ZERO_RESISTANCE).floatValue() + 0.3f) * 0.3f, -@@ -842,6 +853,16 @@ public class Explosion { +@@ -829,6 +840,16 @@ public class Explosion { // CraftBukkit start - TNTPrimeEvent BlockState iblockdata = this.level.getBlockState(blockposition); Block block = iblockdata.getBlock(); @@ -163,7 +163,7 @@ index 87a61b091bb839460394e285e030244fd6140379..5b4286a53c0521c23fc4c36ecb5e53ca Entity sourceEntity = this.source == null ? null : this.source; BlockPos sourceBlock = sourceEntity == null ? BlockPos.containing(this.x, this.y, this.z) : null; diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 62916017bde1ea72ebdd75d71d4e98447971cdda..0ca2c48c3922f67d5ff2a50e15e86c44aae8e3f9 100644 +index 9eab0ad0357fed34ba474787b403be5c14394169..1077a7b696b093fa06d41085f51fb56732cdede2 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -231,6 +231,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { diff --git a/patches/server/0037-Consistent-Explosion-Radius.patch b/patches/server/0037-Consistent-Explosion-Radius.patch index 2aa148c..de00e44 100644 --- a/patches/server/0037-Consistent-Explosion-Radius.patch +++ b/patches/server/0037-Consistent-Explosion-Radius.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Consistent Explosion Radius diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 97bcc95563fcde50b7d13183f94d41b80128c70c..144c2c9c11c3df3c8a95e252458828154728f555 100644 +index 36990070ea39b16ed5b4cb7ec7fd31017dc86d2a..a1b5878567f1489419006306e26af4936983cc2a 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -590,7 +590,7 @@ public class Explosion { +@@ -577,7 +577,7 @@ public class Explosion { double d2 = CACHED_RAYS[ray + 2]; ray += 3; // Paper end - optimise explosions diff --git a/patches/server/0040-Configure-cannon-physics-by-version.patch b/patches/server/0040-Configure-cannon-physics-by-version.patch index 34847e5..0a96088 100644 --- a/patches/server/0040-Configure-cannon-physics-by-version.patch +++ b/patches/server/0040-Configure-cannon-physics-by-version.patch @@ -36,7 +36,7 @@ index 19086bbfdf3a015eafec5ca868c8d2451f554ef0..a40dcbde87860fd6d3b60d0b9e2d5e63 if (xSmaller && z != 0.0) { z = performAABBCollisionsZ(axisalignedbb, z, aabbs); diff --git a/src/main/java/me/samsuik/sakura/explosion/SakuraExplosion.java b/src/main/java/me/samsuik/sakura/explosion/SakuraExplosion.java -index fbdd4c4ec21cff4c9651402a9e94dd99996723e1..0dd7b5dcb59e9eee2af769cc0989d30cf231b490 100644 +index cecc88aa129e201ebe85f7ca9cfd73bc25f2f902..78b08a9557e9fd98251714dce9ba1180d5e1ce5a 100644 --- a/src/main/java/me/samsuik/sakura/explosion/SakuraExplosion.java +++ b/src/main/java/me/samsuik/sakura/explosion/SakuraExplosion.java @@ -167,7 +167,7 @@ public final class SakuraExplosion extends Explosion { @@ -458,7 +458,7 @@ index 19397e2556a3cdc7180a5f8889aefb5ef23715b7..26fc6a8018cfde3c219a7d828f743663 // Paper end - Option to prevent TNT from moving in water } diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 144c2c9c11c3df3c8a95e252458828154728f555..6adf7e5945dcf8d11b133c7497a2c1eea0990860 100644 +index a1b5878567f1489419006306e26af4936983cc2a..30666a0f35a9a8be47ecd2630389490508ba35fd 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java @@ -74,6 +74,7 @@ public class Explosion { @@ -477,7 +477,7 @@ index 144c2c9c11c3df3c8a95e252458828154728f555..6adf7e5945dcf8d11b133c7497a2c1ee } // Paper start - optimise collisions -@@ -499,9 +501,17 @@ public class Explosion { +@@ -486,9 +488,17 @@ public class Explosion { Vec3 vec3d1 = new Vec3(d8 + d3, d9, d10 + d4); // Sakura start @@ -497,7 +497,7 @@ index 144c2c9c11c3df3c8a95e252458828154728f555..6adf7e5945dcf8d11b133c7497a2c1ee // Sakura end ++i; } -@@ -615,6 +625,10 @@ public class Explosion { +@@ -602,6 +612,10 @@ public class Explosion { } if (cachedBlock.outOfWorld) { @@ -508,7 +508,7 @@ index 144c2c9c11c3df3c8a95e252458828154728f555..6adf7e5945dcf8d11b133c7497a2c1ee break; } -@@ -685,10 +699,17 @@ public class Explosion { +@@ -672,10 +686,17 @@ public class Explosion { if (d7 <= 1.0D) { double d8 = entity.getX() - this.x; @@ -527,7 +527,7 @@ index 144c2c9c11c3df3c8a95e252458828154728f555..6adf7e5945dcf8d11b133c7497a2c1ee if (d11 != 0.0D) { d8 /= d11; d9 /= d11; -@@ -1016,7 +1037,14 @@ public class Explosion { +@@ -1003,7 +1024,14 @@ public class Explosion { return data.density(); } @@ -544,7 +544,7 @@ index 144c2c9c11c3df3c8a95e252458828154728f555..6adf7e5945dcf8d11b133c7497a2c1ee if (data == null || !data.isExpandable() && (blockDensity == 0.0f || blockDensity == 1.0f)) { level.densityCache.createCache(key, entity, vec3d, blockDensity); diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 1db7ce24a7459b5509d2f420ed56f3b3b2c1ffe8..a93e22d81939cc7fa3247550da91bb39e6d5b111 100644 +index ebfdcadc3e2e28fb791afd3d5708df0bc0741464..e6b12380dbab67d930b761f4ab9f493f9e895024 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -266,6 +266,205 @@ public abstract class Level implements LevelAccessor, AutoCloseable { diff --git a/patches/server/0044-Allow-explosions-to-destroy-lava.patch b/patches/server/0044-Allow-explosions-to-destroy-lava.patch index 571f597..4dd1214 100644 --- a/patches/server/0044-Allow-explosions-to-destroy-lava.patch +++ b/patches/server/0044-Allow-explosions-to-destroy-lava.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Allow explosions to destroy lava diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 6adf7e5945dcf8d11b133c7497a2c1eea0990860..0b90b05bd538186f8f1d51376560dd6485fdce57 100644 +index 30666a0f35a9a8be47ecd2630389490508ba35fd..5369598d0f81eb44a7aed766ef4fe15eddb0b2c2 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java @@ -228,6 +228,10 @@ public class Explosion { @@ -19,7 +19,7 @@ index 6adf7e5945dcf8d11b133c7497a2c1eea0990860..0b90b05bd538186f8f1d51376560dd64 } // Sakura end - explosion durable blocks -@@ -453,6 +457,12 @@ public class Explosion { +@@ -440,6 +444,12 @@ public class Explosion { return false; } diff --git a/patches/server/0056-Add-explosions-dropping-items-config.patch b/patches/server/0056-Add-explosions-dropping-items-config.patch index ce9f63e..25fc3fb 100644 --- a/patches/server/0056-Add-explosions-dropping-items-config.patch +++ b/patches/server/0056-Add-explosions-dropping-items-config.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add explosions dropping items config diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 0b90b05bd538186f8f1d51376560dd6485fdce57..7d68fc98f2fe995391c57a220f7f5986aea07166 100644 +index 5369598d0f81eb44a7aed766ef4fe15eddb0b2c2..857316fe04acf0eed5046c6789ed8c7829bb5eb8 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -915,6 +915,12 @@ public class Explosion { +@@ -902,6 +902,12 @@ public class Explosion { }); }