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())));
}
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 + "'");
}
}
Aggregations