Interface PlayerHeadObjectContents

All Superinterfaces:
ObjectContents

public sealed interface PlayerHeadObjectContents extends ObjectContents
The contents of a player head.

This object closely mirrors the serialized form of the component contents. This means the game will use its standard heuristics to determine whether the profile needs resolving before display. As of 1.21.9, the profile will be resolved if the name or id is present without any properties.

Since:
4.25.0
Since Minecraft:
1.21.9
  • Field Details

    • DEFAULT_HAT

      static final boolean DEFAULT_HAT
      The default value for whether the player's hat layer should render.
      Since:
      4.25.0
      See Also:
    • NAME_REGEX

      @RegExp static final String NAME_REGEX
      The regular expression for a valid player name.

      This expression matches vanilla Minecraft's validation for what is considered a valid player name. It is a wider validation than what is allowed when currently creating a username.

      Since:
      5.1.0
      See Also:
  • Method Details

    • isValidName

      static boolean isValidName(String name)
      Checks if the given name is a valid player name for a player head object.
      Parameters:
      name - the name to validate
      Returns:
      if the name is valid
      Since:
      5.1.0
      See Also:
    • name

      @Nullable String name()
      Gets the name of the player if present.
      Returns:
      the name of the player or null
      Since:
      4.25.0
    • id

      @Nullable UUID id()
      Gets the UUID of the player if present.
      Returns:
      the UUID of the player or null
      Since:
      4.25.0
    • profileProperties

      @Unmodifiable List<PlayerHeadObjectContents.ProfileProperty> profileProperties()
      Gets the profile properties for the player.
      Returns:
      the properties
      Since:
      4.25.0
    • hat

      boolean hat()
      Whether the player head should render the player's hat layer.
      Returns:
      whether to render the hat layer
      Since:
      4.25.0
    • texture

      @Nullable Key texture()
      Optional namespaced ID of the skin texture to use for rendering.

      The skin is specified relative to the textures folder and with a .png suffix e.g. entity/player/wide/steve will use the default wide Steve skin.

      Overrides the skin specified by the profile properties if present.

      Returns:
      the texture key
      Since:
      4.25.0
    • toBuilder

      @Contract(value="-> new", pure=true) PlayerHeadObjectContents.Builder toBuilder()
      Creates a builder from the state of this object.
      Returns:
      a new builder
      Since:
      4.25.0
    • property

      @Contract(value="_, _ -> new", pure=true) static PlayerHeadObjectContents.ProfileProperty property(String name, String value)
      Creates a profile property with the given value and no signature.
      Parameters:
      name - the name
      value - the value
      Returns:
      a profile property
      Since:
      4.25.0
    • property

      @Contract(value="_, _, _ -> new", pure=true) static PlayerHeadObjectContents.ProfileProperty property(String name, String value, @Nullable String signature)
      Creates a profile property with the given value and signature.
      Parameters:
      name - the name
      value - the value
      signature - the signature, may be null
      Returns:
      a profile property
      Since:
      4.25.0