Search in sources :

Example 1 with ServerPlayNetHandler

use of net.minecraft.network.play.ServerPlayNetHandler in project Magma-1.16.x by magmafoundation.

the class CraftPlayer method kick.

// Paper start
@Override
public void kick(final net.kyori.adventure.text.Component message) {
    org.spigotmc.AsyncCatcher.catchOp("player kick");
    final ServerPlayNetHandler connection = this.getHandle().connection;
    if (connection != null) {
        connection.disconnect(message == null ? net.kyori.adventure.text.Component.empty() : message);
    }
}
Also used : ServerPlayNetHandler(net.minecraft.network.play.ServerPlayNetHandler)

Example 2 with ServerPlayNetHandler

use of net.minecraft.network.play.ServerPlayNetHandler in project Magma-1.16.x by magmafoundation.

the class CraftPlayer method setScoreboard.

@Override
public void setScoreboard(Scoreboard scoreboard) {
    Validate.notNull(scoreboard, "Scoreboard cannot be null");
    ServerPlayNetHandler connection = getHandle().connection;
    if (connection == null) {
        throw new IllegalStateException("Cannot set scoreboard yet");
    }
    if (connection.isDisconnected()) {
    // throw new IllegalStateException("Cannot set scoreboard for invalid CraftPlayer"); // Spigot - remove this as Mojang's semi asynchronous Netty implementation can lead to races
    }
    this.server.getScoreboardManager().setPlayerBoard(this, scoreboard);
}
Also used : ServerPlayNetHandler(net.minecraft.network.play.ServerPlayNetHandler)

Example 3 with ServerPlayNetHandler

use of net.minecraft.network.play.ServerPlayNetHandler in project Magma-1.16.x by magmafoundation.

the class CraftPlayer method showTitle.

@Override
public void showTitle(final net.kyori.adventure.title.Title title) {
    final ServerPlayNetHandler connection = this.getHandle().connection;
    final net.kyori.adventure.title.Title.Times times = title.times();
    if (times != null) {
        connection.send(new STitlePacket(ticks(times.fadeIn()), ticks(times.stay()), ticks(times.fadeOut())));
    }
    final STitlePacket sp = new STitlePacket(STitlePacket.Type.SUBTITLE, null);
    sp.adventure$text = title.subtitle();
    connection.send(sp);
    final STitlePacket tp = new STitlePacket(STitlePacket.Type.TITLE, null);
    tp.adventure$text = title.title();
    connection.send(tp);
}
Also used : ServerPlayNetHandler(net.minecraft.network.play.ServerPlayNetHandler) Title(com.destroystokyo.paper.Title) STitlePacket(net.minecraft.network.play.server.STitlePacket)

Example 4 with ServerPlayNetHandler

use of net.minecraft.network.play.ServerPlayNetHandler in project Magma-1.16.x by magmafoundation.

the class CraftPlayer method adventure$sendPlayerListHeaderAndFooter.

private void adventure$sendPlayerListHeaderAndFooter() {
    final ServerPlayNetHandler connection = this.getHandle().connection;
    if (connection == null)
        return;
    final SPlayerListHeaderFooterPacket packet = new SPlayerListHeaderFooterPacket();
    packet.adventure$header = (this.playerListHeader == null) ? net.kyori.adventure.text.Component.empty() : this.playerListHeader;
    packet.adventure$footer = (this.playerListFooter == null) ? net.kyori.adventure.text.Component.empty() : this.playerListFooter;
    connection.send(packet);
}
Also used : SPlayerListHeaderFooterPacket(net.minecraft.network.play.server.SPlayerListHeaderFooterPacket) ServerPlayNetHandler(net.minecraft.network.play.ServerPlayNetHandler)

Example 5 with ServerPlayNetHandler

use of net.minecraft.network.play.ServerPlayNetHandler in project AstralSorcery by HellFirePvP.

the class ASMHookEndpoint method getOverriddenSeenEntityReachMaximum.

// Kept as JS since mixins might clash if multiple mods are targeting the 36.0 constant
public static double getOverriddenSeenEntityReachMaximum(ServerPlayNetHandler handler, double original) {
    PlayerEntity player = handler.player;
    PlayerProgress prog = ResearchHelper.getProgress(player, player.getEntityWorld().isRemote() ? LogicalSide.CLIENT : LogicalSide.SERVER);
    if (prog.isValid() && prog.getPerkData().hasPerkEffect(perk -> perk instanceof KeyEntityReach)) {
        return 999_999_999.0;
    }
    return original;
}
Also used : PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress) ResearchHelper(hellfirepvp.astralsorcery.common.data.research.ResearchHelper) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Minecraft(net.minecraft.client.Minecraft) KeyEntityReach(hellfirepvp.astralsorcery.common.perk.node.key.KeyEntityReach) ServerPlayNetHandler(net.minecraft.network.play.ServerPlayNetHandler) Dist(net.minecraftforge.api.distmarker.Dist) LogicalSide(net.minecraftforge.fml.LogicalSide) KeyEntityReach(hellfirepvp.astralsorcery.common.perk.node.key.KeyEntityReach) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Aggregations

ServerPlayNetHandler (net.minecraft.network.play.ServerPlayNetHandler)11 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)3 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 Title (com.destroystokyo.paper.Title)1 ServerPlayer (com.irtimaled.bbor.common.models.ServerPlayer)1 PlayerProgress (hellfirepvp.astralsorcery.common.data.research.PlayerProgress)1 ResearchHelper (hellfirepvp.astralsorcery.common.data.research.ResearchHelper)1 KeyEntityReach (hellfirepvp.astralsorcery.common.perk.node.key.KeyEntityReach)1 Minecraft (net.minecraft.client.Minecraft)1 ClientPlayNetHandler (net.minecraft.client.network.play.ClientPlayNetHandler)1 PlayerInventory (net.minecraft.entity.player.PlayerInventory)1 NetworkManager (net.minecraft.network.NetworkManager)1 SOpenBookWindowPacket (net.minecraft.network.play.server.SOpenBookWindowPacket)1 SPlayerListHeaderFooterPacket (net.minecraft.network.play.server.SPlayerListHeaderFooterPacket)1 SSetSlotPacket (net.minecraft.network.play.server.SSetSlotPacket)1 STitlePacket (net.minecraft.network.play.server.STitlePacket)1 World (net.minecraft.world.World)1 Dist (net.minecraftforge.api.distmarker.Dist)1 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)1 LogicalSide (net.minecraftforge.fml.LogicalSide)1