Class ChatPreviewer
ChatScreen, so closing the chat screen and
reopening it would create a new chat previewer.
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 milliseconds to respond. A query can be sent at most every milliseconds.
The response to the query can be "consumed" by calling tryConsumeResponse(java.lang.String).
If the response is still valid (i.e. the input has not changed since the query was sent),
consuming the response will return the response and clear it. Note that to prevent race
condition between the player sending the chat message and the response's arrival, responses
can only be consumed after the cooldown (by default, 200L milliseconds)
has passed. It is also possible to get the response text without consuming by calling
getPreviewText().
- Mappings:
Namespace Name official egeintermediary net/minecraft/class_7479named net/minecraft/client/network/ChatPreviewer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final recordA response to the preview query. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longHow long the previewer should wait before consuming the response since the response arrived at the client in milliseconds.private booleanprivate final class_7516private @Nullable ChatPreviewer.Response -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidclear()Clears the last response and the queries (but not the query time).Returns the preview text (also known as the last response text), ornullif the server responded as such.voidmethod_44274(String string) voidprivate voidmethod_44276(String string) (package private) static StringReturns themessagenormalized by trimming it and then normalizing spaces.voidonResponse(int id, @Nullable Text response) Called when the preview response was received.booleanReturns whether the preview should be rendered.tryConsumeResponse(String message) Returns the consumed response text, ornullif the server responded as such, or if the response could not be consumed.voidtryQuery()Sends the pending query, if it exists and the delay has passed.
-
Field Details
-
CONSUME_COOLDOWN
private static final long CONSUME_COOLDOWNHow long the previewer should wait before consuming the response since the response arrived at the client in milliseconds. Is 200L.- See Also:
- Mappings:
Namespace Name Mixin selector official aLege;a:Jintermediary field_39328Lnet/minecraft/class_7479;field_39328:Jnamed CONSUME_COOLDOWNLnet/minecraft/client/network/ChatPreviewer;CONSUME_COOLDOWN:J
-
field_39429
private boolean field_39429- Mappings:
Namespace Name Mixin selector official bLege;b:Zintermediary field_39429Lnet/minecraft/class_7479;field_39429:Znamed field_39429Lnet/minecraft/client/network/ChatPreviewer;field_39429:Z
-
field_39430
- Mappings:
Namespace Name Mixin selector official cLege;c:Ljava/lang/String;intermediary field_39430Lnet/minecraft/class_7479;field_39430:Ljava/lang/String;named field_39430Lnet/minecraft/client/network/ChatPreviewer;field_39430:Ljava/lang/String;
-
field_39431
- Mappings:
Namespace Name Mixin selector official dLege;d:Ljava/lang/String;intermediary field_39431Lnet/minecraft/class_7479;field_39431:Ljava/lang/String;named field_39431Lnet/minecraft/client/network/ChatPreviewer;field_39431:Ljava/lang/String;
-
field_39432
- Mappings:
Namespace Name Mixin selector official eLege;e:Legd;intermediary field_39432Lnet/minecraft/class_7479;field_39432:Lnet/minecraft/class_7516;named field_39432Lnet/minecraft/client/network/ChatPreviewer;field_39432:Lnet/minecraft/class_7516;
-
lastResponse
- Mappings:
Namespace Name Mixin selector official fLege;f:Lege$a;intermediary field_39334Lnet/minecraft/class_7479;field_39334:Lnet/minecraft/class_7479$class_7481;named lastResponseLnet/minecraft/client/network/ChatPreviewer;lastResponse:Lnet/minecraft/client/network/ChatPreviewer$Response;
-
-
Constructor Details
-
ChatPreviewer
- Mappings:
Namespace Name Mixin selector official <init>Lege;<init>(Lees;)Vintermediary <init>Lnet/minecraft/class_7479;<init>(Lnet/minecraft/class_310;)Vnamed <init>Lnet/minecraft/client/network/ChatPreviewer;<init>(Lnet/minecraft/client/MinecraftClient;)V
-
-
Method Details
-
tryQuery
public void tryQuery()Sends the pending query, if it exists and the delay has passed.- Mappings:
Namespace Name Mixin selector official aLege;a()Vintermediary method_44031Lnet/minecraft/class_7479;method_44031()Vnamed tryQueryLnet/minecraft/client/network/ChatPreviewer;tryQuery()V
-
method_44274
- Mappings:
Namespace Name Mixin selector official aLege;a(Ljava/lang/String;)Vintermediary method_44274Lnet/minecraft/class_7479;method_44274(Ljava/lang/String;)Vnamed method_44274Lnet/minecraft/client/network/ChatPreviewer;method_44274(Ljava/lang/String;)V
-
method_44276
- Mappings:
Namespace Name Mixin selector official cLege;c(Ljava/lang/String;)Vintermediary method_44276Lnet/minecraft/class_7479;method_44276(Ljava/lang/String;)Vnamed method_44276Lnet/minecraft/client/network/ChatPreviewer;method_44276(Ljava/lang/String;)V
-
method_44275
public void method_44275()- Mappings:
Namespace Name Mixin selector official bLege;b()Vintermediary method_44275Lnet/minecraft/class_7479;method_44275()Vnamed method_44275Lnet/minecraft/client/network/ChatPreviewer;method_44275()V
-
clear
private void clear()Clears the last response and the queries (but not the query time).- Mappings:
Namespace Name Mixin selector official eLege;e()Vintermediary method_44036Lnet/minecraft/class_7479;method_44036()Vnamed clearLnet/minecraft/client/network/ChatPreviewer;clear()V
-
onResponse
Called when the preview response was received.- Implementation Note:
- This sets the last response and clears
if the pending query ID equals
invalid @link
#pendingResponseQueryid - Mappings:
Namespace Name Mixin selector official aLege;a(ILrm;)Vintermediary method_44032Lnet/minecraft/class_7479;method_44032(ILnet/minecraft/class_2561;)Vnamed onResponseLnet/minecraft/client/network/ChatPreviewer;onResponse(ILnet/minecraft/text/Text;)V
-
getPreviewText
Returns the preview text (also known as the last response text), ornullif the server responded as such.This does not consume the response.
- Returns:
- the preview text (also known as the last response text), or
nullif the server responded as such - Mappings:
Namespace Name Mixin selector official cLege;c()Lrm;intermediary method_44038Lnet/minecraft/class_7479;method_44038()Lnet/minecraft/class_2561;named getPreviewTextLnet/minecraft/client/network/ChatPreviewer;getPreviewText()Lnet/minecraft/text/Text;
-
tryConsumeResponse
Returns the consumed response text, ornullif the server responded as such, or if the response could not be consumed.If the response is still valid (i.e. the input has not changed since the query was sent), consuming the response will return the response and clear it. Note that to prevent race condition between the player sending the chat message and the response's arrival, responses can only be consumed after the cooldown (by default, 200L milliseconds) has passed. It is also possible to get the response text without consuming by calling
getPreviewText().- Returns:
- the consumed response text, or
nullif the server responded as such, or if the response could not be consumed - Mappings:
Namespace Name Mixin selector official bLege;b(Ljava/lang/String;)Lrm;intermediary method_44037Lnet/minecraft/class_7479;method_44037(Ljava/lang/String;)Lnet/minecraft/class_2561;named tryConsumeResponseLnet/minecraft/client/network/ChatPreviewer;tryConsumeResponse(Ljava/lang/String;)Lnet/minecraft/text/Text;
-
shouldRenderPreview
public boolean shouldRenderPreview()Returns whether the preview should be rendered.- Returns:
- whether the preview should be rendered
- Implementation Note:
- A preview should be rendered if there is a response, a pending query, or a query waiting for the response.
- Mappings:
Namespace Name Mixin selector official dLege;d()Zintermediary method_44040Lnet/minecraft/class_7479;method_44040()Znamed shouldRenderPreviewLnet/minecraft/client/network/ChatPreviewer;shouldRenderPreview()Z
-
normalize
Returns themessagenormalized by trimming it and then normalizing spaces.- Returns:
- the
messagenormalized by trimming it and then normalizing spaces - Mappings:
Namespace Name Mixin selector official dLege;d(Ljava/lang/String;)Ljava/lang/String;intermediary method_44039Lnet/minecraft/class_7479;method_44039(Ljava/lang/String;)Ljava/lang/String;named normalizeLnet/minecraft/client/network/ChatPreviewer;normalize(Ljava/lang/String;)Ljava/lang/String;
-