mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-23 15:29:34 +01:00
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:
parent
9ced122cc9
commit
dc953ea414
18 changed files with 45 additions and 40 deletions
|
@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
--- a/src/main/java/net/minecraft/network/Connection.java
|
--- a/src/main/java/net/minecraft/network/Connection.java
|
||||||
+++ b/src/main/java/net/minecraft/network/Connection.java
|
+++ b/src/main/java/net/minecraft/network/Connection.java
|
||||||
@@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
@@ -0,0 +0,0 @@ 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.
|
this.queue.clear(); // Free up packet queue.
|
||||||
+ // Paper start - Add PlayerConnectionCloseEvent
|
+ // Paper start - Add PlayerConnectionCloseEvent
|
|
@ -8,9 +8,9 @@ diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/commands/Commands.java
|
--- a/src/main/java/net/minecraft/commands/Commands.java
|
||||||
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
||||||
@@ -0,0 +0,0 @@ import net.minecraft.network.chat.MutableComponent;
|
@@ -0,0 +0,0 @@ import net.minecraft.network.chat.ComponentUtils;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.HoverEvent;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import net.minecraft.network.protocol.game.ClientboundCommandsPacket;
|
import net.minecraft.network.protocol.game.ClientboundCommandsPacket;
|
||||||
+import net.minecraft.server.MinecraftServer;
|
+import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.commands.AdvancementCommands;
|
import net.minecraft.server.commands.AdvancementCommands;
|
|
@ -35,25 +35,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1);
|
this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1);
|
||||||
this.lastSentState = -1;
|
this.lastSentState = -1;
|
||||||
@@ -0,0 +0,0 @@ public class ServerPlayerGameMode {
|
@@ -0,0 +0,0 @@ public class ServerPlayerGameMode {
|
||||||
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
|
|
||||||
|
|
||||||
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
|
+ if (true) return; // Paper - Don't notify if unreasonably far away
|
||||||
BlockState iblockdata;
|
this.debugLogging(pos, false, sequence, "too far");
|
||||||
|
} else if (pos.getY() >= worldHeight) {
|
||||||
if (this.player.level.getServer() != null && this.player.chunkPosition().getChessboardDistance(new ChunkPos(pos)) < this.player.level.getServer().getPlayerList().getViewDistance()) {
|
this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos)));
|
||||||
@@ -0,0 +0,0 @@ public class ServerPlayerGameMode {
|
@@ -0,0 +0,0 @@ public class ServerPlayerGameMode {
|
||||||
this.player.connection.send(new ClientboundBlockBreakAckPacket(pos, this.level.getBlockState(pos), action, true, "stopped destroying"));
|
this.debugLogging(pos, true, sequence, "stopped destroying");
|
||||||
} else if (action == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) {
|
} else if (action == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) {
|
||||||
this.isDestroyingBlock = false;
|
this.isDestroyingBlock = false;
|
||||||
- if (!Objects.equals(this.destroyPos, pos)) {
|
- 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
|
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.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
|
+ 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.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1);
|
||||||
+ if (type != null) this.player.connection.send(new ClientboundBlockBreakAckPacket(this.destroyPos, type, action, true, "aborted mismatched destroying")); // Paper
|
+ if (type != null) this.debugLogging(pos, true, sequence, "aborted mismatched destroying");
|
||||||
+ this.destroyPos = BlockPos.ZERO; // Paper
|
+ this.destroyPos = BlockPos.ZERO; // Paper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,10 +68,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
case STOP_DESTROY_BLOCK:
|
case STOP_DESTROY_BLOCK:
|
||||||
+ // Paper start - Don't allow digging in unloaded chunks
|
+ // Paper start - Don't allow digging in unloaded chunks
|
||||||
+ if (this.player.level.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) == null) {
|
+ if (this.player.level.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) == null) {
|
||||||
|
+ this.player.connection.ackBlockChangesUpTo(packet.getSequence());
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packet.getDirection(), this.player.level.getMaxBuildHeight());
|
|
||||||
+ // Paper end - Don't allow digging in unloaded chunks
|
+ // 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;
|
return;
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Invalid player action");
|
|
|
@ -32,10 +32,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
-public class CommandSourceStack implements SharedSuggestionProvider {
|
-public class CommandSourceStack implements SharedSuggestionProvider {
|
||||||
+public class CommandSourceStack implements SharedSuggestionProvider, com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource { // Paper
|
+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_PLAYER = new SimpleCommandExceptionType(Component.translatable("permissions.requires.player"));
|
||||||
public static final SimpleCommandExceptionType ERROR_NOT_ENTITY = new SimpleCommandExceptionType(new TranslatableComponent("permissions.requires.entity"));
|
public static final SimpleCommandExceptionType ERROR_NOT_ENTITY = new SimpleCommandExceptionType(Component.translatable("permissions.requires.entity"));
|
||||||
@@ -0,0 +0,0 @@ public class CommandSourceStack implements SharedSuggestionProvider {
|
@@ -0,0 +0,0 @@ public class CommandSourceStack implements SharedSuggestionProvider {
|
||||||
return this.textName;
|
return this.entity != null ? this.entity.asChatSender() : ChatSender.system(this.getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Paper start
|
+ // Paper start
|
|
@ -26,26 +26,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
+++ b/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
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||||
private int aboveGroundVehicleTickCount;
|
private final ChatPreviewThrottler chatPreviewThrottler = new ChatPreviewThrottler();
|
||||||
private int receivedMovePacketCount;
|
private final AtomicReference<Instant> lastChatTimeStamp;
|
||||||
private int knownMovePacketCount;
|
|
||||||
+ private static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80);
|
|
||||||
private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit
|
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) {
|
public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player) {
|
||||||
|
this.lastChatTimeStamp = new AtomicReference(Instant.EPOCH);
|
||||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||||
|
|
||||||
for (int i = 0; i < signText.size(); ++i) {
|
@Override
|
||||||
TextFilter.FilteredText currentLine = signText.get(i);
|
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
|
+ // 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) {
|
+ 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
|
+ // This handles multibyte characters as 1
|
||||||
+ int offset = currentLine.getRaw().codePoints().limit(MAX_SIGN_LINE_LENGTH).map(Character::charCount).sum();
|
+ int offset = lines[i].codePoints().limit(MAX_SIGN_LINE_LENGTH).map(Character::charCount).sum();
|
||||||
+ if (offset < currentLine.getRaw().length()) {
|
+ if (offset < lines[i].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
|
+ lines[i] = lines[i].substring(0, offset); // this will break any filtering, but filtering is NYI as of 1.17
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
+ }
|
||||||
|
+ List<String> list = (List) Stream.of(lines).map(ChatFormatting::stripFormatting).collect(Collectors.toList());
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
|
||||||
if (this.player.isTextFilteringEnabled()) {
|
this.filterTextPacket(list, (list1) -> {
|
||||||
lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(currentLine.getFiltered())));
|
this.updateSignText(packet, list1);
|
|
@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
||||||
@@ -0,0 +0,0 @@ public class EnderMan extends Monster implements NeutralMob {
|
@@ -0,0 +0,0 @@ public class EnderMan extends Monster implements NeutralMob {
|
||||||
int j = Mth.floor(this.enderman.getY() + random.nextDouble() * 2.0D);
|
int j = Mth.floor(this.enderman.getY() + randomsource.nextDouble() * 2.0D);
|
||||||
int k = Mth.floor(this.enderman.getZ() - 1.0D + random.nextDouble() * 2.0D);
|
int k = Mth.floor(this.enderman.getZ() - 1.0D + randomsource.nextDouble() * 2.0D);
|
||||||
BlockPos blockposition = new BlockPos(i, j, k);
|
BlockPos blockposition = new BlockPos(i, j, k);
|
||||||
- BlockState iblockdata = world.getBlockState(blockposition);
|
- BlockState iblockdata = world.getBlockState(blockposition);
|
||||||
+ BlockState iblockdata = world.getBlockStateIfLoaded(blockposition); // Paper
|
+ BlockState iblockdata = world.getBlockStateIfLoaded(blockposition); // Paper
|
||||||
|
@ -19,8 +19,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
BlockState iblockdata1 = world.getBlockState(blockposition1);
|
BlockState iblockdata1 = world.getBlockState(blockposition1);
|
||||||
BlockState iblockdata2 = this.enderman.getCarriedBlock();
|
BlockState iblockdata2 = this.enderman.getCarriedBlock();
|
||||||
@@ -0,0 +0,0 @@ public class EnderMan extends Monster implements NeutralMob {
|
@@ -0,0 +0,0 @@ public class EnderMan extends Monster implements NeutralMob {
|
||||||
int j = Mth.floor(this.enderman.getY() + random.nextDouble() * 3.0D);
|
int j = Mth.floor(this.enderman.getY() + randomsource.nextDouble() * 3.0D);
|
||||||
int k = Mth.floor(this.enderman.getZ() - 2.0D + random.nextDouble() * 4.0D);
|
int k = Mth.floor(this.enderman.getZ() - 2.0D + randomsource.nextDouble() * 4.0D);
|
||||||
BlockPos blockposition = new BlockPos(i, j, k);
|
BlockPos blockposition = new BlockPos(i, j, k);
|
||||||
- BlockState iblockdata = world.getBlockState(blockposition);
|
- BlockState iblockdata = world.getBlockState(blockposition);
|
||||||
+ BlockState iblockdata = world.getBlockStateIfLoaded(blockposition); // Paper
|
+ BlockState iblockdata = world.getBlockStateIfLoaded(blockposition); // Paper
|
Loading…
Add table
Reference in a new issue