Search in sources :

Example 6 with SpongeObjective

use of org.spongepowered.common.scoreboard.SpongeObjective in project SpongeCommon by SpongePowered.

the class MixinScoreboardLogic method addScoreObjective.

// Add objective
@Override
public ScoreObjective addScoreObjective(String name, IScoreCriteria criteria) {
    SpongeObjective objective = new SpongeObjective(name, (Criterion) criteria);
    objective.setDisplayMode((ObjectiveDisplayMode) (Object) criteria.getRenderType());
    this.scoreboard$addObjective(objective);
    return objective.getObjectiveFor(this);
}
Also used : SpongeObjective(org.spongepowered.common.scoreboard.SpongeObjective)

Example 7 with SpongeObjective

use of org.spongepowered.common.scoreboard.SpongeObjective in project SpongeCommon by SpongePowered.

the class MixinScoreboardLogic method scoreboard$updateDisplaySlot.

public void scoreboard$updateDisplaySlot(@Nullable Objective objective, DisplaySlot displaySlot) {
    if (objective != null && !objective.getScoreboards().contains(this)) {
        throw new IllegalStateException("Attempting to set an objective's display slot that does not exist on this scoreboard!");
    }
    int index = ((SpongeDisplaySlot) displaySlot).getIndex();
    this.objectiveDisplaySlots[index] = objective == null ? null : ((SpongeObjective) objective).getObjectiveFor(this);
    this.sendToPlayers(new SPacketDisplayObjective(index, this.objectiveDisplaySlots[index]));
}
Also used : SPacketDisplayObjective(net.minecraft.network.play.server.SPacketDisplayObjective) SpongeObjective(org.spongepowered.common.scoreboard.SpongeObjective) SpongeDisplaySlot(org.spongepowered.common.scoreboard.SpongeDisplaySlot)

Aggregations

SpongeObjective (org.spongepowered.common.scoreboard.SpongeObjective)7 ScoreObjective (net.minecraft.scoreboard.ScoreObjective)4 IMixinScoreObjective (org.spongepowered.common.interfaces.IMixinScoreObjective)4 Score (net.minecraft.scoreboard.Score)2 IMixinScore (org.spongepowered.common.interfaces.IMixinScore)2 SpongeScore (org.spongepowered.common.scoreboard.SpongeScore)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 SPacketDisplayObjective (net.minecraft.network.play.server.SPacketDisplayObjective)1 SPacketScoreboardObjective (net.minecraft.network.play.server.SPacketScoreboardObjective)1 IScoreCriteria (net.minecraft.scoreboard.IScoreCriteria)1 ObjectiveDisplayMode (org.spongepowered.api.scoreboard.objective.displaymode.ObjectiveDisplayMode)1 Text (org.spongepowered.api.text.Text)1 SpongeDisplaySlot (org.spongepowered.common.scoreboard.SpongeDisplaySlot)1