Class ChatPreviewer

java.lang.Object
net.minecraft.client.network.ChatPreviewer

@Environment(CLIENT) public class ChatPreviewer extends Object
Chat previewer manages the chat preview. Chat previewer is created per 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 ege
intermediary net/minecraft/class_7479
named net/minecraft/client/network/ChatPreviewer
  • Field Details

    • CONSUME_COOLDOWN

      private static final long CONSUME_COOLDOWN
      How 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 a Lege;a:J
      intermediary field_39328 Lnet/minecraft/class_7479;field_39328:J
      named CONSUME_COOLDOWN Lnet/minecraft/client/network/ChatPreviewer;CONSUME_COOLDOWN:J
    • field_39429

      private boolean field_39429
      Mappings:
      Namespace Name Mixin selector
      official b Lege;b:Z
      intermediary field_39429 Lnet/minecraft/class_7479;field_39429:Z
      named field_39429 Lnet/minecraft/client/network/ChatPreviewer;field_39429:Z
    • field_39430

      @Nullable private @Nullable String field_39430
      Mappings:
      Namespace Name Mixin selector
      official c Lege;c:Ljava/lang/String;
      intermediary field_39430 Lnet/minecraft/class_7479;field_39430:Ljava/lang/String;
      named field_39430 Lnet/minecraft/client/network/ChatPreviewer;field_39430:Ljava/lang/String;
    • field_39431

      @Nullable private @Nullable String field_39431
      Mappings:
      Namespace Name Mixin selector
      official d Lege;d:Ljava/lang/String;
      intermediary field_39431 Lnet/minecraft/class_7479;field_39431:Ljava/lang/String;
      named field_39431 Lnet/minecraft/client/network/ChatPreviewer;field_39431:Ljava/lang/String;
    • field_39432

      private final class_7516 field_39432
      Mappings:
      Namespace Name Mixin selector
      official e Lege;e:Legd;
      intermediary field_39432 Lnet/minecraft/class_7479;field_39432:Lnet/minecraft/class_7516;
      named field_39432 Lnet/minecraft/client/network/ChatPreviewer;field_39432:Lnet/minecraft/class_7516;
    • lastResponse

      Mappings:
      Namespace Name Mixin selector
      official f Lege;f:Lege$a;
      intermediary field_39334 Lnet/minecraft/class_7479;field_39334:Lnet/minecraft/class_7479$class_7481;
      named lastResponse Lnet/minecraft/client/network/ChatPreviewer;lastResponse:Lnet/minecraft/client/network/ChatPreviewer$Response;
  • Constructor Details

    • ChatPreviewer

      public ChatPreviewer(MinecraftClient client)
      Mappings:
      Namespace Name Mixin selector
      official <init> Lege;<init>(Lees;)V
      intermediary <init> Lnet/minecraft/class_7479;<init>(Lnet/minecraft/class_310;)V
      named <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 a Lege;a()V
      intermediary method_44031 Lnet/minecraft/class_7479;method_44031()V
      named tryQuery Lnet/minecraft/client/network/ChatPreviewer;tryQuery()V
    • method_44274

      public void method_44274(String string)
      Mappings:
      Namespace Name Mixin selector
      official a Lege;a(Ljava/lang/String;)V
      intermediary method_44274 Lnet/minecraft/class_7479;method_44274(Ljava/lang/String;)V
      named method_44274 Lnet/minecraft/client/network/ChatPreviewer;method_44274(Ljava/lang/String;)V
    • method_44276

      private void method_44276(String string)
      Mappings:
      Namespace Name Mixin selector
      official c Lege;c(Ljava/lang/String;)V
      intermediary method_44276 Lnet/minecraft/class_7479;method_44276(Ljava/lang/String;)V
      named method_44276 Lnet/minecraft/client/network/ChatPreviewer;method_44276(Ljava/lang/String;)V
    • method_44275

      public void method_44275()
      Mappings:
      Namespace Name Mixin selector
      official b Lege;b()V
      intermediary method_44275 Lnet/minecraft/class_7479;method_44275()V
      named method_44275 Lnet/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 e Lege;e()V
      intermediary method_44036 Lnet/minecraft/class_7479;method_44036()V
      named clear Lnet/minecraft/client/network/ChatPreviewer;clear()V
    • onResponse

      public void onResponse(int id, @Nullable @Nullable Text response)
      Called when the preview response was received.
      Implementation Note:
      This sets the last response and clears
      invalid @link
      #pendingResponseQuery
      if the pending query ID equals id
      Mappings:
      Namespace Name Mixin selector
      official a Lege;a(ILrm;)V
      intermediary method_44032 Lnet/minecraft/class_7479;method_44032(ILnet/minecraft/class_2561;)V
      named onResponse Lnet/minecraft/client/network/ChatPreviewer;onResponse(ILnet/minecraft/text/Text;)V
    • getPreviewText

      @Nullable public @Nullable Text getPreviewText()
      Returns the preview text (also known as the last response text), or null if the server responded as such.

      This does not consume the response.

      Returns:
      the preview text (also known as the last response text), or null if the server responded as such
      Mappings:
      Namespace Name Mixin selector
      official c Lege;c()Lrm;
      intermediary method_44038 Lnet/minecraft/class_7479;method_44038()Lnet/minecraft/class_2561;
      named getPreviewText Lnet/minecraft/client/network/ChatPreviewer;getPreviewText()Lnet/minecraft/text/Text;
    • tryConsumeResponse

      @Nullable public @Nullable Text tryConsumeResponse(String message)
      Returns the consumed response text, or null if 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 null if the server responded as such, or if the response could not be consumed
      Mappings:
      Namespace Name Mixin selector
      official b Lege;b(Ljava/lang/String;)Lrm;
      intermediary method_44037 Lnet/minecraft/class_7479;method_44037(Ljava/lang/String;)Lnet/minecraft/class_2561;
      named tryConsumeResponse Lnet/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 d Lege;d()Z
      intermediary method_44040 Lnet/minecraft/class_7479;method_44040()Z
      named shouldRenderPreview Lnet/minecraft/client/network/ChatPreviewer;shouldRenderPreview()Z
    • normalize

      static String normalize(String message)
      Returns the message normalized by trimming it and then normalizing spaces.
      Returns:
      the message normalized by trimming it and then normalizing spaces
      Mappings:
      Namespace Name Mixin selector
      official d Lege;d(Ljava/lang/String;)Ljava/lang/String;
      intermediary method_44039 Lnet/minecraft/class_7479;method_44039(Ljava/lang/String;)Ljava/lang/String;
      named normalize Lnet/minecraft/client/network/ChatPreviewer;normalize(Ljava/lang/String;)Ljava/lang/String;