Skip to content

Commit

Permalink
Merge branch 'PaperMC:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Q2297045667 authored Sep 30, 2024
2 parents 8f6f82d + 9a19e42 commit 1cbcd21
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 42 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ group=dev.folia
version=1.20.6-R0.1-SNAPSHOT
mcVersion=1.20.6

paperRef=e41d44fa873466064879ebed476d280932379a9c
paperRef=6e71f415369e35558450f015cfcc2d2db1c0e064

org.gradle.caching=true
org.gradle.parallel=true
Expand Down
71 changes: 31 additions & 40 deletions patches/server/0003-Threaded-Regions.patch
Original file line number Diff line number Diff line change
Expand Up @@ -15228,7 +15228,7 @@ index 8aff5129f85ab5729b3da2e465871be62d15bdf2..8044271ff01dfc6808f5a3b60be74f6d
Collections.shuffle( this.connections );
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c2199052f19 100644
index dd0610104822bee532542c87ecc9cd16ccf3c216..e16d24bd83cddce7ead70a2a3847d09e988c715e 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -300,7 +300,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
Expand Down Expand Up @@ -15393,38 +15393,29 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
} else if (!completions.isEmpty()) {
final com.mojang.brigadier.suggestion.SuggestionsBuilder builder0 = new com.mojang.brigadier.suggestion.SuggestionsBuilder(packet.getCommand(), stringreader.getTotalLength());
final com.mojang.brigadier.suggestion.SuggestionsBuilder builder = builder0.createOffset(builder0.getInput().lastIndexOf(' ') + 1);
@@ -1165,7 +1200,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
int byteLength = testString.getBytes(java.nio.charset.StandardCharsets.UTF_8).length;
if (byteLength > 256 * 4) {
ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send a book with with a page too large!");
- server.scheduleOnMain(() -> this.disconnect("Book too large!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION)); // Paper - kick event cause
+ this.disconnect("Book too large!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause // Folia - region threading
return;
}
byteTotal += byteLength;
@@ -1188,17 +1223,17 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1186,17 +1221,17 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl

if (byteTotal > byteAllowed) {
ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send too large of a book. Book Size: " + byteTotal + " - Allowed: "+ byteAllowed + " - Pages: " + pageList.size());
- server.scheduleOnMain(() -> this.disconnect("Book too large!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION)); // Paper - kick event cause
ServerGamePacketListenerImpl.LOGGER.warn("{} tried to send a book too large. Book size: {} - Allowed: {} - Pages: {}", this.player.getScoreboardName(), byteTotal, byteAllowed, pageList.size());
- this.disconnect("Book too large!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause
+ this.disconnect("Book too large!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause // Folia - region threading
return;
}
}
// Paper end - Book size limits
// CraftBukkit start
- if (this.lastBookTick + 20 > MinecraftServer.currentTick) {
- server.scheduleOnMain(() -> this.disconnect("Book edited too quickly!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION)); // Paper - kick event cause // Paper - Also ensure this is called on main
+ if (this.lastBookTick + 20 > this.lastTick) {
+ this.disconnect("Book edited too quickly!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause // Paper - Also ensure this is called on main // Folia - region threading
- this.disconnect("Book edited too quickly!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause
+ if (this.lastBookTick + 20 > this.lastTick) { // Folia - region threading
+ this.disconnect("Book edited too quickly!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause // Folia - region threading
return;
}
- this.lastBookTick = MinecraftServer.currentTick;
+ this.lastBookTick = this.lastTick;
+ this.lastBookTick = this.lastTick; // Folia - region threading
// CraftBukkit end
int i = packet.slot();

@@ -1218,7 +1253,19 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1216,7 +1251,19 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
this.updateBookContents(list1, i);
};

Expand All @@ -15445,7 +15436,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
}
}

@@ -1374,9 +1421,10 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1372,9 +1419,10 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
int i = this.receivedMovePacketCount - this.knownMovePacketCount;

// CraftBukkit start - handle custom speeds and skipped ticks
Expand All @@ -15458,7 +15449,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21

if (i > Math.max(this.allowedPlayerTicks, 5)) {
ServerGamePacketListenerImpl.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getName().getString(), i);
@@ -1568,7 +1616,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1566,7 +1614,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl

// If the event is cancelled we move the player back to their old location.
if (event.isCancelled()) {
Expand All @@ -15467,7 +15458,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
return;
}

@@ -1576,7 +1624,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1574,7 +1622,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
// there to avoid any 'Moved wrongly' or 'Moved too quickly' errors.
// We only do this if the Event was not cancelled.
if (!oldTo.equals(event.getTo()) && !event.isCancelled()) {
Expand All @@ -15476,7 +15467,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
return;
}

@@ -1803,9 +1851,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1801,9 +1849,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
if (!this.player.isSpectator()) {
// limit how quickly items can be dropped
// If the ticks aren't the same then the count starts from 0 and we update the lastDropTick.
Expand All @@ -15488,7 +15479,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
} else {
// Else we increment the drop count and check the amount.
this.dropCount++;
@@ -1833,7 +1881,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1831,7 +1879,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
case ABORT_DESTROY_BLOCK:
case STOP_DESTROY_BLOCK:
// Paper start - Don't allow digging into unloaded chunks
Expand All @@ -15497,7 +15488,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
this.player.connection.ackBlockChangesUpTo(packet.getSequence());
return;
}
@@ -1916,7 +1964,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1914,7 +1962,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
// Paper end - improve distance check
BlockPos blockposition = movingobjectpositionblock.getBlockPos();

Expand All @@ -15506,7 +15497,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
Vec3 vec3d1 = vec3d.subtract(Vec3.atCenterOf(blockposition));
double d0 = 1.0000001D;

@@ -2033,7 +2081,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2031,7 +2079,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
Entity entity = packet.getEntity(worldserver);

if (entity != null) {
Expand All @@ -15515,7 +15506,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
return;
}
}
@@ -2068,7 +2116,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2066,7 +2114,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
// CraftBukkit end
ServerGamePacketListenerImpl.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), reason.getString());
Expand All @@ -15524,7 +15515,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
super.onDisconnect(reason, quitMessage); // Paper - Fix kick event leave message not being sent
}

@@ -2077,6 +2125,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2075,6 +2123,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
this.removePlayerFromWorld(null);
}

Expand All @@ -15533,7 +15524,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
private void removePlayerFromWorld(@Nullable net.kyori.adventure.text.Component quitMessage) {
// Paper end - Fix kick event leave message not being sent
this.chatMessageChain.close();
@@ -2089,6 +2139,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2087,6 +2137,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
this.player.disconnect();
// Paper start - Adventure
quitMessage = quitMessage == null ? this.server.getPlayerList().remove(this.player) : this.server.getPlayerList().remove(this.player, quitMessage); // Paper - pass in quitMessage to fix kick message not being used
Expand All @@ -15542,7 +15533,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
if ((quitMessage != null) && !quitMessage.equals(net.kyori.adventure.text.Component.empty())) {
this.server.getPlayerList().broadcastSystemMessage(PaperAdventure.asVanilla(quitMessage), false);
// Paper end
@@ -2337,7 +2389,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2335,7 +2387,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
this.player.resetLastActionTime();
// CraftBukkit start
if (sync) {
Expand All @@ -15551,7 +15542,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
} else {
runnable.run();
}
@@ -2395,7 +2447,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2393,7 +2445,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
String originalFormat = event.getFormat(), originalMessage = event.getMessage();
this.cserver.getPluginManager().callEvent(event);

Expand All @@ -15560,15 +15551,15 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
// Evil plugins still listening to deprecated event
final PlayerChatEvent queueEvent = new PlayerChatEvent(player, event.getMessage(), event.getFormat(), event.getRecipients());
queueEvent.setCancelled(event.isCancelled());
@@ -2493,6 +2545,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2491,6 +2543,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
if (s.isEmpty()) {
ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send an empty message");
} else if (this.getCraftPlayer().isConversing()) {
+ if (true) throw new UnsupportedOperationException(); // Folia - region threading
final String conversationInput = s;
this.server.processQueue.add(new Runnable() {
@Override
@@ -2724,8 +2777,25 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2722,8 +2775,25 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
// Spigot End

public void switchToConfig() {
Expand All @@ -15595,7 +15586,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
this.send(ClientboundStartConfigurationPacket.INSTANCE);
this.connection.setupOutboundProtocol(ConfigurationProtocols.CLIENTBOUND);
}
@@ -2751,7 +2821,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2749,7 +2819,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl

this.player.resetLastActionTime();
this.player.setShiftKeyDown(packet.isUsingSecondaryAction());
Expand All @@ -15604,7 +15595,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
if (!worldserver.getWorldBorder().isWithinBounds(entity.blockPosition())) {
return;
}
@@ -2895,6 +2965,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2893,6 +2963,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
switch (packetplayinclientcommand_enumclientcommand) {
case PERFORM_RESPAWN:
if (this.player.wonGame) {
Expand All @@ -15617,7 +15608,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
this.player.wonGame = false;
this.player = this.server.getPlayerList().respawn(this.player, this.server.getLevel(this.player.getRespawnDimension()), true, null, true, RespawnReason.END_PORTAL, org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag.END_PORTAL); // Paper - Expand PlayerRespawnEvent
CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD);
@@ -2903,6 +2979,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2901,6 +2977,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
return;
}

Expand All @@ -15636,7 +15627,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
this.player = this.server.getPlayerList().respawn(this.player, false, RespawnReason.DEATH);
if (this.server.isHardcore()) {
this.player.setGameMode(GameType.SPECTATOR, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.HARDCORE_DEATH, null); // Paper - Expand PlayerGameModeChangeEvent
@@ -3267,7 +3355,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -3265,7 +3353,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
// Paper start - auto recipe limit
if (!org.bukkit.Bukkit.isPrimaryThread()) {
if (this.recipeSpamPackets.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamLimit) {
Expand All @@ -15645,7 +15636,7 @@ index 4ae88bfcead40cd05f9514a48a922a37767cb3cf..2ae2527bbe5a08af98eb6405a8403c21
return;
}
}
@@ -3436,7 +3524,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -3434,7 +3522,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl

this.filterTextPacket(list).thenAcceptAsync((list1) -> {
this.updateSignText(packet, list1);
Expand Down Expand Up @@ -20422,7 +20413,7 @@ index 73e532dc998e5701c1a73da846da3d3a79871b81..5e4cb998554791cdfc2e32ae7115f87e

if (i % 40L == 0L) {
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index 8310d132006043e93c612890514c4c7f3eb1c74d..1280c358748bbb08f0361acd4ebc095bf6bc3496 100644
index ab5ce14f024305fcf3df4254212363145457eddb..779ffcf390d1ebdf37653454063d3c7d1fc35875 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -49,7 +49,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
Expand Down Expand Up @@ -20545,7 +20536,7 @@ index 8310d132006043e93c612890514c4c7f3eb1c74d..1280c358748bbb08f0361acd4ebc095b
}
if (!result) {
cooldownHopper(hopper);
@@ -541,13 +553,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -546,13 +558,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
}

public static boolean suckInItems(Level world, Hopper hopper) {
Expand All @@ -20561,7 +20552,7 @@ index 8310d132006043e93c612890514c4c7f3eb1c74d..1280c358748bbb08f0361acd4ebc095b
int[] aint = HopperBlockEntity.getSlots(iinventory, enumdirection);
int i = aint.length;

@@ -733,9 +746,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -742,9 +755,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
stack = stack.split(to.getMaxStackSize());
}
// Spigot end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1667,7 +1667,7 @@ index e9f471e60af0725ec34e2985d63ae9ea9f88590a..6a443f42ecec16abea3ddf7bc2e85bb8
}

diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 0196a49a5822e257b0e065e2383ec92b1bc27bba..c086e530b524186d21607e5edc4bd7d1ae60bbd0 100644
index 541c256e4e834da3915023db20235587a0d2259f..2640566c56f65959ca05d17a064263ca4623adc9 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -476,6 +476,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
Expand Down

0 comments on commit 1cbcd21

Please sign in to comment.