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,GameProtocols.Context,ServerGamePacketListener,ServerPacketListener,ServerPingPacketListener,ServerboundPacketListener,TickablePacketListener,ServerPlayerConnection,ICommonPacketListener,IServerCommonPacketListenerExtension,IServerGamePacketListenerExtension
- Direct Known Subclasses:
FakePlayer.FakePlayerNetHandler
public class ServerGamePacketListenerImpl
extends ServerCommonPacketListenerImpl
implements GameProtocols.Context, ServerGamePacketListener, ServerPlayerConnection, TickablePacketListener
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intUsed to keep track of how the player is floating while gamerules should prevent that.private intprivate intprivate Vec3private intprivate intprivate static final Componentprivate final FutureChainprivate RemoteChatSessionprivate final TickThrottlerfinal PlayerChunkSenderprivate booleanprivate booleanprivate final TickThrottlerprivate doubleprivate doubleprivate doubleprivate static final Componentprivate intprivate doubleprivate doubleprivate doubleprivate final LastSeenMessagesValidatorprivate Entity(package private) static final org.slf4j.Loggerprivate static final intprivate static final intprivate final MessageSignatureCacheprivate intprivate static final intprivate booleanprivate intprivate SignedMessageChain.Decoderprivate intprivate static final intprivate doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate doubleprivate booleanFields 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 TypeMethodDescriptionvoidackBlockChangesUpTo(int pSequence) private static voidaddBlockDataToItem(BlockState pState, ServerLevel pLevel, BlockPos pPos, ItemStack pStack) private voidbroadcastChatMessage(PlayerChatMessage pMessage) private static doubleclampHorizontal(double pValue) private static doubleclampVertical(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 booleancontainsInvalidValues(double pX, double pY, double pZ, float pYRot, float pXRot) private static <S> SignedMessageChain.DecodeExceptioncreateSignedArgumentMismatchException(String pCommand, List<ArgumentSignatures.Entry> pSignedArguments, List<SignableCommand.Argument<S>> pUnsignedArguments) private voidprivate 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 intgetMaximumFlyingTicks(Entity pEntity) private PlayerChatMessagegetSignedMessage(ServerboundChatPacket pPacket, LastSeenMessages pLastSeenMessages) voidvoidvoidhandleAnimate(ServerboundSwingPacket pPacket) voidvoidvoidvoidvoidhandleChat(ServerboundChatPacket pPacket) Process chat messages (broadcast back to clients) and commands (executes)voidhandleChatAck(ServerboundChatAckPacket pPacket) voidvoidvoidvoidProcesses the client status updates: respawn attempt from player, opening statistics or achievements, or acquiring 'open inventory' achievementvoidvoidvoidvoidEnchants the item identified by the packet given some convoluted conditions (matching window, which should/shouldn't be in use?)voidExecutes a container/inventory slot manipulation as indicated by the packet.voidProcesses the client closing windows (container)voidvoidThis method is only called for manual tab-completion (theminecraft:ask_serversuggestion provider).voidvoidvoidhandleEditBook(ServerboundEditBookPacket pPacket) voidvoidhandleInteract(ServerboundInteractPacket pPacket) Processes left and right clicks on entitiesvoidvoidprivate voidvoidProcesses clients perspective on player positioning and/or orientationvoidvoidvoidvoidvoidvoidvoidProcesses a player starting/stopping flyingvoidProcesses the player initiating/stopping digging on a particular spot, as well as a player dropping itemsvoidProcesses a range of action-types: sneaking, sprinting, waking from sleep, opening the inventory or setting jump height of the horse the player is ridingvoidProcesses player movement input.private voidhandlePlayerKnownMovement(Vec3 pMovement) voidvoidvoidvoidvoidvoidvoidUpdates which quickbar slot is selectedvoidvoidvoidUpdate the server with an ItemStack in a slot.voidvoidvoidvoidvoidvoidvoidvoidhandleUseItem(ServerboundUseItemPacket pPacket) Called when a client is using an item while not pointing at a block, but simply using an itemvoidbooleanbooleanprivate static booleanisChatMessageIllegal(String pMessage) private booleanisEntityCollidingWithAnythingNew(LevelReader pLevel, Entity pEntity, AABB pBox, double pX, double pY, double pZ) private booleannoBlocksAround(Entity pEntity) voidonDisconnect(DisconnectionDetails pDetails) private com.mojang.brigadier.ParseResults<CommandSourceStack> parseCommand(String pCommand) private voidperformSignedChatCommand(ServerboundChatCommandSignedPacket pPacket, LastSeenMessages pLastSeenMessages) private voidperformUnsignedChatCommand(String pCommand) protected com.mojang.authlib.GameProfileprivate voidprivate voidresetPlayerChatState(RemoteChatSession pChatSession) voidprivate voidresyncPlayerWithVehicle(Entity vehicle) voidsendDisguisedChatMessage(Component pMessage, ChatType.Bound pBoundType) voidsendPlayerChatMessage(PlayerChatMessage pChatMessage, ChatType.Bound pBoundType) private booleanshouldCheckPlayerMovement(boolean pIsElytraMovement) booleanshouldHandleMessage(Packet<?> pPacket) private voidsignBook(FilteredText pTitle, List<FilteredText> pPages, int pIndex) voidvoidteleport(double pX, double pY, double pZ, float pYaw, float pPitch) voidteleport(PositionMoveRotation pPosMoveRotation, Set<Relative> pRelatives) voidtick()private voidtryHandleChat(String pMessage, Runnable pHandler) private voidtryPickItem(ItemStack pStack) private Optional<LastSeenMessages> private booleanprivate voidupdateBookContents(List<FilteredText> pPages, int pIndex) private voidupdateSignText(ServerboundSignUpdatePacket pPacket, List<FilteredText> pFilteredText) private static booleanwasBlockPlacementAttempt(ServerPlayer pPlayer, ItemStack pStack) Methods inherited from class net.minecraft.server.network.ServerCommonPacketListenerImpl
createCookie, createCookie, disconnect, disconnect, getConnection, getConnectionType, getMainThreadEventLoop, getOwner, handleCookieResponse, handleCustomClickAction, handleKeepAlive, handlePong, handleResourcePackResponse, isSingleplayerOwner, keepConnectionAlive, latency, onPacketError, resumeFlushing, send, send, suspendFlushingMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.neoforged.neoforge.common.extensions.ICommonPacketListener
disconnect, getConnection, getConnectionType, getMainThreadEventLoop, hasChannel, hasChannel, hasChannel, sendMethods inherited from interface net.neoforged.neoforge.common.extensions.IServerCommonPacketListenerExtension
send, send, sendMethods inherited from interface net.neoforged.neoforge.common.extensions.IServerGamePacketListenerExtension
sendBundled, sendBundledMethods inherited from interface net.minecraft.network.PacketListener
createDisconnectionInfo, fillCrashReport, fillListenerSpecificCrashDetailsMethods inherited from interface net.minecraft.network.ServerboundPacketListener
flowMethods inherited from interface net.minecraft.network.protocol.common.ServerCommonPacketListener
handleCustomClickAction, handleKeepAlive, handlePong, handleResourcePackResponseMethods inherited from interface net.minecraft.network.protocol.cookie.ServerCookiePacketListener
handleCookieResponseMethods inherited from interface net.minecraft.network.protocol.game.ServerGamePacketListener
protocolMethods inherited from interface net.minecraft.network.protocol.game.ServerPacketListener
onPacketErrorMethods 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 -
chatSpamThrottler
-
dropSpamThrottler
-
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 -
receivedMovementThisTick
private boolean receivedMovementThisTick -
chatSession
-
signedMessageDecoder
-
lastSeenMessages
-
nextChatIndex
private int nextChatIndex -
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:
tickin interfaceTickablePacketListener
-
getMaximumFlyingTicks
-
resetPosition
public void resetPosition() -
isAcceptingMessages
public boolean isAcceptingMessages()- Specified by:
isAcceptingMessagesin interfacePacketListener
-
shouldHandleMessage
- Specified by:
shouldHandleMessagein interfacePacketListener
-
playerProfile
protected com.mojang.authlib.GameProfile playerProfile()- Specified by:
playerProfilein 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:
handlePlayerInputin 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:
handleMoveVehiclein interfaceServerGamePacketListener
-
resyncPlayerWithVehicle
-
noBlocksAround
-
handleAcceptTeleportPacket
- Specified by:
handleAcceptTeleportPacketin interfaceServerGamePacketListener
-
handleAcceptPlayerLoad
- Specified by:
handleAcceptPlayerLoadin interfaceServerGamePacketListener
-
handleRecipeBookSeenRecipePacket
- Specified by:
handleRecipeBookSeenRecipePacketin interfaceServerGamePacketListener
-
handleBundleItemSelectedPacket
- Specified by:
handleBundleItemSelectedPacketin interfaceServerGamePacketListener
-
handleRecipeBookChangeSettingsPacket
- Specified by:
handleRecipeBookChangeSettingsPacketin interfaceServerGamePacketListener
-
handleSeenAdvancements
- Specified by:
handleSeenAdvancementsin interfaceServerGamePacketListener
-
handleCustomCommandSuggestions
This method is only called for manual tab-completion (theminecraft:ask_serversuggestion provider).- Specified by:
handleCustomCommandSuggestionsin interfaceServerGamePacketListener
-
handleSetCommandBlock
- Specified by:
handleSetCommandBlockin interfaceServerGamePacketListener
-
handleSetCommandMinecart
- Specified by:
handleSetCommandMinecartin interfaceServerGamePacketListener
-
handlePickItemFromBlock
- Specified by:
handlePickItemFromBlockin interfaceServerGamePacketListener
-
addBlockDataToItem
private static void addBlockDataToItem(BlockState pState, ServerLevel pLevel, BlockPos pPos, ItemStack pStack) -
handlePickItemFromEntity
- Specified by:
handlePickItemFromEntityin interfaceServerGamePacketListener
-
tryPickItem
-
handleRenameItem
- Specified by:
handleRenameItemin interfaceServerGamePacketListener
-
handleSetBeaconPacket
- Specified by:
handleSetBeaconPacketin interfaceServerGamePacketListener
-
handleSetStructureBlock
- Specified by:
handleSetStructureBlockin interfaceServerGamePacketListener
-
handleSetTestBlock
- Specified by:
handleSetTestBlockin interfaceServerGamePacketListener
-
handleTestInstanceBlockAction
- Specified by:
handleTestInstanceBlockActionin interfaceServerGamePacketListener
-
handleSetJigsawBlock
- Specified by:
handleSetJigsawBlockin interfaceServerGamePacketListener
-
handleJigsawGenerate
- Specified by:
handleJigsawGeneratein interfaceServerGamePacketListener
-
handleSelectTrade
- Specified by:
handleSelectTradein interfaceServerGamePacketListener
-
handleEditBook
- Specified by:
handleEditBookin interfaceServerGamePacketListener
-
updateBookContents
-
signBook
-
filterableFromOutgoing
-
handleEntityTagQuery
- Specified by:
handleEntityTagQueryin interfaceServerGamePacketListener
-
handleContainerSlotStateChanged
- Specified by:
handleContainerSlotStateChangedin interfaceServerGamePacketListener
-
handleBlockEntityTagQuery
- Specified by:
handleBlockEntityTagQueryin interfaceServerGamePacketListener
-
handleMovePlayer
Processes clients perspective on player positioning and/or orientation- Specified by:
handleMovePlayerin interfaceServerGamePacketListener
-
shouldCheckPlayerMovement
private boolean shouldCheckPlayerMovement(boolean pIsElytraMovement) -
updateAwaitingTeleport
private boolean updateAwaitingTeleport() -
isEntityCollidingWithAnythingNew
private boolean isEntityCollidingWithAnythingNew(LevelReader pLevel, Entity pEntity, AABB pBox, double pX, double pY, double pZ) -
teleport
public void teleport(double pX, double pY, double pZ, float pYaw, float pPitch) -
teleport
-
handlePlayerAction
Processes the player initiating/stopping digging on a particular spot, as well as a player dropping items- Specified by:
handlePlayerActionin interfaceServerGamePacketListener
-
wasBlockPlacementAttempt
-
handleUseItemOn
- Specified by:
handleUseItemOnin interfaceServerGamePacketListener
-
handleUseItem
Called when a client is using an item while not pointing at a block, but simply using an item- Specified by:
handleUseItemin interfaceServerGamePacketListener
-
handleTeleportToEntityPacket
- Specified by:
handleTeleportToEntityPacketin interfaceServerGamePacketListener
-
handlePaddleBoat
- Specified by:
handlePaddleBoatin interfaceServerGamePacketListener
-
onDisconnect
- Specified by:
onDisconnectin interfacePacketListener- Overrides:
onDisconnectin classServerCommonPacketListenerImpl
-
removePlayerFromWorld
private void removePlayerFromWorld() -
ackBlockChangesUpTo
public void ackBlockChangesUpTo(int pSequence) -
handleSetCarriedItem
Updates which quickbar slot is selected- Specified by:
handleSetCarriedItemin interfaceServerGamePacketListener
-
handleChat
Process chat messages (broadcast back to clients) and commands (executes)- Specified by:
handleChatin interfaceServerGamePacketListener
-
handleChatCommand
- Specified by:
handleChatCommandin interfaceServerGamePacketListener
-
performUnsignedChatCommand
-
handleSignedChatCommand
- Specified by:
handleSignedChatCommandin 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:
handleChatAckin interfaceServerGamePacketListener
-
handleAnimate
- Specified by:
handleAnimatein 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:
handlePlayerCommandin interfaceServerGamePacketListener
-
sendPlayerChatMessage
-
sendDisguisedChatMessage
-
getRemoteAddress
-
switchToConfig
public void switchToConfig() -
handlePingRequest
- Specified by:
handlePingRequestin interfaceServerPingPacketListener
-
handleInteract
Processes left and right clicks on entities- Specified by:
handleInteractin interfaceServerGamePacketListener
-
handleClientCommand
Processes the client status updates: respawn attempt from player, opening statistics or achievements, or acquiring 'open inventory' achievement- Specified by:
handleClientCommandin interfaceServerGamePacketListener
-
handleContainerClose
Processes the client closing windows (container)- Specified by:
handleContainerClosein 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:
handleContainerClickin interfaceServerGamePacketListener
-
handlePlaceRecipe
- Specified by:
handlePlaceRecipein interfaceServerGamePacketListener
-
handleContainerButtonClick
Enchants the item identified by the packet given some convoluted conditions (matching window, which should/shouldn't be in use?)- Specified by:
handleContainerButtonClickin interfaceServerGamePacketListener
-
handleSetCreativeModeSlot
Update the server with an ItemStack in a slot.- Specified by:
handleSetCreativeModeSlotin interfaceServerGamePacketListener
-
handleSignUpdate
- Specified by:
handleSignUpdatein interfaceServerGamePacketListener
-
updateSignText
-
handlePlayerAbilities
Processes a player starting/stopping flying- Specified by:
handlePlayerAbilitiesin interfaceServerGamePacketListener
-
handleClientInformation
- Specified by:
handleClientInformationin interfaceServerCommonPacketListener
-
handleChangeDifficulty
- Specified by:
handleChangeDifficultyin interfaceServerGamePacketListener
-
handleChangeGameMode
- Specified by:
handleChangeGameModein interfaceServerGamePacketListener
-
handleLockDifficulty
- Specified by:
handleLockDifficultyin interfaceServerGamePacketListener
-
handleChatSessionUpdate
- Specified by:
handleChatSessionUpdatein interfaceServerGamePacketListener
-
handleConfigurationAcknowledged
- Specified by:
handleConfigurationAcknowledgedin interfaceServerGamePacketListener
-
handleChunkBatchReceived
- Specified by:
handleChunkBatchReceivedin interfaceServerGamePacketListener
-
handleDebugSampleSubscription
- Specified by:
handleDebugSampleSubscriptionin interfaceServerGamePacketListener
-
resetPlayerChatState
-
handleCustomPayload
- Specified by:
handleCustomPayloadin interfaceServerCommonPacketListener- Overrides:
handleCustomPayloadin classServerCommonPacketListenerImpl
-
handleClientTickEnd
- Specified by:
handleClientTickEndin interfaceServerGamePacketListener
-
handlePlayerKnownMovement
-
hasInfiniteMaterials
public boolean hasInfiniteMaterials()- Specified by:
hasInfiniteMaterialsin interfaceGameProtocols.Context
-
getPlayer
- Specified by:
getPlayerin interfaceServerPlayerConnection
-