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 server, Connection connection, ServerPlayer player, CommonListenerCookie cookie) -
Method Summary
Modifier and TypeMethodDescriptionvoidackBlockChangesUpTo(int sequence) private static voidaddBlockDataToItem(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack) private voidbroadcastChatMessage(PlayerChatMessage message) private static doubleclampHorizontal(double value) private static doubleclampVertical(double value) private <S> Map<String, PlayerChatMessage> collectSignedArguments(ServerboundChatCommandSignedPacket packet, SignableCommand<S> command, LastSeenMessages lastSeenMessages) private <S> Map<String, PlayerChatMessage> collectUnsignedArguments(List<SignableCommand.Argument<S>> arguments) private static booleancontainsInvalidValues(double x, double y, double z, float yRot, float xRot) private static <S> SignedMessageChain.DecodeExceptioncreateSignedArgumentMismatchException(String command, List<ArgumentSignatures.Entry> signedArguments, List<SignableCommand.Argument<S>> unsignedArguments) private voidprivate Filterable<String> filterableFromOutgoing(FilteredText filteredText) private CompletableFuture<FilteredText> filterTextPacket(String text) private CompletableFuture<List<FilteredText>> filterTextPacket(List<String> texts) private <T,R> CompletableFuture <R> filterTextPacket(T message, BiFunction<TextFilter, T, CompletableFuture<R>> processor) private intgetMaximumFlyingTicks(Entity entity) private PlayerChatMessagegetSignedMessage(ServerboundChatPacket packet, LastSeenMessages lastSeenMessages) voidvoidvoidhandleAnimate(ServerboundSwingPacket packet) voidvoidvoidvoidvoidhandleChat(ServerboundChatPacket packet) Process chat messages (broadcast back to clients) and commands (executes)voidvoidvoidvoidvoidProcesses 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).voidvoidvoidvoidvoidProcesses 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 movement) voidvoidvoidvoidvoidvoidvoidUpdates which quickbar slot is selectedvoidvoidvoidUpdate the server with an ItemStack in a slot.voidvoidvoidvoidvoidvoidvoidvoidCalled when a client is using an item while not pointing at a block, but simply using an itemvoidbooleanbooleanprivate static booleanisChatMessageIllegal(String message) private booleanisEntityCollidingWithAnythingNew(LevelReader level, Entity entity, AABB box, double x, double y, double z) private booleannoBlocksAround(Entity entity) voidonDisconnect(DisconnectionDetails details) private com.mojang.brigadier.ParseResults<CommandSourceStack> parseCommand(String command) private voidperformSignedChatCommand(ServerboundChatCommandSignedPacket packet, LastSeenMessages lastSeenMessages) private voidperformUnsignedChatCommand(String command) protected com.mojang.authlib.GameProfileprivate voidprivate voidresetPlayerChatState(RemoteChatSession chatSession) voidprivate voidresyncPlayerWithVehicle(Entity vehicle) voidsendDisguisedChatMessage(Component message, ChatType.Bound boundType) voidsendPlayerChatMessage(PlayerChatMessage chatMessage, ChatType.Bound boundType) private booleanshouldCheckPlayerMovement(boolean isElytraMovement) booleanshouldHandleMessage(Packet<?> packet) private voidsignBook(FilteredText title, List<FilteredText> pages, int index) voidvoidteleport(double x, double y, double z, float yaw, float pitch) voidteleport(PositionMoveRotation posMoveRotation, Set<Relative> relatives) voidtick()private voidtryHandleChat(String message, Runnable handler) private voidtryPickItem(ItemStack stack) private Optional<LastSeenMessages> private booleanprivate voidupdateBookContents(List<FilteredText> pages, int index) private voidupdateSignText(ServerboundSignUpdatePacket packet, List<FilteredText> filteredText) private static booleanwasBlockPlacementAttempt(ServerPlayer player, ItemStack stack) 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 server, Connection connection, ServerPlayer player, CommonListenerCookie cookie)
-
-
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 message, BiFunction<TextFilter, T, CompletableFuture<R>> processor) -
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 x, double y, double z, float yRot, float xRot) -
clampHorizontal
private static double clampHorizontal(double value) -
clampVertical
private static double clampVertical(double value) -
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 state, ServerLevel level, BlockPos pos, ItemStack stack) -
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 isElytraMovement) -
updateAwaitingTeleport
private boolean updateAwaitingTeleport() -
isEntityCollidingWithAnythingNew
private boolean isEntityCollidingWithAnythingNew(LevelReader level, Entity entity, AABB box, double x, double y, double z) -
teleport
public void teleport(double x, double y, double z, float yaw, float pitch) -
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 sequence) -
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 packet, LastSeenMessages lastSeenMessages) -
handleMessageDecodeFailure
-
collectSignedArguments
private <S> Map<String,PlayerChatMessage> collectSignedArguments(ServerboundChatCommandSignedPacket packet, SignableCommand<S> command, LastSeenMessages lastSeenMessages) throws SignedMessageChain.DecodeException -
collectUnsignedArguments
private <S> Map<String,PlayerChatMessage> collectUnsignedArguments(List<SignableCommand.Argument<S>> arguments) throws SignedMessageChain.DecodeException -
createSignedArgumentMismatchException
private static <S> SignedMessageChain.DecodeException createSignedArgumentMismatchException(String command, List<ArgumentSignatures.Entry> signedArguments, List<SignableCommand.Argument<S>> unsignedArguments) -
parseCommand
-
tryHandleChat
-
unpackAndApplyLastSeen
-
isChatMessageIllegal
-
getSignedMessage
private PlayerChatMessage getSignedMessage(ServerboundChatPacket packet, LastSeenMessages lastSeenMessages) 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
-