diff --git a/build-data/mappings-patch.tiny b/build-data/mappings-patch.tiny index 4dddff41fc..3e893934c8 100644 --- a/build-data/mappings-patch.tiny +++ b/build-data/mappings-patch.tiny @@ -109,29 +109,3 @@ c net/minecraft/world/level/saveddata/maps/WorldMap$WorldMapHumanTracker net/min # CraftBukkit adds a level resource key to LevelStorageSource#createAccess c net/minecraft/world/level/storage/Convertable net/minecraft/world/level/storage/LevelStorageSource m (Ljava/lang/String;Lnet/minecraft/resources/ResourceKey;)Lnet/minecraft/world/level/storage/Convertable$ConversionSession; c createAccess - -# Missed mappings - these should work as they are unmodified by CraftBukkit but don't for some reason -c net/minecraft/network/NetworkManager net/minecraft/network/Connection - m (Lnet/minecraft/network/protocol/Packet;Lio/netty/util/concurrent/GenericFutureListener;Lnet/minecraft/network/EnumProtocol;Lnet/minecraft/network/EnumProtocol;)V a doSendPacket - -c net/minecraft/server/gui/ServerGUI net/minecraft/server/gui/MinecraftServerGui - m (Ljavax/swing/JTextArea;Ljavax/swing/JScrollPane;Ljava/lang/String;)V a print - -c net/minecraft/server/level/PlayerChunk net/minecraft/server/level/ChunkHolder - m (Lnet/minecraft/world/level/World;Lnet/minecraft/core/BlockPosition;Lnet/minecraft/world/level/block/state/IBlockData;)V a broadcastBlockEntityIfNeeded - -c net/minecraft/server/level/PlayerChunkMap net/minecraft/server/level/ChunkMap - m (Lnet/minecraft/world/level/chunk/ChunkStatus;I)Lnet/minecraft/world/level/chunk/ChunkStatus; a getDependencyStatus - -c net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet net/minecraft/world/entity/ai/behavior/StartAttacking - m (Lnet/minecraft/world/entity/EntityInsentient;Lnet/minecraft/world/entity/EntityLiving;)V a setAttackTarget - -c net/minecraft/world/entity/ai/behavior/BehaviorMakeLove net/minecraft/world/entity/ai/behavior/VillagerMakeLove - m (Lnet/minecraft/world/entity/npc/EntityVillager;Lnet/minecraft/core/BlockPosition;)Z a canReach - -c net/minecraft/world/level/block/MultifaceBlock net/minecraft/world/level/block/MultifaceBlock - m (Lnet/minecraft/world/level/block/state/IBlockData;Lnet/minecraft/world/level/IBlockAccess;Lnet/minecraft/core/BlockPosition;Lnet/minecraft/core/EnumDirection;)Lnet/minecraft/world/level/block/state/IBlockData; c getStateForPlacement - -c net/minecraft/server/players/UserCache net/minecraft/server/players/GameProfileCache - m (Ljava/lang/String;)Ljava/util/Optional; getProfile get - p 0 name diff --git a/build-data/reobf-mappings-patch.tiny b/build-data/reobf-mappings-patch.tiny index 41b3374398..945731b50d 100644 --- a/build-data/reobf-mappings-patch.tiny +++ b/build-data/reobf-mappings-patch.tiny @@ -22,7 +22,3 @@ c net/minecraft/world/level/chunk/LevelChunk net/minecraft/world/level/chunk/Chu # Paper changes type c net/minecraft/core/MappedRegistry net/minecraft/core/RegistryMaterials f Lit/unimi/dsi/fastutil/objects/Reference2IntOpenHashMap; toId bw - -# Remove streams from Mob AI System changes type from EnumSet to com.destroystokyo.paper.util.set.OptimizedSmallEnumSet -c net/minecraft/world/entity/ai/goal/Goal net/minecraft/world/entity/ai/goal/PathfinderGoal - m ()Lcom/destroystokyo/paper/util/set/OptimizedSmallEnumSet; getFlags i diff --git a/build.gradle.kts b/build.gradle.kts index 9a44dad124..9ca58a4b4b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,7 @@ plugins { java `maven-publish` id("com.github.johnrengelman.shadow") version "7.1.0" apply false - id("io.papermc.paperweight.core") version "1.1.14" + id("io.papermc.paperweight.core") version "1.2.0" } allprojects { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ffed3a254e..e750102e09 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index 5d8e23a1b7..64db649dbd 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -1403,21 +1403,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - // CraftBukkit start + // CraftBukkit start // Paper start - Adventure Player player = this.player.getBukkitEntity(); - int x = packetplayinupdatesign.getPos().getX(); - int y = packetplayinupdatesign.getPos().getY(); - int z = packetplayinupdatesign.getPos().getZ(); + int x = packet.getPos().getX(); + int y = packet.getPos().getY(); + int z = packet.getPos().getZ(); - String[] lines = new String[4]; + List lines = new java.util.ArrayList<>(); - for (int i = 0; i < list.size(); ++i) { -- TextFilter.FilteredText itextfilter_a = (TextFilter.FilteredText) list.get(i); -- + for (int i = 0; i < signText.size(); ++i) { +- TextFilter.FilteredText itextfilter_a = (TextFilter.FilteredText) signText.get(i); ++ TextFilter.FilteredText currentLine = signText.get(i); + if (this.player.isTextFilteringEnabled()) { - lines[i] = ChatFormatting.stripFormatting(new TextComponent(ChatFormatting.stripFormatting(itextfilter_a.getFiltered())).getString()); -+ lines.add(net.kyori.adventure.text.Component.text(list.get(i).getFiltered())); ++ lines.add(net.kyori.adventure.text.Component.text(currentLine.getFiltered())); } else { - lines[i] = ChatFormatting.stripFormatting(new TextComponent(ChatFormatting.stripFormatting(itextfilter_a.getRaw())).getString()); -+ lines.add(net.kyori.adventure.text.Component.text(list.get(i).getRaw())); ++ lines.add(net.kyori.adventure.text.Component.text(currentLine.getRaw())); } } SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.player.getBukkitEntity(), lines); diff --git a/patches/server/Allow-controlled-flushing-for-network-manager.patch b/patches/server/Allow-controlled-flushing-for-network-manager.patch index 1c6435f019..46571f5000 100644 --- a/patches/server/Allow-controlled-flushing-for-network-manager.patch +++ b/patches/server/Allow-controlled-flushing-for-network-manager.patch @@ -91,11 +91,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - private void doSendPacket(Packet packet, @Nullable GenericFutureListener> genericfuturelistener, ConnectionProtocol enumprotocol, ConnectionProtocol enumprotocol1) { + private void doSendPacket(Packet packet, @Nullable GenericFutureListener> callback, ConnectionProtocol enumprotocol, ConnectionProtocol enumprotocol1) { + // Paper start - add flush parameter -+ this.doSendPacket(packet, genericfuturelistener, enumprotocol, enumprotocol1, true); ++ this.doSendPacket(packet, callback, enumprotocol, enumprotocol1, true); + } -+ private void doSendPacket(Packet packet, @Nullable GenericFutureListener> genericfuturelistener, ConnectionProtocol enumprotocol, ConnectionProtocol enumprotocol1, boolean flush) { ++ private void doSendPacket(Packet packet, @Nullable GenericFutureListener> callback, ConnectionProtocol enumprotocol, ConnectionProtocol enumprotocol1, boolean flush) { + // Paper end - add flush parameter if (enumprotocol != enumprotocol1) { this.setProtocol(enumprotocol); @@ -107,8 +107,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - ChannelFuture channelfuture = this.channel.writeAndFlush(packet); + ChannelFuture channelfuture = flush ? this.channel.writeAndFlush(packet) : this.channel.write(packet); // Paper - add flush parameter - if (genericfuturelistener != null) { - channelfuture.addListener(genericfuturelistener); + if (callback != null) { + channelfuture.addListener(callback); @@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler> { } private boolean processQueue() { diff --git a/patches/server/Asynchronous-chunk-IO-and-loading.patch b/patches/server/Asynchronous-chunk-IO-and-loading.patch index 79ad7432ce..b78e4ea511 100644 --- a/patches/server/Asynchronous-chunk-IO-and-loading.patch +++ b/patches/server/Asynchronous-chunk-IO-and-loading.patch @@ -2782,15 +2782,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource { } - private CompletableFuture> getChunkFutureMainThread(int i, int j, ChunkStatus chunkstatus, boolean flag) { + private CompletableFuture> getChunkFutureMainThread(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) { + // Paper start - add isUrgent - old sig left in place for dirty nms plugins -+ return getChunkFutureMainThread(i, j, chunkstatus, flag, false); ++ return getChunkFutureMainThread(chunkX, chunkZ, leastStatus, create, false); + } -+ private CompletableFuture> getChunkFutureMainThread(int i, int j, ChunkStatus chunkstatus, boolean flag, boolean isUrgent) { ++ private CompletableFuture> getChunkFutureMainThread(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create, boolean isUrgent) { + // Paper end - ChunkPos chunkcoordintpair = new ChunkPos(i, j); + ChunkPos chunkcoordintpair = new ChunkPos(chunkX, chunkZ); long k = chunkcoordintpair.toLong(); - int l = 33 + ChunkStatus.getDistance(chunkstatus); + int l = 33 + ChunkStatus.getDistance(leastStatus); @@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource { // CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task public boolean pollTask() { diff --git a/patches/server/Fix-exploit-that-allowed-colored-signs-to-be-created.patch b/patches/server/Fix-exploit-that-allowed-colored-signs-to-be-created.patch index 57721de6b4..cb9f7e8e7d 100644 --- a/patches/server/Fix-exploit-that-allowed-colored-signs-to-be-created.patch +++ b/patches/server/Fix-exploit-that-allowed-colored-signs-to-be-created.patch @@ -9,14 +9,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser + TextFilter.FilteredText currentLine = signText.get(i); - for (int i = 0; i < list.size(); ++i) { if (this.player.isTextFilteringEnabled()) { -- lines.add(net.kyori.adventure.text.Component.text(list.get(i).getFiltered())); -+ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(list.get(i).getFiltered()))); +- lines.add(net.kyori.adventure.text.Component.text(currentLine.getFiltered())); ++ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(currentLine.getFiltered()))); } else { -- lines.add(net.kyori.adventure.text.Component.text(list.get(i).getRaw())); -+ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(list.get(i).getRaw()))); +- lines.add(net.kyori.adventure.text.Component.text(currentLine.getRaw())); ++ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(currentLine.getRaw()))); } } SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.player.getBukkitEntity(), lines); diff --git a/patches/server/Implement-Chunk-Priority-Urgency-System-for-Chunks.patch b/patches/server/Implement-Chunk-Priority-Urgency-System-for-Chunks.patch index ec1bb8a7af..31e7b70c5e 100644 --- a/patches/server/Implement-Chunk-Priority-Urgency-System-for-Chunks.patch +++ b/patches/server/Implement-Chunk-Priority-Urgency-System-for-Chunks.patch @@ -1040,7 +1040,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 ichunkaccess = (ChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> { return ichunkaccess1; @@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource { - if (flag && !currentlyUnloading) { + if (create && !currentlyUnloading) { // CraftBukkit end this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); + if (isUrgent) this.distanceManager.markUrgent(chunkcoordintpair); // Paper - Chunk priority @@ -1053,13 +1053,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 playerchunk = this.getVisibleChunkIfPresent(k); gameprofilerfiller.pop(); @@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource { - } } } -- -- return this.chunkAbsent(playerchunk, l) ? ChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.getOrScheduleFuture(chunkstatus, this.chunkMap); + +- return this.chunkAbsent(playerchunk, l) ? ChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.getOrScheduleFuture(leastStatus, this.chunkMap); + // Paper start - Chunk priority -+ CompletableFuture> future = this.chunkAbsent(playerchunk, l) ? ChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.getOrScheduleFuture(chunkstatus, this.chunkMap); ++ CompletableFuture> future = this.chunkAbsent(playerchunk, l) ? ChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.getOrScheduleFuture(leastStatus, this.chunkMap); + if (isUrgent) { + future.thenAccept(either -> this.distanceManager.clearUrgent(chunkcoordintpair)); + } diff --git a/patches/server/Limit-Client-Sign-length-more.patch b/patches/server/Limit-Client-Sign-length-more.patch index c7512751c9..2429a1e00a 100644 --- a/patches/server/Limit-Client-Sign-length-more.patch +++ b/patches/server/Limit-Client-Sign-length-more.patch @@ -34,25 +34,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player) { @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser - List lines = new java.util.ArrayList<>(); - for (int i = 0; i < list.size(); ++i) { + for (int i = 0; i < signText.size(); ++i) { + TextFilter.FilteredText currentLine = signText.get(i); + // Paper start - cap line length - modified clients can send longer data than normal -+ net.minecraft.server.network.TextFilter.FilteredText currentLine = list.get(i); + if (MAX_SIGN_LINE_LENGTH > 0 && currentLine.getRaw().length() > MAX_SIGN_LINE_LENGTH) { + // This handles multibyte characters as 1 + int offset = currentLine.getRaw().codePoints().limit(MAX_SIGN_LINE_LENGTH).map(Character::charCount).sum(); + if (offset < currentLine.getRaw().length()) { -+ list.set(i, currentLine = net.minecraft.server.network.TextFilter.FilteredText.passThrough(currentLine.getRaw().substring(0, offset))); // this will break any filtering, but filtering is NYI as of 1.17 ++ signText.set(i, currentLine = net.minecraft.server.network.TextFilter.FilteredText.passThrough(currentLine.getRaw().substring(0, offset))); // this will break any filtering, but filtering is NYI as of 1.17 + } + } + // Paper end + if (this.player.isTextFilteringEnabled()) { -- lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(list.get(i).getFiltered()))); -+ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(currentLine.getFiltered()))); - } else { -- lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(list.get(i).getRaw()))); -+ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(currentLine.getRaw()))); - } - } - SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.player.getBukkitEntity(), lines); + lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(currentLine.getFiltered()))); diff --git a/patches/server/Mob-Spawner-API-Enhancements.patch b/patches/server/Mob-Spawner-API-Enhancements.patch index b2f8cbefd2..ad07f9dee7 100644 --- a/patches/server/Mob-Spawner-API-Enhancements.patch +++ b/patches/server/Mob-Spawner-API-Enhancements.patch @@ -50,7 +50,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (nbt.contains("SpawnPotentials", 9)) { @@ -0,0 +0,0 @@ public abstract class BaseSpawner { - this.setSpawnData(world, pos, mobspawnerdata); + this.setNextSpawnData(world, pos, mobspawnerdata); }); } - @@ -122,7 +122,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + entity.put("Item", item.save(new net.minecraft.nbt.CompoundTag())); + compound.put("Entity", entity); + compound.putInt("Weight", this.getSnapshotNBT().contains("Weight", org.bukkit.craftbukkit.util.CraftMagicNumbers.NBT.TAG_ANY_NUMBER) ? this.getSnapshotNBT().getInt("Weight") : 1); -+ this.getSnapshot().getSpawner().setSpawnData(world.getHandle(), getPosition(), new net.minecraft.world.level.SpawnData(compound)); ++ this.getSnapshot().getSpawner().setNextSpawnData(world.getHandle(), getPosition(), new net.minecraft.world.level.SpawnData(compound)); + this.getSnapshot().getSpawner().spawnPotentials= net.minecraft.world.level.BaseSpawner.EMPTY_POTENTIALS; + } + // Paper end diff --git a/patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch b/patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch index a67e6eb993..81b4cad7b2 100644 --- a/patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch +++ b/patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch @@ -157,8 +157,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end ChannelFuture channelfuture = this.channel.writeAndFlush(packet); - if (genericfuturelistener != null) { - channelfuture.addListener(genericfuturelistener); + if (callback != null) { + channelfuture.addListener(callback); } + // Paper start + if (packet.hasFinishListener()) { diff --git a/patches/server/Prevent-unload-calls-removing-tickets-for-sync-loads.patch b/patches/server/Prevent-unload-calls-removing-tickets-for-sync-loads.patch index b2e5955f6b..3f4d8486bf 100644 --- a/patches/server/Prevent-unload-calls-removing-tickets-for-sync-loads.patch +++ b/patches/server/Prevent-unload-calls-removing-tickets-for-sync-loads.patch @@ -14,15 +14,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private long syncLoadCounter; // Paper - prevent plugin unloads from removing our ticket + - private CompletableFuture> getChunkFutureMainThread(int i, int j, ChunkStatus chunkstatus, boolean flag) { + private CompletableFuture> getChunkFutureMainThread(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) { // Paper start - add isUrgent - old sig left in place for dirty nms plugins - return getChunkFutureMainThread(i, j, chunkstatus, flag, false); + return getChunkFutureMainThread(chunkX, chunkZ, leastStatus, create, false); @@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource { ChunkHolder.FullChunkStatus currentChunkState = ChunkHolder.getFullChunkStatus(playerchunk.getTicketLevel()); currentlyUnloading = (oldChunkState.isOrAfter(ChunkHolder.FullChunkStatus.BORDER) && !currentChunkState.isOrAfter(ChunkHolder.FullChunkStatus.BORDER)); } + final Long identifier; // Paper - prevent plugin unloads from removing our ticket - if (flag && !currentlyUnloading) { + if (create && !currentlyUnloading) { // CraftBukkit end this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); + identifier = Long.valueOf(this.syncLoadCounter++); // Paper - prevent plugin unloads from removing our ticket @@ -39,11 +39,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } - } + + } else { identifier = null; } // Paper - prevent plugin unloads from removing our ticket // Paper start - Chunk priority - CompletableFuture> future = this.chunkAbsent(playerchunk, l) ? ChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.getOrScheduleFuture(chunkstatus, this.chunkMap); + CompletableFuture> future = this.chunkAbsent(playerchunk, l) ? ChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.getOrScheduleFuture(leastStatus, this.chunkMap); + // Paper start - prevent plugin unloads from removing our ticket -+ if (flag && !currentlyUnloading) { ++ if (create && !currentlyUnloading) { + future.thenAcceptAsync((either) -> { + ServerChunkCache.this.distanceManager.removeTicketAtLevel(TicketType.REQUIRED_LOAD, chunkcoordintpair, l, identifier); + }, ServerChunkCache.this.mainThreadProcessor);