Interface MinecraftAudiences

All Known Subinterfaces:
MinecraftClientAudiences, MinecraftServerAudiences

public interface MinecraftAudiences
Common operations in both the client and server environments.

See MinecraftServerAudiences for logical server-specific operations, and MinecraftClientAudiences for logical client-specific operations

In development environments with interface injection, many of the utility methods in this class are redundant.

Since:
6.0.0
  • Method Details

    • update

      default @NotNull net.minecraft.network.chat.Component update(@NotNull net.minecraft.network.chat.Component input, UnaryOperator<Component> modifier)
      Given an existing native component, convert it into an Adventure component for working with.
      Parameters:
      input - source component
      modifier - operator to transform the component
      Returns:
      new component
      Since:
      6.0.0
    • asAdventure

      @Contract("null -> null; !null -> !null") static Key asAdventure(net.minecraft.resources.ResourceLocation loc)
      Convert a MC ResourceLocation instance to a text Key.

      ResourceLocation implements Key at runtime, so this is effectively a cast.

      Parameters:
      loc - The Identifier to convert
      Returns:
      The equivalent data as a Key
      Since:
      6.0.0
    • asNative

      @Contract("null -> null; !null -> !null") static net.minecraft.resources.ResourceLocation asNative(Key key)
      Convert a Kyori Key instance to a MC ResourceLocation.
      Parameters:
      key - The Key to convert
      Returns:
      The equivalent data as a resource location
      Since:
      6.0.0
    • asEmitter

      @Contract("null -> null; !null -> !null") static Sound.Emitter asEmitter(net.minecraft.world.entity.Entity entity)
      Get an Entity's representation as an Sound.Emitter of sounds.
      Parameters:
      entity - the entity to convert
      Returns:
      the entity as a sound emitter
      Since:
      6.0.0
    • asComponentThrowable

      @Contract("null -> null; !null -> !null") default ComponentMessageThrowable asComponentThrowable(com.mojang.brigadier.exceptions.CommandSyntaxException ex)
      Expose a Brigadier CommandSyntaxException's message using the adventure-provided interface for rich-message exceptions.
      Parameters:
      ex - the exception to cast
      Returns:
      a converted command exception
      Since:
      6.0.0
    • nonWrappingSerializer

      @NotNull @NotNull ComponentSerializer<Component,Component,net.minecraft.network.chat.Component> nonWrappingSerializer()
      Return a TextSerializer instance that will do deep conversions between Adventure Components and Minecraft Components.

      This serializer will never wrap text, and can provide MutableComponent instances suitable for passing around the game.

      Returns:
      a serializer instance
      Since:
      6.0.0
    • identified

      @Contract("null -> null; !null -> !null") static Identified identified(net.minecraft.world.entity.player.Player player)
      Get a Player identified by their profile's UUID.
      Parameters:
      player - the player to identify
      Returns:
      an identified representation of the player
      Since:
      6.0.0
    • identity

      @Contract("null -> null; !null -> !null") static Identity identity(com.mojang.authlib.GameProfile profile)
      Get an Identity representation of a GameProfile.
      Parameters:
      profile - the profile to represent
      Returns:
      an identity of the game profile
      Since:
      6.0.0
    • asHoverEvent

      @NotNull static @NotNull HoverEvent<HoverEvent.ShowEntity> asHoverEvent(@NotNull @NotNull net.minecraft.world.entity.Entity entity)
      Returns a HoverEvent that displays the provided Entity.
      Parameters:
      entity - the entity
      Returns:
      hover event
      Since:
      6.0.0
    • asHoverEvent

      @NotNull static @NotNull HoverEvent<HoverEvent.ShowItem> asHoverEvent(@NotNull @NotNull net.minecraft.world.item.ItemStack stack)
      Returns a HoverEvent that displays the provided ItemStack.
      Parameters:
      stack - the item stack
      Returns:
      hover event
      Since:
      6.0.0
    • asSoundType

      @Contract("null -> null; !null -> !null") static Sound.Type asSoundType(net.minecraft.sounds.SoundEvent soundEvent)
      Returns an adventure Sound.Type for the provided SoundEvent.
      Parameters:
      soundEvent - sound event
      Returns:
      sound type
      Since:
      6.0.0
    • key

      @NotNull static @NotNull Key key(@NotNull @NotNull net.minecraft.resources.ResourceKey<?> resourceKey)
      Returns the Kyori Key representation of the ResourceKey's location.
      Parameters:
      resourceKey - resource key
      Returns:
      key
      Since:
      6.0.0
    • asAdventure

      @Contract("null -> null; !null -> !null") static SignedMessage.Signature asAdventure(net.minecraft.network.chat.MessageSignature signature)
      Returns an adventure view of the provided MessageSignature.
      Parameters:
      signature - message signature
      Returns:
      adventure message signature
      Since:
      6.0.0
    • asNative

      @Contract("null -> null; !null -> !null") static net.minecraft.network.chat.MessageSignature asNative(SignedMessage.Signature signature)
      Returns a native view of the provided SignedMessage.Signature.
      Parameters:
      signature - message signature
      Returns:
      native message signature
      Since:
      6.0.0
    • asAdventure

      @Contract("null -> null; !null -> !null") default SignedMessage asAdventure(net.minecraft.network.chat.PlayerChatMessage message)
      Returns an adventure SignedMessage view of the provided PlayerChatMessage.
      Parameters:
      message - player chat message
      Returns:
      signed message
      Since:
      6.0.0
    • dataComponentValue

      @NotNull static <T> @NotNull DataComponentValue dataComponentValue(@NotNull @NotNull net.minecraft.core.component.DataComponentType<T> type, @NotNull T value)
      Get a wrapped value for a certain data component.

      The data component value must not be a transient one.

      Type Parameters:
      T - the value type
      Parameters:
      type - the component type
      value - the value to wrap
      Returns:
      the wrapped value
      Since:
      6.0.0
    • flattener

      @NotNull @NotNull ComponentFlattener flattener()
      Return a component flattener that can use game data to resolve extra information about components.
      Returns:
      the flattener
      Since:
      6.0.0
    • renderer

      @NotNull @NotNull ComponentRenderer<Pointered> renderer()
      Active renderer to render components.
      Returns:
      Shared renderer
      Since:
      6.0.0
    • asNative

      @Contract("null -> null; !null -> !null") net.minecraft.network.chat.Component asNative(Component adventure)
      Get a native Component from an adventure Component.

      The specific type of the returned component is undefined. For example, it may be a wrapper object.

      Parameters:
      adventure - adventure input
      Returns:
      native representation
      Since:
      6.0.0
    • asAdventure

      @Contract("null -> null; !null -> !null") default Component asAdventure(net.minecraft.network.chat.Component vanilla)
      Get an adventure Component from a native Component.
      Parameters:
      vanilla - the native component
      Returns:
      adventure component
      Since:
      6.0.0