i really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really love jmp

This commit is contained in:
Spottedleaf 2022-06-07 18:31:24 -07:00
parent 68b585fba7
commit a27b508dea
18 changed files with 107 additions and 102 deletions

View File

@ -6,7 +6,7 @@ Subject: [PATCH] Fix SpongeAbsortEvent handling
Only process drops when the block is actually going to be removed
diff --git a/src/main/java/net/minecraft/world/level/block/SpongeBlock.java b/src/main/java/net/minecraft/world/level/block/SpongeBlock.java
index dad71c90c51bfef8dd42b3141ad23604a96100fb..11b40defd5f5362346fd8a70a1141cd6425cefa7 100644
index 8fe119f1ce36ce9ee63a1ba32df0ae8645b6a669..7304b2659eb45bc4bc9fa7c43e6ca07221d0fc73 100644
--- a/src/main/java/net/minecraft/world/level/block/SpongeBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/SpongeBlock.java
@@ -129,8 +129,11 @@ public class SpongeBlock extends Block {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Don't allow digging into unloaded chunks
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index 91d6885da13138e1def16e1876910ef893ce244d..eb58536e37af9da5e3ae7e43f874a1ef09c20944 100644
index 53717a4a2bfd841346c00b5f854899e23661122c..3fadf6b46cc722ad81cf810c0761cf717e9f9b78 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -120,8 +120,8 @@ public class ServerPlayerGameMode {
@@ -119,8 +119,8 @@ public class ServerPlayerGameMode {
BlockState iblockdata;
if (this.hasDelayedDestroy) {
@ -19,7 +19,7 @@ index 91d6885da13138e1def16e1876910ef893ce244d..eb58536e37af9da5e3ae7e43f874a1ef
this.hasDelayedDestroy = false;
} else {
float f = this.incrementDestroyProgress(iblockdata, this.delayedDestroyPos, this.delayedTickStart);
@@ -132,7 +132,13 @@ public class ServerPlayerGameMode {
@@ -131,7 +131,13 @@ public class ServerPlayerGameMode {
}
}
} else if (this.isDestroyingBlock) {
@ -34,44 +34,44 @@ index 91d6885da13138e1def16e1876910ef893ce244d..eb58536e37af9da5e3ae7e43f874a1ef
if (iblockdata.isAir()) {
this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1);
this.lastSentState = -1;
@@ -164,6 +170,7 @@ public class ServerPlayerGameMode {
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
@@ -160,6 +166,7 @@ public class ServerPlayerGameMode {
if (d3 > 36.0D) {
public void handleBlockBreakAction(BlockPos pos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight, int sequence) {
if (this.player.getEyePosition().distanceToSqr(Vec3.atCenterOf(pos)) > ServerGamePacketListenerImpl.MAX_INTERACTION_DISTANCE) {
+ if (true) return; // Paper - Don't notify if unreasonably far away
BlockState iblockdata;
if (this.player.level.getServer() != null && this.player.chunkPosition().getChessboardDistance(new ChunkPos(pos)) < this.player.level.getServer().getPlayerList().getViewDistance()) {
@@ -304,10 +311,12 @@ public class ServerPlayerGameMode {
this.player.connection.send(new ClientboundBlockBreakAckPacket(pos, this.level.getBlockState(pos), action, true, "stopped destroying"));
this.debugLogging(pos, false, sequence, "too far");
} else if (pos.getY() >= worldHeight) {
this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos)));
@@ -296,10 +303,12 @@ public class ServerPlayerGameMode {
this.debugLogging(pos, true, sequence, "stopped destroying");
} else if (action == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) {
this.isDestroyingBlock = false;
- if (!Objects.equals(this.destroyPos, pos)) {
+ if (!Objects.equals(this.destroyPos, pos) && !BlockPos.ZERO.equals(this.destroyPos)) {
+ if (!Objects.equals(this.destroyPos, pos) && !BlockPos.ZERO.equals(this.destroyPos)) { // Paper
ServerPlayerGameMode.LOGGER.debug("Mismatch in destroy block pos: {} {}", this.destroyPos, pos); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled
- this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1);
- this.player.connection.send(new ClientboundBlockBreakAckPacket(this.destroyPos, this.level.getBlockState(this.destroyPos), action, true, "aborted mismatched destroying"));
- this.debugLogging(pos, true, sequence, "aborted mismatched destroying");
+ BlockState type = this.level.getBlockStateIfLoaded(this.destroyPos); // Paper - don't load unloaded chunks for stale records here
+ if (type != null) this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1); // Paper
+ if (type != null) this.player.connection.send(new ClientboundBlockBreakAckPacket(this.destroyPos, type, action, true, "aborted mismatched destroying")); // Paper
+ if (type != null) this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1);
+ if (type != null) this.debugLogging(pos, true, sequence, "aborted mismatched destroying");
+ this.destroyPos = BlockPos.ZERO; // Paper
}
this.level.destroyBlockProgress(this.player.getId(), pos, -1);
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 6c7b30c0363b7965bc71704d8432cf21c20a1cc7..d160602ac0d69e3a5e5c7ada66c752691321bb00 100644
index eea6bd6fa0e08c6242d13d2458bdcbdb67bfbb57..414d7f007487ee53dfeec8321b414017e0cd1dbd 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1567,7 +1567,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@@ -1597,6 +1597,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
case START_DESTROY_BLOCK:
case ABORT_DESTROY_BLOCK:
case STOP_DESTROY_BLOCK:
+ // Paper start - Don't allow digging in unloaded chunks
+ if (this.player.level.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) == null) {
+ this.player.connection.ackBlockChangesUpTo(packet.getSequence());
+ return;
+ }
this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packet.getDirection(), this.player.level.getMaxBuildHeight());
+ // Paper end - Don't allow digging in unloaded chunks
this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packet.getDirection(), this.player.level.getMaxBuildHeight(), packet.getSequence());
this.player.connection.ackBlockChangesUpTo(packet.getSequence());
return;
default:
throw new IllegalArgumentException("Invalid player action");

View File

@ -42,10 +42,10 @@ index 65df47283afc4aa1453fdd18e65e6f8cb3bd0c3f..80306b595b555d4057975a07872084a8
Object val = config.get("settings.save-player-data");
if (val instanceof Boolean) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index c4c7120808a42dc36fbd85d9a842792797193a55..cf00b51faaefd6607ab11003276a48f394b25f71 100644
index ff47276975bac1dfa83c310a8944ec6335247a54..35a652b6a2c569787ecb32029de05ef1c6c9de6f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2606,6 +2606,11 @@ public final class CraftServer implements Server {
@@ -2589,6 +2589,11 @@ public final class CraftServer implements Server {
return com.destroystokyo.paper.PaperConfig.suggestPlayersWhenNullTabCompletions;
}

View File

@ -7,7 +7,7 @@ If a players inventory is too big to send in a single packet,
split the inventory set into multiple packets instead.
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 7e7d33a843566440f815d779ef2f3db9efc3b92d..97b9c53f695d55f8e7d1cb5b300740028c535b7c 100644
index 311148ba8ca073d522cac81f9a3f66f30eb70909..8e7f7c7ad159c75d8066aa47aa5d8dd2add201eb 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -130,6 +130,15 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@ -101,7 +101,7 @@ index 0e076173033278587df2b5dfbd01cc9005651eb5..dbd8b9b09b82c1b75e8be9dc7416d9f0
public void write(FriendlyByteBuf buf) {
buf.writeByte(this.containerId);
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 36d9308a11bde0a631de037cf1bcae1062eaa5d9..b89965c73bb6f40e688bd29daf6630ccce054100 100644
index 56cc2169077fed1fe820d08dc14b3add63289add..a7e49476b3e0e46f97cb2cb57377f7ffe5146501 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
@@ -50,7 +50,7 @@ public class ClientboundLevelChunkPacketData {

View File

@ -20,10 +20,10 @@ this is going to be the best soultion all around.
Improvements/suggestions welcome!
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index d020dd3ce45835813a40b1432f8e203b1ea9911e..85a6204af67c5f8a9bd0dfc8598a2a2db2e3e4c1 100644
index 222452a5549e29ef43d183390cc41783aeb8f3e9..3e50915041041486dc6dd939609bcd2673cd2ad2 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -1327,11 +1327,13 @@ public class ServerPlayer extends Player {
@@ -1336,11 +1336,13 @@ public class ServerPlayer extends Player {
}
}
@ -41,10 +41,10 @@ index d020dd3ce45835813a40b1432f8e203b1ea9911e..85a6204af67c5f8a9bd0dfc8598a2a2d
if (entity1 != entity && this.connection != null) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 513331442058ee61a08f4ad69b8912fa3e0d6868..44c53588c54fd275d3f0c7bb5febb67838c939ce 100644
index a279b7473a4e3397898707bf232c7866aacee9d1..18fe107cee949495d2eb7525526d96390c04b0d6 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2230,11 +2230,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -2278,11 +2278,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
public void removeVehicle() {
@ -62,7 +62,7 @@ index 513331442058ee61a08f4ad69b8912fa3e0d6868..44c53588c54fd275d3f0c7bb5febb678
}
}
@@ -2297,7 +2302,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -2345,7 +2350,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return true; // CraftBukkit
}
@ -74,7 +74,7 @@ index 513331442058ee61a08f4ad69b8912fa3e0d6868..44c53588c54fd275d3f0c7bb5febb678
if (entity.getVehicle() == this) {
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
} else {
@@ -2307,7 +2315,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -2355,7 +2363,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
VehicleExitEvent event = new VehicleExitEvent(
(Vehicle) this.getBukkitEntity(),
@ -83,7 +83,7 @@ index 513331442058ee61a08f4ad69b8912fa3e0d6868..44c53588c54fd275d3f0c7bb5febb678
);
// Suppress during worldgen
if (this.valid) {
@@ -2321,7 +2329,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -2369,7 +2377,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
// CraftBukkit end
// Spigot start
@ -93,10 +93,10 @@ index 513331442058ee61a08f4ad69b8912fa3e0d6868..44c53588c54fd275d3f0c7bb5febb678
if (this.valid) {
Bukkit.getPluginManager().callEvent(event);
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 1d679a04a49af796074c27d56e8ab07f0b09b002..8f595222d9b797d03558ec060a5f315ccfd369b3 100644
index 370ec54f5c6741e7c9f3630e7f42ea7d7a7d1423..3ea28ff50d409d1d234d17f62207b0585386a607 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3347,9 +3347,15 @@ public abstract class LivingEntity extends Entity {
@@ -3379,9 +3379,15 @@ public abstract class LivingEntity extends Entity {
@Override
public void stopRiding() {
@ -114,10 +114,10 @@ index 1d679a04a49af796074c27d56e8ab07f0b09b002..8f595222d9b797d03558ec060a5f315c
this.dismountVehicle(entity);
}
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index 64a887de47b26d2dfa27b0ed3c4d8c0e00db163b..8a05690556f8f979d268cd7c6b5c14343ad33579 100644
index 8215717bd7267fe553319b03d73416732a07485b..6eb7240850d50528d8fad8dff79ee578e3f9b588 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -1116,7 +1116,13 @@ public abstract class Player extends LivingEntity {
@@ -1162,7 +1162,13 @@ public abstract class Player extends LivingEntity {
@Override
public void removeVehicle() {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Add more Zombie API
diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
index 953f138b6cd48cc94bc23a4321a9684b4214637e..273f5eb930a37046900f706f5f710ae3fcc9b6df 100644
index cf80a2592e923967fa440f8c383a9dc977177638..aa78c218d0709eff043fb7e7f5e9a3f8fa918982 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
@@ -93,6 +93,7 @@ public class Zombie extends Monster {

View File

@ -24,10 +24,10 @@ index 80306b595b555d4057975a07872084a83abe78ae..0be8f68c3e61f132ada9381e36b743dd
private static void asyncChunks() {
ConfigurationSection section;
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index d160602ac0d69e3a5e5c7ada66c752691321bb00..77d62668dc22df5e9be714fa32f7b24d256361a9 100644
index 414d7f007487ee53dfeec8321b414017e0cd1dbd..2d74384ed9ba6d55f88dbf9d82f3a0b4117f49a3 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1016,6 +1016,45 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@@ -1048,6 +1048,45 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@Override
public void handleEditBook(ServerboundEditBookPacket packet) {

View File

@ -34,11 +34,11 @@ how PlayerPreLoginEvent interacts with PlayerConnectionCloseEvent
is undefined.
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 97b9c53f695d55f8e7d1cb5b300740028c535b7c..3559f6c54e7674d3eaf023d2ceaee13edfcae5b2 100644
index 8e7f7c7ad159c75d8066aa47aa5d8dd2add201eb..58e50b56b0e3f1388826c73c4616a1e24852bdbd 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -430,6 +430,26 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
this.getPacketListener().onDisconnect(new TranslatableComponent("multiplayer.disconnect.generic"));
this.getPacketListener().onDisconnect(Component.translatable("multiplayer.disconnect.generic"));
}
this.queue.clear(); // Free up packet queue.
+ // Paper start - Add PlayerConnectionCloseEvent

View File

@ -5,12 +5,12 @@ Subject: [PATCH] Prevent Enderman from loading chunks
diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
index 102cab5a2104d32440ad489847bb7a443beead51..4920f5465298b4da33b53f80b8af6220cb0e8ccc 100644
index 78a8e5905759d975bb4941b5416fb95ea8c74df5..e0e32528ed9f2f494b5ee2079c3167021f2e84c4 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
@@ -489,7 +489,8 @@ public class EnderMan extends Monster implements NeutralMob {
int j = Mth.floor(this.enderman.getY() + random.nextDouble() * 2.0D);
int k = Mth.floor(this.enderman.getZ() - 1.0D + random.nextDouble() * 2.0D);
@@ -493,7 +493,8 @@ public class EnderMan extends Monster implements NeutralMob {
int j = Mth.floor(this.enderman.getY() + randomsource.nextDouble() * 2.0D);
int k = Mth.floor(this.enderman.getZ() - 1.0D + randomsource.nextDouble() * 2.0D);
BlockPos blockposition = new BlockPos(i, j, k);
- BlockState iblockdata = world.getBlockState(blockposition);
+ BlockState iblockdata = world.getBlockStateIfLoaded(blockposition); // Paper
@ -18,9 +18,9 @@ index 102cab5a2104d32440ad489847bb7a443beead51..4920f5465298b4da33b53f80b8af6220
BlockPos blockposition1 = blockposition.below();
BlockState iblockdata1 = world.getBlockState(blockposition1);
BlockState iblockdata2 = this.enderman.getCarriedBlock();
@@ -535,7 +536,8 @@ public class EnderMan extends Monster implements NeutralMob {
int j = Mth.floor(this.enderman.getY() + random.nextDouble() * 3.0D);
int k = Mth.floor(this.enderman.getZ() - 2.0D + random.nextDouble() * 4.0D);
@@ -539,7 +540,8 @@ public class EnderMan extends Monster implements NeutralMob {
int j = Mth.floor(this.enderman.getY() + randomsource.nextDouble() * 3.0D);
int k = Mth.floor(this.enderman.getZ() - 2.0D + randomsource.nextDouble() * 4.0D);
BlockPos blockposition = new BlockPos(i, j, k);
- BlockState iblockdata = world.getBlockState(blockposition);
+ BlockState iblockdata = world.getBlockStateIfLoaded(blockposition); // Paper

View File

@ -16,10 +16,10 @@ intent to remove) and replace it with two new methods, clearly named and
documented as to their purpose.
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 85a6204af67c5f8a9bd0dfc8598a2a2db2e3e4c1..5aebf4d330dda519efb4ab6e7bcdf4ccb174b11a 100644
index 3e50915041041486dc6dd939609bcd2673cd2ad2..8f9218c552a1a4bc56e5396a85b50ff7ad830090 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -221,6 +221,7 @@ public class ServerPlayer extends Player {
@@ -228,6 +228,7 @@ public class ServerPlayer extends Player {
public int latency;
public boolean wonGame;
private int containerUpdateDelay; // Paper
@ -28,10 +28,10 @@ index 85a6204af67c5f8a9bd0dfc8598a2a2db2e3e4c1..5aebf4d330dda519efb4ab6e7bcdf4cc
public boolean queueHealthUpdatePacket = false;
public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket;
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 12451cc9eca34baa5d5ef6e55f4e4a63356365c6..9e3272a85e760e65217bd75c3ba9bfe21979fd35 100644
index cf3cca43a2eb2a3731112fef37b0ac4a0676ecf5..8ff7ae4af69cd62419b6c51c7a7d957a6550c7b9 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -173,6 +173,7 @@ public abstract class PlayerList {
@@ -177,6 +177,7 @@ public abstract class PlayerList {
}
public void placeNewPlayer(Connection connection, ServerPlayer player) {
@ -106,10 +106,10 @@ index f6665825e62a0cd912e6b06df6d68795596486f0..1f2bc88d4570c6ef00e67a772b745e0b
public Location getBedSpawnLocation() {
CompoundTag data = this.getData();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 2922c1b4d2e5a18c7c54be4a3a81782241f67367..5b06b7d97d77805debd8eb1eb3e0ed64be750bd4 100644
index f14c0dd16b2b9bd2d3bdfbc786176bc18cc76dcf..dae6fc86e5578e7ffa91a0180ed654249f039645 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -171,6 +171,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -169,6 +169,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
private org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus;
private String resourcePackHash;
private static final boolean DISABLE_CHANNEL_LIMIT = System.getProperty("paper.disableChannelLimit") != null; // Paper - add a flag to disable the channel limit
@ -117,7 +117,7 @@ index 2922c1b4d2e5a18c7c54be4a3a81782241f67367..5b06b7d97d77805debd8eb1eb3e0ed64
// Paper end
public CraftPlayer(CraftServer server, ServerPlayer entity) {
@@ -1670,6 +1671,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -1668,6 +1669,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
this.firstPlayed = firstPlayed;
}
@ -136,7 +136,7 @@ index 2922c1b4d2e5a18c7c54be4a3a81782241f67367..5b06b7d97d77805debd8eb1eb3e0ed64
public void readExtraData(CompoundTag nbttagcompound) {
this.hasPlayedBefore = true;
if (nbttagcompound.contains("bukkit")) {
@@ -1692,6 +1705,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -1690,6 +1703,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
public void setExtraData(CompoundTag nbttagcompound) {
@ -145,7 +145,7 @@ index 2922c1b4d2e5a18c7c54be4a3a81782241f67367..5b06b7d97d77805debd8eb1eb3e0ed64
if (!nbttagcompound.contains("bukkit")) {
nbttagcompound.put("bukkit", new CompoundTag());
}
@@ -1706,6 +1721,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -1704,6 +1719,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
data.putLong("firstPlayed", this.getFirstPlayed());
data.putLong("lastPlayed", System.currentTimeMillis());
data.putString("lastKnownName", handle.getScoreboardName());

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Workaround for vehicle tracking issue on disconnect
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 5aebf4d330dda519efb4ab6e7bcdf4ccb174b11a..b26c4933d4b8e782e9cf5de3371162d30b304954 100644
index 8f9218c552a1a4bc56e5396a85b50ff7ad830090..67b4e7c887e012f32ea2a269717373568efed212 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -1569,6 +1569,13 @@ public class ServerPlayer extends Player {
@@ -1578,6 +1578,13 @@ public class ServerPlayer extends Player {
public void disconnect() {
this.disconnected = true;
this.ejectPassengers();

View File

@ -12,10 +12,10 @@ Player we will look at limiting the scope of this change. It appears to
be unintentional in the few cases we've seen so far.
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 5b06b7d97d77805debd8eb1eb3e0ed64be750bd4..c539620e56e05398d0fd0c6f3d721609398f3834 100644
index dae6fc86e5578e7ffa91a0180ed654249f039645..52b00369facc700079dbddc35291072977c2b8ce 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2542,6 +2542,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -2553,6 +2553,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void resetCooldown() {
getHandle().resetAttackStrengthTicker();
}

View File

@ -11,10 +11,10 @@ floating in the air.
This can replace many uses of BlockPhysicsEvent
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index dc2235824853a0d7ccbff51dd26a71e97fe90ba7..a00b4c84cc27678c07d0195a90f38dc458a11862 100644
index 36264caae95b4ab69412a60f24e1e926df424fa0..3b2357eb2844d9e8cf00a43884759da60b9327eb 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -29,6 +29,7 @@ import net.minecraft.nbt.CompoundTag;
@@ -28,6 +28,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
@ -22,7 +22,7 @@ index dc2235824853a0d7ccbff51dd26a71e97fe90ba7..a00b4c84cc27678c07d0195a90f38dc4
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ServerLevel;
@@ -563,8 +564,20 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -574,8 +575,20 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return false;
} else {
FluidState fluid = this.getFluidState(pos);

View File

@ -5,18 +5,18 @@ Subject: [PATCH] Async command map building
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
index 7d6b416f0889221d63233f8650c530467ea8fbd7..f3bbe012541a71ab75c1863990d0c056c62d8c6e 100644
index a4d4b5059582cb5886f10e72bd5e8d84fe0b8441..4c9773997c63f7b2c8465b19810068f11367466b 100644
--- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java
@@ -31,6 +31,7 @@ import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
@@ -31,6 +31,7 @@ import net.minecraft.network.chat.ComponentUtils;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.protocol.game.ClientboundCommandsPacket;
+import net.minecraft.server.MinecraftServer;
import net.minecraft.server.commands.AdvancementCommands;
import net.minecraft.server.commands.AttributeCommand;
import net.minecraft.server.commands.BanIpCommands;
@@ -346,6 +347,12 @@ public class Commands {
@@ -349,6 +350,12 @@ public class Commands {
if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot
// CraftBukkit start
// Register Vanilla commands into builtRoot as before
@ -29,7 +29,7 @@ index 7d6b416f0889221d63233f8650c530467ea8fbd7..f3bbe012541a71ab75c1863990d0c056
Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
RootCommandNode vanillaRoot = new RootCommandNode();
@@ -363,7 +370,14 @@ public class Commands {
@@ -366,7 +373,14 @@ public class Commands {
for (CommandNode node : rootcommandnode.getChildren()) {
bukkit.add(node.getName());
}

View File

@ -10,7 +10,7 @@ Adds CommandRegisteredEvent
- Allows manipulating the CommandNode to add more children/metadata for the client
diff --git a/build.gradle.kts b/build.gradle.kts
index 004b37cddc8e5e4cb4643f52eb58254796886fe7..5a609a297ccfa66859b04eb907595741b8ec2160 100644
index 344787b84f91627e4f33288c75eacd2bca7bcc3f..7dd1c9449a1e6a9197e2915399feabf63f490b0a 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -8,6 +8,7 @@ plugins {
@ -22,20 +22,20 @@ index 004b37cddc8e5e4cb4643f52eb58254796886fe7..5a609a297ccfa66859b04eb907595741
implementation("org.jline:jline-terminal-jansi:3.21.0")
implementation("net.minecrell:terminalconsoleappender:1.3.0")
diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java
index 5ebf717535eab892898a62ce6aaaf936fe064626..31aaad639b6c285226ca7aca1bd2285cfe0d9117 100644
index cd7c33862c7e2e3895efce8a9675aa6a07a8053f..0b8d8b9875acf4c0a6bd47941ff57d01285dd507 100644
--- a/src/main/java/net/minecraft/commands/CommandSourceStack.java
+++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java
@@ -38,7 +38,7 @@ import net.minecraft.world.phys.Vec2;
@@ -36,7 +36,7 @@ import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
import com.mojang.brigadier.tree.CommandNode; // CraftBukkit
-public class CommandSourceStack implements SharedSuggestionProvider {
+public class CommandSourceStack implements SharedSuggestionProvider, com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource { // Paper
public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(new TranslatableComponent("permissions.requires.player"));
public static final SimpleCommandExceptionType ERROR_NOT_ENTITY = new SimpleCommandExceptionType(new TranslatableComponent("permissions.requires.entity"));
@@ -155,6 +155,25 @@ public class CommandSourceStack implements SharedSuggestionProvider {
return this.textName;
public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(Component.translatable("permissions.requires.player"));
public static final SimpleCommandExceptionType ERROR_NOT_ENTITY = new SimpleCommandExceptionType(Component.translatable("permissions.requires.entity"));
@@ -163,6 +163,25 @@ public class CommandSourceStack implements SharedSuggestionProvider {
return this.entity != null ? this.entity.asChatSender() : ChatSender.system(this.getDisplayName());
}
+ // Paper start
@ -61,10 +61,10 @@ index 5ebf717535eab892898a62ce6aaaf936fe064626..31aaad639b6c285226ca7aca1bd2285c
public boolean hasPermission(int level) {
// CraftBukkit start
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
index f3bbe012541a71ab75c1863990d0c056c62d8c6e..4bc28b66788d06d1446284f5adef6a44be736f92 100644
index 4c9773997c63f7b2c8465b19810068f11367466b..a8f3a84615a640d2949d268ef1ac81a051f5a38b 100644
--- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java
@@ -371,6 +371,7 @@ public class Commands {
@@ -374,6 +374,7 @@ public class Commands {
bukkit.add(node.getName());
}
// Paper start - Async command map building
@ -72,7 +72,7 @@ index f3bbe012541a71ab75c1863990d0c056c62d8c6e..4bc28b66788d06d1446284f5adef6a44
MinecraftServer.getServer().execute(() -> {
runSync(player, bukkit, rootcommandnode);
});
@@ -378,6 +379,7 @@ public class Commands {
@@ -381,6 +382,7 @@ public class Commands {
private void runSync(ServerPlayer player, Collection<String> bukkit, RootCommandNode<SharedSuggestionProvider> rootcommandnode) {
// Paper end - Async command map building
@ -81,10 +81,10 @@ index f3bbe012541a71ab75c1863990d0c056c62d8c6e..4bc28b66788d06d1446284f5adef6a44
event.getPlayer().getServer().getPluginManager().callEvent(event);
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 77d62668dc22df5e9be714fa32f7b24d256361a9..95853e761f7c22b251d722031d068475733435ef 100644
index 2d74384ed9ba6d55f88dbf9d82f3a0b4117f49a3..90da4b1e636419aa8c35ab1a06b037f5c7b328f7 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -757,8 +757,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@@ -789,8 +789,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
ParseResults<CommandSourceStack> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
@ -99,7 +99,7 @@ index 77d62668dc22df5e9be714fa32f7b24d256361a9..95853e761f7c22b251d722031d068475
});
});
}
@@ -767,7 +771,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@@ -799,7 +803,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
builder = builder.createOffset(builder.getInput().lastIndexOf(' ') + 1);
completions.forEach(builder::suggest);

View File

@ -22,30 +22,35 @@ it only impacts data sent from the client.
Set -DPaper.maxSignLength=XX to change limit or -1 to disable
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 95853e761f7c22b251d722031d068475733435ef..9933821711eab76bb08be74252639dc3093dfb88 100644
index 90da4b1e636419aa8c35ab1a06b037f5c7b328f7..ea764d2b935c42f88e8dcaff6ba85e5122dbbcc6 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -254,6 +254,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
private int aboveGroundVehicleTickCount;
private int receivedMovePacketCount;
private int knownMovePacketCount;
+ private static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80);
@@ -275,6 +275,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
private final ChatPreviewThrottler chatPreviewThrottler = new ChatPreviewThrottler();
private final AtomicReference<Instant> lastChatTimeStamp;
private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit
+ private static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80); // Paper
public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player) {
@@ -2893,6 +2894,15 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
this.lastChatTimeStamp = new AtomicReference(Instant.EPOCH);
@@ -3046,7 +3047,19 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
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
+ 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()) {
+ 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
+ }
@Override
public void handleSignUpdate(ServerboundSignUpdatePacket packet) {
- List<String> list = (List) Stream.of(packet.getLines()).map(ChatFormatting::stripFormatting).collect(Collectors.toList());
+ // Paper start - cap line length - modified clients can send longer data than normal
+ String[] lines = packet.getLines();
+ for (int i = 0; i < lines.length; ++i) {
+ if (MAX_SIGN_LINE_LENGTH > 0 && lines[i].length() > MAX_SIGN_LINE_LENGTH) {
+ // This handles multibyte characters as 1
+ int offset = lines[i].codePoints().limit(MAX_SIGN_LINE_LENGTH).map(Character::charCount).sum();
+ if (offset < lines[i].length()) {
+ lines[i] = lines[i].substring(0, offset); // this will break any filtering, but filtering is NYI as of 1.17
+ }
+ // Paper end
+ }
+ }
+ List<String> list = (List) Stream.of(lines).map(ChatFormatting::stripFormatting).collect(Collectors.toList());
+ // Paper end
if (this.player.isTextFilteringEnabled()) {
lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(currentLine.getFiltered())));
this.filterTextPacket(list, (list1) -> {
this.updateSignText(packet, list1);