Search in sources :

Example 1 with ClientboundSetTitlesPacket

use of net.minecraft.network.protocol.game.ClientboundSetTitlesPacket in project SpongeCommon by SpongePowered.

the class ServerPlayerMixin_API method showTitle.

@Override
public void showTitle(final Title title) {
    if (this.impl$isFake) {
        return;
    }
    final Title.Times times = Objects.requireNonNull(title, "title").times();
    if (times != null) {
        this.connection.send(new ClientboundSetTitlesPacket(this.api$durationToTicks(times.fadeIn()), this.api$durationToTicks(times.stay()), this.api$durationToTicks(times.fadeOut())));
    }
    this.connection.send(new ClientboundSetTitlesPacket(ClientboundSetTitlesPacket.Type.SUBTITLE, SpongeAdventure.asVanilla(title.subtitle())));
    this.connection.send(new ClientboundSetTitlesPacket(ClientboundSetTitlesPacket.Type.TITLE, SpongeAdventure.asVanilla(title.title())));
}
Also used : ClientboundSetTitlesPacket(net.minecraft.network.protocol.game.ClientboundSetTitlesPacket) Title(net.kyori.adventure.title.Title)

Example 2 with ClientboundSetTitlesPacket

use of net.minecraft.network.protocol.game.ClientboundSetTitlesPacket in project SpongeCommon by SpongePowered.

the class ServerPlayerMixin_API method sendTitlePart.

@Override
public <T> void sendTitlePart(@NotNull final TitlePart<T> part, @NotNull final T value) {
    if (this.impl$isFake) {
        return;
    }
    Objects.requireNonNull(value, "value");
    if (part == TitlePart.TITLE) {
        this.connection.send(new ClientboundSetTitlesPacket(ClientboundSetTitlesPacket.Type.TITLE, SpongeAdventure.asVanilla((Component) value)));
    } else if (part == TitlePart.SUBTITLE) {
        this.connection.send(new ClientboundSetTitlesPacket(ClientboundSetTitlesPacket.Type.SUBTITLE, SpongeAdventure.asVanilla((Component) value)));
    } else if (part == TitlePart.TIMES) {
        final Title.Times times = (Title.Times) value;
        this.connection.send(new ClientboundSetTitlesPacket(this.api$durationToTicks(times.fadeIn()), this.api$durationToTicks(times.stay()), this.api$durationToTicks(times.fadeOut())));
    } else {
        throw new IllegalArgumentException("Unknown TitlePart '" + part + "'");
    }
}
Also used : ClientboundSetTitlesPacket(net.minecraft.network.protocol.game.ClientboundSetTitlesPacket) Title(net.kyori.adventure.title.Title) Component(net.kyori.adventure.text.Component)

Aggregations

Title (net.kyori.adventure.title.Title)2 ClientboundSetTitlesPacket (net.minecraft.network.protocol.game.ClientboundSetTitlesPacket)2 Component (net.kyori.adventure.text.Component)1