Package net.minecraft.server.network
Class ServerGamePacketListenerImpl
java.lang.Object
net.minecraft.server.network.ServerCommonPacketListenerImpl
net.minecraft.server.network.ServerGamePacketListenerImpl
- All Implemented Interfaces:
PacketListener
,ServerCommonPacketListener
,ServerCookiePacketListener
,ServerGamePacketListener
,ServerPacketListener
,ServerPingPacketListener
,ServerboundPacketListener
,TickablePacketListener
,ServerPlayerConnection
,ICommonPacketListener
,IServerCommonPacketListenerExtension
,IServerGamePacketListenerExtension
- Direct Known Subclasses:
FakePlayer.FakePlayerNetHandler
public class ServerGamePacketListenerImpl
extends ServerCommonPacketListenerImpl
implements ServerGamePacketListener, ServerPlayerConnection, TickablePacketListener
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
Used to keep track of how the player is floating while gamerules should prevent that.private int
private int
private Vec3
private int
private int
private static final Component
private final FutureChain
private RemoteChatSession
private int
Incremented by 20 each time a user sends a chat message, decreased by one every tick.final PlayerChunkSender
private boolean
private boolean
private int
private double
private double
private double
private static final Component
private int
private double
private double
private double
private final LastSeenMessagesValidator
private Entity
(package private) static final org.slf4j.Logger
private static final int
private static final int
private final MessageSignatureCache
private static final int
private int
private SignedMessageChain.Decoder
private int
private static final int
private double
private double
private double
private double
private double
private double
private boolean
Fields inherited from class net.minecraft.server.network.ServerCommonPacketListenerImpl
connection, connectionType, DISCONNECT_UNEXPECTED_QUERY, LATENCY_CHECK_INTERVAL, server
-
Constructor Summary
ConstructorsConstructorDescriptionServerGamePacketListenerImpl
(MinecraftServer pServer, Connection pConnection, ServerPlayer pPlayer, CommonListenerCookie pCookie) -
Method Summary
Modifier and TypeMethodDescriptionvoid
ackBlockChangesUpTo
(int pSequence) void
addPendingMessage
(PlayerChatMessage pMessage) private void
broadcastChatMessage
(PlayerChatMessage pMessage) private static double
clampHorizontal
(double pValue) private static double
clampVertical
(double pValue) private <S> Map
<String, PlayerChatMessage> collectSignedArguments
(ServerboundChatCommandSignedPacket pPacket, SignableCommand<S> pCommand, LastSeenMessages pLastSeenMessages) private <S> Map
<String, PlayerChatMessage> collectUnsignedArguments
(List<SignableCommand.Argument<S>> pArguments) private static boolean
containsInvalidValues
(double pX, double pY, double pZ, float pYRot, float pXRot) private static <S> SignedMessageChain.DecodeException
createSignedArgumentMismatchException
(String pCommand, List<ArgumentSignatures.Entry> pSignedArguments, List<SignableCommand.Argument<S>> pUnsignedArguments) private void
private Filterable
<String> filterableFromOutgoing
(FilteredText p_332041_) private CompletableFuture
<FilteredText> filterTextPacket
(String pText) private CompletableFuture
<List<FilteredText>> filterTextPacket
(List<String> pTexts) private <T,
R> CompletableFuture <R> filterTextPacket
(T pMessage, BiFunction<TextFilter, T, CompletableFuture<R>> pProcessor) private int
getMaximumFlyingTicks
(Entity pEntity) private PlayerChatMessage
getSignedMessage
(ServerboundChatPacket pPacket, LastSeenMessages pLastSeenMessages) void
void
handleAnimate
(ServerboundSwingPacket pPacket) void
void
void
handleChat
(ServerboundChatPacket pPacket) Process chat messages (broadcast back to clients) and commands (executes)void
handleChatAck
(ServerboundChatAckPacket pPacket) void
void
void
void
Processes the client status updates: respawn attempt from player, opening statistics or achievements, or acquiring 'open inventory' achievementvoid
void
void
Enchants the item identified by the packet given some convoluted conditions (matching window, which should/shouldn't be in use?)void
Executes a container/inventory slot manipulation as indicated by the packet.void
Processes the client closing windows (container)void
void
This method is only called for manual tab-completion (theminecraft:ask_server
suggestion provider).void
void
void
handleEditBook
(ServerboundEditBookPacket pPacket) void
void
handleInteract
(ServerboundInteractPacket pPacket) Processes left and right clicks on entitiesvoid
void
private void
void
Processes clients perspective on player positioning and/or orientationvoid
void
void
handlePickItem
(ServerboundPickItemPacket pPacket) void
void
void
Processes a player starting/stopping flyingvoid
Processes the player initiating/stopping digging on a particular spot, as well as a player dropping itemsvoid
Processes a range of action-types: sneaking, sprinting, waking from sleep, opening the inventory or setting jump height of the horse the player is ridingvoid
Processes player movement input.void
void
void
void
void
void
void
Updates which quickbar slot is selectedvoid
void
void
Update the server with an ItemStack in a slot.void
void
void
void
void
void
handleUseItem
(ServerboundUseItemPacket pPacket) Called when a client is using an item while not pointing at a block, but simply using an itemvoid
boolean
private static boolean
isChatMessageIllegal
(String pMessage) private boolean
isPlayerCollidingWithAnythingNew
(LevelReader pLevel, AABB pBox, double pX, double pY, double pZ) private boolean
noBlocksAround
(Entity pEntity) void
onDisconnect
(DisconnectionDetails pDetails) private com.mojang.brigadier.ParseResults
<CommandSourceStack> parseCommand
(String p_242938_) private void
performSignedChatCommand
(ServerboundChatCommandSignedPacket pPacket, LastSeenMessages pLastSeenMessages) private void
performUnsignedChatCommand
(String pCommand) protected com.mojang.authlib.GameProfile
private void
private void
resetPlayerChatState
(RemoteChatSession pChatSession) void
private void
resyncPlayerWithVehicle
(Entity vehicle) void
sendDisguisedChatMessage
(Component pMessage, ChatType.Bound pBoundType) void
sendPlayerChatMessage
(PlayerChatMessage pChatMessage, ChatType.Bound pBoundType) boolean
shouldHandleMessage
(Packet<?> pPacket) private void
signBook
(FilteredText pTitle, List<FilteredText> pPages, int pIndex) void
void
teleport
(double pX, double pY, double pZ, float pYaw, float pPitch) void
teleport
(double pX, double pY, double pZ, float pYaw, float pPitch, Set<RelativeMovement> pRelativeSet) Teleports the player position to the (relative) values specified, and syncs to the clientvoid
tick()
private void
tryHandleChat
(String pMessage, Runnable pHandler) private Optional
<LastSeenMessages> private boolean
private void
updateBookContents
(List<FilteredText> pPages, int pIndex) private void
updateSignText
(ServerboundSignUpdatePacket pPacket, List<FilteredText> pFilteredText) private static boolean
wasBlockPlacementAttempt
(ServerPlayer pPlayer, ItemStack pStack) Methods inherited from class net.minecraft.server.network.ServerCommonPacketListenerImpl
createCookie, createCookie, disconnect, disconnect, getConnection, getConnectionType, getMainThreadEventLoop, getOwner, handleCookieResponse, handleKeepAlive, handlePong, handleResourcePackResponse, isSingleplayerOwner, keepConnectionAlive, latency, resumeFlushing, send, send, suspendFlushing
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.neoforged.neoforge.common.extensions.ICommonPacketListener
disconnect, getConnection, getConnectionType, getMainThreadEventLoop, hasChannel, hasChannel, hasChannel, send
Methods inherited from interface net.neoforged.neoforge.common.extensions.IServerCommonPacketListenerExtension
send, send, send
Methods inherited from interface net.neoforged.neoforge.common.extensions.IServerGamePacketListenerExtension
sendBundled, sendBundled
Methods inherited from interface net.minecraft.network.PacketListener
createDisconnectionInfo, fillCrashReport, fillListenerSpecificCrashDetails
Methods inherited from interface net.minecraft.network.ServerboundPacketListener
flow
Methods inherited from interface net.minecraft.network.protocol.common.ServerCommonPacketListener
handleKeepAlive, handlePong, handleResourcePackResponse
Methods inherited from interface net.minecraft.network.protocol.cookie.ServerCookiePacketListener
handleCookieResponse
Methods inherited from interface net.minecraft.network.protocol.game.ServerGamePacketListener
protocol
Methods inherited from interface net.minecraft.network.protocol.game.ServerPacketListener
onPacketError
Methods inherited from interface net.minecraft.server.network.ServerPlayerConnection
send
-
Field Details
-
LOGGER
static final org.slf4j.Logger LOGGER -
NO_BLOCK_UPDATES_TO_ACK
private static final int NO_BLOCK_UPDATES_TO_ACK- See Also:
-
TRACKED_MESSAGE_DISCONNECT_THRESHOLD
private static final int TRACKED_MESSAGE_DISCONNECT_THRESHOLD- See Also:
-
MAXIMUM_FLYING_TICKS
private static final int MAXIMUM_FLYING_TICKS- See Also:
-
CHAT_VALIDATION_FAILED
-
INVALID_COMMAND_SIGNATURE
-
MAX_COMMAND_SUGGESTIONS
private static final int MAX_COMMAND_SUGGESTIONS- See Also:
-
player
-
chunkSender
-
tickCount
private int tickCount -
ackBlockChangesUpTo
private int ackBlockChangesUpTo -
chatSpamTickCount
private int chatSpamTickCountIncremented by 20 each time a user sends a chat message, decreased by one every tick. Non-ops kicked when over 200 -
dropSpamTickCount
private int dropSpamTickCount -
firstGoodX
private double firstGoodX -
firstGoodY
private double firstGoodY -
firstGoodZ
private double firstGoodZ -
lastGoodX
private double lastGoodX -
lastGoodY
private double lastGoodY -
lastGoodZ
private double lastGoodZ -
lastVehicle
-
vehicleFirstGoodX
private double vehicleFirstGoodX -
vehicleFirstGoodY
private double vehicleFirstGoodY -
vehicleFirstGoodZ
private double vehicleFirstGoodZ -
vehicleLastGoodX
private double vehicleLastGoodX -
vehicleLastGoodY
private double vehicleLastGoodY -
vehicleLastGoodZ
private double vehicleLastGoodZ -
awaitingPositionFromClient
-
awaitingTeleport
private int awaitingTeleport -
awaitingTeleportTime
private int awaitingTeleportTime -
clientIsFloating
private boolean clientIsFloating -
aboveGroundTickCount
private int aboveGroundTickCountUsed to keep track of how the player is floating while gamerules should prevent that. Surpassing 80 ticks means kick -
clientVehicleIsFloating
private boolean clientVehicleIsFloating -
aboveGroundVehicleTickCount
private int aboveGroundVehicleTickCount -
receivedMovePacketCount
private int receivedMovePacketCount -
knownMovePacketCount
private int knownMovePacketCount -
chatSession
-
signedMessageDecoder
-
lastSeenMessages
-
messageSignatureCache
-
chatMessageChain
-
waitingForSwitchToConfig
private boolean waitingForSwitchToConfig
-
-
Constructor Details
-
ServerGamePacketListenerImpl
public ServerGamePacketListenerImpl(MinecraftServer pServer, Connection pConnection, ServerPlayer pPlayer, CommonListenerCookie pCookie)
-
-
Method Details
-
tick
public void tick()- Specified by:
tick
in interfaceTickablePacketListener
-
getMaximumFlyingTicks
-
resetPosition
public void resetPosition() -
isAcceptingMessages
public boolean isAcceptingMessages()- Specified by:
isAcceptingMessages
in interfacePacketListener
-
shouldHandleMessage
- Specified by:
shouldHandleMessage
in interfacePacketListener
-
playerProfile
protected com.mojang.authlib.GameProfile playerProfile()- Specified by:
playerProfile
in classServerCommonPacketListenerImpl
-
filterTextPacket
private <T,R> CompletableFuture<R> filterTextPacket(T pMessage, BiFunction<TextFilter, T, CompletableFuture<R>> pProcessor) -
filterTextPacket
-
filterTextPacket
-
handlePlayerInput
Processes player movement input. Includes walking, strafing, jumping, and sneaking. Excludes riding and toggling flying/sprinting.- Specified by:
handlePlayerInput
in interfaceServerGamePacketListener
-
containsInvalidValues
private static boolean containsInvalidValues(double pX, double pY, double pZ, float pYRot, float pXRot) -
clampHorizontal
private static double clampHorizontal(double pValue) -
clampVertical
private static double clampVertical(double pValue) -
handleMoveVehicle
- Specified by:
handleMoveVehicle
in interfaceServerGamePacketListener
-
resyncPlayerWithVehicle
-
noBlocksAround
-
handleAcceptTeleportPacket
- Specified by:
handleAcceptTeleportPacket
in interfaceServerGamePacketListener
-
handleRecipeBookSeenRecipePacket
- Specified by:
handleRecipeBookSeenRecipePacket
in interfaceServerGamePacketListener
-
handleRecipeBookChangeSettingsPacket
- Specified by:
handleRecipeBookChangeSettingsPacket
in interfaceServerGamePacketListener
-
handleSeenAdvancements
- Specified by:
handleSeenAdvancements
in interfaceServerGamePacketListener
-
handleCustomCommandSuggestions
This method is only called for manual tab-completion (theminecraft:ask_server
suggestion provider).- Specified by:
handleCustomCommandSuggestions
in interfaceServerGamePacketListener
-
handleSetCommandBlock
- Specified by:
handleSetCommandBlock
in interfaceServerGamePacketListener
-
handleSetCommandMinecart
- Specified by:
handleSetCommandMinecart
in interfaceServerGamePacketListener
-
handlePickItem
- Specified by:
handlePickItem
in interfaceServerGamePacketListener
-
handleRenameItem
- Specified by:
handleRenameItem
in interfaceServerGamePacketListener
-
handleSetBeaconPacket
- Specified by:
handleSetBeaconPacket
in interfaceServerGamePacketListener
-
handleSetStructureBlock
- Specified by:
handleSetStructureBlock
in interfaceServerGamePacketListener
-
handleSetJigsawBlock
- Specified by:
handleSetJigsawBlock
in interfaceServerGamePacketListener
-
handleJigsawGenerate
- Specified by:
handleJigsawGenerate
in interfaceServerGamePacketListener
-
handleSelectTrade
- Specified by:
handleSelectTrade
in interfaceServerGamePacketListener
-
handleEditBook
- Specified by:
handleEditBook
in interfaceServerGamePacketListener
-
updateBookContents
-
signBook
-
filterableFromOutgoing
-
handleEntityTagQuery
- Specified by:
handleEntityTagQuery
in interfaceServerGamePacketListener
-
handleContainerSlotStateChanged
- Specified by:
handleContainerSlotStateChanged
in interfaceServerGamePacketListener
-
handleBlockEntityTagQuery
- Specified by:
handleBlockEntityTagQuery
in interfaceServerGamePacketListener
-
handleMovePlayer
Processes clients perspective on player positioning and/or orientation- Specified by:
handleMovePlayer
in interfaceServerGamePacketListener
-
updateAwaitingTeleport
private boolean updateAwaitingTeleport() -
isPlayerCollidingWithAnythingNew
private boolean isPlayerCollidingWithAnythingNew(LevelReader pLevel, AABB pBox, double pX, double pY, double pZ) -
teleport
public void teleport(double pX, double pY, double pZ, float pYaw, float pPitch) -
teleport
public void teleport(double pX, double pY, double pZ, float pYaw, float pPitch, Set<RelativeMovement> pRelativeSet) Teleports the player position to the (relative) values specified, and syncs to the client -
handlePlayerAction
Processes the player initiating/stopping digging on a particular spot, as well as a player dropping items- Specified by:
handlePlayerAction
in interfaceServerGamePacketListener
-
wasBlockPlacementAttempt
-
handleUseItemOn
- Specified by:
handleUseItemOn
in interfaceServerGamePacketListener
-
handleUseItem
Called when a client is using an item while not pointing at a block, but simply using an item- Specified by:
handleUseItem
in interfaceServerGamePacketListener
-
handleTeleportToEntityPacket
- Specified by:
handleTeleportToEntityPacket
in interfaceServerGamePacketListener
-
handlePaddleBoat
- Specified by:
handlePaddleBoat
in interfaceServerGamePacketListener
-
onDisconnect
- Specified by:
onDisconnect
in interfacePacketListener
- Overrides:
onDisconnect
in classServerCommonPacketListenerImpl
-
removePlayerFromWorld
private void removePlayerFromWorld() -
ackBlockChangesUpTo
public void ackBlockChangesUpTo(int pSequence) -
handleSetCarriedItem
Updates which quickbar slot is selected- Specified by:
handleSetCarriedItem
in interfaceServerGamePacketListener
-
handleChat
Process chat messages (broadcast back to clients) and commands (executes)- Specified by:
handleChat
in interfaceServerGamePacketListener
-
handleChatCommand
- Specified by:
handleChatCommand
in interfaceServerGamePacketListener
-
performUnsignedChatCommand
-
handleSignedChatCommand
- Specified by:
handleSignedChatCommand
in interfaceServerGamePacketListener
-
performSignedChatCommand
private void performSignedChatCommand(ServerboundChatCommandSignedPacket pPacket, LastSeenMessages pLastSeenMessages) -
handleMessageDecodeFailure
-
collectSignedArguments
private <S> Map<String,PlayerChatMessage> collectSignedArguments(ServerboundChatCommandSignedPacket pPacket, SignableCommand<S> pCommand, LastSeenMessages pLastSeenMessages) throws SignedMessageChain.DecodeException -
collectUnsignedArguments
private <S> Map<String,PlayerChatMessage> collectUnsignedArguments(List<SignableCommand.Argument<S>> pArguments) throws SignedMessageChain.DecodeException -
createSignedArgumentMismatchException
private static <S> SignedMessageChain.DecodeException createSignedArgumentMismatchException(String pCommand, List<ArgumentSignatures.Entry> pSignedArguments, List<SignableCommand.Argument<S>> pUnsignedArguments) -
parseCommand
-
tryHandleChat
-
unpackAndApplyLastSeen
-
isChatMessageIllegal
-
getSignedMessage
private PlayerChatMessage getSignedMessage(ServerboundChatPacket pPacket, LastSeenMessages pLastSeenMessages) throws SignedMessageChain.DecodeException -
broadcastChatMessage
-
detectRateSpam
private void detectRateSpam() -
handleChatAck
- Specified by:
handleChatAck
in interfaceServerGamePacketListener
-
handleAnimate
- Specified by:
handleAnimate
in interfaceServerGamePacketListener
-
handlePlayerCommand
Processes a range of action-types: sneaking, sprinting, waking from sleep, opening the inventory or setting jump height of the horse the player is riding- Specified by:
handlePlayerCommand
in interfaceServerGamePacketListener
-
addPendingMessage
-
sendPlayerChatMessage
-
sendDisguisedChatMessage
-
getRemoteAddress
-
switchToConfig
public void switchToConfig() -
handlePingRequest
- Specified by:
handlePingRequest
in interfaceServerPingPacketListener
-
handleInteract
Processes left and right clicks on entities- Specified by:
handleInteract
in interfaceServerGamePacketListener
-
handleClientCommand
Processes the client status updates: respawn attempt from player, opening statistics or achievements, or acquiring 'open inventory' achievement- Specified by:
handleClientCommand
in interfaceServerGamePacketListener
-
handleContainerClose
Processes the client closing windows (container)- Specified by:
handleContainerClose
in interfaceServerGamePacketListener
-
handleContainerClick
Executes a container/inventory slot manipulation as indicated by the packet. Sends the serverside result if they didn't match the indicated result and prevents further manipulation by the player until he confirms that it has the same open container/inventory- Specified by:
handleContainerClick
in interfaceServerGamePacketListener
-
handlePlaceRecipe
- Specified by:
handlePlaceRecipe
in interfaceServerGamePacketListener
-
handleContainerButtonClick
Enchants the item identified by the packet given some convoluted conditions (matching window, which should/shouldn't be in use?)- Specified by:
handleContainerButtonClick
in interfaceServerGamePacketListener
-
handleSetCreativeModeSlot
Update the server with an ItemStack in a slot.- Specified by:
handleSetCreativeModeSlot
in interfaceServerGamePacketListener
-
handleSignUpdate
- Specified by:
handleSignUpdate
in interfaceServerGamePacketListener
-
updateSignText
-
handlePlayerAbilities
Processes a player starting/stopping flying- Specified by:
handlePlayerAbilities
in interfaceServerGamePacketListener
-
handleClientInformation
- Specified by:
handleClientInformation
in interfaceServerCommonPacketListener
-
handleChangeDifficulty
- Specified by:
handleChangeDifficulty
in interfaceServerGamePacketListener
-
handleLockDifficulty
- Specified by:
handleLockDifficulty
in interfaceServerGamePacketListener
-
handleChatSessionUpdate
- Specified by:
handleChatSessionUpdate
in interfaceServerGamePacketListener
-
handleConfigurationAcknowledged
- Specified by:
handleConfigurationAcknowledged
in interfaceServerGamePacketListener
-
handleChunkBatchReceived
- Specified by:
handleChunkBatchReceived
in interfaceServerGamePacketListener
-
handleDebugSampleSubscription
- Specified by:
handleDebugSampleSubscription
in interfaceServerGamePacketListener
-
resetPlayerChatState
-
handleCustomPayload
- Specified by:
handleCustomPayload
in interfaceServerCommonPacketListener
- Overrides:
handleCustomPayload
in classServerCommonPacketListenerImpl
-
getPlayer
- Specified by:
getPlayer
in interfaceServerPlayerConnection
-