StatList .java

net.minecraft.stats.StatList (class, 303 lines): members: timesTradedWithVillagerStat, timesTalkedToVillagerStat, distanceByMinecartStat, allStats.

net.minecraft.statsclass303 linescommon17.5 KB

API Surface (4)

void init()
StatBase getStatKillEntity(EntityList.EntityEggInfo eggInfo)
StatBase getStatEntityKilledBy(EntityList.EntityEggInfo eggInfo)
StatBase getOneShotStat(String p_151177_0_)

Fields & Constants (57)

mineBlockStatArray
objectCraftStats
objectUseStats
objectBreakStats
oneShotStats
allStats
generalStats
itemStats
objectMineStats
leaveGameStat
minutesPlayedStat
timeSinceDeathStat
distanceWalkedStat
distanceCrouchedStat
distanceSprintedStat
distanceSwumStat
distanceFallenStat
distanceClimbedStat
distanceFlownStat
distanceDoveStat
distanceByMinecartStat
distanceByBoatStat
distanceByPigStat
distanceByHorseStat
jumpStat
dropStat
damageDealtStat
damageTakenStat

…and 29 more (see full source).

String literals (63)

"stat.leaveGame"
"stat.playOneMinute"
"stat.timeSinceDeath"
"stat.walkOneCm"
"stat.crouchOneCm"
"stat.sprintOneCm"
"stat.swimOneCm"
"stat.fallOneCm"
"stat.climbOneCm"
"stat.flyOneCm"
"stat.diveOneCm"
"stat.minecartOneCm"
"stat.boatOneCm"
"stat.pigOneCm"
"stat.horseOneCm"
"stat.jump"
"stat.drop"
"stat.damageDealt"
"stat.damageTaken"
"stat.deaths"
"stat.mobKills"
"stat.animalsBred"
"stat.playerKills"
"stat.fishCaught"

Full Source

StatList.java303 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.stats;
2
3
import com.google.common.collect.Lists;
4
import com.google.common.collect.Maps;
5
import com.google.common.collect.Sets;
6
import java.util.List;
7
import java.util.Map;
8
import java.util.Set;
9
import net.minecraft.block.Block;
10
import net.minecraft.entity.EntityList;
11
import net.minecraft.init.Blocks;
12
import net.minecraft.item.Item;
13
import net.minecraft.item.ItemBlock;
14
import net.minecraft.item.ItemStack;
15
import net.minecraft.item.crafting.CraftingManager;
16
import net.minecraft.item.crafting.FurnaceRecipes;
17
import net.minecraft.item.crafting.IRecipe;
18
import net.minecraft.util.ChatComponentTranslation;
19
import net.minecraft.util.ResourceLocation;
20
21
public class StatList
22
{
23
    protected static Map<String, StatBase> oneShotStats = Maps.<String, StatBase>newHashMap();
24
    public static List<StatBase> allStats = Lists.<StatBase>newArrayList();
25
    public static List<StatBase> generalStats = Lists.<StatBase>newArrayList();
26
    public static List<StatCrafting> itemStats = Lists.<StatCrafting>newArrayList();
27
    public static List<StatCrafting> objectMineStats = Lists.<StatCrafting>newArrayList();
28
29
    /** number of times you've left a game */
30
    public static StatBase leaveGameStat = (new StatBasic("stat.leaveGame", new ChatComponentTranslation("stat.leaveGame", new Object[0]))).initIndependentStat().registerStat();
31
32
    /** number of minutes you have played */
33
    public static StatBase minutesPlayedStat = (new StatBasic("stat.playOneMinute", new ChatComponentTranslation("stat.playOneMinute", new Object[0]), StatBase.timeStatType)).initIndependentStat().registerStat();
34
    public static StatBase timeSinceDeathStat = (new StatBasic("stat.timeSinceDeath", new ChatComponentTranslation("stat.timeSinceDeath", new Object[0]), StatBase.timeStatType)).initIndependentStat().registerStat();
35
36
    /** distance you've walked */
37
    public static StatBase distanceWalkedStat = (new StatBasic("stat.walkOneCm", new ChatComponentTranslation("stat.walkOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat();
38
    public static StatBase distanceCrouchedStat = (new StatBasic("stat.crouchOneCm", new ChatComponentTranslation("stat.crouchOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat();
39
    public static StatBase distanceSprintedStat = (new StatBasic("stat.sprintOneCm", new ChatComponentTranslation("stat.sprintOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat();
40
41
    /** distance you have swam */
42
    public static StatBase distanceSwumStat = (new StatBasic("stat.swimOneCm", new ChatComponentTranslation("stat.swimOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat();
43
44
    /** the distance you have fallen */
45
    public static StatBase distanceFallenStat = (new StatBasic("stat.fallOneCm", new ChatComponentTranslation("stat.fallOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat();
46
47
    /** the distance you've climbed */
48
    public static StatBase distanceClimbedStat = (new StatBasic("stat.climbOneCm", new ChatComponentTranslation("stat.climbOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat();
49
50
    /** the distance you've flown */
51
    public static StatBase distanceFlownStat = (new StatBasic("stat.flyOneCm", new ChatComponentTranslation("stat.flyOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat();
52
53
    /** the distance you've dived */
54
    public static StatBase distanceDoveStat = (new StatBasic("stat.diveOneCm", new ChatComponentTranslation("stat.diveOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat();
55
56
    /** the distance you've traveled by minecart */
57
    public static StatBase distanceByMinecartStat = (new StatBasic("stat.minecartOneCm", new ChatComponentTranslation("stat.minecartOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat();
58
59
    /** the distance you've traveled by boat */
60
    public static StatBase distanceByBoatStat = (new StatBasic("stat.boatOneCm", new ChatComponentTranslation("stat.boatOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat();
61
62
    /** the distance you've traveled by pig */
63
    public static StatBase distanceByPigStat = (new StatBasic("stat.pigOneCm", new ChatComponentTranslation("stat.pigOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat();
64
    public static StatBase distanceByHorseStat = (new StatBasic("stat.horseOneCm", new ChatComponentTranslation("stat.horseOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat();
65
66
    /** the times you've jumped */
67
    public static StatBase jumpStat = (new StatBasic("stat.jump", new ChatComponentTranslation("stat.jump", new Object[0]))).initIndependentStat().registerStat();
68
69
    /** the distance you've dropped (or times you've fallen?) */
70
    public static StatBase dropStat = (new StatBasic("stat.drop", new ChatComponentTranslation("stat.drop", new Object[0]))).initIndependentStat().registerStat();
71
72
    /** the amount of damage you've dealt */
73
    public static StatBase damageDealtStat = (new StatBasic("stat.damageDealt", new ChatComponentTranslation("stat.damageDealt", new Object[0]), StatBase.field_111202_k)).registerStat();
74
75
    /** the amount of damage you have taken */
76
    public static StatBase damageTakenStat = (new StatBasic("stat.damageTaken", new ChatComponentTranslation("stat.damageTaken", new Object[0]), StatBase.field_111202_k)).registerStat();
77
78
    /** the number of times you have died */
79
    public static StatBase deathsStat = (new StatBasic("stat.deaths", new ChatComponentTranslation("stat.deaths", new Object[0]))).registerStat();
80
81
    /** the number of mobs you have killed */
82
    public static StatBase mobKillsStat = (new StatBasic("stat.mobKills", new ChatComponentTranslation("stat.mobKills", new Object[0]))).registerStat();
83
84
    /** the number of animals you have bred */
85
    public static StatBase animalsBredStat = (new StatBasic("stat.animalsBred", new ChatComponentTranslation("stat.animalsBred", new Object[0]))).registerStat();
86
87
    /** counts the number of times you've killed a player */
88
    public static StatBase playerKillsStat = (new StatBasic("stat.playerKills", new ChatComponentTranslation("stat.playerKills", new Object[0]))).registerStat();
89
    public static StatBase fishCaughtStat = (new StatBasic("stat.fishCaught", new ChatComponentTranslation("stat.fishCaught", new Object[0]))).registerStat();
90
    public static StatBase junkFishedStat = (new StatBasic("stat.junkFished", new ChatComponentTranslation("stat.junkFished", new Object[0]))).registerStat();
91
    public static StatBase treasureFishedStat = (new StatBasic("stat.treasureFished", new ChatComponentTranslation("stat.treasureFished", new Object[0]))).registerStat();
92
    public static StatBase timesTalkedToVillagerStat = (new StatBasic("stat.talkedToVillager", new ChatComponentTranslation("stat.talkedToVillager", new Object[0]))).registerStat();
93
    public static StatBase timesTradedWithVillagerStat = (new StatBasic("stat.tradedWithVillager", new ChatComponentTranslation("stat.tradedWithVillager", new Object[0]))).registerStat();
94
    public static StatBase field_181724_H = (new StatBasic("stat.cakeSlicesEaten", new ChatComponentTranslation("stat.cakeSlicesEaten", new Object[0]))).registerStat();
95
    public static StatBase field_181725_I = (new StatBasic("stat.cauldronFilled", new ChatComponentTranslation("stat.cauldronFilled", new Object[0]))).registerStat();
96
    public static StatBase field_181726_J = (new StatBasic("stat.cauldronUsed", new ChatComponentTranslation("stat.cauldronUsed", new Object[0]))).registerStat();
97
    public static StatBase field_181727_K = (new StatBasic("stat.armorCleaned", new ChatComponentTranslation("stat.armorCleaned", new Object[0]))).registerStat();
98
    public static StatBase field_181728_L = (new StatBasic("stat.bannerCleaned", new ChatComponentTranslation("stat.bannerCleaned", new Object[0]))).registerStat();
99
    public static StatBase field_181729_M = (new StatBasic("stat.brewingstandInteraction", new ChatComponentTranslation("stat.brewingstandInteraction", new Object[0]))).registerStat();
100
    public static StatBase field_181730_N = (new StatBasic("stat.beaconInteraction", new ChatComponentTranslation("stat.beaconInteraction", new Object[0]))).registerStat();
101
    public static StatBase field_181731_O = (new StatBasic("stat.dropperInspected", new ChatComponentTranslation("stat.dropperInspected", new Object[0]))).registerStat();
102
    public static StatBase field_181732_P = (new StatBasic("stat.hopperInspected", new ChatComponentTranslation("stat.hopperInspected", new Object[0]))).registerStat();
103
    public static StatBase field_181733_Q = (new StatBasic("stat.dispenserInspected", new ChatComponentTranslation("stat.dispenserInspected", new Object[0]))).registerStat();
104
    public static StatBase field_181734_R = (new StatBasic("stat.noteblockPlayed", new ChatComponentTranslation("stat.noteblockPlayed", new Object[0]))).registerStat();
105
    public static StatBase field_181735_S = (new StatBasic("stat.noteblockTuned", new ChatComponentTranslation("stat.noteblockTuned", new Object[0]))).registerStat();
106
    public static StatBase field_181736_T = (new StatBasic("stat.flowerPotted", new ChatComponentTranslation("stat.flowerPotted", new Object[0]))).registerStat();
107
    public static StatBase field_181737_U = (new StatBasic("stat.trappedChestTriggered", new ChatComponentTranslation("stat.trappedChestTriggered", new Object[0]))).registerStat();
108
    public static StatBase field_181738_V = (new StatBasic("stat.enderchestOpened", new ChatComponentTranslation("stat.enderchestOpened", new Object[0]))).registerStat();
109
    public static StatBase field_181739_W = (new StatBasic("stat.itemEnchanted", new ChatComponentTranslation("stat.itemEnchanted", new Object[0]))).registerStat();
110
    public static StatBase field_181740_X = (new StatBasic("stat.recordPlayed", new ChatComponentTranslation("stat.recordPlayed", new Object[0]))).registerStat();
111
    public static StatBase field_181741_Y = (new StatBasic("stat.furnaceInteraction", new ChatComponentTranslation("stat.furnaceInteraction", new Object[0]))).registerStat();
112
    public static StatBase field_181742_Z = (new StatBasic("stat.craftingTableInteraction", new ChatComponentTranslation("stat.workbenchInteraction", new Object[0]))).registerStat();
113
    public static StatBase field_181723_aa = (new StatBasic("stat.chestOpened", new ChatComponentTranslation("stat.chestOpened", new Object[0]))).registerStat();
114
    public static final StatBase[] mineBlockStatArray = new StatBase[4096];
115
116
    /** Tracks the number of items a given block or item has been crafted. */
117
    public static final StatBase[] objectCraftStats = new StatBase[32000];
118
119
    /** Tracks the number of times a given block or item has been used. */
120
    public static final StatBase[] objectUseStats = new StatBase[32000];
121
122
    /** Tracks the number of times a given block or item has been broken. */
123
    public static final StatBase[] objectBreakStats = new StatBase[32000];
124
125
    public static void init()
126
    {
127
        initMiningStats();
128
        initStats();
129
        initItemDepleteStats();
130
        initCraftableStats();
131
        AchievementList.init();
132
        EntityList.func_151514_a();
133
    }
134
135
    /**
136
     * Initializes statistics related to craftable items. Is only called after both block and item stats have been
137
     * initialized.
138
     */
139
    private static void initCraftableStats()
140
    {
141
        Set<Item> set = Sets.<Item>newHashSet();
142
143
        for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList())
144
        {
145
            if (irecipe.getRecipeOutput() != null)
146
            {
147
                set.add(irecipe.getRecipeOutput().getItem());
148
            }
149
        }
150
151
        for (ItemStack itemstack : FurnaceRecipes.instance().getSmeltingList().values())
152
        {
153
            set.add(itemstack.getItem());
154
        }
155
156
        for (Item item : set)
157
        {
158
            if (item != null)
159
            {
160
                int i = Item.getIdFromItem(item);
161
                String s = func_180204_a(item);
162
163
                if (s != null)
164
                {
165
                    objectCraftStats[i] = (new StatCrafting("stat.craftItem.", s, new ChatComponentTranslation("stat.craftItem", new Object[] {(new ItemStack(item)).getChatComponent()}), item)).registerStat();
166
                }
167
            }
168
        }
169
170
        replaceAllSimilarBlocks(objectCraftStats);
171
    }
172
173
    private static void initMiningStats()
174
    {
175
        for (Block block : Block.blockRegistry)
176
        {
177
            Item item = Item.getItemFromBlock(block);
178
179
            if (item != null)
180
            {
181
                int i = Block.getIdFromBlock(block);
182
                String s = func_180204_a(item);
183
184
                if (s != null && block.getEnableStats())
185
                {
186
                    mineBlockStatArray[i] = (new StatCrafting("stat.mineBlock.", s, new ChatComponentTranslation("stat.mineBlock", new Object[] {(new ItemStack(block)).getChatComponent()}), item)).registerStat();
187
                    objectMineStats.add((StatCrafting)mineBlockStatArray[i]);
188
                }
189
            }
190
        }
191
192
        replaceAllSimilarBlocks(mineBlockStatArray);
193
    }
194
195
    private static void initStats()
196
    {
197
        for (Item item : Item.itemRegistry)
198
        {
199
            if (item != null)
200
            {
201
                int i = Item.getIdFromItem(item);
202
                String s = func_180204_a(item);
203
204
                if (s != null)
205
                {
206
                    objectUseStats[i] = (new StatCrafting("stat.useItem.", s, new ChatComponentTranslation("stat.useItem", new Object[] {(new ItemStack(item)).getChatComponent()}), item)).registerStat();
207
208
                    if (!(item instanceof ItemBlock))
209
                    {
210
                        itemStats.add((StatCrafting)objectUseStats[i]);
211
                    }
212
                }
213
            }
214
        }
215
216
        replaceAllSimilarBlocks(objectUseStats);
217
    }
218
219
    private static void initItemDepleteStats()
220
    {
221
        for (Item item : Item.itemRegistry)
222
        {
223
            if (item != null)
224
            {
225
                int i = Item.getIdFromItem(item);
226
                String s = func_180204_a(item);
227
228
                if (s != null && item.isDamageable())
229
                {
230
                    objectBreakStats[i] = (new StatCrafting("stat.breakItem.", s, new ChatComponentTranslation("stat.breakItem", new Object[] {(new ItemStack(item)).getChatComponent()}), item)).registerStat();
231
                }
232
            }
233
        }
234
235
        replaceAllSimilarBlocks(objectBreakStats);
236
    }
237
238
    private static String func_180204_a(Item p_180204_0_)
239
    {
240
        ResourceLocation resourcelocation = (ResourceLocation)Item.itemRegistry.getNameForObject(p_180204_0_);
241
        return resourcelocation != null ? resourcelocation.toString().replace(':', '.') : null;
242
    }
243
244
    /**
245
     * Forces all dual blocks to count for each other on the stats list
246
     */
247
    private static void replaceAllSimilarBlocks(StatBase[] p_75924_0_)
248
    {
249
        mergeStatBases(p_75924_0_, Blocks.water, Blocks.flowing_water);
250
        mergeStatBases(p_75924_0_, Blocks.lava, Blocks.flowing_lava);
251
        mergeStatBases(p_75924_0_, Blocks.lit_pumpkin, Blocks.pumpkin);
252
        mergeStatBases(p_75924_0_, Blocks.lit_furnace, Blocks.furnace);
253
        mergeStatBases(p_75924_0_, Blocks.lit_redstone_ore, Blocks.redstone_ore);
254
        mergeStatBases(p_75924_0_, Blocks.powered_repeater, Blocks.unpowered_repeater);
255
        mergeStatBases(p_75924_0_, Blocks.powered_comparator, Blocks.unpowered_comparator);
256
        mergeStatBases(p_75924_0_, Blocks.redstone_torch, Blocks.unlit_redstone_torch);
257
        mergeStatBases(p_75924_0_, Blocks.lit_redstone_lamp, Blocks.redstone_lamp);
258
        mergeStatBases(p_75924_0_, Blocks.double_stone_slab, Blocks.stone_slab);
259
        mergeStatBases(p_75924_0_, Blocks.double_wooden_slab, Blocks.wooden_slab);
260
        mergeStatBases(p_75924_0_, Blocks.double_stone_slab2, Blocks.stone_slab2);
261
        mergeStatBases(p_75924_0_, Blocks.grass, Blocks.dirt);
262
        mergeStatBases(p_75924_0_, Blocks.farmland, Blocks.dirt);
263
    }
264
265
    /**
266
     * Merge {@link StatBase} object references for similar blocks
267
     */
268
    private static void mergeStatBases(StatBase[] statBaseIn, Block p_151180_1_, Block p_151180_2_)
269
    {
270
        int i = Block.getIdFromBlock(p_151180_1_);
271
        int j = Block.getIdFromBlock(p_151180_2_);
272
273
        if (statBaseIn[i] != null && statBaseIn[j] == null)
274
        {
275
            statBaseIn[j] = statBaseIn[i];
276
        }
277
        else
278
        {
279
            allStats.remove(statBaseIn[i]);
280
            objectMineStats.remove(statBaseIn[i]);
281
            generalStats.remove(statBaseIn[i]);
282
            statBaseIn[i] = statBaseIn[j];
283
        }
284
    }
285
286
    public static StatBase getStatKillEntity(EntityList.EntityEggInfo eggInfo)
287
    {
288
        String s = EntityList.getStringFromID(eggInfo.spawnedID);
289
        return s == null ? null : (new StatBase("stat.killEntity." + s, new ChatComponentTranslation("stat.entityKill", new Object[] {new ChatComponentTranslation("entity." + s + ".name", new Object[0])}))).registerStat();
290
    }
291
292
    public static StatBase getStatEntityKilledBy(EntityList.EntityEggInfo eggInfo)
293
    {
294
        String s = EntityList.getStringFromID(eggInfo.spawnedID);
295
        return s == null ? null : (new StatBase("stat.entityKilledBy." + s, new ChatComponentTranslation("stat.entityKilledBy", new Object[] {new ChatComponentTranslation("entity." + s + ".name", new Object[0])}))).registerStat();
296
    }
297
298
    public static StatBase getOneShotStat(String p_151177_0_)
299
    {
300
        return (StatBase)oneShotStats.get(p_151177_0_);
301
    }
302
}
303

Deobfuscated MCP 1.8.9 source of StatList from Marcelektro/MavenMCP-1.8.9 (net/minecraft/stats/StatList.java), stored verbatim.