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 egiintermediary net/minecraft/class_7516named net/minecraft/client/network/ChatPreviewRequester
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classA utility class that increments the ID by a random number from 0 to 99.private static final recordA query, or a request, to the server to send the chat message preview. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MinecraftClientprivate static final longHow long the previewer should wait at a minimum before sending the next query in milliseconds.private final ChatPreviewRequester.IdIncrementorprivate static final longHow long the previewer can wait for the response at most before sending the next query in milliseconds.private @Nullable ChatPreviewRequester.QueryThe query that is waiting for the server to respond (i.e.private longThe last time a query was sent. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()handleResponse(int id) Returns the response's original queried message, ornullif the response is not for the current pending request.booleanReturns whether the requester has a query that is waiting for the server to respond.private booleanshouldRequest(long currentTime) Returns whether the delay for querying has passed.booleantryRequest(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 aLegi;a:Jintermediary field_39423Lnet/minecraft/class_7516;field_39423:Jnamed EARLIEST_NEXT_QUERY_DELAYLnet/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 bLegi;b:Jintermediary field_39424Lnet/minecraft/class_7516;field_39424:Jnamed LATEST_NEXT_QUERY_DELAYLnet/minecraft/client/network/ChatPreviewRequester;LATEST_NEXT_QUERY_DELAY:J
-
client
- Mappings:
Namespace Name Mixin selector official cLegi;c:Leex;intermediary field_39425Lnet/minecraft/class_7516;field_39425:Lnet/minecraft/class_310;named clientLnet/minecraft/client/network/ChatPreviewRequester;client:Lnet/minecraft/client/MinecraftClient;
-
idIncrementor
- Mappings:
Namespace Name Mixin selector official dLegi;d:Legi$b;intermediary field_39426Lnet/minecraft/class_7516;field_39426:Lnet/minecraft/class_7516$class_7482;named idIncrementorLnet/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 benullif there is no such query.- Mappings:
Namespace Name Mixin selector official eLegi;e:Legi$a;intermediary field_39427Lnet/minecraft/class_7516;field_39427:Lnet/minecraft/class_7516$class_7480;named pendingResponseQueryLnet/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 fLegi;f:Jintermediary field_39428Lnet/minecraft/class_7516;field_39428:Jnamed queryTimeLnet/minecraft/client/network/ChatPreviewRequester;queryTime:J
-
-
Constructor Details
-
ChatPreviewRequester
- Mappings:
Namespace Name Mixin selector official <init>Legi;<init>(Leex;)Vintermediary <init>Lnet/minecraft/class_7516;<init>(Lnet/minecraft/class_310;)Vnamed <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:
falseif the request could not be sent due to the delay, otherwisetrue- Mappings:
Namespace Name Mixin selector official aLegi;a(Ljava/lang/String;J)Zintermediary method_44272Lnet/minecraft/class_7516;method_44272(Ljava/lang/String;J)Znamed tryRequestLnet/minecraft/client/network/ChatPreviewRequester;tryRequest(Ljava/lang/String;J)Z
-
handleResponse
Returns the response's original queried message, ornullif 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
nullif the response is not for the current pending request - Mappings:
Namespace Name Mixin selector official aLegi;a(I)Ljava/lang/String;intermediary method_44270Lnet/minecraft/class_7516;method_44270(I)Ljava/lang/String;named handleResponseLnet/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 aLegi;a(J)Zintermediary method_44271Lnet/minecraft/class_7516;method_44271(J)Znamed shouldRequestLnet/minecraft/client/network/ChatPreviewRequester;shouldRequest(J)Z
-
clear
public void clear()- Mappings:
Namespace Name Mixin selector official aLegi;a()Vintermediary method_44269Lnet/minecraft/class_7516;method_44269()Vnamed clearLnet/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 bLegi;b()Zintermediary method_44273Lnet/minecraft/class_7516;method_44273()Znamed hasPendingResponseQueryLnet/minecraft/client/network/ChatPreviewRequester;hasPendingResponseQuery()Z
-