diff options
author | Jake Potrebic <[email protected]> | 2024-04-08 16:03:41 -0700 |
---|---|---|
committer | Jake Potrebic <[email protected]> | 2024-04-10 14:04:48 -0700 |
commit | 83903c75cf9a027b0d8e8c01843b51a427361f3a (patch) | |
tree | 63be93b40a9863c1f5ce1450684fe630264f1f20 | |
parent | c1166f5d0d73723d8e7bad1a158a96a21835c5c2 (diff) | |
download | Paper-83903c75cf9a027b0d8e8c01843b51a427361f3a.tar.gz Paper-83903c75cf9a027b0d8e8c01843b51a427361f3a.zip |
update patches again to handle inlined simple lambdas
89 files changed, 606 insertions, 652 deletions
diff --git a/patches/server/0002-Remap-fixes.patch b/patches/server/0002-Remap-fixes.patch index 20de85514e..9a1f203f9a 100644 --- a/patches/server/0002-Remap-fixes.patch +++ b/patches/server/0002-Remap-fixes.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Remap fixes diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java -index 14dc0f93a1904bd78853ff861c855115f8de0462..cd2a345e5e33b4a8858bcf64bda1aa99aef2f059 100644 +index 17a400bb1710afe0b2c88ba7b0a008d4dbcbfa0c..1a4cab0b9995b733aa84b89129009a99177eee9b 100644 --- a/src/main/java/net/minecraft/core/BlockPos.java +++ b/src/main/java/net/minecraft/core/BlockPos.java -@@ -292,9 +292,11 @@ public class BlockPos extends Vec3i { +@@ -289,9 +289,11 @@ public class BlockPos extends Vec3i { public static Iterable<BlockPos> withinManhattan(BlockPos center, int rangeX, int rangeY, int rangeZ) { int i = rangeX + rangeY + rangeZ; @@ -20,10 +20,10 @@ index 14dc0f93a1904bd78853ff861c855115f8de0462..cd2a345e5e33b4a8858bcf64bda1aa99 + int centerY = center.getY(); + int centerZ = center.getZ(); + // Paper end - return () -> { - return new AbstractIterator<BlockPos>() { + return () -> new AbstractIterator<BlockPos>() { private final BlockPos.MutableBlockPos cursor = new BlockPos.MutableBlockPos(); -@@ -309,7 +311,7 @@ public class BlockPos extends Vec3i { + private int currentDepth; +@@ -305,7 +307,7 @@ public class BlockPos extends Vec3i { protected BlockPos computeNext() { if (this.zMirror) { this.zMirror = false; @@ -32,7 +32,7 @@ index 14dc0f93a1904bd78853ff861c855115f8de0462..cd2a345e5e33b4a8858bcf64bda1aa99 return this.cursor; } else { BlockPos blockPos; -@@ -335,7 +337,7 @@ public class BlockPos extends Vec3i { +@@ -331,7 +333,7 @@ public class BlockPos extends Vec3i { int k = this.currentDepth - Math.abs(i) - Math.abs(j); if (k <= rangeZ) { this.zMirror = k != 0; diff --git a/patches/server/0003-Build-system-changes.patch b/patches/server/0003-Build-system-changes.patch index 8f489a8989..c935af1a00 100644 --- a/patches/server/0003-Build-system-changes.patch +++ b/patches/server/0003-Build-system-changes.patch @@ -66,7 +66,7 @@ index 4e0b810bd0a9991d10e13920f47f0b6d0a56f6aa..50d9182a4845564cd62b026700a7d051 + jvmArgs("-DPaper.pushPaperAssetsRoot=true") } diff --git a/src/main/java/net/minecraft/resources/ResourceLocation.java b/src/main/java/net/minecraft/resources/ResourceLocation.java -index 6b6bf94b7826aad8e10200495772f68a9b4a0b48..980ba384d15c69030d033426290678e569af23b4 100644 +index 0064a1112f392379ff095f95738f1368240ca4cf..aed74e471126a8a66046a181973158d7d288d3f0 100644 --- a/src/main/java/net/minecraft/resources/ResourceLocation.java +++ b/src/main/java/net/minecraft/resources/ResourceLocation.java @@ -28,6 +28,7 @@ public class ResourceLocation implements Comparable<ResourceLocation> { @@ -78,10 +78,10 @@ index 6b6bf94b7826aad8e10200495772f68a9b4a0b48..980ba384d15c69030d033426290678e5 private final String path; diff --git a/src/main/java/net/minecraft/server/packs/VanillaPackResourcesBuilder.java b/src/main/java/net/minecraft/server/packs/VanillaPackResourcesBuilder.java -index e3e28f21f6eee539ca960946067b2d31626899fa..6dd89ad3e7354b1403b873b5c55a41f0b04c956a 100644 +index 6a11d33eb44e0fde731b54a9200eb44b20a73c43..29ab3aae87de2bf14b31268239d935e49cb0fa98 100644 --- a/src/main/java/net/minecraft/server/packs/VanillaPackResourcesBuilder.java +++ b/src/main/java/net/minecraft/server/packs/VanillaPackResourcesBuilder.java -@@ -140,6 +140,15 @@ public class VanillaPackResourcesBuilder { +@@ -138,6 +138,15 @@ public class VanillaPackResourcesBuilder { public VanillaPackResourcesBuilder applyDevelopmentConfig() { developmentConfig.accept(this); @@ -98,7 +98,7 @@ index e3e28f21f6eee539ca960946067b2d31626899fa..6dd89ad3e7354b1403b873b5c55a41f0 } 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 f2d24c3dd0a958bfd038ba7e3cafb72b53ea20dd..d0d65a59d75b56e4fc8c29068ac56e13df2b2aea 100644 +index dd5e32e7a64eaddab66905dba2595f2220706adb..439b9bc95ae8580fcde89f86565df39ba4040d59 100644 --- a/src/main/java/net/minecraft/server/packs/repository/ServerPacksSource.java +++ b/src/main/java/net/minecraft/server/packs/repository/ServerPacksSource.java @@ -38,7 +38,7 @@ public class ServerPacksSource extends BuiltInPackSource { diff --git a/patches/server/0006-MC-Dev-fixes.patch b/patches/server/0006-MC-Dev-fixes.patch index dac30cbd81..8dfbf39c27 100644 --- a/patches/server/0006-MC-Dev-fixes.patch +++ b/patches/server/0006-MC-Dev-fixes.patch @@ -5,10 +5,10 @@ Subject: [PATCH] MC Dev fixes diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java -index cd2a345e5e33b4a8858bcf64bda1aa99aef2f059..44853c711442e0360e5631ae1c5d1d5a6edd2526 100644 +index 1a4cab0b9995b733aa84b89129009a99177eee9b..ead823fa2a143acb05b33152ee1e5ee4b4936a20 100644 --- a/src/main/java/net/minecraft/core/BlockPos.java +++ b/src/main/java/net/minecraft/core/BlockPos.java -@@ -411,12 +411,12 @@ public class BlockPos extends Vec3i { +@@ -405,12 +405,12 @@ public class BlockPos extends Vec3i { if (this.index == l) { return this.endOfData(); } else { @@ -27,7 +27,7 @@ index cd2a345e5e33b4a8858bcf64bda1aa99aef2f059..44853c711442e0360e5631ae1c5d1d5a } }; diff --git a/src/main/java/net/minecraft/network/ConnectionProtocol.java b/src/main/java/net/minecraft/network/ConnectionProtocol.java -index 81c74fc4ebdab7d2b11f2aebef997dc71ae39c97..fca5251008f21c0f3eee9390eca9b9fa2fef1151 100644 +index 68ccf051f5a769abaa0bf9508add9303c56a1193..9d6dafb4855af9ccb7bc033ebf0fca5f75ceb9c6 100644 --- a/src/main/java/net/minecraft/network/ConnectionProtocol.java +++ b/src/main/java/net/minecraft/network/ConnectionProtocol.java @@ -451,7 +451,7 @@ public enum ConnectionProtocol { diff --git a/patches/server/0009-MC-Utils.patch b/patches/server/0009-MC-Utils.patch index 74d7ea2349..8f3da9d5b8 100644 --- a/patches/server/0009-MC-Utils.patch +++ b/patches/server/0009-MC-Utils.patch @@ -5937,7 +5937,7 @@ index 0000000000000000000000000000000000000000..d603887f4d0464f4463172fd79bcd529 + } +} diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java -index 21c2bd6795d044ef6898de57d0734dd453769587..9a12feebbae4a9fdfd24214c2ffa61e717d6e358 100644 +index 3d4c889aa278f814f3af0af62fd38db4f1f05a45..bf17c2005aa71a627c93b3bbaa773a5902b897c1 100644 --- a/src/main/java/net/minecraft/Util.java +++ b/src/main/java/net/minecraft/Util.java @@ -127,7 +127,7 @@ public class Util { @@ -5950,10 +5950,10 @@ index 21c2bd6795d044ef6898de57d0734dd453769587..9a12feebbae4a9fdfd24214c2ffa61e7 public static long getEpochMillis() { diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java -index 4f520046c5b650a780896a565efe959bc0bd21ae..8a8dd896328ec3f392f3c5ef7c94633922e45ee3 100644 +index 557702f85573da753d68fcba76dde7c74de9d12b..1e2f58f2f95c558ce28706c405050c4c5701dd40 100644 --- a/src/main/java/net/minecraft/nbt/CompoundTag.java +++ b/src/main/java/net/minecraft/nbt/CompoundTag.java -@@ -163,7 +163,7 @@ public class CompoundTag implements Tag { +@@ -159,7 +159,7 @@ public class CompoundTag implements Tag { return "TAG_Compound"; } }; @@ -5962,7 +5962,7 @@ index 4f520046c5b650a780896a565efe959bc0bd21ae..8a8dd896328ec3f392f3c5ef7c946339 protected CompoundTag(Map<String, Tag> entries) { this.tags = entries; -@@ -239,6 +239,10 @@ public class CompoundTag implements Tag { +@@ -235,6 +235,10 @@ public class CompoundTag implements Tag { this.tags.put(key, NbtUtils.createUUID(value)); } @@ -6029,7 +6029,7 @@ index 929d31aa624f035eb314dece08969b102f5781fc..e94f0361cbca873f05b5b768c68c0933 + // Paper end - MC Utils - default query payloads } diff --git a/src/main/java/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java b/src/main/java/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java -index 44cac39893eb968aa8ea21ee571c0dcb866ce06c..5151d68ba6ec72a7124f298253c5f0af080b2ea6 100644 +index 3ad2f40a7a1a8878290c5efd3e032572daf0b558..bcc4cd142c22e8d6957a329719353d789b826a69 100644 --- a/src/main/java/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java +++ b/src/main/java/net/minecraft/network/protocol/login/ServerboundCustomQueryAnswerPacket.java @@ -15,7 +15,17 @@ public record ServerboundCustomQueryAnswerPacket(int transactionId, @Nullable Cu @@ -6051,7 +6051,7 @@ index 44cac39893eb968aa8ea21ee571c0dcb866ce06c..5151d68ba6ec72a7124f298253c5f0af } private static CustomQueryAnswerPayload readUnknownPayload(FriendlyByteBuf buf) { -@@ -40,4 +50,21 @@ public record ServerboundCustomQueryAnswerPacket(int transactionId, @Nullable Cu +@@ -38,4 +48,21 @@ public record ServerboundCustomQueryAnswerPacket(int transactionId, @Nullable Cu public void handle(ServerLoginPacketListener listener) { listener.handleCustomQueryPacket(this); } @@ -7364,7 +7364,7 @@ index daa1e9bf39666233dd80eeee0ffd76e168376889..ced67cf88c91c5270a0060a7307f3673 boolean hasChunk(int chunkX, int chunkZ); diff --git a/src/main/java/net/minecraft/world/level/PathNavigationRegion.java b/src/main/java/net/minecraft/world/level/PathNavigationRegion.java -index 11364675963d9ef3b69b784ffa4bcd21ec35c530..bc6ea19689a4200a2a0759bed1445ef26c494e9e 100644 +index 497792978bdf0e6a53d772304770e8df3e7416ea..c5454b92ca2565461c799d7340160f9fb72c1b0f 100644 --- a/src/main/java/net/minecraft/world/level/PathNavigationRegion.java +++ b/src/main/java/net/minecraft/world/level/PathNavigationRegion.java @@ -9,6 +9,7 @@ import net.minecraft.core.Holder; @@ -7375,7 +7375,7 @@ index 11364675963d9ef3b69b784ffa4bcd21ec35c530..bc6ea19689a4200a2a0759bed1445ef2 import net.minecraft.world.entity.Entity; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biomes; -@@ -69,7 +70,7 @@ public class PathNavigationRegion implements BlockGetter, CollisionGetter { +@@ -67,7 +68,7 @@ public class PathNavigationRegion implements BlockGetter, CollisionGetter { private ChunkAccess getChunk(int chunkX, int chunkZ) { int i = chunkX - this.centerX; int j = chunkZ - this.centerZ; @@ -7384,7 +7384,7 @@ index 11364675963d9ef3b69b784ffa4bcd21ec35c530..bc6ea19689a4200a2a0759bed1445ef2 ChunkAccess chunkAccess = this.chunks[i][j]; return (ChunkAccess)(chunkAccess != null ? chunkAccess : new EmptyLevelChunk(this.level, new ChunkPos(chunkX, chunkZ), this.plains.get())); } else { -@@ -77,6 +78,30 @@ public class PathNavigationRegion implements BlockGetter, CollisionGetter { +@@ -75,6 +76,30 @@ public class PathNavigationRegion implements BlockGetter, CollisionGetter { } } @@ -7713,7 +7713,7 @@ index d59392c322936ce89b759ac9787c8f4f0b228af6..2d6daf76a56574c9727b404feb4f8634 private short tickingFluidCount; public final PalettedContainer<BlockState> states; diff --git a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java -index af83a60623092073881c9d4c0c39d907c31c070c..aee460cd2cfed3134870b5c02bf4ecb5738a5aa0 100644 +index 47d1a5142bdddfa89b1d84002784c1328d8ac3b4..03e5e5c5ea003ba52b9f3ee405cd77e22ea387c8 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java @@ -81,6 +81,18 @@ public class ProtoChunk extends ChunkAccess { diff --git a/patches/server/0010-Adventure.patch b/patches/server/0010-Adventure.patch index 9d49f67c14..5ccebb831a 100644 --- a/patches/server/0010-Adventure.patch +++ b/patches/server/0010-Adventure.patch @@ -2096,10 +2096,10 @@ index 0000000000000000000000000000000000000000..c0701d4f93a4d77a8177d2dd8d5076f9 + } +} diff --git a/src/main/java/net/minecraft/ChatFormatting.java b/src/main/java/net/minecraft/ChatFormatting.java -index 75f33ca3425800f63d7b51a0b303aae72e6ef8f8..20baece1b9e1e3fef7236c6643af96c64b7981fd 100644 +index 8128ad5adc43980e6b19d87b7ade90b2d7bed699..3953972ef49e1899102116f35d9153bd81430aa7 100644 --- a/src/main/java/net/minecraft/ChatFormatting.java +++ b/src/main/java/net/minecraft/ChatFormatting.java -@@ -113,6 +113,18 @@ public enum ChatFormatting implements StringRepresentable { +@@ -110,6 +110,18 @@ public enum ChatFormatting implements StringRepresentable { return name == null ? null : FORMATTING_BY_NAME.get(cleanName(name)); } @@ -2237,10 +2237,10 @@ index d0e159f54da70bf0bd834738ced5d4b414a36142..0d80fcee1831af59b06c4d00dc713bd4 try { int j = friendlyByteBuf.writerIndex(); diff --git a/src/main/java/net/minecraft/network/chat/ChatDecorator.java b/src/main/java/net/minecraft/network/chat/ChatDecorator.java -index 887b9fd625aa23c4ec828a175d63695f915232d3..8e4a4b15152c2f83444fa8017bec06bbd1389e2c 100644 +index e4624d696dcf0ddb6d42a80701dfc47ec6877540..8885e405b626daa0af1485ad734863af73b3c1f3 100644 --- a/src/main/java/net/minecraft/network/chat/ChatDecorator.java +++ b/src/main/java/net/minecraft/network/chat/ChatDecorator.java -@@ -2,12 +2,72 @@ package net.minecraft.network.chat; +@@ -2,10 +2,70 @@ package net.minecraft.network.chat; import javax.annotation.Nullable; import net.minecraft.server.level.ServerPlayer; @@ -2248,10 +2248,8 @@ index 887b9fd625aa23c4ec828a175d63695f915232d3..8e4a4b15152c2f83444fa8017bec06bb @FunctionalInterface public interface ChatDecorator { - ChatDecorator PLAIN = (sender, message) -> { -- return message; -+ return CompletableFuture.completedFuture(message); // Paper - adventure; support async chat decoration events - }; +- ChatDecorator PLAIN = (sender, message) -> message; ++ ChatDecorator PLAIN = (sender, message) -> CompletableFuture.completedFuture(message); // Paper - adventure; support async chat decoration events; - Component decorate(@Nullable ServerPlayer sender, Component message); + @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - adventure; support chat decoration events @@ -2316,10 +2314,10 @@ index 887b9fd625aa23c4ec828a175d63695f915232d3..8e4a4b15152c2f83444fa8017bec06bb + // Paper end - adventure; support async chat decoration events } diff --git a/src/main/java/net/minecraft/network/chat/ComponentSerialization.java b/src/main/java/net/minecraft/network/chat/ComponentSerialization.java -index c39b04c7e83fba45b5220678b4d94bf96f4c16dc..f51130399642a5e4a004b0661e33cf850ff18b4b 100644 +index 48ce8553ac13a1c660a5125e17d2a173d62ca7ff..b89386d9366543f7777e6eab961938763188345f 100644 --- a/src/main/java/net/minecraft/network/chat/ComponentSerialization.java +++ b/src/main/java/net/minecraft/network/chat/ComponentSerialization.java -@@ -58,7 +58,25 @@ public class ComponentSerialization { +@@ -51,7 +51,25 @@ public class ComponentSerialization { return ExtraCodecs.orCompressed(mapCodec3, mapCodec2); } @@ -2345,9 +2343,9 @@ index c39b04c7e83fba45b5220678b4d94bf96f4c16dc..f51130399642a5e4a004b0661e33cf85 ComponentContents.Type<?>[] types = new ComponentContents.Type[]{ PlainTextContents.TYPE, TranslatableContents.TYPE, KeybindContents.TYPE, ScoreContents.TYPE, SelectorContents.TYPE, NbtContents.TYPE }; -@@ -73,6 +91,34 @@ public class ComponentSerialization { - .apply(instance, MutableComponent::new); - } +@@ -64,6 +82,34 @@ public class ComponentSerialization { + ) + .apply(instance, MutableComponent::new) ); + // Paper start - adventure; create separate codec for each locale + final Codec<Component> origCodec = codec; @@ -2377,11 +2375,11 @@ index c39b04c7e83fba45b5220678b4d94bf96f4c16dc..f51130399642a5e4a004b0661e33cf85 + } + }; + // Paper end - adventure; create separate codec for each locale - return Codec.either(Codec.either(Codec.STRING, ExtraCodecs.nonEmptyList(selfCodec.listOf())), codec).xmap(either -> { - return either.map(either2 -> { - return either2.map(Component::literal, ComponentSerialization::createFromList); + return Codec.either(Codec.either(Codec.STRING, ExtraCodecs.nonEmptyList(selfCodec.listOf())), codec) + .xmap(either -> either.map(either2 -> either2.map(Component::literal, ComponentSerialization::createFromList), text -> (Component)text), text -> { + String string = text.tryCollapseToString(); diff --git a/src/main/java/net/minecraft/network/chat/ComponentUtils.java b/src/main/java/net/minecraft/network/chat/ComponentUtils.java -index 103885e8d5458bc06c8bfe0f42c1d35b5716b541..d51c9210bb3267c03cc10920178f7c53e1413c94 100644 +index 0030c0c91e989fcdc5b7ce6490836a0e8dd3b5d5..3365aed2b67ae0e4dd0410f5190ba474f146139b 100644 --- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java +++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java @@ -41,6 +41,11 @@ public class ComponentUtils { @@ -2454,7 +2452,7 @@ index e2def0ca552343143e495736d533b3334686fd62..c87b708c368713a23a10ad97704575ee sender.connection.sendPlayerChatMessage(playerChatMessage, params); } diff --git a/src/main/java/net/minecraft/network/chat/PlayerChatMessage.java b/src/main/java/net/minecraft/network/chat/PlayerChatMessage.java -index 2f3e750c148e3c0c2c0c9e72572ec5021fbab2c9..843126bc73c449615ab81309d22db224a6f484ac 100644 +index d89049328641faa889b7c567123ab3a2c63b8df0..81e904e78c9fec49ac244f0a62cef75e5824f2dd 100644 --- a/src/main/java/net/minecraft/network/chat/PlayerChatMessage.java +++ b/src/main/java/net/minecraft/network/chat/PlayerChatMessage.java @@ -15,8 +15,54 @@ import net.minecraft.util.SignatureUpdater; @@ -2511,9 +2509,9 @@ index 2f3e750c148e3c0c2c0c9e72572ec5021fbab2c9..843126bc73c449615ab81309d22db224 + } + // Paper end - adventure; support signed messages public static final MapCodec<PlayerChatMessage> MAP_CODEC = RecordCodecBuilder.mapCodec( - instance -> { - return instance.group( -@@ -50,7 +96,7 @@ public record PlayerChatMessage( + instance -> instance.group( + SignedMessageLink.CODEC.fieldOf("link").forGetter(PlayerChatMessage::link), +@@ -47,7 +93,7 @@ public record PlayerChatMessage( } public PlayerChatMessage withUnsignedContent(Component unsignedContent) { diff --git a/patches/server/0013-Paper-Plugins.patch b/patches/server/0013-Paper-Plugins.patch index 114f21034c..24c7946f56 100644 --- a/patches/server/0013-Paper-Plugins.patch +++ b/patches/server/0013-Paper-Plugins.patch @@ -7117,10 +7117,10 @@ index f7114d5b8f2f93f62883e24da29afaf9f74ee1a6..8bf0630c0e06950cd99b7ae9898137f7 return foundFrame.orElse(null); diff --git a/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java b/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java -index a40bad65312fc65def43ba6d93ee97e97dcbad72..b85d4e8da923232ba2963a969a83b9e8936cb43f 100644 +index d14613f7d37198276c251e73703b060a971fac28..e741062f0c9c114db47124031c6fa6a6e145a5cd 100644 --- a/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java +++ b/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java -@@ -370,7 +370,13 @@ public class BuiltInRegistries { +@@ -312,7 +312,13 @@ public class BuiltInRegistries { } public static void bootStrap() { diff --git a/patches/server/0079-Do-not-load-chunks-for-Pathfinding.patch b/patches/server/0079-Do-not-load-chunks-for-Pathfinding.patch index 9ccd7b1587..55c9f2fd6e 100644 --- a/patches/server/0079-Do-not-load-chunks-for-Pathfinding.patch +++ b/patches/server/0079-Do-not-load-chunks-for-Pathfinding.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Do not load chunks for Pathfinding diff --git a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java -index c68d227e758f11a3146fc382014ce96651cd7acf..5ff66dd2ff2e3027ee7f7b62d5398c965195d8ed 100644 +index 79baaf943a01912c423823e1c153c062d5316232..9e51dcaae00967bcfd30615b1d978c333fafaa8f 100644 --- a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java +++ b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java -@@ -473,7 +473,12 @@ public class WalkNodeEvaluator extends NodeEvaluator { +@@ -469,7 +469,12 @@ public class WalkNodeEvaluator extends NodeEvaluator { for (int n = -1; n <= 1; n++) { if (l != 0 || n != 0) { pos.set(i + l, j + m, k + n); @@ -22,7 +22,7 @@ index c68d227e758f11a3146fc382014ce96651cd7acf..5ff66dd2ff2e3027ee7f7b62d5398c96 if (blockState.is(Blocks.CACTUS) || blockState.is(Blocks.SWEET_BERRY_BUSH)) { return BlockPathTypes.DANGER_OTHER; } -@@ -489,6 +494,7 @@ public class WalkNodeEvaluator extends NodeEvaluator { +@@ -485,6 +490,7 @@ public class WalkNodeEvaluator extends NodeEvaluator { if (blockState.is(Blocks.WITHER_ROSE) || blockState.is(Blocks.POINTED_DRIPSTONE)) { return BlockPathTypes.DAMAGE_CAUTIOUS; } @@ -30,7 +30,7 @@ index c68d227e758f11a3146fc382014ce96651cd7acf..5ff66dd2ff2e3027ee7f7b62d5398c96 } } } -@@ -498,7 +504,8 @@ public class WalkNodeEvaluator extends NodeEvaluator { +@@ -494,7 +500,8 @@ public class WalkNodeEvaluator extends NodeEvaluator { } protected static BlockPathTypes getBlockPathTypeRaw(BlockGetter world, BlockPos pos) { diff --git a/patches/server/0080-Add-PlayerUseUnknownEntityEvent.patch b/patches/server/0080-Add-PlayerUseUnknownEntityEvent.patch index f97fec7cb8..06d7226a38 100644 --- a/patches/server/0080-Add-PlayerUseUnknownEntityEvent.patch +++ b/patches/server/0080-Add-PlayerUseUnknownEntityEvent.patch @@ -9,10 +9,10 @@ virtual entities/entities that are not actually known to the server. Co-authored-by: Nassim Jahnke <[email protected]> diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java -index e4149e3108a163d2e33f78e45c852ded5a4833cc..893a0f362c4683db73d165405ea9b3913608ea1c 100644 +index b1bc671490329379e0a61466c13ca88c49259721..3a377e887989f591c671fec31208255252b58a78 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java -@@ -169,4 +169,14 @@ public class ServerboundInteractPacket implements Packet<ServerGamePacketListene +@@ -167,4 +167,14 @@ public class ServerboundInteractPacket implements Packet<ServerGamePacketListene buf.writeEnum(this.hand); } } diff --git a/patches/server/0085-Configurable-Player-Collision.patch b/patches/server/0085-Configurable-Player-Collision.patch index e1dc5880fe..d1204a16fd 100644 --- a/patches/server/0085-Configurable-Player-Collision.patch +++ b/patches/server/0085-Configurable-Player-Collision.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Configurable Player Collision diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java -index d60acdd2e2949461270a767569c3b105c9001024..e9d03ebfbd02a46b0ba274be107e099cc24b59e3 100644 +index f767bc67fb2b63e0476771b7caabc702ce05c800..0f05f1c2a30fef68ae635f4a2476b8cd1b6a127d 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java -@@ -200,7 +200,7 @@ public class ClientboundSetPlayerTeamPacket implements Packet<ClientGamePacketLi +@@ -198,7 +198,7 @@ public class ClientboundSetPlayerTeamPacket implements Packet<ClientGamePacketLi buf.writeComponent(this.displayName); buf.writeByte(this.options); buf.writeUtf(this.nametagVisibility); diff --git a/patches/server/0087-Configurable-RCON-IP-address.patch b/patches/server/0087-Configurable-RCON-IP-address.patch index 8db10da972..3520bc08a0 100644 --- a/patches/server/0087-Configurable-RCON-IP-address.patch +++ b/patches/server/0087-Configurable-RCON-IP-address.patch @@ -33,10 +33,10 @@ index d64ac84d4c5ef3dd3054a601deee128d3069686b..90fe26a546eeebf90ccf7f899103346c // CraftBukkit start diff --git a/src/main/java/net/minecraft/server/rcon/thread/RconThread.java b/src/main/java/net/minecraft/server/rcon/thread/RconThread.java -index 40d7b7d42506ea12ca348296f07ac090ccd67b73..cabaa1ea22b0ed66a45f6c0c2c051764ad65f37e 100644 +index cf6ff562614e07dfdc0ae1d2d68df67d61136df0..594fbb033b63b8c9fb8752b1fcc78f8e9f7a2a83 100644 --- a/src/main/java/net/minecraft/server/rcon/thread/RconThread.java +++ b/src/main/java/net/minecraft/server/rcon/thread/RconThread.java -@@ -59,7 +59,7 @@ public class RconThread extends GenericThread { +@@ -57,7 +57,7 @@ public class RconThread extends GenericThread { @Nullable public static RconThread create(ServerInterface server) { DedicatedServerProperties dedicatedServerProperties = server.getProperties(); diff --git a/patches/server/0114-Configurable-Cartographer-Treasure-Maps.patch b/patches/server/0114-Configurable-Cartographer-Treasure-Maps.patch index 8470a74ac8..e4dfccf663 100644 --- a/patches/server/0114-Configurable-Cartographer-Treasure-Maps.patch +++ b/patches/server/0114-Configurable-Cartographer-Treasure-Maps.patch @@ -9,10 +9,10 @@ Also allow turning off treasure maps all together as they can eat up Map ID's which are limited in quantity. diff --git a/src/main/java/net/minecraft/world/entity/npc/VillagerTrades.java b/src/main/java/net/minecraft/world/entity/npc/VillagerTrades.java -index 20fbbf57a9bc17803ff68f317a723f8fe1c46ff3..f8f7711545a8c51e3a81dc59d782b15e3a0ef4a1 100644 +index 5978240beb47bc5678e9aebc8d56aeb30dd7223a..bf2c2dd82831f85defa8b5760608f20e7036ebf6 100644 --- a/src/main/java/net/minecraft/world/entity/npc/VillagerTrades.java +++ b/src/main/java/net/minecraft/world/entity/npc/VillagerTrades.java -@@ -1644,7 +1644,8 @@ public class VillagerTrades { +@@ -1643,7 +1643,8 @@ public class VillagerTrades { return null; } else { ServerLevel serverLevel = (ServerLevel)entity.level(); @@ -23,10 +23,10 @@ index 20fbbf57a9bc17803ff68f317a723f8fe1c46ff3..f8f7711545a8c51e3a81dc59d782b15e ItemStack itemStack = MapItem.create(serverLevel, blockPos.getX(), blockPos.getZ(), (byte)2, true, true); MapItem.renderBiomePreviewMap(serverLevel, itemStack); diff --git a/src/main/java/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java b/src/main/java/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java -index 6adb72926d7bbc73d80b91dadbdb895a22bd0efd..4a6c4d943c60b8da1cd89a4cadfcb6fef8e4e7c9 100644 +index 59fa50fb8614d1492e31362feccc100701b56b8e..0bf1291fa4abf7f17381a48651a846379cedb3e1 100644 --- a/src/main/java/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java +++ b/src/main/java/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java -@@ -90,8 +90,17 @@ public class ExplorationMapFunction extends LootItemConditionalFunction { +@@ -83,8 +83,17 @@ public class ExplorationMapFunction extends LootItemConditionalFunction { Vec3 vec3 = context.getParamOrNull(LootContextParams.ORIGIN); if (vec3 != null) { ServerLevel serverLevel = context.getLevel(); diff --git a/patches/server/0197-Configurable-LootPool-luck-formula.patch b/patches/server/0197-Configurable-LootPool-luck-formula.patch index 929037b4c9..5748a6b1d6 100644 --- a/patches/server/0197-Configurable-LootPool-luck-formula.patch +++ b/patches/server/0197-Configurable-LootPool-luck-formula.patch @@ -36,10 +36,10 @@ This change will result in some major changes to fishing formulas. I would love to see this change in Vanilla, so Mojang please pull :) diff --git a/src/main/java/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java b/src/main/java/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java -index 128b1a1c11258c648b7734d5f41fbec8e2f1bd55..f385344f866e21ebdd7b0463822aa5dd7b82dfc4 100644 +index f73cfe6a1fd96ebc0e24d3488f00cd3403cb3454..4f73aae0342ddcefba19e14d5400c960c2acf70c 100644 --- a/src/main/java/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java +++ b/src/main/java/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java -@@ -128,9 +128,35 @@ public abstract class LootPoolSingletonContainer extends LootPoolEntryContainer +@@ -127,9 +127,35 @@ public abstract class LootPoolSingletonContainer extends LootPoolEntryContainer protected abstract class EntryBase implements LootPoolEntry { @Override public int getWeight(float luck) { diff --git a/patches/server/0202-Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch b/patches/server/0202-Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch index c009e429ef..a0ad6a5340 100644 --- a/patches/server/0202-Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch +++ b/patches/server/0202-Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch @@ -98,16 +98,16 @@ index 312398b7f1281144a0529a743d2a09376d575ff5..f832000cb023ce873f4437b6f6db19a6 world.playSound(null, entity, this.getImpactSound.apply(entity), SoundSource.NEUTRAL, 1.0F, 1.0F); } else if (this.hasRammedHornBreakingBlock(world, entity)) { diff --git 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 -index be7031dad5c30fefcdaccb9721e216374b2f26a8..e4626e981fbe6c7c9e17441429a8e3dd33d3e664 100644 +index af5efb89381092f938ef4aa3147fd0415ff909ab..c7138c9201885d396a2fd2505ebb3278d1651ecd 100644 --- 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 @@ -81,7 +81,7 @@ public class SonicBoom extends Behavior<Warden> { - target.hurt(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); + target.hurt(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); + target.push(vec33.x() * e, vec33.y() * d, vec33.z() * e, entity); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent - }); + }); } } diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java diff --git a/patches/server/0216-Improve-BlockPosition-inlining.patch b/patches/server/0216-Improve-BlockPosition-inlining.patch index 3e778d1ab7..52f65f41ad 100644 --- a/patches/server/0216-Improve-BlockPosition-inlining.patch +++ b/patches/server/0216-Improve-BlockPosition-inlining.patch @@ -21,10 +21,10 @@ This is based upon conclusions drawn from inspecting the assenmbly generated byt They had 'callq' (invoke) instead of 'mov' (get from memory) instructions. diff --git a/src/main/java/net/minecraft/core/Vec3i.java b/src/main/java/net/minecraft/core/Vec3i.java -index bc5a8e034ae0cd875689456ed862b46c1343bed9..8908905d76fb8568c9a3c18a54b03d6a93574be8 100644 +index 64acf7d83d3419af603ad43172c35ed321a2d1c4..afb1e5ff7b1b6b42f81eaa7888a1ec3ded804ccb 100644 --- a/src/main/java/net/minecraft/core/Vec3i.java +++ b/src/main/java/net/minecraft/core/Vec3i.java -@@ -43,12 +43,12 @@ public class Vec3i implements Comparable<Vec3i> { +@@ -37,12 +37,12 @@ public class Vec3i implements Comparable<Vec3i> { } @Override @@ -39,7 +39,7 @@ index bc5a8e034ae0cd875689456ed862b46c1343bed9..8908905d76fb8568c9a3c18a54b03d6a return (this.getY() + this.getZ() * 31) * 31 + this.getX(); } -@@ -61,15 +61,15 @@ public class Vec3i implements Comparable<Vec3i> { +@@ -55,15 +55,15 @@ public class Vec3i implements Comparable<Vec3i> { } } diff --git a/patches/server/0233-Optimize-BlockPosition-helper-methods.patch b/patches/server/0233-Optimize-BlockPosition-helper-methods.patch index 39da5505cc..876bc9b803 100644 --- a/patches/server/0233-Optimize-BlockPosition-helper-methods.patch +++ b/patches/server/0233-Optimize-BlockPosition-helper-methods.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Optimize BlockPosition helper methods diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java -index 44853c711442e0360e5631ae1c5d1d5a6edd2526..a965c4295b4db0aa304554d7d6d031dbcd591969 100644 +index ead823fa2a143acb05b33152ee1e5ee4b4936a20..4bc994bacdf1fbb7689d799d21a50b7903bf9e59 100644 --- a/src/main/java/net/minecraft/core/BlockPos.java +++ b/src/main/java/net/minecraft/core/BlockPos.java -@@ -132,67 +132,84 @@ public class BlockPos extends Vec3i { +@@ -131,67 +131,84 @@ public class BlockPos extends Vec3i { @Override public BlockPos above() { diff --git a/patches/server/0238-Optimize-MappedRegistry.patch b/patches/server/0238-Optimize-MappedRegistry.patch index 08acc887fa..6f50c2dc94 100644 --- a/patches/server/0238-Optimize-MappedRegistry.patch +++ b/patches/server/0238-Optimize-MappedRegistry.patch @@ -8,21 +8,19 @@ Use larger initial sizes to increase bucket capacity on the BiMap BiMap.get was seen to be using a good bit of CPU time. diff --git a/src/main/java/net/minecraft/core/MappedRegistry.java b/src/main/java/net/minecraft/core/MappedRegistry.java -index 814049ce20142a6820f30607b9cb6d2d426caa1c..d4bbc2172d95c2767902d8695a68f86af7e8baa7 100644 +index ffa0d08c0a2c8cb8f3f1c896b435acff02bdaed6..020f00b5aba1873310fb0e044bcc47140c405ebd 100644 --- a/src/main/java/net/minecraft/core/MappedRegistry.java +++ b/src/main/java/net/minecraft/core/MappedRegistry.java -@@ -36,13 +36,13 @@ public class MappedRegistry<T> implements WritableRegistry<T> { +@@ -36,11 +36,11 @@ public class MappedRegistry<T> implements WritableRegistry<T> { private static final Logger LOGGER = LogUtils.getLogger(); final ResourceKey<? extends Registry<T>> key; private final ObjectList<Holder.Reference<T>> byId = new ObjectArrayList<>(256); -- private final Reference2IntMap<T> toId = Util.make(new Reference2IntOpenHashMap<>(), map -> { -+ private final Reference2IntMap<T> toId = Util.make(new Reference2IntOpenHashMap<>(2048), map -> { // Paper - Perf: Use bigger expected size to reduce collisions - map.defaultReturnValue(-1); - }); +- private final Reference2IntMap<T> toId = Util.make(new Reference2IntOpenHashMap<>(), map -> map.defaultReturnValue(-1)); - private final Map<ResourceLocation, Holder.Reference<T>> byLocation = new HashMap<>(); - private final Map<ResourceKey<T>, Holder.Reference<T>> byKey = new HashMap<>(); - private final Map<T, Holder.Reference<T>> byValue = new IdentityHashMap<>(); - private final Map<T, Lifecycle> lifecycles = new IdentityHashMap<>(); ++ private final Reference2IntMap<T> toId = Util.make(new Reference2IntOpenHashMap<>(2048), map -> map.defaultReturnValue(-1)); // Paper - Perf: Use bigger expected size to reduce collisions + private final Map<ResourceLocation, Holder.Reference<T>> byLocation = new HashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions + private final Map<ResourceKey<T>, Holder.Reference<T>> byKey = new HashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions + private final Map<T, Holder.Reference<T>> byValue = new IdentityHashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions diff --git a/patches/server/0287-Entity-getEntitySpawnReason.patch b/patches/server/0287-Entity-getEntitySpawnReason.patch index 2e712d95da..aee2a0bbb9 100644 --- a/patches/server/0287-Entity-getEntitySpawnReason.patch +++ b/patches/server/0287-Entity-getEntitySpawnReason.patch @@ -120,10 +120,10 @@ index cae8c508972d771ad96228ace8a7e6cbc34d5489..3184f73ce799cc5202d2129be736e2fe // CraftBukkit start if (org.bukkit.craftbukkit.event.CraftEventFactory.callSpawnerSpawnEvent(entity, pos).isCancelled()) { diff --git a/src/main/java/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java -index c498e2881b22d23f8fbf558cc65f4e5a5ad4085e..ed3c82b96951af247680bde3e4e0951e80c7579e 100644 +index 41fa4258fbdd2f887383b9d3def10466557c406c..d71a9fb54269f7c7e251e0e3bdd8b5a072af5201 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java -@@ -187,7 +187,7 @@ public class SculkShriekerBlockEntity extends BlockEntity implements GameEventLi +@@ -181,7 +181,7 @@ public class SculkShriekerBlockEntity extends BlockEntity implements GameEventLi private boolean trySummonWarden(ServerLevel world) { return this.warningLevel >= 4 diff --git a/patches/server/0341-Remote-Connections-shouldn-t-hold-up-shutdown.patch b/patches/server/0341-Remote-Connections-shouldn-t-hold-up-shutdown.patch index 157b6e74e9..6a31d5070a 100644 --- a/patches/server/0341-Remote-Connections-shouldn-t-hold-up-shutdown.patch +++ b/patches/server/0341-Remote-Connections-shouldn-t-hold-up-shutdown.patch @@ -24,10 +24,10 @@ index 78775feb965d6eb98a1ff655ae44b9f0399ef9aa..28fe088d97bd5fbfcc29dcc7d2a657d5 System.exit(0); // CraftBukkit diff --git a/src/main/java/net/minecraft/server/rcon/thread/RconThread.java b/src/main/java/net/minecraft/server/rcon/thread/RconThread.java -index cabaa1ea22b0ed66a45f6c0c2c051764ad65f37e..5849d1163e70fb887b7596382dd24c204fab1339 100644 +index 594fbb033b63b8c9fb8752b1fcc78f8e9f7a2a83..c12d7db2b048a327c0e8f398848cd3a9bce0ebce 100644 --- a/src/main/java/net/minecraft/server/rcon/thread/RconThread.java +++ b/src/main/java/net/minecraft/server/rcon/thread/RconThread.java -@@ -106,6 +106,14 @@ public class RconThread extends GenericThread { +@@ -104,6 +104,14 @@ public class RconThread extends GenericThread { this.clients.clear(); } diff --git a/patches/server/0349-Reduce-memory-footprint-of-CompoundTag.patch b/patches/server/0349-Reduce-memory-footprint-of-CompoundTag.patch index 95b6084d67..56beb848eb 100644 --- a/patches/server/0349-Reduce-memory-footprint-of-CompoundTag.patch +++ b/patches/server/0349-Reduce-memory-footprint-of-CompoundTag.patch @@ -8,10 +8,10 @@ is important because we clone chunk data after reading it for safety. So, reduce the impact of the clone on GC. diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java -index 8a8dd896328ec3f392f3c5ef7c94633922e45ee3..17df3322cd407191465cc4ad09f355569228c772 100644 +index 1e2f58f2f95c558ce28706c405050c4c5701dd40..c7945686a4ee50d7a9d5f1173aa90e456f68b410 100644 --- a/src/main/java/net/minecraft/nbt/CompoundTag.java +++ b/src/main/java/net/minecraft/nbt/CompoundTag.java -@@ -53,7 +53,7 @@ public class CompoundTag implements Tag { +@@ -49,7 +49,7 @@ public class CompoundTag implements Tag { private static CompoundTag loadCompound(DataInput input, NbtAccounter tracker) throws IOException { tracker.accountBytes(48L); @@ -20,7 +20,7 @@ index 8a8dd896328ec3f392f3c5ef7c94633922e45ee3..17df3322cd407191465cc4ad09f35556 byte b; while ((b = input.readByte()) != 0) { -@@ -170,7 +170,7 @@ public class CompoundTag implements Tag { +@@ -166,7 +166,7 @@ public class CompoundTag implements Tag { } public CompoundTag() { @@ -29,7 +29,7 @@ index 8a8dd896328ec3f392f3c5ef7c94633922e45ee3..17df3322cd407191465cc4ad09f35556 } @Override -@@ -483,8 +483,16 @@ public class CompoundTag implements Tag { +@@ -477,8 +477,16 @@ public class CompoundTag implements Tag { @Override public CompoundTag copy() { diff --git a/patches/server/0368-Add-villager-reputation-API.patch b/patches/server/0368-Add-villager-reputation-API.patch index 4a32aef874..5043e90bdc 100644 --- a/patches/server/0368-Add-villager-reputation-API.patch +++ b/patches/server/0368-Add-villager-reputation-API.patch @@ -9,10 +9,10 @@ public net.minecraft.world.entity.ai.gossip.GossipContainer$EntityGossips <init> public net.minecraft.world.entity.ai.gossip.GossipContainer gossips diff --git a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java -index 398e6fe9de9fa49675a9a04facdfe54cb8c62c0c..2ac97b08932a182c1512ed935a4d76b341c6a6aa 100644 +index f06a5f0d9c5c877ddf963254d3124f5fe2d67282..aa32804bc9affe9a615d3ffaa513f6f09aab3f32 100644 --- a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java +++ b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java -@@ -225,6 +225,43 @@ public class GossipContainer { +@@ -216,6 +216,43 @@ public class GossipContainer { public void remove(GossipType gossipType) { this.entries.removeInt(gossipType); } diff --git a/patches/server/0381-Fix-piston-physics-inconsistency-MC-188840.patch b/patches/server/0381-Fix-piston-physics-inconsistency-MC-188840.patch index 0c989a3736..9aea09e883 100644 --- a/patches/server/0381-Fix-piston-physics-inconsistency-MC-188840.patch +++ b/patches/server/0381-Fix-piston-physics-inconsistency-MC-188840.patch @@ -66,10 +66,10 @@ index b3732a6246a2b011e36c5c35fa2ac7749e75db16..3ae61e7b50bfc440c597f88843f92903 } diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -index f7a2490d58cac95cb6dc8643e8e64df7e04f09df..8a5fccf52230eae9777a0157cc25c1321fcf094c 100644 +index 541f4ffd06509aa72cf26ea108f84160eac82bc3..0e15da7cae105196d444b924b8e0db190583ba30 100644 --- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -@@ -300,7 +300,7 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -296,7 +296,7 @@ public class PistonMovingBlockEntity extends BlockEntity { if (world.getBlockState(pos).is(Blocks.MOVING_PISTON)) { BlockState blockState = Block.updateFromNeighbourShapes(blockEntity.movedState, world, pos); if (blockState.isAir()) { diff --git a/patches/server/0382-Fix-missing-chunks-due-to-integer-overflow.patch b/patches/server/0382-Fix-missing-chunks-due-to-integer-overflow.patch index 771107a256..cc53c02b77 100644 --- a/patches/server/0382-Fix-missing-chunks-due-to-integer-overflow.patch +++ b/patches/server/0382-Fix-missing-chunks-due-to-integer-overflow.patch @@ -15,10 +15,10 @@ allows the distance calculation to avoid overflow and work as intended. This issue is being tracked in Mojira ticket MC-159283 diff --git a/src/main/java/net/minecraft/world/level/levelgen/DensityFunctions.java b/src/main/java/net/minecraft/world/level/levelgen/DensityFunctions.java -index 381dd2af60e9f45c0132a90e8dc1baec30aee4ad..61fcd3fc7b0990388a1bdde1b6c7f8a608520eeb 100644 +index ed4882fc82c97378b3512182c69e8a56fc74aea8..08165e84c0b8db7495bb66605bc73a269dd5152f 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/DensityFunctions.java +++ b/src/main/java/net/minecraft/world/level/levelgen/DensityFunctions.java -@@ -525,7 +525,7 @@ public final class DensityFunctions { +@@ -521,7 +521,7 @@ public final class DensityFunctions { int j = z / 2; int k = x % 2; int l = z % 2; diff --git a/patches/server/0394-Support-old-UUID-format-for-NBT.patch b/patches/server/0394-Support-old-UUID-format-for-NBT.patch index d144298802..c754088358 100644 --- a/patches/server/0394-Support-old-UUID-format-for-NBT.patch +++ b/patches/server/0394-Support-old-UUID-format-for-NBT.patch @@ -8,10 +8,10 @@ We have stored UUID in plenty of places that did not get DFU'd So just look for old format and load it if it exists. diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java -index 17df3322cd407191465cc4ad09f355569228c772..528b2b84889982fb37c81a72d51eb835c84eb843 100644 +index c7945686a4ee50d7a9d5f1173aa90e456f68b410..23916b011ed0645ab284fb080c9555921290d875 100644 --- a/src/main/java/net/minecraft/nbt/CompoundTag.java +++ b/src/main/java/net/minecraft/nbt/CompoundTag.java -@@ -236,6 +236,12 @@ public class CompoundTag implements Tag { +@@ -232,6 +232,12 @@ public class CompoundTag implements Tag { } public void putUUID(String key, UUID value) { @@ -24,7 +24,7 @@ index 17df3322cd407191465cc4ad09f355569228c772..528b2b84889982fb37c81a72d51eb835 this.tags.put(key, NbtUtils.createUUID(value)); } -@@ -244,10 +250,20 @@ public class CompoundTag implements Tag { +@@ -240,10 +246,20 @@ public class CompoundTag implements Tag { * You must use {@link #hasUUID(String)} before or else it <b>will</b> throw an NPE. */ public UUID getUUID(String key) { @@ -46,10 +46,10 @@ index 17df3322cd407191465cc4ad09f355569228c772..528b2b84889982fb37c81a72d51eb835 return tag != null && tag.getType() == IntArrayTag.TYPE && ((IntArrayTag)tag).getAsIntArray().length == 4; } diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java -index c5ac21c4cc50c7acf96f0ba3ac4713cd508f6a01..c613577572532fd1b8a8c912b9fd8e41c54669bb 100644 +index 3e395d575fab2348cd30a88511a194aba2d8e4ba..f3b11b08358fdd93464cd19b05047e10727a5799 100644 --- a/src/main/java/net/minecraft/nbt/NbtUtils.java +++ b/src/main/java/net/minecraft/nbt/NbtUtils.java -@@ -73,6 +73,14 @@ public final class NbtUtils { +@@ -65,6 +65,14 @@ public final class NbtUtils { @Nullable public static GameProfile readGameProfile(CompoundTag nbt) { UUID uUID = nbt.hasUUID("Id") ? nbt.getUUID("Id") : Util.NIL_UUID; diff --git a/patches/server/0407-Fix-AdvancementDataPlayer-leak-due-from-quitting-ear.patch b/patches/server/0407-Fix-AdvancementDataPlayer-leak-due-from-quitting-ear.patch index cf3d7a4259..ff901ed478 100644 --- a/patches/server/0407-Fix-AdvancementDataPlayer-leak-due-from-quitting-ear.patch +++ b/patches/server/0407-Fix-AdvancementDataPlayer-leak-due-from-quitting-ear.patch @@ -9,10 +9,10 @@ itself, so the criterion object stores no references - and thus needs no cleanup. diff --git a/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java b/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java -index 4e6d623de07bf1741050a9e899b85cd6c0efcaa0..670e59432979740caf283d839c2f42c9748fe215 100644 +index 9a387d5dc0925304d4163e3caa22206aaa68e3b7..795d1f3e6065baee4cadf71ae0eeabfa5522199b 100644 --- a/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java +++ b/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java -@@ -15,34 +15,34 @@ import net.minecraft.server.level.ServerPlayer; +@@ -15,32 +15,32 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.storage.loot.LootContext; public abstract class SimpleCriterionTrigger<T extends SimpleCriterionTrigger.SimpleInstance> implements CriterionTrigger<T> { @@ -21,10 +21,8 @@ index 4e6d623de07bf1741050a9e899b85cd6c0efcaa0..670e59432979740caf283d839c2f42c9 @Override public final void addPlayerListener(PlayerAdvancements manager, CriterionTrigger.Listener<T> conditions) { -- this.players.computeIfAbsent(manager, managerx -> { -+ manager.criterionData.computeIfAbsent(this, managerx -> { // Paper - fix AdvancementDataPlayer leak - return Sets.newHashSet(); - }).add(conditions); +- this.players.computeIfAbsent(manager, managerx -> Sets.newHashSet()).add(conditions); ++ manager.criterionData.computeIfAbsent(this, managerx -> Sets.newHashSet()).add(conditions); } @Override diff --git a/patches/server/0408-Optimize-NetworkManager-Exception-Handling.patch b/patches/server/0408-Optimize-NetworkManager-Exception-Handling.patch index c13a2fef23..320fb48f53 100644 --- a/patches/server/0408-Optimize-NetworkManager-Exception-Handling.patch +++ b/patches/server/0408-Optimize-NetworkManager-Exception-Handling.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Optimize NetworkManager Exception Handling diff --git a/src/main/java/net/minecraft/network/ConnectionProtocol.java b/src/main/java/net/minecraft/network/ConnectionProtocol.java -index fca5251008f21c0f3eee9390eca9b9fa2fef1151..147836d6dbbcf6978e82d1031eee754743bc254e 100644 +index 9d6dafb4855af9ccb7bc033ebf0fca5f75ceb9c6..347c4eff66ec1f3393494133ca59df2411dafa21 100644 --- a/src/main/java/net/minecraft/network/ConnectionProtocol.java +++ b/src/main/java/net/minecraft/network/ConnectionProtocol.java -@@ -596,6 +596,7 @@ public enum ConnectionProtocol { +@@ -590,6 +590,7 @@ public enum ConnectionProtocol { @Nullable public Packet<?> createPacket(int id, FriendlyByteBuf buf) { diff --git a/patches/server/0435-Fix-Concurrency-issue-in-ShufflingList.patch b/patches/server/0435-Fix-Concurrency-issue-in-ShufflingList.patch index 2df4bc442f..43d9b1f7e5 100644 --- a/patches/server/0435-Fix-Concurrency-issue-in-ShufflingList.patch +++ b/patches/server/0435-Fix-Concurrency-issue-in-ShufflingList.patch @@ -7,7 +7,7 @@ if multiple threads from worldgen sort at same time, it will crash. So make a copy of the list for sorting purposes. diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java -index 93c9075a5a1fe8bc27b8cfef13f84689f75580f3..ef1e9457aa215afd0d9a0a9cda2f6b5c4ac6974f 100644 +index 3288afe9aaf69c32a92b172fb1aaf3fbb8a494a5..5ca112631cce775c609950d3540059f54033fd3e 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java @@ -18,7 +18,7 @@ public class GateBehavior<E extends LivingEntity> implements BehaviorControl<E> @@ -20,7 +20,7 @@ index 93c9075a5a1fe8bc27b8cfef13f84689f75580f3..ef1e9457aa215afd0d9a0a9cda2f6b5c public GateBehavior( diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java -index 9b1203ce731f5de84c84fab149177ae6c7a389a3..21afbc0512c650399ebde59ac5938f83ef8439e8 100644 +index 195eea55fabc7a9a665e0a8f04934a3aaf9f8b71..3fac11bf02652b5f51f30f99bdf516504467d0d2 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java @@ -16,12 +16,25 @@ import net.minecraft.util.RandomSource; @@ -49,13 +49,11 @@ index 9b1203ce731f5de84c84fab149177ae6c7a389a3..21afbc0512c650399ebde59ac5938f83 this.entries = Lists.newArrayList(list); } -@@ -37,11 +50,12 @@ public class ShufflingList<U> implements Iterable<U> { +@@ -35,9 +48,12 @@ public class ShufflingList<U> implements Iterable<U> { } public ShufflingList<U> shuffle() { -- this.entries.forEach(entry -> { -- entry.setRandom(this.random.nextFloat()); -- }); +- this.entries.forEach(entry -> entry.setRandom(this.random.nextFloat())); - this.entries.sort(Comparator.comparingDouble(ShufflingList.WeightedEntry::getRandWeight)); - return this; + // Paper start - Fix Concurrency issue in ShufflingList during worldgen diff --git a/patches/server/0441-Reduce-blockpos-allocation-from-pathfinding.patch b/patches/server/0441-Reduce-blockpos-allocation-from-pathfinding.patch index b53931f78d..581e82fb41 100644 --- a/patches/server/0441-Reduce-blockpos-allocation-from-pathfinding.patch +++ b/patches/server/0441-Reduce-blockpos-allocation-from-pathfinding.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Reduce blockpos allocation from pathfinding diff --git a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java -index 5ff66dd2ff2e3027ee7f7b62d5398c965195d8ed..347cd0b7e1abbb03ee884261953da7e44ead0028 100644 +index 9e51dcaae00967bcfd30615b1d978c333fafaa8f..e5f4c3900b36586f4db4f5a5acbb7137c24f53df 100644 --- a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java +++ b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java -@@ -487,7 +487,7 @@ public class WalkNodeEvaluator extends NodeEvaluator { +@@ -483,7 +483,7 @@ public class WalkNodeEvaluator extends NodeEvaluator { return BlockPathTypes.DANGER_FIRE; } @@ -17,7 +17,7 @@ index 5ff66dd2ff2e3027ee7f7b62d5398c965195d8ed..347cd0b7e1abbb03ee884261953da7e4 return BlockPathTypes.WATER_BORDER; } -@@ -520,7 +520,7 @@ public class WalkNodeEvaluator extends NodeEvaluator { +@@ -516,7 +516,7 @@ public class WalkNodeEvaluator extends NodeEvaluator { } else if (blockState.is(Blocks.COCOA)) { return BlockPathTypes.COCOA; } else if (!blockState.is(Blocks.WITHER_ROSE) && !blockState.is(Blocks.POINTED_DRIPSTONE)) { diff --git a/patches/server/0458-Significantly-improve-performance-of-the-end-generat.patch b/patches/server/0458-Significantly-improve-performance-of-the-end-generat.patch index 8e15ca096a..dfab509fb3 100644 --- a/patches/server/0458-Significantly-improve-performance-of-the-end-generat.patch +++ b/patches/server/0458-Significantly-improve-performance-of-the-end-generat.patch @@ -12,10 +12,10 @@ Co-authored-by: Dylan Xaldin <[email protected]> Co-authored-by: pop4959 <[email protected]> diff --git a/src/main/java/net/minecraft/world/level/levelgen/DensityFunctions.java b/src/main/java/net/minecraft/world/level/levelgen/DensityFunctions.java -index 61fcd3fc7b0990388a1bdde1b6c7f8a608520eeb..b1a80220d967fcce451a003029ff61e1f72881f2 100644 +index 08165e84c0b8db7495bb66605bc73a269dd5152f..53db6d27c8d7daa7530435f953af8bd7b884a317 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/DensityFunctions.java +++ b/src/main/java/net/minecraft/world/level/levelgen/DensityFunctions.java -@@ -513,6 +513,16 @@ public final class DensityFunctions { +@@ -509,6 +509,16 @@ public final class DensityFunctions { ); private static final float ISLAND_THRESHOLD = -0.9F; private final SimplexNoise islandNoise; @@ -32,7 +32,7 @@ index 61fcd3fc7b0990388a1bdde1b6c7f8a608520eeb..b1a80220d967fcce451a003029ff61e1 public EndIslandDensityFunction(long seed) { RandomSource randomSource = new LegacyRandomSource(seed); -@@ -528,12 +538,26 @@ public final class DensityFunctions { +@@ -524,12 +534,26 @@ public final class DensityFunctions { float f = 100.0F - Mth.sqrt((long) x * (long) x + (long) z * (long) z) * 8.0F; // Paper - cast ints to long to avoid integer overflow float var18 = Mth.clamp(f, -100.0F, 80.0F); diff --git a/patches/server/0462-Add-PlayerShearBlockEvent.patch b/patches/server/0462-Add-PlayerShearBlockEvent.patch index 5c56301158..a38cf5e637 100644 --- a/patches/server/0462-Add-PlayerShearBlockEvent.patch +++ b/patches/server/0462-Add-PlayerShearBlockEvent.patch @@ -39,7 +39,7 @@ index 44e72176a0da08a77fa192ee31c0fcd53f0dc22d..27f1c1ac12251f1438ee8bf14f4afb5f entityhuman1.broadcastBreakEvent(hand); }); diff --git a/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java b/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java -index e2e13874bf41178228d0414ea51167cd6aa23053..88dfa1eb8b4c588aafffed7b8e8b68e0bae28f4b 100644 +index c0098fe96201bfc448e7d2e3d672c310c9c9e75a..966783c646dae5a79259c1a322a9cfc8dd83d997 100644 --- a/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java +++ b/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java @@ -35,16 +35,24 @@ public class PumpkinBlock extends Block { @@ -73,6 +73,6 @@ index e2e13874bf41178228d0414ea51167cd6aa23053..88dfa1eb8b4c588aafffed7b8e8b68e0 ); world.addFreshEntity(itemEntity); + } // Paper - Add PlayerShearBlockEvent - itemStack.hurtAndBreak(1, player, playerx -> { - playerx.broadcastBreakEvent(hand); - }); + itemStack.hurtAndBreak(1, player, playerx -> playerx.broadcastBreakEvent(hand)); + world.gameEvent(player, GameEvent.SHEAR, pos); + player.awardStat(Stats.ITEM_USED.get(Items.SHEARS)); diff --git a/patches/server/0478-Add-PlayerFlowerPotManipulateEvent.patch b/patches/server/0478-Add-PlayerFlowerPotManipulateEvent.patch index dedc31d955..ba8831c6f6 100644 --- a/patches/server/0478-Add-PlayerFlowerPotManipulateEvent.patch +++ b/patches/server/0478-Add-PlayerFlowerPotManipulateEvent.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add PlayerFlowerPotManipulateEvent diff --git a/src/main/java/net/minecraft/world/level/block/FlowerPotBlock.java b/src/main/java/net/minecraft/world/level/block/FlowerPotBlock.java -index ba0cdfb946678bdd96ec065f2ada956addccf610..cadfd0ec0fb04ac817601cbef6230b10b6b1af35 100644 +index cb77c7af329dd9fa8dc28ee3cfc475baa4b1392b..8e8fa6e0823258220b604ceef8e1f5ae15556b9a 100644 --- a/src/main/java/net/minecraft/world/level/block/FlowerPotBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FlowerPotBlock.java -@@ -67,6 +67,21 @@ public class FlowerPotBlock extends Block { +@@ -66,6 +66,21 @@ public class FlowerPotBlock extends Block { boolean bl = blockState.is(Blocks.AIR); boolean bl2 = this.isEmpty(); if (bl != bl2) { diff --git a/patches/server/0489-Configurable-door-breaking-difficulty.patch b/patches/server/0489-Configurable-door-breaking-difficulty.patch index ce0156aaf0..18f1e68a47 100644 --- a/patches/server/0489-Configurable-door-breaking-difficulty.patch +++ b/patches/server/0489-Configurable-door-breaking-difficulty.patch @@ -10,10 +10,10 @@ public net.minecraft.world.entity.monster.Zombie DOOR_BREAKING_PREDICATE Co-authored-by: Doc <[email protected]> diff --git a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java -index 42a12615451f9ea9df683a088df42dc41c8a7ebb..a72c29e3e04c3d649bc5cc2637be1a4ed5ec525c 100644 +index 89a05518e1b95f6edc1ac57f6ed9c3946b87b93e..0ee020848cdfd0c069f1e8d3a9516a339d82467c 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java +++ b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java -@@ -198,7 +198,7 @@ public class Vindicator extends AbstractIllager { +@@ -196,7 +196,7 @@ public class Vindicator extends AbstractIllager { static class VindicatorBreakDoorGoal extends BreakDoorGoal { public VindicatorBreakDoorGoal(Mob mob) { diff --git a/patches/server/0510-Inline-shift-direction-fields.patch b/patches/server/0510-Inline-shift-direction-fields.patch index 832d9f67e8..88027eb7c0 100644 --- a/patches/server/0510-Inline-shift-direction-fields.patch +++ b/patches/server/0510-Inline-shift-direction-fields.patch @@ -7,22 +7,23 @@ Removes a layer of indirection for EnumDirection.getAdjacent(X|Y|Z)(), which is critical section for much of the server, including the lighting engine. diff --git a/src/main/java/net/minecraft/core/Direction.java b/src/main/java/net/minecraft/core/Direction.java -index 60867bd1c64aba844aa7b5d4f9577607be9cc8e5..83a2b952df749b7aaab439db4ec2d38bc4f5b11c 100644 +index 14b57310811bb930b40396a02b263cdbccb1076b..75694cfd7d8adde6b9246518c20fe75774297a57 100644 --- a/src/main/java/net/minecraft/core/Direction.java +++ b/src/main/java/net/minecraft/core/Direction.java -@@ -48,6 +48,11 @@ public enum Direction implements StringRepresentable { - }).sorted(Comparator.comparingInt(direction -> { - return direction.data2d; - })).toArray(Direction[]::new); +@@ -48,6 +48,12 @@ public enum Direction implements StringRepresentable { + .sorted(Comparator.comparingInt(direction -> direction.data2d)) + .toArray(Direction[]::new); + + // Paper start - Perf: Inline shift direction fields + private final int adjX; + private final int adjY; + private final int adjZ; + // Paper end - Perf: Inline shift direction fields - ++ private Direction(int id, int idOpposite, int idHorizontal, String name, Direction.AxisDirection direction, Direction.Axis axis, Vec3i vector) { this.data3d = id; -@@ -57,6 +62,11 @@ public enum Direction implements StringRepresentable { + this.data2d = idHorizontal; +@@ -56,6 +62,11 @@ public enum Direction implements StringRepresentable { this.axis = axis; this.axisDirection = direction; this.normal = vector; @@ -34,7 +35,7 @@ index 60867bd1c64aba844aa7b5d4f9577607be9cc8e5..83a2b952df749b7aaab439db4ec2d38b } public static Direction[] orderedByNearest(Entity entity) { -@@ -220,15 +230,15 @@ public enum Direction implements StringRepresentable { +@@ -219,15 +230,15 @@ public enum Direction implements StringRepresentable { } public int getStepX() { diff --git a/patches/server/0513-living-entity-allow-attribute-registration.patch b/patches/server/0513-living-entity-allow-attribute-registration.patch index 154aa1be98..b05d18bed0 100644 --- a/patches/server/0513-living-entity-allow-attribute-registration.patch +++ b/patches/server/0513-living-entity-allow-attribute-registration.patch @@ -5,11 +5,11 @@ Subject: [PATCH] living entity allow attribute registration diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java -index a88404f5b7b86692da43a1b64c352b9f9e041238..3ca7909fa233d440dbaa57c05954188687308ecc 100644 +index 4228d28b2f697e7dc320525c1ad48a8a2aa0fdb4..b99a080ab27e24d8131fda931ca70d6d271bb01c 100644 --- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java +++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java -@@ -146,4 +146,12 @@ public class AttributeMap { - }); +@@ -138,4 +138,12 @@ public class AttributeMap { + }, () -> LOGGER.warn("Ignoring unknown attribute '{}'", string)); } } + diff --git a/patches/server/0517-Improve-ServerGUI.patch b/patches/server/0517-Improve-ServerGUI.patch index f626efff64..9aec8b6334 100644 --- a/patches/server/0517-Improve-ServerGUI.patch +++ b/patches/server/0517-Improve-ServerGUI.patch @@ -58,10 +58,10 @@ index 2bbc57b4869caf690f53618d60359c5133ec62a8..c42a9949c4d37d45883867a54222a7ab public void windowClosing(WindowEvent windowevent) { if (!servergui.isClosing.getAndSet(true)) { diff --git a/src/main/java/net/minecraft/server/gui/StatsComponent.java b/src/main/java/net/minecraft/server/gui/StatsComponent.java -index 28cf84d136275d67dd5107dc282f4320a5ae8b1d..8994bf9abb79d958e8928b94e75b3fa30ed9d5cc 100644 +index 6e9c6d556ed55325e36d191fc9d1508c00879671..096c89bd01cec2abd151bf6fffc4847d1bcd548f 100644 --- a/src/main/java/net/minecraft/server/gui/StatsComponent.java +++ b/src/main/java/net/minecraft/server/gui/StatsComponent.java -@@ -36,10 +36,19 @@ public class StatsComponent extends JComponent { +@@ -34,10 +34,19 @@ public class StatsComponent extends JComponent { private void tick() { long l = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); @@ -81,7 +81,7 @@ index 28cf84d136275d67dd5107dc282f4320a5ae8b1d..8994bf9abb79d958e8928b94e75b3fa3 this.values[this.vp++ & 0xFF] = (int)(l * 100L / Runtime.getRuntime().maxMemory()); this.repaint(); } -@@ -68,4 +77,10 @@ public class StatsComponent extends JComponent { +@@ -66,4 +75,10 @@ public class StatsComponent extends JComponent { public void close() { this.timer.stop(); } diff --git a/patches/server/0557-Expand-PlayerGameModeChangeEvent.patch b/patches/server/0557-Expand-PlayerGameModeChangeEvent.patch index 72428d5c8f..809cfad9a7 100644 --- a/patches/server/0557-Expand-PlayerGameModeChangeEvent.patch +++ b/patches/server/0557-Expand-PlayerGameModeChangeEvent.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Expand PlayerGameModeChangeEvent diff --git a/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java b/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java -index 698db6fc0e1088bb80bf277bf14719cad6b68055..ec813a8a0f7e48ce93bf9d254c68ddd56b0a6737 100644 +index b95a979f8f58f43e0becedcd843ff8bb992eb455..a046a0b1519806ff3d987e6402f152b60a3a6f4c 100644 --- a/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java +++ b/src/main/java/net/minecraft/server/commands/DefaultGameModeCommands.java -@@ -25,9 +25,13 @@ public class DefaultGameModeCommands { +@@ -28,9 +28,13 @@ public class DefaultGameModeCommands { GameType gameType = minecraftServer.getForcedGameType(); if (gameType != null) { for (ServerPlayer serverPlayer : minecraftServer.getPlayerList().getPlayers()) { @@ -25,10 +25,10 @@ index 698db6fc0e1088bb80bf277bf14719cad6b68055..ec813a8a0f7e48ce93bf9d254c68ddd5 } diff --git a/src/main/java/net/minecraft/server/commands/GameModeCommand.java b/src/main/java/net/minecraft/server/commands/GameModeCommand.java -index f5be3b762b096540952421c52e4bd23c2d31b917..b1cbf365125b4db64b46a1f834b6d93808cbd709 100644 +index 7f09119bc7d661e08a960dd2bd46006efe752d3e..d1da3600dc07107309b20ebe6e7c0c4da0e8de76 100644 --- a/src/main/java/net/minecraft/server/commands/GameModeCommand.java +++ b/src/main/java/net/minecraft/server/commands/GameModeCommand.java -@@ -63,9 +63,14 @@ public class GameModeCommand { +@@ -60,9 +60,14 @@ public class GameModeCommand { int i = 0; for (ServerPlayer serverPlayer : targets) { diff --git a/patches/server/0569-Add-PlayerKickEvent-causes.patch b/patches/server/0569-Add-PlayerKickEvent-causes.patch index 8607264816..17147225c5 100644 --- a/patches/server/0569-Add-PlayerKickEvent-causes.patch +++ b/patches/server/0569-Add-PlayerKickEvent-causes.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add PlayerKickEvent causes diff --git a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java -index 1bb98a7e5267602bf9c37ba5041ff75d77d53e15..ec260062e5206df08425ad65573691fda262fa93 100644 +index e15d740275d265c460c1771cdad5556bcec9d798..0af9ed92824ccf30814eceb6a2c2e5c12661c991 100644 --- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java +++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java @@ -34,16 +34,16 @@ public class SignedMessageChain { @@ -61,10 +61,10 @@ index c9545f96317fd6692889d82851d76084efa6a61d..fdda28bd6aa3a2d3079a383157b82ff8 } diff --git a/src/main/java/net/minecraft/server/commands/BanIpCommands.java b/src/main/java/net/minecraft/server/commands/BanIpCommands.java -index 33cadaac63f70384f8997a95a41462afcea9d27e..e7c2672798b5b50f25f924ca87db27fac229f820 100644 +index b451f98aaa5b694cfd9fadebcb5a4441951e9e87..b23dca02fe85a299d13353706915db2aec3467a6 100644 --- a/src/main/java/net/minecraft/server/commands/BanIpCommands.java +++ b/src/main/java/net/minecraft/server/commands/BanIpCommands.java -@@ -61,7 +61,7 @@ public class BanIpCommands { +@@ -66,7 +66,7 @@ public class BanIpCommands { } for (ServerPlayer serverPlayer : list) { @@ -74,11 +74,11 @@ index 33cadaac63f70384f8997a95a41462afcea9d27e..e7c2672798b5b50f25f924ca87db27fa return list.size(); diff --git a/src/main/java/net/minecraft/server/commands/BanPlayerCommands.java b/src/main/java/net/minecraft/server/commands/BanPlayerCommands.java -index 8b677cd8974900ef214ebbf441f6a00e88153a77..f5f73d519819e00c8377cd9cf7907704f08a2549 100644 +index e63a03a419061edc6a1305f6469d2282d960d6d1..be436480873ac914d67dac36061ac087b7389ab1 100644 --- a/src/main/java/net/minecraft/server/commands/BanPlayerCommands.java +++ b/src/main/java/net/minecraft/server/commands/BanPlayerCommands.java -@@ -44,7 +44,7 @@ public class BanPlayerCommands { - }, true); +@@ -55,7 +55,7 @@ public class BanPlayerCommands { + ); ServerPlayer serverPlayer = source.getServer().getPlayerList().getPlayer(gameProfile.getId()); if (serverPlayer != null) { - serverPlayer.connection.disconnect(Component.translatable("multiplayer.disconnect.banned")); @@ -87,18 +87,18 @@ index 8b677cd8974900ef214ebbf441f6a00e88153a77..f5f73d519819e00c8377cd9cf7907704 } } diff --git a/src/main/java/net/minecraft/server/commands/KickCommand.java b/src/main/java/net/minecraft/server/commands/KickCommand.java -index 1f82f045d059ba455459e5c9a546c1948e379539..43e0b479891b6e92af7e592bdbe3c7d22888429b 100644 +index d1caaecfdfba1cdeba032f0bc38c06541fa61633..6468b3a25c7527a2fde6899e4812b5cb79ce4b1d 100644 --- a/src/main/java/net/minecraft/server/commands/KickCommand.java +++ b/src/main/java/net/minecraft/server/commands/KickCommand.java -@@ -35,7 +35,7 @@ public class KickCommand { +@@ -48,7 +48,7 @@ public class KickCommand { for (ServerPlayer serverPlayer : targets) { if (!source.getServer().isSingleplayerOwner(serverPlayer.getGameProfile())) { - serverPlayer.connection.disconnect(reason); + serverPlayer.connection.disconnect(reason, org.bukkit.event.player.PlayerKickEvent.Cause.KICK_COMMAND); // Paper - kick event cause - source.sendSuccess(() -> { - return Component.translatable("commands.kick.success", serverPlayer.getDisplayName(), reason); - }, true); + source.sendSuccess(() -> Component.translatable("commands.kick.success", serverPlayer.getDisplayName(), reason), true); + i++; + } diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java index 6bb846d3ee2fb54ab3ffa116607f2a83e538460e..a65a1466dab52fca75cda16a4b22fef03b6207a0 100644 --- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java @@ -461,7 +461,7 @@ index e913acef00c0a1a2f49779800b46997588b46253..dcb8de1c28b767068aa10f044bd8cf72 // CraftBukkit end diff --git a/src/main/java/net/minecraft/world/entity/player/ProfilePublicKey.java b/src/main/java/net/minecraft/world/entity/player/ProfilePublicKey.java -index 7e474f8ff62169ad6ef1fdb940bb725cf3a26c43..b45b48df79102af21ef617773ab76be281764ff9 100644 +index f472dea0bd4f834c0c8f0aa59ae7cdae082b14af..2fa51c3a70f43cd23b8f494fc643d66cecfda7d2 100644 --- a/src/main/java/net/minecraft/world/entity/player/ProfilePublicKey.java +++ b/src/main/java/net/minecraft/world/entity/player/ProfilePublicKey.java @@ -24,7 +24,7 @@ public record ProfilePublicKey(ProfilePublicKey.Data data) { @@ -473,7 +473,7 @@ index 7e474f8ff62169ad6ef1fdb940bb725cf3a26c43..b45b48df79102af21ef617773ab76be2 } else { return new ProfilePublicKey(publicKeyData); } -@@ -90,8 +90,16 @@ public record ProfilePublicKey(ProfilePublicKey.Data data) { +@@ -88,8 +88,16 @@ public record ProfilePublicKey(ProfilePublicKey.Data data) { } public static class ValidationException extends ThrowingComponent { diff --git a/patches/server/0572-Synchronize-PalettedContainer-instead-of-ThreadingDe.patch b/patches/server/0572-Synchronize-PalettedContainer-instead-of-ThreadingDe.patch index 22417860f4..2deed69271 100644 --- a/patches/server/0572-Synchronize-PalettedContainer-instead-of-ThreadingDe.patch +++ b/patches/server/0572-Synchronize-PalettedContainer-instead-of-ThreadingDe.patch @@ -14,10 +14,10 @@ contention situations. And this is extremely a low contention situation. diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java -index 8095da1ae11e0b01e8c86346a0bea67ac96443a8..a1ace0df243b43768bbb60a0941c18e3f5d10dfd 100644 +index 6b37d460a76156162743d77d192f34366b29e5f9..268752a0b939abcaa9c7a302d2642b0c0fa2d331 100644 --- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java -@@ -32,14 +32,14 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer +@@ -30,14 +30,14 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer public final IdMap<T> registry; private volatile PalettedContainer.Data<T> data; private final PalettedContainer.Strategy strategy; @@ -35,7 +35,7 @@ index 8095da1ae11e0b01e8c86346a0bea67ac96443a8..a1ace0df243b43768bbb60a0941c18e3 } public static <T> Codec<PalettedContainer<T>> codecRW(IdMap<T> idList, Codec<T> entryCodec, PalettedContainer.Strategy paletteProvider, T defaultValue) { -@@ -111,7 +111,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer +@@ -104,7 +104,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer } @Override @@ -44,7 +44,7 @@ index 8095da1ae11e0b01e8c86346a0bea67ac96443a8..a1ace0df243b43768bbb60a0941c18e3 PalettedContainer.Data<T> data = this.data; PalettedContainer.Data<T> data2 = this.createOrReuseData(data, newBits); data2.copyFrom(data.palette, data.storage); -@@ -136,7 +136,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer +@@ -129,7 +129,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer return this.getAndSet(this.strategy.getIndex(x, y, z), value); } @@ -53,7 +53,7 @@ index 8095da1ae11e0b01e8c86346a0bea67ac96443a8..a1ace0df243b43768bbb60a0941c18e3 int i = this.data.palette.idFor(value); int j = this.data.storage.getAndSet(index, i); return this.data.palette.valueFor(j); -@@ -152,7 +152,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer +@@ -145,7 +145,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer } } @@ -62,8 +62,8 @@ index 8095da1ae11e0b01e8c86346a0bea67ac96443a8..a1ace0df243b43768bbb60a0941c18e3 int i = this.data.palette.idFor(value); this.data.storage.set(index, i); } -@@ -177,7 +177,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer - }); +@@ -168,7 +168,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer + intSet.forEach(id -> action.accept(palette.valueFor(id))); } - public void read(FriendlyByteBuf buf) { @@ -71,7 +71,7 @@ index 8095da1ae11e0b01e8c86346a0bea67ac96443a8..a1ace0df243b43768bbb60a0941c18e3 this.acquire(); try { -@@ -192,7 +192,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer +@@ -183,7 +183,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer } @Override @@ -80,7 +80,7 @@ index 8095da1ae11e0b01e8c86346a0bea67ac96443a8..a1ace0df243b43768bbb60a0941c18e3 this.acquire(); try { -@@ -248,7 +248,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer +@@ -231,7 +231,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer } @Override diff --git a/patches/server/0578-Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch b/patches/server/0578-Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch index db1e86c9fe..efeca7582b 100644 --- a/patches/server/0578-Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch +++ b/patches/server/0578-Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Optimize Biome Mob Lookups for Mob Spawning Uses an EnumMap as well as a Set paired List for O(1) contains calls. diff --git a/src/main/java/net/minecraft/world/level/biome/MobSpawnSettings.java b/src/main/java/net/minecraft/world/level/biome/MobSpawnSettings.java -index c9056ce165a39d9c135cbc5bbbd21c5e418fbf31..0550da2840a6a084b3aa308d28e64d2a27cc78ee 100644 +index c376a6cc04faf8d8545c99c0815682ea7cad98db..ffa24b71400f2041c9154817c6c767bc7dffb176 100644 --- a/src/main/java/net/minecraft/world/level/biome/MobSpawnSettings.java +++ b/src/main/java/net/minecraft/world/level/biome/MobSpawnSettings.java -@@ -81,12 +81,44 @@ public class MobSpawnSettings { +@@ -75,8 +75,40 @@ public class MobSpawnSettings { } public static class Builder { @@ -45,13 +45,8 @@ index c9056ce165a39d9c135cbc5bbbd21c5e418fbf31..0550da2840a6a084b3aa308d28e64d2a + } + // use toImmutableEnumMap collector private final Map<MobCategory, List<MobSpawnSettings.SpawnerData>> spawners = Stream.of(MobCategory.values()) -- .collect(ImmutableMap.toImmutableMap(mobCategory -> { -+ .collect(Maps.toImmutableEnumMap(mobCategory -> { - return (MobCategory)mobCategory; - }, mobCategory -> { -- return Lists.newArrayList(); -+ return new MobList(); // Use MobList instead of ArrayList - })); +- .collect(ImmutableMap.toImmutableMap(mobCategory -> (MobCategory)mobCategory, mobCategory -> Lists.newArrayList())); ++ .collect(Maps.toImmutableEnumMap(mobCategory -> (MobCategory)mobCategory, mobCategory -> new MobList())); // Use MobList instead of ArrayList + // Paper end - Perf: keep track of data in a pair set to give O(1) contains calls private final Map<EntityType<?>, MobSpawnSettings.MobSpawnCost> mobSpawnCosts = Maps.newLinkedHashMap(); private float creatureGenerationProbability = 0.1F; diff --git a/patches/server/0619-Add-more-advancement-API.patch b/patches/server/0619-Add-more-advancement-API.patch index 4490ddc039..c86f1459b7 100644 --- a/patches/server/0619-Add-more-advancement-API.patch +++ b/patches/server/0619-Add-more-advancement-API.patch @@ -84,10 +84,10 @@ index 0000000000000000000000000000000000000000..adac21ce6db3ff7a56dbcd6bffc02143 + } +} diff --git a/src/main/java/net/minecraft/advancements/DisplayInfo.java b/src/main/java/net/minecraft/advancements/DisplayInfo.java -index 07bff6a054b26332dcbae56a357176a9f6f15d4d..32969022be43fc7094b44e3cd268622ba836c3ae 100644 +index 3751b43469e92b8a3d70ec3d5413bc1571147e6e..8057d42f2484bca8e5555e3010c27b898c4245b5 100644 --- a/src/main/java/net/minecraft/advancements/DisplayInfo.java +++ b/src/main/java/net/minecraft/advancements/DisplayInfo.java -@@ -36,6 +36,7 @@ public class DisplayInfo { +@@ -34,6 +34,7 @@ public class DisplayInfo { private final boolean hidden; private float x; private float y; diff --git a/patches/server/0632-Sanitize-ResourceLocation-error-logging.patch b/patches/server/0632-Sanitize-ResourceLocation-error-logging.patch index 644928b836..3c467a8134 100644 --- a/patches/server/0632-Sanitize-ResourceLocation-error-logging.patch +++ b/patches/server/0632-Sanitize-ResourceLocation-error-logging.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Sanitize ResourceLocation error logging diff --git a/src/main/java/net/minecraft/resources/ResourceLocation.java b/src/main/java/net/minecraft/resources/ResourceLocation.java -index 980ba384d15c69030d033426290678e569af23b4..651a61681b0b484253f82b43a75e76c5a1c40543 100644 +index aed74e471126a8a66046a181973158d7d288d3f0..3908f88959e43d2f485d5f239257e6564dbda6cd 100644 --- a/src/main/java/net/minecraft/resources/ResourceLocation.java +++ b/src/main/java/net/minecraft/resources/ResourceLocation.java -@@ -209,7 +209,7 @@ public class ResourceLocation implements Comparable<ResourceLocation> { +@@ -207,7 +207,7 @@ public class ResourceLocation implements Comparable<ResourceLocation> { private static String assertValidNamespace(String namespace, String path) { if (!isValidNamespace(namespace)) { @@ -17,7 +17,7 @@ index 980ba384d15c69030d033426290678e569af23b4..651a61681b0b484253f82b43a75e76c5 } else { return namespace; } -@@ -235,7 +235,7 @@ public class ResourceLocation implements Comparable<ResourceLocation> { +@@ -233,7 +233,7 @@ public class ResourceLocation implements Comparable<ResourceLocation> { private static String assertValidPath(String namespace, String path) { if (!isValidPath(path)) { diff --git a/patches/server/0633-Manually-inline-methods-in-BlockPosition.patch b/patches/server/0633-Manually-inline-methods-in-BlockPosition.patch index 8a43418cf2..870042962d 100644 --- a/patches/server/0633-Manually-inline-methods-in-BlockPosition.patch +++ b/patches/server/0633-Manually-inline-methods-in-BlockPosition.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Manually inline methods in BlockPosition diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java -index a965c4295b4db0aa304554d7d6d031dbcd591969..f06a51b70df8450801a27bb06e6d7f6e4ee3049e 100644 +index 4bc994bacdf1fbb7689d799d21a50b7903bf9e59..d80e3f5f53b9d28dea574cff5c65dfa3f8148f88 100644 --- a/src/main/java/net/minecraft/core/BlockPos.java +++ b/src/main/java/net/minecraft/core/BlockPos.java -@@ -547,9 +547,9 @@ public class BlockPos extends Vec3i { +@@ -536,9 +536,9 @@ public class BlockPos extends Vec3i { } public BlockPos.MutableBlockPos set(int x, int y, int z) { @@ -21,7 +21,7 @@ index a965c4295b4db0aa304554d7d6d031dbcd591969..f06a51b70df8450801a27bb06e6d7f6e return this; } -@@ -614,19 +614,19 @@ public class BlockPos extends Vec3i { +@@ -603,19 +603,19 @@ public class BlockPos extends Vec3i { @Override public BlockPos.MutableBlockPos setX(int i) { @@ -45,12 +45,12 @@ index a965c4295b4db0aa304554d7d6d031dbcd591969..f06a51b70df8450801a27bb06e6d7f6e } diff --git a/src/main/java/net/minecraft/core/Vec3i.java b/src/main/java/net/minecraft/core/Vec3i.java -index 8908905d76fb8568c9a3c18a54b03d6a93574be8..5d996ece22d893818cda7c521725b2fd199759ff 100644 +index afb1e5ff7b1b6b42f81eaa7888a1ec3ded804ccb..21387401c7958414fa6f3fd530488481d92a6eca 100644 --- a/src/main/java/net/minecraft/core/Vec3i.java +++ b/src/main/java/net/minecraft/core/Vec3i.java -@@ -19,9 +19,9 @@ public class Vec3i implements Comparable<Vec3i> { - return IntStream.of(vec.getX(), vec.getY(), vec.getZ()); - }); +@@ -17,9 +17,9 @@ public class Vec3i implements Comparable<Vec3i> { + vec -> IntStream.of(vec.getX(), vec.getY(), vec.getZ()) + ); public static final Vec3i ZERO = new Vec3i(0, 0, 0); - private int x; - private int y; diff --git a/patches/server/0649-Fix-CocaoDecorator-causing-a-crash-when-trying-to-ge.patch b/patches/server/0649-Fix-CocaoDecorator-causing-a-crash-when-trying-to-ge.patch index f62cd66b50..db1f49cd0a 100644 --- a/patches/server/0649-Fix-CocaoDecorator-causing-a-crash-when-trying-to-ge.patch +++ b/patches/server/0649-Fix-CocaoDecorator-causing-a-crash-when-trying-to-ge.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Fix CocaoDecorator causing a crash when trying to generate diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/treedecorators/CocoaDecorator.java b/src/main/java/net/minecraft/world/level/levelgen/feature/treedecorators/CocoaDecorator.java -index fab1fbd2699c50336e764b8f12ce98a527ebba74..61deaeeb719fae6b27f0afa88357c9018c1bdd7b 100644 +index 05a874404daec8d7194e0d5bc8d17f76d3cc94ef..961a772eecb759c8c2a2e1461988fdb3f06dd1b0 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/feature/treedecorators/CocoaDecorator.java +++ b/src/main/java/net/minecraft/world/level/levelgen/feature/treedecorators/CocoaDecorator.java -@@ -25,6 +25,7 @@ public class CocoaDecorator extends TreeDecorator { +@@ -26,6 +26,7 @@ public class CocoaDecorator extends TreeDecorator { @Override public void place(TreeDecorator.Context generator) { diff --git a/patches/server/0654-prevent-unintended-light-block-manipulation.patch b/patches/server/0654-prevent-unintended-light-block-manipulation.patch index bacb3c9757..9371202698 100644 --- a/patches/server/0654-prevent-unintended-light-block-manipulation.patch +++ b/patches/server/0654-prevent-unintended-light-block-manipulation.patch @@ -5,10 +5,10 @@ Subject: [PATCH] prevent unintended light block manipulation diff --git a/src/main/java/net/minecraft/world/level/block/LightBlock.java b/src/main/java/net/minecraft/world/level/block/LightBlock.java -index 51452f816b02770d5e015d753cd008f598198ddc..504a2c0ec7e479d80aeb5fc6434c73d6e36167c9 100644 +index 0fe3186b4edbbc93f5794d23dffe58c063be8d67..95d36c3a74d0b71662864f27c54cf52ba41d384c 100644 --- a/src/main/java/net/minecraft/world/level/block/LightBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LightBlock.java -@@ -54,6 +54,7 @@ public class LightBlock extends Block implements SimpleWaterloggedBlock { +@@ -52,6 +52,7 @@ public class LightBlock extends Block implements SimpleWaterloggedBlock { @Override public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { if (!world.isClientSide && player.canUseGameMasterBlocks()) { diff --git a/patches/server/0662-Remove-client-side-code-using-deprecated-for-removal.patch b/patches/server/0662-Remove-client-side-code-using-deprecated-for-removal.patch index a0878d0d37..b7a4fc1608 100644 --- a/patches/server/0662-Remove-client-side-code-using-deprecated-for-removal.patch +++ b/patches/server/0662-Remove-client-side-code-using-deprecated-for-removal.patch @@ -7,17 +7,17 @@ Subject: [PATCH] Remove client-side code using deprecated for removal Fixes warnings on build diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java -index 1bab7a03d433d3745cf9e244f5501dd3efedf583..081b460aa9b3674bf239378a6fc3f6cd30bb2d26 100644 +index 722734ce612fb790ddc80488a795a85ebcd4a842..72e734af483dc03e1ae947b2ab3b6fa7df38ce62 100644 --- a/src/main/java/net/minecraft/Util.java +++ b/src/main/java/net/minecraft/Util.java -@@ -950,16 +950,7 @@ public class Util { +@@ -935,16 +935,7 @@ public class Util { } public void openUrl(URL url) { - try { -- Process process = AccessController.doPrivileged((PrivilegedExceptionAction<Process>)(() -> { -- return Runtime.getRuntime().exec(this.getOpenUrlArguments(url)); -- })); +- Process process = AccessController.doPrivileged( +- (PrivilegedExceptionAction<Process>)(() -> Runtime.getRuntime().exec(this.getOpenUrlArguments(url))) +- ); - process.getInputStream().close(); - process.getErrorStream().close(); - process.getOutputStream().close(); diff --git a/patches/server/0664-Prevent-sending-oversized-item-data-in-equipment-and.patch b/patches/server/0664-Prevent-sending-oversized-item-data-in-equipment-and.patch index 49f1956e75..cd57452be8 100644 --- a/patches/server/0664-Prevent-sending-oversized-item-data-in-equipment-and.patch +++ b/patches/server/0664-Prevent-sending-oversized-item-data-in-equipment-and.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Prevent sending oversized item data in equipment and metadata diff --git a/src/main/java/net/minecraft/network/syncher/EntityDataSerializers.java b/src/main/java/net/minecraft/network/syncher/EntityDataSerializers.java -index 0677879604b66fc1442567c5fdf6aa6600407d77..4d4f1be84ea89f5d8685943ad1dc120a5a49d48e 100644 +index 3ee4c01e4505241e575b8b2e96338ba27b793a2b..d70f77e4d5ca59c9f802ecb354fa8d53d1e10134 100644 --- a/src/main/java/net/minecraft/network/syncher/EntityDataSerializers.java +++ b/src/main/java/net/minecraft/network/syncher/EntityDataSerializers.java -@@ -46,7 +46,7 @@ public class EntityDataSerializers { +@@ -44,7 +44,7 @@ public class EntityDataSerializers { public static final EntityDataSerializer<ItemStack> ITEM_STACK = new EntityDataSerializer<ItemStack>() { @Override public void write(FriendlyByteBuf buf, ItemStack value) { diff --git a/patches/server/0666-Fix-Spigot-growth-modifiers.patch b/patches/server/0666-Fix-Spigot-growth-modifiers.patch index e04bd59b80..6463677b83 100644 --- a/patches/server/0666-Fix-Spigot-growth-modifiers.patch +++ b/patches/server/0666-Fix-Spigot-growth-modifiers.patch @@ -76,10 +76,10 @@ index b74e61064926a7c7fb03286651ea52c150f86107..30300ef3ec839dfa944c992ab50db4d3 return (BlockState) state.cycle(GrowingPlantHeadBlock.AGE); } diff --git a/src/main/java/net/minecraft/world/level/block/MangrovePropaguleBlock.java b/src/main/java/net/minecraft/world/level/block/MangrovePropaguleBlock.java -index 434d0761858946c802edea14078f567142da19f3..35be55f181255edbb54b47e906b5e811a4480223 100644 +index 83cc52de8cbb538f8ff2dbce0594f44b8d404b8e..d3827a6759c99d945767498d37a6dbb6b70b6d0d 100644 --- a/src/main/java/net/minecraft/world/level/block/MangrovePropaguleBlock.java +++ b/src/main/java/net/minecraft/world/level/block/MangrovePropaguleBlock.java -@@ -115,7 +115,7 @@ public class MangrovePropaguleBlock extends SaplingBlock implements SimpleWaterl +@@ -114,7 +114,7 @@ public class MangrovePropaguleBlock extends SaplingBlock implements SimpleWaterl @Override public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { if (!isHanging(state)) { diff --git a/patches/server/0680-Load-effect-amplifiers-greater-than-127-correctly.patch b/patches/server/0680-Load-effect-amplifiers-greater-than-127-correctly.patch index 45270d599a..d1a35c86e5 100644 --- a/patches/server/0680-Load-effect-amplifiers-greater-than-127-correctly.patch +++ b/patches/server/0680-Load-effect-amplifiers-greater-than-127-correctly.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Load effect amplifiers greater than 127 correctly MOJIRA: MC-118857 diff --git a/src/main/java/net/minecraft/world/effect/MobEffectInstance.java b/src/main/java/net/minecraft/world/effect/MobEffectInstance.java -index 77b7ec9bd9ab986ebcf90c8eedd11d2ec6ef50ec..007766522d0e2fe874d43df789eb4c946a5edd15 100644 +index 83f1d79147630084b24be20602571f36fc62a1b3..5c9a0c91ae53b575d325a294c702668d30252fcf 100644 --- a/src/main/java/net/minecraft/world/effect/MobEffectInstance.java +++ b/src/main/java/net/minecraft/world/effect/MobEffectInstance.java -@@ -306,7 +306,7 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> { +@@ -298,7 +298,7 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> { } private static MobEffectInstance loadSpecifiedEffect(MobEffect type, CompoundTag nbt) { diff --git a/patches/server/0699-Add-missing-structure-set-seed-configs.patch b/patches/server/0699-Add-missing-structure-set-seed-configs.patch index 3f162bf933..5056c05a21 100644 --- a/patches/server/0699-Add-missing-structure-set-seed-configs.patch +++ b/patches/server/0699-Add-missing-structure-set-seed-configs.patch @@ -148,7 +148,7 @@ index a310bfbf0d08187375ea17f4b04b276a0b7d0b9f..798e22fb4d685b5845ebf687e8004e94 } } diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java b/src/main/java/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java -index bb71545509b8ca804cac25b40e2ce053f8e6a4da..629d2403db1d9927520bbad2da5c7732718e6bf0 100644 +index 5e7c0d5a31156b75ac4895bd13c8b7138894a576..dc44ae806dc2779e5f0ec0de3fdb4b53da806a5b 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java +++ b/src/main/java/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java @@ -79,9 +79,23 @@ public abstract class StructurePlacement { @@ -213,7 +213,7 @@ index bb71545509b8ca804cac25b40e2ce053f8e6a4da..629d2403db1d9927520bbad2da5c7732 int i = chunkX >> 4; int j = chunkZ >> 4; WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L)); -@@ -141,7 +161,7 @@ public abstract class StructurePlacement { +@@ -139,7 +159,7 @@ public abstract class StructurePlacement { @FunctionalInterface public interface FrequencyReducer { @@ -222,7 +222,7 @@ index bb71545509b8ca804cac25b40e2ce053f8e6a4da..629d2403db1d9927520bbad2da5c7732 } public static enum FrequencyReductionMethod implements StringRepresentable { -@@ -161,8 +181,8 @@ public abstract class StructurePlacement { +@@ -159,8 +179,8 @@ public abstract class StructurePlacement { this.reducer = generationPredicate; } diff --git a/patches/server/0706-Configurable-sculk-sensor-listener-range.patch b/patches/server/0706-Configurable-sculk-sensor-listener-range.patch index f525f7812b..bbf1cb0843 100644 --- a/patches/server/0706-Configurable-sculk-sensor-listener-range.patch +++ b/patches/server/0706-Configurable-sculk-sensor-listener-range.patch @@ -32,7 +32,7 @@ index 4c9c35131e9bd37a48f6c4beb2bbcaf7988069c5..cf865dcfde2ae6c0ae72a8e7469be2dd } diff --git a/src/main/java/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java -index aee9119c05bf1d7e2601879e87f002f0e3f11216..a1281c0a769568367145a1a67ffae1d5be63a17e 100644 +index fd791916336032e29aae83a2ff5d956bc18f2938..a08a59192cd01789b4aff9af6d0f1d4c27bb4fe1 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java @@ -23,6 +23,7 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList @@ -43,9 +43,9 @@ index aee9119c05bf1d7e2601879e87f002f0e3f11216..a1281c0a769568367145a1a67ffae1d5 protected SculkSensorBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) { super(type, pos, state); -@@ -50,8 +51,16 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList - this.vibrationData = listener; - }); +@@ -48,8 +49,16 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList + .resultOrPartial(LOGGER::error) + .ifPresent(listener -> this.vibrationData = listener); } + // Paper start - Configurable sculk sensor listener range + if (nbt.contains(PAPER_LISTENER_RANGE_NBT_KEY)) { @@ -60,10 +60,10 @@ index aee9119c05bf1d7e2601879e87f002f0e3f11216..a1281c0a769568367145a1a67ffae1d5 @Override protected void saveAdditional(CompoundTag nbt) { super.saveAdditional(nbt); -@@ -59,7 +68,13 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList - VibrationSystem.Data.CODEC.encodeStart(NbtOps.INSTANCE, this.vibrationData).resultOrPartial(LOGGER::error).ifPresent(listenerNbt -> { - nbt.put("listener", listenerNbt); - }); +@@ -58,7 +67,13 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList + .encodeStart(NbtOps.INSTANCE, this.vibrationData) + .resultOrPartial(LOGGER::error) + .ifPresent(listenerNbt -> nbt.put("listener", listenerNbt)); + this.saveRangeOverride(nbt); // Paper - Configurable sculk sensor listener range + } + // Paper start - Configurable sculk sensor listener range @@ -74,7 +74,7 @@ index aee9119c05bf1d7e2601879e87f002f0e3f11216..a1281c0a769568367145a1a67ffae1d5 @Override public VibrationSystem.Data getVibrationData() { -@@ -96,6 +111,7 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList +@@ -95,6 +110,7 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList @Override public int getListenerRadius() { diff --git a/patches/server/0717-Fix-swamp-hut-cat-generation-deadlock.patch b/patches/server/0717-Fix-swamp-hut-cat-generation-deadlock.patch index 3c6b80ca04..8a176245ca 100644 --- a/patches/server/0717-Fix-swamp-hut-cat-generation-deadlock.patch +++ b/patches/server/0717-Fix-swamp-hut-cat-generation-deadlock.patch @@ -23,7 +23,7 @@ index 534630b0161c8d869e49e7a59572193550be0671..7dfd2b17e82a80683af28779d0bd8f64 this.setPersistenceRequired(); } diff --git a/src/main/java/net/minecraft/world/level/StructureManager.java b/src/main/java/net/minecraft/world/level/StructureManager.java -index da0adda84ad762bba2c0f86ec95fe81a0839ed58..6d22e48b03da6a3bc20c0ee5a1f3008430304fde 100644 +index 09e0c6b6bddcba2f4a59838ac63cda3188f71e41..07eb481380e8fd4e492f36342ba633579c1b624e 100644 --- a/src/main/java/net/minecraft/world/level/StructureManager.java +++ b/src/main/java/net/minecraft/world/level/StructureManager.java @@ -46,7 +46,12 @@ public class StructureManager { @@ -40,7 +40,7 @@ index da0adda84ad762bba2c0f86ec95fe81a0839ed58..6d22e48b03da6a3bc20c0ee5a1f30084 Builder<StructureStart> builder = ImmutableList.builder(); for (Entry<Structure, LongSet> entry : map.entrySet()) { -@@ -111,13 +116,18 @@ public class StructureManager { +@@ -111,10 +116,15 @@ public class StructureManager { } public StructureStart getStructureWithPieceAt(BlockPos pos, TagKey<Structure> structureTag) { @@ -51,12 +51,9 @@ index da0adda84ad762bba2c0f86ec95fe81a0839ed58..6d22e48b03da6a3bc20c0ee5a1f30084 + // Paper end - Fix swamp hut cat generation deadlock Registry<Structure> registry = this.registryAccess().registryOrThrow(Registries.STRUCTURE); - for (StructureStart structureStart : this.startsForStructure(new ChunkPos(pos), structure -> { - return registry.getHolder(registry.getId(structure)).map(reference -> { - return reference.is(structureTag); - }).orElse(false); -- })) { -+ }, levelAccessor)) { // Paper - Fix swamp hut cat generation deadlock + for (StructureStart structureStart : this.startsForStructure( +- new ChunkPos(pos), structure -> registry.getHolder(registry.getId(structure)).map(reference -> reference.is(structureTag)).orElse(false) ++ new ChunkPos(pos), structure -> registry.getHolder(registry.getId(structure)).map(reference -> reference.is(structureTag)).orElse(false), levelAccessor // Paper - Fix swamp hut cat generation deadlock + )) { if (this.structureHasPieceAt(pos, structureStart)) { return structureStart; - } diff --git a/patches/server/0747-Sanitize-sent-BlockEntity-NBT.patch b/patches/server/0747-Sanitize-sent-BlockEntity-NBT.patch index 96727241f8..72cdd70ba1 100644 --- a/patches/server/0747-Sanitize-sent-BlockEntity-NBT.patch +++ b/patches/server/0747-Sanitize-sent-BlockEntity-NBT.patch @@ -18,10 +18,10 @@ index d79284a790569141c2ac8178d6ecc20b17cdd0d3..3944852921335c78a04a9dc301882ab5 public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity) { diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index 99fe90094f1cabdaea9db89cfc016a98c1ee8c2d..ebd7b78f9d3439f8278846c32ee3317ad9f1e6ad 100644 +index a44a82d2d5ed4d675dc1a184d5b6b935fda575dd..03b6aa2e3bd871ae59e761866b53a10f72b3cdac 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -@@ -149,6 +149,7 @@ public class ClientboundLevelChunkPacketData { +@@ -145,6 +145,7 @@ public class ClientboundLevelChunkPacketData { CompoundTag compoundTag = blockEntity.getUpdateTag(); BlockPos blockPos = blockEntity.getBlockPos(); int i = SectionPos.sectionRelative(blockPos.getX()) << 4 | SectionPos.sectionRelative(blockPos.getZ()); diff --git a/patches/server/0752-Add-WardenAngerChangeEvent.patch b/patches/server/0752-Add-WardenAngerChangeEvent.patch index 298551c409..7bd9e6cd8e 100644 --- a/patches/server/0752-Add-WardenAngerChangeEvent.patch +++ b/patches/server/0752-Add-WardenAngerChangeEvent.patch @@ -5,18 +5,18 @@ Subject: [PATCH] Add WardenAngerChangeEvent diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/AngerManagement.java b/src/main/java/net/minecraft/world/entity/monster/warden/AngerManagement.java -index e9d7d165974ac2f96d1bb13710a41c36307daa56..053036b4d68a1780f0b1885a7a0c931c02ed648b 100644 +index 27e52ee93ab591e97f37705de64cb5b62c06e253..3d792957f27fd4bdfad8d76262a8e2a2012bf35f 100644 --- a/src/main/java/net/minecraft/world/entity/monster/warden/AngerManagement.java +++ b/src/main/java/net/minecraft/world/entity/monster/warden/AngerManagement.java -@@ -155,7 +155,7 @@ public class AngerManagement { +@@ -146,7 +146,7 @@ public class AngerManagement { + public int increaseAnger(Entity entity, int amount) { boolean bl = !this.angerBySuspect.containsKey(entity); - int i = this.angerBySuspect.computeInt(entity, (suspect, anger) -> { -- return Math.min(150, (anger == null ? 0 : anger) + amount); -+ return Math.min(150, (anger == null ? 0 : anger) + amount); // Paper - diff on change (Warden#increaseAngerAt WardenAngerChangeEvent) - }); +- int i = this.angerBySuspect.computeInt(entity, (suspect, anger) -> Math.min(150, (anger == null ? 0 : anger) + amount)); ++ int i = this.angerBySuspect.computeInt(entity, (suspect, anger) -> Math.min(150, (anger == null ? 0 : anger) + amount)); // Paper - diff on change (Warden#increaseAngerAt WardenAngerChangeEvent) if (bl) { int j = this.angerByUuid.removeInt(entity.getUUID()); + i += j; diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java index b5185fcb635fbf5e5ed9d6cc9cc517cb46ada5aa..937f81a859953498abe73bea560c86e6560e1c33 100644 --- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java diff --git a/patches/server/0753-Add-option-for-strict-advancement-dimension-checks.patch b/patches/server/0753-Add-option-for-strict-advancement-dimension-checks.patch index fb51c24820..7d0540d1db 100644 --- a/patches/server/0753-Add-option-for-strict-advancement-dimension-checks.patch +++ b/patches/server/0753-Add-option-for-strict-advancement-dimension-checks.patch @@ -11,10 +11,10 @@ distance trigger. This adds a config option to ignore that and use the exact dimension key of the worlds involved. diff --git a/src/main/java/net/minecraft/advancements/critereon/LocationPredicate.java b/src/main/java/net/minecraft/advancements/critereon/LocationPredicate.java -index df1d872869319fe29bd6085f915927e5a01db7b9..aa6a255574feac0f58e2102eca2705fc6832afd5 100644 +index 079e3af44a964321d360b979f64f572057235ab8..8f2c00cd70bc99855f23f3db58567233a1fda84e 100644 --- a/src/main/java/net/minecraft/advancements/critereon/LocationPredicate.java +++ b/src/main/java/net/minecraft/advancements/critereon/LocationPredicate.java -@@ -64,7 +64,7 @@ public record LocationPredicate( +@@ -62,7 +62,7 @@ public record LocationPredicate( public boolean matches(ServerLevel world, double x, double y, double z) { if (this.position.isPresent() && !this.position.get().matches(x, y, z)) { return false; diff --git a/patches/server/0760-Do-not-sync-load-chunk-for-dynamic-game-event-listen.patch b/patches/server/0760-Do-not-sync-load-chunk-for-dynamic-game-event-listen.patch index 66e57a50fb..b5557f95ef 100644 --- a/patches/server/0760-Do-not-sync-load-chunk-for-dynamic-game-event-listen.patch +++ b/patches/server/0760-Do-not-sync-load-chunk-for-dynamic-game-event-listen.patch @@ -15,10 +15,10 @@ to account for the case where the chunk is _not_ currently loaded and then later loaded. diff --git a/src/main/java/net/minecraft/world/level/gameevent/DynamicGameEventListener.java b/src/main/java/net/minecraft/world/level/gameevent/DynamicGameEventListener.java -index 13c2a0215ca072b7b30aec773094bbf0c7f8668c..38c89c1f70f5c9aa2d11e0e53e004e513c537dd2 100644 +index 53eeb59257e3e943cbe7dc113674135077f0c20d..fc316f6c6db1d39bb24daa1d272e5128c71320dd 100644 --- a/src/main/java/net/minecraft/world/level/gameevent/DynamicGameEventListener.java +++ b/src/main/java/net/minecraft/world/level/gameevent/DynamicGameEventListener.java -@@ -47,7 +47,7 @@ public class DynamicGameEventListener<T extends GameEventListener> { +@@ -41,7 +41,7 @@ public class DynamicGameEventListener<T extends GameEventListener> { private static void ifChunkExists(LevelReader world, @Nullable SectionPos sectionPos, Consumer<GameEventListenerRegistry> dispatcherConsumer) { if (sectionPos != null) { diff --git a/patches/server/0778-Fire-EntityChangeBlockEvent-in-more-places.patch b/patches/server/0778-Fire-EntityChangeBlockEvent-in-more-places.patch index 9bb1ac5623..87d13244aa 100644 --- a/patches/server/0778-Fire-EntityChangeBlockEvent-in-more-places.patch +++ b/patches/server/0778-Fire-EntityChangeBlockEvent-in-more-places.patch @@ -80,7 +80,7 @@ index a298f511c8a7eb208a0dd63b24ec050848a31476..41a3ca4edf4fa662f2af13efd7b78b56 }); world.levelEvent(3002, blockposition1, -1); diff --git a/src/main/java/net/minecraft/world/item/AxeItem.java b/src/main/java/net/minecraft/world/item/AxeItem.java -index da06e2aca90b467f3fa36a4a73d83a432266e6b7..0954d7a3e5a8d35802b6bab217eaff315b9582a0 100644 +index 596f4c6b69e5a9bd9eeebee60cf49128264727ae..4f8689e8cbc8b6b9f44168126b95cc864a383c9e 100644 --- a/src/main/java/net/minecraft/world/item/AxeItem.java +++ b/src/main/java/net/minecraft/world/item/AxeItem.java @@ -60,6 +60,11 @@ public class AxeItem extends DiggerItem { @@ -112,10 +112,10 @@ index 1977e702f6af39ebf100c1f2f2edc2d1c4d003b0..cfcd1778b5ae66395400221879dde357 Block.pushEntitiesUp(iblockdata, iblockdata1, world, blockposition); world.setBlock(blockposition, iblockdata1, 2); diff --git a/src/main/java/net/minecraft/world/item/HoneycombItem.java b/src/main/java/net/minecraft/world/item/HoneycombItem.java -index 486b1bdfe93aec49ee9bd3f2152c1e98d72f298f..45bb406bc1c7d95cfe7e24855e7a1cb91b798f40 100644 +index decabf6fccaca3d1bfeba679ac71677d33315f5e..14d37bf64af719eae3ea154ea7f952cc27712b57 100644 --- a/src/main/java/net/minecraft/world/item/HoneycombItem.java +++ b/src/main/java/net/minecraft/world/item/HoneycombItem.java -@@ -78,6 +78,14 @@ public class HoneycombItem extends Item implements SignApplicator { +@@ -74,6 +74,14 @@ public class HoneycombItem extends Item implements SignApplicator { return getWaxed(blockState).map(state -> { Player player = context.getPlayer(); ItemStack itemStack = context.getItemInHand(); @@ -148,7 +148,7 @@ index 5c62741e3a3854a7f674bfec49758f837f3bb9a0..b93ed2896ebeb8ec75eb3cfb717a740c entityhuman.setItemInHand(context.getHand(), ItemUtils.createFilledResult(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE))); entityhuman.awardStat(Stats.ITEM_USED.get(itemstack.getItem())); diff --git a/src/main/java/net/minecraft/world/item/ShovelItem.java b/src/main/java/net/minecraft/world/item/ShovelItem.java -index d743f4228f4ff869e823ad8b1aa3b7d5c84ae07a..da225c6fd807eb82196142943207c113e849d843 100644 +index 6118bee65c1fe65482db2cd8d1e0e3c2dad4c8f3..9aba0211f37501bbd19b583d22fa83eae32390d9 100644 --- a/src/main/java/net/minecraft/world/item/ShovelItem.java +++ b/src/main/java/net/minecraft/world/item/ShovelItem.java @@ -45,20 +45,29 @@ public class ShovelItem extends DiggerItem { diff --git a/patches/server/0780-Missing-effect-cause.patch b/patches/server/0780-Missing-effect-cause.patch index c008aa285d..3fcbc0382f 100644 --- a/patches/server/0780-Missing-effect-cause.patch +++ b/patches/server/0780-Missing-effect-cause.patch @@ -31,15 +31,15 @@ index 5d27598d62c1ddfc84bac64228275749ec01cba5..f0061dab24ee5ee94c151483a553db25 if (stack.isEmpty()) { diff --git a/src/main/java/net/minecraft/world/item/SuspiciousStewItem.java b/src/main/java/net/minecraft/world/item/SuspiciousStewItem.java -index ed19c3b8d19b4244d8d374d0531b1dcacee2de4a..fb0634f9b9a2b41a4fbcde1411d76bf22b2c73aa 100644 +index 6322eddcf097572f24216eefdb9b6b5dedf5edbe..4cc05188a4408e076b6babc91dd24f772f0c7d70 100644 --- a/src/main/java/net/minecraft/world/item/SuspiciousStewItem.java +++ b/src/main/java/net/minecraft/world/item/SuspiciousStewItem.java -@@ -64,7 +64,7 @@ public class SuspiciousStewItem extends Item { +@@ -58,7 +58,7 @@ public class SuspiciousStewItem extends Item { + @Override public ItemStack finishUsingItem(ItemStack stack, Level world, LivingEntity user) { ItemStack itemStack = super.finishUsingItem(stack, world, user); - listPotionEffects(itemStack, effect -> { -- user.addEffect(effect.createEffectInstance()); -+ user.addEffect(effect.createEffectInstance(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // Paper - Add missing effect cause - }); +- listPotionEffects(itemStack, effect -> user.addEffect(effect.createEffectInstance())); ++ listPotionEffects(itemStack, effect -> user.addEffect(effect.createEffectInstance(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD)); // Paper - Add missing effect cause return user instanceof Player && ((Player)user).getAbilities().instabuild ? itemStack : new ItemStack(Items.BOWL); } + } diff --git a/patches/server/0786-fix-Jigsaw-block-kicking-user.patch b/patches/server/0786-fix-Jigsaw-block-kicking-user.patch index 95f3747fd3..2e5fd7e357 100644 --- a/patches/server/0786-fix-Jigsaw-block-kicking-user.patch +++ b/patches/server/0786-fix-Jigsaw-block-kicking-user.patch @@ -5,10 +5,10 @@ Subject: [PATCH] fix Jigsaw block kicking user diff --git a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java -index 27947d216cf705b8c6a85c9ba6521cdc05149015..d75d43fd3f6bdd9b85bb32e026e20eee9b29a967 100644 +index f39a35f7c6ee61d5d7375e9792957f27e507cf0c..447b0359922011fe12b1bb9628d23a47c9d7dc89 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java -@@ -138,7 +138,12 @@ public class JigsawBlockEntity extends BlockEntity { +@@ -136,7 +136,12 @@ public class JigsawBlockEntity extends BlockEntity { public void generate(ServerLevel world, int maxDepth, boolean keepJigsaws) { BlockPos blockPos = this.getBlockPos().relative(this.getBlockState().getValue(JigsawBlock.ORIENTATION).front()); Registry<StructureTemplatePool> registry = world.registryAccess().registryOrThrow(Registries.TEMPLATE_POOL); @@ -23,10 +23,10 @@ index 27947d216cf705b8c6a85c9ba6521cdc05149015..d75d43fd3f6bdd9b85bb32e026e20eee } diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/pools/StructureTemplatePool.java b/src/main/java/net/minecraft/world/level/levelgen/structure/pools/StructureTemplatePool.java -index d87c2f41ec32178f5663abb43c68d87cdc9e925e..ae4560767d5683a035aa18bf61c2613d0c5947a8 100644 +index c8e41cd51bddfafb3675352ea9ec39188ee91a80..488ddcc22dfb08baedc080326b1531151826a702 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/structure/pools/StructureTemplatePool.java +++ b/src/main/java/net/minecraft/world/level/levelgen/structure/pools/StructureTemplatePool.java -@@ -101,7 +101,13 @@ public class StructureTemplatePool { +@@ -98,7 +98,13 @@ public class StructureTemplatePool { } public StructurePoolElement getRandomTemplate(RandomSource random) { diff --git a/patches/server/0789-Fix-a-bunch-of-vanilla-bugs.patch b/patches/server/0789-Fix-a-bunch-of-vanilla-bugs.patch index 73ce537a92..4b96d454ab 100644 --- a/patches/server/0789-Fix-a-bunch-of-vanilla-bugs.patch +++ b/patches/server/0789-Fix-a-bunch-of-vanilla-bugs.patch @@ -87,31 +87,31 @@ index 829c72333664da0c06ce04af93ea39bb90ce0b67..b4f7e3ae855cbf48925f0db916501adf this.setSuccess(true); return stack; diff --git a/src/main/java/net/minecraft/server/commands/DeOpCommands.java b/src/main/java/net/minecraft/server/commands/DeOpCommands.java -index 0641b6b77a27ce88794ece2d8b936fabba545717..e5dc7e3890ece93c703e0064bab33bca0457d9af 100644 +index 0283f26151488d715dc823a0008c9a37ef6740fb..d98447e58233745665f0833196226077d972cc2a 100644 --- a/src/main/java/net/minecraft/server/commands/DeOpCommands.java +++ b/src/main/java/net/minecraft/server/commands/DeOpCommands.java -@@ -34,7 +34,7 @@ public class DeOpCommands { +@@ -35,7 +35,7 @@ public class DeOpCommands { + if (playerList.isOp(gameProfile)) { playerList.deop(gameProfile); i++; - source.sendSuccess(() -> { -- return Component.translatable("commands.deop.success", targets.iterator().next().getName()); -+ return Component.translatable("commands.deop.success", gameProfile.getName()); // Paper - fixes MC-253721 - }, true); +- source.sendSuccess(() -> Component.translatable("commands.deop.success", targets.iterator().next().getName()), true); ++ source.sendSuccess(() -> Component.translatable("commands.deop.success", gameProfile.getName()), true); // Paper - fixes MC-253721 } } + diff --git a/src/main/java/net/minecraft/server/commands/OpCommand.java b/src/main/java/net/minecraft/server/commands/OpCommand.java -index 06419a448a7e28e763c4569e48b7705a846032bb..3c7a3b13756bcf72d5024c273522317051268d48 100644 +index 6854ca4d4fec2b4fa541c3fabf63787665572609..e7b444a10b244828827b3c66c53465206ea8e0ec 100644 --- a/src/main/java/net/minecraft/server/commands/OpCommand.java +++ b/src/main/java/net/minecraft/server/commands/OpCommand.java -@@ -39,7 +39,7 @@ public class OpCommand { +@@ -46,7 +46,7 @@ public class OpCommand { + if (!playerList.isOp(gameProfile)) { playerList.op(gameProfile); i++; - source.sendSuccess(() -> { -- return Component.translatable("commands.op.success", targets.iterator().next().getName()); -+ return Component.translatable("commands.op.success", gameProfile.getName()); // Paper - fixes MC-253721 - }, true); +- source.sendSuccess(() -> Component.translatable("commands.op.success", targets.iterator().next().getName()), true); ++ source.sendSuccess(() -> Component.translatable("commands.op.success", gameProfile.getName()), true); // Paper - fixes MC-253721 } } + diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java index f2d3dc066b00b685715eb5104234945c41a15f92..43c8f6a0615f392cc560b2259b116cc9d5fba4e7 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -336,10 +336,10 @@ index ab85050a64d4897aff11d0780d8cb26660918ac7..bfb9694087821de206fafe867f207e07 this.getFramedMapId().ifPresent((i) -> { MapItemSavedData worldmap = MapItem.getSavedData(i, this.level()); diff --git a/src/main/java/net/minecraft/world/entity/npc/CatSpawner.java b/src/main/java/net/minecraft/world/entity/npc/CatSpawner.java -index 1d6e21853aefd14b33e3545795b5c4bf6df0176c..956857123953922a4a750f47dcebfeeffd4e3d51 100644 +index c718cee92522a0d3c0e30eafd09fa8178c7e6e4a..5d1610eddcaf0cf65c726a5438b42e53bab85332 100644 --- a/src/main/java/net/minecraft/world/entity/npc/CatSpawner.java +++ b/src/main/java/net/minecraft/world/entity/npc/CatSpawner.java -@@ -85,8 +85,8 @@ public class CatSpawner implements CustomSpawner { +@@ -83,8 +83,8 @@ public class CatSpawner implements CustomSpawner { if (cat == null) { return 0; } else { @@ -388,11 +388,11 @@ index b670c0cb3886c99d38a91b5c13aa2cefaae702cf..9599a5f96601030bf7f7cbd3392861d6 // Paper start - Add PlayerChangeBeaconEffectEvent io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent event = new io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent((org.bukkit.entity.Player) this.player.player.getBukkitEntity(), convert(primary), convert(secondary), this.access.getLocation().getBlock()); diff --git a/src/main/java/net/minecraft/world/item/BundleItem.java b/src/main/java/net/minecraft/world/item/BundleItem.java -index 2d829860ffefd4c8bb73023a723e9d7685da5cbe..dccad12de9fbd85704f1db205fb011456b88376d 100644 +index 1e538c691d867a96a57fec9350b4f663d01f8e93..c4c966c555407b7146053187e2ed16cfb99a2dc9 100644 --- a/src/main/java/net/minecraft/world/item/BundleItem.java +++ b/src/main/java/net/minecraft/world/item/BundleItem.java -@@ -51,7 +51,7 @@ public class BundleItem extends Item { - }); +@@ -49,7 +49,7 @@ public class BundleItem extends Item { + removeOne(stack).ifPresent(removedStack -> add(stack, slot.safeInsert(removedStack))); } else if (itemStack.getItem().canFitInsideContainerItems()) { int i = (64 - getContentWeight(stack)) / getWeight(itemStack); - int j = add(stack, slot.safeTake(itemStack.getCount(), i, player)); @@ -400,7 +400,7 @@ index 2d829860ffefd4c8bb73023a723e9d7685da5cbe..dccad12de9fbd85704f1db205fb01145 if (j > 0) { this.playInsertSound(player); } -@@ -122,7 +122,7 @@ public class BundleItem extends Item { +@@ -120,7 +120,7 @@ public class BundleItem extends Item { int i = getContentWeight(bundle); int j = getWeight(stack); int k = Math.min(stack.getCount(), (64 - i) / j); diff --git a/patches/server/0813-check-global-player-list-where-appropriate.patch b/patches/server/0813-check-global-player-list-where-appropriate.patch index 9ca69c423c..bf8f80fdbd 100644 --- a/patches/server/0813-check-global-player-list-where-appropriate.patch +++ b/patches/server/0813-check-global-player-list-where-appropriate.patch @@ -50,10 +50,10 @@ index d4ac3e566b47cfc8688bcc2ab08385b6de4693f8..7de9d012e7416eaa0189b513a0972c84 if (entityhuman instanceof ServerPlayer) { CriteriaTriggers.CURED_ZOMBIE_VILLAGER.trigger((ServerPlayer) entityhuman, this, entityvillager); diff --git a/src/main/java/net/minecraft/world/level/EntityGetter.java b/src/main/java/net/minecraft/world/level/EntityGetter.java -index c35d5865b77203d0de6467d2793424837704e95a..77cd9d5518ac1d7c3c900354cdeb7be3fb66b0ac 100644 +index d465fb01af4c8610f83ecb9c68b83127cf7e95ae..bd20bea7f76a7307f1698fb2dfef37125032d166 100644 --- a/src/main/java/net/minecraft/world/level/EntityGetter.java +++ b/src/main/java/net/minecraft/world/level/EntityGetter.java -@@ -241,4 +241,11 @@ public interface EntityGetter { +@@ -237,4 +237,11 @@ public interface EntityGetter { return null; } @@ -66,10 +66,10 @@ index c35d5865b77203d0de6467d2793424837704e95a..77cd9d5518ac1d7c3c900354cdeb7be3 + // Paper end - check global player list where appropriate } diff --git a/src/main/java/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java -index ed3c82b96951af247680bde3e4e0951e80c7579e..d3a528f93d174820b3248f708178c71b4c04a9d2 100644 +index d71a9fb54269f7c7e251e0e3bdd8b5a072af5201..a2ab5291605a3a3c4fda067c23da7d9aafe1cc38 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java -@@ -101,6 +101,13 @@ public class SculkShriekerBlockEntity extends BlockEntity implements GameEventLi +@@ -97,6 +97,13 @@ public class SculkShriekerBlockEntity extends BlockEntity implements GameEventLi @Nullable public static ServerPlayer tryGetPlayer(@Nullable Entity entity) { diff --git a/patches/server/0828-Improve-logging-and-errors.patch b/patches/server/0828-Improve-logging-and-errors.patch index 2e809213c7..d5774cbd4f 100644 --- a/patches/server/0828-Improve-logging-and-errors.patch +++ b/patches/server/0828-Improve-logging-and-errors.patch @@ -65,10 +65,10 @@ index b8f1549d1ea98a105577927a735bab331aff3840..45a68beff0c97ead5e9f1201b5fb9ef8 } diff --git a/src/main/java/net/minecraft/server/packs/PathPackResources.java b/src/main/java/net/minecraft/server/packs/PathPackResources.java -index 84990b08c4f9f995dbaf63a7d32957051c73fd58..12fe10191533dc250018239433f378a59e338954 100644 +index 87928500f40ceeaad6669de194d2c80089051e60..8d554e7bb1291ac24a958a92458f993344e3be3b 100644 --- a/src/main/java/net/minecraft/server/packs/PathPackResources.java +++ b/src/main/java/net/minecraft/server/packs/PathPackResources.java -@@ -106,6 +106,12 @@ public class PathPackResources extends AbstractPackResources { +@@ -102,6 +102,12 @@ public class PathPackResources extends AbstractPackResources { try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(path)) { for (Path path2 : directoryStream) { String string = path2.getFileName().toString(); diff --git a/patches/server/0849-Fix-text-display-error-on-spawn.patch b/patches/server/0849-Fix-text-display-error-on-spawn.patch index 7a889319e6..6dc3644125 100644 --- a/patches/server/0849-Fix-text-display-error-on-spawn.patch +++ b/patches/server/0849-Fix-text-display-error-on-spawn.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix text display error on spawn diff --git a/src/main/java/net/minecraft/world/entity/Display.java b/src/main/java/net/minecraft/world/entity/Display.java -index 9658bf8b295380fe6677eeddbcb0f44df3137019..460b82bcb400a73399015ff6588eab5a95be6d23 100644 +index 622ec8aa412bca354e6a14693e0d19a941cf4c1b..cad5104baf9941f69d4a6935c0a210942b0f84f2 100644 --- a/src/main/java/net/minecraft/world/entity/Display.java +++ b/src/main/java/net/minecraft/world/entity/Display.java -@@ -912,7 +912,7 @@ public abstract class Display extends Entity { +@@ -899,7 +899,7 @@ public abstract class Display extends Entity { byte var10 = loadFlag(b, nbt, "default_background", (byte)4); Optional<Display.TextDisplay.Align> optional = Display.TextDisplay.Align.CODEC .decode(NbtOps.INSTANCE, nbt.get("alignment")) diff --git a/patches/server/0856-Prevent-causing-expired-keys-from-impacting-new-join.patch b/patches/server/0856-Prevent-causing-expired-keys-from-impacting-new-join.patch index 682e80e173..c23be58240 100644 --- a/patches/server/0856-Prevent-causing-expired-keys-from-impacting-new-join.patch +++ b/patches/server/0856-Prevent-causing-expired-keys-from-impacting-new-join.patch @@ -5,24 +5,26 @@ Subject: [PATCH] Prevent causing expired keys from impacting new joins diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java -index 8875b0d1df39ee2b3de5b4ed61221f38dead2624..71d79adb717729ba6a7a0a97f96b7747e87873c4 100644 +index e4f0949b6538734ff25daf68a428262481feeb81..754a2a5e958a04b3f8bf216b6022f547aa1cd36f 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java -@@ -102,7 +102,13 @@ public class ClientboundPlayerInfoUpdatePacket implements Packet<ClientGamePacke - INITIALIZE_CHAT((serialized, buf) -> { - serialized.chatSession = buf.readNullable(RemoteChatSession.Data::read); - }, (buf, entry) -> { -- buf.writeNullable(entry.chatSession, RemoteChatSession.Data::write); +@@ -101,7 +101,15 @@ public class ClientboundPlayerInfoUpdatePacket implements Packet<ClientGamePacke + }), + INITIALIZE_CHAT( + (serialized, buf) -> serialized.chatSession = buf.readNullable(RemoteChatSession.Data::read), +- (buf, entry) -> buf.writeNullable(entry.chatSession, RemoteChatSession.Data::write) + // Paper start - Prevent causing expired keys from impacting new joins -+ RemoteChatSession.Data chatSession = entry.chatSession; -+ if (chatSession != null && chatSession.profilePublicKey().hasExpired()) { -+ chatSession = null; ++ (buf, entry) -> { ++ RemoteChatSession.Data chatSession = entry.chatSession; ++ if (chatSession != null && chatSession.profilePublicKey().hasExpired()) { ++ chatSession = null; ++ } ++ buf.writeNullable(chatSession, RemoteChatSession.Data::write); + } -+ buf.writeNullable(chatSession, RemoteChatSession.Data::write); + // Paper end - Prevent causing expired keys from impacting new joins - }), - UPDATE_GAME_MODE((serialized, buf) -> { - serialized.gameMode = GameType.byId(buf.readVarInt()); + ), + UPDATE_GAME_MODE((serialized, buf) -> serialized.gameMode = GameType.byId(buf.readVarInt()), (buf, entry) -> buf.writeVarInt(entry.gameMode().getId())), + UPDATE_LISTED((serialized, buf) -> serialized.listed = buf.readBoolean(), (buf, entry) -> buf.writeBoolean(entry.listed())), diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java index c9dab47fe3db73b31b40e071d37f1be63401c19d..69118af2a873f23f6543676db39263bfeb81b4f1 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java diff --git a/patches/server/0863-Avoid-Lazy-Initialization-for-Enum-Fields.patch b/patches/server/0863-Avoid-Lazy-Initialization-for-Enum-Fields.patch index 7bcb96efdd..112f2214ae 100644 --- a/patches/server/0863-Avoid-Lazy-Initialization-for-Enum-Fields.patch +++ b/patches/server/0863-Avoid-Lazy-Initialization-for-Enum-Fields.patch @@ -7,10 +7,10 @@ This patch is meant to get rid of any instances of lazy initialization that Mine This has the possibility to create race condition issues, and generally don't make sense to be lazily done anyways. diff --git a/src/main/java/com/mojang/math/OctahedralGroup.java b/src/main/java/com/mojang/math/OctahedralGroup.java -index 33ea26e900907a6ef18136720ac6e42ac8382f10..facdba0d515cf124cdab2c60dd2a13cc040c017f 100644 +index 8af12b383bb80d1c0a12e1151030ab6e21c27e79..d2efe5e4f767f8316bc3915573bd1efcbcf20968 100644 --- a/src/main/java/com/mojang/math/OctahedralGroup.java +++ b/src/main/java/com/mojang/math/OctahedralGroup.java -@@ -108,6 +108,7 @@ public enum OctahedralGroup implements StringRepresentable { +@@ -110,6 +110,7 @@ public enum OctahedralGroup implements StringRepresentable { this.permutation = axisTransformation; this.transformation = new Matrix3f().scaling(flipX ? -1.0F : 1.0F, flipY ? -1.0F : 1.0F, flipZ ? -1.0F : 1.0F); this.transformation.mul(axisTransformation.transformation()); @@ -18,7 +18,7 @@ index 33ea26e900907a6ef18136720ac6e42ac8382f10..facdba0d515cf124cdab2c60dd2a13cc } private BooleanList packInversions() { -@@ -136,7 +137,7 @@ public enum OctahedralGroup implements StringRepresentable { +@@ -138,7 +139,7 @@ public enum OctahedralGroup implements StringRepresentable { return this.name; } @@ -27,7 +27,7 @@ index 33ea26e900907a6ef18136720ac6e42ac8382f10..facdba0d515cf124cdab2c60dd2a13cc if (this.rotatedDirections == null) { this.rotatedDirections = Maps.newEnumMap(Direction.class); Direction.Axis[] axiss = Direction.Axis.values(); -@@ -151,6 +152,10 @@ public enum OctahedralGroup implements StringRepresentable { +@@ -153,6 +154,10 @@ public enum OctahedralGroup implements StringRepresentable { } } diff --git a/patches/server/0903-Remove-UpgradeData-neighbour-ticks-outside-of-range.patch b/patches/server/0903-Remove-UpgradeData-neighbour-ticks-outside-of-range.patch index bcf2216c32..930a90563b 100644 --- a/patches/server/0903-Remove-UpgradeData-neighbour-ticks-outside-of-range.patch +++ b/patches/server/0903-Remove-UpgradeData-neighbour-ticks-outside-of-range.patch @@ -7,10 +7,10 @@ The lists are only supposed to contain ticks for the 1 radius neighbours of the chunk. diff --git a/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java b/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java -index 45329a79338821c6f988f8e5f55749043271e603..5b6ccb52689af685380193f3a0eef2f121f9bd26 100644 +index ae52f9a04221efed322bc3dc76ac0d56738ffba7..25c1abaeb916781f810d580a4d388d4d3adad75a 100644 --- a/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java +++ b/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java -@@ -98,6 +98,25 @@ public class UpgradeData { +@@ -100,6 +100,25 @@ public class UpgradeData { } } @@ -36,7 +36,7 @@ index 45329a79338821c6f988f8e5f55749043271e603..5b6ccb52689af685380193f3a0eef2f1 public void upgrade(LevelChunk chunk) { this.upgradeInside(chunk); -@@ -105,6 +124,11 @@ public class UpgradeData { +@@ -107,6 +126,11 @@ public class UpgradeData { upgradeSides(chunk, direction8); } diff --git a/patches/server/0914-Add-Listing-API-for-Player.patch b/patches/server/0914-Add-Listing-API-for-Player.patch index 57bbb114f0..18d73fa178 100644 --- a/patches/server/0914-Add-Listing-API-for-Player.patch +++ b/patches/server/0914-Add-Listing-API-for-Player.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add Listing API for Player diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java -index 71d79adb717729ba6a7a0a97f96b7747e87873c4..c487241f20ac989d37371e0d49c529cb5cd86abe 100644 +index 754a2a5e958a04b3f8bf216b6022f547aa1cd36f..d41fe931daf03c40ca1d7b9159001d0122d72f0c 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java @@ -29,6 +29,17 @@ public class ClientboundPlayerInfoUpdatePacket implements Packet<ClientGamePacke @@ -56,7 +56,7 @@ index 71d79adb717729ba6a7a0a97f96b7747e87873c4..c487241f20ac989d37371e0d49c529cb public ClientboundPlayerInfoUpdatePacket(FriendlyByteBuf buf) { this.actions = buf.readEnumSet(ClientboundPlayerInfoUpdatePacket.Action.class); this.entries = buf.readList(buf2 -> { -@@ -158,16 +192,24 @@ public class ClientboundPlayerInfoUpdatePacket implements Packet<ClientGamePacke +@@ -146,16 +180,24 @@ public class ClientboundPlayerInfoUpdatePacket implements Packet<ClientGamePacke @Nullable RemoteChatSession.Data chatSession ) { Entry(ServerPlayer player) { diff --git a/patches/server/0915-Configurable-Region-Compression-Format.patch b/patches/server/0915-Configurable-Region-Compression-Format.patch index 7ae1778b0e..315bfdce09 100644 --- a/patches/server/0915-Configurable-Region-Compression-Format.patch +++ b/patches/server/0915-Configurable-Region-Compression-Format.patch @@ -18,13 +18,13 @@ index 169e375c814ff814d15101d09dccc67783f50465..8d20e265872e1f8200de186a69a29f49 public RegionFile(Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync) throws IOException { diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileVersion.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileVersion.java -index b6cd5163ee9cd0dfb78fd2393431677186a9b78a..4bfd16b73163fb502cb8716d3ef43f9fa1c3d184 100644 +index ebe6fafc26031bc503ca032976f2a593a0f54c6b..581912e1315a4a8b46042a27df54826fa63e9c75 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileVersion.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileVersion.java -@@ -30,6 +30,17 @@ public class RegionFileVersion { - }, stream -> { - return stream; - })); +@@ -26,6 +26,17 @@ public class RegionFileVersion { + ) + ); + public static final RegionFileVersion VERSION_NONE = register(new RegionFileVersion(3, stream -> stream, stream -> stream)); + + // Paper start - Configurable region compression format + public static RegionFileVersion getCompressionFormat() { diff --git a/patches/server/0930-Skip-POI-finding-if-stuck-in-vehicle.patch b/patches/server/0930-Skip-POI-finding-if-stuck-in-vehicle.patch index a7cde65a3a..762ee16e70 100644 --- a/patches/server/0930-Skip-POI-finding-if-stuck-in-vehicle.patch +++ b/patches/server/0930-Skip-POI-finding-if-stuck-in-vehicle.patch @@ -19,14 +19,14 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -index 977e477ca46e2c560e00858d3c992be13d3a2413..05d529a74fa3412b4b07bcf0d469118c38862279 100644 +index f3ffce662336ac53e787f9fe7176cef4b77d950b..ea9a3cb588213af1a1eb9a79d0b7244f99048b5e 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -@@ -59,6 +59,7 @@ public class AcquirePoi { +@@ -57,6 +57,7 @@ public class AcquirePoi { return false; } else { mutableLong.setValue(time + 20L + (long)world.getRandom().nextInt(20)); + if (entity.getNavigation().isStuck()) mutableLong.add(200); // Paper - Perf: Wait an additional 10s to check again if they're stuck PoiManager poiManager = world.getPoiManager(); - long2ObjectMap.long2ObjectEntrySet().removeIf(entry -> { - return !entry.getValue().isStillValid(time); + long2ObjectMap.long2ObjectEntrySet().removeIf(entry -> !entry.getValue().isStillValid(time)); + Predicate<BlockPos> predicate2 = pos -> { diff --git a/patches/server/0939-Fix-race-condition-on-UpgradeData.BlockFixers-class-.patch b/patches/server/0939-Fix-race-condition-on-UpgradeData.BlockFixers-class-.patch index f618e16c94..e547ae2524 100644 --- a/patches/server/0939-Fix-race-condition-on-UpgradeData.BlockFixers-class-.patch +++ b/patches/server/0939-Fix-race-condition-on-UpgradeData.BlockFixers-class-.patch @@ -14,14 +14,14 @@ field by calling any method on the class, and for convenience we use values(). diff --git a/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java b/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java -index 5b6ccb52689af685380193f3a0eef2f121f9bd26..5a4b512bbb190153e28b638e6f9e52c9264eb24d 100644 +index 25c1abaeb916781f810d580a4d388d4d3adad75a..932c9ba8d9ef82746cac0c40292a8e41ffb4ea33 100644 --- a/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java +++ b/src/main/java/net/minecraft/world/level/chunk/UpgradeData.java -@@ -138,6 +138,7 @@ public class UpgradeData { +@@ -140,6 +140,7 @@ public class UpgradeData { Fluid fluid = tick.type() == Fluids.EMPTY ? level.getFluidState(tick.pos()).getType() : tick.type(); level.scheduleTick(tick.pos(), fluid, tick.delay(), tick.priority()); }); + UpgradeData.BlockFixers.values(); // Paper - force the class init so that we don't access CHUNKY_FIXERS before all BlockFixers are initialised - CHUNKY_FIXERS.forEach(logic -> { - logic.processChunk(level); - }); + CHUNKY_FIXERS.forEach(logic -> logic.processChunk(level)); + } + diff --git a/patches/server/0961-Lazily-create-LootContext-for-criterions.patch b/patches/server/0961-Lazily-create-LootContext-for-criterions.patch index 7ef28810ed..f0786c2018 100644 --- a/patches/server/0961-Lazily-create-LootContext-for-criterions.patch +++ b/patches/server/0961-Lazily-create-LootContext-for-criterions.patch @@ -8,10 +8,10 @@ For each player on each tick, enter block triggers are invoked, and these create To avoid this, we now lazily create the LootContext if the criterion passes the predicate AND if any of the listener triggers require a loot context instance diff --git a/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java b/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java -index 670e59432979740caf283d839c2f42c9748fe215..9c95c83e74c84e15c8d03503fc3cd0ee10044fd3 100644 +index 795d1f3e6065baee4cadf71ae0eeabfa5522199b..557de599b3496105b572bebb86313e3441947bae 100644 --- a/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java +++ b/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java -@@ -44,14 +44,14 @@ public abstract class SimpleCriterionTrigger<T extends SimpleCriterionTrigger.Si +@@ -42,14 +42,14 @@ public abstract class SimpleCriterionTrigger<T extends SimpleCriterionTrigger.Si PlayerAdvancements playerAdvancements = player.getAdvancements(); Set<CriterionTrigger.Listener<T>> set = (Set) playerAdvancements.criterionData.get(this); // Paper - fix AdvancementDataPlayer leak if (set != null && !set.isEmpty()) { diff --git a/patches/server/0973-Validate-ResourceLocation-in-NBT-reading.patch b/patches/server/0973-Validate-ResourceLocation-in-NBT-reading.patch index ed9dd93bc3..b913537457 100644 --- a/patches/server/0973-Validate-ResourceLocation-in-NBT-reading.patch +++ b/patches/server/0973-Validate-ResourceLocation-in-NBT-reading.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Validate ResourceLocation in NBT reading diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java -index c613577572532fd1b8a8c912b9fd8e41c54669bb..128c6615374e85b772f109200813aa696d784035 100644 +index f3b11b08358fdd93464cd19b05047e10727a5799..c192ddee39afe1de0b5454bc94593b10fefbb24d 100644 --- a/src/main/java/net/minecraft/nbt/NbtUtils.java +++ b/src/main/java/net/minecraft/nbt/NbtUtils.java -@@ -230,8 +230,10 @@ public final class NbtUtils { +@@ -222,8 +222,10 @@ public final class NbtUtils { if (!nbt.contains("Name", 8)) { return Blocks.AIR.defaultBlockState(); } else { @@ -22,7 +22,7 @@ index c613577572532fd1b8a8c912b9fd8e41c54669bb..128c6615374e85b772f109200813aa69 return Blocks.AIR.defaultBlockState(); } else { diff --git a/src/main/java/net/minecraft/resources/ResourceLocation.java b/src/main/java/net/minecraft/resources/ResourceLocation.java -index 651a61681b0b484253f82b43a75e76c5a1c40543..b00e2fe01a433363f75b891086f4c77d27c38209 100644 +index 3908f88959e43d2f485d5f239257e6564dbda6cd..b549f65d0e276a5ed5b8b2f6956268d05910724f 100644 --- a/src/main/java/net/minecraft/resources/ResourceLocation.java +++ b/src/main/java/net/minecraft/resources/ResourceLocation.java @@ -33,6 +33,13 @@ public class ResourceLocation implements Comparable<ResourceLocation> { diff --git a/patches/server/0978-Rewrite-dataconverter-system.patch b/patches/server/0978-Rewrite-dataconverter-system.patch index 5728a626b2..971d840785 100644 --- a/patches/server/0978-Rewrite-dataconverter-system.patch +++ b/patches/server/0978-Rewrite-dataconverter-system.patch @@ -24850,10 +24850,10 @@ index 01e54bd6c8157bc5c20375180a29c62599d72a3b..0eaecd48f763d60e3bfe684fae1700c2 @Override 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 fd7060813fdf335813c1e6ef5a695931cfce242a..8c0e4a0e451d1e0ff8ff20fbe3a92bb20b8b4bda 100644 +index 8609030e7a2fb6362bb482f6a41fe81263101c44..809da7fec1e1288a7a7bf1ee46c5b7bdd12bca01 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 -@@ -150,7 +150,14 @@ public class SectionStorage<R> implements AutoCloseable { +@@ -148,7 +148,14 @@ public class SectionStorage<R> implements AutoCloseable { int j = getVersion(dynamic); int k = SharedConstants.getCurrentVersion().getDataVersion().getVersion(); boolean bl = j != k; @@ -24870,10 +24870,10 @@ index fd7060813fdf335813c1e6ef5a695931cfce242a..8c0e4a0e451d1e0ff8ff20fbe3a92bb2 for (int l = this.levelHeightAccessor.getMinSection(); l < this.levelHeightAccessor.getMaxSection(); l++) { 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 da919ad85ce06572f8e7e4c121a2c222f975c7f5..4303dc2366275dfab3901af4e522113f9a84ce4a 100644 +index a63eaec77251a7f6660d17d7210c639b71751c45..769a8c5788e6a01666b9b5ac24b02c632c6c9e48 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 -@@ -141,7 +141,7 @@ public class StructureCheck { +@@ -139,7 +139,7 @@ public class StructureCheck { CompoundTag compoundTag2; try { @@ -24883,10 +24883,10 @@ index da919ad85ce06572f8e7e4c121a2c222f975c7f5..4303dc2366275dfab3901af4e522113f LOGGER.warn("Failed to partially datafix chunk {}", pos, var12); return StructureCheckResult.CHUNK_LOAD_NEEDED; diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager.java b/src/main/java/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager.java -index 4ddd6a05b538ba1514ca510bf8233a60aa2a21bb..bc6dabe66758c1b8142d0a8be01f146c0d442531 100644 +index 7a350e2542da8055e94da4653399b6f3e07a0c7b..bd97c2407b02c2d6ef345c0cd421340703457e72 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager.java +++ b/src/main/java/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager.java -@@ -247,7 +247,7 @@ public class StructureTemplateManager { +@@ -229,7 +229,7 @@ public class StructureTemplateManager { public StructureTemplate readStructure(CompoundTag nbt) { StructureTemplate structureTemplate = new StructureTemplate(); int i = NbtUtils.getDataVersion(nbt, 500); diff --git a/patches/server/0979-Starlight.patch b/patches/server/0979-Starlight.patch index 8312055b47..598933220f 100644 --- a/patches/server/0979-Starlight.patch +++ b/patches/server/0979-Starlight.patch @@ -4518,7 +4518,7 @@ index 4e1618462840a1378dbe6492696c97544815edf2..8e8e3896040241bba8fd15f4d6d04656 while (objectiterator.hasNext()) { diff --git a/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java b/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java -index f103a885777557af6cb864bfe8a6c5ca6ff351ab..814689f9eb0d4024bfa8512b799acf4547786e9c 100644 +index 1dfae40ec19c4df0a97359941cf2c948cd1c9cb2..3229bb8dfb9f39e5fa1c8d91cb58057764cd4abb 100644 --- a/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java +++ b/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java @@ -23,6 +23,17 @@ import net.minecraft.world.level.chunk.LightChunkGetter; @@ -4552,7 +4552,7 @@ index f103a885777557af6cb864bfe8a6c5ca6ff351ab..814689f9eb0d4024bfa8512b799acf45 public ThreadedLevelLightEngine( LightChunkGetter chunkProvider, ChunkMap chunkStorage, -@@ -40,12 +57,154 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl +@@ -40,11 +57,153 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl ProcessorMailbox<Runnable> processor, ProcessorHandle<ChunkTaskPriorityQueueSorter.Message<Runnable>> executor ) { @@ -4687,8 +4687,8 @@ index f103a885777557af6cb864bfe8a6c5ca6ff351ab..814689f9eb0d4024bfa8512b799acf45 + public boolean hasLightWork() { + // route to new light engine + return this.theLightEngine.hasUpdates(); - } - ++ } ++ + @Override + public LayerLightEventListener getLayerListener(final LightLayer lightType) { + return lightType == LightLayer.BLOCK ? this.theLightEngine.getBlockReader() : this.theLightEngine.getSkyReader(); @@ -4702,13 +4702,12 @@ index f103a885777557af6cb864bfe8a6c5ca6ff351ab..814689f9eb0d4024bfa8512b799acf45 + if (sky == 15) return 15; + final int block = this.theLightEngine.getBlockReader().getLightValue(pos); + return Math.max(sky, block); -+ } + } + // Paper end - replace light engine imp -+ + @Override public void close() { - } -@@ -57,20 +216,16 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl +@@ -57,16 +216,16 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl @Override public void checkBlock(BlockPos pos) { @@ -4717,11 +4716,7 @@ index f103a885777557af6cb864bfe8a6c5ca6ff351ab..814689f9eb0d4024bfa8512b799acf45 - SectionPos.blockToSectionCoord(pos.getX()), - SectionPos.blockToSectionCoord(pos.getZ()), - ThreadedLevelLightEngine.TaskType.PRE_UPDATE, -- Util.name(() -> { -- super.checkBlock(blockPos); -- }, () -> { -- return "checkBlock " + blockPos; -- }) +- Util.name(() -> super.checkBlock(blockPos), () -> "checkBlock " + blockPos) - ); + // Paper start - replace light engine impl + final BlockPos posCopy = pos.immutable(); @@ -4733,20 +4728,20 @@ index f103a885777557af6cb864bfe8a6c5ca6ff351ab..814689f9eb0d4024bfa8512b799acf45 protected void updateChunkStatus(ChunkPos pos) { + if (true) return; // Paper - replace light engine impl - this.addTask(pos.x, pos.z, () -> { - return 0; - }, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { -@@ -92,17 +247,16 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl + this.addTask(pos.x, pos.z, () -> 0, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { + super.retainData(pos, false); + super.setLightEnabled(pos, false); +@@ -84,17 +243,16 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl @Override public void updateSectionStatus(SectionPos pos, boolean notReady) { -- this.addTask(pos.x(), pos.z(), () -> { -- return 0; -- }, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { -- super.updateSectionStatus(pos, notReady); -- }, () -> { -- return "updateSectionStatus " + pos + " " + notReady; -- })); +- this.addTask( +- pos.x(), +- pos.z(), +- () -> 0, +- ThreadedLevelLightEngine.TaskType.PRE_UPDATE, +- Util.name(() -> super.updateSectionStatus(pos, notReady), () -> "updateSectionStatus " + pos + " " + notReady) +- ); + // Paper start - replace light engine impl + this.queueTaskForSection(pos.getX(), pos.getY(), pos.getZ(), () -> { + return this.theLightEngine.sectionChange(pos, notReady); @@ -4757,34 +4752,33 @@ index f103a885777557af6cb864bfe8a6c5ca6ff351ab..814689f9eb0d4024bfa8512b799acf45 @Override public void propagateLightSources(ChunkPos chunkPos) { + if (true) return; // Paper - replace light engine impl - this.addTask(chunkPos.x, chunkPos.z, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { - super.propagateLightSources(chunkPos); - }, () -> { -@@ -112,6 +266,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl + this.addTask( + chunkPos.x, + chunkPos.z, +@@ -105,6 +263,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl @Override public void setLightEnabled(ChunkPos pos, boolean retainData) { + if (true) return; // Paper - replace light engine impl - this.addTask(pos.x, pos.z, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { - super.setLightEnabled(pos, retainData); - }, () -> { -@@ -121,6 +276,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl + this.addTask( + pos.x, + pos.z, +@@ -115,6 +274,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl @Override public void queueSectionData(LightLayer lightType, SectionPos pos, @Nullable DataLayer nibbles) { + if (true) return; // Paper - replace light engine impl - this.addTask(pos.x(), pos.z(), () -> { - return 0; - }, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { -@@ -145,6 +301,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl + this.addTask( + pos.x(), + pos.z(), +@@ -139,12 +299,14 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl @Override public void retainData(ChunkPos pos, boolean retainData) { + if (true) return; // Paper - replace light engine impl - this.addTask(pos.x, pos.z, () -> { - return 0; - }, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { -@@ -155,6 +312,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl + this.addTask( + pos.x, pos.z, () -> 0, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> super.retainData(pos, retainData), () -> "retainData " + pos) + ); } public CompletableFuture<ChunkAccess> initializeLight(ChunkAccess chunk, boolean bl) { @@ -4792,7 +4786,7 @@ index f103a885777557af6cb864bfe8a6c5ca6ff351ab..814689f9eb0d4024bfa8512b799acf45 ChunkPos chunkPos = chunk.getPos(); this.addTask(chunkPos.x, chunkPos.z, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { LevelChunkSection[] levelChunkSections = chunk.getSections(); -@@ -179,6 +337,37 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl +@@ -165,6 +327,37 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl } public CompletableFuture<ChunkAccess> lightChunk(ChunkAccess chunk, boolean excludeBlocks) { @@ -4830,7 +4824,7 @@ index f103a885777557af6cb864bfe8a6c5ca6ff351ab..814689f9eb0d4024bfa8512b799acf45 ChunkPos chunkPos = chunk.getPos(); chunk.setLightCorrect(false); this.addTask(chunkPos.x, chunkPos.z, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { -@@ -198,7 +387,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl +@@ -180,7 +373,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl } public void tryScheduleUpdate() { @@ -4839,7 +4833,7 @@ index f103a885777557af6cb864bfe8a6c5ca6ff351ab..814689f9eb0d4024bfa8512b799acf45 this.taskMailbox.tell(() -> { this.runUpdate(); this.scheduled.set(false); -@@ -219,7 +408,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl +@@ -201,7 +394,7 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl } objectListIterator.back(j); @@ -5180,10 +5174,10 @@ index af757309cb46af6df07872f7596b66df6d6f18d7..73e682bb3ef3b2e450ec8c594b5365c7 this.level.getChunkSource().getLightEngine().checkBlock(blockposition); gameprofilerfiller.pop(); diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java -index a1ace0df243b43768bbb60a0941c18e3f5d10dfd..a6a8fbe2d6d538a0fea8a202ec8fdbecc009d664 100644 +index 268752a0b939abcaa9c7a302d2642b0c0fa2d331..2d7c6f00d399c7607e653078d77103a54509d03b 100644 --- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java -@@ -162,7 +162,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer +@@ -155,7 +155,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer return this.get(this.strategy.getIndex(x, y, z)); } @@ -5193,7 +5187,7 @@ index a1ace0df243b43768bbb60a0941c18e3f5d10dfd..a6a8fbe2d6d538a0fea8a202ec8fdbec return data.palette.valueFor(data.storage.get(index)); } diff --git a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java -index aee460cd2cfed3134870b5c02bf4ecb5738a5aa0..b4cf3d1405b79fb419be5116484f19dc76187b4a 100644 +index 03e5e5c5ea003ba52b9f3ee405cd77e22ea387c8..1036ff2ac8ba0967a36eb7977ed49500a05a33e6 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java @@ -141,7 +141,7 @@ public class ProtoChunk extends ChunkAccess { diff --git a/patches/server/0980-Rewrite-chunk-system.patch b/patches/server/0980-Rewrite-chunk-system.patch index 6093ffd30a..f7beb82fae 100644 --- a/patches/server/0980-Rewrite-chunk-system.patch +++ b/patches/server/0980-Rewrite-chunk-system.patch @@ -18911,7 +18911,7 @@ index bd6c60ebfc76d19313bf01048268f8ce7e6603c5..18356db5d998dccb9e645a9ee0bebc5c super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); this.chatVisibility = ChatVisiblity.FULL; diff --git a/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java b/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java -index 814689f9eb0d4024bfa8512b799acf4547786e9c..abf096eaa0ea1ada68a80c72d72b38e8b9d70c02 100644 +index 3229bb8dfb9f39e5fa1c8d91cb58057764cd4abb..17b624294fc0cab2976e3804e6c9a24b91a0e3aa 100644 --- a/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java +++ b/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java @@ -37,15 +37,12 @@ import net.minecraft.world.level.chunk.ChunkStatus; @@ -18970,7 +18970,7 @@ index 814689f9eb0d4024bfa8512b799acf4547786e9c..abf096eaa0ea1ada68a80c72d72b38e8 if (updateFuture == null) { // not scheduled -@@ -287,16 +283,11 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl +@@ -285,16 +281,11 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl } private void addTask(int x, int z, ThreadedLevelLightEngine.TaskType stage, Runnable task) { @@ -18989,7 +18989,7 @@ index 814689f9eb0d4024bfa8512b799acf4547786e9c..abf096eaa0ea1ada68a80c72d72b38e8 } @Override -@@ -337,87 +328,15 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl +@@ -327,83 +318,15 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl } public CompletableFuture<ChunkAccess> lightChunk(ChunkAccess chunk, boolean excludeBlocks) { @@ -19030,16 +19030,12 @@ index 814689f9eb0d4024bfa8512b799acf4547786e9c..abf096eaa0ea1ada68a80c72d72b38e8 - if (!excludeBlocks) { - super.propagateLightSources(chunkPos); - } -- }, () -> { -- return "lightChunk " + chunkPos + " " + excludeBlocks; -- })); +- }, () -> "lightChunk " + chunkPos + " " + excludeBlocks)); - return CompletableFuture.supplyAsync(() -> { - chunk.setLightCorrect(true); - this.chunkMap.releaseLightTicket(chunkPos); - return chunk; -- }, task -> { -- this.addTask(chunkPos.x, chunkPos.z, ThreadedLevelLightEngine.TaskType.POST_UPDATE, task); -- }); +- }, task -> this.addTask(chunkPos.x, chunkPos.z, ThreadedLevelLightEngine.TaskType.POST_UPDATE, task)); + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } @@ -19177,7 +19173,7 @@ index c3e7bd8865cc8990fc59f1ff0dfc1697cbb5ca49..5ece375eaf6bcc61864997a389bb5e24 + // 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 b7778d5296d01870e37560d8f03d48e4a4dd62ae..cc56479a54ccbb80e352c3e876e306647807c551 100644 +index e890162e1cea3538ed7dea7b78ee2e5346a8ce7b..9baae5af750b46ededbd660d15934da71befde72 100644 --- a/src/main/java/net/minecraft/server/network/PlayerChunkSender.java +++ b/src/main/java/net/minecraft/server/network/PlayerChunkSender.java @@ -43,16 +43,23 @@ public class PlayerChunkSender { @@ -19215,7 +19211,7 @@ index b7778d5296d01870e37560d8f03d48e4a4dd62ae..cc56479a54ccbb80e352c3e876e30664 handler.send(new ClientboundLevelChunkWithLightPacket(chunk, world.getLightEngine(), null, null)); // Paper start - PlayerChunkLoadEvent if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) { -@@ -115,6 +123,7 @@ public class PlayerChunkSender { +@@ -118,6 +126,7 @@ public class PlayerChunkSender { } public void onChunkBatchReceivedByClient(float desiredBatchSize) { @@ -19511,7 +19507,7 @@ index 5275e7a34f86830d43edcab3a0e94f8d8e9cfae5..b108f779abe3d9798c0bcbc983f41d48 @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 9d6b226e297af07486e4ee16091c23acafea9418..c80e75ba66bcd5957d6360a8d5de4f052dbf87d7 100644 +index ed008e1a9573ea3c75de94680b91c8ee598ee44a..c07cc1bf3b98525d72924edee4233364fd8174d0 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; @@ -19546,7 +19542,7 @@ index 9d6b226e297af07486e4ee16091c23acafea9418..c80e75ba66bcd5957d6360a8d5de4f05 } public void add(BlockPos pos, Holder<PoiType> type) { -@@ -201,8 +217,8 @@ public class PoiManager extends SectionStorage<PoiSection> { +@@ -177,8 +193,8 @@ public class PoiManager extends SectionStorage<PoiSection> { } public int sectionsToVillage(SectionPos pos) { @@ -19557,7 +19553,7 @@ index 9d6b226e297af07486e4ee16091c23acafea9418..c80e75ba66bcd5957d6360a8d5de4f05 } boolean isVillageCenter(long pos) { -@@ -216,21 +232,118 @@ public class PoiManager extends SectionStorage<PoiSection> { +@@ -192,21 +208,118 @@ public class PoiManager extends SectionStorage<PoiSection> { @Override public void tick(BooleanSupplier shouldKeepTicking) { @@ -19680,18 +19676,18 @@ index 9d6b226e297af07486e4ee16091c23acafea9418..c80e75ba66bcd5957d6360a8d5de4f05 + // Paper end - rewrite chunk system + public void checkConsistencyWithBlocks(SectionPos sectionPos, LevelChunkSection chunkSection) { - Util.ifElse(this.getOrLoad(sectionPos.asLong()), poiSet -> { - poiSet.refresh(populator -> { -@@ -276,7 +389,7 @@ public class PoiManager extends SectionStorage<PoiSection> { - return pair.getFirst().chunk(); - }) - .filter(chunkPos -> { -- return this.loadedChunks.add(chunkPos.toLong()); -+ return true; // Paper - rewrite chunk system - }) - .forEach(chunkPos -> { - world.getChunk(chunkPos.x, chunkPos.z, ChunkStatus.EMPTY); -@@ -293,7 +406,7 @@ public class PoiManager extends SectionStorage<PoiSection> { + Util.ifElse(this.getOrLoad(sectionPos.asLong()), poiSet -> poiSet.refresh(populator -> { + if (mayHavePoi(chunkSection)) { +@@ -241,7 +354,7 @@ public class PoiManager extends SectionStorage<PoiSection> { + .map(sectionPos -> Pair.of(sectionPos, this.getOrLoad(sectionPos.asLong()))) + .filter(pair -> !pair.getSecond().map(PoiSection::isValid).orElse(false)) + .map(pair -> pair.getFirst().chunk()) +- .filter(chunkPos -> this.loadedChunks.add(chunkPos.toLong())) ++ // Paper - rewrite chunk system + .forEach(chunkPos -> world.getChunk(chunkPos.x, chunkPos.z, ChunkStatus.EMPTY)); + } + +@@ -255,7 +368,7 @@ public class PoiManager extends SectionStorage<PoiSection> { @Override protected int getLevelFromSource(long id) { @@ -19700,7 +19696,7 @@ index 9d6b226e297af07486e4ee16091c23acafea9418..c80e75ba66bcd5957d6360a8d5de4f05 } @Override -@@ -315,6 +428,35 @@ public class PoiManager extends SectionStorage<PoiSection> { +@@ -277,6 +390,35 @@ public class PoiManager extends SectionStorage<PoiSection> { } } @@ -19737,7 +19733,7 @@ index 9d6b226e297af07486e4ee16091c23acafea9418..c80e75ba66bcd5957d6360a8d5de4f05 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 b54c6f70a9cb583ddcf1647dbbd05b4e1e5a1308..dbdcc8c842d427e1b0ce178a5d3cad23c4ccaf5e 100644 +index beb0ff150fdd8ca6c44139ccb2d0eb77a4431e0c..f7d69dd83aad8e0ec1497441c61188bcf230865f 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 { @@ -19747,7 +19743,7 @@ index b54c6f70a9cb583ddcf1647dbbd05b4e1e5a1308..dbdcc8c842d427e1b0ce178a5d3cad23 + public final Optional<PoiSection> noAllocateOptional = Optional.of(this); // Paper - rewrite chunk system public static Codec<PoiSection> codec(Runnable updateListener) { - return RecordCodecBuilder.<PoiSection>create(instance -> { + return RecordCodecBuilder.<PoiSection>create( @@ -46,6 +47,12 @@ public class PoiSection { this(updateListener, true, ImmutableList.of()); } @@ -19762,7 +19758,7 @@ index b54c6f70a9cb583ddcf1647dbbd05b4e1e5a1308..dbdcc8c842d427e1b0ce178a5d3cad23 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 77cd9d5518ac1d7c3c900354cdeb7be3fb66b0ac..eba4663a6928989bfa14d57303d77fdabea31481 100644 +index bd20bea7f76a7307f1698fb2dfef37125032d166..9a28912f52824acdc80a62243b136e6f365bf567 100644 --- a/src/main/java/net/minecraft/world/level/EntityGetter.java +++ b/src/main/java/net/minecraft/world/level/EntityGetter.java @@ -19,6 +19,18 @@ import net.minecraft.world.phys.shapes.Shapes; @@ -20894,7 +20890,7 @@ index fa086a19f038b929f356292b2f657929765f7b6f..f1ecc3832da094400ed9d45bfc60af10 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 8c0e4a0e451d1e0ff8ff20fbe3a92bb20b8b4bda..05c71f8468a3ea075c45465515fd1f075d6ce313 100644 +index 809da7fec1e1288a7a7bf1ee46c5b7bdd12bca01..bc6043a21227ce8c9c3879bc9c93c3803f79857b 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,17 +34,17 @@ import net.minecraft.world.level.ChunkPos; @@ -20934,7 +20930,7 @@ index 8c0e4a0e451d1e0ff8ff20fbe3a92bb20b8b4bda..05c71f8468a3ea075c45465515fd1f07 } protected void tick(BooleanSupplier shouldKeepTicking) { -@@ -124,23 +125,21 @@ public class SectionStorage<R> implements AutoCloseable { +@@ -122,23 +123,21 @@ public class SectionStorage<R> implements AutoCloseable { } private void readColumn(ChunkPos pos) { @@ -20967,7 +20963,7 @@ index 8c0e4a0e451d1e0ff8ff20fbe3a92bb20b8b4bda..05c71f8468a3ea075c45465515fd1f07 if (data == null) { for (int i = this.levelHeightAccessor.getMinSection(); i < this.levelHeightAccessor.getMaxSection(); i++) { this.storage.put(getKey(pos, i), Optional.empty()); -@@ -183,7 +182,7 @@ public class SectionStorage<R> implements AutoCloseable { +@@ -179,7 +178,7 @@ public class SectionStorage<R> implements AutoCloseable { Dynamic<Tag> dynamic = this.writeColumn(pos, registryOps); Tag tag = dynamic.getValue(); if (tag instanceof CompoundTag) { @@ -20976,7 +20972,7 @@ index 8c0e4a0e451d1e0ff8ff20fbe3a92bb20b8b4bda..05c71f8468a3ea075c45465515fd1f07 } else { LOGGER.error("Expected compound tag, got {}", tag); } -@@ -237,7 +236,7 @@ public class SectionStorage<R> implements AutoCloseable { +@@ -229,7 +228,7 @@ public class SectionStorage<R> implements AutoCloseable { } private static int getVersion(Dynamic<?> dynamic) { @@ -20985,7 +20981,7 @@ index 8c0e4a0e451d1e0ff8ff20fbe3a92bb20b8b4bda..05c71f8468a3ea075c45465515fd1f07 } public void flush(ChunkPos pos) { -@@ -254,6 +253,9 @@ public class SectionStorage<R> implements AutoCloseable { +@@ -246,6 +245,9 @@ public class SectionStorage<R> implements AutoCloseable { @Override public void close() throws IOException { @@ -21094,7 +21090,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 4303dc2366275dfab3901af4e522113f9a84ce4a..f6af4f61775eee7932e96fc600423ff59040d50d 100644 +index 769a8c5788e6a01666b9b5ac24b02c632c6c9e48..09867812600b24b3b7d05b58f98582650d313fc8 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 @@ -49,8 +49,101 @@ public class StructureCheck { @@ -21214,23 +21210,21 @@ index 4303dc2366275dfab3901af4e522113f9a84ce4a..f6af4f61775eee7932e96fc600423ff5 if (structureCheckResult != null) { return structureCheckResult; } else { -- boolean bl = this.featureChecks.computeIfAbsent(type, structure2 -> { -- return new Long2BooleanOpenHashMap(); -- }).computeIfAbsent(l, chunkPos -> { -+ boolean bl = this.featureChecksSafe.computeIfAbsent(type, structure2 -> { // Paper - rewrite chunk system - synchronise this class -+ return new SynchronisedLong2BooleanMap(PER_FEATURE_CHECK_LIMIT); // Paper - rewrite chunk system - synchronise this class -+ }).getOrCompute(l, chunkPos -> { // Paper - rewrite chunk system - synchronise this class - return this.canCreateStructure(pos, type); - }); +- boolean bl = this.featureChecks +- .computeIfAbsent(type, structure2 -> new Long2BooleanOpenHashMap()) +- .computeIfAbsent(l, chunkPos -> this.canCreateStructure(pos, type)); ++ boolean bl = this.featureChecksSafe // Paper - rewrite chunk system - synchronise this class ++ .computeIfAbsent(type, structure2 -> new SynchronisedLong2BooleanMap(PER_FEATURE_CHECK_LIMIT)) // Paper - rewrite chunk system - synchronise this class ++ .getOrCompute(l, chunkPos -> this.canCreateStructure(pos, type)); // Paper - rewrite chunk system - synchronise this class return !bl ? StructureCheckResult.START_NOT_PRESENT : StructureCheckResult.CHUNK_LOAD_NEEDED; -@@ -218,17 +311,26 @@ public class StructureCheck { + } + } +@@ -216,15 +309,26 @@ public class StructureCheck { } private void storeFullResults(long pos, Object2IntMap<Structure> referencesByStructure) { - this.loadedChunks.put(pos, deduplicateEmptyMap(referencesByStructure)); -- this.featureChecks.values().forEach(generationPossibilityByChunkPos -> { -- generationPossibilityByChunkPos.remove(pos); -- }); +- this.featureChecks.values().forEach(generationPossibilityByChunkPos -> generationPossibilityByChunkPos.remove(pos)); + // Paper start - rewrite chunk system - synchronise this class + this.loadedChunksSafe.put(pos, deduplicateEmptyMap(referencesByStructure)); + // once we insert into loadedChunks, we don't really need to be very careful about removing everything @@ -21254,8 +21248,8 @@ index 4303dc2366275dfab3901af4e522113f9a84ce4a..f6af4f61775eee7932e96fc600423ff5 } + // Paper end - rewrite chunk system - synchronise this class - referencesByStructure.computeInt(structure, (feature, references) -> { - return references == null ? 1 : references + 1; + referencesByStructure.computeInt(structure, (feature, references) -> references == null ? 1 : references + 1); + return referencesByStructure; diff --git a/src/main/java/net/minecraft/world/ticks/LevelChunkTicks.java b/src/main/java/net/minecraft/world/ticks/LevelChunkTicks.java index 47c2b2da9799690291396effb9e1b06d71efc6fd..2cdd18f724296f10cd4a522d1e8196723d39cf45 100644 --- a/src/main/java/net/minecraft/world/ticks/LevelChunkTicks.java diff --git a/patches/server/0982-Optimize-isInWorldBounds-and-getBlockState-for-inlin.patch b/patches/server/0982-Optimize-isInWorldBounds-and-getBlockState-for-inlin.patch index ed273d35cb..bb73216915 100644 --- a/patches/server/0982-Optimize-isInWorldBounds-and-getBlockState-for-inlin.patch +++ b/patches/server/0982-Optimize-isInWorldBounds-and-getBlockState-for-inlin.patch @@ -12,10 +12,10 @@ Replace all calls to the new place to the unnecessary forward. Optimize getType and getBlockData to manually inline and optimize the calls diff --git a/src/main/java/net/minecraft/core/Vec3i.java b/src/main/java/net/minecraft/core/Vec3i.java -index 5d996ece22d893818cda7c521725b2fd199759ff..9003ca5e317145728cd290710bc426adc574ac13 100644 +index 21387401c7958414fa6f3fd530488481d92a6eca..17bb8fb0353a818d946a0831781918781314c0ce 100644 --- a/src/main/java/net/minecraft/core/Vec3i.java +++ b/src/main/java/net/minecraft/core/Vec3i.java -@@ -36,6 +36,12 @@ public class Vec3i implements Comparable<Vec3i> { +@@ -30,6 +30,12 @@ public class Vec3i implements Comparable<Vec3i> { ); } @@ -71,7 +71,7 @@ index 030fafe3b0bcad9e95251f5824ac2ef58640c705..b4e05ce176dfc6a2e66b294ed461c320 @Override public FluidState getFluidState(BlockPos pos) { diff --git a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java -index b4cf3d1405b79fb419be5116484f19dc76187b4a..34343246f2d5ce082cd4a342249f4f189255b629 100644 +index 1036ff2ac8ba0967a36eb7977ed49500a05a33e6..a1f6274c9b1ab02ee55f1ae6011fc2dbb6e4824f 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java @@ -95,14 +95,18 @@ public class ProtoChunk extends ChunkAccess { diff --git a/patches/server/0989-Entity-Activation-Range-2.0.patch b/patches/server/0989-Entity-Activation-Range-2.0.patch index 89ff4e2c84..9fb613e8c3 100644 --- a/patches/server/0989-Entity-Activation-Range-2.0.patch +++ b/patches/server/0989-Entity-Activation-Range-2.0.patch @@ -183,7 +183,7 @@ index d6393210cfee53685f83c8491bea8b9c13b01eea..3d95257d2203fe40bb1fab58ad2a1f9e public float getWalkTargetValue(BlockPos pos) { return this.getWalkTargetValue(pos, this.level()); diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java -index 05142a6c332b8f2257199fee9db57d3d92f6bff2..b236ac6e261790b53944885d0d6575eba0986fde 100644 +index 9be9a6a59666297e05a9fc19d9345ae7d5f3bf40..040d62effc651d14d3557f8ff582cb078b74ae1e 100644 --- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java +++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java @@ -34,6 +34,7 @@ public class GoalSelector { @@ -194,8 +194,8 @@ index 05142a6c332b8f2257199fee9db57d3d92f6bff2..b236ac6e261790b53944885d0d6575eb public GoalSelector(Supplier<ProfilerFiller> profiler) { this.profiler = profiler; -@@ -50,6 +51,20 @@ public class GoalSelector { - }); +@@ -48,6 +49,20 @@ public class GoalSelector { + this.availableGoals.removeIf(goal -> predicate.test(goal.getGoal())); } + // Paper start @@ -213,8 +213,8 @@ index 05142a6c332b8f2257199fee9db57d3d92f6bff2..b236ac6e261790b53944885d0d6575eb + } + // Paper end public void removeGoal(Goal goal) { - this.availableGoals.stream().filter(wrappedGoal -> { - return wrappedGoal.getGoal() == goal; + this.availableGoals.stream().filter(wrappedGoal -> wrappedGoal.getGoal() == goal).filter(WrappedGoal::isRunning).forEach(WrappedGoal::stop); + this.availableGoals.removeIf(wrappedGoal -> wrappedGoal.getGoal() == goal); diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java index 6d8ea05e5e86e9f6359b560043bb55a10784e952..aee0147649d458b87d92496eda0c1723ebe570d2 100644 --- a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java @@ -357,10 +357,10 @@ index 5c209e323a5559480231c6d99357ba8b89edb027..4bedd5801cc8ce14387f02dfb361a00a public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot // Paper start - add paper world config diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -index 8a5fccf52230eae9777a0157cc25c1321fcf094c..fc6bf624f63beb61737460d5e2ffb70a824b565b 100644 +index 0e15da7cae105196d444b924b8e0db190583ba30..9f45dda6ff45ac1ffb7ac99575b7d09bdc61c56a 100644 --- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -@@ -149,6 +149,10 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -147,6 +147,10 @@ public class PistonMovingBlockEntity extends BlockEntity { } entity.setDeltaMovement(e, g, h); diff --git a/patches/server/0991-Anti-Xray.patch b/patches/server/0991-Anti-Xray.patch index e314f559e8..0e19dabd18 100644 --- a/patches/server/0991-Anti-Xray.patch +++ b/patches/server/0991-Anti-Xray.patch @@ -1001,10 +1001,10 @@ 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 51b01a1d4f3a33f9c321349051b038acc9786b9c..76114aa1369539855ccebd4361218693f8975821 100644 +index 921bd11bd8d266c2dd5c78a44f4714a48417eb3e..99e6d6e97e2869d574ea04b7eccbd6c0f827b19b 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<ClientboundChunksBiomesPacket.C +@@ -61,8 +61,10 @@ public record ClientboundChunksBiomesPacket(List<ClientboundChunksBiomesPacket.C } public static void extractChunkData(FriendlyByteBuf buf, LevelChunk chunk) { @@ -1017,7 +1017,7 @@ index 51b01a1d4f3a33f9c321349051b038acc9786b9c..76114aa1369539855ccebd4361218693 } diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index ebd7b78f9d3439f8278846c32ee3317ad9f1e6ad..9c51c4d12bac588002f530f484ee89b094269349 100644 +index 03b6aa2e3bd871ae59e761866b53a10f72b3cdac..454bec4f8843e7e4e42cd8a8132b557ead292dcc 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java @@ -25,7 +25,10 @@ public class ClientboundLevelChunkPacketData { @@ -1048,7 +1048,7 @@ index ebd7b78f9d3439f8278846c32ee3317ad9f1e6ad..9c51c4d12bac588002f530f484ee89b0 this.blockEntitiesData = Lists.newArrayList(); for (Entry<BlockPos, BlockEntity> entry2 : chunk.getBlockEntities().entrySet()) { -@@ -84,9 +94,15 @@ public class ClientboundLevelChunkPacketData { +@@ -82,9 +92,15 @@ public class ClientboundLevelChunkPacketData { return byteBuf; } @@ -1139,7 +1139,7 @@ index 5063eb6d4a24600262c32d2c9eb5fb5bf8fa354e..692a01b52a71e26887ee42cbd5fd64b0 public void destroyAndAck(BlockPos pos, int sequence, String reason) { diff --git a/src/main/java/net/minecraft/server/network/PlayerChunkSender.java b/src/main/java/net/minecraft/server/network/PlayerChunkSender.java -index cc56479a54ccbb80e352c3e876e306647807c551..eddff7cf4bc7d0a491994fd0a20a6509dc2b6efc 100644 +index 9baae5af750b46ededbd660d15934da71befde72..8a360bf585041af8cd74dbb38d3c888c998289c5 100644 --- a/src/main/java/net/minecraft/server/network/PlayerChunkSender.java +++ b/src/main/java/net/minecraft/server/network/PlayerChunkSender.java @@ -87,7 +87,10 @@ public class PlayerChunkSender { @@ -1280,18 +1280,18 @@ index b606e33f8b64eaba28c008cc353d88aa45549e31..8852263cb6faec1b68326145aa30e5cd public int getSerializedSize() { diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java -index a6a8fbe2d6d538a0fea8a202ec8fdbecc009d664..5418261725f7a0dc9a0e8295fe511f69b558a6cd 100644 +index 2d7c6f00d399c7607e653078d77103a54509d03b..d473637a705c1f11079fff08e334545779a99a84 100644 --- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java -@@ -30,6 +30,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer - return 0; - }; +@@ -28,6 +28,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer + private static final int MIN_PALETTE_BITS = 0; + private final PaletteResize<T> dummyPaletteResize = (newSize, added) -> 0; public final IdMap<T> registry; + private final T @org.jetbrains.annotations.Nullable [] presetValues; // Paper - Anti-Xray - Add preset values private volatile PalettedContainer.Data<T> data; private final PalettedContainer.Strategy strategy; // private final ThreadingDetector threadingDetector = new ThreadingDetector("PalettedContainer"); // Paper - unused -@@ -42,14 +43,19 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer +@@ -40,14 +41,19 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer // this.threadingDetector.checkAndUnlock(); // Paper - disable this } @@ -1308,14 +1308,14 @@ index a6a8fbe2d6d538a0fea8a202ec8fdbecc009d664..5418261725f7a0dc9a0e8295fe511f69 } public static <T> Codec<PalettedContainerRO<T>> codecRO(IdMap<T> idList, Codec<T> entryCodec, PalettedContainer.Strategy paletteProvider, T defaultValue) { - PalettedContainerRO.Unpacker<T, PalettedContainerRO<T>> unpacker = (idListx, paletteProviderx, serialized) -> { -- return unpack(idListx, paletteProviderx, serialized).map(result -> { -+ return unpack(idListx, paletteProviderx, serialized, defaultValue, null).map(result -> { // Paper - Anti-Xray - Add preset values - return (PalettedContainerRO<T>)result; - }); - }; -@@ -78,25 +84,58 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer - }); + PalettedContainerRO.Unpacker<T, PalettedContainerRO<T>> unpacker = (idListx, paletteProviderx, serialized) -> unpack( +- idListx, paletteProviderx, serialized ++ idListx, paletteProviderx, serialized, defaultValue, null // Paper - Anti-Xray - Add preset values + ) + .map(result -> (PalettedContainerRO<T>)result); + return codec(idList, entryCodec, paletteProvider, defaultValue, unpacker); +@@ -71,25 +77,58 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer + ); } + // Paper start - Anti-Xray - Add preset values @@ -1376,7 +1376,7 @@ index a6a8fbe2d6d538a0fea8a202ec8fdbecc009d664..5418261725f7a0dc9a0e8295fe511f69 this.strategy = paletteProvider; this.registry = idList; this.data = this.createOrReuseData(null, 0); -@@ -113,11 +152,33 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer +@@ -106,11 +145,33 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer @Override public synchronized int onResize(int newBits, T object) { // Paper - synchronize PalettedContainer.Data<T> data = this.data; @@ -1411,7 +1411,7 @@ index a6a8fbe2d6d538a0fea8a202ec8fdbecc009d664..5418261725f7a0dc9a0e8295fe511f69 public T getAndSet(int x, int y, int z, T value) { this.acquire(); -@@ -186,24 +247,33 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer +@@ -177,24 +238,33 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer data.palette.read(buf); buf.readLongArray(data.storage.getRaw()); this.data = data; @@ -1448,7 +1448,7 @@ index a6a8fbe2d6d538a0fea8a202ec8fdbecc009d664..5418261725f7a0dc9a0e8295fe511f69 ) { List<T> list = serialized.paletteEntries(); int i = paletteProvider.size(); -@@ -244,7 +314,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer +@@ -227,7 +297,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer } } @@ -1457,7 +1457,7 @@ index a6a8fbe2d6d538a0fea8a202ec8fdbecc009d664..5418261725f7a0dc9a0e8295fe511f69 } @Override -@@ -303,12 +373,12 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer +@@ -284,12 +354,12 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer } public PalettedContainer<T> copy() { @@ -1472,7 +1472,7 @@ index a6a8fbe2d6d538a0fea8a202ec8fdbecc009d664..5418261725f7a0dc9a0e8295fe511f69 } @Override -@@ -351,9 +421,18 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer +@@ -328,9 +398,18 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer return 1 + this.palette.getSerializedSize() + VarInt.getByteSize(this.storage.getRaw().length) + this.storage.getRaw().length * 8; } diff --git a/patches/server/0994-Optimize-GoalSelector-Goal.Flag-Set-operations.patch b/patches/server/0994-Optimize-GoalSelector-Goal.Flag-Set-operations.patch index b3736865b4..93d48fc88d 100644 --- a/patches/server/0994-Optimize-GoalSelector-Goal.Flag-Set-operations.patch +++ b/patches/server/0994-Optimize-GoalSelector-Goal.Flag-Set-operations.patch @@ -58,7 +58,7 @@ index 16f9a98b8a939e5ca7e2dc04f87134a7ed66736b..dd423302b1baa64ef86ded87a2965934 protected int adjustedTickDelay(int ticks) { diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java -index b236ac6e261790b53944885d0d6575eba0986fde..1a9d20db26d6e3d633df5484b6f7f3125c6b2c97 100644 +index 040d62effc651d14d3557f8ff582cb078b74ae1e..704423f8ae549a12889e4a15c216e9c471e59aca 100644 --- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java +++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java @@ -31,10 +31,12 @@ public class GoalSelector { @@ -75,16 +75,12 @@ index b236ac6e261790b53944885d0d6575eba0986fde..1a9d20db26d6e3d633df5484b6f7f312 public GoalSelector(Supplier<ProfilerFiller> profiler) { this.profiler = profiler; -@@ -66,26 +68,32 @@ public class GoalSelector { +@@ -64,22 +66,32 @@ public class GoalSelector { } // Paper end public void removeGoal(Goal goal) { -- this.availableGoals.stream().filter(wrappedGoal -> { -- return wrappedGoal.getGoal() == goal; -- }).filter(WrappedGoal::isRunning).forEach(WrappedGoal::stop); -- this.availableGoals.removeIf(wrappedGoal -> { -- return wrappedGoal.getGoal() == goal; -- }); +- this.availableGoals.stream().filter(wrappedGoal -> wrappedGoal.getGoal() == goal).filter(WrappedGoal::isRunning).forEach(WrappedGoal::stop); +- this.availableGoals.removeIf(wrappedGoal -> wrappedGoal.getGoal() == goal); - } - - private static boolean goalContainsAnyFlags(WrappedGoal goal, EnumSet<Goal.Flag> controls) { @@ -122,7 +118,7 @@ index b236ac6e261790b53944885d0d6575eba0986fde..1a9d20db26d6e3d633df5484b6f7f312 if (!goalsByControl.getOrDefault(flag, NO_GOAL).canBeReplacedBy(goal)) { return false; } -@@ -99,7 +107,7 @@ public class GoalSelector { +@@ -93,7 +105,7 @@ public class GoalSelector { profilerFiller.push("goalCleanup"); for (WrappedGoal wrappedGoal : this.availableGoals) { @@ -131,7 +127,7 @@ index b236ac6e261790b53944885d0d6575eba0986fde..1a9d20db26d6e3d633df5484b6f7f312 wrappedGoal.stop(); } } -@@ -117,11 +125,14 @@ public class GoalSelector { +@@ -111,11 +123,14 @@ public class GoalSelector { profilerFiller.push("goalUpdate"); for (WrappedGoal wrappedGoal2 : this.availableGoals) { @@ -151,7 +147,7 @@ index b236ac6e261790b53944885d0d6575eba0986fde..1a9d20db26d6e3d633df5484b6f7f312 WrappedGoal wrappedGoal3 = this.lockedFlags.getOrDefault(flag, NO_GOAL); wrappedGoal3.stop(); this.lockedFlags.put(flag, wrappedGoal2); -@@ -161,11 +172,11 @@ public class GoalSelector { +@@ -155,11 +170,11 @@ public class GoalSelector { } public void disableControlFlag(Goal.Flag control) { diff --git a/patches/server/1002-Optimize-Bit-Operations-by-inlining.patch b/patches/server/1002-Optimize-Bit-Operations-by-inlining.patch index 72a4578554..5823fb0d37 100644 --- a/patches/server/1002-Optimize-Bit-Operations-by-inlining.patch +++ b/patches/server/1002-Optimize-Bit-Operations-by-inlining.patch @@ -7,11 +7,11 @@ Inline bit operations and reduce instruction count to make these hot operations faster diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java -index f06a51b70df8450801a27bb06e6d7f6e4ee3049e..58573dba0ad7590d1f799af2bebadc03853393ef 100644 +index d80e3f5f53b9d28dea574cff5c65dfa3f8148f88..70f9e737b3b9f80395afc3542aafe4a0c774c722 100644 --- a/src/main/java/net/minecraft/core/BlockPos.java +++ b/src/main/java/net/minecraft/core/BlockPos.java -@@ -37,15 +37,16 @@ public class BlockPos extends Vec3i { - }).stable(); +@@ -36,15 +36,16 @@ public class BlockPos extends Vec3i { + .stable(); private static final Logger LOGGER = LogUtils.getLogger(); public static final BlockPos ZERO = new BlockPos(0, 0, 0); - private static final int PACKED_X_LENGTH = 1 + Mth.log2(Mth.smallestEncompassingPowerOfTwo(30000000)); @@ -36,7 +36,7 @@ index f06a51b70df8450801a27bb06e6d7f6e4ee3049e..58573dba0ad7590d1f799af2bebadc03 public BlockPos(int x, int y, int z) { super(x, y, z); -@@ -55,28 +56,29 @@ public class BlockPos extends Vec3i { +@@ -54,28 +55,29 @@ public class BlockPos extends Vec3i { this(pos.getX(), pos.getY(), pos.getZ()); } @@ -71,7 +71,7 @@ index f06a51b70df8450801a27bb06e6d7f6e4ee3049e..58573dba0ad7590d1f799af2bebadc03 } public static BlockPos containing(double x, double y, double z) { -@@ -92,10 +94,7 @@ public class BlockPos extends Vec3i { +@@ -91,10 +93,7 @@ public class BlockPos extends Vec3i { } public static long asLong(int x, int y, int z) { diff --git a/patches/server/1003-Remove-streams-from-hot-code.patch b/patches/server/1003-Remove-streams-from-hot-code.patch index bf425cde83..458d94198a 100644 --- a/patches/server/1003-Remove-streams-from-hot-code.patch +++ b/patches/server/1003-Remove-streams-from-hot-code.patch @@ -7,10 +7,10 @@ Co-authored-by: Bjarne Koll <[email protected]> Co-authored-by: Spottedleaf <[email protected]> diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java -index ef1e9457aa215afd0d9a0a9cda2f6b5c4ac6974f..f93543049d014e26d16e6b5d7995f776948212af 100644 +index 5ca112631cce775c609950d3540059f54033fd3e..5e13c5d7534397b902889b8dde9037da114b1039 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java -@@ -59,7 +59,7 @@ public class GateBehavior<E extends LivingEntity> implements BehaviorControl<E> +@@ -57,7 +57,7 @@ public class GateBehavior<E extends LivingEntity> implements BehaviorControl<E> if (this.hasRequiredMemories(entity)) { this.status = Behavior.Status.RUNNING; this.orderPolicy.apply(this.behaviors); @@ -19,15 +19,11 @@ index ef1e9457aa215afd0d9a0a9cda2f6b5c4ac6974f..f93543049d014e26d16e6b5d7995f776 return true; } else { return false; -@@ -68,11 +68,13 @@ public class GateBehavior<E extends LivingEntity> implements BehaviorControl<E> +@@ -66,7 +66,13 @@ public class GateBehavior<E extends LivingEntity> implements BehaviorControl<E> @Override public final void tickOrStop(ServerLevel world, E entity, long time) { -- this.behaviors.stream().filter(task -> { -- return task.getStatus() == Behavior.Status.RUNNING; -- }).forEach(task -> { -- task.tickOrStop(world, entity, time); -- }); +- this.behaviors.stream().filter(task -> task.getStatus() == Behavior.Status.RUNNING).forEach(task -> task.tickOrStop(world, entity, time)); + // Paper start - Perf: Remove streams from hot code + for (final BehaviorControl<? super E> task : this.behaviors) { + if (task.getStatus() == Behavior.Status.RUNNING) { @@ -35,18 +31,14 @@ index ef1e9457aa215afd0d9a0a9cda2f6b5c4ac6974f..f93543049d014e26d16e6b5d7995f776 + } + } + // Paper end - Perf: Remove streams from hot code - if (this.behaviors.stream().noneMatch(task -> { - return task.getStatus() == Behavior.Status.RUNNING; - })) { -@@ -83,12 +85,16 @@ public class GateBehavior<E extends LivingEntity> implements BehaviorControl<E> + if (this.behaviors.stream().noneMatch(task -> task.getStatus() == Behavior.Status.RUNNING)) { + this.doStop(world, entity, time); + } +@@ -75,8 +81,16 @@ public class GateBehavior<E extends LivingEntity> implements BehaviorControl<E> @Override public final void doStop(ServerLevel world, E entity, long time) { this.status = Behavior.Status.STOPPED; -- this.behaviors.stream().filter(task -> { -- return task.getStatus() == Behavior.Status.RUNNING; -- }).forEach(task -> { -- task.doStop(world, entity, time); -- }); +- this.behaviors.stream().filter(task -> task.getStatus() == Behavior.Status.RUNNING).forEach(task -> task.doStop(world, entity, time)); - this.exitErasedMemories.forEach(entity.getBrain()::eraseMemory); + // Paper start - Perf: Remove streams from hot code + for (final BehaviorControl<? super E> task : this.behaviors) { @@ -61,18 +53,14 @@ index ef1e9457aa215afd0d9a0a9cda2f6b5c4ac6974f..f93543049d014e26d16e6b5d7995f776 } @Override -@@ -122,26 +128,30 @@ public class GateBehavior<E extends LivingEntity> implements BehaviorControl<E> +@@ -111,18 +125,30 @@ public class GateBehavior<E extends LivingEntity> implements BehaviorControl<E> public static enum RunningPolicy { RUN_ONE { + // Paper start - Perf: Remove streams from hot code @Override - public <E extends LivingEntity> void apply(Stream<BehaviorControl<? super E>> tasks, ServerLevel world, E entity, long time) { -- tasks.filter(task -> { -- return task.getStatus() == Behavior.Status.STOPPED; -- }).filter(task -> { -- return task.tryStart(world, entity, time); -- }).findFirst(); +- tasks.filter(task -> task.getStatus() == Behavior.Status.STOPPED).filter(task -> task.tryStart(world, entity, time)).findFirst(); + public <E extends LivingEntity> void apply(ShufflingList<BehaviorControl<? super E>> tasks, ServerLevel world, E entity, long time) { + for (final BehaviorControl<? super E> task : tasks) { + if (task.getStatus() == Behavior.Status.STOPPED && task.tryStart(world, entity, time)) { @@ -86,11 +74,7 @@ index ef1e9457aa215afd0d9a0a9cda2f6b5c4ac6974f..f93543049d014e26d16e6b5d7995f776 + // Paper start - Perf: Remove streams from hot code @Override - public <E extends LivingEntity> void apply(Stream<BehaviorControl<? super E>> tasks, ServerLevel world, E entity, long time) { -- tasks.filter(task -> { -- return task.getStatus() == Behavior.Status.STOPPED; -- }).forEach(task -> { -- task.tryStart(world, entity, time); -- }); +- tasks.filter(task -> task.getStatus() == Behavior.Status.STOPPED).forEach(task -> task.tryStart(world, entity, time)); + public <E extends LivingEntity> void apply(ShufflingList<BehaviorControl<? super E>> tasks, ServerLevel world, E entity, long time) { + for (final BehaviorControl<? super E> task : tasks) { + if (task.getStatus() == Behavior.Status.STOPPED) { @@ -106,11 +90,11 @@ index ef1e9457aa215afd0d9a0a9cda2f6b5c4ac6974f..f93543049d014e26d16e6b5d7995f776 } } diff --git a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java -index 2ac97b08932a182c1512ed935a4d76b341c6a6aa..703ae9b8e38cf829dbf5a8be9364e7d413591ea7 100644 +index aa32804bc9affe9a615d3ffaa513f6f09aab3f32..c7f012674361a323c1efeca4660cd3f46d308ee1 100644 --- a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java +++ b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java -@@ -61,8 +61,22 @@ public class GossipContainer { - }); +@@ -59,8 +59,22 @@ public class GossipContainer { + return this.gossips.entrySet().stream().flatMap(entry -> entry.getValue().unpack(entry.getKey())); } + // Paper start - Perf: Remove streams from hot code @@ -133,24 +117,25 @@ index 2ac97b08932a182c1512ed935a4d76b341c6a6aa..703ae9b8e38cf829dbf5a8be9364e7d4 if (list.isEmpty()) { return Collections.emptyList(); } else { -@@ -152,7 +166,7 @@ public class GossipContainer { - } +@@ -145,7 +159,7 @@ public class GossipContainer { public <T> T store(DynamicOps<T> ops) { -- return GossipContainer.GossipEntry.LIST_CODEC.encodeStart(ops, this.unpack().toList()).resultOrPartial(error -> { -+ return GossipContainer.GossipEntry.LIST_CODEC.encodeStart(ops, this.decompress()).resultOrPartial(error -> { // Paper - Perf: Remove streams from hot code - LOGGER.warn("Failed to serialize gossips: {}", error); - }).orElseGet(ops::emptyList); + return GossipContainer.GossipEntry.LIST_CODEC +- .encodeStart(ops, this.unpack().toList()) ++ .encodeStart(ops, this.decompress()) // Paper - Perf: Remove streams from hot code + .resultOrPartial(error -> LOGGER.warn("Failed to serialize gossips: {}", error)) + .orElseGet(ops::emptyList); } -@@ -180,11 +194,23 @@ public class GossipContainer { +@@ -172,12 +186,23 @@ public class GossipContainer { final Object2IntMap<GossipType> entries = new Object2IntOpenHashMap<>(); public int weightedValue(Predicate<GossipType> gossipTypeFilter) { -- return this.entries.object2IntEntrySet().stream().filter(entry -> { -- return gossipTypeFilter.test(entry.getKey()); -- }).mapToInt(entry -> { -- return entry.getIntValue() * entry.getKey().weight; -- }).sum(); +- return this.entries +- .object2IntEntrySet() +- .stream() +- .filter(entry -> gossipTypeFilter.test(entry.getKey())) +- .mapToInt(entry -> entry.getIntValue() * entry.getKey().weight) +- .sum(); + // Paper start - Perf: Remove streams from hot code + int weight = 0; + for (Object2IntMap.Entry<GossipType> entry : entries.object2IntEntrySet()) { @@ -172,22 +157,21 @@ index 2ac97b08932a182c1512ed935a4d76b341c6a6aa..703ae9b8e38cf829dbf5a8be9364e7d4 public Stream<GossipContainer.GossipEntry> unpack(UUID target) { diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java -index b518a843e9b599c15558f27476a758c7980ed5c3..bbe2d8f64b1cfd952bba45f4408bb3bc66464a15 100644 +index 28fd073ddad358e087e8c78985a97cad21be81b7..a5bd308d1b3ea5db185c06a287167d1d8894a987 100644 --- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java +++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java -@@ -25,14 +25,18 @@ public class NearestItemSensor extends Sensor<Mob> { +@@ -24,13 +24,17 @@ public class NearestItemSensor extends Sensor<Mob> { + @Override protected void doTick(ServerLevel world, Mob entity) { Brain<?> brain = entity.getBrain(); - List<ItemEntity> list = world.getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(32.0, 16.0, 32.0), itemEntity -> { -- return true; -+ return itemEntity.closerThan(entity, MAX_DISTANCE_TO_WANTED_ITEM) && entity.wantsToPickUp(itemEntity.getItem()); // Paper - Perf: Move predicate into getEntities - }); +- List<ItemEntity> list = world.getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(32.0, 16.0, 32.0), itemEntity -> true); ++ List<ItemEntity> list = world.getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(32.0, 16.0, 32.0), itemEntity -> itemEntity.closerThan(entity, MAX_DISTANCE_TO_WANTED_ITEM) && entity.wantsToPickUp(itemEntity.getItem())); // Paper - Perf: Move predicate into getEntities list.sort(Comparator.comparingDouble(entity::distanceToSqr)); -- Optional<ItemEntity> optional = list.stream().filter(itemEntity -> { -- return entity.wantsToPickUp(itemEntity.getItem()); -- }).filter(itemEntity -> { -- return itemEntity.closerThan(entity, 32.0); -- }).filter(entity::hasLineOfSight).findFirst(); +- Optional<ItemEntity> optional = list.stream() +- .filter(itemEntity -> entity.wantsToPickUp(itemEntity.getItem())) +- .filter(itemEntity -> itemEntity.closerThan(entity, 32.0)) +- .filter(entity::hasLineOfSight) +- .findFirst(); - brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, optional); + // Paper start - Perf: remove streams from hot code + ItemEntity nearest = null; @@ -202,16 +186,14 @@ index b518a843e9b599c15558f27476a758c7980ed5c3..bbe2d8f64b1cfd952bba45f4408bb3bc } } diff --git a/src/main/java/net/minecraft/world/level/levelgen/Beardifier.java b/src/main/java/net/minecraft/world/level/levelgen/Beardifier.java -index 0082d641d3fb9631f3262d8dc41863cb638d341a..ba549438664c8bfa736084b256663f9e7c5e26c6 100644 +index a530a214bd9c1eccb67e954a5fb9858dcc7719c5..ba549438664c8bfa736084b256663f9e7c5e26c6 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/Beardifier.java +++ b/src/main/java/net/minecraft/world/level/levelgen/Beardifier.java -@@ -35,11 +35,10 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker { +@@ -35,9 +35,10 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker { int j = pos.getMinBlockZ(); ObjectList<Beardifier.Rigid> objectList = new ObjectArrayList<>(10); ObjectList<JigsawJunction> objectList2 = new ObjectArrayList<>(32); -- world.startsForStructure(pos, structure -> { -- return structure.terrainAdaptation() != TerrainAdjustment.NONE; -- }) +- world.startsForStructure(pos, structure -> structure.terrainAdaptation() != TerrainAdjustment.NONE) - .forEach( - start -> { + // Paper start - Perf: Remove streams from hot code @@ -221,7 +203,7 @@ index 0082d641d3fb9631f3262d8dc41863cb638d341a..ba549438664c8bfa736084b256663f9e TerrainAdjustment terrainAdjustment = start.getStructure().terrainAdaptation(); for (StructurePiece structurePiece : start.getPieces()) { -@@ -67,8 +66,7 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker { +@@ -65,8 +66,7 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker { } } } diff --git a/patches/server/1005-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch b/patches/server/1005-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch index ae79f5fd1c..76d173106a 100644 --- a/patches/server/1005-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch +++ b/patches/server/1005-Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch @@ -16,16 +16,15 @@ This lets us get faster foreach iteration, as well as avoids map lookups on the values when needed. diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -index 846e84d59303661f06f871879cccca3d721d4f04..d1e1f12451058f7f276f8277536a4c0a4d736601 100644 +index a2e7040df11a0138c706a10b190111b6c3bd99a9..d1e1f12451058f7f276f8277536a4c0a4d736601 100644 --- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java +++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -@@ -38,9 +38,12 @@ public class PathFinder { +@@ -38,8 +38,12 @@ public class PathFinder { if (node == null) { return null; } else { -- Map<Target, BlockPos> map = positions.stream().collect(Collectors.toMap(pos -> { -- return this.nodeEvaluator.getGoal((double)pos.getX(), (double)pos.getY(), (double)pos.getZ()); -- }, Function.identity())); +- Map<Target, BlockPos> map = positions.stream() +- .collect(Collectors.toMap(pos -> this.nodeEvaluator.getGoal((double)pos.getX(), (double)pos.getY(), (double)pos.getZ()), Function.identity())); + // Paper start - Perf: remove streams and optimize collection + List<Map.Entry<Target, BlockPos>> map = Lists.newArrayList(); + for (BlockPos pos : positions) { @@ -35,7 +34,7 @@ index 846e84d59303661f06f871879cccca3d721d4f04..d1e1f12451058f7f276f8277536a4c0a Path path = this.findPath(world.getProfiler(), node, map, followRange, distance, rangeMultiplier); this.nodeEvaluator.done(); return path; -@@ -48,18 +51,19 @@ public class PathFinder { +@@ -47,18 +51,19 @@ public class PathFinder { } @Nullable @@ -60,7 +59,7 @@ index 846e84d59303661f06f871879cccca3d721d4f04..d1e1f12451058f7f276f8277536a4c0a int j = (int)((float)this.maxVisitedNodes * rangeMultiplier); while (!this.openSet.isEmpty()) { -@@ -70,14 +74,18 @@ public class PathFinder { +@@ -69,14 +74,18 @@ public class PathFinder { Node node = this.openSet.pop(); node.closed = true; @@ -82,7 +81,7 @@ index 846e84d59303661f06f871879cccca3d721d4f04..d1e1f12451058f7f276f8277536a4c0a break; } -@@ -92,7 +100,7 @@ public class PathFinder { +@@ -91,7 +100,7 @@ public class PathFinder { if (node2.walkedDistance < followRange && (!node2.inOpenSet() || g < node2.g)) { node2.cameFrom = node; node2.g = g; @@ -91,15 +90,15 @@ index 846e84d59303661f06f871879cccca3d721d4f04..d1e1f12451058f7f276f8277536a4c0a if (node2.inOpenSet()) { this.openSet.changeCost(node2, node2.g + node2.h); } else { -@@ -104,23 +112,32 @@ public class PathFinder { +@@ -103,23 +112,32 @@ public class PathFinder { } } -- Optional<Path> optional = !set3.isEmpty() ? set3.stream().map(node -> { -- return this.reconstructPath(node.getBestNode(), positions.get(node), true); -- }).min(Comparator.comparingInt(Path::getNodeCount)) : set.stream().map(targetx -> { -- return this.reconstructPath(targetx.getBestNode(), positions.get(targetx), false); -- }).min(Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount)); +- Optional<Path> optional = !set3.isEmpty() +- ? set3.stream().map(node -> this.reconstructPath(node.getBestNode(), positions.get(node), true)).min(Comparator.comparingInt(Path::getNodeCount)) +- : set.stream() +- .map(targetx -> this.reconstructPath(targetx.getBestNode(), positions.get(targetx), false)) +- .min(Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount)); + // Paper start - Perf: remove streams and optimize collection + Path best = null; + boolean entryListIsEmpty = entryList.isEmpty(); diff --git a/patches/server/1007-Improve-boat-collision-performance.patch b/patches/server/1007-Improve-boat-collision-performance.patch index 3de7a875b6..d32dfc35cc 100644 --- a/patches/server/1007-Improve-boat-collision-performance.patch +++ b/patches/server/1007-Improve-boat-collision-performance.patch @@ -5,13 +5,13 @@ Subject: [PATCH] Improve boat collision performance diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java -index 081b460aa9b3674bf239378a6fc3f6cd30bb2d26..7eb6562ac38fed3fc79e98ebbcb2633ea8cb6e48 100644 +index 72e734af483dc03e1ae947b2ab3b6fa7df38ce62..01a12f4d6f3c2f09bffc78692443b9fd391db45a 100644 --- a/src/main/java/net/minecraft/Util.java +++ b/src/main/java/net/minecraft/Util.java @@ -123,6 +123,7 @@ public class Util { - }).findFirst().orElseThrow(() -> { - return new IllegalStateException("No jar file system provider found"); - }); + .filter(fileSystemProvider -> fileSystemProvider.getScheme().equalsIgnoreCase("jar")) + .findFirst() + .orElseThrow(() -> new IllegalStateException("No jar file system provider found")); + public static final double COLLISION_EPSILON = 1.0E-7; // Paper - Improve boat collision performance private static Consumer<String> thePauser = message -> { }; diff --git a/patches/server/1008-Optimise-general-POI-access.patch b/patches/server/1008-Optimise-general-POI-access.patch index f1f6ef5a39..37c3515f14 100644 --- a/patches/server/1008-Optimise-general-POI-access.patch +++ b/patches/server/1008-Optimise-general-POI-access.patch @@ -841,10 +841,10 @@ index 0000000000000000000000000000000000000000..69be1761b3b5ba7b496c1c10a4db897e + } +} diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -index 05d529a74fa3412b4b07bcf0d469118c38862279..a46aa33d3013003a899659c4bd039d12544b73d7 100644 +index ea9a3cb588213af1a1eb9a79d0b7244f99048b5e..7fe13fa3ecce56117f0b13af386be572719a86c3 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -@@ -75,11 +75,11 @@ public class AcquirePoi { +@@ -71,11 +71,11 @@ public class AcquirePoi { return true; } }; @@ -862,16 +862,17 @@ index 05d529a74fa3412b4b07bcf0d469118c38862279..a46aa33d3013003a899659c4bd039d12 if (path != null && path.canReach()) { BlockPos blockPos = path.getTarget(); diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java -index 1fb3059d96910c095c881e1f89d52dbbf82b8c1c..700c16020a5c40f49bc1c74c47cb4b52a4021bbb 100644 +index d5a549f08b98c80a5cf0eef02cb8a389c32dfecb..92731b6b593289e9f583c9b705b219e81fcd8e73 100644 --- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java +++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java -@@ -53,10 +53,12 @@ public class NearestBedSensor extends Sensor<Mob> { +@@ -53,11 +53,12 @@ public class NearestBedSensor extends Sensor<Mob> { return true; } }; -- Set<Pair<Holder<PoiType>, BlockPos>> set = poiManager.findAllWithType(holder -> { -- return holder.is(PoiTypes.HOME); -- }, predicate, entity.blockPosition(), 48, PoiManager.Occupancy.ANY).collect(Collectors.toSet()); +- Set<Pair<Holder<PoiType>, BlockPos>> set = poiManager.findAllWithType( +- holder -> holder.is(PoiTypes.HOME), predicate, entity.blockPosition(), 48, PoiManager.Occupancy.ANY +- ) +- .collect(Collectors.toSet()); - Path path = AcquirePoi.findPathToPois(entity, set); + // Paper start - optimise POI access + java.util.List<Pair<Holder<PoiType>, BlockPos>> poiposes = new java.util.ArrayList<>(); @@ -883,10 +884,10 @@ index 1fb3059d96910c095c881e1f89d52dbbf82b8c1c..700c16020a5c40f49bc1c74c47cb4b52 BlockPos blockPos = path.getTarget(); Optional<Holder<PoiType>> optional = poiManager.getType(blockPos); 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 c80e75ba66bcd5957d6360a8d5de4f052dbf87d7..bdd24b0978fac23d3ea04c76caa5061434a5883e 100644 +index c07cc1bf3b98525d72924edee4233364fd8174d0..3ac271b10c63fae4afcadc59140c0ad5b794f129 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 -@@ -135,40 +135,45 @@ public class PoiManager extends SectionStorage<PoiSection> { +@@ -124,40 +124,48 @@ public class PoiManager extends SectionStorage<PoiSection> { public Optional<BlockPos> find( Predicate<Holder<PoiType>> typePredicate, Predicate<BlockPos> posPredicate, BlockPos pos, int radius, PoiManager.Occupancy occupationStatus ) { @@ -898,9 +899,9 @@ index c80e75ba66bcd5957d6360a8d5de4f052dbf87d7..bdd24b0978fac23d3ea04c76caa50614 } public Optional<BlockPos> findClosest(Predicate<Holder<PoiType>> typePredicate, BlockPos pos, int radius, PoiManager.Occupancy occupationStatus) { -- return this.getInRange(typePredicate, pos, radius, occupationStatus).map(PoiRecord::getPos).min(Comparator.comparingDouble(blockPos2 -> { -- return blockPos2.distSqr(pos); -- })); +- return this.getInRange(typePredicate, pos, radius, occupationStatus) +- .map(PoiRecord::getPos) +- .min(Comparator.comparingDouble(blockPos2 -> blockPos2.distSqr(pos))); + // Paper start - re-route to faster logic + BlockPos ret = io.papermc.paper.util.PoiAccess.findClosestPoiDataPosition(this, typePredicate, null, pos, radius, radius * radius, occupationStatus, false); + return Optional.ofNullable(ret); @@ -910,11 +911,9 @@ index c80e75ba66bcd5957d6360a8d5de4f052dbf87d7..bdd24b0978fac23d3ea04c76caa50614 public Optional<Pair<Holder<PoiType>, BlockPos>> findClosestWithType( Predicate<Holder<PoiType>> typePredicate, BlockPos pos, int radius, PoiManager.Occupancy occupationStatus ) { -- return this.getInRange(typePredicate, pos, radius, occupationStatus).min(Comparator.comparingDouble(poi -> { -- return poi.getPos().distSqr(pos); -- })).map(poi -> { -- return Pair.of(poi.getPoiType(), poi.getPos()); -- }); +- return this.getInRange(typePredicate, pos, radius, occupationStatus) +- .min(Comparator.comparingDouble(poi -> poi.getPos().distSqr(pos))) +- .map(poi -> Pair.of(poi.getPoiType(), poi.getPos())); + // Paper start - re-route to faster logic + return Optional.ofNullable(io.papermc.paper.util.PoiAccess.findClosestPoiDataTypeAndPosition( + this, typePredicate, null, pos, radius, radius * radius, occupationStatus, false @@ -928,9 +927,7 @@ index c80e75ba66bcd5957d6360a8d5de4f052dbf87d7..bdd24b0978fac23d3ea04c76caa50614 - return this.getInRange(typePredicate, pos, radius, occupationStatus) - .map(PoiRecord::getPos) - .filter(posPredicate) -- .min(Comparator.comparingDouble(blockPos2 -> { -- return blockPos2.distSqr(pos); -- })); +- .min(Comparator.comparingDouble(blockPos2 -> blockPos2.distSqr(pos))); + // Paper start - re-route to faster logic + BlockPos ret = io.papermc.paper.util.PoiAccess.findClosestPoiDataPosition(this, typePredicate, posPredicate, pos, radius, radius * radius, occupationStatus, false); + return Optional.ofNullable(ret); @@ -938,26 +935,31 @@ index c80e75ba66bcd5957d6360a8d5de4f052dbf87d7..bdd24b0978fac23d3ea04c76caa50614 } public Optional<BlockPos> take(Predicate<Holder<PoiType>> typePredicate, BiPredicate<Holder<PoiType>, BlockPos> biPredicate, BlockPos pos, int radius) { -- return this.getInRange(typePredicate, pos, radius, PoiManager.Occupancy.HAS_SPACE).filter(poi -> { -- return biPredicate.test(poi.getPoiType(), poi.getPos()); -- }).findFirst().map(poi -> { +- return this.getInRange(typePredicate, pos, radius, PoiManager.Occupancy.HAS_SPACE) +- .filter(poi -> biPredicate.test(poi.getPoiType(), poi.getPos())) +- .findFirst() +- .map(poi -> { +- poi.acquireTicket(); +- return poi.getPos(); +- }); + // Paper start - re-route to faster logic + final @javax.annotation.Nullable PoiRecord closest = io.papermc.paper.util.PoiAccess.findClosestPoiDataRecord( + this, typePredicate, biPredicate, pos, radius, radius * radius, Occupancy.HAS_SPACE, false + ); + return Optional.ofNullable(closest).map(poi -> { + // Paper end - re-route to faster logic - poi.acquireTicket(); - return poi.getPos(); - }); -@@ -182,10 +187,21 @@ public class PoiManager extends SectionStorage<PoiSection> { ++ poi.acquireTicket(); ++ return poi.getPos(); ++ }); + } + + public Optional<BlockPos> getRandom( +@@ -168,8 +176,21 @@ public class PoiManager extends SectionStorage<PoiSection> { int radius, RandomSource random ) { - List<PoiRecord> list = Util.toShuffledList(this.getInRange(typePredicate, pos, radius, occupationStatus), random); -- return list.stream().filter(poi -> { -- return positionPredicate.test(poi.getPos()); -- }).findFirst().map(PoiRecord::getPos); +- return list.stream().filter(poi -> positionPredicate.test(poi.getPos())).findFirst().map(PoiRecord::getPos); + // Paper start - re-route to faster logic + List<PoiRecord> list = new java.util.ArrayList<>(); + io.papermc.paper.util.PoiAccess.findAnyPoiRecords( @@ -977,7 +979,7 @@ index c80e75ba66bcd5957d6360a8d5de4f052dbf87d7..bdd24b0978fac23d3ea04c76caa50614 public boolean release(BlockPos pos) { 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 dbdcc8c842d427e1b0ce178a5d3cad23c4ccaf5e..2fdde213fde2f7f509b339a2041d582fc0d876e8 100644 +index f7d69dd83aad8e0ec1497441c61188bcf230865f..94404922304cfe23ea5fe8524387bc9b675cbc78 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 @@ -26,7 +26,7 @@ import org.slf4j.Logger; @@ -990,7 +992,7 @@ index dbdcc8c842d427e1b0ce178a5d3cad23c4ccaf5e..2fdde213fde2f7f509b339a2041d582f private boolean isValid; public final Optional<PoiSection> noAllocateOptional = Optional.of(this); // Paper - rewrite chunk system 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 05c71f8468a3ea075c45465515fd1f075d6ce313..9fb15c86d0fc0f6463454ac8d6dcebce6157d993 100644 +index bc6043a21227ce8c9c3879bc9c93c3803f79857b..4ac5024936987c15f927e3148af4bfa57228ad1e 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 @@ -79,11 +79,11 @@ public class SectionStorage<R> extends RegionFileStorage implements AutoCloseabl diff --git a/patches/server/1009-Custom-table-implementation-for-blockstate-state-loo.patch b/patches/server/1009-Custom-table-implementation-for-blockstate-state-loo.patch index 66c7db3ba9..712f8d62d7 100644 --- a/patches/server/1009-Custom-table-implementation-for-blockstate-state-loo.patch +++ b/patches/server/1009-Custom-table-implementation-for-blockstate-state-loo.patch @@ -173,7 +173,7 @@ index 0000000000000000000000000000000000000000..57d0cd3ad6f972e986c72a57f1a6e360 + } +} diff --git a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java -index 23155d3181f78b5eec1412828441c54826ea8ca5..32df70def3551adc759aec22803fb4195d48c843 100644 +index e3b74a69699a79522b91a144206dc9fa7a977600..01be7f911c7b013f923f6a3099ca9d7eaabd2547 100644 --- a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java +++ b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java @@ -42,11 +42,13 @@ public abstract class StateHolder<O, S> { @@ -264,7 +264,7 @@ index b63116b333b6e06494091a82588acfb639bddb71..ff5fd91257c4554c523682009efe1db8 super(name, Boolean.class); } diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java b/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java -index cd7efe4a09e114ab68a90365a6f5363a5c4c17a2..19337b8adefdec32626f5ed788a714a24f39dc35 100644 +index 3097298fe356df98967cf4bdeaaede69dfe8a441..498c5abe0a9d024d77029719c621c1c8485791f3 100644 --- a/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java +++ b/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java @@ -15,6 +15,15 @@ public class EnumProperty<T extends Enum<T> & StringRepresentable> extends Prope @@ -320,11 +320,11 @@ index 3a850321a4bcc68058483b5fd53e829c425a68af..977504f2641d0133a572b0d5de85d058 super(name, Integer.class); if (min < 0) { diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/Property.java b/src/main/java/net/minecraft/world/level/block/state/properties/Property.java -index bad6c58b0adc1ca630d3e943a86a2bc66dd94c9f..129bac4e41a6d50532709fadd3b0d1db8aa85e4d 100644 +index 9055f15af0cae55effa6942913a9d7edf3857e07..b9493e3762410aca8e683c32b5aef187c0bee082 100644 --- a/src/main/java/net/minecraft/world/level/block/state/properties/Property.java +++ b/src/main/java/net/minecraft/world/level/block/state/properties/Property.java @@ -24,6 +24,17 @@ public abstract class Property<T extends Comparable<T>> { - }, this::getName); + ); private final Codec<Property.Value<T>> valueCodec = this.codec.xmap(this::value, Property.Value::value); + // Paper start - optimise iblockdata state lookup diff --git a/patches/server/1011-Optimise-random-block-ticking.patch b/patches/server/1011-Optimise-random-block-ticking.patch index 8becffdb12..7bda9d54c9 100644 --- a/patches/server/1011-Optimise-random-block-ticking.patch +++ b/patches/server/1011-Optimise-random-block-ticking.patch @@ -436,10 +436,10 @@ index 8852263cb6faec1b68326145aa30e5cd36d066e7..eb05c01e85825cbd5b7cf43bc6d261db public PalettedContainer<BlockState> getStates() { diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java -index 5418261725f7a0dc9a0e8295fe511f69b558a6cd..07137251105f7023936a67038d03ff4f24a9f19b 100644 +index d473637a705c1f11079fff08e334545779a99a84..adfbdca12fbdee2602feb0158674166d5256e49e 100644 --- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java -@@ -404,6 +404,14 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer +@@ -381,6 +381,14 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer } } diff --git a/patches/server/1012-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch b/patches/server/1012-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch index 2113dfcb95..82da6f079e 100644 --- a/patches/server/1012-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch +++ b/patches/server/1012-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch @@ -763,7 +763,7 @@ index 42d37bee3a459adcd46408596ccf93abbcff51fe..fe312b1aef579cb4bf81bdd967cf72ff } diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileVersion.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileVersion.java -index 4bfd16b73163fb502cb8716d3ef43f9fa1c3d184..d38ad94312bbb1b41d2ab71fd981649a69fe4929 100644 +index 581912e1315a4a8b46042a27df54826fa63e9c75..ee635da4ecb47fe496ed8ba1b497b5a3e094cbd3 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileVersion.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileVersion.java @@ -14,7 +14,7 @@ import javax.annotation.Nullable; @@ -771,7 +771,7 @@ index 4bfd16b73163fb502cb8716d3ef43f9fa1c3d184..d38ad94312bbb1b41d2ab71fd981649a public class RegionFileVersion { - private static final Int2ObjectMap<RegionFileVersion> VERSIONS = new Int2ObjectOpenHashMap<>(); -+ public static final Int2ObjectMap<RegionFileVersion> VERSIONS = new Int2ObjectOpenHashMap<>(); // Paper - private -> public - public static final RegionFileVersion VERSION_GZIP = register(new RegionFileVersion(1, stream -> { - return new FastBufferedInputStream(new GZIPInputStream(stream)); - }, stream -> { ++ public static final Int2ObjectMap<RegionFileVersion> VERSIONS = new Int2ObjectOpenHashMap<>(); // Paper - private -> public + public static final RegionFileVersion VERSION_GZIP = register( + new RegionFileVersion( + 1, stream -> new FastBufferedInputStream(new GZIPInputStream(stream)), stream -> new BufferedOutputStream(new GZIPOutputStream(stream)) diff --git a/patches/server/1015-Collision-optimisations.patch b/patches/server/1015-Collision-optimisations.patch index 2b153fafde..d418ac9c7b 100644 --- a/patches/server/1015-Collision-optimisations.patch +++ b/patches/server/1015-Collision-optimisations.patch @@ -2153,7 +2153,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 83a2b952df749b7aaab439db4ec2d38bc4f5b11c..6bcf4d8e5c69dbc655d522abadc7f14ee7b21d71 100644 +index 75694cfd7d8adde6b9246518c20fe75774297a57..84a760fdc50bdafc9150f977e9c5d557a30ee220 100644 --- a/src/main/java/net/minecraft/core/Direction.java +++ b/src/main/java/net/minecraft/core/Direction.java @@ -53,6 +53,21 @@ public enum Direction implements StringRepresentable { @@ -2494,7 +2494,7 @@ index 86a4f30c8784c602436ecf1c78efb0bdca4b7089..b0bea28e9261767c60d30fb0e76f4f3a 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 a4200e1992207e7665673c2acdb45facfd0bc676..4e32426a3d261f77d6066bb5256596a4ae0de0a3 100644 +index 1ad0c976c6e2d6d31397dff850a9de7c16d16fba..dc877fe2e3c53b353baa59c125232e425fee67d7 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 { @@ -2511,7 +2511,7 @@ index a4200e1992207e7665673c2acdb45facfd0bc676..4e32426a3d261f77d6066bb5256596a4 return this.noCollision(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 eba4663a6928989bfa14d57303d77fdabea31481..44cfa3821774f22ac05aa679fdee34d8d68b7d60 100644 +index 9a28912f52824acdc80a62243b136e6f365bf567..21843501355a0c0c8d594e3e5312e97861c9a777 100644 --- a/src/main/java/net/minecraft/world/level/EntityGetter.java +++ b/src/main/java/net/minecraft/world/level/EntityGetter.java @@ -46,20 +46,36 @@ public interface EntityGetter { @@ -2594,10 +2594,10 @@ index eba4663a6928989bfa14d57303d77fdabea31481..44cfa3821774f22ac05aa679fdee34d8 - } + entities = this.getHardCollidingEntities(entity, box, null); + } ++ ++ final List<VoxelShape> ret = new java.util.ArrayList<>(Math.min(25, entities.size())); - return builder.build(); -+ final List<VoxelShape> ret = new java.util.ArrayList<>(Math.min(25, entities.size())); -+ + for (int i = 0, len = entities.size(); i < len; ++i) { + final Entity otherEntity = entities.get(i); + @@ -3537,7 +3537,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 d88f69275ffee4669dd6d31e2669c41f66a1919d..ce8fff01475bdfe9094c237fc5f294f3958edb42 100644 +index 86df4ef44d0a5107ee929dfd40d8ccb0779e8bfc..fbf1a559aefe444410b63a773374e011e4964e16 100644 --- a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java +++ b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java @@ -16,9 +16,15 @@ public final class Shapes { @@ -3796,10 +3796,6 @@ index d88f69275ffee4669dd6d31e2669c41f66a1919d..ce8fff01475bdfe9094c237fc5f294f3 + // secondly, use our cache to retrieve sliced shape + final VoxelShape newFirst = shape.getFaceShapeClamped(direction); + if (newFirst.isEmpty()) { -+ return false; -+ } -+ final VoxelShape newSecond = neighbor.getFaceShapeClamped(direction.getOpposite()); -+ if (newSecond.isEmpty()) { return false; - } else { - Direction.Axis axis = direction.getAxis(); @@ -3811,6 +3807,10 @@ index d88f69275ffee4669dd6d31e2669c41f66a1919d..ce8fff01475bdfe9094c237fc5f294f3 - && DoubleMath.fuzzyEquals(voxelShape2.min(axis), 0.0, 1.0E-7) - && !joinIsNotEmpty(new SliceShape(voxelShape, axis, voxelShape.shape.getSize(axis) - 1), new SliceShape(voxelShape2, axis, 0), booleanOp); } ++ final VoxelShape newSecond = neighbor.getFaceShapeClamped(direction.getOpposite()); ++ if (newSecond.isEmpty()) { ++ return false; ++ } + + return !joinIsNotEmpty(newFirst, newSecond, BooleanOp.ONLY_FIRST); + // Paper end - optimise collisions @@ -3953,7 +3953,7 @@ index 53aa193f33a1a15376a59b8d6dd8cbc6cbec168b..a745ff8d115e1d0da6138e4f06726e07 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 80899dc599f05198cc58524355b66791dc418141..6ed187fa64dcbd01927c5180739dc8aaaf1fbe72 100644 +index 2936c56e5690b42518010698e5177755422e4c5d..e6b17f32f2b6930739a98c6139442383c1847add 100644 --- a/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java +++ b/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java @@ -16,37 +16,438 @@ import net.minecraft.world.phys.BlockHitResult; @@ -4379,11 +4379,11 @@ index 80899dc599f05198cc58524355b66791dc418141..6ed187fa64dcbd01927c5180739dc8aa + // Paper start - optimise collisions + if (this.isEmpty) { + throw Util.pauseInIde(new UnsupportedOperationException("No bounds for empty shape.")); - } ++ } + AABB cached = this.cachedBounds; + if (cached != null) { + return cached; -+ } + } + + final io.papermc.paper.util.collisions.CachedShapeData shapeData = this.cachedShapeData; + @@ -4412,23 +4412,23 @@ index 80899dc599f05198cc58524355b66791dc418141..6ed187fa64dcbd01927c5180739dc8aa } public VoxelShape singleEncompassing() { -@@ -69,26 +470,106 @@ public abstract class VoxelShape { +@@ -69,28 +470,106 @@ public abstract class VoxelShape { protected abstract DoubleList getCoords(Direction.Axis axis); public boolean isEmpty() { - return this.shape.isEmpty(); + return this.isEmpty; // Paper - optimise collisions - } - ++ } ++ + // Paper start - optimise collisions + private static DoubleList offsetList(final DoubleList src, final double by) { + if (src instanceof OffsetDoubleList offsetDoubleList) { + return new OffsetDoubleList(offsetDoubleList.delegate, by + offsetDoubleList.offset); + } + return new OffsetDoubleList(src, by); -+ } + } + // Paper end - optimise collisions -+ + public VoxelShape move(double x, double y, double z) { - return (VoxelShape)(this.isEmpty() - ? Shapes.empty() @@ -4460,9 +4460,11 @@ index 80899dc599f05198cc58524355b66791dc418141..6ed187fa64dcbd01927c5180739dc8aa public VoxelShape optimize() { - VoxelShape[] voxelShapes = new VoxelShape[]{Shapes.empty()}; -- this.forAllBoxes((minX, minY, minZ, maxX, maxY, maxZ) -> { -- voxelShapes[0] = Shapes.joinUnoptimized(voxelShapes[0], Shapes.box(minX, minY, minZ, maxX, maxY, maxZ), BooleanOp.OR); -- }); +- this.forAllBoxes( +- (minX, minY, minZ, maxX, maxY, maxZ) -> voxelShapes[0] = Shapes.joinUnoptimized( +- voxelShapes[0], Shapes.box(minX, minY, minZ, maxX, maxY, maxZ), BooleanOp.OR +- ) +- ); - return voxelShapes[0]; + // Paper start - optimise collisions + // Optimise merge strategy to increase the number of simple joins, and additionally forward the toAabbs cache @@ -4532,7 +4534,7 @@ index 80899dc599f05198cc58524355b66791dc418141..6ed187fa64dcbd01927c5180739dc8aa } public void forAllEdges(Shapes.DoubleLineConsumer consumer) { -@@ -128,12 +609,43 @@ public abstract class VoxelShape { +@@ -126,10 +605,43 @@ public abstract class VoxelShape { ); } @@ -4556,9 +4558,7 @@ index 80899dc599f05198cc58524355b66791dc418141..6ed187fa64dcbd01927c5180739dc8aa + public List<AABB> toAabbs() { - List<AABB> list = Lists.newArrayList(); -- this.forAllBoxes((x1, y1, z1, x2, y2, z2) -> { -- list.add(new AABB(x1, y1, z1, x2, y2, z2)); -- }); +- this.forAllBoxes((x1, y1, z1, x2, y2, z2) -> list.add(new AABB(x1, y1, z1, x2, y2, z2))); - return list; + // Paper start - optimise collisions + io.papermc.paper.util.collisions.CachedToAABBs cachedToAABBs = this.cachedToAABBs; @@ -4581,8 +4581,8 @@ index 80899dc599f05198cc58524355b66791dc418141..6ed187fa64dcbd01927c5180739dc8aa } public double min(Direction.Axis axis, double from, double to) { -@@ -160,43 +672,85 @@ public abstract class VoxelShape { - }) - 1; +@@ -154,43 +666,85 @@ public abstract class VoxelShape { + return Mth.binarySearch(0, this.shape.getSize(axis) + 1, i -> coord < this.get(axis, i)) - 1; } + // Paper start - optimise collisions @@ -4694,7 +4694,7 @@ index 80899dc599f05198cc58524355b66791dc418141..6ed187fa64dcbd01927c5180739dc8aa } public VoxelShape getFaceShape(Direction facing) { -@@ -233,7 +787,28 @@ public abstract class VoxelShape { +@@ -227,7 +781,28 @@ public abstract class VoxelShape { } public double collide(Direction.Axis axis, AABB box, double maxDist) { diff --git a/patches/server/1018-Fix-entity-type-tags-suggestions-in-selectors.patch b/patches/server/1018-Fix-entity-type-tags-suggestions-in-selectors.patch index 1a2f0de3d7..9b422d15a5 100644 --- a/patches/server/1018-Fix-entity-type-tags-suggestions-in-selectors.patch +++ b/patches/server/1018-Fix-entity-type-tags-suggestions-in-selectors.patch @@ -118,13 +118,13 @@ index 3d897ec6920eff6176ddac9f0442a997b9ef14fd..abaf1ea340c69c8bee80e64567b44b5c this.level = MinMaxBounds.Ints.ANY; this.rotX = WrappedMinMaxBounds.ANY; diff --git a/src/main/java/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java b/src/main/java/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java -index cb4c218eb06ada02824a0574b077b3f3f65e063b..2d6f92d4967fba88472057cfea020ac64ca1e9c8 100644 +index 53f77dbd5be1297d56d25c12e07c3dd65d6c4cd3..2cf42c9d33ce545a48e0080b46758c1bc17fd665 100644 --- a/src/main/java/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java +++ b/src/main/java/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java -@@ -75,6 +75,19 @@ public class EntitySelectorOptions { - public static final DynamicCommandExceptionType ERROR_ENTITY_TYPE_INVALID = new DynamicCommandExceptionType(entity -> { - return Component.translatableEscape("argument.entity.options.type.invalid", entity); - }); +@@ -75,6 +75,20 @@ public class EntitySelectorOptions { + public static final DynamicCommandExceptionType ERROR_ENTITY_TYPE_INVALID = new DynamicCommandExceptionType( + entity -> Component.translatableEscape("argument.entity.options.type.invalid", entity) + ); + // Paper start - tell clients to ask server for suggestions for EntityArguments + public static final DynamicCommandExceptionType ERROR_ENTITY_TAG_INVALID = new DynamicCommandExceptionType((object) -> { + return io.papermc.paper.adventure.PaperAdventure @@ -138,10 +138,20 @@ index cb4c218eb06ada02824a0574b077b3f3f65e063b..2d6f92d4967fba88472057cfea020ac6 + ); + }); + // Paper end - tell clients to ask server for suggestions for EntityArguments ++ private static void register(String id, EntitySelectorOptions.Modifier handler, Predicate<EntitySelectorParser> condition, Component description) { OPTIONS.put(id, new EntitySelectorOptions.Option(handler, condition, description)); -@@ -301,7 +314,7 @@ public class EntitySelectorOptions { +@@ -176,7 +190,7 @@ public class EntitySelectorOptions { + reader.setSuggestions( + (builder, consumer) -> SharedSuggestionProvider.suggest(Arrays.asList("nearest", "furthest", "random", "arbitrary"), builder) + ); +- ++ + reader.setOrder(switch (string) { + case "nearest" -> EntitySelectorParser.ORDER_NEAREST; + case "furthest" -> EntitySelectorParser.ORDER_FURTHEST; +@@ -280,7 +294,7 @@ public class EntitySelectorOptions { BuiltInRegistries.ENTITY_TYPE.getTagNames().map(TagKey::location), builder, String.valueOf('#') ); } @@ -150,7 +160,7 @@ index cb4c218eb06ada02824a0574b077b3f3f65e063b..2d6f92d4967fba88472057cfea020ac6 return builder.buildFuture(); } ); -@@ -314,9 +327,15 @@ public class EntitySelectorOptions { +@@ -293,9 +307,15 @@ public class EntitySelectorOptions { if (bl) { reader.setTypeLimitedInversely(); } @@ -164,15 +174,6 @@ index cb4c218eb06ada02824a0574b077b3f3f65e063b..2d6f92d4967fba88472057cfea020ac6 + throw ERROR_ENTITY_TAG_INVALID.createWithContext(reader.getReader(), tagKey); + } + // Paper end - tell clients to ask server for suggestions for EntityArguments - reader.addPredicate(entity -> { - return entity.getType().is(tagKey) != bl; - }); -@@ -329,7 +348,7 @@ public class EntitySelectorOptions { - if (Objects.equals(EntityType.PLAYER, entityType) && !bl) { - reader.setIncludesEntities(false); - } -- -+ - reader.addPredicate(entity -> { - return Objects.equals(entityType, entity.getType()) != bl; - }); + reader.addPredicate(entity -> entity.getType().is(tagKey) != bl); + } else { + ResourceLocation resourceLocation = ResourceLocation.read(reader.getReader()); diff --git a/patches/server/1027-Optimise-nearby-player-retrieval.patch b/patches/server/1027-Optimise-nearby-player-retrieval.patch index 5607141705..06b8d42fec 100644 --- a/patches/server/1027-Optimise-nearby-player-retrieval.patch +++ b/patches/server/1027-Optimise-nearby-player-retrieval.patch @@ -128,16 +128,19 @@ index 8a5abc320137d045acba0c87cef9f2912d78b6fb..6907d1be36fbdf0856c0e11983218d2f // Add env and gen to constructor, IWorldDataServer -> WorldDataServer public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java -index 3e24da56fc57afa5d8fdcb3c32c60299272fa43e..65cd42ce9f553e0aa5bf248bdbf902f9d1f55460 100644 +index 2e887e426dcd79e2dda401f127d0e01ca537e80e..65cd42ce9f553e0aa5bf248bdbf902f9d1f55460 100644 --- a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java +++ b/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java -@@ -21,18 +21,50 @@ public class PlayerSensor extends Sensor<LivingEntity> { +@@ -21,17 +21,50 @@ public class PlayerSensor extends Sensor<LivingEntity> { @Override protected void doTick(ServerLevel world, LivingEntity entity) { -- List<Player> list = world.players().stream().filter(EntitySelector.NO_SPECTATORS).filter(player -> { -- return entity.closerThan(player, 16.0); -- }).sorted(Comparator.comparingDouble(entity::distanceToSqr)).collect(Collectors.toList()); +- List<Player> list = world.players() +- .stream() +- .filter(EntitySelector.NO_SPECTATORS) +- .filter(player -> entity.closerThan(player, 16.0)) +- .sorted(Comparator.comparingDouble(entity::distanceToSqr)) +- .collect(Collectors.toList()); + // Paper start - Perf: optimise nearby player retrieval & remove streams from hot code + io.papermc.paper.util.player.NearbyPlayers nearbyPlayers = world.chunkSource.chunkMap.getNearbyPlayers(); + net.minecraft.world.phys.Vec3 entityPos = entity.position(); @@ -164,13 +167,9 @@ index 3e24da56fc57afa5d8fdcb3c32c60299272fa43e..65cd42ce9f553e0aa5bf248bdbf902f9 + players.sort(Comparator.comparingDouble(entity::distanceToSqr)); Brain<?> brain = entity.getBrain(); - brain.setMemory(MemoryModuleType.NEAREST_PLAYERS, list); -- List<Player> list2 = list.stream().filter(player -> { -- return isEntityTargetable(entity, player); -- }).collect(Collectors.toList()); +- List<Player> list2 = list.stream().filter(player -> isEntityTargetable(entity, player)).collect(Collectors.toList()); - brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_PLAYER, list2.isEmpty() ? null : list2.get(0)); -- Optional<Player> optional = list2.stream().filter(player -> { -- return isEntityAttackable(entity, player); -- }).findFirst(); +- Optional<Player> optional = list2.stream().filter(player -> isEntityAttackable(entity, player)).findFirst(); - brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, optional); + + brain.setMemory(MemoryModuleType.NEAREST_PLAYERS, players); @@ -208,10 +207,10 @@ index aecb0ad814586bfc5e56755ee14379a69388b38c..d2f0c3b26d4beedb49d86e0242d84359 private boolean testInvisible = true; @Nullable diff --git a/src/main/java/net/minecraft/world/level/EntityGetter.java b/src/main/java/net/minecraft/world/level/EntityGetter.java -index 44cfa3821774f22ac05aa679fdee34d8d68b7d60..e6f7081450e129a72ac0b5031b474d14328a6d42 100644 +index 21843501355a0c0c8d594e3e5312e97861c9a777..ea0aee88c7d901034427db201c1b2430f8a1d522 100644 --- a/src/main/java/net/minecraft/world/level/EntityGetter.java +++ b/src/main/java/net/minecraft/world/level/EntityGetter.java -@@ -235,9 +235,13 @@ public interface EntityGetter { +@@ -233,9 +233,13 @@ public interface EntityGetter { T livingEntity = null; for (T livingEntity2 : entityList) { diff --git a/patches/server/1034-Improve-tag-parser-handling.patch b/patches/server/1034-Improve-tag-parser-handling.patch index b7c0892a46..4ce624ebc9 100644 --- a/patches/server/1034-Improve-tag-parser-handling.patch +++ b/patches/server/1034-Improve-tag-parser-handling.patch @@ -54,7 +54,7 @@ index 0000000000000000000000000000000000000000..a375ad4ba9db990b24a2b9ff366fcba6 + } +} diff --git a/src/main/java/net/minecraft/nbt/TagParser.java b/src/main/java/net/minecraft/nbt/TagParser.java -index c0a06ad138aede0bfd8f3a61f08d906ddda4780b..284a0904963eebc7284d8da601b00e4b4b2574cc 100644 +index 733303e860560f4c93372326ab4efdaf21e5ace7..39b5850c4be7e61de2a8bcfe781504aa9784674f 100644 --- a/src/main/java/net/minecraft/nbt/TagParser.java +++ b/src/main/java/net/minecraft/nbt/TagParser.java @@ -48,6 +48,7 @@ public class TagParser { @@ -125,10 +125,10 @@ index c0a06ad138aede0bfd8f3a61f08d906ddda4780b..284a0904963eebc7284d8da601b00e4b + } } diff --git a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java b/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java -index 18ff39d166521355f1e7d39c1dbad3becb136753..92aeffbab3513e2e1d5ec15dc7fff04bbd445a2a 100644 +index 65debad7aa7ffb1b0b19f89713ff394e8c9d245e..18e53db59082bae94922edc4baa812aa6f089576 100644 --- a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java +++ b/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java -@@ -190,6 +190,15 @@ public class TranslatableContents implements ComponentContents { +@@ -181,6 +181,15 @@ public class TranslatableContents implements ComponentContents { @Override public <T> Optional<T> visit(FormattedText.ContentConsumer<T> visitor) { @@ -144,7 +144,7 @@ index 18ff39d166521355f1e7d39c1dbad3becb136753..92aeffbab3513e2e1d5ec15dc7fff04b this.decompose(); for (FormattedText formattedText : this.decomposedParts) { -@@ -201,6 +210,25 @@ public class TranslatableContents implements ComponentContents { +@@ -192,6 +201,25 @@ public class TranslatableContents implements ComponentContents { return Optional.empty(); } |