Search in sources :

Example 1 with Objective

use of net.minecraft.world.scores.Objective in project MinecraftForge by MinecraftForge.

the class ForgeIngameGui method renderPlayerList.

protected void renderPlayerList(int width, int height, PoseStack mStack) {
    Objective scoreobjective = this.minecraft.level.getScoreboard().getDisplayObjective(0);
    ClientPacketListener handler = minecraft.player.connection;
    if (minecraft.options.keyPlayerList.isDown() && (!minecraft.isLocalServer() || handler.getOnlinePlayers().size() > 1 || scoreobjective != null)) {
        this.tabList.setVisible(true);
        if (pre(PLAYER_LIST, mStack))
            return;
        this.tabList.render(mStack, width, this.minecraft.level.getScoreboard(), scoreobjective);
        post(PLAYER_LIST, mStack);
    } else {
        this.tabList.setVisible(false);
    }
}
Also used : Objective(net.minecraft.world.scores.Objective) ClientPacketListener(net.minecraft.client.multiplayer.ClientPacketListener)

Example 2 with Objective

use of net.minecraft.world.scores.Objective in project Denizen-For-Bukkit by DenizenScript.

the class SidebarImpl method sendUpdate.

@Override
public void sendUpdate() {
    List<PlayerTeam> oldTeams = generatedTeams;
    generatedTeams = new ArrayList<>();
    PacketHelperImpl.send(player, new ClientboundSetObjectivePacket(this.obj1, 0));
    for (int i = 0; i < this.lines.length; i++) {
        String line = this.lines[i];
        if (line == null) {
            break;
        }
        String lineId = Utilities.generateRandomColors(8);
        PlayerTeam team = new PlayerTeam(dummyScoreboard, lineId);
        team.getPlayers().add(lineId);
        team.setPlayerPrefix(Handler.componentToNMS(FormattedTextHelper.parse(line, ChatColor.WHITE)));
        generatedTeams.add(team);
        PacketHelperImpl.send(player, ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true));
        PacketHelperImpl.send(player, new ClientboundSetScorePacket(ServerScoreboard.Method.CHANGE, obj1.getName(), lineId, this.scores[i]));
    }
    PacketHelperImpl.send(player, new ClientboundSetDisplayObjectivePacket(1, this.obj1));
    PacketHelperImpl.send(player, new ClientboundSetObjectivePacket(this.obj2, 1));
    Objective temp = this.obj2;
    this.obj2 = this.obj1;
    this.obj1 = temp;
    for (PlayerTeam team : oldTeams) {
        PacketHelperImpl.send(player, ClientboundSetPlayerTeamPacket.createRemovePacket(team));
    }
}
Also used : ClientboundSetScorePacket(net.minecraft.network.protocol.game.ClientboundSetScorePacket) Objective(net.minecraft.world.scores.Objective) PlayerTeam(net.minecraft.world.scores.PlayerTeam) ClientboundSetDisplayObjectivePacket(net.minecraft.network.protocol.game.ClientboundSetDisplayObjectivePacket) ClientboundSetObjectivePacket(net.minecraft.network.protocol.game.ClientboundSetObjectivePacket)

Example 3 with Objective

use of net.minecraft.world.scores.Objective in project Denizen-For-Bukkit by DenizenScript.

the class SidebarImpl method sendUpdate.

@Override
public void sendUpdate() {
    List<PlayerTeam> oldTeams = generatedTeams;
    generatedTeams = new ArrayList<>();
    PacketHelperImpl.send(player, new ClientboundSetObjectivePacket(this.obj1, 0));
    for (int i = 0; i < this.lines.length; i++) {
        String line = this.lines[i];
        if (line == null) {
            break;
        }
        String lineId = Utilities.generateRandomColors(8);
        PlayerTeam team = new PlayerTeam(dummyScoreboard, lineId);
        team.getPlayers().add(lineId);
        team.setPlayerPrefix(Handler.componentToNMS(FormattedTextHelper.parse(line, ChatColor.WHITE)));
        generatedTeams.add(team);
        PacketHelperImpl.send(player, ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true));
        PacketHelperImpl.send(player, new ClientboundSetScorePacket(ServerScoreboard.Method.CHANGE, obj1.getName(), lineId, this.scores[i]));
    }
    PacketHelperImpl.send(player, new ClientboundSetDisplayObjectivePacket(1, this.obj1));
    PacketHelperImpl.send(player, new ClientboundSetObjectivePacket(this.obj2, 1));
    Objective temp = this.obj2;
    this.obj2 = this.obj1;
    this.obj1 = temp;
    for (PlayerTeam team : oldTeams) {
        PacketHelperImpl.send(player, ClientboundSetPlayerTeamPacket.createRemovePacket(team));
    }
}
Also used : ClientboundSetScorePacket(net.minecraft.network.protocol.game.ClientboundSetScorePacket) Objective(net.minecraft.world.scores.Objective) PlayerTeam(net.minecraft.world.scores.PlayerTeam) ClientboundSetDisplayObjectivePacket(net.minecraft.network.protocol.game.ClientboundSetDisplayObjectivePacket) ClientboundSetObjectivePacket(net.minecraft.network.protocol.game.ClientboundSetObjectivePacket)

Aggregations

Objective (net.minecraft.world.scores.Objective)3 ClientboundSetDisplayObjectivePacket (net.minecraft.network.protocol.game.ClientboundSetDisplayObjectivePacket)2 ClientboundSetObjectivePacket (net.minecraft.network.protocol.game.ClientboundSetObjectivePacket)2 ClientboundSetScorePacket (net.minecraft.network.protocol.game.ClientboundSetScorePacket)2 PlayerTeam (net.minecraft.world.scores.PlayerTeam)2 ClientPacketListener (net.minecraft.client.multiplayer.ClientPacketListener)1