use of net.minecraft.network.packet.s2c.play.TitleS2CPacket in project HadesGameV2 by CaaMoe.
the class GameCore method sendTitle.
// 发送标题
public void sendTitle(ServerPlayerEntity playerEntity, Text title, Text subtitle, int fadeIn, int fadeOut, int delay) {
TitleFadeS2CPacket time = new TitleFadeS2CPacket(fadeIn, delay, fadeOut);
TitleS2CPacket titlePacket = new TitleS2CPacket(title);
SubtitleS2CPacket subtitlePacket = new SubtitleS2CPacket(subtitle);
playerEntity.networkHandler.sendPacket(time);
playerEntity.networkHandler.sendPacket(titlePacket);
playerEntity.networkHandler.sendPacket(subtitlePacket);
}
use of net.minecraft.network.packet.s2c.play.TitleS2CPacket in project UHC-Mod by CasualUHC.
the class GameManager method startCountDown.
public void startCountDown() {
PlayerUtils.messageEveryPlayer(new LiteralText("Please stand still during the countdown so you don't fall when you get teleported!").formatted(Formatting.GOLD));
// We repeat the code with interval 1 second
AtomicInteger integer = new AtomicInteger(10);
ScheduledFuture<?> future = this.EXECUTOR.scheduleAtFixedRate(() -> {
int i = integer.getAndDecrement();
PlayerUtils.forEveryPlayer(playerEntity -> {
playerEntity.networkHandler.sendPacket(new TitleS2CPacket(new LiteralText(String.valueOf(i)).formatted(Formatting.GREEN)));
playerEntity.playSound(SoundEvents.BLOCK_NOTE_BLOCK_PLING, SoundCategory.MASTER, 1.0F, 3.0F);
});
}, 0, 1, TimeUnit.SECONDS);
this.FUTURES.add(future);
this.FUTURES.add(this.EXECUTOR.schedule(() -> {
future.cancel(true);
PlayerUtils.forEveryPlayer(playerEntity -> {
playerEntity.networkHandler.sendPacket(new TitleS2CPacket(new LiteralText("Good Luck!").formatted(Formatting.GOLD, Formatting.BOLD)));
playerEntity.playSound(SoundEvents.BLOCK_NOTE_BLOCK_BELL, SoundCategory.MASTER, 1.0F, 1.0F);
playerEntity.getHungerManager().setSaturationLevel(20F);
EntityAttributeInstance instance = playerEntity.getAttributes().getCustomInstance(EntityAttributes.GENERIC_MAX_HEALTH);
if (instance != null) {
instance.removeModifier(PlayerUtils.HEALTH_BOOST);
instance.addPersistentModifier(new EntityAttributeModifier(PlayerUtils.HEALTH_BOOST, "Health Boost", GameSettings.HEALTH.getValue(), EntityAttributeModifier.Operation.MULTIPLY_BASE));
}
playerEntity.setHealth(playerEntity.getMaxHealth());
});
// Pushing back to main thread
MinecraftServer server = UHCMod.UHC_SERVER;
PlayerUtils.forEveryPlayer(playerEntity -> {
if (!TeamUtils.isNonTeam(playerEntity.getScoreboardTeam()) && !playerEntity.isSpectator()) {
((ServerPlayerMixinInterface) playerEntity).setCoordsBoolean(true);
playerEntity.changeGameMode(GameMode.SURVIVAL);
playerEntity.sendMessage(new LiteralText("You can disable the coordinates above your hotbar by using /coords"), false);
playerEntity.getInventory().clear();
PlayerUtils.setPlayerPlaying(playerEntity, true);
} else {
playerEntity.changeGameMode(GameMode.SPECTATOR);
}
});
server.execute(() -> {
server.getCommandManager().execute(server.getCommandSource(), "/fill 24 250 24 -25 289 -25 air");
server.getCommandManager().execute(server.getCommandSource(), "/spreadplayers 0 0 500 2900 true @e[type=player]");
Events.ON_ACTIVE.trigger();
});
}, 10, TimeUnit.SECONDS));
}
use of net.minecraft.network.packet.s2c.play.TitleS2CPacket in project pingspam by BasiqueEvangelist.
the class ServerPlayerEntityMixin method tick.
@Inject(method = "tick", at = @At("TAIL"))
private void tick(CallbackInfo ci) {
if (pings.size() > 0 && PingSpam.CONFIG.getConfig().showUnreadMessagesInActionbar) {
actionbarTime--;
if (actionbarTime <= 0) {
actionbarTime = ACTIONBAR_TIME;
networkHandler.sendPacket(new TitleS2CPacket(TitleS2CPacket.Action.ACTIONBAR, new LiteralText("You have " + pings.size() + " unread message" + (pings.size() != 1 ? "s" : "") + ".")));
}
} else {
actionbarTime = 0;
}
}
use of net.minecraft.network.packet.s2c.play.TitleS2CPacket in project dynmap by webbukkit.
the class FabricPlayer method sendTitleText.
/**
* Send title and subtitle text (called from server thread)
*/
@Override
public void sendTitleText(String title, String subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks) {
if (player != null) {
ServerPlayerEntity player = this.player;
TitleFadeS2CPacket times = new TitleFadeS2CPacket(fadeInTicks, stayTicks, fadeOutTicks);
player.networkHandler.sendPacket(times);
if (title != null) {
TitleS2CPacket titlepkt = new TitleS2CPacket(new LiteralText(title));
player.networkHandler.sendPacket(titlepkt);
}
if (subtitle != null) {
SubtitleS2CPacket subtitlepkt = new SubtitleS2CPacket(new LiteralText(subtitle));
player.networkHandler.sendPacket(subtitlepkt);
}
}
}
use of net.minecraft.network.packet.s2c.play.TitleS2CPacket in project dynmap by webbukkit.
the class FabricPlayer method sendTitleText.
/**
* Send title and subtitle text (called from server thread)
*/
@Override
public void sendTitleText(String title, String subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks) {
if (player != null) {
ServerPlayerEntity player = this.player;
TitleFadeS2CPacket times = new TitleFadeS2CPacket(fadeInTicks, stayTicks, fadeOutTicks);
player.networkHandler.sendPacket(times);
if (title != null) {
TitleS2CPacket titlepkt = new TitleS2CPacket(new LiteralText(title));
player.networkHandler.sendPacket(titlepkt);
}
if (subtitle != null) {
SubtitleS2CPacket subtitlepkt = new SubtitleS2CPacket(new LiteralText(subtitle));
player.networkHandler.sendPacket(subtitlepkt);
}
}
}
Aggregations