Package net.minecraft.client.network
Class ChatPreviewRequester
java.lang.Object
net.minecraft.client.network.ChatPreviewRequester
Chat preview requester requests the server to preview a message.
A query is a request to the server to send the chat message preview. The previewer only sends the query if there is no query that is waiting for the response, or if the last query took more than 1000L milliseconds to respond. A query can be sent at most every 100L milliseconds.
- See Also:
- Mappings:
Namespace Name official egf
intermediary net/minecraft/class_7516
named net/minecraft/client/network/ChatPreviewRequester
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static class
A utility class that increments the ID by a random number from 0 to 99.private static final record
A query, or a request, to the server to send the chat message preview. -
Field Summary
Modifier and TypeFieldDescriptionprivate final MinecraftClient
private static final long
How long the previewer should wait at a minimum before sending the next query in milliseconds.private final ChatPreviewRequester.IdIncrementor
private static final long
How long the previewer can wait for the response at most before sending the next query in milliseconds.private @Nullable ChatPreviewRequester.Query
The query that is waiting for the server to respond (i.e.private long
The last time a query was sent. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
handleResponse
(int id) Returns the response's original queried message, ornull
if the response is not for the current pending request.boolean
Returns whether the requester has a query that is waiting for the server to respond.private boolean
shouldRequest
(long currentTime) Returns whether the delay for querying has passed.boolean
tryRequest
(String message, long currentTime) Sends the request to previewmessage
, if there isn't already one and if the delay has passed.
-
Field Details
-
EARLIEST_NEXT_QUERY_DELAY
private static final long EARLIEST_NEXT_QUERY_DELAYHow long the previewer should wait at a minimum before sending the next query in milliseconds. Is 100L.- See Also:
- Mappings:
Namespace Name Mixin selector official a
Legf;a:J
intermediary field_39423
Lnet/minecraft/class_7516;field_39423:J
named EARLIEST_NEXT_QUERY_DELAY
Lnet/minecraft/client/network/ChatPreviewRequester;EARLIEST_NEXT_QUERY_DELAY:J
-
LATEST_NEXT_QUERY_DELAY
private static final long LATEST_NEXT_QUERY_DELAYHow long the previewer can wait for the response at most before sending the next query in milliseconds. Is 1000L.- See Also:
- Mappings:
Namespace Name Mixin selector official b
Legf;b:J
intermediary field_39424
Lnet/minecraft/class_7516;field_39424:J
named LATEST_NEXT_QUERY_DELAY
Lnet/minecraft/client/network/ChatPreviewRequester;LATEST_NEXT_QUERY_DELAY:J
-
client
- Mappings:
Namespace Name Mixin selector official c
Legf;c:Leeu;
intermediary field_39425
Lnet/minecraft/class_7516;field_39425:Lnet/minecraft/class_310;
named client
Lnet/minecraft/client/network/ChatPreviewRequester;client:Lnet/minecraft/client/MinecraftClient;
-
idIncrementor
- Mappings:
Namespace Name Mixin selector official d
Legf;d:Legf$b;
intermediary field_39426
Lnet/minecraft/class_7516;field_39426:Lnet/minecraft/class_7516$class_7482;
named idIncrementor
Lnet/minecraft/client/network/ChatPreviewRequester;idIncrementor:Lnet/minecraft/client/network/ChatPreviewRequester$IdIncrementor;
-
pendingResponseQuery
The query that is waiting for the server to respond (i.e. the last query). Can benull
if there is no such query.- Mappings:
Namespace Name Mixin selector official e
Legf;e:Legf$a;
intermediary field_39427
Lnet/minecraft/class_7516;field_39427:Lnet/minecraft/class_7516$class_7480;
named pendingResponseQuery
Lnet/minecraft/client/network/ChatPreviewRequester;pendingResponseQuery:Lnet/minecraft/client/network/ChatPreviewRequester$Query;
-
queryTime
private long queryTimeThe last time a query was sent.The next query will be sent after 100L to 1000L milliseconds; the actual delay depends on when the server responds to the query.
- Mappings:
Namespace Name Mixin selector official f
Legf;f:J
intermediary field_39428
Lnet/minecraft/class_7516;field_39428:J
named queryTime
Lnet/minecraft/client/network/ChatPreviewRequester;queryTime:J
-
-
Constructor Details
-
ChatPreviewRequester
- Mappings:
Namespace Name Mixin selector official <init>
Legf;<init>(Leeu;)V
intermediary <init>
Lnet/minecraft/class_7516;<init>(Lnet/minecraft/class_310;)V
named <init>
Lnet/minecraft/client/network/ChatPreviewRequester;<init>(Lnet/minecraft/client/MinecraftClient;)V
-
-
Method Details
-
tryRequest
Sends the request to previewmessage
, if there isn't already one and if the delay has passed.- Returns:
false
if the request could not be sent due to the delay, otherwisetrue
- Mappings:
Namespace Name Mixin selector official a
Legf;a(Ljava/lang/String;J)Z
intermediary method_44272
Lnet/minecraft/class_7516;method_44272(Ljava/lang/String;J)Z
named tryRequest
Lnet/minecraft/client/network/ChatPreviewRequester;tryRequest(Ljava/lang/String;J)Z
-
handleResponse
Returns the response's original queried message, ornull
if the response is not for the current pending request.If the response is valid, this will also clear
pendingResponseQuery
.- Returns:
- the response's original queried message, or
null
if the response is not for the current pending request - Mappings:
Namespace Name Mixin selector official a
Legf;a(I)Ljava/lang/String;
intermediary method_44270
Lnet/minecraft/class_7516;method_44270(I)Ljava/lang/String;
named handleResponse
Lnet/minecraft/client/network/ChatPreviewRequester;handleResponse(I)Ljava/lang/String;
-
shouldRequest
private boolean shouldRequest(long currentTime) Returns whether the delay for querying has passed.The previewer only sends the query if there is no query that is waiting for the response, or if the last query took more than 1000L milliseconds to respond. A query can be sent at most every 100L milliseconds.
- Returns:
- whether the delay for querying has passed
- Mappings:
Namespace Name Mixin selector official a
Legf;a(J)Z
intermediary method_44271
Lnet/minecraft/class_7516;method_44271(J)Z
named shouldRequest
Lnet/minecraft/client/network/ChatPreviewRequester;shouldRequest(J)Z
-
clear
public void clear()- Mappings:
Namespace Name Mixin selector official a
Legf;a()V
intermediary method_44269
Lnet/minecraft/class_7516;method_44269()V
named clear
Lnet/minecraft/client/network/ChatPreviewRequester;clear()V
-
hasPendingResponseQuery
public boolean hasPendingResponseQuery()Returns whether the requester has a query that is waiting for the server to respond.- Returns:
- whether the requester has a query that is waiting for the server to respond
- Mappings:
Namespace Name Mixin selector official b
Legf;b()Z
intermediary method_44273
Lnet/minecraft/class_7516;method_44273()Z
named hasPendingResponseQuery
Lnet/minecraft/client/network/ChatPreviewRequester;hasPendingResponseQuery()Z
-