Interface DelegateProfileable

All Superinterfaces:
Profileable
All Known Implementing Classes:
ProfileContainer.BlockProfileContainer, ProfileContainer.ItemStackProfileContainer, ProfileInstruction

@Internal public interface DelegateProfileable extends Profileable
Ideally this should've been an abstract class with finalized methods, but we usually need another abstract class and Java can't have multiple ones, and also it'd have been better if getDelegateProfile() was protected.
  • Method Details

    • getDelegateProfile

      @Internal @NotNull @NotNull Profileable getDelegateProfile()
      The profileable object which handles all the operations. It doesn't necessarily have to be a constant object, it can change dynamically.
    • getProfile

      @Nullable default @Nullable @Unmodifiable com.mojang.authlib.GameProfile getProfile()
      Description copied from interface: Profileable
      This method should not be used directly unless you know what you're doing.

      The texture which might be cached. If any errors occur, the check may be re-evaluated. The cached values might also be re-evaluated due to expiration.

      Specified by:
      getProfile in interface Profileable
      Returns:
      the original profile (not cloned if possible) for an instance that's always guaranteed to be a copy you can use Profileable.getDisposableProfile() instead. Null if no profile is set (only happens for ProfileContainer).
    • test

      @Nullable default @Nullable ProfileException test()
      Description copied from interface: Profileable
      Tests whether this profile has any issues or throws any exception. This is a good way if you're going to be checking for user issues before trying to ProfileInstruction.apply() them. For now, this is basically equivalent to calling Profileable.getProfile() and catching exceptions. Which means that the profile will be cached if a cache is behind this profile.

      These issues include, wrong username, network issues, etc. Note that some issues only occur when ProfileInstruction.apply() is used. Any other type of exception that might happen are still ignored.

      Specified by:
      test in interface Profileable
    • getDisposableProfile

      @Nullable default @Nullable com.mojang.authlib.GameProfile getDisposableProfile()
      Description copied from interface: Profileable
      Same as Profileable.getProfile(), except some implementations of Profileable cannot inherently return any original instance as they're not cacheable, so this method ensures that no duplicate cloning of GameProfile occurs for performance.

      For most implementations however, this defaults to a simple cloning of the cached instances.

      Specified by:
      getDisposableProfile in interface Profileable
      Returns:
      always a copied version of Profileable.getProfile() that you can change. Null if Profileable.getProfile() is null
    • isReady

      default boolean isReady()
      Description copied from interface: Profileable
      Whether this profile has all the necessary information to construct its Profileable.getProfile() right away. When this method returns false, it means some kind of request has to be sent to Mojang servers in order to retrieve some information.

      Even if this method returns true, it doesn't necessarily mean that this profile has all information (textures, username, UUID, etc.) it merely means that it has all the information it needs in memory to compute its Profileable.getProfile() and doesn't need to a request any data using MinecraftClient.

      Specified by:
      isReady in interface Profileable
      See Also:
    • transform

      @NotNull default @NotNull Profileable transform(@NotNull @NotNull ProfileTransformer... transformers)
      Description copied from interface: Profileable
      Adds transformer (read ProfileTransformer) information to a copied version of this profile (so it doesn't affect this instance, but the class type will change). So it's recommended to not chain this method and instead collect all transformers and call this method once for performance when necessary.

      Profiles are copied before being transformed, so the main cache remains intact but the result of transformed profiles are never cached.

      Specified by:
      transform in interface Profileable
      Parameters:
      transformers - a list of transformers to apply in order once Profileable.getProfile() is called.
    • getProfileValue

      @Nullable default @Nullable String getProfileValue()
      Description copied from interface: Profileable
      A string representation of the Profileable.getProfile() which is useful for data storage which can be serialized back using Profileable.detect(String).

      Note that in some cases this is the Base64 value of the textures property, but some may provide less verbose data when possible. Items and blocks can also provide compact data if their profile was built using ProfileTransformer.includeOriginalValue().

      Specified by:
      getProfileValue in interface Profileable
      Returns:
      null if Profileable.getProfile() is null or the set profile doesn't have a texture property.