Search in sources :

Example 1 with IScoreCriteria

use of net.minecraft.scoreboard.IScoreCriteria in project SpongeCommon by SpongePowered.

the class SpongeObjective method getObjectiveFor.

public ScoreObjective getObjectiveFor(net.minecraft.scoreboard.Scoreboard scoreboard) {
    if (this.objectives.containsKey(scoreboard)) {
        return this.objectives.get(scoreboard);
    }
    ScoreObjective objective = new ScoreObjective(scoreboard, this.name, (IScoreCriteria) this.criterion);
    // We deliberately set the fields here instead of using the methods.
    // Since a new objective is being created here, we want to avoid
    // sending packets until everything is in the proper state.
    objective.displayName = SpongeTexts.toLegacy(this.displayName);
    objective.renderType = (IScoreCriteria.EnumRenderType) (Object) this.displayMode;
    ((IMixinScoreObjective) objective).setSpongeObjective(this);
    this.objectives.put(scoreboard, objective);
    return objective;
}
Also used : ScoreObjective(net.minecraft.scoreboard.ScoreObjective) IMixinScoreObjective(org.spongepowered.common.interfaces.IMixinScoreObjective) IMixinScoreObjective(org.spongepowered.common.interfaces.IMixinScoreObjective) IScoreCriteria(net.minecraft.scoreboard.IScoreCriteria)

Example 2 with IScoreCriteria

use of net.minecraft.scoreboard.IScoreCriteria in project SpongeCommon by SpongePowered.

the class SpongeObjectiveBuilder method build.

@Override
public Objective build() throws IllegalStateException {
    checkState(this.name != null, "Name cannot be null");
    checkState(this.criterion != null, "Criterion cannot be null");
    SpongeObjective objective = new SpongeObjective(this.name, this.criterion);
    if (this.displayName != null) {
        objective.setDisplayName(this.displayName);
    }
    if (this.objectiveDisplayMode != null) {
        objective.setDisplayMode(this.objectiveDisplayMode);
    } else if (this.criterion instanceof IScoreCriteria) {
        objective.setDisplayMode((ObjectiveDisplayMode) (Object) ((IScoreCriteria) this.criterion).getRenderType());
    }
    return objective;
}
Also used : IScoreCriteria(net.minecraft.scoreboard.IScoreCriteria) SpongeObjective(org.spongepowered.common.scoreboard.SpongeObjective) ObjectiveDisplayMode(org.spongepowered.api.scoreboard.objective.displaymode.ObjectiveDisplayMode)

Aggregations

IScoreCriteria (net.minecraft.scoreboard.IScoreCriteria)2 ScoreObjective (net.minecraft.scoreboard.ScoreObjective)1 ObjectiveDisplayMode (org.spongepowered.api.scoreboard.objective.displaymode.ObjectiveDisplayMode)1 IMixinScoreObjective (org.spongepowered.common.interfaces.IMixinScoreObjective)1 SpongeObjective (org.spongepowered.common.scoreboard.SpongeObjective)1