use of net.minecraft.scoreboard.Score in project SpongeCommon by SpongePowered.
the class MixinScoreboardLogic method scoreboard$removeObjective.
@SuppressWarnings({ "rawtypes" })
public void scoreboard$removeObjective(Objective objective) {
ScoreObjective scoreObjective = ((SpongeObjective) objective).getObjectiveFor(this);
this.scoreObjectives.remove(scoreObjective.getName());
for (int i = 0; i < 19; ++i) {
if (this.getObjectiveInDisplaySlot(i) == scoreObjective) {
this.setObjectiveInDisplaySlot(i, null);
}
}
this.sendToPlayers(new SPacketScoreboardObjective(scoreObjective, SpongeScoreboardConstants.OBJECTIVE_PACKET_REMOVE));
List list = this.scoreObjectiveCriterias.get(scoreObjective.getCriteria());
if (list != null) {
list.remove(scoreObjective);
}
for (Map<ScoreObjective, net.minecraft.scoreboard.Score> scoreMap : this.entitiesScoreObjectives.values()) {
Score score = scoreMap.remove(scoreObjective);
if (score != null) {
((IMixinScore) score).getSpongeScore().removeScoreFor(scoreObjective);
}
}
// We deliberately don't call func_96533_c, because there's no need
this.markSaveDataDirty();
((SpongeObjective) objective).removeObjectiveFor(this);
}
use of net.minecraft.scoreboard.Score in project SpongeCommon by SpongePowered.
the class MixinScoreboardLogic method removeObjectiveFromEntity.
@Override
public void removeObjectiveFromEntity(String name, ScoreObjective objective) {
if (objective != null) {
SpongeObjective spongeObjective = ((IMixinScoreObjective) objective).getSpongeObjective();
Optional<org.spongepowered.api.scoreboard.Score> score = spongeObjective.getScore(SpongeTexts.fromLegacy(name));
if (score.isPresent()) {
spongeObjective.removeScore(score.get());
} else {
SpongeImpl.getLogger().warn("Objective " + objective + " did have have the score " + name);
}
} else {
Text textName = SpongeTexts.fromLegacy(name);
for (ScoreObjective scoreObjective : this.scoreObjectives.values()) {
((IMixinScoreObjective) scoreObjective).getSpongeObjective().removeScore(textName);
}
}
}
use of net.minecraft.scoreboard.Score in project SpongeCommon by SpongePowered.
the class MixinEntityPlayerMP method onDeath.
/**
* @author blood - May 12th, 2016
* @author gabizou - June 3rd, 2016
*
* @reason SpongeForge requires an overwrite so we do it here instead. This handles player death events.
*/
@Override
@Overwrite
public void onDeath(DamageSource cause) {
// Sponge start
DestructEntityEvent.Death event = SpongeCommonEventFactory.callDestructEntityEventDeath((EntityPlayerMP) (Object) this, cause);
// Double check that the PhaseTracker is already capturing the Death phase
final PhaseTracker phaseTracker;
final boolean tracksEntityDeaths;
if (!this.world.isRemote) {
phaseTracker = PhaseTracker.getInstance();
final PhaseData peek = phaseTracker.getCurrentPhaseData();
final IPhaseState state = peek.state;
tracksEntityDeaths = state.tracksEntityDeaths();
} else {
phaseTracker = null;
tracksEntityDeaths = false;
}
try (PhaseContext<?> context = !tracksEntityDeaths ? EntityPhase.State.DEATH.createPhaseContext().source(this).setDamageSource((org.spongepowered.api.event.cause.entity.damage.source.DamageSource) cause).buildAndSwitch() : null) {
// Sponge end
boolean flag = this.world.getGameRules().getBoolean("showDeathMessages");
this.connection.sendPacket(new SPacketCombatEvent(this.getCombatTracker(), SPacketCombatEvent.Event.ENTITY_DIED, flag));
if (flag) {
Team team = this.getTeam();
if (team != null && team.getDeathMessageVisibility() != Team.EnumVisible.ALWAYS) {
if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OTHER_TEAMS) {
this.mcServer.getPlayerList().sendMessageToAllTeamMembers((EntityPlayerMP) (Object) this, this.getCombatTracker().getDeathMessage());
} else if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OWN_TEAM) {
this.mcServer.getPlayerList().sendMessageToTeamOrAllPlayers((EntityPlayerMP) (Object) this, this.getCombatTracker().getDeathMessage());
}
} else {
this.mcServer.getPlayerList().sendMessage(this.getCombatTracker().getDeathMessage());
}
}
this.spawnShoulderEntities();
// Ignore keepInventory GameRule instead use keepInventory from Event
if (!event.getKeepInventory() && !this.isSpectator()) {
this.destroyVanishingCursedItems();
this.inventory.dropAllItems();
}
for (ScoreObjective scoreobjective : this.getWorldScoreboard().getObjectivesFromCriteria(IScoreCriteria.DEATH_COUNT)) {
Score score = this.getWorldScoreboard().getOrCreateScore(this.getName(), scoreobjective);
score.incrementScore();
}
EntityLivingBase entitylivingbase = this.getAttackingEntity();
if (entitylivingbase != null) {
EntityList.EntityEggInfo entitylist$entityegginfo = EntityList.ENTITY_EGGS.get(EntityList.getKey(entitylivingbase));
if (entitylist$entityegginfo != null) {
this.addStat(entitylist$entityegginfo.entityKilledByStat);
}
entitylivingbase.awardKillScore((EntityPlayerMP) (Object) this, this.scoreValue, cause);
}
this.addStat(StatList.DEATHS);
this.takeStat(StatList.TIME_SINCE_DEATH);
this.extinguish();
this.setFlag(0, false);
this.getCombatTracker().reset();
this.keepInventory = event.getKeepInventory();
}
// Sponge - brackets
}
use of net.minecraft.scoreboard.Score in project takumicraft by TNTModders.
the class RenderPlayerSP method renderEntityName.
/**
* Allows the render to do state modifications necessary before the model is rendered.
*/
/* @Override
protected void preRenderCallback(AbstractClientPlayer entitylivingbaseIn, float partialTickTime) {
float f = 0.9375F;
GlStateManager.scale(0.9375F, 0.9375F, 0.9375F);
}*/
@Override
protected void renderEntityName(AbstractClientPlayer entityIn, double x, double y, double z, String name, double distanceSq) {
if (distanceSq < 100.0D) {
Scoreboard scoreboard = entityIn.getWorldScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjectiveInDisplaySlot(2);
if (scoreobjective != null) {
Score score = scoreboard.getOrCreateScore(entityIn.getName(), scoreobjective);
this.renderLivingLabel(entityIn, score.getScorePoints() + " " + scoreobjective.getDisplayName(), x, y, z, 64);
y += (double) ((float) this.getFontRendererFromRenderManager().FONT_HEIGHT * 1.15F * 0.025F);
}
}
super.renderEntityName(entityIn, x, y, z, name, distanceSq);
}
use of net.minecraft.scoreboard.Score in project ct.js by ChatTriggers.
the class TabList method getNamesByObjectives.
/**
* Gets names set in scoreboard objectives (useful for newer games)
*
* @return The formatted names
*/
public static List<String> getNamesByObjectives() {
List<String> tabNames = new ArrayList<>();
try {
Scoreboard scoreboard = World.getWorld().getScoreboard();
ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(0);
Collection<Score> scores = scoreboard.getSortedScores(sidebarObjective);
for (Score score : scores) {
ScorePlayerTeam team = scoreboard.getPlayersTeam(score.getPlayerName());
String name = ScorePlayerTeam.formatPlayerName(team, score.getPlayerName());
tabNames.add(name);
}
} catch (Exception e) {
return new ArrayList<>();
}
return tabNames;
}
Aggregations