public void func_150873_a(EntityPlayer p_150873_1_, StatBase p_150873_2_, int p_150873_3_) { int var4 = p_150873_2_.isAchievement() ? this.writeStat(p_150873_2_) : 0; super.func_150873_a(p_150873_1_, p_150873_2_, p_150873_3_); this.field_150888_e.add(p_150873_2_); if (p_150873_2_.isAchievement() && var4 == 0 && p_150873_3_ > 0) { this.field_150886_g = true; if (this.field_150890_c.isAnnouncingPlayerAchievements()) { this.field_150890_c .getConfigurationManager() .sendChatMsg( new ChatComponentTranslation( "chat.type.achievement", new Object[] {p_150873_1_.getDisplayName(), p_150873_2_.func_150955_j()})); } } if (p_150873_2_.isAchievement() && var4 > 0 && p_150873_3_ == 0) { this.field_150886_g = true; if (this.field_150890_c.isAnnouncingPlayerAchievements()) { this.field_150890_c .getConfigurationManager() .sendChatMsg( new ChatComponentTranslation( "chat.type.achievement.taken", new Object[] {p_150873_1_.getDisplayName(), p_150873_2_.func_150955_j()})); } } }
public Map func_150881_a(String p_150881_1_) { JsonElement var2 = (new JsonParser()).parse(p_150881_1_); if (!var2.isJsonObject()) { return Maps.newHashMap(); } else { JsonObject var3 = var2.getAsJsonObject(); HashMap var4 = Maps.newHashMap(); Iterator var5 = var3.entrySet().iterator(); while (var5.hasNext()) { Entry var6 = (Entry) var5.next(); StatBase var7 = StatList.getOneShotStat((String) var6.getKey()); if (var7 != null) { TupleIntJsonSerializable var8 = new TupleIntJsonSerializable(); if (((JsonElement) var6.getValue()).isJsonPrimitive() && ((JsonElement) var6.getValue()).getAsJsonPrimitive().isNumber()) { var8.setIntegerValue(((JsonElement) var6.getValue()).getAsInt()); } else if (((JsonElement) var6.getValue()).isJsonObject()) { JsonObject var9 = ((JsonElement) var6.getValue()).getAsJsonObject(); if (var9.has("value") && var9.get("value").isJsonPrimitive() && var9.get("value").getAsJsonPrimitive().isNumber()) { var8.setIntegerValue(var9.getAsJsonPrimitive("value").getAsInt()); } if (var9.has("progress") && var7.func_150954_l() != null) { try { Constructor var10 = var7.func_150954_l().getConstructor(new Class[0]); IJsonSerializable var11 = (IJsonSerializable) var10.newInstance(new Object[0]); var11.func_152753_a(var9.get("progress")); var8.setJsonSerializableValue(var11); } catch (Throwable var12) { logger.warn("Invalid statistic progress in " + this.field_150887_d, var12); } } } var4.put(var7, var8); } else { logger.warn( "Invalid statistic in " + this.field_150887_d + ": Don\'t know what " + (String) var6.getKey() + " is"); } } return var4; } }
@SideOnly(Side.CLIENT) /** Formats a given stat for human consumption. */ public String format(int par1) { double var2 = (double) par1 / 20.0D; double var4 = var2 / 60.0D; double var6 = var4 / 60.0D; double var8 = var6 / 24.0D; double var10 = var8 / 365.0D; return var10 > 0.5D ? StatBase.getDecimalFormat().format(var10) + " y" : (var8 > 0.5D ? StatBase.getDecimalFormat().format(var8) + " d" : (var6 > 0.5D ? StatBase.getDecimalFormat().format(var6) + " h" : (var4 > 0.5D ? StatBase.getDecimalFormat().format(var4) + " m" : var2 + " s"))); }
public void addStat(StatBase statbase, int i) { if (statbase == null) { return; } if (statbase.func_25067_a()) { Achievement achievement = (Achievement) statbase; if (achievement.parentAchievement == null || mc.statFileWriter.hasAchievementUnlocked(achievement.parentAchievement)) { if (!mc.statFileWriter.hasAchievementUnlocked(achievement)) { mc.guiAchievement.queueTakenAchievement(achievement); } mc.statFileWriter.func_25100_a(statbase, i); } } else { mc.statFileWriter.func_25100_a(statbase, i); } }
/** Register the stat into StatList. */ public StatBase registerStat() { super.registerStat(); StatList.generalStats.add(this); return this; }
public Achievement func_75985_c() { super.func_75971_g(); AchievementList.field_76007_e.add(this); return this; }
public void increaseStat(EntityPlayer player, StatBase stat, int amount) { if (!stat.isAchievement() || this.canUnlockAchievement((Achievement) stat)) { this.unlockAchievement(player, stat, this.readStat(stat) + amount); } }