Search in sources :

Example 1 with ScoreboardPlayerUpdateS2CPacket

use of net.minecraft.network.packet.s2c.play.ScoreboardPlayerUpdateS2CPacket in project KahzerxMod by otakucraft.

the class ScoreboardMixin method onCreate.

@Inject(method = "createChangePackets", at = @At(value = "RETURN"))
private void onCreate(ScoreboardObjective objective, CallbackInfoReturnable<List<Packet<?>>> cir) {
    if (ScoreboardExtension.isExtensionEnabled) {
        int i = 0;
        for (ScoreboardPlayerScore score : getAllPlayerScores(objective)) {
            i += score.getScore();
        }
        cir.getReturnValue().add(new ScoreboardPlayerUpdateS2CPacket(ServerScoreboard.UpdateMode.CHANGE, objective.getName(), Formatting.BOLD + "TOTAL", i));
    }
}
Also used : ScoreboardPlayerScore(net.minecraft.scoreboard.ScoreboardPlayerScore) ScoreboardPlayerUpdateS2CPacket(net.minecraft.network.packet.s2c.play.ScoreboardPlayerUpdateS2CPacket) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with ScoreboardPlayerUpdateS2CPacket

use of net.minecraft.network.packet.s2c.play.ScoreboardPlayerUpdateS2CPacket in project KahzerxMod by otakucraft.

the class ScoreboardMixin method onUpdate.

@Inject(method = "updateScore", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/PlayerManager;sendToAll(Lnet/minecraft/network/Packet;)V"))
private void onUpdate(ScoreboardPlayerScore score, CallbackInfo ci) {
    if (ScoreboardExtension.isExtensionEnabled) {
        ScoreboardObjective objective = score.getObjective();
        if (objective == null) {
            return;
        }
        int i = 0;
        for (ScoreboardPlayerScore sc : getAllPlayerScores(objective)) {
            i += sc.getScore();
        }
        server.getPlayerManager().sendToAll(new ScoreboardPlayerUpdateS2CPacket(ServerScoreboard.UpdateMode.CHANGE, objective.getName(), Formatting.BOLD + "TOTAL", i));
    }
}
Also used : ScoreboardPlayerScore(net.minecraft.scoreboard.ScoreboardPlayerScore) ScoreboardObjective(net.minecraft.scoreboard.ScoreboardObjective) ScoreboardPlayerUpdateS2CPacket(net.minecraft.network.packet.s2c.play.ScoreboardPlayerUpdateS2CPacket) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

ScoreboardPlayerUpdateS2CPacket (net.minecraft.network.packet.s2c.play.ScoreboardPlayerUpdateS2CPacket)2 ScoreboardPlayerScore (net.minecraft.scoreboard.ScoreboardPlayerScore)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 ScoreboardObjective (net.minecraft.scoreboard.ScoreboardObjective)1