Skip to content

Commit aa4cf19

Browse files
committed
Finish 26.1.1 patches
1 parent 2a42718 commit aa4cf19

115 files changed

Lines changed: 1735 additions & 1650 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
uses: actions/setup-java@v4
1818
with:
1919
distribution: 'temurin'
20-
java-version: '21'
20+
java-version: '25'
2121
- name: Setup Gradle
2222
uses: gradle/actions/setup-gradle@v4
2323
- name: Configure Git User Details

.github/workflows/upstream.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
uses: actions/setup-java@v4
1818
with:
1919
distribution: 'temurin'
20-
java-version: '21'
20+
java-version: '25'
2121
- name: Setup Gradle
2222
uses: gradle/actions/setup-gradle@v4
2323
- name: Configure Git User Details

shreddedpaper-server/minecraft-patches/sources/ca/spottedleaf/moonrise/common/misc/NearbyPlayers.java.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155

156156
- final TrackedChunk chunk = NearbyPlayers.this.byChunk.get(chunkKey);
157157
+ NearbyPlayers.this.chunkModificationLock.write(chunkKey, () -> { // ShreddedPaper
158-
+ TrackedChunk chunk = NearbyPlayers.this.byChunkLock.optimisticRead(() -> NearbyPlayers.this.byChunk.get(chunkKey)); // ShreddedPaper
158+
+ final TrackedChunk chunk = NearbyPlayers.this.byChunkLock.optimisticRead(() -> NearbyPlayers.this.byChunk.get(chunkKey)); // ShreddedPaper
159159
final NearbyMapType type = this.type;
160160
if (chunk != null) {
161161
chunk.addPlayer(parameter, type);
@@ -180,7 +180,7 @@
180180
+ NearbyPlayers.this.chunkModificationLock.write(chunkKey, () -> { // ShreddedPaper
181181
+ final TrackedChunk chunk = NearbyPlayers.this.byChunkLock.optimisticRead(() -> NearbyPlayers.this.byChunk.get(chunkKey)); // ShreddedPaper
182182
if (chunk == null) {
183-
throw new IllegalStateException("Chunk should exist at " + new ChunkPos(chunkKey));
183+
throw new IllegalStateException("Chunk should exist at " + ChunkPos.unpack(chunkKey));
184184
}
185185
@@ -262,12 +_,13 @@
186186
type.removeFrom(parameter, NearbyPlayers.this.world, chunkX, chunkZ);

shreddedpaper-server/minecraft-patches/sources/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java.patch

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,22 @@
1818
long currTime = System.nanoTime();
1919
for (final ServerPlayer player : new java.util.ArrayList<>(this.world.players())) {
2020
final PlayerChunkLoaderData loader = ((ChunkSystemServerPlayer)player).moonrise$getChunkLoader();
21-
@@ -387,6 +_,7 @@
22-
Math.abs(c2x - centerX) + Math.abs(c2z - centerZ)
21+
@@ -405,13 +_,13 @@
22+
(diff2X * diff2X) + (diff2Z * diff2Z)
2323
);
2424
};
2525
+ private final LongArrayList retryLaterSendQueue = new LongArrayList(); // ShreddedPaper
26-
private final LongHeapPriorityQueue sendQueue = new LongHeapPriorityQueue(CLOSEST_MANHATTAN_DIST);
27-
private final LongHeapPriorityQueue tickingQueue = new LongHeapPriorityQueue(CLOSEST_MANHATTAN_DIST);
28-
private final LongHeapPriorityQueue generatingQueue = new LongHeapPriorityQueue(CLOSEST_MANHATTAN_DIST);
29-
@@ -641,7 +_,7 @@
26+
private final LongHeapPriorityQueue sendQueue = new LongHeapPriorityQueue(this.queueComparator);
27+
private final LongHeapPriorityQueue tickingQueue = new LongHeapPriorityQueue(this.queueComparator);
28+
private final LongHeapPriorityQueue generatingQueue = new LongHeapPriorityQueue(this.queueComparator);
29+
private final LongHeapPriorityQueue genQueue = new LongHeapPriorityQueue(this.queueComparator);
30+
private final LongHeapPriorityQueue loadingQueue = new LongHeapPriorityQueue(this.queueComparator);
31+
private final LongHeapPriorityQueue loadQueue = new LongHeapPriorityQueue(this.queueComparator);
32+
-
33+
private volatile boolean removed;
34+
35+
public PlayerChunkLoaderData(final ServerLevel world, final ServerPlayer player) {
36+
@@ -659,7 +_,7 @@
3037
return true;
3138
}
3239

@@ -35,12 +42,12 @@
3542
TickThread.ensureTickThread(this.player, "Cannot tick player chunk loader async");
3643
if (this.removed) {
3744
throw new IllegalStateException("Ticking removed player chunk loader");
38-
@@ -821,17 +_,31 @@
39-
final long maxSends = Math.max(0L, Math.min(MAX_RATE, Integer.MAX_VALUE)); // note: no logic to track concurrent sends
40-
final int maxSendsThisTick = Math.min((int)this.chunkSendLimiter.takeAllocation(time, sendRate, maxSends), this.sendQueue.size());
45+
@@ -838,17 +_,31 @@
46+
final long maxSends = Math.max(0L, Math.min(MAX_RATE, Math.min(this.sendQueue.size(), Integer.MAX_VALUE))); // note: no logic to track concurrent sends
47+
final long maxSendsThisTick = this.chunkSendLimiter.takeAllocation(maxSends);
4148
// we do not return sends that we took from the allocation back because we want to limit the max send rate, not target it
4249
+ int j = 0; // ShreddedPaper
43-
for (int i = 0; i < maxSendsThisTick; ++i) {
50+
for (long i = 0; i < maxSendsThisTick; ++i) {
4451
final long pendingSend = this.sendQueue.firstLong();
4552
final int pendingSendX = CoordinateUtils.getChunkX(pendingSend);
4653
final int pendingSendZ = CoordinateUtils.getChunkZ(pendingSend);
@@ -68,7 +75,7 @@
6875
// not yet post-processed, need to do this so that tile entities can properly be sent to clients
6976
chunk.postProcessGeneration(this.world);
7077
// check if there was any recursive action
71-
@@ -841,7 +_,17 @@
78+
@@ -858,7 +_,17 @@
7279
}
7380
this.sendQueue.dequeueLong();
7481

@@ -87,7 +94,7 @@
8794

8895
if (this.removed) {
8996
// sendChunk may invoke plugin logic
90-
@@ -849,6 +_,15 @@
97+
@@ -866,6 +_,15 @@
9198
}
9299
}
93100

@@ -103,7 +110,7 @@
103110
this.flushDelayedTicketOps();
104111
}
105112

106-
@@ -907,7 +_,7 @@
113+
@@ -918,7 +_,7 @@
107114
);
108115
}
109116

@@ -112,15 +119,15 @@
112119
TickThread.ensureTickThread(this.player, "Cannot update player asynchronously");
113120
if (this.removed) {
114121
throw new IllegalStateException("Updating removed player chunk loader");
115-
@@ -967,6 +_,7 @@
122+
@@ -978,6 +_,7 @@
116123
this.player.connection.send(this.updateClientSimulationDistance(tickViewDistance));
117124
}
118125

119126
+ this.retryLaterSendQueue.clear(); // ShreddedPaper
120127
this.sendQueue.clear();
121128
this.tickingQueue.clear();
122129
this.generatingQueue.clear();
123-
@@ -1073,6 +_,7 @@
130+
@@ -1084,6 +_,7 @@
124131
this.tickMap.remove();
125132

126133
// purge queues

shreddedpaper-server/minecraft-patches/sources/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222

2323
@@ -77,7 +_,7 @@
2424

25-
private final ConcurrentLong2ReferenceChainedHashTable<TicketSet> tickets = new ConcurrentLong2ReferenceChainedHashTable<>();
26-
private final ConcurrentLong2ReferenceChainedHashTable<Long2IntOpenHashMap> sectionToChunkToExpireCount = new ConcurrentLong2ReferenceChainedHashTable<>();
25+
private final ConcurrentChainedLong2ReferenceHashTable<TicketSet> tickets = new ConcurrentChainedLong2ReferenceHashTable<>();
26+
private final ConcurrentChainedLong2ReferenceHashTable<Long2IntOpenHashMap> sectionToChunkToExpireCount = new ConcurrentChainedLong2ReferenceHashTable<>();
2727
- final ChunkUnloadQueue unloadQueue;
2828
+ // final ChunkUnloadQueue unloadQueue; // ShreddedPaper - use our own unload queue
2929

30-
private final ConcurrentLong2ReferenceChainedHashTable<NewChunkHolder> chunkHolders = ConcurrentLong2ReferenceChainedHashTable.createWithCapacity(16384, 0.25f);
30+
private final ConcurrentChainedLong2ReferenceHashTable<NewChunkHolder> chunkHolders = ConcurrentChainedLong2ReferenceHashTable.createWithCapacity(16384, 0.25f);
3131
private final ServerLevel world;
3232
@@ -85,6 +_,7 @@
3333
private long currentTick;

shreddedpaper-server/minecraft-patches/sources/net/minecraft/CrashReport.java.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
- private List<String> extraInfo = List.of("", "DO NOT REPORT THIS TO PAPER! REPORT TO PURPUR INSTEAD!", ""); // Purpur - Rebrand
88
+ private List<String> extraInfo = List.of("", "DO NOT REPORT THIS TO PAPER! REPORT TO SHREDDEDPAPER INSTEAD!", ""); // Purpur - Rebrand // ShreddedPaper
99

10-
public CrashReport(String title, Throwable exception) {
10+
public CrashReport(final String title, final Throwable t) {
1111
this.title = title;

shreddedpaper-server/minecraft-patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
--- a/net/minecraft/core/dispenser/DispenseItemBehavior.java
22
+++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java
3-
@@ -407,20 +_,20 @@
3+
@@ -337,20 +_,20 @@
44
return result;
55
}
66
// Paper end - Call BlockDispenseEvent
77
- level.captureTreeGeneration = true; // CraftBukkit
88
+ level.captureTreeGenerationThreadLocal.set(true); // CraftBukkit // ShreddedPaper - use thread local
9-
if (!BoneMealItem.growCrop(item, level, blockPos) && !BoneMealItem.growWaterPlant(item, level, blockPos, null)) {
9+
if (!BoneMealItem.growCrop(dispensed, level, target) && !BoneMealItem.growWaterPlant(dispensed, level, target, null)) {
1010
this.setSuccess(false);
1111
} else if (!level.isClientSide()) {
12-
level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH, blockPos, 15);
12+
level.levelEvent(LevelEvent.PARTICLES_AND_SOUND_PLANT_GROWTH, target, 15);
1313
}
1414
// CraftBukkit start
1515
- level.captureTreeGeneration = false;
@@ -20,7 +20,7 @@
2020
+ if (!level.capturedBlockStatesThreadLocal.get().isEmpty()) { // ShreddedPaper - use thread local
2121
+ org.bukkit.TreeType treeType = net.minecraft.world.level.block.SaplingBlock.treeTypeThreadLocal.get(); // ShreddedPaper - use thread local
2222
+ net.minecraft.world.level.block.SaplingBlock.treeTypeThreadLocal.remove(); // ShreddedPaper - use thread local
23-
org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(blockPos, level);
23+
org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(target, level);
2424
- List<org.bukkit.block.BlockState> states = new java.util.ArrayList<>(level.capturedBlockStates.values());
2525
- level.capturedBlockStates.clear();
2626
+ List<org.bukkit.block.BlockState> states = new java.util.ArrayList<>(level.capturedBlockStatesThreadLocal.get().values()); // ShreddedPaper - use thread local

shreddedpaper-server/minecraft-patches/sources/net/minecraft/network/Connection.java.patch

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,37 +32,37 @@
3232
import net.minecraft.util.debugchart.LocalSampleLogger;
3333
@@ -303,6 +_,7 @@
3434

35-
private static void syncAfterConfigurationChange(ChannelFuture future) {
35+
private static void syncAfterConfigurationChange(final ChannelFuture future) {
3636
try {
3737
+ if (TickThread.isTickThread()) MinecraftServer.getServer().managedBlock(future::isDone); // ShreddedPaper - don't block main thread
3838
future.syncUninterruptibly();
3939
} catch (Exception var2) {
4040
if (var2 instanceof ClosedChannelException) {
41-
@@ -400,7 +_,7 @@
41+
@@ -398,7 +_,7 @@
4242

43-
public void send(Packet<?> packet, @Nullable ChannelFutureListener sendListener, boolean flush) {
43+
public void send(final Packet<?> packet, final @Nullable ChannelFutureListener listener, final boolean flush) {
4444
// Paper start - Optimize network: Handle oversized packets better
4545
- final boolean connected = this.isConnected();
4646
+ final boolean connected = true || this.isConnected(); // ShreddedPaper - Checking if the player is connected is expensive
4747
if (!connected && !this.preparing) {
4848
return;
4949
}
50-
@@ -448,6 +_,14 @@
50+
@@ -446,6 +_,14 @@
5151
if (this.channel.eventLoop().inEventLoop()) {
52-
this.doSendPacket(packet, sendListener, flush);
52+
this.doSendPacket(packet, listener, flush);
5353
} else {
5454
+ // ShreddedPaper start - Use lazyExecute if we aren't flushing
5555
+ if (ShreddedPaperConfiguration.get().optimizations.useLazyExecuteWhenNotFlushing && !flush) {
5656
+ ((AbstractEventExecutor) this.channel.eventLoop()).lazyExecute(() -> {
57-
+ this.doSendPacket(packet, sendListener, flush);
57+
+ this.doSendPacket(packet, listener, flush);
5858
+ });
5959
+ return;
6060
+ }
6161
+ // ShreddedPaper end - Use lazyExecute if we aren't flushing
62-
this.channel.eventLoop().execute(() -> this.doSendPacket(packet, sendListener, flush));
62+
this.channel.eventLoop().execute(() -> this.doSendPacket(packet, listener, flush));
6363
}
6464
}
65-
@@ -500,7 +_,7 @@
65+
@@ -498,7 +_,7 @@
6666
}
6767

6868
// Paper start - Optimize network: Rewrite this to be safer if ran off main thread
@@ -71,7 +71,7 @@
7171
if (!this.isConnected()) {
7272
return true;
7373
}
74-
@@ -556,7 +_,8 @@
74+
@@ -554,7 +_,8 @@
7575
private static int currTick; // Paper - Buffer joins to world
7676
private static int tickSecond; // Purpur - Max joins per second
7777
public void tick() {

shreddedpaper-server/minecraft-patches/sources/net/minecraft/network/protocol/PacketUtils.java.patch

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,23 @@
1818
import org.jspecify.annotations.Nullable;
1919
import org.slf4j.Logger;
2020

21-
@@ -19,6 +_,28 @@
21+
@@ -19,6 +_,27 @@
2222
}
2323

24-
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T packetListener, PacketProcessor processor) throws RunningOnDifferentThreadException {
24+
public static <T extends PacketListener> void ensureRunningOnSameThread(final Packet<T> packet, final T listener, final PacketProcessor packetProcessor) throws RunningOnDifferentThreadException {
2525
+ // ShreddedPaper start - run on player's thread
26-
+ if (packetListener instanceof ServerGamePacketListenerImpl gamePacketListener) {
26+
+ if (listener instanceof ServerGamePacketListenerImpl gamePacketListener) {
2727
+ if (TickThread.isTickThreadFor(gamePacketListener.player)) return;
2828
+ ShreddedPaper.runSync(gamePacketListener.player, () -> {
29-
+ if (packetListener instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // Paper - Don't handle sync packets for kicked players
30-
+ if (packetListener.shouldHandleMessage(packet)) {
29+
+ if (listener instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // Paper - Don't handle sync packets for kicked players
30+
+ if (listener.shouldHandleMessage(packet)) {
3131
+ try {
32-
+ packet.handle(packetListener);
32+
+ packet.handle(listener);
3333
+ } catch (Exception var3) {
3434
+ if (var3 instanceof ReportedException reportedException && reportedException.getCause() instanceof OutOfMemoryError) {
35-
+ throw PacketUtils.makeReportedException(var3, packet, packetListener);
35+
+ throw PacketUtils.makeReportedException(var3, packet, listener);
3636
+ }
37-
+
38-
+ packetListener.onPacketError(packet, var3);
37+
+ listener.onPacketError(packet, var3);
3938
+ }
4039
+ } else {
4140
+ LOGGER.debug("Ignoring packet due to disconnection: {}", packet);
@@ -44,6 +43,6 @@
4443
+ throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD;
4544
+ }
4645
+ // ShreddedPaper end - run on player's thread
47-
if (!processor.isSameThread()) {
48-
processor.scheduleIfPossible(packetListener, packet);
46+
if (!packetProcessor.isSameThread()) {
47+
packetProcessor.scheduleIfPossible(listener, packet);
4948
throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD;

shreddedpaper-server/minecraft-patches/sources/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java.patch

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
// Paper start - Async-Anti-Xray - Ready flag for the connection, add chunk packet info
66
private volatile boolean ready;
77
+ public boolean modifyBlocks; // ShreddedPaper
8-
98
@Override
109
public boolean isReady() {
11-
@@ -39,6 +_,7 @@
12-
ChunkPos pos = chunk.getPos();
13-
this.x = pos.x;
14-
this.z = pos.z;
10+
return this.ready;
11+
@@ -51,6 +_,7 @@
12+
ChunkPos chunkPos = levelChunk.getPos();
13+
this.x = chunkPos.x();
14+
this.z = chunkPos.z();
1515
+ this.modifyBlocks = modifyBlocks; // ShreddedPaper
16-
io.papermc.paper.antixray.ChunkPacketInfo<net.minecraft.world.level.block.state.BlockState> chunkPacketInfo = modifyBlocks ? chunk.getLevel().chunkPacketBlockController.getChunkPacketInfo(this, chunk) : null; // Paper - Ant-Xray
17-
this.chunkData = new ClientboundLevelChunkPacketData(chunk, chunkPacketInfo); // Paper - Anti-Xray
18-
this.lightData = new ClientboundLightUpdatePacketData(pos, lightEngine, skyLight, blockLight);
16+
io.papermc.paper.antixray.ChunkPacketInfo<net.minecraft.world.level.block.state.BlockState> chunkPacketInfo = modifyBlocks ? levelChunk.getLevel().chunkPacketBlockController.getChunkPacketInfo(this, levelChunk) : null; // Paper - Anti-Xray
17+
this.chunkData = new ClientboundLevelChunkPacketData(levelChunk, chunkPacketInfo); // Paper - Anti-Xray
18+
this.lightData = new ClientboundLightUpdatePacketData(chunkPos, lightEngine, skyChangedLightSectionFilter, blockChangedLightSectionFilter);

0 commit comments

Comments
 (0)