├── README.md ├── .gitignore ├── 1.7.10 ├── mcmod.info └── org │ └── jackhuang │ └── myui │ ├── client │ ├── NewMenuHandler.java │ ├── MyUIModGuiFactory.java │ └── NewMenu.java │ ├── MyUI.java │ └── util │ ├── MD5Util.java │ ├── NetUtil.java │ ├── GLUtil.java │ ├── HttpDownloader.java │ └── LoadServerThread.java ├── 1.7.2 ├── mcmod.info └── org │ └── jackhuang │ └── myui │ ├── util │ ├── MD5Util.java │ ├── NetUtil.java │ ├── GLUtil.java │ ├── HttpDownloader.java │ └── LoadServerThread.java │ ├── MyUI.java │ └── client │ ├── MyUIModGuiFactory.java │ └── NewMenu.java ├── 1.6.4 └── org │ └── jackhuang │ └── myui │ ├── util │ ├── MD5Util.java │ ├── NetUtil.java │ ├── GLUtil.java │ ├── HttpDownloader.java │ └── LoadServerThread.java │ ├── MyUI.java │ ├── CopyrightScreen.java │ └── NewMenu.java └── LICENSE.md /README.md: -------------------------------------------------------------------------------- 1 | MyUI 2 | ==== 3 | 4 | It changed the main look of Minecraft. 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | -------------------------------------------------------------------------------- /1.7.10/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "MyUI", 4 | "name": "MyUI", 5 | "description": "It changed the minecraft main screen look.", 6 | "version": "1.0", 7 | "mcversion": "1.7.10", 8 | "url": "", 9 | "updateUrl": "", 10 | "authorList": ["huanghongxun"], 11 | "credits": "Huang Yuhui.", 12 | "logoFile": "", 13 | "screenshots": [], 14 | "dependencies": [""] 15 | } 16 | ] 17 | -------------------------------------------------------------------------------- /1.7.2/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "MyUI", 4 | "name": "MyUI", 5 | "description": "It changed the minecraft main screen look.", 6 | "version": "1.0", 7 | "mcversion": "1.7.2", 8 | "url": "", 9 | "updateUrl": "", 10 | "authorList": ["huanghongxun"], 11 | "credits": "Huang Yuhui.", 12 | "logoFile": "", 13 | "screenshots": [], 14 | "dependencies": [""] 15 | } 16 | ] 17 | -------------------------------------------------------------------------------- /1.7.10/org/jackhuang/myui/client/NewMenuHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.client; 9 | 10 | public class NewMenuHandler { 11 | 12 | public static NewMenuHandler instance = new NewMenuHandler(); 13 | 14 | @SubscribeEvent 15 | public void openMainMenu(GuiOpenEvent event) throws IOException { 16 | if (event.gui instanceof GuiMainMenu) { 17 | event.gui = new NewMenu(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /1.7.10/org/jackhuang/myui/MyUI.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui; 9 | 10 | 11 | @Mod(modid = "MyUI", name = "MyUI", version = "1.1", guiFactory = "org.jackhuang.myui.client.MyUIModGuiFactory") 12 | public class MyUI { 13 | 14 | @EventHandler 15 | public void preInit(FMLPreInitializationEvent event) { 16 | 17 | MinecraftForge.EVENT_BUS.register(new NewMenuHandler()); 18 | } 19 | 20 | @Mod.Instance("MyUI") 21 | public static MyUI instance; 22 | } 23 | -------------------------------------------------------------------------------- /1.6.4/org/jackhuang/myui/util/MD5Util.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.util; 9 | 10 | public class MD5Util { 11 | 12 | public static int tryParseInt(String s, int def) { 13 | try { 14 | return Integer.parseInt(s); 15 | } catch(Throwable t) { 16 | return def; 17 | } 18 | } 19 | 20 | public static double tryParseDouble(String s, double def) { 21 | try { 22 | return Double.parseDouble(s); 23 | } catch(Throwable t) { 24 | return def; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /1.7.10/org/jackhuang/myui/util/MD5Util.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.util; 9 | 10 | public class MD5Util { 11 | 12 | public static int tryParseInt(String s, int def) { 13 | try { 14 | return Integer.parseInt(s); 15 | } catch(Throwable t) { 16 | return def; 17 | } 18 | } 19 | 20 | public static double tryParseDouble(String s, double def) { 21 | try { 22 | return Double.parseDouble(s); 23 | } catch(Throwable t) { 24 | return def; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /1.7.2/org/jackhuang/myui/util/MD5Util.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.util; 9 | 10 | public class MD5Util { 11 | 12 | public static int tryParseInt(String s, int def) { 13 | try { 14 | return Integer.parseInt(s); 15 | } catch(Throwable t) { 16 | return def; 17 | } 18 | } 19 | 20 | public static double tryParseDouble(String s, double def) { 21 | try { 22 | return Double.parseDouble(s); 23 | } catch(Throwable t) { 24 | return def; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /1.6.4/org/jackhuang/myui/MyUI.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui; 9 | 10 | @Mod(modid = "MyUI", name = "MyUI", version = "1.1") 11 | public class MyUI { 12 | 13 | @EventHandler 14 | public void postInit(FMLPostInitializationEvent event) { 15 | 16 | MinecraftForge.EVENT_BUS.register(this); 17 | } 18 | 19 | @Mod.Instance("MyUI") 20 | public static MyUI instance; 21 | 22 | @ForgeSubscribe 23 | public void openGui(GuiOpenEvent event) { 24 | if(event.gui instanceof GuiMainMenu) 25 | event.gui = new NewMenu(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /1.7.2/org/jackhuang/myui/MyUI.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui; 9 | 10 | @Mod(modid = "MyUI", name = "MyUI", version = "1.1", guiFactory = "org.jackhuang.myui.client.MyUIModGuiFactory") 11 | public class MyUI { 12 | 13 | @EventHandler 14 | public void preInit(FMLPreInitializationEvent event) { 15 | 16 | MinecraftForge.EVENT_BUS.register(this); 17 | } 18 | 19 | @SubscribeEvent 20 | public void openMainMenu(GuiOpenEvent event) { 21 | if (event.gui instanceof GuiMainMenu) { 22 | event.gui = new NewMenu(); 23 | } 24 | } 25 | 26 | @Mod.Instance("MyUI") 27 | public static MyUI instance; 28 | } 29 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MyUI Mod License 2 | ## Source 3 | * You may not create works using the MyUI code (source or binary) without huanghongxun's explicit permission except in the cases listed in the license. 4 | * This source code is hosted on GitHub. 5 | * You may NOT create derivative jars from MyUI source to distribute to other users. 6 | * You may NOT distribute any Jar created from a fork for any reason. 7 | 8 | ## Distribution 9 | * You may not publicly distribute MyUI on another site without huanghongxun's explicit permission. And if you have permission you must use the download links provided there unless you receive permission to do otherwise. 10 | 11 | ## Mod Packs 12 | * You may not sell the mod pack. 13 | * You are required to publicly post a licensing page with entries for all the mods currently in your mod pack. If you cannot or will not do this, you can not use MyUI in your mod pack. -------------------------------------------------------------------------------- /1.7.2/org/jackhuang/myui/util/NetUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.util; 9 | 10 | public class NetUtil { 11 | 12 | public static String getNetContent(String url) { 13 | URL u = new URL(url); 14 | return getStreamContent(u.openStream()); 15 | } 16 | 17 | public static String getStreamContent(InputStream is) { 18 | BufferedReader reader = new BufferedReader(new InputStreamReader(is)); 19 | String c = "", line; 20 | while((line = reader.readLine()) != null) 21 | c += "\n" + line; 22 | return c.substring(1); 23 | } 24 | 25 | public static void writeToStream(OutputStream os, String content) { 26 | OutputStreamWriter writer = new OutputStreamWriter(os); 27 | writer.write(content); 28 | writer.flush(); writer.close(); 29 | } 30 | 31 | public static String post(String url, String content) { 32 | URL u = new URL(url); 33 | URLConnection c = u.openConnection(); 34 | c.setDoOutput(true); 35 | writeToStream(c.getOutputStream(), content); 36 | return getStreamContent(c.getInputStream()); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /1.6.4/org/jackhuang/myui/util/NetUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.util; 9 | 10 | public class NetUtil { 11 | 12 | public static String getNetContent(String url) throws IOException { 13 | URL u = new URL(url); 14 | return getStreamContent(u.openStream()); 15 | } 16 | 17 | public static String getStreamContent(InputStream is) throws IOException { 18 | BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); 19 | String c = "", line; 20 | while((line = reader.readLine()) != null) 21 | c += "\n" + line; 22 | return c.substring(1); 23 | } 24 | 25 | public static void writeToStream(OutputStream os, String content) throws IOException { 26 | OutputStreamWriter writer = new OutputStreamWriter(os); 27 | writer.write(content); 28 | writer.flush(); writer.close(); 29 | } 30 | 31 | public static String post(String url, String content) throws IOException { 32 | URL u = new URL(url); 33 | URLConnection c = u.openConnection(); 34 | c.setDoOutput(true); 35 | writeToStream(c.getOutputStream(), content); 36 | return getStreamContent(c.getInputStream()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /1.7.10/org/jackhuang/myui/util/NetUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.util; 9 | 10 | public class NetUtil { 11 | 12 | public static String getNetContent(String url) throws IOException { 13 | URL u = new URL(url); 14 | return getStreamContent(u.openStream()); 15 | } 16 | 17 | public static String getStreamContent(InputStream is) throws IOException { 18 | BufferedReader reader = new BufferedReader(new InputStreamReader(is)); 19 | String c = "", line; 20 | while((line = reader.readLine()) != null) 21 | c += "\n" + line; 22 | return c.substring(1); 23 | } 24 | 25 | public static void writeToStream(OutputStream os, String content) throws IOException { 26 | OutputStreamWriter writer = new OutputStreamWriter(os); 27 | writer.write(content); 28 | writer.flush(); writer.close(); 29 | } 30 | 31 | public static String post(String url, String content) throws IOException { 32 | URL u = new URL(url); 33 | URLConnection c = u.openConnection(); 34 | c.setDoOutput(true); 35 | writeToStream(c.getOutputStream(), content); 36 | return getStreamContent(c.getInputStream()); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /1.6.4/org/jackhuang/myui/CopyrightScreen.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui; 9 | 10 | public class CopyrightScreen extends GuiScreen { 11 | private GuiScreen parent; 12 | 13 | public CopyrightScreen(GuiScreen parent) { 14 | this.parent = parent; 15 | } 16 | 17 | @Override 18 | public void initGui() { 19 | this.buttonList.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.getString("gui.done"))); 20 | } 21 | 22 | @Override 23 | protected void actionPerformed(GuiButton p_146284_1_) { 24 | if ((p_146284_1_.enabled) && (p_146284_1_.id == 1)) { 25 | FMLClientHandler.instance().showGuiScreen(this.parent); 26 | } 27 | } 28 | 29 | @Override 30 | public void drawScreen(int par1, int par2, float par3) { 31 | drawDefaultBackground(); 32 | drawCenteredString(this.fontRenderer, "MyUI Mod 版权许可(以下为侵犯版权的行为)", this.width / 2, 40, 16777215); 33 | 34 | List list = ImmutableList.of( 35 | "以下购买人为甲方,受托人为乙方。", 36 | "mcbbs: huanghongxun, baidu: huanghongxun20, qq: 1542806507", 37 | "1 甲方权利和义务", 38 | "1.1 甲方向乙方提供软件定制时所需的定制软件规划。", 39 | "1.2 根据项目需要提供有关资料、图片等,要求保证所有资料完整、真实。", 40 | "1.3 甲方在使用乙方提供的软件产品时,不得转为第三方使用,本次定制的最终产品是乙方专门为甲方定制,其知识产权属于乙方,甲方为永久使用权。", 41 | "1.4 如甲方需要乙方提供其他软件、技术支持、相关开发等,双方应另行签署其他协议;", 42 | "1.5 甲方同意按双方约定的付款方式和时间及时向乙方支付软件费用,以及在乙方进行软件开发工作时提供其他必要的帮助。", 43 | "1.6 甲方承诺,向乙方提供的内容、资料等不会侵犯任何第三方权利;若发生侵犯第三方权利的情形,由甲方承担全部责任。因甲方在使用本软件给第三方造成损害的,由甲方自行承担责任。", 44 | "1.7 甲方当事人应当保守在履行服务协议中获知的对方商业秘密。", 45 | "1.8 甲方对乙方提供服务过程中使用的技术、软件等所涉及的包括知识产权在内的一切法律问题不承担任何责任。", 46 | "2 乙方的权利和义务", 47 | "2.1 可以根据甲方的要求指导甲方使用定制软件;", 48 | "2.2 依合同收取费用;", 49 | "2.3 在开发过程中,对甲方陆续提出的修改要求,乙方应协助实现,(但如果超出合同要求工作量过大,则需要协商修改合同条款),并由甲方验收,对验收时不合格的地方进行修改;", 50 | "2.4 本合同项目完成后,甲方有对这些相关程序的永久使用权,包括二次开发。乙方完全拥有本程序代码的所有权。除乙方授权外,甲方不得向乙方源代码或源代码所生产的产品直接销售给第三方。", 51 | "2.5 乙方当事人应当保守在履行服务协议中获知的对方商业秘密。", 52 | "2.6 乙方在签订合同后,开始定制工作,在设计阶段和功能开发阶段要及时与甲方沟通,若甲乙双方在功能理解上存在分歧不能协商好,本着甲方对乙方专业水准的认可前提下,以乙方的理解为主。" 53 | ); 54 | 55 | 56 | for (int i = list.size()-1; i >= 0; i--) { 57 | String brd = list.get(i); 58 | if (!Strings.isNullOrEmpty(brd)) { 59 | this.drawString(this.fontRenderer, brd, 2, 60 + i * (this.fontRenderer.FONT_HEIGHT + 1), 60 | 16777215); 61 | } 62 | } 63 | 64 | 65 | super.drawScreen(par1, par2, par3); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /1.7.10/org/jackhuang/myui/util/GLUtil.java: -------------------------------------------------------------------------------- 1 | package org.jackhuang.myui.util; 2 | 3 | public class GLUtil { 4 | 5 | public static int loadTexture(BufferedImage image) { 6 | int[] pixels = new int[image.getWidth() * image.getHeight()]; 7 | image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, 8 | image.getWidth()); 9 | 10 | ByteBuffer buffer = BufferUtils.createByteBuffer(image.getWidth() 11 | * image.getHeight() * 4); // 4 for RGBA, 3 for RGB 12 | 13 | for (int x = 0; x < image.getWidth(); x++) { 14 | for (int y = 0; y < image.getHeight(); y++) { 15 | int pixel = pixels[y * image.getWidth() + x]; 16 | buffer.put((byte) ((pixel >> 16) & 0xFF)); // Red component 17 | buffer.put((byte) ((pixel >> 8) & 0xFF)); // Green component 18 | buffer.put((byte) (pixel & 0xFF)); // Blue component 19 | buffer.put((byte) ((pixel >> 24) & 0xFF)); // Alpha component. 20 | // Only for RGBA 21 | } 22 | } 23 | 24 | buffer.flip(); // FOR THE LOVE OF GOD DO NOT FORGET THIS 25 | 26 | // You now have a ByteBuffer filled with the color data of each pixel. 27 | // Now just create a texture ID and bind it. Then you can load it using 28 | // whatever OpenGL method you want, for example: 29 | 30 | int textureID = glGenTextures(); // Generate texture ID 31 | glBindTexture(GL_TEXTURE_2D, textureID); // Bind texture ID 32 | 33 | // Setup wrap mode 34 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); 35 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); 36 | 37 | // Setup texture scaling filtering 38 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 39 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 40 | 41 | // Send texel data to OpenGL 42 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image.getWidth(), 43 | image.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); 44 | 45 | // Return the texture ID so we can bind it later again 46 | return textureID; 47 | } 48 | 49 | public static BufferedImage loadImage(String loc) { 50 | 51 | try { 52 | File f = new File(loc).getAbsoluteFile(); 53 | //System.out.println("F: " + f.getPath()); 54 | return ImageIO.read(f); 55 | } catch (IOException e) { 56 | } 57 | return null; 58 | } 59 | 60 | public static void drawTexture(int x1, int y1, int x2, int y2) { 61 | GL11.glColor3f(255, 255, 255); 62 | GL11.glBegin(GL11.GL_QUADS); 63 | GL11.glTexCoord2d(0, 0); 64 | GL11.glVertex2i(x1, y1); 65 | GL11.glTexCoord2d(1, 0); 66 | GL11.glVertex2i(x1, y2); 67 | GL11.glTexCoord2d(1, 1); 68 | GL11.glVertex2i(x2, y2); 69 | GL11.glTexCoord2d(0, 1); 70 | GL11.glVertex2i(x2, y1); 71 | GL11.glEnd(); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /1.7.2/org/jackhuang/myui/util/GLUtil.java: -------------------------------------------------------------------------------- 1 | package org.jackhuang.myui.util; 2 | 3 | public class GLUtil { 4 | 5 | public static int loadTexture(BufferedImage image) { 6 | int[] pixels = new int[image.getWidth() * image.getHeight()]; 7 | image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, 8 | image.getWidth()); 9 | 10 | ByteBuffer buffer = BufferUtils.createByteBuffer(image.getWidth() 11 | * image.getHeight() * 4); // 4 for RGBA, 3 for RGB 12 | 13 | for (int x = 0; x < image.getWidth(); x++) { 14 | for (int y = 0; y < image.getHeight(); y++) { 15 | int pixel = pixels[y * image.getWidth() + x]; 16 | buffer.put((byte) ((pixel >> 16) & 0xFF)); // Red component 17 | buffer.put((byte) ((pixel >> 8) & 0xFF)); // Green component 18 | buffer.put((byte) (pixel & 0xFF)); // Blue component 19 | buffer.put((byte) ((pixel >> 24) & 0xFF)); // Alpha component. 20 | // Only for RGBA 21 | } 22 | } 23 | 24 | buffer.flip(); // FOR THE LOVE OF GOD DO NOT FORGET THIS 25 | 26 | // You now have a ByteBuffer filled with the color data of each pixel. 27 | // Now just create a texture ID and bind it. Then you can load it using 28 | // whatever OpenGL method you want, for example: 29 | 30 | int textureID = glGenTextures(); // Generate texture ID 31 | glBindTexture(GL_TEXTURE_2D, textureID); // Bind texture ID 32 | 33 | // Setup wrap mode 34 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); 35 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); 36 | 37 | // Setup texture scaling filtering 38 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 39 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 40 | 41 | // Send texel data to OpenGL 42 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image.getWidth(), 43 | image.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); 44 | 45 | // Return the texture ID so we can bind it later again 46 | return textureID; 47 | } 48 | 49 | public static BufferedImage loadImage(String loc) { 50 | 51 | try { 52 | File f = new File(loc).getAbsoluteFile(); 53 | //System.out.println("F: " + f.getPath()); 54 | return ImageIO.read(f); 55 | } catch (IOException e) { 56 | } 57 | return null; 58 | } 59 | 60 | public static void drawTexture(int x1, int y1, int x2, int y2) { 61 | GL11.glColor3f(255, 255, 255); 62 | GL11.glBegin(GL11.GL_QUADS); 63 | GL11.glTexCoord2d(0, 0); 64 | GL11.glVertex2i(x1, y1); 65 | GL11.glTexCoord2d(1, 0); 66 | GL11.glVertex2i(x1, y2); 67 | GL11.glTexCoord2d(1, 1); 68 | GL11.glVertex2i(x2, y2); 69 | GL11.glTexCoord2d(0, 1); 70 | GL11.glVertex2i(x2, y1); 71 | GL11.glEnd(); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /1.6.4/org/jackhuang/myui/util/GLUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * "MyUI" is distributed under the MIT License. 5 | * Please check the contents of the license. 6 | */ 7 | package org.jackhuang.myui.util; 8 | 9 | public class GLUtil { 10 | 11 | public static int loadTexture(BufferedImage image) { 12 | int[] pixels = new int[image.getWidth() * image.getHeight()]; 13 | image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, 14 | image.getWidth()); 15 | 16 | ByteBuffer buffer = BufferUtils.createByteBuffer(image.getWidth() 17 | * image.getHeight() * 4); // 4 for RGBA, 3 for RGB 18 | 19 | for (int x = 0; x < image.getWidth(); x++) { 20 | for (int y = 0; y < image.getHeight(); y++) { 21 | int pixel = pixels[y * image.getWidth() + x]; 22 | buffer.put((byte) ((pixel >> 16) & 0xFF)); // Red component 23 | buffer.put((byte) ((pixel >> 8) & 0xFF)); // Green component 24 | buffer.put((byte) (pixel & 0xFF)); // Blue component 25 | buffer.put((byte) ((pixel >> 24) & 0xFF)); // Alpha component. 26 | // Only for RGBA 27 | } 28 | } 29 | 30 | buffer.flip(); // FOR THE LOVE OF GOD DO NOT FORGET THIS 31 | 32 | // You now have a ByteBuffer filled with the color data of each pixel. 33 | // Now just create a texture ID and bind it. Then you can load it using 34 | // whatever OpenGL method you want, for example: 35 | 36 | int textureID = glGenTextures(); // Generate texture ID 37 | glBindTexture(GL_TEXTURE_2D, textureID); // Bind texture ID 38 | 39 | // Setup wrap mode 40 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); 41 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); 42 | 43 | // Setup texture scaling filtering 44 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 45 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 46 | 47 | // Send texel data to OpenGL 48 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image.getWidth(), 49 | image.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); 50 | 51 | // Return the texture ID so we can bind it later again 52 | return textureID; 53 | } 54 | 55 | public static BufferedImage loadImage(String loc) { 56 | 57 | try { 58 | File f = new File(loc).getAbsoluteFile(); 59 | //System.out.println("F: " + f.getPath()); 60 | return ImageIO.read(f); 61 | } catch (IOException e) { 62 | } 63 | return null; 64 | } 65 | 66 | public static void drawTexture(int x1, int y1, int x2, int y2) { 67 | GL11.glColor3f(255, 255, 255); 68 | GL11.glBegin(GL11.GL_QUADS); 69 | GL11.glTexCoord2d(0, 0); 70 | GL11.glVertex2i(x1, y1); 71 | GL11.glTexCoord2d(1, 0); 72 | GL11.glVertex2i(x1, y2); 73 | GL11.glTexCoord2d(1, 1); 74 | GL11.glVertex2i(x2, y2); 75 | GL11.glTexCoord2d(0, 1); 76 | GL11.glVertex2i(x2, y1); 77 | GL11.glEnd(); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /1.7.10/org/jackhuang/myui/util/HttpDownloader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.util; 9 | 10 | public class HttpDownloader { 11 | 12 | private static final int MAX_BUFFER_SIZE = 2048; 13 | 14 | public static final String STATUSES[] = {"Downloading", 15 | "Paused", "Complete", "Cancelled", "Error"}; 16 | 17 | public static final int DOWNLOADING = 0; 18 | public static final int PAUSED = 1; 19 | public static final int COMPLETE = 2; 20 | public static final int CANCELLED = 3; 21 | public static final int ERROR = 4; 22 | 23 | private URL url; 24 | private int size; 25 | private int downloaded; 26 | private ActionListener listener; 27 | private String filePath; 28 | 29 | public HttpDownloader(URL url, String filePath, ActionListener l) { 30 | this.url = url; 31 | size = -1; 32 | downloaded = 0; 33 | this.filePath = filePath; 34 | this.listener = l; 35 | } 36 | 37 | public String getUrl() { 38 | return url.toString(); 39 | } 40 | 41 | public long getSize() { 42 | return size; 43 | } 44 | 45 | public float getProgress() { 46 | return ((float) downloaded / size) * 100; 47 | } 48 | 49 | private String getFileName(URL url) { 50 | String fileName = url.getFile(); 51 | return fileName.substring(fileName.lastIndexOf('/') + 1); 52 | } 53 | 54 | @Override 55 | public void run() { 56 | RandomAccessFile file = null; 57 | InputStream stream = null; 58 | HttpURLConnection connection = url.openConnection(); 59 | 60 | connection.setConnectTimeout(5000); 61 | connection.setRequestProperty("Range", 62 | "bytes=" + downloaded + "-"); 63 | connection.connect(); 64 | 65 | if (connection.getResponseCode() / 100 != 2) { 66 | throw new Exception(); 67 | } 68 | 69 | int contentLength = connection.getContentLength(); 70 | if (contentLength < 1) { 71 | throw new Exception(); 72 | } 73 | 74 | if (size == -1) { 75 | size = contentLength; 76 | } 77 | 78 | file = new RandomAccessFile(filePath, "rw"); 79 | file.seek(downloaded); 80 | 81 | stream = connection.getInputStream(); 82 | while (true) { 83 | byte buffer[] = new byte[MAX_BUFFER_SIZE]; 84 | 85 | int read = stream.read(buffer); 86 | if (read == -1) 87 | break; 88 | 89 | file.write(buffer, 0, read); 90 | downloaded += read; 91 | } 92 | if(listener != null) 93 | listener.actionPerformed(null); 94 | } 95 | } -------------------------------------------------------------------------------- /1.7.2/org/jackhuang/myui/util/HttpDownloader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.util; 9 | 10 | public class HttpDownloader { 11 | 12 | private static final int MAX_BUFFER_SIZE = 2048; 13 | 14 | public static final String STATUSES[] = {"Downloading", 15 | "Paused", "Complete", "Cancelled", "Error"}; 16 | 17 | public static final int DOWNLOADING = 0; 18 | public static final int PAUSED = 1; 19 | public static final int COMPLETE = 2; 20 | public static final int CANCELLED = 3; 21 | public static final int ERROR = 4; 22 | 23 | private URL url; 24 | private int size; 25 | private int downloaded; 26 | private ActionListener listener; 27 | private String filePath; 28 | 29 | public HttpDownloader(URL url, String filePath, ActionListener l) { 30 | this.url = url; 31 | size = -1; 32 | downloaded = 0; 33 | this.filePath = filePath; 34 | this.listener = l; 35 | } 36 | 37 | public String getUrl() { 38 | return url.toString(); 39 | } 40 | 41 | public long getSize() { 42 | return size; 43 | } 44 | 45 | public float getProgress() { 46 | return ((float) downloaded / size) * 100; 47 | } 48 | 49 | private String getFileName(URL url) { 50 | String fileName = url.getFile(); 51 | return fileName.substring(fileName.lastIndexOf('/') + 1); 52 | } 53 | 54 | @Override 55 | public void run() { 56 | RandomAccessFile file = null; 57 | InputStream stream = null; 58 | HttpURLConnection connection = url.openConnection(); 59 | 60 | connection.setConnectTimeout(5000); 61 | connection.setRequestProperty("Range", 62 | "bytes=" + downloaded + "-"); 63 | connection.connect(); 64 | 65 | if (connection.getResponseCode() / 100 != 2) { 66 | throw new Exception(); 67 | } 68 | 69 | int contentLength = connection.getContentLength(); 70 | if (contentLength < 1) { 71 | throw new Exception(); 72 | } 73 | 74 | if (size == -1) { 75 | size = contentLength; 76 | } 77 | 78 | file = new RandomAccessFile(filePath, "rw"); 79 | file.seek(downloaded); 80 | 81 | stream = connection.getInputStream(); 82 | while (true) { 83 | byte buffer[] = new byte[MAX_BUFFER_SIZE]; 84 | 85 | int read = stream.read(buffer); 86 | if (read == -1) 87 | break; 88 | 89 | file.write(buffer, 0, read); 90 | downloaded += read; 91 | } 92 | if(listener != null) 93 | listener.actionPerformed(null); 94 | } 95 | } -------------------------------------------------------------------------------- /1.6.4/org/jackhuang/myui/util/HttpDownloader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.util; 9 | 10 | public class HttpDownloader implements Runnable { 11 | private static final int MAX_BUFFER_SIZE = 2048; 12 | public static final String STATUSES[] = {"Downloading", 13 | "Paused", "Complete", "Cancelled", "Error"}; 14 | public static final int DOWNLOADING = 0; 15 | public static final int PAUSED = 1; 16 | public static final int COMPLETE = 2; 17 | public static final int CANCELLED = 3; 18 | public static final int ERROR = 4; 19 | 20 | private URL url; 21 | private int size; 22 | private int downloaded; 23 | private ActionListener listener; 24 | private String filePath; 25 | public HttpDownloader(URL url, String filePath, ActionListener l) { 26 | this.url = url; 27 | size = -1; 28 | downloaded = 0; 29 | this.filePath = filePath; 30 | this.listener = l; 31 | } 32 | public String getUrl() { 33 | return url.toString(); 34 | } 35 | public long getSize() { 36 | return size; 37 | } 38 | public float getProgress() { 39 | return ((float) downloaded / size) * 100; 40 | } 41 | private String getFileName(URL url) { 42 | String fileName = url.getFile(); 43 | return fileName.substring(fileName.lastIndexOf('/') + 1); 44 | } 45 | 46 | @Override 47 | public void run() { 48 | RandomAccessFile file = null; 49 | InputStream stream = null; 50 | 51 | HttpURLConnection connection = 52 | (HttpURLConnection) url.openConnection(); 53 | 54 | connection.setConnectTimeout(5000); 55 | connection.setRequestProperty("Range", 56 | "bytes=" + downloaded + "-"); 57 | connection.connect(); 58 | if (connection.getResponseCode() / 100 != 2) { 59 | throw new Exception(); 60 | } 61 | int contentLength = connection.getContentLength(); 62 | if (contentLength < 1) { 63 | throw new Exception(); 64 | } 65 | if (size == -1) { 66 | size = contentLength; 67 | } 68 | file = new RandomAccessFile(filePath, "rw"); 69 | file.seek(downloaded); 70 | 71 | stream = connection.getInputStream(); 72 | while (true) { 73 | byte buffer[] = new byte[MAX_BUFFER_SIZE]; 74 | int read = stream.read(buffer); 75 | if (read == -1) 76 | break; 77 | file.write(buffer, 0, read); 78 | downloaded += read; 79 | } 80 | if(listener != null) 81 | listener.actionPerformed(null); 82 | } 83 | } -------------------------------------------------------------------------------- /1.6.4/org/jackhuang/myui/util/LoadServerThread.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.util; 9 | 10 | public class LoadServerThread extends Thread { 11 | 12 | String url; 13 | 14 | public long online = -1, maxplayer = -1, offset; 15 | public String populationInfo = ""; 16 | 17 | public LoadServerThread(String url) { 18 | this.url = url; 19 | } 20 | 21 | @Override 22 | public void run() { 23 | String ip; int port; 24 | String[] split = url.split(":"); 25 | ip = split[0]; 26 | if (split.length >= 2) { 27 | port = MD5Util.tryParseInt(split[1], 25565); 28 | } else { 29 | port = 25565; 30 | } 31 | Socket socket = null; 32 | DataInputStream datainputstream = null; 33 | DataOutputStream dataoutputstream = null; 34 | long begin = MinecraftServer.getSystemTimeMillis(); 35 | socket = new Socket(); 36 | socket.setSoTimeout(3000); 37 | socket.setTcpNoDelay(true); 38 | socket.setTrafficClass(18); 39 | socket.connect(new InetSocketAddress(ip, port), 3000); 40 | datainputstream = new DataInputStream(socket.getInputStream()); 41 | dataoutputstream = new DataOutputStream(socket.getOutputStream()); 42 | Packet254ServerPing packet254serverping = new Packet254ServerPing(78, ip, port); 43 | dataoutputstream.writeByte(packet254serverping.getPacketId()); 44 | packet254serverping.writePacketData(dataoutputstream); 45 | long end = MinecraftServer.getSystemTimeMillis(); 46 | offset = (end - begin); 47 | if (datainputstream.read() != 255) 48 | { 49 | throw new IOException("Bad message"); 50 | } 51 | String s = Packet.readString(datainputstream, 256); 52 | char[] achar = s.toCharArray(); 53 | for (int i = 0; i < achar.length; ++i) 54 | { 55 | if (achar[i] != 167 && achar[i] != 0 && ChatAllowedCharacters.allowedCharacters.indexOf(achar[i]) < 0) 56 | { 57 | achar[i] = 63; 58 | } 59 | } 60 | s = new String(achar); 61 | String[] astring; 62 | if (s.startsWith("\u00a7") && s.length() > 1) 63 | { 64 | astring = s.substring(1).split("\u0000"); 65 | if (MathHelper.parseIntWithDefault(astring[0], 0) == 1) 66 | { 67 | online = MathHelper.parseIntWithDefault(astring[4], 0); 68 | maxplayer = MathHelper.parseIntWithDefault(astring[5], 0); 69 | if (online >= 0 && maxplayer >= 0) 70 | { 71 | populationInfo = EnumChatFormatting.GRAY + "" + online + "" + EnumChatFormatting.DARK_GRAY + "/" + EnumChatFormatting.GRAY + maxplayer; 72 | } 73 | else 74 | { 75 | populationInfo = "" + EnumChatFormatting.DARK_GRAY + "???"; 76 | } 77 | } 78 | else 79 | { 80 | populationInfo = EnumChatFormatting.DARK_GRAY + "???"; 81 | } 82 | } 83 | else 84 | { 85 | astring = s.split("\u00a7"); 86 | s = astring[0]; 87 | online = -1; 88 | maxplayer = -1; 89 | online = Integer.parseInt(astring[1]); 90 | maxplayer = Integer.parseInt(astring[2]); 91 | if (online >= 0 && maxplayer > 0) 92 | { 93 | populationInfo = EnumChatFormatting.GRAY + "" + online + "" + EnumChatFormatting.DARK_GRAY + "/" + EnumChatFormatting.GRAY + maxplayer; 94 | } 95 | else 96 | { 97 | populationInfo = "" + EnumChatFormatting.DARK_GRAY + "???"; 98 | } 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /1.7.10/org/jackhuang/myui/client/MyUIModGuiFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.client; 9 | 10 | import java.util.List; 11 | import java.util.Set; 12 | 13 | import net.minecraft.client.Minecraft; 14 | import net.minecraft.client.gui.Gui; 15 | import net.minecraft.client.gui.GuiButton; 16 | import net.minecraft.client.gui.GuiScreen; 17 | import net.minecraft.client.gui.GuiTextField; 18 | import net.minecraft.client.resources.I18n; 19 | 20 | import com.google.common.base.Strings; 21 | import com.google.common.collect.ImmutableList; 22 | import com.google.common.collect.ImmutableSet; 23 | 24 | import cpw.mods.fml.client.FMLClientHandler; 25 | import cpw.mods.fml.client.IModGuiFactory; 26 | import cpw.mods.fml.client.IModGuiFactory.RuntimeOptionCategoryElement; 27 | import cpw.mods.fml.client.IModGuiFactory.RuntimeOptionGuiHandler; 28 | 29 | public class MyUIModGuiFactory implements IModGuiFactory { 30 | 31 | private Minecraft minecraft; 32 | 33 | private static final Set categories = ImmutableSet.of(new IModGuiFactory.RuntimeOptionCategoryElement("COPYRIGHT", "MYUI")); 34 | 35 | @Override 36 | public void initialize(Minecraft minecraftInstance) { 37 | minecraft = minecraftInstance; 38 | } 39 | 40 | @Override 41 | public Class mainConfigGuiClass() { 42 | return MyConfigGuiScreen.class; 43 | } 44 | 45 | @Override 46 | public Set runtimeGuiCategories() { 47 | return categories; 48 | } 49 | 50 | @Override 51 | public RuntimeOptionGuiHandler getHandlerFor( 52 | RuntimeOptionCategoryElement element) { 53 | return null; 54 | } 55 | 56 | public static class MyConfigGuiScreen extends GuiScreen { 57 | private GuiScreen parent; 58 | private GuiTextField urlField; 59 | 60 | public MyConfigGuiScreen(GuiScreen parent) { 61 | this.parent = parent; 62 | } 63 | 64 | @Override 65 | public void initGui() { 66 | this.buttonList.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done"))); 67 | this.buttonList.add(new GuiButton(2, (this.width - 144)/2, this.height / 2 - 10,144,20, "版权声明")); 68 | 69 | this.urlField = new GuiTextField(fontRendererObj, (this.width - 144)/2, this.height / 2 - 20, 144, 20); 70 | } 71 | 72 | @Override 73 | protected void actionPerformed(GuiButton p_146284_1_) { 74 | if(!(p_146284_1_.enabled)) return; 75 | switch (p_146284_1_.id) { 76 | case 1: 77 | FMLClientHandler.instance().showGuiScreen(this.parent); 78 | break; 79 | case 2: 80 | FMLClientHandler.instance().showGuiScreen(new CopyrightScreen(this)); 81 | break; 82 | } 83 | } 84 | 85 | @Override 86 | protected void keyTyped(char par1, int par2) { 87 | // TODO Auto-generated method stub 88 | super.keyTyped(par1, par2); 89 | } 90 | 91 | @Override 92 | public void drawScreen(int par1, int par2, float par3) { 93 | drawDefaultBackground(); 94 | drawCenteredString(this.fontRendererObj, "MyUI MOD设置界面", this.width / 2, 40, 16777215); 95 | urlField.drawTextBox(); 96 | 97 | super.drawScreen(par1, par2, par3); 98 | } 99 | } 100 | 101 | public static class CopyrightScreen extends GuiScreen { 102 | private GuiScreen parent; 103 | 104 | public CopyrightScreen(GuiScreen parent) { 105 | this.parent = parent; 106 | } 107 | 108 | @Override 109 | public void initGui() { 110 | this.buttonList.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done"))); 111 | } 112 | 113 | @Override 114 | protected void actionPerformed(GuiButton p_146284_1_) { 115 | if ((p_146284_1_.enabled) && (p_146284_1_.id == 1)) { 116 | FMLClientHandler.instance().showGuiScreen(this.parent); 117 | } 118 | } 119 | 120 | @Override 121 | public void drawScreen(int par1, int par2, float par3) { 122 | drawDefaultBackground(); 123 | drawCenteredString(this.fontRendererObj, "MyUI Mod 服务协议", this.width / 2, 5, 16777215); 124 | 125 | List list = ImmutableList.of( 126 | "以下定制方为甲方,受托人为乙方。", 127 | "mcbbs: huanghongxun, baidu: huanghongxun20, qq: 1542806507", 128 | "1 甲方权利和义务", 129 | "1.1 甲方向乙方提供软件定制时所需的定制软件规划。", 130 | "1.2 根据项目需要提供有关资料、图片等,要求保证所有资料完整、真实。", 131 | "1.3 甲方在使用乙方提供的软件产品时,不得转为第三方使用,本次定制的最终产品是乙方专门为甲方定制,其知识产权属于乙方,甲方为永久使用权。", 132 | "1.4 如甲方需要乙方提供其他软件、技术支持、相关开发等,双方应另行签署其他协议;", 133 | "1.5 甲方同意按双方约定的付款方式和时间及时向乙方支付软件费用,以及在乙方进行软件开发工作时提供其他必要的帮助。", 134 | "1.6 甲方承诺,向乙方提供的内容、资料等不会侵犯任何第三方权利;若发生侵犯第三方权利的情形,由甲方承担全部责任。因甲方在使用本软件给第三方造成损害的,由甲方自行承担责任。", 135 | "1.7 甲方当事人应当保守在履行服务协议中获知的对方商业秘密。", 136 | "1.8 甲方对乙方提供服务过程中使用的技术、软件等所涉及的包括知识产权在内的一切法律问题不承担任何责任。", 137 | "2 乙方的权利和义务", 138 | "2.1 可以根据甲方的要求指导甲方使用定制软件;", 139 | "2.2 依合同收取费用;", 140 | "2.3 在开发过程中,对甲方陆续提出的修改要求,乙方应协助实现,(但如果超出合同要求工作量过大,则需要协商修改合同条款),并由甲方验收,对验收时不合格的地方进行修改;", 141 | "2.4 本合同项目完成后,甲方有对这些相关程序的永久使用权,包括二次开发。乙方完全拥有本程序代码的所有权。除乙方授权外,甲方不得向乙方源代码或源代码所生产的产品直接销售给第三方。", 142 | "2.5 乙方当事人应当保守在履行服务协议中获知的对方商业秘密。", 143 | "2.6 乙方在签订合同后,开始定制工作,在设计阶段和功能开发阶段要及时与甲方沟通,若甲乙双方在功能理解上存在分歧不能协商好,本着甲方对乙方专业水准的认可前提下,以乙方的理解为主。" 144 | ); 145 | 146 | 147 | for (int i = list.size()-1; i >= 0; i--) { 148 | String brd = list.get(i); 149 | if (!Strings.isNullOrEmpty(brd)) { 150 | this.drawString(this.fontRendererObj, brd, 2, 15 + i * (this.fontRendererObj.FONT_HEIGHT + 1), 151 | 16777215); 152 | } 153 | } 154 | 155 | 156 | super.drawScreen(par1, par2, par3); 157 | } 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /1.7.2/org/jackhuang/myui/client/MyUIModGuiFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.client; 9 | 10 | import java.util.List; 11 | import java.util.Set; 12 | 13 | import net.minecraft.client.Minecraft; 14 | import net.minecraft.client.gui.Gui; 15 | import net.minecraft.client.gui.GuiButton; 16 | import net.minecraft.client.gui.GuiScreen; 17 | import net.minecraft.client.gui.GuiTextField; 18 | import net.minecraft.client.resources.I18n; 19 | 20 | import com.google.common.base.Strings; 21 | import com.google.common.collect.ImmutableList; 22 | import com.google.common.collect.ImmutableSet; 23 | 24 | import cpw.mods.fml.client.FMLClientHandler; 25 | import cpw.mods.fml.client.IModGuiFactory; 26 | import cpw.mods.fml.client.IModGuiFactory.RuntimeOptionCategoryElement; 27 | import cpw.mods.fml.client.IModGuiFactory.RuntimeOptionGuiHandler; 28 | 29 | public class MyUIModGuiFactory implements IModGuiFactory { 30 | 31 | private Minecraft minecraft; 32 | 33 | private static final Set categories = ImmutableSet.of(new IModGuiFactory.RuntimeOptionCategoryElement("COPYRIGHT", "MYUI")); 34 | 35 | @Override 36 | public void initialize(Minecraft minecraftInstance) { 37 | minecraft = minecraftInstance; 38 | } 39 | 40 | @Override 41 | public Class mainConfigGuiClass() { 42 | return MyConfigGuiScreen.class; 43 | } 44 | 45 | @Override 46 | public Set runtimeGuiCategories() { 47 | return categories; 48 | } 49 | 50 | @Override 51 | public RuntimeOptionGuiHandler getHandlerFor( 52 | RuntimeOptionCategoryElement element) { 53 | return null; 54 | } 55 | 56 | public static class MyConfigGuiScreen extends GuiScreen { 57 | private GuiScreen parent; 58 | private GuiTextField urlField; 59 | 60 | public MyConfigGuiScreen(GuiScreen parent) { 61 | this.parent = parent; 62 | } 63 | 64 | @Override 65 | public void initGui() { 66 | this.buttonList.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done"))); 67 | this.buttonList.add(new GuiButton(2, (this.width - 144)/2, this.height / 2 - 10,144,20, "版权声明")); 68 | 69 | this.urlField = new GuiTextField(fontRendererObj, (this.width - 144)/2, this.height / 2 - 20, 144, 20); 70 | } 71 | 72 | @Override 73 | protected void actionPerformed(GuiButton p_146284_1_) { 74 | if(!(p_146284_1_.enabled)) return; 75 | switch (p_146284_1_.id) { 76 | case 1: 77 | FMLClientHandler.instance().showGuiScreen(this.parent); 78 | break; 79 | case 2: 80 | FMLClientHandler.instance().showGuiScreen(new CopyrightScreen(this)); 81 | break; 82 | } 83 | } 84 | 85 | @Override 86 | protected void keyTyped(char par1, int par2) { 87 | // TODO Auto-generated method stub 88 | super.keyTyped(par1, par2); 89 | } 90 | 91 | @Override 92 | public void drawScreen(int par1, int par2, float par3) { 93 | drawDefaultBackground(); 94 | drawCenteredString(this.fontRendererObj, "MyUI MOD设置界面", this.width / 2, 40, 16777215); 95 | urlField.drawTextBox(); 96 | 97 | super.drawScreen(par1, par2, par3); 98 | } 99 | } 100 | 101 | public static class CopyrightScreen extends GuiScreen { 102 | private GuiScreen parent; 103 | 104 | public CopyrightScreen(GuiScreen parent) { 105 | this.parent = parent; 106 | } 107 | 108 | @Override 109 | public void initGui() { 110 | this.buttonList.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done"))); 111 | } 112 | 113 | @Override 114 | protected void actionPerformed(GuiButton p_146284_1_) { 115 | if ((p_146284_1_.enabled) && (p_146284_1_.id == 1)) { 116 | FMLClientHandler.instance().showGuiScreen(this.parent); 117 | } 118 | } 119 | 120 | @Override 121 | public void drawScreen(int par1, int par2, float par3) { 122 | drawDefaultBackground(); 123 | drawCenteredString(this.fontRendererObj, "MyUI Mod 版权许可", this.width / 2, 40, 16777215); 124 | 125 | List list = ImmutableList.of( 126 | "以下购买人为甲方,受托人为乙方。", 127 | "mcbbs: huanghongxun, baidu: huanghongxun20, qq: 1542806507", 128 | "1 甲方权利和义务", 129 | "1.1 甲方向乙方提供软件定制时所需的定制软件规划。", 130 | "1.2 根据项目需要提供有关资料、图片等,要求保证所有资料完整、真实。", 131 | "1.3 甲方在使用乙方提供的软件产品时,不得转为第三方使用,本次定制的最终产品是乙方专门为甲方定制,其知识产权属于乙方,甲方为永久使用权。", 132 | "1.4 如甲方需要乙方提供其他软件、技术支持、相关开发等,双方应另行签署其他协议;", 133 | "1.5 甲方同意按双方约定的付款方式和时间及时向乙方支付软件费用,以及在乙方进行软件开发工作时提供其他必要的帮助。", 134 | "1.6 甲方承诺,向乙方提供的内容、资料等不会侵犯任何第三方权利;若发生侵犯第三方权利的情形,由甲方承担全部责任。因甲方在使用本软件给第三方造成损害的,由甲方自行承担责任。", 135 | "1.7 甲方当事人应当保守在履行服务协议中获知的对方商业秘密。", 136 | "1.8 甲方对乙方提供服务过程中使用的技术、软件等所涉及的包括知识产权在内的一切法律问题不承担任何责任。", 137 | "2 乙方的权利和义务", 138 | "2.1 可以根据甲方的要求指导甲方使用定制软件;", 139 | "2.2 依合同收取费用;", 140 | "2.3 在开发过程中,对甲方陆续提出的修改要求,乙方应协助实现,(但如果超出合同要求工作量过大,则需要协商修改合同条款),并由甲方验收,对验收时不合格的地方进行修改;", 141 | "2.4 本合同项目完成后,甲方有对这些相关程序的永久使用权,包括二次开发。乙方完全拥有本程序代码的所有权。除乙方授权外,甲方不得向乙方源代码或源代码所生产的产品直接销售给第三方。", 142 | "2.5 乙方当事人应当保守在履行服务协议中获知的对方商业秘密。", 143 | "2.6 乙方在签订合同后,开始定制工作,在设计阶段和功能开发阶段要及时与甲方沟通,若甲乙双方在功能理解上存在分歧不能协商好,本着甲方对乙方专业水准的认可前提下,以乙方的理解为主。" 144 | ); 145 | 146 | 147 | for (int i = list.size()-1; i >= 0; i--) { 148 | String brd = list.get(i); 149 | if (!Strings.isNullOrEmpty(brd)) { 150 | this.drawString(this.fontRendererObj, brd, 2, 60 + i * (this.fontRendererObj.FONT_HEIGHT + 1), 151 | 16777215); 152 | } 153 | } 154 | 155 | 156 | super.drawScreen(par1, par2, par3); 157 | } 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /1.7.2/org/jackhuang/myui/util/LoadServerThread.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.util; 9 | 10 | public class LoadServerThread { 11 | private static final Splitter field_147230_a = Splitter.on('\000').limit(6); 12 | 13 | private final List netmgrs = Collections 14 | .synchronizedList(new ArrayList()); 15 | 16 | public LoadServerThread(String url) { 17 | this.url = url; 18 | } 19 | 20 | public void func_147224_a(final String url) { 21 | try { 22 | isLoading = true; 23 | 24 | final ServerAddress address = ServerAddress.func_78860_a(url); 25 | final NetworkManager mgr = NetworkManager.provideLanClient( 26 | InetAddress.getByName(address.getIP()), address.getPort()); 27 | netmgrs.add(mgr); 28 | mgr.setNetHandler(new INetHandlerStatusClient() { 29 | 30 | private boolean connected = false; 31 | 32 | @Override 33 | public void onNetworkTick() { 34 | } 35 | 36 | @Override 37 | public void onDisconnect(IChatComponent arg0) { 38 | isLoading = false; 39 | 40 | if(!connected) { 41 | FMLLog.severe("Can't ping %s:%d", address.getIP(), address.getPort()); 42 | func_147225_b(url); 43 | } 44 | } 45 | 46 | @Override 47 | public void onConnectionStateTransition( 48 | EnumConnectionState arg0, EnumConnectionState arg1) { 49 | } 50 | 51 | @Override 52 | public void handleServerInfo(S00PacketServerInfo arg0) { 53 | connected = true; 54 | 55 | ServerStatusResponse response = arg0.func_149294_c(); 56 | if (response.func_151318_b() != null) { 57 | online = response.func_151318_b().func_151333_b(); 58 | maxplayer = response.func_151318_b().func_151332_a(); 59 | } 60 | 61 | mgr.scheduleOutboundPacket(new C01PacketPing(Minecraft 62 | .getSystemTime())); 63 | 64 | isLoading = false; 65 | } 66 | 67 | @Override 68 | public void handlePong(S01PacketPong arg0) { 69 | long i = arg0.func_149292_c(); 70 | long j = Minecraft.getSystemTime(); 71 | offset = j - i; 72 | mgr.closeChannel(new ChatComponentText("Finished")); 73 | } 74 | }); 75 | mgr.scheduleOutboundPacket(new C00Handshake(4, address.getIP(), 76 | address.getPort(), EnumConnectionState.STATUS)); 77 | mgr.scheduleOutboundPacket(new C00PacketServerQuery()); 78 | } catch (Throwable t) { 79 | isLoading = false; 80 | maxplayer = online = -1; 81 | t.printStackTrace(); 82 | } 83 | } 84 | 85 | private void func_147225_b(String p_147225_1_) { 86 | begin = Minecraft.getSystemTime(); 87 | 88 | final ServerAddress serveraddress = ServerAddress 89 | .func_78860_a(p_147225_1_); 90 | new Bootstrap() 91 | .group(NetworkManager.eventLoops) 92 | .handler(new ChannelInitializer() { 93 | private static final String __OBFID = "CL_00000894"; 94 | 95 | protected void initChannel(Channel p_initChannel_1_) { 96 | try { 97 | p_initChannel_1_.config().setOption( 98 | ChannelOption.IP_TOS, Integer.valueOf(24)); 99 | } catch (ChannelException channelexception1) { 100 | } 101 | 102 | try { 103 | p_initChannel_1_.config().setOption( 104 | ChannelOption.TCP_NODELAY, 105 | Boolean.valueOf(false)); 106 | } catch (ChannelException channelexception) { 107 | } 108 | 109 | p_initChannel_1_ 110 | .pipeline() 111 | .addLast( 112 | new ChannelHandler[] { new SimpleChannelInboundHandler() { 113 | private static final String __OBFID = "CL_00000895"; 114 | 115 | public void channelActive( 116 | ChannelHandlerContext p_channelActive_1_) 117 | throws Exception { 118 | super.channelActive(p_channelActive_1_); 119 | ByteBuf bytebuf = Unpooled 120 | .buffer(); 121 | bytebuf.writeByte(254); 122 | bytebuf.writeByte(1); 123 | bytebuf.writeByte(250); 124 | char[] achar = "MC|PingHost" 125 | .toCharArray(); 126 | bytebuf.writeShort(achar.length); 127 | char[] achar1 = achar; 128 | int i = achar.length; 129 | 130 | for (int j = 0; j < i; j++) { 131 | char c0 = achar1[j]; 132 | bytebuf.writeChar(c0); 133 | } 134 | 135 | bytebuf.writeShort(7 + 2 * serveraddress 136 | .getIP().length()); 137 | bytebuf.writeByte(127); 138 | achar = serveraddress.getIP() 139 | .toCharArray(); 140 | bytebuf.writeShort(achar.length); 141 | achar1 = achar; 142 | i = achar.length; 143 | 144 | for (int j = 0; j < i; j++) { 145 | char c0 = achar1[j]; 146 | bytebuf.writeChar(c0); 147 | } 148 | 149 | bytebuf.writeInt(serveraddress 150 | .getPort()); 151 | p_channelActive_1_ 152 | .channel() 153 | .writeAndFlush(bytebuf) 154 | .addListener( 155 | ChannelFutureListener.CLOSE_ON_FAILURE); 156 | } 157 | 158 | protected void channelRead0( 159 | ChannelHandlerContext p_147219_1_, 160 | ByteBuf p_147219_2_) { 161 | short short1 = p_147219_2_ 162 | .readUnsignedByte(); 163 | 164 | if (short1 == 255) { 165 | String s = new String( 166 | p_147219_2_ 167 | .readBytes( 168 | p_147219_2_ 169 | .readShort() * 2) 170 | .array(), 171 | Charsets.UTF_16BE); 172 | String[] astring = (String[]) (String[]) Iterables 173 | .toArray( 174 | field_147230_a 175 | .split(s), 176 | String.class); 177 | 178 | if ("§1".equals(astring[0])) { 179 | int i = MathHelper 180 | .parseIntWithDefault( 181 | astring[1], 182 | 0); 183 | String s1 = astring[2]; 184 | String s2 = astring[3]; 185 | online = MathHelper 186 | .parseIntWithDefault( 187 | astring[4], 188 | -1); 189 | maxplayer = MathHelper 190 | .parseIntWithDefault( 191 | astring[5], 192 | -1); 193 | } 194 | } 195 | 196 | p_147219_1_.close(); 197 | end = Minecraft.getSystemTime(); 198 | offset = end - begin; 199 | } 200 | 201 | public void exceptionCaught( 202 | ChannelHandlerContext p_exceptionCaught_1_, 203 | Throwable p_exceptionCaught_2_) { 204 | p_exceptionCaught_1_.close(); 205 | } 206 | 207 | protected void channelRead0( 208 | ChannelHandlerContext p_channelRead0_1_, 209 | Object p_channelRead0_2_) { 210 | channelRead0( 211 | p_channelRead0_1_, 212 | (ByteBuf) p_channelRead0_2_); 213 | } 214 | 215 | } }); 216 | } 217 | 218 | }).channel(NioSocketChannel.class) 219 | .connect(serveraddress.getIP(), serveraddress.getPort()); 220 | } 221 | 222 | public void processReceivedMessages() { 223 | synchronized (netmgrs) { 224 | for (Iterator iterator = netmgrs.iterator(); iterator 225 | .hasNext();) { 226 | NetworkManager mgr = iterator.next(); 227 | if (mgr.isChannelOpen()) { 228 | mgr.processReceivedPackets(); 229 | } else { 230 | iterator.remove(); 231 | if (mgr.getExitMessage() != null) 232 | mgr.getNetHandler().onDisconnect(mgr.getExitMessage()); 233 | } 234 | } 235 | } 236 | } 237 | 238 | public void cancel() { 239 | synchronized (netmgrs) { 240 | for (Iterator iterator = netmgrs.iterator(); iterator 241 | .hasNext();) { 242 | NetworkManager mgr = iterator.next(); 243 | if (mgr.isChannelOpen()) { 244 | iterator.remove(); 245 | mgr.closeChannel(new ChatComponentText("Cancelled")); 246 | } 247 | } 248 | isLoading = false; 249 | } 250 | } 251 | } -------------------------------------------------------------------------------- /1.7.10/org/jackhuang/myui/util/LoadServerThread.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.util; 9 | 10 | public class LoadServerThread { 11 | private static final Splitter field_147230_a = Splitter.on('\000').limit(6); 12 | 13 | private final List netmgrs = Collections 14 | .synchronizedList(new ArrayList()); 15 | 16 | String url; 17 | 18 | public long online = -1, maxplayer = -1, offset; 19 | private long begin, end; 20 | public boolean isLoading = false; 21 | 22 | public LoadServerThread(String url) { 23 | this.url = url; 24 | } 25 | 26 | public void func_147224_a(final String url) { 27 | try { 28 | isLoading = true; 29 | 30 | final ServerAddress address = ServerAddress.func_78860_a(url); 31 | final NetworkManager mgr = NetworkManager.provideLanClient( 32 | InetAddress.getByName(address.getIP()), address.getPort()); 33 | netmgrs.add(mgr); 34 | mgr.setNetHandler(new INetHandlerStatusClient() { 35 | 36 | private boolean connected = false; 37 | 38 | @Override 39 | public void onNetworkTick() { 40 | } 41 | 42 | @Override 43 | public void onDisconnect(IChatComponent arg0) { 44 | isLoading = false; 45 | 46 | if(!connected) { 47 | FMLLog.severe("Can't ping %s:%d", address.getIP(), address.getPort()); 48 | func_147225_b(url); 49 | } 50 | } 51 | 52 | @Override 53 | public void onConnectionStateTransition( 54 | EnumConnectionState arg0, EnumConnectionState arg1) { 55 | } 56 | 57 | @Override 58 | public void handleServerInfo(S00PacketServerInfo arg0) { 59 | connected = true; 60 | 61 | ServerStatusResponse response = arg0.func_149294_c(); 62 | if (response.func_151318_b() != null) { 63 | online = response.func_151318_b().func_151333_b(); 64 | maxplayer = response.func_151318_b().func_151332_a(); 65 | } 66 | 67 | mgr.scheduleOutboundPacket(new C01PacketPing(Minecraft 68 | .getSystemTime())); 69 | 70 | isLoading = false; 71 | } 72 | 73 | @Override 74 | public void handlePong(S01PacketPong arg0) { 75 | long i = arg0.func_149292_c(); 76 | long j = Minecraft.getSystemTime(); 77 | offset = j - i; 78 | mgr.closeChannel(new ChatComponentText("Finished")); 79 | } 80 | }); 81 | mgr.scheduleOutboundPacket(new C00Handshake(4, address.getIP(), 82 | address.getPort(), EnumConnectionState.STATUS)); 83 | mgr.scheduleOutboundPacket(new C00PacketServerQuery()); 84 | } catch (Throwable t) { 85 | isLoading = false; 86 | maxplayer = online = -1; 87 | t.printStackTrace(); 88 | } 89 | } 90 | 91 | private void func_147225_b(String p_147225_1_) { 92 | begin = Minecraft.getSystemTime(); 93 | 94 | final ServerAddress serveraddress = ServerAddress 95 | .func_78860_a(p_147225_1_); 96 | new Bootstrap() 97 | .group(NetworkManager.eventLoops) 98 | .handler(new ChannelInitializer() { 99 | private static final String __OBFID = "CL_00000894"; 100 | 101 | protected void initChannel(Channel p_initChannel_1_) { 102 | try { 103 | p_initChannel_1_.config().setOption( 104 | ChannelOption.IP_TOS, Integer.valueOf(24)); 105 | } catch (ChannelException channelexception1) { 106 | } 107 | 108 | try { 109 | p_initChannel_1_.config().setOption( 110 | ChannelOption.TCP_NODELAY, 111 | Boolean.valueOf(false)); 112 | } catch (ChannelException channelexception) { 113 | } 114 | 115 | p_initChannel_1_ 116 | .pipeline() 117 | .addLast( 118 | new ChannelHandler[] { new SimpleChannelInboundHandler() { 119 | private static final String __OBFID = "CL_00000895"; 120 | 121 | public void channelActive( 122 | ChannelHandlerContext p_channelActive_1_) 123 | throws Exception { 124 | super.channelActive(p_channelActive_1_); 125 | ByteBuf bytebuf = Unpooled 126 | .buffer(); 127 | bytebuf.writeByte(254); 128 | bytebuf.writeByte(1); 129 | bytebuf.writeByte(250); 130 | char[] achar = "MC|PingHost" 131 | .toCharArray(); 132 | bytebuf.writeShort(achar.length); 133 | char[] achar1 = achar; 134 | int i = achar.length; 135 | 136 | for (int j = 0; j < i; j++) { 137 | char c0 = achar1[j]; 138 | bytebuf.writeChar(c0); 139 | } 140 | 141 | bytebuf.writeShort(7 + 2 * serveraddress 142 | .getIP().length()); 143 | bytebuf.writeByte(127); 144 | achar = serveraddress.getIP() 145 | .toCharArray(); 146 | bytebuf.writeShort(achar.length); 147 | achar1 = achar; 148 | i = achar.length; 149 | 150 | for (int j = 0; j < i; j++) { 151 | char c0 = achar1[j]; 152 | bytebuf.writeChar(c0); 153 | } 154 | 155 | bytebuf.writeInt(serveraddress 156 | .getPort()); 157 | p_channelActive_1_ 158 | .channel() 159 | .writeAndFlush(bytebuf) 160 | .addListener( 161 | ChannelFutureListener.CLOSE_ON_FAILURE); 162 | } 163 | 164 | protected void channelRead0( 165 | ChannelHandlerContext p_147219_1_, 166 | ByteBuf p_147219_2_) { 167 | short short1 = p_147219_2_ 168 | .readUnsignedByte(); 169 | 170 | if (short1 == 255) { 171 | String s = new String( 172 | p_147219_2_ 173 | .readBytes( 174 | p_147219_2_ 175 | .readShort() * 2) 176 | .array(), 177 | Charsets.UTF_16BE); 178 | String[] astring = (String[]) (String[]) Iterables 179 | .toArray( 180 | field_147230_a 181 | .split(s), 182 | String.class); 183 | 184 | if ("§1".equals(astring[0])) { 185 | int i = MathHelper 186 | .parseIntWithDefault( 187 | astring[1], 188 | 0); 189 | String s1 = astring[2]; 190 | String s2 = astring[3]; 191 | online = MathHelper 192 | .parseIntWithDefault( 193 | astring[4], 194 | -1); 195 | maxplayer = MathHelper 196 | .parseIntWithDefault( 197 | astring[5], 198 | -1); 199 | } 200 | } 201 | 202 | p_147219_1_.close(); 203 | end = Minecraft.getSystemTime(); 204 | offset = end - begin; 205 | } 206 | 207 | public void exceptionCaught( 208 | ChannelHandlerContext p_exceptionCaught_1_, 209 | Throwable p_exceptionCaught_2_) { 210 | p_exceptionCaught_1_.close(); 211 | } 212 | 213 | protected void channelRead0( 214 | ChannelHandlerContext p_channelRead0_1_, 215 | Object p_channelRead0_2_) { 216 | channelRead0( 217 | p_channelRead0_1_, 218 | (ByteBuf) p_channelRead0_2_); 219 | } 220 | 221 | } }); 222 | } 223 | 224 | }).channel(NioSocketChannel.class) 225 | .connect(serveraddress.getIP(), serveraddress.getPort()); 226 | } 227 | 228 | public void processReceivedMessages() { 229 | synchronized (netmgrs) { 230 | for (Iterator iterator = netmgrs.iterator(); iterator 231 | .hasNext();) { 232 | NetworkManager mgr = iterator.next(); 233 | if (mgr.isChannelOpen()) { 234 | mgr.processReceivedPackets(); 235 | } else { 236 | iterator.remove(); 237 | if (mgr.getExitMessage() != null) 238 | mgr.getNetHandler().onDisconnect(mgr.getExitMessage()); 239 | } 240 | } 241 | } 242 | } 243 | 244 | public void cancel() { 245 | synchronized (netmgrs) { 246 | for (Iterator iterator = netmgrs.iterator(); iterator 247 | .hasNext();) { 248 | NetworkManager mgr = iterator.next(); 249 | if (mgr.isChannelOpen()) { 250 | iterator.remove(); 251 | mgr.closeChannel(new ChatComponentText("Cancelled")); 252 | } 253 | } 254 | isLoading = false; 255 | } 256 | } 257 | } -------------------------------------------------------------------------------- /1.6.4/org/jackhuang/myui/NewMenu.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui; 9 | 10 | public class NewMenu extends GuiScreen { 11 | private static final Random rand = new Random(); 12 | private float updateCounter; 13 | private GuiButton buttonResetDemo; 14 | private int panoramaTimer; 15 | private DynamicTexture viewportTexture; 16 | private boolean field_96141_q = true; 17 | private static boolean field_96140_r; 18 | private static boolean field_96139_s; 19 | private final Object field_104025_t = new Object(); 20 | private String field_92025_p; 21 | private String field_104024_v; 22 | private static final ResourceLocation splashTexts = new ResourceLocation( 23 | "texts/splashes.txt"); 24 | private static final ResourceLocation minecraftTitleTextures = new ResourceLocation( 25 | "textures/gui/title/minecraft.png"); 26 | private static final ResourceLocation[] titlePanoramaPaths = new ResourceLocation[] { 27 | new ResourceLocation("textures/gui/title/background/panorama_0.png"), 28 | new ResourceLocation("textures/gui/title/background/panorama_1.png"), 29 | new ResourceLocation("textures/gui/title/background/panorama_2.png"), 30 | new ResourceLocation("textures/gui/title/background/panorama_3.png"), 31 | new ResourceLocation("textures/gui/title/background/panorama_4.png"), 32 | new ResourceLocation("textures/gui/title/background/panorama_5.png") }; 33 | private String field_96138_a; 34 | private int field_92024_r; 35 | private int field_92023_s; 36 | private int field_92022_t; 37 | private int field_92021_u; 38 | private int field_92020_v; 39 | private int field_92019_w; 40 | private ResourceLocation field_110351_G; 41 | private GuiButton minecraftRealmsButton; 42 | private GuiButton fmlModButton = null; 43 | public NewMenu() { 44 | BufferedReader bufferedreader = null; 45 | String s; 46 | try { 47 | ArrayList arraylist = new ArrayList(); 48 | bufferedreader = new BufferedReader(new InputStreamReader(Minecraft 49 | .getMinecraft().getResourceManager() 50 | .getResource(splashTexts).getInputStream(), Charsets.UTF_8)); 51 | 52 | while ((s = bufferedreader.readLine()) != null) { 53 | s = s.trim(); 54 | 55 | if (!s.isEmpty()) { 56 | arraylist.add(s); 57 | } 58 | } 59 | } catch (IOException ioexception) { 60 | ; 61 | } finally { 62 | if (bufferedreader != null) { 63 | try { 64 | bufferedreader.close(); 65 | } catch (IOException ioexception1) { 66 | ; 67 | } 68 | } 69 | } 70 | 71 | this.updateCounter = rand.nextFloat(); 72 | this.field_92025_p = ""; 73 | String s1 = System.getProperty("os_architecture"); 74 | s = System.getProperty("java_version"); 75 | } 76 | public void updateScreen() { 77 | ++this.panoramaTimer; 78 | } 79 | public boolean doesGuiPauseGame() { 80 | return false; 81 | } 82 | protected void keyTyped(char par1, int par2) { 83 | } 84 | public void initGui() { 85 | this.viewportTexture = new DynamicTexture(256, 256); 86 | this.field_110351_G = this.mc.getTextureManager() 87 | .getDynamicTextureLocation("background", this.viewportTexture); 88 | Calendar calendar = Calendar.getInstance(); 89 | calendar.setTime(new Date()); 90 | boolean flag = true; 91 | int i = this.height / 4 + 48; 92 | this.addSingleplayerMultiplayerButtons(i, 24); 93 | 94 | this.addCustomizedButtons(i, 24); 95 | 96 | Object object = this.field_104025_t; 97 | 98 | synchronized (this.field_104025_t) { 99 | this.field_92023_s = this.fontRenderer 100 | .getStringWidth(this.field_92025_p); 101 | this.field_92024_r = this.fontRenderer 102 | .getStringWidth(field_96138_a); 103 | int j = this.width / 6 * 4; 104 | this.field_92022_t = (this.width - j) / 2; 105 | this.field_92021_u = i - 24; 106 | this.field_92020_v = this.field_92022_t + j; 107 | this.field_92019_w = this.field_92021_u + 24; 108 | } 109 | 110 | if (MyUI.instance.announcementContent != null) { 111 | String[] a = MyUI.instance.announcementContent.split("\n"); 112 | this.field_92025_p = a[0]; 113 | if (a.length > 1) 114 | this.field_96138_a = a[1]; 115 | } else { 116 | this.field_92025_p = "暂无公告"; 117 | } 118 | 119 | thread = new LoadServerThread(MyUI.instance.serverURL1); 120 | thread.start(); 121 | } 122 | 123 | private void addCustomizedButtons(int top, int split) { 124 | int block = this.width / 6; 125 | this.buttonList.add(new GuiButton(21, block * 2 + 2, top, 126 | block * 3 / 2 - 2, 20, "电信入口")); 127 | this.buttonList.add(new GuiButton(22, block * 7 / 2 + 2, top, 128 | block * 3 / 2 - 2, 20, "联通入口")); 129 | this.buttonList.add(new GuiButton(23, block * 2 + 2, top + split, 130 | block * 3 / 2 - 2, 20, "进入服务器官网")); 131 | this.buttonList.add(new GuiButton(25, block * 7 / 2 + 2, top + split, 132 | block * 3 / 2 - 2, 20, "进入Q群")); 133 | this.buttonList.add(new GuiButton(0, block * 3 + 2, top + 72 + 12, 134 | block - 2, 20, I18n.getString("menu.options"))); 135 | this.buttonList.add(new GuiButton(4, block * 4 + 2, top + 72 + 12, 136 | block - 2, 20, I18n.getString("menu.quit"))); 137 | this.buttonList.add(new GuiButtonLanguage(5, block * 2 + 2 - 24, 138 | top + 72 + 12)); 139 | 140 | } 141 | 142 | private void drawAnnouncement() { 143 | int i = this.height / 4 + 48; 144 | int block = this.width / 6; 145 | drawRect(0, 0, this.width, 25, 1428160512); 146 | 147 | String s2 = "", s3 = " 点击此处刷新"; 148 | 149 | if (thread != null && thread.online >= 0 && thread.maxplayer >= 0) { 150 | s2 += "在线人数/最大人数: " + thread.online + "/" + thread.maxplayer; 151 | s2 += " 延迟: " + thread.offset + "ms"; 152 | } else { 153 | s2 += "无法连接服务器"; 154 | s2 += "或服务器响应错误"; 155 | } 156 | drawCenteredString(fontRenderer, s2 + s3, this.width / 2, 15, 16777125); 157 | 158 | String s = "当前版本为" + EnumChatFormatting.YELLOW + MyUI.instance.version 159 | + EnumChatFormatting.RESET + ", 最新版本为" 160 | + EnumChatFormatting.GREEN + MyUI.instance.newestVersion 161 | + EnumChatFormatting.RESET + ", "; 162 | if (MD5Util.tryParseDouble(MyUI.instance.newestVersion, 1) > MyUI.instance.versionDouble) 163 | s += EnumChatFormatting.UNDERLINE + "点击此处" 164 | + EnumChatFormatting.RESET + "更新您的客户端"; 165 | else 166 | s += "您的客户端为最新, 无需更新"; 167 | drawCenteredString(fontRenderer, s, this.width / 2, 3, 14737632); 168 | 169 | drawRect(this.field_92022_t - 2, i, block * 2, i + 24 * 3 - 4, 1428160512); 170 | 171 | drawCenteredString(fontRenderer, MyUI.instance.announcementTitle, 172 | (block + 2) / 2 + block, i + 24 * 3, 16777125); 173 | 174 | BufferedImage image = GLUtil.loadImage("announcement_picture.png"); 175 | if (image != null) { 176 | GLUtil.loadTexture(image); 177 | GLUtil.drawTexture(this.field_92022_t - 2, i, block * 2, i + 24 * 3 - 4); 178 | } 179 | } 180 | private void addSingleplayerMultiplayerButtons(int par1, int par2) { 181 | int block = this.width / 6; 182 | 183 | this.buttonList.add(new GuiButton(1, block * 2 + 2, par1 + 72 + 12, 184 | block - 2, 20, I18n.getString("menu.singleplayer"))); 185 | fmlModButton = new GuiButton(6, block * 2 + 2, par1 + par2 * 2, 186 | block * 3 - 2, 20, "模组"); 187 | this.buttonList.add(fmlModButton); 188 | } 189 | public static void connectToServer(GuiScreen parent, String serverURL) { 190 | Minecraft.getMinecraft().displayGuiScreen( 191 | new GuiConnecting(parent, Minecraft.getMinecraft(), 192 | new ServerData("Server", serverURL))); 193 | } 194 | protected void actionPerformed(GuiButton par1GuiButton) { 195 | if (par1GuiButton.id == 0) { 196 | this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings)); 197 | } 198 | 199 | if (par1GuiButton.id == 5) { 200 | this.mc.displayGuiScreen(new GuiLanguage(this, 201 | this.mc.gameSettings, this.mc.getLanguageManager())); 202 | } 203 | 204 | if (par1GuiButton.id == 1) { 205 | this.mc.displayGuiScreen(new GuiSelectWorld(this)); 206 | } 207 | 208 | if (par1GuiButton.id == 2) { 209 | this.mc.displayGuiScreen(new GuiMultiplayer(this)); 210 | } 211 | 212 | if (par1GuiButton.id == 14 && this.minecraftRealmsButton.drawButton) { 213 | this.func_140005_i(); 214 | } 215 | 216 | if (par1GuiButton.id == 4) { 217 | this.mc.shutdown(); 218 | } 219 | 220 | if (par1GuiButton.id == 6) { 221 | this.mc.displayGuiScreen(new GuiModList(this)); 222 | } 223 | 224 | if (par1GuiButton.id == 11) { 225 | this.mc.launchIntegratedServer("Demo_World", "Demo_World", 226 | DemoWorldServer.demoWorldSettings); 227 | } 228 | 229 | if (par1GuiButton.id == 12) { 230 | ISaveFormat isaveformat = this.mc.getSaveLoader(); 231 | WorldInfo worldinfo = isaveformat.getWorldInfo("Demo_World"); 232 | 233 | if (worldinfo != null) { 234 | GuiYesNo guiyesno = GuiSelectWorld.getDeleteWorldScreen(this, 235 | worldinfo.getWorldName(), 12); 236 | this.mc.displayGuiScreen(guiyesno); 237 | } 238 | } 239 | String url = null; 240 | boolean b = false; 241 | if (par1GuiButton.id == 13) { 242 | url = this.field_104024_v; 243 | } else if (par1GuiButton.id == 23) { 244 | url = MyUI.instance.webiteURL; 245 | } else if (par1GuiButton.id == 24) { 246 | url = MyUI.instance.contactURL; 247 | } else if (par1GuiButton.id == 25) { 248 | url = MyUI.instance.qGroupURL; 249 | } 250 | if (url != null) { 251 | try { 252 | java.awt.Desktop.getDesktop().browse(new URI(url)); 253 | } catch (Throwable e) { 254 | } 255 | } 256 | if (url != null) 257 | this.mc.displayGuiScreen(null); 258 | 259 | if (par1GuiButton.id == 20) { 260 | connectToServer(this, MyUI.instance.serverURL1); 261 | } 262 | 263 | if (par1GuiButton.id == 21) { 264 | connectToServer(this, MyUI.instance.serverURL2); 265 | } 266 | 267 | if (par1GuiButton.id == 22) { 268 | connectToServer(this, MyUI.instance.serverURL3); 269 | } 270 | } 271 | 272 | private void func_140005_i() { 273 | McoClient mcoclient = new McoClient(this.mc.getSession()); 274 | 275 | try { 276 | if (mcoclient.func_140054_c().booleanValue()) { 277 | this.mc.displayGuiScreen(new GuiScreenClientOutdated(this)); 278 | } else { 279 | this.mc.displayGuiScreen(new GuiScreenOnlineServers(this)); 280 | } 281 | } catch (ExceptionMcoService exceptionmcoservice) { 282 | this.mc.getLogAgent().logSevere(exceptionmcoservice.toString()); 283 | } catch (IOException ioexception) { 284 | this.mc.getLogAgent().logSevere(ioexception.getLocalizedMessage()); 285 | } 286 | } 287 | 288 | public void confirmClicked(boolean par1, int par2) { 289 | if (par1 && par2 == 12) { 290 | ISaveFormat isaveformat = this.mc.getSaveLoader(); 291 | isaveformat.flushCache(); 292 | isaveformat.deleteWorldDirectory("Demo_World"); 293 | this.mc.displayGuiScreen(this); 294 | } 295 | } 296 | private void drawPanorama(int par1, int par2, float par3) { 297 | Tessellator tessellator = Tessellator.instance; 298 | GL11.glMatrixMode(GL11.GL_PROJECTION); 299 | GL11.glPushMatrix(); 300 | GL11.glLoadIdentity(); 301 | Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F); 302 | GL11.glMatrixMode(GL11.GL_MODELVIEW); 303 | GL11.glPushMatrix(); 304 | GL11.glLoadIdentity(); 305 | GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 306 | GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); 307 | GL11.glEnable(GL11.GL_BLEND); 308 | GL11.glDisable(GL11.GL_ALPHA_TEST); 309 | GL11.glDisable(GL11.GL_CULL_FACE); 310 | GL11.glDepthMask(false); 311 | GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); 312 | byte b0 = 8; 313 | 314 | for (int k = 0; k < b0 * b0; ++k) { 315 | GL11.glPushMatrix(); 316 | float f1 = ((float) (k % b0) / (float) b0 - 0.5F) / 64.0F; 317 | float f2 = ((float) (k / b0) / (float) b0 - 0.5F) / 64.0F; 318 | float f3 = 0.0F; 319 | GL11.glTranslatef(f1, f2, f3); 320 | GL11.glRotatef( 321 | MathHelper 322 | .sin(((float) this.panoramaTimer + par3) / 400.0F) * 25.0F + 20.0F, 323 | 1.0F, 0.0F, 0.0F); 324 | GL11.glRotatef(-((float) this.panoramaTimer + par3) * 0.1F, 0.0F, 325 | 1.0F, 0.0F); 326 | 327 | for (int l = 0; l < 6; ++l) { 328 | GL11.glPushMatrix(); 329 | 330 | if (l == 1) { 331 | GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); 332 | } 333 | 334 | if (l == 2) { 335 | GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); 336 | } 337 | 338 | if (l == 3) { 339 | GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); 340 | } 341 | 342 | if (l == 4) { 343 | GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); 344 | } 345 | 346 | if (l == 5) { 347 | GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); 348 | } 349 | 350 | this.mc.getTextureManager().bindTexture(titlePanoramaPaths[l]); 351 | tessellator.startDrawingQuads(); 352 | tessellator.setColorRGBA_I(16777215, 255 / (k + 1)); 353 | float f4 = 0.0F; 354 | tessellator.addVertexWithUV(-1.0D, -1.0D, 1.0D, 355 | (double) (0.0F + f4), (double) (0.0F + f4)); 356 | tessellator.addVertexWithUV(1.0D, -1.0D, 1.0D, 357 | (double) (1.0F - f4), (double) (0.0F + f4)); 358 | tessellator.addVertexWithUV(1.0D, 1.0D, 1.0D, 359 | (double) (1.0F - f4), (double) (1.0F - f4)); 360 | tessellator.addVertexWithUV(-1.0D, 1.0D, 1.0D, 361 | (double) (0.0F + f4), (double) (1.0F - f4)); 362 | tessellator.draw(); 363 | GL11.glPopMatrix(); 364 | } 365 | 366 | GL11.glPopMatrix(); 367 | GL11.glColorMask(true, true, true, false); 368 | } 369 | 370 | tessellator.setTranslation(0.0D, 0.0D, 0.0D); 371 | GL11.glColorMask(true, true, true, true); 372 | GL11.glMatrixMode(GL11.GL_PROJECTION); 373 | GL11.glPopMatrix(); 374 | GL11.glMatrixMode(GL11.GL_MODELVIEW); 375 | GL11.glPopMatrix(); 376 | GL11.glDepthMask(true); 377 | GL11.glEnable(GL11.GL_CULL_FACE); 378 | GL11.glEnable(GL11.GL_ALPHA_TEST); 379 | GL11.glEnable(GL11.GL_DEPTH_TEST); 380 | } 381 | private void rotateAndBlurSkybox(float par1) { 382 | this.mc.getTextureManager().bindTexture(this.field_110351_G); 383 | GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256); 384 | GL11.glEnable(GL11.GL_BLEND); 385 | GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); 386 | GL11.glColorMask(true, true, true, false); 387 | Tessellator tessellator = Tessellator.instance; 388 | tessellator.startDrawingQuads(); 389 | byte b0 = 3; 390 | 391 | for (int i = 0; i < b0; ++i) { 392 | tessellator 393 | .setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F / (float) (i + 1)); 394 | int j = this.width; 395 | int k = this.height; 396 | float f1 = (float) (i - b0 / 2) / 256.0F; 397 | tessellator.addVertexWithUV((double) j, (double) k, 398 | (double) this.zLevel, (double) (0.0F + f1), 0.0D); 399 | tessellator.addVertexWithUV((double) j, 0.0D, (double) this.zLevel, 400 | (double) (1.0F + f1), 0.0D); 401 | tessellator.addVertexWithUV(0.0D, 0.0D, (double) this.zLevel, 402 | (double) (1.0F + f1), 1.0D); 403 | tessellator.addVertexWithUV(0.0D, (double) k, (double) this.zLevel, 404 | (double) (0.0F + f1), 1.0D); 405 | } 406 | 407 | tessellator.draw(); 408 | GL11.glColorMask(true, true, true, true); 409 | } 410 | private void renderSkybox(int par1, int par2, float par3) { 411 | GL11.glViewport(0, 0, 256, 256); 412 | this.drawPanorama(par1, par2, par3); 413 | GL11.glDisable(GL11.GL_TEXTURE_2D); 414 | GL11.glEnable(GL11.GL_TEXTURE_2D); 415 | this.rotateAndBlurSkybox(par3); 416 | this.rotateAndBlurSkybox(par3); 417 | this.rotateAndBlurSkybox(par3); 418 | this.rotateAndBlurSkybox(par3); 419 | this.rotateAndBlurSkybox(par3); 420 | this.rotateAndBlurSkybox(par3); 421 | this.rotateAndBlurSkybox(par3); 422 | this.rotateAndBlurSkybox(par3); 423 | GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); 424 | Tessellator tessellator = Tessellator.instance; 425 | tessellator.startDrawingQuads(); 426 | float f1 = this.width > this.height ? 120.0F / (float) this.width 427 | : 120.0F / (float) this.height; 428 | float f2 = (float) this.height * f1 / 256.0F; 429 | float f3 = (float) this.width * f1 / 256.0F; 430 | GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, 431 | GL11.GL_LINEAR); 432 | GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, 433 | GL11.GL_LINEAR); 434 | tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F); 435 | int k = this.width; 436 | int l = this.height; 437 | tessellator.addVertexWithUV(0.0D, (double) l, (double) this.zLevel, 438 | (double) (0.5F - f2), (double) (0.5F + f3)); 439 | tessellator.addVertexWithUV((double) k, (double) l, 440 | (double) this.zLevel, (double) (0.5F - f2), 441 | (double) (0.5F - f3)); 442 | tessellator.addVertexWithUV((double) k, 0.0D, (double) this.zLevel, 443 | (double) (0.5F + f2), (double) (0.5F - f3)); 444 | tessellator.addVertexWithUV(0.0D, 0.0D, (double) this.zLevel, 445 | (double) (0.5F + f2), (double) (0.5F + f3)); 446 | tessellator.draw(); 447 | } 448 | public void drawScreen(int par1, int par2, float par3) { 449 | 450 | this.renderSkybox(par1, par2, par3); 451 | Tessellator tessellator = Tessellator.instance; 452 | short short1 = 274; 453 | int k = this.width / 2 - short1 / 2; 454 | byte b0 = 30; 455 | this.drawGradientRect(0, 0, this.width, this.height, -2130706433, 456 | 16777215); 457 | this.drawGradientRect(0, 0, this.width, this.height, 0, 458 | Integer.MIN_VALUE); 459 | this.mc.getTextureManager().bindTexture(minecraftTitleTextures); 460 | GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 461 | 462 | if ((double) this.updateCounter < 1.0E-4D) { 463 | this.drawTexturedModalRect(k + 0, b0 + 0, 0, 0, 99, 44); 464 | this.drawTexturedModalRect(k + 99, b0 + 0, 129, 0, 27, 44); 465 | this.drawTexturedModalRect(k + 99 + 26, b0 + 0, 126, 0, 3, 44); 466 | this.drawTexturedModalRect(k + 99 + 26 + 3, b0 + 0, 99, 0, 26, 44); 467 | this.drawTexturedModalRect(k + 155, b0 + 0, 0, 45, 155, 44); 468 | } else { 469 | this.drawTexturedModalRect(k + 0, b0 + 0, 0, 0, 155, 44); 470 | this.drawTexturedModalRect(k + 155, b0 + 0, 0, 45, 155, 44); 471 | } 472 | 473 | drawAnnouncement(); 474 | 475 | tessellator.setColorOpaque_I(16777215); 476 | 477 | String s = "Minecraft 1.6.2"; 478 | 479 | if (this.mc.isDemo()) { 480 | s = s + " Demo"; 481 | } 482 | 483 | List brandings = //Lists.reverse(FMLCommonHandler.instance().getBrandings()); 484 | ImmutableList.of("MCP, Minecraft Forge, FML, Optifine", s); 485 | for (int i = 0; i < brandings.size(); i++) { 486 | String brd = brandings.get(i); 487 | if (!Strings.isNullOrEmpty(brd)) { 488 | this.drawString(this.fontRenderer, brd, 2, this.height 489 | - (10 + i * (this.fontRenderer.FONT_HEIGHT + 1)), 490 | 16777215); 491 | } 492 | } 493 | 494 | String s1 = "Copyright Mojang AB. Do not distribute!"; 495 | String s2 = "Copyright huangyuhui. All Rights Reserved. Click here for about."; 496 | this.drawString(this.fontRenderer, s1, 497 | this.width - this.fontRenderer.getStringWidth(s1) - 2, 498 | this.height - 10, 16777215); 499 | this.drawString(this.fontRenderer, s2, 500 | this.width - this.fontRenderer.getStringWidth(s2) - 2, 501 | this.height - 20, 16777215); 502 | 503 | if (StringUtils.isNotBlank(this.field_92025_p)) { 504 | drawRect(this.field_92022_t - 2, this.field_92021_u - 2, 505 | this.field_92020_v + 2, this.field_92019_w - 1, 1428160512); 506 | this.drawCenteredString(this.fontRenderer, this.field_92025_p, 507 | this.width / 2, this.field_92021_u, 16777215); 508 | this.drawCenteredString(this.fontRenderer, field_96138_a, 509 | this.width / 2, this.field_92021_u + 12, 16777215); 510 | } 511 | 512 | super.drawScreen(par1, par2, par3); 513 | } 514 | protected void mouseClicked(int par1, int par2, int par3) { 515 | super.mouseClicked(par1, par2, par3); 516 | 517 | if (15 <= par2 && par2 < 25) 518 | thread.run(); 519 | if (par2 < 15) { 520 | try { 521 | java.awt.Desktop.getDesktop().browse( 522 | new URI(MyUI.instance.updateURL)); 523 | } catch (Throwable t) { 524 | } 525 | } 526 | 527 | int block = width / 6; 528 | int i = this.height / 4 + 48; 529 | if ((block - 2) <= par1 && par1 <= (block * 2) && i <= par2 530 | && par2 <= (i + 24 * 3 - 4)) { 531 | try { 532 | java.awt.Desktop.getDesktop().browse( 533 | new URI(MyUI.instance.announcementPictureURL)); 534 | } catch (Throwable t) { 535 | } 536 | } 537 | 538 | if (par2 > this.height - 20 && par2 < this.height - 10 539 | && par1 > this.width - 50) { 540 | mc.displayGuiScreen(new CopyrightScreen(this)); 541 | } 542 | } 543 | } 544 | -------------------------------------------------------------------------------- /1.7.2/org/jackhuang/myui/client/NewMenu.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.client; 9 | 10 | public class NewMenu extends GuiScreen { 11 | private static final AtomicInteger field_146973_f = new AtomicInteger(0); 12 | private static final Logger logger = LogManager.getLogger(); 13 | private static final Random rand = new Random(); 14 | private float updateCounter; 15 | private String splashText; 16 | private GuiButton buttonResetDemo; 17 | private int panoramaTimer; 18 | private DynamicTexture viewportTexture; 19 | private boolean field_96141_q = true; 20 | private static boolean field_96140_r; 21 | private static boolean field_96139_s; 22 | private final Object field_104025_t = new Object(); 23 | private String outdate_first; 24 | private String outdate_second; 25 | private String outdate_link; 26 | private static final ResourceLocation splashTexts = new ResourceLocation( 27 | "texts/splashes.txt"); 28 | private static final ResourceLocation minecraftTitleTextures = new ResourceLocation( 29 | "textures/gui/title/minecraft.png"); 30 | private static final ResourceLocation[] titlePanoramaPaths = new ResourceLocation[] { 31 | new ResourceLocation("textures/gui/title/background/panorama_0.png"), 32 | new ResourceLocation("textures/gui/title/background/panorama_1.png"), 33 | new ResourceLocation("textures/gui/title/background/panorama_2.png"), 34 | new ResourceLocation("textures/gui/title/background/panorama_3.png"), 35 | new ResourceLocation("textures/gui/title/background/panorama_4.png"), 36 | new ResourceLocation("textures/gui/title/background/panorama_5.png") }; 37 | public static final String outdate_default = "Please click " 38 | + EnumChatFormatting.UNDERLINE + "here" + EnumChatFormatting.RESET 39 | + " for more information."; 40 | private int outdate_second_width; 41 | private int outdate_first_width; 42 | private int outdate_l; 43 | private int outdate_b; 44 | private int outdate_r; 45 | private int outdate_t; 46 | private String username=null; 47 | private String player=null; 48 | private ResourceLocation field_110351_G; 49 | private GuiButton minecraftRealmsButton; 50 | private static final String __OBFID = "CL_00001154"; 51 | 52 | private GuiButton fmlModButton = null; 53 | private GuiButton multiplayerButton=null; 54 | private static double version = 1.0; 55 | 56 | @SuppressWarnings({ "rawtypes", "unchecked" }) 57 | public NewMenu() { 58 | this.outdate_second = outdate_default; 59 | this.splashText = "missingno"; 60 | BufferedReader bufferedreader = null; 61 | 62 | try { 63 | ArrayList arraylist = new ArrayList(); 64 | bufferedreader = new BufferedReader(new InputStreamReader(Minecraft 65 | .getMinecraft().getResourceManager() 66 | .getResource(splashTexts).getInputStream(), Charsets.UTF_8)); 67 | String s; 68 | 69 | while ((s = bufferedreader.readLine()) != null) { 70 | s = s.trim(); 71 | 72 | if (!s.isEmpty()) { 73 | arraylist.add(s); 74 | } 75 | } 76 | 77 | if (!arraylist.isEmpty()) { 78 | do { 79 | this.splashText = (String) arraylist.get(rand 80 | .nextInt(arraylist.size())); 81 | } while (this.splashText.hashCode() == 125780783); 82 | } 83 | } catch (IOException ioexception1) { 84 | ; 85 | } finally { 86 | if (bufferedreader != null) { 87 | try { 88 | bufferedreader.close(); 89 | } catch (IOException ioexception) { 90 | ; 91 | } 92 | } 93 | } 94 | } 95 | 96 | public void updateScreen() { 97 | ++this.panoramaTimer; 98 | } 99 | 100 | public boolean doesGuiPauseGame() { 101 | return false; 102 | } 103 | 104 | @SuppressWarnings({ "unchecked" }) 105 | @Override 106 | public void initGui() { 107 | this.viewportTexture = new DynamicTexture(256, 256); 108 | this.field_110351_G = this.mc.getTextureManager() 109 | .getDynamicTextureLocation("background", this.viewportTexture); 110 | Calendar calendar = Calendar.getInstance(); 111 | calendar.setTime(new Date()); 112 | 113 | if (calendar.get(2) + 1 == 11 && calendar.get(5) == 9) { 114 | this.splashText = "Happy birthday, ez!"; 115 | } else if (calendar.get(2) + 1 == 6 && calendar.get(5) == 1) { 116 | this.splashText = "Happy birthday, Notch!"; 117 | } else if (calendar.get(2) + 1 == 12 && calendar.get(5) == 24) { 118 | this.splashText = "Merry X-mas!"; 119 | } else if (calendar.get(2) + 1 == 1 && calendar.get(5) == 1) { 120 | this.splashText = "Happy new year!"; 121 | } else if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31) { 122 | this.splashText = "OOoooOOOoooo! Spooky!"; 123 | } else if (calendar.get(2) + 1 == 5 && calendar.get(5) == 15) { 124 | this.splashText = "Happy Birthday, Brian!"; 125 | } 126 | 127 | boolean flag = true; 128 | int i = this.height / 4 + 48; 129 | int split = 24; 130 | 131 | if (this.mc.isDemo()) { 132 | } else { 133 | this.addSingleplayerMultiplayerButtons(i, split); 134 | } 135 | 136 | this.addCustomizedButtons(i, 24); 137 | 138 | loginframe_l = 114; 139 | loginframe_r = this.width / 4*3 - 2; 140 | 141 | Object object = this.field_104025_t; 142 | 143 | synchronized (this.field_104025_t) { 144 | this.outdate_first_width = this.fontRendererObj 145 | .getStringWidth(this.outdate_first); 146 | this.outdate_second_width = this.fontRendererObj 147 | .getStringWidth(this.outdate_second); 148 | int j = this.width / 6 * 4; 149 | this.outdate_l = (this.width - j) / 2; 150 | this.outdate_b = i - 24; 151 | this.outdate_r = this.outdate_l + j; 152 | this.outdate_t = this.outdate_b + 24; 153 | } 154 | 155 | if (MyUI.instance.announcementContent != null) { 156 | String[] a = MyUI.instance.announcementContent.split("\n"); 157 | this.outdate_first = a[0]; 158 | if (a.length > 1) 159 | this.outdate_second = a[1]; 160 | } else { 161 | this.outdate_first = "暂无公告"; 162 | } 163 | 164 | thread = new LoadServerThread(MyUI.instance.serverURL1); 165 | thread.func_147224_a(MyUI.instance.serverURL1); 166 | } 167 | 168 | private void addCustomizedButtons(int top, int split) { 169 | int block = this.width / 6; 170 | 171 | this.buttonList.add(new GuiButton(20, block * 2 + 2, top, block - 2, 172 | 20, "自动配对线路")); 173 | this.buttonList.add(new GuiButton(21, block * 3 + 2, top, block - 2, 174 | 20, "电信入口")); 175 | this.buttonList.add(new GuiButton(22, block * 4 + 2, top, block - 2, 176 | 20, "联通入口")); 177 | this.buttonList.add(new GuiButton(23, block * 2 + 2, top + split, 178 | block * 1 - 2, 20, "进入官网")); 179 | this.buttonList.add(new GuiButton(25, block * 3 + 2, top + split, 180 | block * 1 - 2, 20, "进入Q群")); 181 | this.buttonList.add(new GuiButton(24, block * 4 + 2, top + split, 182 | block * 1 - 2, 20, "联系服主")); 183 | 184 | this.buttonList.add(new GuiButton(0, block * 3 + 2, top + 72 + 12, 185 | block - 2, 20, I18n.format("menu.options"))); 186 | this.buttonList.add(new GuiButton(4, block * 4 + 2, top + 72 + 12, 187 | block - 2, 20, I18n.format("menu.quit"))); 188 | this.buttonList.add(new GuiButtonLanguage(5, block * 2 + 2 - 24, 189 | top + 72 + 12)); 190 | 191 | } 192 | 193 | private void drawAnnouncement() { 194 | if(thread != null && thread.isLoading) 195 | thread.processReceivedMessages(); 196 | 197 | int i = this.height / 4 + 48; 198 | int block = this.width / 6; 199 | 200 | drawRect(0, 0, this.width, 25, 1428160512); 201 | 202 | String s2 = "", s3 = "点击此处刷新"; 203 | 204 | if (thread != null && thread.online >= 0 && thread.maxplayer >= 0) { 205 | s2 += "在线人数/最大人数: " + thread.online + "/" + thread.maxplayer; 206 | s2 += " 延迟: " + thread.offset + "ms"; 207 | } else if(thread != null && thread.isLoading) { 208 | s2 += "加载中"; s3 = "点击此处取消"; 209 | } else { 210 | s2 += EnumChatFormatting.YELLOW + "无法连接服务器、服务器响应错误或请求被取消"; 211 | } 212 | drawCenteredString(fontRendererObj, s2 + " " + EnumChatFormatting.UNDERLINE + s3 + EnumChatFormatting.RESET, this.width / 2, 15, 14737632); 213 | 214 | String s = "当前版本为" + EnumChatFormatting.YELLOW + MyUI.instance.version 215 | + EnumChatFormatting.RESET + ", 最新版本为" 216 | + EnumChatFormatting.GREEN + MyUI.instance.newestVersion 217 | + EnumChatFormatting.RESET + ", "; 218 | if (MD5Util.tryParseDouble(MyUI.instance.newestVersion, 1) > MyUI.instance.versionDouble) 219 | s += EnumChatFormatting.UNDERLINE + "点击此处" 220 | + EnumChatFormatting.RESET + "更新您的客户端"; 221 | else 222 | s += "您的客户端为最新, 无需更新"; 223 | drawCenteredString(fontRendererObj, s, this.width / 2, 3, 14737632); 224 | 225 | drawRect(this.outdate_l - 2, i, block * 2, i + 24 * 3 - 4, 1428160512); 226 | 227 | drawCenteredString(fontRendererObj, MyUI.instance.announcementTitle, 228 | (block + 2) / 2 + block, i + 24 * 3, 14737632); 229 | 230 | BufferedImage image = GLUtil.loadImage("announcement_picture.png"); 231 | if (image != null) { 232 | GLUtil.loadTexture(image); 233 | GLUtil.drawTexture(this.outdate_l - 2, i, block * 2, i + 24 * 3 - 4); 234 | } 235 | } 236 | 237 | @SuppressWarnings("unchecked") 238 | private void addSingleplayerMultiplayerButtons(int par1, int par2) { 239 | int block = this.width / 6; 240 | 241 | this.buttonList.add(new GuiButton(1, block * 2 + 2, par1 + 72 + 12, 242 | block - 2, 20, I18n.format("menu.singleplayer"))); 243 | fmlModButton = new GuiButton(6, block * 2 + 2, par1 + par2 * 2, 244 | block * 3 - 2, 20, "模组"); 245 | this.buttonList.add(fmlModButton); 246 | } 247 | 248 | protected void actionPerformed(GuiButton p_146284_1_) { 249 | if (p_146284_1_.id == 0) { 250 | this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings)); 251 | } 252 | 253 | if (p_146284_1_.id == 5) { 254 | this.mc.displayGuiScreen(new GuiLanguage(this, 255 | this.mc.gameSettings, this.mc.getLanguageManager())); 256 | } 257 | 258 | if (p_146284_1_.id == 1) { 259 | this.mc.displayGuiScreen(new GuiSelectWorld(this)); 260 | } 261 | 262 | if (p_146284_1_.id == 4) { 263 | this.mc.shutdown(); 264 | } 265 | 266 | if (p_146284_1_.id == 6) { 267 | this.mc.displayGuiScreen(new GuiModList(this)); 268 | } 269 | 270 | if (p_146284_1_.id == 11) { 271 | this.mc.launchIntegratedServer("Demo_World", "Demo_World", 272 | DemoWorldServer.demoWorldSettings); 273 | } 274 | 275 | String url = null; 276 | boolean b = false; 277 | if (p_146284_1_.id == 13) { 278 | openLink(this.outdate_link, 97); 279 | } else if (p_146284_1_.id == 23) { 280 | openLink(MyUI.instance.webiteURL, 96); 281 | } else if (p_146284_1_.id == 24) { 282 | openLink(MyUI.instance.contactURL, 95); 283 | } else if (p_146284_1_.id == 25) { 284 | openLink(MyUI.instance.qGroupURL, 94); 285 | } 286 | 287 | if (p_146284_1_.id == 20) { 288 | FMLClientHandler.instance().setupServerList(); 289 | FMLClientHandler.instance().connectToServer(this, 290 | new ServerData("", MyUI.instance.serverURL1)); 291 | } 292 | 293 | if (p_146284_1_.id == 21) { 294 | FMLClientHandler.instance().setupServerList(); 295 | FMLClientHandler.instance().connectToServer(this, 296 | new ServerData("", MyUI.instance.serverURL2)); 297 | } 298 | 299 | if (p_146284_1_.id == 22) { 300 | FMLClientHandler.instance().setupServerList(); 301 | FMLClientHandler.instance().connectToServer(this, 302 | new ServerData("", MyUI.instance.serverURL3)); 303 | } 304 | } 305 | 306 | @SuppressWarnings({ "unchecked", "rawtypes" }) 307 | public void confirmClicked(boolean par1, int par2) { 308 | if (par1 && par2 == 12) { 309 | ISaveFormat isaveformat = this.mc.getSaveLoader(); 310 | isaveformat.flushCache(); 311 | isaveformat.deleteWorldDirectory("Demo_World"); 312 | this.mc.displayGuiScreen(this); 313 | } else if (par2 == 13) { 314 | if (par1) { 315 | try { 316 | Class oclass = Class.forName("java.awt.Desktop"); 317 | Object object = oclass 318 | .getMethod("getDesktop", new Class[0]).invoke( 319 | (Object) null, new Object[0]); 320 | oclass.getMethod("browse", new Class[] { URI.class }) 321 | .invoke(object, 322 | new Object[] { new URI(this.outdate_link) }); 323 | } catch (Throwable throwable) { 324 | logger.error("Couldn\'t open link", throwable); 325 | } 326 | } 327 | 328 | this.mc.displayGuiScreen(this); 329 | } else { 330 | if(par1) 331 | try { 332 | java.awt.Desktop.getDesktop().browse(new URI(myURL[par2])); 333 | } catch(Throwable t) { 334 | t.printStackTrace(); 335 | } 336 | mc.displayGuiScreen(null); 337 | } 338 | } 339 | 340 | private void drawPanorama(int par1, int par2, float par3) { 341 | Tessellator tessellator = Tessellator.instance; 342 | GL11.glMatrixMode(GL11.GL_PROJECTION); 343 | GL11.glPushMatrix(); 344 | GL11.glLoadIdentity(); 345 | Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F); 346 | GL11.glMatrixMode(GL11.GL_MODELVIEW); 347 | GL11.glPushMatrix(); 348 | GL11.glLoadIdentity(); 349 | GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 350 | GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); 351 | GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); 352 | GL11.glEnable(GL11.GL_BLEND); 353 | GL11.glDisable(GL11.GL_ALPHA_TEST); 354 | GL11.glDisable(GL11.GL_CULL_FACE); 355 | GL11.glDepthMask(false); 356 | OpenGlHelper.glBlendFunc(770, 771, 1, 0); 357 | byte b0 = 8; 358 | 359 | for (int k = 0; k < b0 * b0; ++k) { 360 | GL11.glPushMatrix(); 361 | float f1 = ((float) (k % b0) / (float) b0 - 0.5F) / 64.0F; 362 | float f2 = ((float) (k / b0) / (float) b0 - 0.5F) / 64.0F; 363 | float f3 = 0.0F; 364 | GL11.glTranslatef(f1, f2, f3); 365 | GL11.glRotatef( 366 | MathHelper 367 | .sin(((float) this.panoramaTimer + par3) / 400.0F) * 25.0F + 20.0F, 368 | 1.0F, 0.0F, 0.0F); 369 | GL11.glRotatef(-((float) this.panoramaTimer + par3) * 0.1F, 0.0F, 370 | 1.0F, 0.0F); 371 | 372 | for (int l = 0; l < 6; ++l) { 373 | GL11.glPushMatrix(); 374 | 375 | if (l == 1) { 376 | GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); 377 | } 378 | 379 | if (l == 2) { 380 | GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); 381 | } 382 | 383 | if (l == 3) { 384 | GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); 385 | } 386 | 387 | if (l == 4) { 388 | GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); 389 | } 390 | 391 | if (l == 5) { 392 | GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); 393 | } 394 | 395 | this.mc.getTextureManager().bindTexture(titlePanoramaPaths[l]); 396 | tessellator.startDrawingQuads(); 397 | tessellator.setColorRGBA_I(16777215, 255 / (k + 1)); 398 | float f4 = 0.0F; 399 | tessellator.addVertexWithUV(-1.0D, -1.0D, 1.0D, 400 | (double) (0.0F + f4), (double) (0.0F + f4)); 401 | tessellator.addVertexWithUV(1.0D, -1.0D, 1.0D, 402 | (double) (1.0F - f4), (double) (0.0F + f4)); 403 | tessellator.addVertexWithUV(1.0D, 1.0D, 1.0D, 404 | (double) (1.0F - f4), (double) (1.0F - f4)); 405 | tessellator.addVertexWithUV(-1.0D, 1.0D, 1.0D, 406 | (double) (0.0F + f4), (double) (1.0F - f4)); 407 | tessellator.draw(); 408 | GL11.glPopMatrix(); 409 | } 410 | 411 | GL11.glPopMatrix(); 412 | GL11.glColorMask(true, true, true, false); 413 | } 414 | 415 | tessellator.setTranslation(0.0D, 0.0D, 0.0D); 416 | GL11.glColorMask(true, true, true, true); 417 | GL11.glMatrixMode(GL11.GL_PROJECTION); 418 | GL11.glPopMatrix(); 419 | GL11.glMatrixMode(GL11.GL_MODELVIEW); 420 | GL11.glPopMatrix(); 421 | GL11.glDepthMask(true); 422 | GL11.glEnable(GL11.GL_CULL_FACE); 423 | GL11.glEnable(GL11.GL_DEPTH_TEST); 424 | } 425 | 426 | private void rotateAndBlurSkybox(float par1) { 427 | this.mc.getTextureManager().bindTexture(this.field_110351_G); 428 | GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, 429 | GL11.GL_LINEAR); 430 | GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, 431 | GL11.GL_LINEAR); 432 | GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256); 433 | GL11.glEnable(GL11.GL_BLEND); 434 | OpenGlHelper.glBlendFunc(770, 771, 1, 0); 435 | GL11.glColorMask(true, true, true, false); 436 | Tessellator tessellator = Tessellator.instance; 437 | tessellator.startDrawingQuads(); 438 | GL11.glDisable(GL11.GL_ALPHA_TEST); 439 | byte b0 = 3; 440 | 441 | for (int i = 0; i < b0; ++i) { 442 | tessellator 443 | .setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F / (float) (i + 1)); 444 | int j = this.width; 445 | int k = this.height; 446 | float f1 = (float) (i - b0 / 2) / 256.0F; 447 | tessellator.addVertexWithUV((double) j, (double) k, 448 | (double) this.zLevel, (double) (0.0F + f1), 1.0D); 449 | tessellator.addVertexWithUV((double) j, 0.0D, (double) this.zLevel, 450 | (double) (1.0F + f1), 1.0D); 451 | tessellator.addVertexWithUV(0.0D, 0.0D, (double) this.zLevel, 452 | (double) (1.0F + f1), 0.0D); 453 | tessellator.addVertexWithUV(0.0D, (double) k, (double) this.zLevel, 454 | (double) (0.0F + f1), 0.0D); 455 | } 456 | 457 | tessellator.draw(); 458 | GL11.glEnable(GL11.GL_ALPHA_TEST); 459 | GL11.glColorMask(true, true, true, true); 460 | } 461 | 462 | private void renderSkybox(int par1, int par2, float par3) { 463 | this.mc.getFramebuffer().unbindFramebuffer(); 464 | GL11.glViewport(0, 0, 256, 256); 465 | this.drawPanorama(par1, par2, par3); 466 | this.rotateAndBlurSkybox(par3); 467 | this.rotateAndBlurSkybox(par3); 468 | this.rotateAndBlurSkybox(par3); 469 | this.rotateAndBlurSkybox(par3); 470 | this.rotateAndBlurSkybox(par3); 471 | this.rotateAndBlurSkybox(par3); 472 | this.rotateAndBlurSkybox(par3); 473 | this.mc.getFramebuffer().bindFramebuffer(true); 474 | GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); 475 | Tessellator tessellator = Tessellator.instance; 476 | tessellator.startDrawingQuads(); 477 | float f1 = this.width > this.height ? 120.0F / (float) this.width 478 | : 120.0F / (float) this.height; 479 | float f2 = (float) this.height * f1 / 256.0F; 480 | float f3 = (float) this.width * f1 / 256.0F; 481 | tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F); 482 | int k = this.width; 483 | int l = this.height; 484 | tessellator.addVertexWithUV(0.0D, (double) l, (double) this.zLevel, 485 | (double) (0.5F - f2), (double) (0.5F + f3)); 486 | tessellator.addVertexWithUV((double) k, (double) l, 487 | (double) this.zLevel, (double) (0.5F - f2), 488 | (double) (0.5F - f3)); 489 | tessellator.addVertexWithUV((double) k, 0.0D, (double) this.zLevel, 490 | (double) (0.5F + f2), (double) (0.5F - f3)); 491 | tessellator.addVertexWithUV(0.0D, 0.0D, (double) this.zLevel, 492 | (double) (0.5F + f2), (double) (0.5F + f3)); 493 | tessellator.draw(); 494 | } 495 | 496 | public void drawScreen(int par1, int par2, float par3) { 497 | GL11.glDisable(GL11.GL_ALPHA_TEST); 498 | this.renderSkybox(par1, par2, par3); 499 | GL11.glEnable(GL11.GL_ALPHA_TEST); 500 | Tessellator tessellator = Tessellator.instance; 501 | short short1 = 274; 502 | int k = this.width / 2 - short1 / 2; 503 | byte b0 = 30; 504 | this.drawGradientRect(0, 0, this.width, this.height, -2130706433, 505 | 16777215); 506 | this.drawGradientRect(0, 0, this.width, this.height, 0, 507 | Integer.MIN_VALUE); 508 | this.mc.getTextureManager().bindTexture(minecraftTitleTextures); 509 | GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 510 | 511 | if ((double) this.updateCounter < 1.0E-4D) { 512 | this.drawTexturedModalRect(k + 0, b0 + 0, 0, 0, 99, 44); 513 | this.drawTexturedModalRect(k + 99, b0 + 0, 129, 0, 27, 44); 514 | this.drawTexturedModalRect(k + 99 + 26, b0 + 0, 126, 0, 3, 44); 515 | this.drawTexturedModalRect(k + 99 + 26 + 3, b0 + 0, 99, 0, 26, 44); 516 | this.drawTexturedModalRect(k + 155, b0 + 0, 0, 45, 155, 44); 517 | } else { 518 | this.drawTexturedModalRect(k + 0, b0 + 0, 0, 0, 155, 44); 519 | this.drawTexturedModalRect(k + 155, b0 + 0, 0, 45, 155, 44); 520 | } 521 | 522 | tessellator.setColorOpaque_I(-1); 523 | GL11.glPushMatrix(); 524 | GL11.glTranslatef((float) (this.width / 2 + 90), 70.0F, 0.0F); 525 | GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F); 526 | float f1 = 1.8F - MathHelper 527 | .abs(MathHelper.sin((float) (Minecraft.getSystemTime() % 1000L) 528 | / 1000.0F * (float) Math.PI * 2.0F) * 0.1F); 529 | f1 = f1 530 | * 100.0F 531 | / (float) (this.fontRendererObj.getStringWidth(this.splashText) + 32); 532 | GL11.glScalef(f1, f1, f1); 533 | this.drawCenteredString(this.fontRendererObj, this.splashText, 0, -8, 534 | -256); 535 | GL11.glPopMatrix(); 536 | String s = "Minecraft 1.7.2"; 537 | 538 | if (this.mc.isDemo()) { 539 | s = s + " Demo"; 540 | } 541 | 542 | drawAnnouncement(); 543 | 544 | List brandings = Lists.reverse(FMLCommonHandler.instance() 545 | .getBrandings(true)); 546 | for (int i = 0; i < brandings.size(); i++) { 547 | String brd = brandings.get(i); 548 | if (!Strings.isNullOrEmpty(brd)) { 549 | this.drawString(this.fontRendererObj, brd, 2, this.height 550 | - (10 + i * (this.fontRendererObj.FONT_HEIGHT + 1)), 551 | 16777215); 552 | } 553 | } 554 | String s1 = "Copyright Mojang AB. Do not distribute!"; 555 | String s2 = "Copyright(c) 2014 modded by huangyuhui. All Rights Reserved."; 556 | 557 | this.drawString(this.fontRendererObj, s2, this.width 558 | - this.fontRendererObj.getStringWidth(s2) - 2, 559 | this.height - 20, -1); 560 | this.drawString(this.fontRendererObj, s1, this.width 561 | - this.fontRendererObj.getStringWidth(s1) - 2, 562 | this.height - 10, -1); 563 | 564 | if (!StringUtils.isBlank(this.outdate_first)) { 565 | drawRect(this.outdate_l - 2, this.outdate_b - 2, 566 | this.outdate_r + 2, this.outdate_t - 1, 1428160512); 567 | this.drawCenteredString(this.fontRendererObj, this.outdate_first, 568 | this.width / 2, this.outdate_b, -1); 569 | this.drawCenteredString(this.fontRendererObj, this.outdate_second, 570 | this.width / 2, 571 | this.outdate_b + 12, -1); 572 | } 573 | 574 | super.drawScreen(par1, par2, par3); 575 | } 576 | 577 | @Override 578 | protected void mouseClicked(int par1, int par2, int par3) { 579 | super.mouseClicked(par1, par2, par3); 580 | 581 | if (15 <= par2 && par2 < 25) { 582 | if(thread.isLoading) 583 | thread.cancel(); 584 | else 585 | thread.func_147224_a(MyUI.instance.serverURL1); 586 | } 587 | 588 | if (par2 < 15) { 589 | openLink(MyUI.instance.updateURL, 99); 590 | } 591 | 592 | int block = width / 6; 593 | int i = this.height / 4 + 48; 594 | if ((block - 2) <= par1 && par1 <= (block * 2) && i <= par2 595 | && par2 <= (i + 24 * 3 - 4)) { 596 | openLink(MyUI.instance.announcementPictureURL, 98); 597 | } 598 | 599 | if (par2 > this.height - 20 && par2 < this.height - 10 600 | && par1 > this.width - 50) { 601 | mc.displayGuiScreen(new MyUIModGuiFactory.CopyrightScreen(this)); 602 | } 603 | } 604 | 605 | public void openLink(String url, int index) { 606 | myURL[index] = url; 607 | GuiConfirmOpenLink guiconfirmopenlink = new GuiConfirmOpenLink(this, url, 13, true); 608 | guiconfirmopenlink.func_146358_g(); 609 | this.mc.displayGuiScreen(guiconfirmopenlink); 610 | } 611 | } -------------------------------------------------------------------------------- /1.7.10/org/jackhuang/myui/client/NewMenu.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Huang Yuhui, 2014 3 | * 4 | * This code is the property of huanghongxun 5 | * and may not be used with explicit written 6 | * permission. 7 | */ 8 | package org.jackhuang.myui.client; 9 | 10 | public class NewMenu extends GuiScreen { 11 | private static final AtomicInteger field_146973_f = new AtomicInteger(0); 12 | private static final Logger logger = LogManager.getLogger(); 13 | private static final Random rand = new Random(); 14 | private float updateCounter; 15 | private String splashText; 16 | private GuiButton buttonResetDemo; 17 | private int panoramaTimer; 18 | private DynamicTexture viewportTexture; 19 | private boolean field_96141_q = true; 20 | private static boolean field_96140_r; 21 | private static boolean field_96139_s; 22 | private final Object field_104025_t = new Object(); 23 | private String outdate_first; 24 | private String outdate_second; 25 | private String outdate_link; 26 | private static final ResourceLocation splashTexts = new ResourceLocation( 27 | "texts/splashes.txt"); 28 | private static final ResourceLocation minecraftTitleTextures = new ResourceLocation( 29 | "textures/gui/title/minecraft.png"); 30 | private static final ResourceLocation[] titlePanoramaPaths = new ResourceLocation[] { 31 | new ResourceLocation("textures/gui/title/background/panorama_0.png"), 32 | new ResourceLocation("textures/gui/title/background/panorama_1.png"), 33 | new ResourceLocation("textures/gui/title/background/panorama_2.png"), 34 | new ResourceLocation("textures/gui/title/background/panorama_3.png"), 35 | new ResourceLocation("textures/gui/title/background/panorama_4.png"), 36 | new ResourceLocation("textures/gui/title/background/panorama_5.png") }; 37 | public static final String outdate_default = "Please click " 38 | + EnumChatFormatting.UNDERLINE + "here" + EnumChatFormatting.RESET 39 | + " for more information."; 40 | private int outdate_second_width; 41 | private int outdate_first_width; 42 | private int outdate_l; 43 | private int outdate_b; 44 | private int outdate_r; 45 | private int outdate_t; 46 | private String username=null; 47 | private String player=null; 48 | private ResourceLocation field_110351_G; 49 | private GuiButton minecraftRealmsButton; 50 | private static final String __OBFID = "CL_00001154"; 51 | 52 | private GuiButton fmlModButton = null; 53 | private GuiButton multiplayerButton=null; 54 | private static double version = 1.0; 55 | 56 | @SuppressWarnings({ "rawtypes", "unchecked" }) 57 | public NewMenu() { 58 | this.outdate_second = outdate_default; 59 | this.splashText = "missingno"; 60 | BufferedReader bufferedreader = null; 61 | 62 | try { 63 | ArrayList arraylist = new ArrayList(); 64 | bufferedreader = new BufferedReader(new InputStreamReader(Minecraft 65 | .getMinecraft().getResourceManager() 66 | .getResource(splashTexts).getInputStream(), Charsets.UTF_8)); 67 | String s; 68 | 69 | while ((s = bufferedreader.readLine()) != null) { 70 | s = s.trim(); 71 | 72 | if (!s.isEmpty()) { 73 | arraylist.add(s); 74 | } 75 | } 76 | 77 | if (!arraylist.isEmpty()) { 78 | do { 79 | this.splashText = (String) arraylist.get(rand 80 | .nextInt(arraylist.size())); 81 | } while (this.splashText.hashCode() == 125780783); 82 | } 83 | } catch (IOException ioexception1) { 84 | ; 85 | } finally { 86 | if (bufferedreader != null) { 87 | try { 88 | bufferedreader.close(); 89 | } catch (IOException ioexception) { 90 | ; 91 | } 92 | } 93 | } 94 | } 95 | 96 | public void updateScreen() { 97 | ++this.panoramaTimer; 98 | } 99 | 100 | public boolean doesGuiPauseGame() { 101 | return false; 102 | } 103 | 104 | @SuppressWarnings({ "unchecked" }) 105 | @Override 106 | public void initGui() { 107 | this.viewportTexture = new DynamicTexture(256, 256); 108 | this.field_110351_G = this.mc.getTextureManager() 109 | .getDynamicTextureLocation("background", this.viewportTexture); 110 | Calendar calendar = Calendar.getInstance(); 111 | calendar.setTime(new Date()); 112 | 113 | if (calendar.get(2) + 1 == 11 && calendar.get(5) == 9) { 114 | this.splashText = "Happy birthday, ez!"; 115 | } else if (calendar.get(2) + 1 == 6 && calendar.get(5) == 1) { 116 | this.splashText = "Happy birthday, Notch!"; 117 | } else if (calendar.get(2) + 1 == 12 && calendar.get(5) == 24) { 118 | this.splashText = "Merry X-mas!"; 119 | } else if (calendar.get(2) + 1 == 1 && calendar.get(5) == 1) { 120 | this.splashText = "Happy new year!"; 121 | } else if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31) { 122 | this.splashText = "OOoooOOOoooo! Spooky!"; 123 | } else if (calendar.get(2) + 1 == 5 && calendar.get(5) == 15) { 124 | this.splashText = "Happy Birthday, Brian!"; 125 | } 126 | 127 | boolean flag = true; 128 | int i = this.height / 4 + 48; 129 | int split = 24; 130 | 131 | if (this.mc.isDemo()) { 132 | } else { 133 | this.addSingleplayerMultiplayerButtons(i, split); 134 | } 135 | 136 | this.addCustomizedButtons(i, 24); 137 | 138 | loginframe_l = 114; 139 | loginframe_r = this.width / 4*3 - 2; 140 | 141 | Object object = this.field_104025_t; 142 | 143 | synchronized (this.field_104025_t) { 144 | this.outdate_first_width = this.fontRendererObj 145 | .getStringWidth(this.outdate_first); 146 | this.outdate_second_width = this.fontRendererObj 147 | .getStringWidth(this.outdate_second); 148 | int j = this.width / 6 * 4; 149 | this.outdate_l = (this.width - j) / 2; 150 | this.outdate_b = i - 24; 151 | this.outdate_r = this.outdate_l + j; 152 | this.outdate_t = this.outdate_b + 24; 153 | } 154 | 155 | if (MyUI.instance.announcementContent != null) { 156 | String[] a = MyUI.instance.announcementContent.split("\n"); 157 | this.outdate_first = a[0]; 158 | if (a.length > 1) 159 | this.outdate_second = a[1]; 160 | } else { 161 | this.outdate_first = "暂无公告"; 162 | } 163 | 164 | thread = new LoadServerThread(MyUI.instance.serverURL1); 165 | thread.func_147224_a(MyUI.instance.serverURL1); 166 | } 167 | 168 | private void addCustomizedButtons(int top, int split) { 169 | int block = this.width / 6; 170 | 171 | this.buttonList.add(new GuiButton(20, block * 2 + 2, top, block - 2, 172 | 20, "自动配对线路")); 173 | this.buttonList.add(new GuiButton(21, block * 3 + 2, top, block - 2, 174 | 20, "电信入口")); 175 | this.buttonList.add(new GuiButton(22, block * 4 + 2, top, block - 2, 176 | 20, "联通入口")); 177 | this.buttonList.add(new GuiButton(23, block * 2 + 2, top + split, 178 | block * 1 - 2, 20, "进入官网")); 179 | this.buttonList.add(new GuiButton(25, block * 3 + 2, top + split, 180 | block * 1 - 2, 20, "进入Q群")); 181 | this.buttonList.add(new GuiButton(24, block * 4 + 2, top + split, 182 | block * 1 - 2, 20, "联系服主")); 183 | 184 | this.buttonList.add(new GuiButton(0, block * 3 + 2, top + 72 + 12, 185 | block - 2, 20, I18n.format("menu.options"))); 186 | this.buttonList.add(new GuiButton(4, block * 4 + 2, top + 72 + 12, 187 | block - 2, 20, I18n.format("menu.quit"))); 188 | this.buttonList.add(new GuiButtonLanguage(5, block * 2 + 2 - 24, 189 | top + 72 + 12)); 190 | 191 | } 192 | 193 | private void drawAnnouncement() { 194 | if(thread != null && thread.isLoading) 195 | thread.processReceivedMessages(); 196 | 197 | int i = this.height / 4 + 48; 198 | int block = this.width / 6; 199 | 200 | drawRect(0, 0, this.width, 25, 1428160512); 201 | 202 | String s2 = "", s3 = "点击此处刷新"; 203 | 204 | if (thread != null && thread.online >= 0 && thread.maxplayer >= 0) { 205 | s2 += "在线人数/最大人数: " + thread.online + "/" + thread.maxplayer; 206 | s2 += " 延迟: " + thread.offset + "ms"; 207 | } else if(thread != null && thread.isLoading) { 208 | s2 += "加载中"; s3 = "点击此处取消"; 209 | } else { 210 | s2 += EnumChatFormatting.YELLOW + "无法连接服务器、服务器响应错误或请求被取消"; 211 | } 212 | drawCenteredString(fontRendererObj, s2 + " " + EnumChatFormatting.UNDERLINE + s3 + EnumChatFormatting.RESET, this.width / 2, 15, 14737632); 213 | 214 | String s = "当前版本为" + EnumChatFormatting.YELLOW + MyUI.instance.version 215 | + EnumChatFormatting.RESET + ", 最新版本为" 216 | + EnumChatFormatting.GREEN + MyUI.instance.newestVersion 217 | + EnumChatFormatting.RESET + ", "; 218 | if (MD5Util.tryParseDouble(MyUI.instance.newestVersion, 1) > MyUI.instance.versionDouble) 219 | s += EnumChatFormatting.UNDERLINE + "点击此处" 220 | + EnumChatFormatting.RESET + "更新您的客户端"; 221 | else 222 | s += "您的客户端为最新, 无需更新"; 223 | drawCenteredString(fontRendererObj, s, this.width / 2, 3, 14737632); 224 | 225 | drawRect(this.outdate_l - 2, i, block * 2, i + 24 * 3 - 4, 1428160512); 226 | 227 | drawCenteredString(fontRendererObj, MyUI.instance.announcementTitle, 228 | (block + 2) / 2 + block, i + 24 * 3, 14737632); 229 | 230 | BufferedImage image = GLUtil.loadImage("announcement_picture.png"); 231 | if (image != null) { 232 | GLUtil.loadTexture(image); 233 | GLUtil.drawTexture(this.outdate_l - 2, i, block * 2, i + 24 * 3 - 4); 234 | } 235 | } 236 | 237 | @SuppressWarnings("unchecked") 238 | private void addSingleplayerMultiplayerButtons(int par1, int par2) { 239 | int block = this.width / 6; 240 | 241 | this.buttonList.add(new GuiButton(1, block * 2 + 2, par1 + 72 + 12, 242 | block - 2, 20, I18n.format("menu.singleplayer"))); 243 | fmlModButton = new GuiButton(6, block * 2 + 2, par1 + par2 * 2, 244 | block * 3 - 2, 20, "模组"); 245 | this.buttonList.add(fmlModButton); 246 | } 247 | 248 | protected void actionPerformed(GuiButton p_146284_1_) { 249 | if (p_146284_1_.id == 0) { 250 | this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings)); 251 | } 252 | 253 | if (p_146284_1_.id == 5) { 254 | this.mc.displayGuiScreen(new GuiLanguage(this, 255 | this.mc.gameSettings, this.mc.getLanguageManager())); 256 | } 257 | 258 | if (p_146284_1_.id == 1) { 259 | this.mc.displayGuiScreen(new GuiSelectWorld(this)); 260 | } 261 | 262 | if (p_146284_1_.id == 4) { 263 | this.mc.shutdown(); 264 | } 265 | 266 | if (p_146284_1_.id == 6) { 267 | this.mc.displayGuiScreen(new GuiModList(this)); 268 | } 269 | 270 | if (p_146284_1_.id == 11) { 271 | this.mc.launchIntegratedServer("Demo_World", "Demo_World", 272 | DemoWorldServer.demoWorldSettings); 273 | } 274 | 275 | String url = null; 276 | boolean b = false; 277 | if (p_146284_1_.id == 13) { 278 | openLink(this.outdate_link); 279 | } else if (p_146284_1_.id == 23) { 280 | openLink(MyUI.instance.webiteURL); 281 | } else if (p_146284_1_.id == 24) { 282 | openLink(MyUI.instance.contactURL); 283 | } else if (p_146284_1_.id == 25) { 284 | openLink(MyUI.instance.qGroupURL); 285 | } 286 | 287 | if (p_146284_1_.id == 20) { 288 | FMLClientHandler.instance().setupServerList(); 289 | FMLClientHandler.instance().connectToServer(this, 290 | new ServerData("", MyUI.instance.serverURL1)); 291 | } 292 | 293 | if (p_146284_1_.id == 21) { 294 | FMLClientHandler.instance().setupServerList(); 295 | FMLClientHandler.instance().connectToServer(this, 296 | new ServerData("", MyUI.instance.serverURL2)); 297 | } 298 | 299 | if (p_146284_1_.id == 22) { 300 | FMLClientHandler.instance().setupServerList(); 301 | FMLClientHandler.instance().connectToServer(this, 302 | new ServerData("", MyUI.instance.serverURL3)); 303 | } 304 | } 305 | 306 | @SuppressWarnings({ "unchecked", "rawtypes" }) 307 | public void confirmClicked(boolean par1, int par2) { 308 | if (par1 && par2 == 12) { 309 | ISaveFormat isaveformat = this.mc.getSaveLoader(); 310 | isaveformat.flushCache(); 311 | isaveformat.deleteWorldDirectory("Demo_World"); 312 | this.mc.displayGuiScreen(this); 313 | } else if (par2 == 13) { 314 | if (par1) { 315 | try { 316 | Class oclass = Class.forName("java.awt.Desktop"); 317 | Object object = oclass 318 | .getMethod("getDesktop", new Class[0]).invoke( 319 | (Object) null, new Object[0]); 320 | oclass.getMethod("browse", new Class[] { URI.class }) 321 | .invoke(object, 322 | new Object[] { new URI(this.outdate_link) }); 323 | } catch (Throwable throwable) { 324 | logger.error("Couldn\'t open link", throwable); 325 | } 326 | } 327 | 328 | this.mc.displayGuiScreen(this); 329 | } 330 | } 331 | 332 | private void drawPanorama(int par1, int par2, float par3) { 333 | Tessellator tessellator = Tessellator.instance; 334 | GL11.glMatrixMode(GL11.GL_PROJECTION); 335 | GL11.glPushMatrix(); 336 | GL11.glLoadIdentity(); 337 | Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F); 338 | GL11.glMatrixMode(GL11.GL_MODELVIEW); 339 | GL11.glPushMatrix(); 340 | GL11.glLoadIdentity(); 341 | GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 342 | GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); 343 | GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); 344 | GL11.glEnable(GL11.GL_BLEND); 345 | GL11.glDisable(GL11.GL_ALPHA_TEST); 346 | GL11.glDisable(GL11.GL_CULL_FACE); 347 | GL11.glDepthMask(false); 348 | OpenGlHelper.glBlendFunc(770, 771, 1, 0); 349 | byte b0 = 8; 350 | 351 | for (int k = 0; k < b0 * b0; ++k) { 352 | GL11.glPushMatrix(); 353 | float f1 = ((float) (k % b0) / (float) b0 - 0.5F) / 64.0F; 354 | float f2 = ((float) (k / b0) / (float) b0 - 0.5F) / 64.0F; 355 | float f3 = 0.0F; 356 | GL11.glTranslatef(f1, f2, f3); 357 | GL11.glRotatef( 358 | MathHelper 359 | .sin(((float) this.panoramaTimer + par3) / 400.0F) * 25.0F + 20.0F, 360 | 1.0F, 0.0F, 0.0F); 361 | GL11.glRotatef(-((float) this.panoramaTimer + par3) * 0.1F, 0.0F, 362 | 1.0F, 0.0F); 363 | 364 | for (int l = 0; l < 6; ++l) { 365 | GL11.glPushMatrix(); 366 | 367 | if (l == 1) { 368 | GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); 369 | } 370 | 371 | if (l == 2) { 372 | GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); 373 | } 374 | 375 | if (l == 3) { 376 | GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); 377 | } 378 | 379 | if (l == 4) { 380 | GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); 381 | } 382 | 383 | if (l == 5) { 384 | GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); 385 | } 386 | 387 | this.mc.getTextureManager().bindTexture(titlePanoramaPaths[l]); 388 | tessellator.startDrawingQuads(); 389 | tessellator.setColorRGBA_I(16777215, 255 / (k + 1)); 390 | float f4 = 0.0F; 391 | tessellator.addVertexWithUV(-1.0D, -1.0D, 1.0D, 392 | (double) (0.0F + f4), (double) (0.0F + f4)); 393 | tessellator.addVertexWithUV(1.0D, -1.0D, 1.0D, 394 | (double) (1.0F - f4), (double) (0.0F + f4)); 395 | tessellator.addVertexWithUV(1.0D, 1.0D, 1.0D, 396 | (double) (1.0F - f4), (double) (1.0F - f4)); 397 | tessellator.addVertexWithUV(-1.0D, 1.0D, 1.0D, 398 | (double) (0.0F + f4), (double) (1.0F - f4)); 399 | tessellator.draw(); 400 | GL11.glPopMatrix(); 401 | } 402 | 403 | GL11.glPopMatrix(); 404 | GL11.glColorMask(true, true, true, false); 405 | } 406 | 407 | tessellator.setTranslation(0.0D, 0.0D, 0.0D); 408 | GL11.glColorMask(true, true, true, true); 409 | GL11.glMatrixMode(GL11.GL_PROJECTION); 410 | GL11.glPopMatrix(); 411 | GL11.glMatrixMode(GL11.GL_MODELVIEW); 412 | GL11.glPopMatrix(); 413 | GL11.glDepthMask(true); 414 | GL11.glEnable(GL11.GL_CULL_FACE); 415 | GL11.glEnable(GL11.GL_DEPTH_TEST); 416 | } 417 | 418 | private void rotateAndBlurSkybox(float par1) { 419 | this.mc.getTextureManager().bindTexture(this.field_110351_G); 420 | GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, 421 | GL11.GL_LINEAR); 422 | GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, 423 | GL11.GL_LINEAR); 424 | GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256); 425 | GL11.glEnable(GL11.GL_BLEND); 426 | OpenGlHelper.glBlendFunc(770, 771, 1, 0); 427 | GL11.glColorMask(true, true, true, false); 428 | Tessellator tessellator = Tessellator.instance; 429 | tessellator.startDrawingQuads(); 430 | GL11.glDisable(GL11.GL_ALPHA_TEST); 431 | byte b0 = 3; 432 | 433 | for (int i = 0; i < b0; ++i) { 434 | tessellator 435 | .setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F / (float) (i + 1)); 436 | int j = this.width; 437 | int k = this.height; 438 | float f1 = (float) (i - b0 / 2) / 256.0F; 439 | tessellator.addVertexWithUV((double) j, (double) k, 440 | (double) this.zLevel, (double) (0.0F + f1), 1.0D); 441 | tessellator.addVertexWithUV((double) j, 0.0D, (double) this.zLevel, 442 | (double) (1.0F + f1), 1.0D); 443 | tessellator.addVertexWithUV(0.0D, 0.0D, (double) this.zLevel, 444 | (double) (1.0F + f1), 0.0D); 445 | tessellator.addVertexWithUV(0.0D, (double) k, (double) this.zLevel, 446 | (double) (0.0F + f1), 0.0D); 447 | } 448 | 449 | tessellator.draw(); 450 | GL11.glEnable(GL11.GL_ALPHA_TEST); 451 | GL11.glColorMask(true, true, true, true); 452 | } 453 | 454 | private void renderSkybox(int par1, int par2, float par3) { 455 | this.mc.getFramebuffer().unbindFramebuffer(); 456 | GL11.glViewport(0, 0, 256, 256); 457 | this.drawPanorama(par1, par2, par3); 458 | this.rotateAndBlurSkybox(par3); 459 | this.rotateAndBlurSkybox(par3); 460 | this.rotateAndBlurSkybox(par3); 461 | this.rotateAndBlurSkybox(par3); 462 | this.rotateAndBlurSkybox(par3); 463 | this.rotateAndBlurSkybox(par3); 464 | this.rotateAndBlurSkybox(par3); 465 | this.mc.getFramebuffer().bindFramebuffer(true); 466 | GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); 467 | Tessellator tessellator = Tessellator.instance; 468 | tessellator.startDrawingQuads(); 469 | float f1 = this.width > this.height ? 120.0F / (float) this.width 470 | : 120.0F / (float) this.height; 471 | float f2 = (float) this.height * f1 / 256.0F; 472 | float f3 = (float) this.width * f1 / 256.0F; 473 | tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F); 474 | int k = this.width; 475 | int l = this.height; 476 | tessellator.addVertexWithUV(0.0D, (double) l, (double) this.zLevel, 477 | (double) (0.5F - f2), (double) (0.5F + f3)); 478 | tessellator.addVertexWithUV((double) k, (double) l, 479 | (double) this.zLevel, (double) (0.5F - f2), 480 | (double) (0.5F - f3)); 481 | tessellator.addVertexWithUV((double) k, 0.0D, (double) this.zLevel, 482 | (double) (0.5F + f2), (double) (0.5F - f3)); 483 | tessellator.addVertexWithUV(0.0D, 0.0D, (double) this.zLevel, 484 | (double) (0.5F + f2), (double) (0.5F + f3)); 485 | tessellator.draw(); 486 | } 487 | 488 | public void drawScreen(int par1, int par2, float par3) { 489 | if(!MyUI.instance.service) 490 | mc.displayGuiScreen(new GuiMainMenu()); 491 | 492 | GL11.glDisable(GL11.GL_ALPHA_TEST); 493 | this.renderSkybox(par1, par2, par3); 494 | GL11.glEnable(GL11.GL_ALPHA_TEST); 495 | Tessellator tessellator = Tessellator.instance; 496 | short short1 = 274; 497 | int k = this.width / 2 - short1 / 2; 498 | byte b0 = 30; 499 | this.drawGradientRect(0, 0, this.width, this.height, -2130706433, 500 | 16777215); 501 | this.drawGradientRect(0, 0, this.width, this.height, 0, 502 | Integer.MIN_VALUE); 503 | this.mc.getTextureManager().bindTexture(minecraftTitleTextures); 504 | GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 505 | 506 | if ((double) this.updateCounter < 1.0E-4D) { 507 | this.drawTexturedModalRect(k + 0, b0 + 0, 0, 0, 99, 44); 508 | this.drawTexturedModalRect(k + 99, b0 + 0, 129, 0, 27, 44); 509 | this.drawTexturedModalRect(k + 99 + 26, b0 + 0, 126, 0, 3, 44); 510 | this.drawTexturedModalRect(k + 99 + 26 + 3, b0 + 0, 99, 0, 26, 44); 511 | this.drawTexturedModalRect(k + 155, b0 + 0, 0, 45, 155, 44); 512 | } else { 513 | this.drawTexturedModalRect(k + 0, b0 + 0, 0, 0, 155, 44); 514 | this.drawTexturedModalRect(k + 155, b0 + 0, 0, 45, 155, 44); 515 | } 516 | 517 | tessellator.setColorOpaque_I(-1); 518 | GL11.glPushMatrix(); 519 | GL11.glTranslatef((float) (this.width / 2 + 90), 70.0F, 0.0F); 520 | GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F); 521 | float f1 = 1.8F - MathHelper 522 | .abs(MathHelper.sin((float) (Minecraft.getSystemTime() % 1000L) 523 | / 1000.0F * (float) Math.PI * 2.0F) * 0.1F); 524 | f1 = f1 525 | * 100.0F 526 | / (float) (this.fontRendererObj.getStringWidth(this.splashText) + 32); 527 | GL11.glScalef(f1, f1, f1); 528 | this.drawCenteredString(this.fontRendererObj, this.splashText, 0, -8, 529 | -256); 530 | GL11.glPopMatrix(); 531 | String s = "Minecraft 1.7.2"; 532 | 533 | if (this.mc.isDemo()) { 534 | s = s + " Demo"; 535 | } 536 | 537 | drawAnnouncement(); 538 | 539 | List brandings = Lists.reverse(FMLCommonHandler.instance() 540 | .getBrandings(true)); 541 | for (int i = 0; i < brandings.size(); i++) { 542 | String brd = brandings.get(i); 543 | if (!Strings.isNullOrEmpty(brd)) { 544 | this.drawString(this.fontRendererObj, brd, 2, this.height 545 | - (10 + i * (this.fontRendererObj.FONT_HEIGHT + 1)), 546 | 16777215); 547 | } 548 | } 549 | 550 | String s1 = "Copyright Mojang AB. Do not distribute!"; 551 | String s2 = "Copyright huangyuhui. All Rights Reserved. Click here for about."; 552 | 553 | this.drawString(this.fontRendererObj, s2, this.width 554 | - this.fontRendererObj.getStringWidth(s2) - 2, 555 | this.height - 20, -1); 556 | this.drawString(this.fontRendererObj, s1, this.width 557 | - this.fontRendererObj.getStringWidth(s1) - 2, 558 | this.height - 10, -1); 559 | 560 | if (!StringUtils.isBlank(this.outdate_first)) { 561 | drawRect(this.outdate_l - 2, this.outdate_b - 2, 562 | this.outdate_r + 2, this.outdate_t - 1, 1428160512); 563 | this.drawCenteredString(this.fontRendererObj, this.outdate_first, 564 | this.width / 2, this.outdate_b, -1); 565 | this.drawCenteredString(this.fontRendererObj, this.outdate_second, 566 | this.width / 2, 567 | this.outdate_b + 12, -1); 568 | } 569 | 570 | super.drawScreen(par1, par2, par3); 571 | } 572 | 573 | @Override 574 | protected void mouseClicked(int par1, int par2, int par3) { 575 | super.mouseClicked(par1, par2, par3); 576 | 577 | if (15 <= par2 && par2 < 25) { 578 | if(thread.isLoading) 579 | thread.cancel(); 580 | else 581 | thread.func_147224_a(MyUI.instance.serverURL1); 582 | } 583 | 584 | if (par2 < 15) { 585 | openLink(MyUI.instance.updateURL); 586 | } 587 | 588 | int block = width / 6; 589 | int i = this.height / 4 + 48; 590 | if ((block - 2) <= par1 && par1 <= (block * 2) && i <= par2 591 | && par2 <= (i + 24 * 3 - 4)) { 592 | openLink(MyUI.instance.announcementPictureURL); 593 | } 594 | 595 | if (par2 > this.height - 20 && par2 < this.height - 10 596 | && par1 > this.width - 50) { 597 | mc.displayGuiScreen(new MyUIModGuiFactory.CopyrightScreen(this)); 598 | } 599 | } 600 | 601 | public void openLink(String url) { 602 | GuiConfirmOpenLink guiconfirmopenlink = new GuiConfirmOpenLink( 603 | new MyGuiYesNoCallback(url), url, 13, true); 604 | guiconfirmopenlink.func_146358_g(); 605 | this.mc.displayGuiScreen(guiconfirmopenlink); 606 | } 607 | 608 | public static class MyGuiYesNoCallback implements GuiYesNoCallback { 609 | String url; 610 | 611 | public MyGuiYesNoCallback(String url) { 612 | this.url = url; 613 | } 614 | 615 | @Override 616 | public void confirmClicked(boolean arg0, int arg1) { 617 | 618 | } 619 | 620 | } 621 | } --------------------------------------------------------------------------------