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));
}
}
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));
}
}
Aggregations