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 Summary
Modifier and TypeMethodDescriptiondefault Component
asAdventure
(net.minecraft.network.chat.Component vanilla) Get an adventureComponent
from a nativeComponent
.static SignedMessage.Signature
asAdventure
(net.minecraft.network.chat.MessageSignature signature) Returns an adventure view of the providedMessageSignature
.default SignedMessage
asAdventure
(net.minecraft.network.chat.PlayerChatMessage message) Returns an adventureSignedMessage
view of the providedPlayerChatMessage
.static Key
asAdventure
(net.minecraft.resources.ResourceLocation loc) Convert a MCResourceLocation
instance to a text Key.default ComponentMessageThrowable
asComponentThrowable
(com.mojang.brigadier.exceptions.CommandSyntaxException ex) Expose a Brigadier CommandSyntaxException's message using the adventure-provided interface for rich-message exceptions.static Sound.Emitter
asEmitter
(net.minecraft.world.entity.Entity entity) Get anEntity
's representation as anSound.Emitter
of sounds.static @NotNull HoverEvent
<HoverEvent.ShowEntity> asHoverEvent
(@NotNull net.minecraft.world.entity.Entity entity) Returns aHoverEvent
that displays the providedEntity
.static @NotNull HoverEvent
<HoverEvent.ShowItem> asHoverEvent
(@NotNull net.minecraft.world.item.ItemStack stack) Returns aHoverEvent
that displays the providedItemStack
.static net.minecraft.network.chat.MessageSignature
asNative
(SignedMessage.Signature signature) Returns a native view of the providedSignedMessage.Signature
.static net.minecraft.resources.ResourceLocation
Convert a KyoriKey
instance to a MC ResourceLocation.net.minecraft.network.chat.Component
Get a nativeComponent
from an adventureComponent
.static Sound.Type
asSoundType
(net.minecraft.sounds.SoundEvent soundEvent) Returns an adventureSound.Type
for the providedSoundEvent
.static <T> @NotNull DataComponentValue
dataComponentValue
(@NotNull net.minecraft.core.component.DataComponentType<T> type, T value) Get a wrapped value for a certain data component.@NotNull ComponentFlattener
Return a component flattener that can use game data to resolve extra information about components.static Identified
identified
(net.minecraft.world.entity.player.Player player) Get aPlayer
identified by their profile'sUUID
.static Identity
identity
(com.mojang.authlib.GameProfile profile) Get anIdentity
representation of aGameProfile
.static @NotNull Key
key
(@NotNull net.minecraft.resources.ResourceKey<?> resourceKey) @NotNull ComponentSerializer
<Component, Component, net.minecraft.network.chat.Component> Return a TextSerializer instance that will do deep conversions between AdventureComponents
and MinecraftComponents
.@NotNull ComponentRenderer
<Pointered> renderer()
Active renderer to render components.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.
-
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.ResourceLocation loc) Convert a MCResourceLocation
instance to a text Key.ResourceLocation
implementsKey
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 KyoriKey
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 anEntity
's representation as anSound.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, nonWrappingSerializer()net.minecraft.network.chat.Component> Return a TextSerializer instance that will do deep conversions between AdventureComponents
and MinecraftComponents
.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 aPlayer
identified by their profile'sUUID
.- 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 anIdentity
representation of aGameProfile
.- 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 aHoverEvent
that 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 aHoverEvent
that 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.Type
for the providedSoundEvent
.- Parameters:
soundEvent
- sound event- Returns:
- sound type
- Since:
- 6.0.0
-
key
@NotNull static @NotNull Key key(@NotNull @NotNull net.minecraft.resources.ResourceKey<?> resourceKey) - 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 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 adventureSignedMessage
view 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
transient
one.- 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 nativeComponent
from 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
@Contract("null -> null; !null -> !null") default Component asAdventure(net.minecraft.network.chat.Component vanilla) Get an adventureComponent
from a nativeComponent
.- Parameters:
vanilla
- the native component- Returns:
- adventure component
- Since:
- 6.0.0
-