use of net.minecraft.scoreboard.ScoreObjective in project SpongeCommon by SpongePowered.
the class SpongeObjective method addScore.
@Override
public void addScore(Score score) throws IllegalArgumentException {
if (this.scores.containsKey(score.getName())) {
throw new IllegalArgumentException(String.format("A score with the name %s already exists!", SpongeTexts.toLegacy(score.getName())));
}
this.scores.put(score.getName(), score);
SpongeScore spongeScore = (SpongeScore) score;
for (ScoreObjective objective : this.objectives.values()) {
this.addScoreToScoreboard(objective.scoreboard, spongeScore.getScoreFor(objective));
}
}
use of net.minecraft.scoreboard.ScoreObjective in project SpongeCommon by SpongePowered.
the class SpongeObjective method updateScores.
public void updateScores(net.minecraft.scoreboard.Scoreboard scoreboard) {
ScoreObjective objective = this.getObjectiveFor(scoreboard);
for (Score score : this.getScores().values()) {
SpongeScore spongeScore = (SpongeScore) score;
this.addScoreToScoreboard(scoreboard, spongeScore.getScoreFor(objective));
}
}
use of net.minecraft.scoreboard.ScoreObjective 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.ScoreObjective in project Hyperium by HyperiumClient.
the class AboveHeadRenderer method render.
@InvokeEvent
public void render(RenderPlayerEvent event) {
if (levelhead == null || levelhead.getDisplayManager() == null || levelhead.getDisplayManager().getMasterConfig() == null || !levelhead.getDisplayManager().getMasterConfig().isEnabled()) {
return;
}
EntityPlayer player = event.getEntity();
int o = 0;
for (AboveHeadDisplay display : levelhead.getDisplayManager().getAboveHead()) {
int index = display.getIndex();
int extraHead = levelhead.getLevelheadPurchaseStates().getExtraHead();
if (index > extraHead || !display.getConfig().isEnabled())
continue;
LevelheadTag levelheadTag = display.getCache().get(player.getUniqueID());
if (display.loadOrRender(player) && levelheadTag != null && !(levelheadTag instanceof NullLevelheadTag)) {
if ((event.getEntity().getUniqueID().equals(Levelhead.getInstance().userUuid) && !display.getConfig().isShowSelf() || !Hyperium.INSTANCE.getHandlers().getHypixelDetector().isHypixel())) {
continue;
}
if (player.getDistanceSqToEntity(Minecraft.getMinecraft().thePlayer) < 64 * 64) {
double offset = 0.3;
Scoreboard scoreboard = player.getWorldScoreboard();
ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(2);
if (objective != null && event.getEntity().getDistanceSqToEntity(Minecraft.getMinecraft().thePlayer) < 10 * 10) {
offset *= 2;
}
if (player.getUniqueID().equals(levelhead.userUuid) && !Settings.SHOW_OWN_NAME)
offset -= .3;
if (Hyperium.INSTANCE.getCosmetics().getDeadmau5Cosmetic().isPurchasedBy(event.getEntity().getUniqueID())) {
HyperiumPurchase packageIfReady = PurchaseApi.getInstance().getPackageIfReady(event.getEntity().getUniqueID());
if (packageIfReady != null) {
AbstractHyperiumPurchase purchase = packageIfReady.getPurchase(EnumPurchaseType.DEADMAU5_COSMETIC);
if (purchase != null) {
if (event.getEntity().getUniqueID() != Minecraft.getMinecraft().thePlayer.getUniqueID()) {
if (((EarsCosmetic) purchase).isEnabled()) {
offset += .3;
}
} else if (Settings.EARS_STATE.equalsIgnoreCase("on")) {
offset += .2;
}
}
}
}
offset += levelhead.getDisplayManager().getMasterConfig().getOffset();
renderName(event, levelheadTag, player, event.getX(), event.getY() + offset + o * .3D, event.getZ());
}
}
o++;
}
}
use of net.minecraft.scoreboard.ScoreObjective 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);
}
Aggregations