| 1 | package net.minecraft.client.gui.achievement;
|
| 2 |
|
| 3 | import com.google.common.collect.Lists;
|
| 4 | import java.io.IOException;
|
| 5 | import java.util.Collections;
|
| 6 | import java.util.Comparator;
|
| 7 | import java.util.List;
|
| 8 | import net.minecraft.client.Minecraft;
|
| 9 | import net.minecraft.client.audio.PositionedSoundRecord;
|
| 10 | import net.minecraft.client.gui.GuiButton;
|
| 11 | import net.minecraft.client.gui.GuiScreen;
|
| 12 | import net.minecraft.client.gui.GuiSlot;
|
| 13 | import net.minecraft.client.gui.IProgressMeter;
|
| 14 | import net.minecraft.client.renderer.GlStateManager;
|
| 15 | import net.minecraft.client.renderer.RenderHelper;
|
| 16 | import net.minecraft.client.renderer.Tessellator;
|
| 17 | import net.minecraft.client.renderer.WorldRenderer;
|
| 18 | import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
| 19 | import net.minecraft.client.resources.I18n;
|
| 20 | import net.minecraft.entity.EntityList;
|
| 21 | import net.minecraft.item.Item;
|
| 22 | import net.minecraft.item.ItemStack;
|
| 23 | import net.minecraft.network.play.client.C16PacketClientStatus;
|
| 24 | import net.minecraft.stats.StatBase;
|
| 25 | import net.minecraft.stats.StatCrafting;
|
| 26 | import net.minecraft.stats.StatFileWriter;
|
| 27 | import net.minecraft.stats.StatList;
|
| 28 | import net.minecraft.util.ResourceLocation;
|
| 29 | import org.lwjgl.input.Mouse;
|
| 30 |
|
| 31 | public class GuiStats extends GuiScreen implements IProgressMeter
|
| 32 | {
|
| 33 | protected GuiScreen parentScreen;
|
| 34 | protected String screenTitle = "Select world";
|
| 35 | private GuiStats.StatsGeneral generalStats;
|
| 36 | private GuiStats.StatsItem itemStats;
|
| 37 | private GuiStats.StatsBlock blockStats;
|
| 38 | private GuiStats.StatsMobsList mobStats;
|
| 39 | private StatFileWriter field_146546_t;
|
| 40 | private GuiSlot displaySlot;
|
| 41 |
|
| 42 | /** When true, the game will be paused when the gui is shown */
|
| 43 | private boolean doesGuiPauseGame = true;
|
| 44 |
|
| 45 | public GuiStats(GuiScreen p_i1071_1_, StatFileWriter p_i1071_2_)
|
| 46 | {
|
| 47 | this.parentScreen = p_i1071_1_;
|
| 48 | this.field_146546_t = p_i1071_2_;
|
| 49 | }
|
| 50 |
|
| 51 | /**
|
| 52 | * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
|
| 53 | * window resizes, the buttonList is cleared beforehand.
|
| 54 | */
|
| 55 | public void initGui()
|
| 56 | {
|
| 57 | this.screenTitle = I18n.format("gui.stats", new Object[0]);
|
| 58 | this.doesGuiPauseGame = true;
|
| 59 | this.mc.getNetHandler().addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.REQUEST_STATS));
|
| 60 | }
|
| 61 |
|
| 62 | /**
|
| 63 | * Handles mouse input.
|
| 64 | */
|
| 65 | public void handleMouseInput() throws IOException
|
| 66 | {
|
| 67 | super.handleMouseInput();
|
| 68 |
|
| 69 | if (this.displaySlot != null)
|
| 70 | {
|
| 71 | this.displaySlot.handleMouseInput();
|
| 72 | }
|
| 73 | }
|
| 74 |
|
| 75 | public void func_175366_f()
|
| 76 | {
|
| 77 | this.generalStats = new GuiStats.StatsGeneral(this.mc);
|
| 78 | this.generalStats.registerScrollButtons(1, 1);
|
| 79 | this.itemStats = new GuiStats.StatsItem(this.mc);
|
| 80 | this.itemStats.registerScrollButtons(1, 1);
|
| 81 | this.blockStats = new GuiStats.StatsBlock(this.mc);
|
| 82 | this.blockStats.registerScrollButtons(1, 1);
|
| 83 | this.mobStats = new GuiStats.StatsMobsList(this.mc);
|
| 84 | this.mobStats.registerScrollButtons(1, 1);
|
| 85 | }
|
| 86 |
|
| 87 | public void createButtons()
|
| 88 | {
|
| 89 | this.buttonList.add(new GuiButton(0, this.width / 2 + 4, this.height - 28, 150, 20, I18n.format("gui.done", new Object[0])));
|
| 90 | this.buttonList.add(new GuiButton(1, this.width / 2 - 160, this.height - 52, 80, 20, I18n.format("stat.generalButton", new Object[0])));
|
| 91 | GuiButton guibutton;
|
| 92 | this.buttonList.add(guibutton = new GuiButton(2, this.width / 2 - 80, this.height - 52, 80, 20, I18n.format("stat.blocksButton", new Object[0])));
|
| 93 | GuiButton guibutton1;
|
| 94 | this.buttonList.add(guibutton1 = new GuiButton(3, this.width / 2, this.height - 52, 80, 20, I18n.format("stat.itemsButton", new Object[0])));
|
| 95 | GuiButton guibutton2;
|
| 96 | this.buttonList.add(guibutton2 = new GuiButton(4, this.width / 2 + 80, this.height - 52, 80, 20, I18n.format("stat.mobsButton", new Object[0])));
|
| 97 |
|
| 98 | if (this.blockStats.getSize() == 0)
|
| 99 | {
|
| 100 | guibutton.enabled = false;
|
| 101 | }
|
| 102 |
|
| 103 | if (this.itemStats.getSize() == 0)
|
| 104 | {
|
| 105 | guibutton1.enabled = false;
|
| 106 | }
|
| 107 |
|
| 108 | if (this.mobStats.getSize() == 0)
|
| 109 | {
|
| 110 | guibutton2.enabled = false;
|
| 111 | }
|
| 112 | }
|
| 113 |
|
| 114 | /**
|
| 115 | * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
|
| 116 | */
|
| 117 | protected void actionPerformed(GuiButton button) throws IOException
|
| 118 | {
|
| 119 | if (button.enabled)
|
| 120 | {
|
| 121 | if (button.id == 0)
|
| 122 | {
|
| 123 | this.mc.displayGuiScreen(this.parentScreen);
|
| 124 | }
|
| 125 | else if (button.id == 1)
|
| 126 | {
|
| 127 | this.displaySlot = this.generalStats;
|
| 128 | }
|
| 129 | else if (button.id == 3)
|
| 130 | {
|
| 131 | this.displaySlot = this.itemStats;
|
| 132 | }
|
| 133 | else if (button.id == 2)
|
| 134 | {
|
| 135 | this.displaySlot = this.blockStats;
|
| 136 | }
|
| 137 | else if (button.id == 4)
|
| 138 | {
|
| 139 | this.displaySlot = this.mobStats;
|
| 140 | }
|
| 141 | else
|
| 142 | {
|
| 143 | this.displaySlot.actionPerformed(button);
|
| 144 | }
|
| 145 | }
|
| 146 | }
|
| 147 |
|
| 148 | /**
|
| 149 | * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
|
| 150 | */
|
| 151 | public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
| 152 | {
|
| 153 | if (this.doesGuiPauseGame)
|
| 154 | {
|
| 155 | this.drawDefaultBackground();
|
| 156 | this.drawCenteredString(this.fontRendererObj, I18n.format("multiplayer.downloadingStats", new Object[0]), this.width / 2, this.height / 2, 16777215);
|
| 157 | this.drawCenteredString(this.fontRendererObj, lanSearchStates[(int)(Minecraft.getSystemTime() / 150L % (long)lanSearchStates.length)], this.width / 2, this.height / 2 + this.fontRendererObj.FONT_HEIGHT * 2, 16777215);
|
| 158 | }
|
| 159 | else
|
| 160 | {
|
| 161 | this.displaySlot.drawScreen(mouseX, mouseY, partialTicks);
|
| 162 | this.drawCenteredString(this.fontRendererObj, this.screenTitle, this.width / 2, 20, 16777215);
|
| 163 | super.drawScreen(mouseX, mouseY, partialTicks);
|
| 164 | }
|
| 165 | }
|
| 166 |
|
| 167 | public void doneLoading()
|
| 168 | {
|
| 169 | if (this.doesGuiPauseGame)
|
| 170 | {
|
| 171 | this.func_175366_f();
|
| 172 | this.createButtons();
|
| 173 | this.displaySlot = this.generalStats;
|
| 174 | this.doesGuiPauseGame = false;
|
| 175 | }
|
| 176 | }
|
| 177 |
|
| 178 | /**
|
| 179 | * Returns true if this GUI should pause the game when it is displayed in single-player
|
| 180 | */
|
| 181 | public boolean doesGuiPauseGame()
|
| 182 | {
|
| 183 | return !this.doesGuiPauseGame;
|
| 184 | }
|
| 185 |
|
| 186 | private void drawStatsScreen(int p_146521_1_, int p_146521_2_, Item p_146521_3_)
|
| 187 | {
|
| 188 | this.drawButtonBackground(p_146521_1_ + 1, p_146521_2_ + 1);
|
| 189 | GlStateManager.enableRescaleNormal();
|
| 190 | RenderHelper.enableGUIStandardItemLighting();
|
| 191 | this.itemRender.renderItemIntoGUI(new ItemStack(p_146521_3_, 1, 0), p_146521_1_ + 2, p_146521_2_ + 2);
|
| 192 | RenderHelper.disableStandardItemLighting();
|
| 193 | GlStateManager.disableRescaleNormal();
|
| 194 | }
|
| 195 |
|
| 196 | /**
|
| 197 | * Draws a gray box that serves as a button background.
|
| 198 | */
|
| 199 | private void drawButtonBackground(int p_146531_1_, int p_146531_2_)
|
| 200 | {
|
| 201 | this.drawSprite(p_146531_1_, p_146531_2_, 0, 0);
|
| 202 | }
|
| 203 |
|
| 204 | /**
|
| 205 | * Draws a sprite from assets/textures/gui/container/stats_icons.png
|
| 206 | */
|
| 207 | private void drawSprite(int p_146527_1_, int p_146527_2_, int p_146527_3_, int p_146527_4_)
|
| 208 | {
|
| 209 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
| 210 | this.mc.getTextureManager().bindTexture(statIcons);
|
| 211 | float f = 0.0078125F;
|
| 212 | float f1 = 0.0078125F;
|
| 213 | int i = 18;
|
| 214 | int j = 18;
|
| 215 | Tessellator tessellator = Tessellator.getInstance();
|
| 216 | WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
| 217 | worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
|
| 218 | worldrenderer.pos((double)(p_146527_1_ + 0), (double)(p_146527_2_ + 18), (double)this.zLevel).tex((double)((float)(p_146527_3_ + 0) * 0.0078125F), (double)((float)(p_146527_4_ + 18) * 0.0078125F)).endVertex();
|
| 219 | worldrenderer.pos((double)(p_146527_1_ + 18), (double)(p_146527_2_ + 18), (double)this.zLevel).tex((double)((float)(p_146527_3_ + 18) * 0.0078125F), (double)((float)(p_146527_4_ + 18) * 0.0078125F)).endVertex();
|
| 220 | worldrenderer.pos((double)(p_146527_1_ + 18), (double)(p_146527_2_ + 0), (double)this.zLevel).tex((double)((float)(p_146527_3_ + 18) * 0.0078125F), (double)((float)(p_146527_4_ + 0) * 0.0078125F)).endVertex();
|
| 221 | worldrenderer.pos((double)(p_146527_1_ + 0), (double)(p_146527_2_ + 0), (double)this.zLevel).tex((double)((float)(p_146527_3_ + 0) * 0.0078125F), (double)((float)(p_146527_4_ + 0) * 0.0078125F)).endVertex();
|
| 222 | tessellator.draw();
|
| 223 | }
|
| 224 |
|
| 225 | abstract class Stats extends GuiSlot
|
| 226 | {
|
| 227 | protected int field_148218_l = -1;
|
| 228 | protected List<StatCrafting> statsHolder;
|
| 229 | protected Comparator<StatCrafting> statSorter;
|
| 230 | protected int field_148217_o = -1;
|
| 231 | protected int field_148215_p;
|
| 232 |
|
| 233 | protected Stats(Minecraft mcIn)
|
| 234 | {
|
| 235 | super(mcIn, GuiStats.this.width, GuiStats.this.height, 32, GuiStats.this.height - 64, 20);
|
| 236 | this.setShowSelectionBox(false);
|
| 237 | this.setHasListHeader(true, 20);
|
| 238 | }
|
| 239 |
|
| 240 | protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
|
| 241 | {
|
| 242 | }
|
| 243 |
|
| 244 | protected boolean isSelected(int slotIndex)
|
| 245 | {
|
| 246 | return false;
|
| 247 | }
|
| 248 |
|
| 249 | protected void drawBackground()
|
| 250 | {
|
| 251 | GuiStats.this.drawDefaultBackground();
|
| 252 | }
|
| 253 |
|
| 254 | protected void drawListHeader(int p_148129_1_, int p_148129_2_, Tessellator p_148129_3_)
|
| 255 | {
|
| 256 | if (!Mouse.isButtonDown(0))
|
| 257 | {
|
| 258 | this.field_148218_l = -1;
|
| 259 | }
|
| 260 |
|
| 261 | if (this.field_148218_l == 0)
|
| 262 | {
|
| 263 | GuiStats.this.drawSprite(p_148129_1_ + 115 - 18, p_148129_2_ + 1, 0, 0);
|
| 264 | }
|
| 265 | else
|
| 266 | {
|
| 267 | GuiStats.this.drawSprite(p_148129_1_ + 115 - 18, p_148129_2_ + 1, 0, 18);
|
| 268 | }
|
| 269 |
|
| 270 | if (this.field_148218_l == 1)
|
| 271 | {
|
| 272 | GuiStats.this.drawSprite(p_148129_1_ + 165 - 18, p_148129_2_ + 1, 0, 0);
|
| 273 | }
|
| 274 | else
|
| 275 | {
|
| 276 | GuiStats.this.drawSprite(p_148129_1_ + 165 - 18, p_148129_2_ + 1, 0, 18);
|
| 277 | }
|
| 278 |
|
| 279 | if (this.field_148218_l == 2)
|
| 280 | {
|
| 281 | GuiStats.this.drawSprite(p_148129_1_ + 215 - 18, p_148129_2_ + 1, 0, 0);
|
| 282 | }
|
| 283 | else
|
| 284 | {
|
| 285 | GuiStats.this.drawSprite(p_148129_1_ + 215 - 18, p_148129_2_ + 1, 0, 18);
|
| 286 | }
|
| 287 |
|
| 288 | if (this.field_148217_o != -1)
|
| 289 | {
|
| 290 | int i = 79;
|
| 291 | int j = 18;
|
| 292 |
|
| 293 | if (this.field_148217_o == 1)
|
| 294 | {
|
| 295 | i = 129;
|
| 296 | }
|
| 297 | else if (this.field_148217_o == 2)
|
| 298 | {
|
| 299 | i = 179;
|
| 300 | }
|
| 301 |
|
| 302 | if (this.field_148215_p == 1)
|
| 303 | {
|
| 304 | j = 36;
|
| 305 | }
|
| 306 |
|
| 307 | GuiStats.this.drawSprite(p_148129_1_ + i, p_148129_2_ + 1, j, 0);
|
| 308 | }
|
| 309 | }
|
| 310 |
|
| 311 | protected void func_148132_a(int p_148132_1_, int p_148132_2_)
|
| 312 | {
|
| 313 | this.field_148218_l = -1;
|
| 314 |
|
| 315 | if (p_148132_1_ >= 79 && p_148132_1_ < 115)
|
| 316 | {
|
| 317 | this.field_148218_l = 0;
|
| 318 | }
|
| 319 | else if (p_148132_1_ >= 129 && p_148132_1_ < 165)
|
| 320 | {
|
| 321 | this.field_148218_l = 1;
|
| 322 | }
|
| 323 | else if (p_148132_1_ >= 179 && p_148132_1_ < 215)
|
| 324 | {
|
| 325 | this.field_148218_l = 2;
|
| 326 | }
|
| 327 |
|
| 328 | if (this.field_148218_l >= 0)
|
| 329 | {
|
| 330 | this.func_148212_h(this.field_148218_l);
|
| 331 | this.mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
|
| 332 | }
|
| 333 | }
|
| 334 |
|
| 335 | protected final int getSize()
|
| 336 | {
|
| 337 | return this.statsHolder.size();
|
| 338 | }
|
| 339 |
|
| 340 | protected final StatCrafting func_148211_c(int p_148211_1_)
|
| 341 | {
|
| 342 | return (StatCrafting)this.statsHolder.get(p_148211_1_);
|
| 343 | }
|
| 344 |
|
| 345 | protected abstract String func_148210_b(int p_148210_1_);
|
| 346 |
|
| 347 | protected void func_148209_a(StatBase p_148209_1_, int p_148209_2_, int p_148209_3_, boolean p_148209_4_)
|
| 348 | {
|
| 349 | if (p_148209_1_ != null)
|
| 350 | {
|
| 351 | String s = p_148209_1_.format(GuiStats.this.field_146546_t.readStat(p_148209_1_));
|
| 352 | GuiStats.this.drawString(GuiStats.this.fontRendererObj, s, p_148209_2_ - GuiStats.this.fontRendererObj.getStringWidth(s), p_148209_3_ + 5, p_148209_4_ ? 16777215 : 9474192);
|
| 353 | }
|
| 354 | else
|
| 355 | {
|
| 356 | String s1 = "-";
|
| 357 | GuiStats.this.drawString(GuiStats.this.fontRendererObj, s1, p_148209_2_ - GuiStats.this.fontRendererObj.getStringWidth(s1), p_148209_3_ + 5, p_148209_4_ ? 16777215 : 9474192);
|
| 358 | }
|
| 359 | }
|
| 360 |
|
| 361 | protected void func_148142_b(int p_148142_1_, int p_148142_2_)
|
| 362 | {
|
| 363 | if (p_148142_2_ >= this.top && p_148142_2_ <= this.bottom)
|
| 364 | {
|
| 365 | int i = this.getSlotIndexFromScreenCoords(p_148142_1_, p_148142_2_);
|
| 366 | int j = this.width / 2 - 92 - 16;
|
| 367 |
|
| 368 | if (i >= 0)
|
| 369 | {
|
| 370 | if (p_148142_1_ < j + 40 || p_148142_1_ > j + 40 + 20)
|
| 371 | {
|
| 372 | return;
|
| 373 | }
|
| 374 |
|
| 375 | StatCrafting statcrafting = this.func_148211_c(i);
|
| 376 | this.func_148213_a(statcrafting, p_148142_1_, p_148142_2_);
|
| 377 | }
|
| 378 | else
|
| 379 | {
|
| 380 | String s = "";
|
| 381 |
|
| 382 | if (p_148142_1_ >= j + 115 - 18 && p_148142_1_ <= j + 115)
|
| 383 | {
|
| 384 | s = this.func_148210_b(0);
|
| 385 | }
|
| 386 | else if (p_148142_1_ >= j + 165 - 18 && p_148142_1_ <= j + 165)
|
| 387 | {
|
| 388 | s = this.func_148210_b(1);
|
| 389 | }
|
| 390 | else
|
| 391 | {
|
| 392 | if (p_148142_1_ < j + 215 - 18 || p_148142_1_ > j + 215)
|
| 393 | {
|
| 394 | return;
|
| 395 | }
|
| 396 |
|
| 397 | s = this.func_148210_b(2);
|
| 398 | }
|
| 399 |
|
| 400 | s = ("" + I18n.format(s, new Object[0])).trim();
|
| 401 |
|
| 402 | if (s.length() > 0)
|
| 403 | {
|
| 404 | int k = p_148142_1_ + 12;
|
| 405 | int l = p_148142_2_ - 12;
|
| 406 | int i1 = GuiStats.this.fontRendererObj.getStringWidth(s);
|
| 407 | GuiStats.this.drawGradientRect(k - 3, l - 3, k + i1 + 3, l + 8 + 3, -1073741824, -1073741824);
|
| 408 | GuiStats.this.fontRendererObj.drawStringWithShadow(s, (float)k, (float)l, -1);
|
| 409 | }
|
| 410 | }
|
| 411 | }
|
| 412 | }
|
| 413 |
|
| 414 | protected void func_148213_a(StatCrafting p_148213_1_, int p_148213_2_, int p_148213_3_)
|
| 415 | {
|
| 416 | if (p_148213_1_ != null)
|
| 417 | {
|
| 418 | Item item = p_148213_1_.func_150959_a();
|
| 419 | ItemStack itemstack = new ItemStack(item);
|
| 420 | String s = itemstack.getUnlocalizedName();
|
| 421 | String s1 = ("" + I18n.format(s + ".name", new Object[0])).trim();
|
| 422 |
|
| 423 | if (s1.length() > 0)
|
| 424 | {
|
| 425 | int i = p_148213_2_ + 12;
|
| 426 | int j = p_148213_3_ - 12;
|
| 427 | int k = GuiStats.this.fontRendererObj.getStringWidth(s1);
|
| 428 | GuiStats.this.drawGradientRect(i - 3, j - 3, i + k + 3, j + 8 + 3, -1073741824, -1073741824);
|
| 429 | GuiStats.this.fontRendererObj.drawStringWithShadow(s1, (float)i, (float)j, -1);
|
| 430 | }
|
| 431 | }
|
| 432 | }
|
| 433 |
|
| 434 | protected void func_148212_h(int p_148212_1_)
|
| 435 | {
|
| 436 | if (p_148212_1_ != this.field_148217_o)
|
| 437 | {
|
| 438 | this.field_148217_o = p_148212_1_;
|
| 439 | this.field_148215_p = -1;
|
| 440 | }
|
| 441 | else if (this.field_148215_p == -1)
|
| 442 | {
|
| 443 | this.field_148215_p = 1;
|
| 444 | }
|
| 445 | else
|
| 446 | {
|
| 447 | this.field_148217_o = -1;
|
| 448 | this.field_148215_p = 0;
|
| 449 | }
|
| 450 |
|
| 451 | Collections.sort(this.statsHolder, this.statSorter);
|
| 452 | }
|
| 453 | }
|
| 454 |
|
| 455 | class StatsBlock extends GuiStats.Stats
|
| 456 | {
|
| 457 | public StatsBlock(Minecraft mcIn)
|
| 458 | {
|
| 459 | super(mcIn);
|
| 460 | this.statsHolder = Lists.<StatCrafting>newArrayList();
|
| 461 |
|
| 462 | for (StatCrafting statcrafting : StatList.objectMineStats)
|
| 463 | {
|
| 464 | boolean flag = false;
|
| 465 | int i = Item.getIdFromItem(statcrafting.func_150959_a());
|
| 466 |
|
| 467 | if (GuiStats.this.field_146546_t.readStat(statcrafting) > 0)
|
| 468 | {
|
| 469 | flag = true;
|
| 470 | }
|
| 471 | else if (StatList.objectUseStats[i] != null && GuiStats.this.field_146546_t.readStat(StatList.objectUseStats[i]) > 0)
|
| 472 | {
|
| 473 | flag = true;
|
| 474 | }
|
| 475 | else if (StatList.objectCraftStats[i] != null && GuiStats.this.field_146546_t.readStat(StatList.objectCraftStats[i]) > 0)
|
| 476 | {
|
| 477 | flag = true;
|
| 478 | }
|
| 479 |
|
| 480 | if (flag)
|
| 481 | {
|
| 482 | this.statsHolder.add(statcrafting);
|
| 483 | }
|
| 484 | }
|
| 485 |
|
| 486 | this.statSorter = new Comparator<StatCrafting>()
|
| 487 | {
|
| 488 | public int compare(StatCrafting p_compare_1_, StatCrafting p_compare_2_)
|
| 489 | {
|
| 490 | int j = Item.getIdFromItem(p_compare_1_.func_150959_a());
|
| 491 | int k = Item.getIdFromItem(p_compare_2_.func_150959_a());
|
| 492 | StatBase statbase = null;
|
| 493 | StatBase statbase1 = null;
|
| 494 |
|
| 495 | if (StatsBlock.this.field_148217_o == 2)
|
| 496 | {
|
| 497 | statbase = StatList.mineBlockStatArray[j];
|
| 498 | statbase1 = StatList.mineBlockStatArray[k];
|
| 499 | }
|
| 500 | else if (StatsBlock.this.field_148217_o == 0)
|
| 501 | {
|
| 502 | statbase = StatList.objectCraftStats[j];
|
| 503 | statbase1 = StatList.objectCraftStats[k];
|
| 504 | }
|
| 505 | else if (StatsBlock.this.field_148217_o == 1)
|
| 506 | {
|
| 507 | statbase = StatList.objectUseStats[j];
|
| 508 | statbase1 = StatList.objectUseStats[k];
|
| 509 | }
|
| 510 |
|
| 511 | if (statbase != null || statbase1 != null)
|
| 512 | {
|
| 513 | if (statbase == null)
|
| 514 | {
|
| 515 | return 1;
|
| 516 | }
|
| 517 |
|
| 518 | if (statbase1 == null)
|
| 519 | {
|
| 520 | return -1;
|
| 521 | }
|
| 522 |
|
| 523 | int l = GuiStats.this.field_146546_t.readStat(statbase);
|
| 524 | int i1 = GuiStats.this.field_146546_t.readStat(statbase1);
|
| 525 |
|
| 526 | if (l != i1)
|
| 527 | {
|
| 528 | return (l - i1) * StatsBlock.this.field_148215_p;
|
| 529 | }
|
| 530 | }
|
| 531 |
|
| 532 | return j - k;
|
| 533 | }
|
| 534 | };
|
| 535 | }
|
| 536 |
|
| 537 | protected void drawListHeader(int p_148129_1_, int p_148129_2_, Tessellator p_148129_3_)
|
| 538 | {
|
| 539 | super.drawListHeader(p_148129_1_, p_148129_2_, p_148129_3_);
|
| 540 |
|
| 541 | if (this.field_148218_l == 0)
|
| 542 | {
|
| 543 | GuiStats.this.drawSprite(p_148129_1_ + 115 - 18 + 1, p_148129_2_ + 1 + 1, 18, 18);
|
| 544 | }
|
| 545 | else
|
| 546 | {
|
| 547 | GuiStats.this.drawSprite(p_148129_1_ + 115 - 18, p_148129_2_ + 1, 18, 18);
|
| 548 | }
|
| 549 |
|
| 550 | if (this.field_148218_l == 1)
|
| 551 | {
|
| 552 | GuiStats.this.drawSprite(p_148129_1_ + 165 - 18 + 1, p_148129_2_ + 1 + 1, 36, 18);
|
| 553 | }
|
| 554 | else
|
| 555 | {
|
| 556 | GuiStats.this.drawSprite(p_148129_1_ + 165 - 18, p_148129_2_ + 1, 36, 18);
|
| 557 | }
|
| 558 |
|
| 559 | if (this.field_148218_l == 2)
|
| 560 | {
|
| 561 | GuiStats.this.drawSprite(p_148129_1_ + 215 - 18 + 1, p_148129_2_ + 1 + 1, 54, 18);
|
| 562 | }
|
| 563 | else
|
| 564 | {
|
| 565 | GuiStats.this.drawSprite(p_148129_1_ + 215 - 18, p_148129_2_ + 1, 54, 18);
|
| 566 | }
|
| 567 | }
|
| 568 |
|
| 569 | protected void drawSlot(int entryID, int p_180791_2_, int p_180791_3_, int p_180791_4_, int mouseXIn, int mouseYIn)
|
| 570 | {
|
| 571 | StatCrafting statcrafting = this.func_148211_c(entryID);
|
| 572 | Item item = statcrafting.func_150959_a();
|
| 573 | GuiStats.this.drawStatsScreen(p_180791_2_ + 40, p_180791_3_, item);
|
| 574 | int i = Item.getIdFromItem(item);
|
| 575 | this.func_148209_a(StatList.objectCraftStats[i], p_180791_2_ + 115, p_180791_3_, entryID % 2 == 0);
|
| 576 | this.func_148209_a(StatList.objectUseStats[i], p_180791_2_ + 165, p_180791_3_, entryID % 2 == 0);
|
| 577 | this.func_148209_a(statcrafting, p_180791_2_ + 215, p_180791_3_, entryID % 2 == 0);
|
| 578 | }
|
| 579 |
|
| 580 | protected String func_148210_b(int p_148210_1_)
|
| 581 | {
|
| 582 | return p_148210_1_ == 0 ? "stat.crafted" : (p_148210_1_ == 1 ? "stat.used" : "stat.mined");
|
| 583 | }
|
| 584 | }
|
| 585 |
|
| 586 | class StatsGeneral extends GuiSlot
|
| 587 | {
|
| 588 | public StatsGeneral(Minecraft mcIn)
|
| 589 | {
|
| 590 | super(mcIn, GuiStats.this.width, GuiStats.this.height, 32, GuiStats.this.height - 64, 10);
|
| 591 | this.setShowSelectionBox(false);
|
| 592 | }
|
| 593 |
|
| 594 | protected int getSize()
|
| 595 | {
|
| 596 | return StatList.generalStats.size();
|
| 597 | }
|
| 598 |
|
| 599 | protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
|
| 600 | {
|
| 601 | }
|
| 602 |
|
| 603 | protected boolean isSelected(int slotIndex)
|
| 604 | {
|
| 605 | return false;
|
| 606 | }
|
| 607 |
|
| 608 | protected int getContentHeight()
|
| 609 | {
|
| 610 | return this.getSize() * 10;
|
| 611 | }
|
| 612 |
|
| 613 | protected void drawBackground()
|
| 614 | {
|
| 615 | GuiStats.this.drawDefaultBackground();
|
| 616 | }
|
| 617 |
|
| 618 | protected void drawSlot(int entryID, int p_180791_2_, int p_180791_3_, int p_180791_4_, int mouseXIn, int mouseYIn)
|
| 619 | {
|
| 620 | StatBase statbase = (StatBase)StatList.generalStats.get(entryID);
|
| 621 | GuiStats.this.drawString(GuiStats.this.fontRendererObj, statbase.getStatName().getUnformattedText(), p_180791_2_ + 2, p_180791_3_ + 1, entryID % 2 == 0 ? 16777215 : 9474192);
|
| 622 | String s = statbase.format(GuiStats.this.field_146546_t.readStat(statbase));
|
| 623 | GuiStats.this.drawString(GuiStats.this.fontRendererObj, s, p_180791_2_ + 2 + 213 - GuiStats.this.fontRendererObj.getStringWidth(s), p_180791_3_ + 1, entryID % 2 == 0 ? 16777215 : 9474192);
|
| 624 | }
|
| 625 | }
|
| 626 |
|
| 627 | class StatsItem extends GuiStats.Stats
|
| 628 | {
|
| 629 | public StatsItem(Minecraft mcIn)
|
| 630 | {
|
| 631 | super(mcIn);
|
| 632 | this.statsHolder = Lists.<StatCrafting>newArrayList();
|
| 633 |
|
| 634 | for (StatCrafting statcrafting : StatList.itemStats)
|
| 635 | {
|
| 636 | boolean flag = false;
|
| 637 | int i = Item.getIdFromItem(statcrafting.func_150959_a());
|
| 638 |
|
| 639 | if (GuiStats.this.field_146546_t.readStat(statcrafting) > 0)
|
| 640 | {
|
| 641 | flag = true;
|
| 642 | }
|
| 643 | else if (StatList.objectBreakStats[i] != null && GuiStats.this.field_146546_t.readStat(StatList.objectBreakStats[i]) > 0)
|
| 644 | {
|
| 645 | flag = true;
|
| 646 | }
|
| 647 | else if (StatList.objectCraftStats[i] != null && GuiStats.this.field_146546_t.readStat(StatList.objectCraftStats[i]) > 0)
|
| 648 | {
|
| 649 | flag = true;
|
| 650 | }
|
| 651 |
|
| 652 | if (flag)
|
| 653 | {
|
| 654 | this.statsHolder.add(statcrafting);
|
| 655 | }
|
| 656 | }
|
| 657 |
|
| 658 | this.statSorter = new Comparator<StatCrafting>()
|
| 659 | {
|
| 660 | public int compare(StatCrafting p_compare_1_, StatCrafting p_compare_2_)
|
| 661 | {
|
| 662 | int j = Item.getIdFromItem(p_compare_1_.func_150959_a());
|
| 663 | int k = Item.getIdFromItem(p_compare_2_.func_150959_a());
|
| 664 | StatBase statbase = null;
|
| 665 | StatBase statbase1 = null;
|
| 666 |
|
| 667 | if (StatsItem.this.field_148217_o == 0)
|
| 668 | {
|
| 669 | statbase = StatList.objectBreakStats[j];
|
| 670 | statbase1 = StatList.objectBreakStats[k];
|
| 671 | }
|
| 672 | else if (StatsItem.this.field_148217_o == 1)
|
| 673 | {
|
| 674 | statbase = StatList.objectCraftStats[j];
|
| 675 | statbase1 = StatList.objectCraftStats[k];
|
| 676 | }
|
| 677 | else if (StatsItem.this.field_148217_o == 2)
|
| 678 | {
|
| 679 | statbase = StatList.objectUseStats[j];
|
| 680 | statbase1 = StatList.objectUseStats[k];
|
| 681 | }
|
| 682 |
|
| 683 | if (statbase != null || statbase1 != null)
|
| 684 | {
|
| 685 | if (statbase == null)
|
| 686 | {
|
| 687 | return 1;
|
| 688 | }
|
| 689 |
|
| 690 | if (statbase1 == null)
|
| 691 | {
|
| 692 | return -1;
|
| 693 | }
|
| 694 |
|
| 695 | int l = GuiStats.this.field_146546_t.readStat(statbase);
|
| 696 | int i1 = GuiStats.this.field_146546_t.readStat(statbase1);
|
| 697 |
|
| 698 | if (l != i1)
|
| 699 | {
|
| 700 | return (l - i1) * StatsItem.this.field_148215_p;
|
| 701 | }
|
| 702 | }
|
| 703 |
|
| 704 | return j - k;
|
| 705 | }
|
| 706 | };
|
| 707 | }
|
| 708 |
|
| 709 | protected void drawListHeader(int p_148129_1_, int p_148129_2_, Tessellator p_148129_3_)
|
| 710 | {
|
| 711 | super.drawListHeader(p_148129_1_, p_148129_2_, p_148129_3_);
|
| 712 |
|
| 713 | if (this.field_148218_l == 0)
|
| 714 | {
|
| 715 | GuiStats.this.drawSprite(p_148129_1_ + 115 - 18 + 1, p_148129_2_ + 1 + 1, 72, 18);
|
| 716 | }
|
| 717 | else
|
| 718 | {
|
| 719 | GuiStats.this.drawSprite(p_148129_1_ + 115 - 18, p_148129_2_ + 1, 72, 18);
|
| 720 | }
|
| 721 |
|
| 722 | if (this.field_148218_l == 1)
|
| 723 | {
|
| 724 | GuiStats.this.drawSprite(p_148129_1_ + 165 - 18 + 1, p_148129_2_ + 1 + 1, 18, 18);
|
| 725 | }
|
| 726 | else
|
| 727 | {
|
| 728 | GuiStats.this.drawSprite(p_148129_1_ + 165 - 18, p_148129_2_ + 1, 18, 18);
|
| 729 | }
|
| 730 |
|
| 731 | if (this.field_148218_l == 2)
|
| 732 | {
|
| 733 | GuiStats.this.drawSprite(p_148129_1_ + 215 - 18 + 1, p_148129_2_ + 1 + 1, 36, 18);
|
| 734 | }
|
| 735 | else
|
| 736 | {
|
| 737 | GuiStats.this.drawSprite(p_148129_1_ + 215 - 18, p_148129_2_ + 1, 36, 18);
|
| 738 | }
|
| 739 | }
|
| 740 |
|
| 741 | protected void drawSlot(int entryID, int p_180791_2_, int p_180791_3_, int p_180791_4_, int mouseXIn, int mouseYIn)
|
| 742 | {
|
| 743 | StatCrafting statcrafting = this.func_148211_c(entryID);
|
| 744 | Item item = statcrafting.func_150959_a();
|
| 745 | GuiStats.this.drawStatsScreen(p_180791_2_ + 40, p_180791_3_, item);
|
| 746 | int i = Item.getIdFromItem(item);
|
| 747 | this.func_148209_a(StatList.objectBreakStats[i], p_180791_2_ + 115, p_180791_3_, entryID % 2 == 0);
|
| 748 | this.func_148209_a(StatList.objectCraftStats[i], p_180791_2_ + 165, p_180791_3_, entryID % 2 == 0);
|
| 749 | this.func_148209_a(statcrafting, p_180791_2_ + 215, p_180791_3_, entryID % 2 == 0);
|
| 750 | }
|
| 751 |
|
| 752 | protected String func_148210_b(int p_148210_1_)
|
| 753 | {
|
| 754 | return p_148210_1_ == 1 ? "stat.crafted" : (p_148210_1_ == 2 ? "stat.used" : "stat.depleted");
|
| 755 | }
|
| 756 | }
|
| 757 |
|
| 758 | class StatsMobsList extends GuiSlot
|
| 759 | {
|
| 760 | private final List<EntityList.EntityEggInfo> field_148222_l = Lists.<EntityList.EntityEggInfo>newArrayList();
|
| 761 |
|
| 762 | public StatsMobsList(Minecraft mcIn)
|
| 763 | {
|
| 764 | super(mcIn, GuiStats.this.width, GuiStats.this.height, 32, GuiStats.this.height - 64, GuiStats.this.fontRendererObj.FONT_HEIGHT * 4);
|
| 765 | this.setShowSelectionBox(false);
|
| 766 |
|
| 767 | for (EntityList.EntityEggInfo entitylist$entityegginfo : EntityList.entityEggs.values())
|
| 768 | {
|
| 769 | if (GuiStats.this.field_146546_t.readStat(entitylist$entityegginfo.field_151512_d) > 0 || GuiStats.this.field_146546_t.readStat(entitylist$entityegginfo.field_151513_e) > 0)
|
| 770 | {
|
| 771 | this.field_148222_l.add(entitylist$entityegginfo);
|
| 772 | }
|
| 773 | }
|
| 774 | }
|
| 775 |
|
| 776 | protected int getSize()
|
| 777 | {
|
| 778 | return this.field_148222_l.size();
|
| 779 | }
|
| 780 |
|
| 781 | protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
|
| 782 | {
|
| 783 | }
|
| 784 |
|
| 785 | protected boolean isSelected(int slotIndex)
|
| 786 | {
|
| 787 | return false;
|
| 788 | }
|
| 789 |
|
| 790 | protected int getContentHeight()
|
| 791 | {
|
| 792 | return this.getSize() * GuiStats.this.fontRendererObj.FONT_HEIGHT * 4;
|
| 793 | }
|
| 794 |
|
| 795 | protected void drawBackground()
|
| 796 | {
|
| 797 | GuiStats.this.drawDefaultBackground();
|
| 798 | }
|
| 799 |
|
| 800 | protected void drawSlot(int entryID, int p_180791_2_, int p_180791_3_, int p_180791_4_, int mouseXIn, int mouseYIn)
|
| 801 | {
|
| 802 | EntityList.EntityEggInfo entitylist$entityegginfo = (EntityList.EntityEggInfo)this.field_148222_l.get(entryID);
|
| 803 | String s = I18n.format("entity." + EntityList.getStringFromID(entitylist$entityegginfo.spawnedID) + ".name", new Object[0]);
|
| 804 | int i = GuiStats.this.field_146546_t.readStat(entitylist$entityegginfo.field_151512_d);
|
| 805 | int j = GuiStats.this.field_146546_t.readStat(entitylist$entityegginfo.field_151513_e);
|
| 806 | String s1 = I18n.format("stat.entityKills", new Object[] {Integer.valueOf(i), s});
|
| 807 | String s2 = I18n.format("stat.entityKilledBy", new Object[] {s, Integer.valueOf(j)});
|
| 808 |
|
| 809 | if (i == 0)
|
| 810 | {
|
| 811 | s1 = I18n.format("stat.entityKills.none", new Object[] {s});
|
| 812 | }
|
| 813 |
|
| 814 | if (j == 0)
|
| 815 | {
|
| 816 | s2 = I18n.format("stat.entityKilledBy.none", new Object[] {s});
|
| 817 | }
|
| 818 |
|
| 819 | GuiStats.this.drawString(GuiStats.this.fontRendererObj, s, p_180791_2_ + 2 - 10, p_180791_3_ + 1, 16777215);
|
| 820 | GuiStats.this.drawString(GuiStats.this.fontRendererObj, s1, p_180791_2_ + 2, p_180791_3_ + 1 + GuiStats.this.fontRendererObj.FONT_HEIGHT, i == 0 ? 6316128 : 9474192);
|
| 821 | GuiStats.this.drawString(GuiStats.this.fontRendererObj, s2, p_180791_2_ + 2, p_180791_3_ + 1 + GuiStats.this.fontRendererObj.FONT_HEIGHT * 2, j == 0 ? 6316128 : 9474192);
|
| 822 | }
|
| 823 | }
|
| 824 | }
|
| 825 |
|