From 1ad2569a6619a6b2041fa83234bfb7b120202911 Mon Sep 17 00:00:00 2001 From: MiniDigger | Martin Date: Thu, 5 Oct 2023 18:57:50 +0200 Subject: [PATCH] [ci skip] fix run dev --- build.gradle.kts | 6 +-- .../server/0003-Build-system-changes.patch | 8 +-- .../server/0018-Rewrite-chunk-system.patch | 34 ++++++------ patches/server/0342-Anti-Xray.patch | 23 ++++---- .../server/0727-Collision-optimisations.patch | 54 ++++++++++--------- 5 files changed, 66 insertions(+), 59 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f787dbc00ee2..0e0e38cd9ce4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -137,9 +137,9 @@ tasks.collectAtsFromPatches { } // Uncomment while updating for a new Minecraft version -tasks.withType { - filterPatches.set(false) -} +// tasks.withType { +// filterPatches.set(false) +// } tasks.register("printMinecraftVersion") { doLast { diff --git a/patches/server/0003-Build-system-changes.patch b/patches/server/0003-Build-system-changes.patch index ef01672983c9..10d8e9cd111b 100644 --- a/patches/server/0003-Build-system-changes.patch +++ b/patches/server/0003-Build-system-changes.patch @@ -9,7 +9,7 @@ public net.minecraft.server.packs.VanillaPackResourcesBuilder safeGetPath(Ljava/ Co-authored-by: Jake Potrebic diff --git a/build.gradle.kts b/build.gradle.kts -index beb19d5aa6cb60115cbd173b2a7f67769b4a367d..3a8b06b7cafb912cf1faecd219673afea2319815 100644 +index beb19d5aa6cb60115cbd173b2a7f67769b4a367d..34b1f3b634358c05668eb7401c8783546a1b89cc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,10 +9,9 @@ plugins { @@ -94,12 +94,12 @@ index beb19d5aa6cb60115cbd173b2a7f67769b4a367d..3a8b06b7cafb912cf1faecd219673afe tasks.registerRunTask("runDev") { description = "Spin up a non-relocated Mojang-mapped test server" - classpath(sourceSets.main.map { it.runtimeClasspath }) -+ classpath(tasks.filterProjectDir.flatMap { it.outputJar }) + classpath(runtimeClasspathForRunDev) ++ classpath(tasks.filterProjectDir.flatMap { it.outputJar }) + jvmArgs("-DPaper.isRunDev=true") } diff --git a/src/main/java/net/minecraft/resources/ResourceLocation.java b/src/main/java/net/minecraft/resources/ResourceLocation.java -index 68e3d54c79924d72b22eb3bc142ff47aa1700895..d3300e43523429fdd0e61c5aa9aed2e6bc78e07e 100644 +index 924e0552c4b60c6fbfe1aa659e201e5349d91e09..0185ea054848f9b400533e97ac0b9a49b81db980 100644 --- a/src/main/java/net/minecraft/resources/ResourceLocation.java +++ b/src/main/java/net/minecraft/resources/ResourceLocation.java @@ -26,6 +26,7 @@ public class ResourceLocation implements Comparable { @@ -133,7 +133,7 @@ index 84dab998d5b91b9c5690e9e086b17a60b6dec058..2ac60ea28ce722cdef61cfdc69bbbdf3 Path path = (Path) optionset.valueOf("pidFile"); // CraftBukkit diff --git a/src/main/java/net/minecraft/server/packs/repository/ServerPacksSource.java b/src/main/java/net/minecraft/server/packs/repository/ServerPacksSource.java -index 7db49f077704f03d1815f8382523199bd6c9a0dc..4ed8f38ba9c7b075b99a0da0e213a1e9d03ac717 100644 +index 61228abc3b0628732a4b9dbdf9827adb7a2fd8d8..1522706703392d74a92c964ded7206f7c469c20c 100644 --- a/src/main/java/net/minecraft/server/packs/repository/ServerPacksSource.java +++ b/src/main/java/net/minecraft/server/packs/repository/ServerPacksSource.java @@ -32,7 +32,7 @@ public class ServerPacksSource extends BuiltInPackSource { diff --git a/patches/server/0018-Rewrite-chunk-system.patch b/patches/server/0018-Rewrite-chunk-system.patch index edc653779b3f..f04ffa411abe 100644 --- a/patches/server/0018-Rewrite-chunk-system.patch +++ b/patches/server/0018-Rewrite-chunk-system.patch @@ -16620,7 +16620,7 @@ index 0000000000000000000000000000000000000000..7e8dc9e8f381abfdcce2746edc93122d + } +} diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java -index a5e438a834826161c52ca9db57d234d9ff80a591..b8bc1b9b8e8a33df90a963f9f9769292bf595642 100644 +index d24b4e21f162032e7455f62b9b36ffb8c3712c61..e809d6b5b742101f47a7630b3b1ede752682249e 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java @@ -14,7 +14,7 @@ public class ServerboundCommandSuggestionPacket implements Packet waitForPendingTasks(int x, int z) { diff --git a/src/main/java/net/minecraft/server/level/Ticket.java b/src/main/java/net/minecraft/server/level/Ticket.java -index b346fa94b23d81da7da073f71dd12e672e0f079c..0edb97617f0c0da8dda901a26891b33c324715c7 100644 +index 9f69b82cc8c2180182a52cf07f2f2e9ee3e90d31..c33a983818c57e44106e5a9a8d4ab4032d191d87 100644 --- a/src/main/java/net/minecraft/server/level/Ticket.java +++ b/src/main/java/net/minecraft/server/level/Ticket.java @@ -6,9 +6,12 @@ public final class Ticket implements Comparable> { @@ -20421,7 +20421,7 @@ index e96a0ca47e4701ba187555bd92c968345bc85677..73b96f804079288e9c5fcc11da54e61e + // Paper end } diff --git a/src/main/java/net/minecraft/server/network/PlayerChunkSender.java b/src/main/java/net/minecraft/server/network/PlayerChunkSender.java -index c509a1318bcef38fd4927e38b6ee9846853e2d15..5de5209e04d631bd6a50e28e8d3abebf148252c1 100644 +index a82d550697ffd11c85542cade2950d8862e37c65..aa9d88a089524024ffc49a90e54be623bfa6ed36 100644 --- a/src/main/java/net/minecraft/server/network/PlayerChunkSender.java +++ b/src/main/java/net/minecraft/server/network/PlayerChunkSender.java @@ -42,14 +42,22 @@ public class PlayerChunkSender { @@ -20527,7 +20527,7 @@ index b30128b77d2fe8a8c1db9b5746aab537a9a25430..5ae47b3449df7a83a5c22a266f7b9e4e while (iterator.hasNext()) { diff --git a/src/main/java/net/minecraft/util/SortedArraySet.java b/src/main/java/net/minecraft/util/SortedArraySet.java -index ca788f0dcec4a117b410fe8348969e056b138b1e..a6ac76707da39cf86113003b1f326433fdc86c86 100644 +index 0e00590f1cc0b28b2c2abe9576af891e35e21e6a..246c5c70db65a31807254102a6b17a2989e91a79 100644 --- a/src/main/java/net/minecraft/util/SortedArraySet.java +++ b/src/main/java/net/minecraft/util/SortedArraySet.java @@ -14,6 +14,14 @@ public class SortedArraySet extends AbstractSet { @@ -20775,7 +20775,7 @@ index 8b3763ba7f5648c41c5bf8a72e5c801d5483e6e0..0e79e92014dd56fc2ba98ce605046362 @Override diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java -index b18b896c624d5cadc02b1db9d011d82124d61d54..6f2c7baea0d1ac7813c7b85e1f5558573745762c 100644 +index bcf54eded41eb370b28807dc63d5497ce8d368cc..eff1489c8d91b0ff7c4f953d9bfb4002b6a82e94 100644 --- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java +++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java @@ -38,12 +38,28 @@ import net.minecraft.world.level.chunk.storage.SectionStorage; @@ -20850,6 +20850,8 @@ index b18b896c624d5cadc02b1db9d011d82124d61d54..6f2c7baea0d1ac7813c7b85e1f555857 @Override protected void onSectionLoad(long pos) { - this.distanceTracker.update(pos, this.distanceTracker.getLevelFromSource(pos), false); +- } +- + this.updateDistanceTracking(pos); // Paper - move to new distance tracking util + } + @@ -20929,8 +20931,8 @@ index b18b896c624d5cadc02b1db9d011d82124d61d54..6f2c7baea0d1ac7813c7b85e1f555857 + this.onSectionLoad(SectionPos.asLong(chunkX, sectionY, chunkZ)); + } + } - } - ++ } ++ + public void checkConsistency(net.minecraft.world.level.chunk.ChunkAccess chunk) { + int chunkX = chunk.getPos().x; + int chunkZ = chunk.getPos().z; @@ -21001,7 +21003,7 @@ index b18b896c624d5cadc02b1db9d011d82124d61d54..6f2c7baea0d1ac7813c7b85e1f555857 HAS_SPACE(PoiRecord::hasSpace), IS_OCCUPIED(PoiRecord::isOccupied), diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiSection.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiSection.java -index 795a02941d7cecb58ec45b5e79c8d510ff21163a..3fc17817906876e83f040f908b8b1ba6cfa37b8b 100644 +index b349c3836f4a63d5da3129af028fb03d002a88b4..161edb0a940c70ba5574e5310dfe14d5418f9955 100644 --- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiSection.java +++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiSection.java @@ -29,6 +29,7 @@ public class PoiSection { @@ -21026,7 +21028,7 @@ index 795a02941d7cecb58ec45b5e79c8d510ff21163a..3fc17817906876e83f040f908b8b1ba6 this.setDirty = updateListener; this.isValid = valid; diff --git a/src/main/java/net/minecraft/world/level/EntityGetter.java b/src/main/java/net/minecraft/world/level/EntityGetter.java -index b6a3c75b84d9f768afee33aa0f226207b307c1c0..2ec2b1d9d987c7f31c685aec3d3c87f42758c94b 100644 +index 252b6dec50561bf9c910fd7b647d83bb968a9ed4..82822ec64b1fd7b6a968b0ae05790ffa9af4ba53 100644 --- a/src/main/java/net/minecraft/world/level/EntityGetter.java +++ b/src/main/java/net/minecraft/world/level/EntityGetter.java @@ -18,6 +18,18 @@ import net.minecraft.world.phys.shapes.Shapes; @@ -21199,7 +21201,7 @@ index d87f02c748fe2e5b4ea251f6691e8907a152cb6d..5988c0847af4e8f0094328e91f736f25 + // Paper end } diff --git a/src/main/java/net/minecraft/world/level/LevelReader.java b/src/main/java/net/minecraft/world/level/LevelReader.java -index cc0d20e9f851268fe8403ac516f426ec1d008150..12eaafdbd324fa36b3f46c3b644bc8117a4123ad 100644 +index 276b5ff0c70d2a47a7be2ff82288dc8dc5f3b47a..424ec90252300cd7f73e6deeec680f7d04f2f54c 100644 --- a/src/main/java/net/minecraft/world/level/LevelReader.java +++ b/src/main/java/net/minecraft/world/level/LevelReader.java @@ -26,6 +26,15 @@ public interface LevelReader extends BlockAndTintGetter, CollisionGetter, Signal @@ -21779,7 +21781,7 @@ index 6c0f87535ffa95cf82ab4b03bb7bf8f2132d275f..b4e7c9b317d532d4915932f8f79dfebf } } diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java -index 98b3909b536f11eda9c481ffd74066ad0cdb0ebc..0ec0be22f7292d57c40da6f1f4575bdebf8dbd09 100644 +index 00f5951f3fb78d077dd828c3d8390c4a40d387c5..5c21e31e30a99d96ad6070fced0683c579b21765 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/EntityStorage.java @@ -30,43 +30,31 @@ public class EntityStorage implements EntityPersistentStorage { @@ -22149,7 +22151,7 @@ index 1988063a0cac0350ae3b3388b8f2a0c95b8b259f..2b6ba2e30c9a4682d6deb2ab750d6923 while (objectiterator.hasNext()) { diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java -index 56f0e217276b01aed2f20a71f6849826285fc15b..54db563d80bbabd87a2be6f5ead92b482ac07b10 100644 +index ab829edd451fed983f88b5571b32a1c443d74350..f080ff6913f903cff39e724ffbadd757be7aad6c 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/SectionStorage.java @@ -34,27 +34,28 @@ import net.minecraft.world.level.ChunkPos; @@ -22248,7 +22250,7 @@ index 56f0e217276b01aed2f20a71f6849826285fc15b..54db563d80bbabd87a2be6f5ead92b48 + // Paper - rewrite chunk system } diff --git a/src/main/java/net/minecraft/world/level/entity/EntityTickList.java b/src/main/java/net/minecraft/world/level/entity/EntityTickList.java -index 2830d32bba3dc85847e3a5d9b4d98f822e34b606..4cdfc433df67afcd455422e9baf56f167dd712ae 100644 +index 1e18f1ebff5db01a354a35a72f925d9f7e8c390e..3ec34eed3029762b29f1d0c8b0e7b0b729a3034d 100644 --- a/src/main/java/net/minecraft/world/level/entity/EntityTickList.java +++ b/src/main/java/net/minecraft/world/level/entity/EntityTickList.java @@ -8,54 +8,42 @@ import javax.annotation.Nullable; @@ -22347,7 +22349,7 @@ index 54308f1decc3982f30bf8b7a8a9d8865bfdbb9fd..902156477bdfc9917105f1229f760c26 while (iterator.hasNext()) { diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java -index 1ca00340aaa201dd34e5c350d23ef53e126a0ca6..16356d7f388561300e794a52f3f263b8e7d9b880 100644 +index e5f28e8bf148693714d2d538b4979badc5e9a6fa..3caf5f120fa1b5e3b221461a1b01d203d2d3a61f 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java +++ b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java @@ -50,8 +50,101 @@ public class StructureCheck { @@ -22510,7 +22512,7 @@ index 1ca00340aaa201dd34e5c350d23ef53e126a0ca6..16356d7f388561300e794a52f3f263b8 referencesByStructure.computeInt(structure, (feature, references) -> { return references == null ? 1 : references + 1; diff --git a/src/main/java/net/minecraft/world/ticks/LevelChunkTicks.java b/src/main/java/net/minecraft/world/ticks/LevelChunkTicks.java -index 9f6c2e5b5d9e8d714a47c770e255d06c0ef7c190..ac807277a6b26d140ea9873d17c7aa4fb5fe37b2 100644 +index 899affb31121ad3580353594c17165f725676c9f..dc6d296e827c666e2bb64e31db5e04a95b1e10c0 100644 --- a/src/main/java/net/minecraft/world/ticks/LevelChunkTicks.java +++ b/src/main/java/net/minecraft/world/ticks/LevelChunkTicks.java @@ -25,6 +25,19 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon diff --git a/patches/server/0342-Anti-Xray.patch b/patches/server/0342-Anti-Xray.patch index b89fbd92af41..b746547589fb 100644 --- a/patches/server/0342-Anti-Xray.patch +++ b/patches/server/0342-Anti-Xray.patch @@ -997,7 +997,7 @@ index 0000000000000000000000000000000000000000..80a2dfb266ae1221680a7b24fee2f7e2 + } +} diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundChunksBiomesPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundChunksBiomesPacket.java -index 6cff1a98dc7cf33947ec760dbc3d3d0ec5db5f6c..51f647de153255c919b1440338cf1b3e2d6b5dbf 100644 +index 157ad9decef457427857327568635d08875895c9..3ab98c93e14a171a49b44d315b6646c2f94274be 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundChunksBiomesPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundChunksBiomesPacket.java @@ -63,8 +63,10 @@ public record ClientboundChunksBiomesPacket(List implements PaletteResize, PalettedContainer @@ -1309,6 +1309,9 @@ index 1219200cd915d6239a32a2bd09d325cd8fa9b346..98e720a21432fff7fce8653095a56e2e this.registry = idList; this.strategy = paletteProvider; this.data = new PalettedContainer.Data<>(dataProvider, storage, dataProvider.factory().create(dataProvider.bits(), idList, this, paletteEntries)); +- } +- +- private PalettedContainer(IdMap idList, PalettedContainer.Strategy paletteProvider, PalettedContainer.Data data) { + + if (presetValues != null && (dataProvider.factory() == PalettedContainer.Strategy.SINGLE_VALUE_PALETTE_FACTORY ? this.data.palette.valueFor(0) != defaultValue : dataProvider.factory() != PalettedContainer.Strategy.GLOBAL_PALETTE_FACTORY)) { + // In 1.18 Mojang unfortunately removed code that already handled possible resize operations on read from disk for us @@ -1332,9 +1335,8 @@ index 1219200cd915d6239a32a2bd09d325cd8fa9b346..98e720a21432fff7fce8653095a56e2e + } + } + // Paper end - } - -- private PalettedContainer(IdMap idList, PalettedContainer.Strategy paletteProvider, PalettedContainer.Data data) { ++ } ++ + // Paper start - Anti-Xray - Add preset values + private PalettedContainer(IdMap idList, PalettedContainer.Strategy paletteProvider, PalettedContainer.Data data, T @org.jetbrains.annotations.Nullable [] presetValues) { + this.presetValues = presetValues; @@ -1371,6 +1373,7 @@ index 1219200cd915d6239a32a2bd09d325cd8fa9b346..98e720a21432fff7fce8653095a56e2e data2.copyFrom(data.palette, data.storage); this.data = data2; - return data2.palette.idFor(object); +- } + this.addPresetValues(); + return object == null ? -1 : data2.palette.idFor(object); + // Paper end @@ -1383,7 +1386,7 @@ index 1219200cd915d6239a32a2bd09d325cd8fa9b346..98e720a21432fff7fce8653095a56e2e + this.data.palette.idFor(presetValue); + } + } - } ++ } + // Paper end public T getAndSet(int x, int y, int z, T value) { @@ -1471,7 +1474,7 @@ index 1219200cd915d6239a32a2bd09d325cd8fa9b346..98e720a21432fff7fce8653095a56e2e } diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainerRO.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainerRO.java -index 9a2bf744abd8916d492e901be889223591bac3fd..1dd415c96d17eff8e7555c33d3c52e57f2559fa5 100644 +index 40f09b6b4355f52e2542a421359119b06ec3d647..4a98634941ba433dc72788f156d65d93037cddd3 100644 --- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainerRO.java +++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainerRO.java @@ -14,7 +14,10 @@ public interface PalettedContainerRO { diff --git a/patches/server/0727-Collision-optimisations.patch b/patches/server/0727-Collision-optimisations.patch index ac8a34257660..bff1981aa303 100644 --- a/patches/server/0727-Collision-optimisations.patch +++ b/patches/server/0727-Collision-optimisations.patch @@ -2178,7 +2178,7 @@ index 0000000000000000000000000000000000000000..1f42bdfdb052056e62a939ab0d1944f8 + +} diff --git a/src/main/java/net/minecraft/core/Direction.java b/src/main/java/net/minecraft/core/Direction.java -index d0a8092bf57a29ab7c00ec0ddf52a9fdb2a33267..392406722b0a040c1d41fdc1154d75d39f6e9c86 100644 +index 978755027d957a3c888e5f354a2e8466cfaae582..0ba30cbaad5df2a8f52139be9b00310970330ceb 100644 --- a/src/main/java/net/minecraft/core/Direction.java +++ b/src/main/java/net/minecraft/core/Direction.java @@ -57,6 +57,21 @@ public enum Direction implements StringRepresentable { @@ -2482,7 +2482,7 @@ index 25bf917fae922b34cc639148993bac39a50b4ce5..1c7702a5c888846f93f8f80d3b854a26 while (iterator.hasNext()) { diff --git a/src/main/java/net/minecraft/world/level/BlockCollisions.java b/src/main/java/net/minecraft/world/level/BlockCollisions.java -index a3eaf80b020c3bbc0306c5d17659ee661dfd275b..1b6f72932fbdd567a1534bcf15e8a610b00f974d 100644 +index 6284701b83883e93838c7de11c6cd05eaef0c086..27afbb147cabbc778eba584b8019817baace335d 100644 --- a/src/main/java/net/minecraft/world/level/BlockCollisions.java +++ b/src/main/java/net/minecraft/world/level/BlockCollisions.java @@ -105,7 +105,7 @@ public class BlockCollisions extends AbstractIterator { @@ -2510,7 +2510,7 @@ index ad2c533e9a0f0e2d97620b0e16200d7eeaedeefb..6cda651b7a44867947053538cb40e112 public ClipContext(Vec3 start, Vec3 end, ClipContext.Block shapeType, ClipContext.Fluid fluidHandling, Entity entity) { diff --git a/src/main/java/net/minecraft/world/level/CollisionGetter.java b/src/main/java/net/minecraft/world/level/CollisionGetter.java -index c476e37df8a75d77f5093b2a449e04f25ef2c2dd..5d66aadae51db1ae760812849bfc8740b82af9a9 100644 +index bbace777cbbd5014c0115380aa05d179c0e3fe22..11a941cee7ab37436e501aa712d05b2915a51960 100644 --- a/src/main/java/net/minecraft/world/level/CollisionGetter.java +++ b/src/main/java/net/minecraft/world/level/CollisionGetter.java @@ -35,6 +35,12 @@ public interface CollisionGetter extends BlockGetter { @@ -2527,7 +2527,7 @@ index c476e37df8a75d77f5093b2a449e04f25ef2c2dd..5d66aadae51db1ae760812849bfc8740 return this.noCollision((Entity)null, box); } diff --git a/src/main/java/net/minecraft/world/level/EntityGetter.java b/src/main/java/net/minecraft/world/level/EntityGetter.java -index a25497eec004add7408a63b1a0f09e3fa443b324..9f892de55ab03367daed4c30cc44c9dd8adc29ed 100644 +index 662ab644c7762a8e2f4ec1b1d72d9c9b98152881..d2e9656befa324aceced3f6feb000c4bb78bf136 100644 --- a/src/main/java/net/minecraft/world/level/EntityGetter.java +++ b/src/main/java/net/minecraft/world/level/EntityGetter.java @@ -45,17 +45,36 @@ public interface EntityGetter { @@ -3236,7 +3236,7 @@ index 55208b4889f4af60f2b2b66ed6b102b2cd0bb26b..e21f4c5aff3a8e97101f6efc1349fbec if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) { diff --git a/src/main/java/net/minecraft/world/phys/AABB.java b/src/main/java/net/minecraft/world/phys/AABB.java -index f80783dc163997626850189f5647c06f9d15da6c..e3dbf3066337a482460238f8a94d854cf88adfa2 100644 +index 097214481bcc933988c0aede61869b9141e4e03e..1131c6c66200390bd3cfaec21bb771b015c7218f 100644 --- a/src/main/java/net/minecraft/world/phys/AABB.java +++ b/src/main/java/net/minecraft/world/phys/AABB.java @@ -25,6 +25,17 @@ public class AABB { @@ -3267,7 +3267,7 @@ index f80783dc163997626850189f5647c06f9d15da6c..e3dbf3066337a482460238f8a94d854c approachDirection = clipPoint(traceDistanceResult, approachDirection, deltaX, deltaY, deltaZ, box.minX, box.minY, box.maxY, box.minZ, box.maxZ, Direction.WEST, intersectingVector.x, intersectingVector.y, intersectingVector.z); } else if (deltaX < -1.0E-7D) { diff --git a/src/main/java/net/minecraft/world/phys/shapes/ArrayVoxelShape.java b/src/main/java/net/minecraft/world/phys/shapes/ArrayVoxelShape.java -index 9d627b8e6bf3140b894d38b9a720896e2d776369..a232b9396a41c11579a4d691b05717b16473513e 100644 +index 33185ed85125b5c6cc3a706a144fa3bc4492e30d..c3ad13c68052b02b82ae4a85dad9afa28cd53b0c 100644 --- a/src/main/java/net/minecraft/world/phys/shapes/ArrayVoxelShape.java +++ b/src/main/java/net/minecraft/world/phys/shapes/ArrayVoxelShape.java @@ -15,7 +15,7 @@ public class ArrayVoxelShape extends VoxelShape { @@ -3294,7 +3294,7 @@ index 9d627b8e6bf3140b894d38b9a720896e2d776369..a232b9396a41c11579a4d691b05717b1 + } diff --git a/src/main/java/net/minecraft/world/phys/shapes/BitSetDiscreteVoxelShape.java b/src/main/java/net/minecraft/world/phys/shapes/BitSetDiscreteVoxelShape.java -index c25f409d63a50c5de1434db1d6b298935f106221..6f532d9aa613ecb0f5695b108ec6d7ed3598ca82 100644 +index 1a9aec843cc179727d1bf7615fbe4e4a324400fb..fe6998760bb85eecd72c4ebc89662542055be048 100644 --- a/src/main/java/net/minecraft/world/phys/shapes/BitSetDiscreteVoxelShape.java +++ b/src/main/java/net/minecraft/world/phys/shapes/BitSetDiscreteVoxelShape.java @@ -4,13 +4,13 @@ import java.util.BitSet; @@ -3323,6 +3323,19 @@ index c25f409d63a50c5de1434db1d6b298935f106221..6f532d9aa613ecb0f5695b108ec6d7ed protected static void forAllBoxes(DiscreteVoxelShape voxelSet, DiscreteVoxelShape.IntLineConsumer callback, boolean coalesce) { - BitSetDiscreteVoxelShape bitSetDiscreteVoxelShape = new BitSetDiscreteVoxelShape(voxelSet); +- +- for(int i = 0; i < bitSetDiscreteVoxelShape.ySize; ++i) { +- for(int j = 0; j < bitSetDiscreteVoxelShape.xSize; ++j) { +- int k = -1; +- +- for(int l = 0; l <= bitSetDiscreteVoxelShape.zSize; ++l) { +- if (bitSetDiscreteVoxelShape.isFullWide(j, i, l)) { +- if (coalesce) { +- if (k == -1) { +- k = l; +- } +- } else { +- callback.consume(j, i, l, j + 1, i + 1, l + 1); + // Paper start - optimise collisions + // called with the shape of a VoxelShape, so we can expect the cache to exist + final io.papermc.paper.util.collisions.CachedShapeData cache = voxelSet.getOrCreateCachedShapeData(); @@ -3360,21 +3373,10 @@ index c25f409d63a50c5de1434db1d6b298935f106221..6f532d9aa613ecb0f5695b108ec6d7ed + } else { + // same notes about loop order as the above + // this branch is actually important to optimise, as it affects uncached toAabbs() (which affects optimize()) - -- for(int i = 0; i < bitSetDiscreteVoxelShape.ySize; ++i) { -- for(int j = 0; j < bitSetDiscreteVoxelShape.xSize; ++j) { -- int k = -1; ++ + // only clone when we may write to it + bitset = bitset.clone(); - -- for(int l = 0; l <= bitSetDiscreteVoxelShape.zSize; ++l) { -- if (bitSetDiscreteVoxelShape.isFullWide(j, i, l)) { -- if (coalesce) { -- if (k == -1) { -- k = l; -- } -- } else { -- callback.consume(j, i, l, j + 1, i + 1, l + 1); ++ + for (int y = 0; y < sizeY; ++y, indexY += incY) { + indexX = indexY; + for (int x = 0; x < sizeX; ++x, indexX += incX) { @@ -3453,7 +3455,7 @@ index c25f409d63a50c5de1434db1d6b298935f106221..6f532d9aa613ecb0f5695b108ec6d7ed private boolean isZStripFull(int z1, int z2, int x, int y) { diff --git a/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java b/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java -index 68e89dbd79171627046e89699057964e44c40e7d..110405e6e70d980d3e09f04d79562b32a7413071 100644 +index 374da999d4fb544a5571ca888dd4cc60680d0ee0..47acd4f6a25be8a1d217f489494449bdbd179842 100644 --- a/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java +++ b/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java @@ -7,6 +7,7 @@ import net.minecraft.util.Mth; @@ -3465,7 +3467,7 @@ index 68e89dbd79171627046e89699057964e44c40e7d..110405e6e70d980d3e09f04d79562b32 @Override diff --git a/src/main/java/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java b/src/main/java/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java -index b27ed92b2a87d4c20c1aa300202adfab896c99ea..d0a4547f95ee24283af77cfa130979d05915292f 100644 +index 91fdb93f7229a98c82210c7f2b79be216e66e14d..0fb2f156e1cd47dbc5b69cbd4258414422d388ee 100644 --- a/src/main/java/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java +++ b/src/main/java/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java @@ -9,6 +9,71 @@ public abstract class DiscreteVoxelShape { @@ -3541,7 +3543,7 @@ index b27ed92b2a87d4c20c1aa300202adfab896c99ea..d0a4547f95ee24283af77cfa130979d0 if (sizeX >= 0 && sizeY >= 0 && sizeZ >= 0) { this.xSize = sizeX; diff --git a/src/main/java/net/minecraft/world/phys/shapes/OffsetDoubleList.java b/src/main/java/net/minecraft/world/phys/shapes/OffsetDoubleList.java -index 7ec02a7849437a18860aa0df7d9ddd71b2447d4c..5e45e49ab09344cb95736f4124b1c6e002ef5b82 100644 +index 4d99823619b7d80391625074520beca81dc5f7c7..443b8538800b58570a56c7e8142fe17425d711ec 100644 --- a/src/main/java/net/minecraft/world/phys/shapes/OffsetDoubleList.java +++ b/src/main/java/net/minecraft/world/phys/shapes/OffsetDoubleList.java @@ -4,8 +4,8 @@ import it.unimi.dsi.fastutil.doubles.AbstractDoubleList; @@ -3556,7 +3558,7 @@ index 7ec02a7849437a18860aa0df7d9ddd71b2447d4c..5e45e49ab09344cb95736f4124b1c6e0 public OffsetDoubleList(DoubleList oldList, double offset) { this.delegate = oldList; diff --git a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java -index 9176735c08a75854209f24113b0e78332249dc4d..17785f7c709073a01928e8e6a57702f8357900f4 100644 +index b073361134dbe2c5034261d32dd26a6de9af60a1..03ca66922454455d046cdec8d68b9ad915292200 100644 --- a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java +++ b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java @@ -16,13 +16,43 @@ public final class Shapes { @@ -3929,7 +3931,7 @@ index 9176735c08a75854209f24113b0e78332249dc4d..17785f7c709073a01928e8e6a57702f8 @VisibleForTesting diff --git a/src/main/java/net/minecraft/world/phys/shapes/SliceShape.java b/src/main/java/net/minecraft/world/phys/shapes/SliceShape.java -index cf469f9daa81da8bc330c9cac7e813db87f9f9af..d9256710e815a5cb55409a80d59df2029b98c0d7 100644 +index 47d96862976b8387c2f148fcf13eb5b10742ff1c..30485998e78f6c435e65d02c76d1a5ed1b3f0a98 100644 --- a/src/main/java/net/minecraft/world/phys/shapes/SliceShape.java +++ b/src/main/java/net/minecraft/world/phys/shapes/SliceShape.java @@ -12,6 +12,7 @@ public class SliceShape extends VoxelShape { @@ -3941,7 +3943,7 @@ index cf469f9daa81da8bc330c9cac7e813db87f9f9af..d9256710e815a5cb55409a80d59df202 private static DiscreteVoxelShape makeSlice(DiscreteVoxelShape voxelSet, Direction.Axis axis, int sliceWidth) { diff --git a/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java b/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java -index 15e2dfa9a17b4f19768c0cde0ad8031f0122cd33..6bd6385ad82481a099f3556ed2dbd3744888fc34 100644 +index 355ae0373a8c7235045a42002e72f2c3c38b1763..9904222d84f596dc7a8c232154816a61437f9d46 100644 --- a/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java +++ b/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java @@ -16,30 +16,438 @@ import net.minecraft.world.phys.BlockHitResult;