Interface MinecraftAudiences
- All Known Subinterfaces:
MinecraftClientAudiences, MinecraftServerAudiences
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 Summary
Modifier and TypeMethodDescriptiondefault ComponentasAdventure(net.minecraft.network.chat.Component vanilla) Get an adventureComponentfrom a nativeComponent.static SignedMessage.SignatureasAdventure(net.minecraft.network.chat.MessageSignature signature) Returns an adventure view of the providedMessageSignature.default SignedMessageasAdventure(net.minecraft.network.chat.PlayerChatMessage message) Returns an adventureSignedMessageview of the providedPlayerChatMessage.static KeyasAdventure(net.minecraft.resources.Identifier loc) Convert a MCIdentifierinstance to a text Key.default ComponentMessageThrowableasComponentThrowable(com.mojang.brigadier.exceptions.CommandSyntaxException ex) Expose a Brigadier CommandSyntaxException's message using the adventure-provided interface for rich-message exceptions.static Sound.EmitterasEmitter(net.minecraft.world.entity.Entity entity) Get anEntity's representation as anSound.Emitterof sounds.static @NotNull HoverEvent<HoverEvent.ShowEntity> asHoverEvent(@NotNull net.minecraft.world.entity.Entity entity) Returns aHoverEventthat displays the providedEntity.static @NotNull HoverEvent<HoverEvent.ShowItem> asHoverEvent(@NotNull net.minecraft.world.item.ItemStack stack) Returns aHoverEventthat displays the providedItemStack.static net.minecraft.network.chat.MessageSignatureasNative(SignedMessage.Signature signature) Returns a native view of the providedSignedMessage.Signature.static net.minecraft.resources.IdentifierConvert a KyoriKeyinstance to a MC Identifier.net.minecraft.network.chat.ComponentGet a nativeComponentfrom an adventureComponent.static Sound.TypeasSoundType(net.minecraft.sounds.SoundEvent soundEvent) Returns an adventureSound.Typefor the providedSoundEvent.static <T> @NotNull DataComponentValuedataComponentValue(@NotNull net.minecraft.core.component.DataComponentType<T> type, T value) Get a wrapped value for a certain data component.@NotNull ComponentFlattenerReturn a component flattener that can use game data to resolve extra information about components.static Identifiedidentified(net.minecraft.world.entity.player.Player player) Get aPlayeridentified by their profile'sUUID.static Identityidentity(com.mojang.authlib.GameProfile profile) Get anIdentityrepresentation of aGameProfile.static @NotNull Keykey(@NotNull net.minecraft.resources.ResourceKey<?> resourceKey) @NotNull ComponentSerializer<Component, Component, net.minecraft.network.chat.Component> Return a ComponentSerializer instance that will do deep conversions between AdventureComponentsand MinecraftComponents.static @NotNull ComponentSerializer<Component, Component, net.minecraft.network.chat.Component> nonWrappingSerializer(Supplier<net.minecraft.core.HolderLookup.Provider> provider) Return a ComponentSerializer instance that will do deep conversions between AdventureComponentsand MinecraftComponents.@NotNull ComponentRenderer<Pointered> renderer()Active renderer to render components.default @NotNull net.minecraft.network.chat.Componentupdate(@NotNull net.minecraft.network.chat.Component input, UnaryOperator<Component> modifier) Given an existing native component, convert it into an Adventure component for working with.
-
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 componentmodifier- operator to transform the component- Returns:
- new component
- Since:
- 6.0.0
-
asAdventure
@Contract("null -> null; !null -> !null") static Key asAdventure(net.minecraft.resources.Identifier loc) Convert a MCIdentifierinstance to a text Key.IdentifierimplementsKeyat 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
-
asEmitter
@Contract("null -> null; !null -> !null") static Sound.Emitter asEmitter(net.minecraft.world.entity.Entity entity) Get anEntity's representation as anSound.Emitterof sounds.- Parameters:
entity- the entity to convert- Returns:
- the entity as a sound emitter
- Since:
- 6.0.0
-
nonWrappingSerializer
@NotNull static @NotNull ComponentSerializer<Component, Component, net.minecraft.network.chat.Component> nonWrappingSerializer(Supplier<net.minecraft.core.HolderLookup.Provider> provider) Return a ComponentSerializer instance that will do deep conversions between AdventureComponentsand MinecraftComponents.This serializer will never wrap text, and can provide
MutableComponentinstances suitable for passing around the game. This variant is available to create such a serializer without game context. For in-game use,nonWrappingSerializer()may be simpler.- Parameters:
provider- a provider of registry information- Returns:
- a serializer instance
- Since:
- 6.1.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 ComponentSerializer instance that will do deep conversions between AdventureComponentsand MinecraftComponents.This serializer will never wrap text, and can provide
MutableComponentinstances 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 aPlayeridentified by their profile'sUUID.- Parameters:
player- the player to identify- Returns:
- an identified representation of the player
- Since:
- 6.0.0
-
identity
-
asHoverEvent
@NotNull static @NotNull HoverEvent<HoverEvent.ShowEntity> asHoverEvent(@NotNull @NotNull net.minecraft.world.entity.Entity entity) Returns aHoverEventthat displays the providedEntity.- 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 aHoverEventthat displays the providedItemStack.- 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 adventureSound.Typefor the providedSoundEvent.- Parameters:
soundEvent- sound event- Returns:
- sound type
- Since:
- 6.0.0
-
key
-
asAdventure
@Contract("null -> null; !null -> !null") static SignedMessage.Signature asAdventure(net.minecraft.network.chat.MessageSignature signature) Returns an adventure view of the providedMessageSignature.- 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 providedSignedMessage.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 adventureSignedMessageview of the providedPlayerChatMessage.- 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
transientone.- Type Parameters:
T- the value type- Parameters:
type- the component typevalue- the value to wrap- Returns:
- the wrapped value
- Since:
- 6.0.0
-
flattener
Return a component flattener that can use game data to resolve extra information about components.- Returns:
- the flattener
- Since:
- 6.0.0
-
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 nativeComponentfrom an adventureComponent.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
-