| 1 | package net.minecraft.client.gui;
|
| 2 |
|
| 3 | import net.minecraft.client.Minecraft;
|
| 4 | import net.minecraft.client.gui.spectator.ISpectatorMenuObject;
|
| 5 | import net.minecraft.client.gui.spectator.ISpectatorMenuRecipient;
|
| 6 | import net.minecraft.client.gui.spectator.SpectatorMenu;
|
| 7 | import net.minecraft.client.gui.spectator.categories.SpectatorDetails;
|
| 8 | import net.minecraft.client.renderer.GlStateManager;
|
| 9 | import net.minecraft.client.renderer.RenderHelper;
|
| 10 | import net.minecraft.client.settings.GameSettings;
|
| 11 | import net.minecraft.util.MathHelper;
|
| 12 | import net.minecraft.util.ResourceLocation;
|
| 13 |
|
| 14 | public class GuiSpectator extends Gui implements ISpectatorMenuRecipient
|
| 15 | {
|
| 16 | private static final ResourceLocation field_175267_f = new ResourceLocation("textures/gui/widgets.png");
|
| 17 | public static final ResourceLocation field_175269_a = new ResourceLocation("textures/gui/spectator_widgets.png");
|
| 18 | private final Minecraft field_175268_g;
|
| 19 | private long field_175270_h;
|
| 20 | private SpectatorMenu field_175271_i;
|
| 21 |
|
| 22 | public GuiSpectator(Minecraft mcIn)
|
| 23 | {
|
| 24 | this.field_175268_g = mcIn;
|
| 25 | }
|
| 26 |
|
| 27 | public void func_175260_a(int p_175260_1_)
|
| 28 | {
|
| 29 | this.field_175270_h = Minecraft.getSystemTime();
|
| 30 |
|
| 31 | if (this.field_175271_i != null)
|
| 32 | {
|
| 33 | this.field_175271_i.func_178644_b(p_175260_1_);
|
| 34 | }
|
| 35 | else
|
| 36 | {
|
| 37 | this.field_175271_i = new SpectatorMenu(this);
|
| 38 | }
|
| 39 | }
|
| 40 |
|
| 41 | private float func_175265_c()
|
| 42 | {
|
| 43 | long i = this.field_175270_h - Minecraft.getSystemTime() + 5000L;
|
| 44 | return MathHelper.clamp_float((float)i / 2000.0F, 0.0F, 1.0F);
|
| 45 | }
|
| 46 |
|
| 47 | public void renderTooltip(ScaledResolution p_175264_1_, float p_175264_2_)
|
| 48 | {
|
| 49 | if (this.field_175271_i != null)
|
| 50 | {
|
| 51 | float f = this.func_175265_c();
|
| 52 |
|
| 53 | if (f <= 0.0F)
|
| 54 | {
|
| 55 | this.field_175271_i.func_178641_d();
|
| 56 | }
|
| 57 | else
|
| 58 | {
|
| 59 | int i = p_175264_1_.getScaledWidth() / 2;
|
| 60 | float f1 = this.zLevel;
|
| 61 | this.zLevel = -90.0F;
|
| 62 | float f2 = (float)p_175264_1_.getScaledHeight() - 22.0F * f;
|
| 63 | SpectatorDetails spectatordetails = this.field_175271_i.func_178646_f();
|
| 64 | this.func_175258_a(p_175264_1_, f, i, f2, spectatordetails);
|
| 65 | this.zLevel = f1;
|
| 66 | }
|
| 67 | }
|
| 68 | }
|
| 69 |
|
| 70 | protected void func_175258_a(ScaledResolution p_175258_1_, float p_175258_2_, int p_175258_3_, float p_175258_4_, SpectatorDetails p_175258_5_)
|
| 71 | {
|
| 72 | GlStateManager.enableRescaleNormal();
|
| 73 | GlStateManager.enableBlend();
|
| 74 | GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
| 75 | GlStateManager.color(1.0F, 1.0F, 1.0F, p_175258_2_);
|
| 76 | this.field_175268_g.getTextureManager().bindTexture(field_175267_f);
|
| 77 | this.drawTexturedModalRect((float)(p_175258_3_ - 91), p_175258_4_, 0, 0, 182, 22);
|
| 78 |
|
| 79 | if (p_175258_5_.func_178681_b() >= 0)
|
| 80 | {
|
| 81 | this.drawTexturedModalRect((float)(p_175258_3_ - 91 - 1 + p_175258_5_.func_178681_b() * 20), p_175258_4_ - 1.0F, 0, 22, 24, 22);
|
| 82 | }
|
| 83 |
|
| 84 | RenderHelper.enableGUIStandardItemLighting();
|
| 85 |
|
| 86 | for (int i = 0; i < 9; ++i)
|
| 87 | {
|
| 88 | this.func_175266_a(i, p_175258_1_.getScaledWidth() / 2 - 90 + i * 20 + 2, p_175258_4_ + 3.0F, p_175258_2_, p_175258_5_.func_178680_a(i));
|
| 89 | }
|
| 90 |
|
| 91 | RenderHelper.disableStandardItemLighting();
|
| 92 | GlStateManager.disableRescaleNormal();
|
| 93 | GlStateManager.disableBlend();
|
| 94 | }
|
| 95 |
|
| 96 | private void func_175266_a(int p_175266_1_, int p_175266_2_, float p_175266_3_, float p_175266_4_, ISpectatorMenuObject p_175266_5_)
|
| 97 | {
|
| 98 | this.field_175268_g.getTextureManager().bindTexture(field_175269_a);
|
| 99 |
|
| 100 | if (p_175266_5_ != SpectatorMenu.field_178657_a)
|
| 101 | {
|
| 102 | int i = (int)(p_175266_4_ * 255.0F);
|
| 103 | GlStateManager.pushMatrix();
|
| 104 | GlStateManager.translate((float)p_175266_2_, p_175266_3_, 0.0F);
|
| 105 | float f = p_175266_5_.func_178662_A_() ? 1.0F : 0.25F;
|
| 106 | GlStateManager.color(f, f, f, p_175266_4_);
|
| 107 | p_175266_5_.func_178663_a(f, i);
|
| 108 | GlStateManager.popMatrix();
|
| 109 | String s = String.valueOf((Object)GameSettings.getKeyDisplayString(this.field_175268_g.gameSettings.keyBindsHotbar[p_175266_1_].getKeyCode()));
|
| 110 |
|
| 111 | if (i > 3 && p_175266_5_.func_178662_A_())
|
| 112 | {
|
| 113 | this.field_175268_g.fontRendererObj.drawStringWithShadow(s, (float)(p_175266_2_ + 19 - 2 - this.field_175268_g.fontRendererObj.getStringWidth(s)), p_175266_3_ + 6.0F + 3.0F, 16777215 + (i << 24));
|
| 114 | }
|
| 115 | }
|
| 116 | }
|
| 117 |
|
| 118 | public void renderSelectedItem(ScaledResolution p_175263_1_)
|
| 119 | {
|
| 120 | int i = (int)(this.func_175265_c() * 255.0F);
|
| 121 |
|
| 122 | if (i > 3 && this.field_175271_i != null)
|
| 123 | {
|
| 124 | ISpectatorMenuObject ispectatormenuobject = this.field_175271_i.func_178645_b();
|
| 125 | String s = ispectatormenuobject != SpectatorMenu.field_178657_a ? ispectatormenuobject.getSpectatorName().getFormattedText() : this.field_175271_i.func_178650_c().func_178670_b().getFormattedText();
|
| 126 |
|
| 127 | if (s != null)
|
| 128 | {
|
| 129 | int j = (p_175263_1_.getScaledWidth() - this.field_175268_g.fontRendererObj.getStringWidth(s)) / 2;
|
| 130 | int k = p_175263_1_.getScaledHeight() - 35;
|
| 131 | GlStateManager.pushMatrix();
|
| 132 | GlStateManager.enableBlend();
|
| 133 | GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
| 134 | this.field_175268_g.fontRendererObj.drawStringWithShadow(s, (float)j, (float)k, 16777215 + (i << 24));
|
| 135 | GlStateManager.disableBlend();
|
| 136 | GlStateManager.popMatrix();
|
| 137 | }
|
| 138 | }
|
| 139 | }
|
| 140 |
|
| 141 | public void func_175257_a(SpectatorMenu p_175257_1_)
|
| 142 | {
|
| 143 | this.field_175271_i = null;
|
| 144 | this.field_175270_h = 0L;
|
| 145 | }
|
| 146 |
|
| 147 | public boolean func_175262_a()
|
| 148 | {
|
| 149 | return this.field_175271_i != null;
|
| 150 | }
|
| 151 |
|
| 152 | public void func_175259_b(int p_175259_1_)
|
| 153 | {
|
| 154 | int i;
|
| 155 |
|
| 156 | for (i = this.field_175271_i.func_178648_e() + p_175259_1_; i >= 0 && i <= 8 && (this.field_175271_i.func_178643_a(i) == SpectatorMenu.field_178657_a || !this.field_175271_i.func_178643_a(i).func_178662_A_()); i += p_175259_1_)
|
| 157 | {
|
| 158 | ;
|
| 159 | }
|
| 160 |
|
| 161 | if (i >= 0 && i <= 8)
|
| 162 | {
|
| 163 | this.field_175271_i.func_178644_b(i);
|
| 164 | this.field_175270_h = Minecraft.getSystemTime();
|
| 165 | }
|
| 166 | }
|
| 167 |
|
| 168 | public void func_175261_b()
|
| 169 | {
|
| 170 | this.field_175270_h = Minecraft.getSystemTime();
|
| 171 |
|
| 172 | if (this.func_175262_a())
|
| 173 | {
|
| 174 | int i = this.field_175271_i.func_178648_e();
|
| 175 |
|
| 176 | if (i != -1)
|
| 177 | {
|
| 178 | this.field_175271_i.func_178644_b(i);
|
| 179 | }
|
| 180 | }
|
| 181 | else
|
| 182 | {
|
| 183 | this.field_175271_i = new SpectatorMenu(this);
|
| 184 | }
|
| 185 | }
|
| 186 | }
|
| 187 |
|