Search in sources :

Example 1 with ScoreboardAccessor

use of org.spongepowered.common.accessor.world.scores.ScoreboardAccessor in project SpongeCommon by SpongePowered.

the class ServerScoreboardMixin method bridge$updateDisplaySlot.

@Override
public void bridge$updateDisplaySlot(@Nullable final Objective objective, final int slot) throws IllegalStateException {
    if (objective != null && !objective.scoreboards().contains(this)) {
        throw new IllegalStateException("Attempting to set an objective's display slot that does not exist on this scoreboard!");
    }
    ((ScoreboardAccessor) this).accessor$displayObjectives()[slot] = objective == null ? null : ((SpongeObjective) objective).getObjectiveFor(this);
    ((ServerScoreboardBridge) this).bridge$sendToPlayers(new ClientboundSetDisplayObjectivePacket(slot, ((ScoreboardAccessor) this).accessor$displayObjectives()[slot]));
}
Also used : ClientboundSetDisplayObjectivePacket(net.minecraft.network.protocol.game.ClientboundSetDisplayObjectivePacket) ScoreboardAccessor(org.spongepowered.common.accessor.world.scores.ScoreboardAccessor) SpongeObjective(org.spongepowered.common.scoreboard.SpongeObjective) ServerScoreboardBridge(org.spongepowered.common.bridge.server.ServerScoreboardBridge)

Aggregations

ClientboundSetDisplayObjectivePacket (net.minecraft.network.protocol.game.ClientboundSetDisplayObjectivePacket)1 ScoreboardAccessor (org.spongepowered.common.accessor.world.scores.ScoreboardAccessor)1 ServerScoreboardBridge (org.spongepowered.common.bridge.server.ServerScoreboardBridge)1 SpongeObjective (org.spongepowered.common.scoreboard.SpongeObjective)1