Class ChatPreviewRequester

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

@Environment(CLIENT) public class ChatPreviewRequester extends Object
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 ehf
intermediary net/minecraft/class_7516
named net/minecraft/client/network/ChatPreviewRequester
  • Field Details

    • EARLIEST_NEXT_QUERY_DELAY

      private static final long EARLIEST_NEXT_QUERY_DELAY
      How 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 Lehf;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_DELAY
      How 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 Lehf;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

      private final MinecraftClient client
      Mappings:
      Namespace Name Mixin selector
      official c Lehf;c:Lefu;
      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

      private final ChatPreviewRequester.IdIncrementor idIncrementor
      Mappings:
      Namespace Name Mixin selector
      official d Lehf;d:Lehf$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

      @Nullable private @Nullable ChatPreviewRequester.Query pendingResponseQuery
      The query that is waiting for the server to respond (i.e. the last query). Can be null if there is no such query.
      Mappings:
      Namespace Name Mixin selector
      official e Lehf;e:Lehf$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 queryTime
      The 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 Lehf;f:J
      intermediary field_39428 Lnet/minecraft/class_7516;field_39428:J
      named queryTime Lnet/minecraft/client/network/ChatPreviewRequester;queryTime:J
  • Constructor Details

    • ChatPreviewRequester

      public ChatPreviewRequester(MinecraftClient client)
      Mappings:
      Namespace Name Mixin selector
      official <init> Lehf;<init>(Lefu;)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

      public boolean tryRequest(String message, long currentTime)
      Sends the request to preview message, 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, otherwise true
      Mappings:
      Namespace Name Mixin selector
      official a Lehf;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

      @Nullable public @Nullable String handleResponse(int id)
      Returns the response's original queried message, or null 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 Lehf;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 Lehf;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 Lehf;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 Lehf;b()Z
      intermediary method_44273 Lnet/minecraft/class_7516;method_44273()Z
      named hasPendingResponseQuery Lnet/minecraft/client/network/ChatPreviewRequester;hasPendingResponseQuery()Z