Advertisement
SergOmarov

Untitled

Sep 23rd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.07 KB | None | 0 0
  1. package hohserg.shop;
  2.  
  3. import cpw.mods.fml.relauncher.Side;
  4. import cpw.mods.fml.relauncher.SideOnly;
  5. import net.minecraft.client.gui.Gui;
  6. import net.minecraft.client.gui.GuiButton;
  7. import net.minecraft.client.gui.inventory.GuiContainer;
  8. import net.minecraft.client.renderer.OpenGlHelper;
  9. import net.minecraft.client.renderer.RenderHelper;
  10. import net.minecraft.client.renderer.entity.RenderManager;
  11. import net.minecraft.entity.EntityLivingBase;
  12. import net.minecraft.entity.player.EntityPlayer;
  13. import net.minecraft.util.ResourceLocation;
  14. import org.lwjgl.opengl.GL11;
  15. import org.lwjgl.opengl.GL12;
  16.  
  17. import java.util.ArrayList;
  18. import java.util.List;
  19.  
  20. @SideOnly(Side.CLIENT)
  21. public final class GuiShop extends GuiContainer
  22. {
  23. private GuiButton buy;
  24. private String text = "";
  25. private int i = 0, pre = 0;
  26. private EntityPlayer player;
  27. public static int selecedIndex;
  28. private long lastTickTime = 720;
  29. public static float rotation = 0.0F;
  30. public static List<Category> categories;
  31. private MoneyType moneyType = MoneyType.LAKY;
  32.  
  33. public GuiShop(EntityPlayer player)
  34. {
  35. super(new ContainerShop(player));
  36. categories = new ArrayList<>();
  37. categories.add(new Category("Броня"));
  38. categories.add(new Category("Оружие"));
  39. categories.add(new Category("Питомцы"));
  40. categories.add(new Category("Декор"));
  41. categories.add(new Category("Другое"));
  42. }
  43.  
  44. @Override
  45. public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_)
  46. {
  47. super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
  48. if (true)
  49. {
  50. buy.enabled = false;
  51. }
  52. else
  53. {
  54. buy.enabled = true;
  55. }
  56. }
  57.  
  58. @Override
  59. public void initGui()
  60. {
  61. super.initGui();
  62. this.buttonList.clear();
  63. this.buttonList.add(new GuiButton(6, guiLeft - 71, guiTop + 150, 47, 20, moneyType.getUnl()));
  64. buy = new GuiButton(5, guiLeft + 189, guiTop + 150, 67, 20, "\u041A\u0443\u043F\u0438\u0442\u044C");
  65. this.buttonList.add(buy);
  66.  
  67. int
  68. posX = guiLeft,
  69. posY = guiTop;
  70.  
  71. for (int i = 0; i < categories.size(); i++)
  72. {
  73. this.buttonList.add(new GuiButton(i, posX + (42 * i) - 23, posY - 5, 42, 10, categories.get(i).getTitle()));
  74. }
  75. lastTickTime = System.currentTimeMillis();
  76. }
  77.  
  78. @Override
  79. protected void mouseClicked(int p_73864_1_, int p_73864_2_, int p_73864_3_)
  80. {
  81. super.mouseClicked(p_73864_1_, p_73864_2_, p_73864_3_);
  82. }
  83.  
  84. @Override
  85. protected void actionPerformed(GuiButton button)
  86. {
  87. switch (button.id)
  88. {
  89. case 0:
  90. case 1:
  91. case 2:
  92. case 3:
  93. case 4:
  94. case 5:
  95. text = categories.get(button.id).getTitle();
  96. break;
  97. case 6:
  98. ++i;
  99. if (i == 4)
  100. {
  101. i = 0;
  102. }
  103. this.moneyType = this.moneyType.getType(i);
  104. button.displayString = this.moneyType.getUnl();
  105. break;
  106. }
  107. }
  108.  
  109. @Override
  110. public void drawGuiContainerBackgroundLayer(float partialTicks, int p_146976_2_, int p_146976_3_)
  111. {
  112. mc.renderEngine.bindTexture(new ResourceLocation("sh", "textures/gui/background.png"));
  113. Gui.func_146110_a(guiLeft - 75, guiTop - 25, 0, 0, 350, 502, 420, 420);
  114. this.fontRendererObj.drawString(text, guiLeft, guiTop + 140, 0xFFFFFF, false);
  115. this.fontRendererObj.drawString("\u0412\u0430\u043B\u044E\u0442\u0430", guiLeft - 60, guiTop + 140, 0xFFFFFF, false);
  116.  
  117. GL11.glPushMatrix();
  118. GL11.glScalef(0.5F, 0.5F, 1);
  119. String money;
  120. int posX, posY;
  121.  
  122. for (MoneyType type : MoneyType.values())
  123. {
  124. money = String.valueOf(ClientUpdater.getMoney(type.getName()));
  125. posX = (int) (guiLeft + mc.fontRenderer.getStringWidth(money) * 0.5F) * 2;
  126. posY = (int) (guiTop + 8 * 0.5F) * 2;
  127. mc.fontRenderer.drawString(money, (posX + type.getX()) + 420, (posY + type.getY()) + 212, 0xFFFFFF, false);
  128. }
  129. GL11.glColor3f(1.0F, 1.0F, 1.0F);
  130. GL11.glPopMatrix();
  131. drawPlayer(guiLeft - 48, guiTop + 83, this.mc.thePlayer);
  132. }
  133.  
  134. private void drawPlayer(int x, int y, EntityLivingBase player)
  135. {
  136. long diff = System.currentTimeMillis() - lastTickTime;
  137. this.lastTickTime = System.currentTimeMillis();
  138. rotation += (float)diff * 0.27f;
  139. GL11.glEnable(GL11.GL_COLOR_MATERIAL);
  140. GL11.glPushMatrix();
  141. GL11.glTranslatef((float)x, (float)y, 50.0F);
  142. GL11.glScalef(-35, 35, 35);
  143. GL11.glRotatef(rotation * 0.125F, 0.0F, 0.2F, 0.0F);
  144. float f2 = player.renderYawOffset, f3 = player.rotationYaw, f4 = player.rotationPitch, f5 = player.prevRotationYawHead, f6 = player.rotationYawHead;
  145. GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
  146. player.renderYawOffset = 40.0F;
  147. player.rotationYaw = 0;
  148. player.rotationPitch = 0.0F;
  149. player.rotationYawHead = 40F;
  150. RenderHelper.enableStandardItemLighting();
  151. GL11.glTranslatef(0.0F, player.yOffset, 0.0F);
  152. RenderManager.instance.playerViewY = 180.0F;
  153. RenderManager.instance.renderEntityWithPosYaw(player, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
  154. player.renderYawOffset = f2;
  155. player.rotationYaw = f3;
  156. player.rotationPitch = f4;
  157. player.prevRotationYawHead = f5;
  158. player.rotationYawHead = f6;
  159. GL11.glPopMatrix();
  160. RenderHelper.disableStandardItemLighting();
  161. GL11.glDisable(GL12.GL_RESCALE_NORMAL);
  162. OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
  163. GL11.glDisable(GL11.GL_TEXTURE_2D);
  164. OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
  165. }
  166.  
  167. @Override
  168. public void onGuiClosed()
  169. {
  170. super.onGuiClosed();
  171. }
  172. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement