// *************************************************************************** // initDisplay // *************************************************************************** private static void initDisplay(boolean fullscreen) { DisplayMode chosenMode = null; try { DisplayMode[] modes = Display.getAvailableDisplayModes(); for (int i = 0; i < modes.length; i++) { if ((modes[i].getWidth() == targetWidth) && (modes[i].getHeight() == targetHeight)) { chosenMode = modes[i]; break; } } } catch (LWJGLException e) { Sys.alert("Error", "Unable to determine display modes."); System.exit(0); } // at this point if we have no mode there was no appropriate, let the user know // and give up if (chosenMode == null) { Sys.alert("Error", "Unable to find appropriate display mode."); System.exit(0); } try { Display.setDisplayMode(chosenMode); Display.setFullscreen(fullscreen); Display.setTitle("OpenCraft"); Display.create(); } catch (LWJGLException e) { Sys.alert("Error", "Unable to create display."); System.exit(0); } }
public long getTimeMillis() { long res = Sys.getTimerResolution(); long time = Sys.getTime(); if (res != 1000) { time = (time * 1000) / res; } return time; }
@Override protected void actionPerformed(GuiButton guiButton) { if (guiButton.enabled) { if (guiButton.id == this.btnOpenDir.id) { boolean success = false; try { Class c = Class.forName("java.awt.Desktop"); Object m = c.getMethod("getDesktop", new Class[0]).invoke((Object) null, new Object[0]); c.getMethod("browse", new Class[] {URI.class}) .invoke(m, new Object[] {Settings.schematicDirectory.toURI()}); } catch (Throwable e) { success = true; } if (success) { Settings.logger.logInfo("Opening via Sys class!"); Sys.openURL("file://" + Settings.schematicDirectory.getAbsolutePath()); } } else if (guiButton.id == this.btnDone.id) { loadSchematic(); this.mc.displayGuiScreen(this.prevGuiScreen); } else { this.guiSchematicLoadSlot.actionPerformed(guiButton); } } }
/** * Disconnect from game. Allows for resetting server and client if triggered, but is not used in * all situations. * * @param message the message */ public static void disconnectGame(String message) { /* //wouldn't be hard to use something like this to reset to lobby rather than quit the game: //at the moment this disconnect is only in a few places between stages, i.e. while waiting //so it's not too bad to quit the game. Player leaver = null; for(Player p : session.getPlayers()) { if(p.getID() == message.origin) { leaver = p; } } session.removePlayer(leaver); System.out.println(leaver.getName()+" LEFT THE GAME"); * */ if (FEServer.getServer() != null) { // boot the server back to lobby FEServer.resetToLobbyAndKickPlayers(); } else { // exit the client if (message != null && !message.equals("")) { Sys.alert("FE:MP", message); } System.exit(0); } }
public void transform(ItemRenderType type) { if (type == ItemRenderType.EQUIPPED) { GL11.glTranslatef(0.5F, 0.5F, 0.5F); GL11.glRotatef(185, 1, 0, 0); GL11.glRotatef(40, 0, 1, 0); GL11.glRotatef(-70, 0, 0, 1); GL11.glScalef(3.2F, 3.2F, 3.2F); } if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glScalef(8.2F, 8.2F, 8.2F); GL11.glTranslatef(0.291F, -0.15F, 0.1F); GL11.glRotatef(180, 0, 0, 1); } GL11.glScalef(-0.4F, -0.4F, 0.4F); if (type == ItemRenderType.INVENTORY || type == ItemRenderType.ENTITY) { if (type == ItemRenderType.INVENTORY) { GL11.glTranslatef(0.0F, 1.45F, 0.0F); GL11.glScalef(2.0F, 2.0F, 2.0F); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(180, 0, 1, 0); } else { GL11.glRotatef(Sys.getTime() / 90F % 360F, 0F, 1F, 0F); GL11.glScalef(2F, -2F, 2F); } GL11.glScalef(1.3F, 1.3F, 1.3F); } }
public void run() { if (listener == null) throw new IllegalStateException( "SystemListener is not set on context!" + "Must set with JmeContext.setSystemListner()."); logger.log(Level.INFO, "Using LWJGL {0}", Sys.getVersion()); if (!initInThread()) { logger.log(Level.SEVERE, "Display initialization failed. Cannot continue."); return; } while (true) { if (renderable.get()) { if (Display.isCloseRequested()) listener.requestClose(false); if (wasActive != Display.isActive()) { if (!wasActive) { listener.gainFocus(); timer.reset(); wasActive = true; } else { listener.loseFocus(); wasActive = false; } } } runLoop(); if (needClose.get()) break; } deinitInThread(); }
@Override protected void actionPerformed(GuiButton guiButton) { if (guiButton.enabled) { if (guiButton.id == this.btnOpenDir.id) { boolean retry = false; try { Class c = Class.forName("java.awt.Desktop"); Object m = c.getMethod("getDesktop").invoke(null); c.getMethod("browse", URI.class) .invoke(m, ConfigurationHandler.schematicDirectory.toURI()); } catch (Throwable e) { retry = true; } if (retry) { Reference.logger.info("Opening via Sys class!"); Sys.openURL("file://" + ConfigurationHandler.schematicDirectory.getAbsolutePath()); } } else if (guiButton.id == this.btnDone.id) { if (Schematica.proxy.isLoadEnabled) { loadSchematic(); } this.mc.displayGuiScreen(this.parentScreen); } else { this.guiSchematicLoadSlot.actionPerformed(guiButton); } } }
/** * ************************************************************************************************************************************************************************************************* * Initialization stuff comes in here... * ************************************************************************************************************************************************************************************************ */ private void init() { try { Display.setDisplayMode(new DisplayMode(640, 480)); Display.setVSyncEnabled(true); Display.setTitle("MS3D Loader [G36C]"); Display.create(); Keyboard.create(); } catch (LWJGLException e) { Sys.alert("Error", "Initialization failed!\n\n" + e.getMessage()); System.exit(0); } /* OpenGL */ int width = Display.getDisplayMode().getWidth(); int height = Display.getDisplayMode().getHeight(); GL11.glViewport(0, 0, width, height); // Reset The Current Viewport GL11.glMatrixMode(GL11.GL_PROJECTION); // Select The Projection Matrix GL11.glLoadIdentity(); // Reset The Projection Matrix GLU.gluPerspective( 45.0f, ((float) width / (float) height), 0.1f, 1000.0f); // Calculate The Aspect Ratio Of The Window GL11.glMatrixMode(GL11.GL_MODELVIEW); // Select The Modelview Matrix GL11.glLoadIdentity(); // Reset The Modelview Matrix GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Background color GL11.glClearDepth(1.0f); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); // Load model // g36c = new // MS3DModel(resourceLoader.loadResourceAsStream("models/gsg9.ms3d"),this.getClass().getResource("./data/textures").getPath()); g36c = new MS3DModel( resourceLoader.loadResourceAsStream("models/assassin.ms3d"), this.getClass().getResource("./data/textures").getPath()); // tdsLoader=new TDSLoader(); // try { // tdsLoader.load(resourceLoader.loadResourceAsStream("models/face.3ds")); // System.out.println(tdsLoader.getObjectSize()); // } catch (IOException e) { // e.printStackTrace(); // } // Load font font = new Font(resourceLoader.loadResourceAsStream("textures/font.bmp"), 12, width, height); // Init timer timer = new Timer(); }
public int getAnimationTime(StateKey state) { long curTime = Sys.getTime(); int idx = getMouseButton(state); if (idx >= 0) { curTime -= lastTime[idx]; } return (int) curTime & Integer.MAX_VALUE; }
@Override public void update(float delta) { long startTime = 1000 * Sys.getTime() / Sys.getTimerResolution(); while (current != null && 1000 * Sys.getTime() / Sys.getTimerResolution() - startTime < 20) { if (current.step()) { popStep(); } } if (current == null) { nuiManager.popScreen(); CoreRegistry.get(GameEngine.class).changeState(new StateIngame()); } else { float progressValue = (progress + current.getExpectedCost() * current.getProgress()) / maxProgress; loadingScreen.updateStatus(current.getMessage(), progressValue); nuiManager.update(delta); } }
public void run() { loadNatives(); logger.log(Level.FINE, "Using LWJGL {0}", Sys.getVersion()); initInThread(); while (!needClose.get()) { runLoop(); } deinitInThread(); }
static { Sys.initialize(); display_impl = createDisplayImplementation(); try { current_mode = initial_mode = display_impl.init(); LWJGLUtil.log("Initial mode: " + initial_mode); } catch (LWJGLException e) { throw new RuntimeException(e); } ; }
/** * Application init * * @param args Commandline args */ public static void main(String[] args) { try { init(false); run(); } catch (Exception e) { e.printStackTrace(System.err); Sys.alert(GAME_TITLE, "An error occured and the game will exit."); } finally { cleanup(); } System.exit(0); }
public void transform(ItemStack itemstack, ItemRenderType type) { final EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; if (type == ItemRenderType.EQUIPPED) { GL11.glRotatef(70, 1.0F, 0, 0); GL11.glRotatef(-10, 0.0F, 1, 0); GL11.glRotatef(50, 0.0F, 1, 1); GL11.glTranslatef(-0.8F, -3.2F, 0F); GL11.glScalef(5.2F, 5.2F, 5.2F); if (player != null && player.ridingEntity != null && player.ridingEntity instanceof EntityTier1Rocket) { GL11.glScalef(0.0F, 0.0F, 0.0F); } } if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(2.5F, 5.9F, 1F); GL11.glRotatef(28, 0.0F, 0, 1); GL11.glRotatef(50 + 180, 0.0F, 1, 0); GL11.glRotatef(73, 1.0F, 0, 0); GL11.glScalef(5.2F, 5.2F, 5.2F); if (player != null && player.ridingEntity != null && player.ridingEntity instanceof EntityTier1Rocket) { GL11.glScalef(0.0F, 0.0F, 0.0F); } } GL11.glTranslatef(0, 0.1F, 0); GL11.glScalef(-0.4F, -0.4F, 0.4F); if (type == ItemRenderType.INVENTORY || type == ItemRenderType.ENTITY) { if (type == ItemRenderType.INVENTORY) { GL11.glRotatef(85F, 1F, 0F, 1F); GL11.glRotatef(20F, 1F, 0F, 0F); GL11.glScalef(0.7F, 0.7F, 0.7F); GL11.glTranslatef(0.0F, 1.6F, -0.4F); } else { GL11.glTranslatef(0, -0.9F, 0); GL11.glScalef(0.5F, 0.5F, 0.5F); } GL11.glScalef(1.3F, 1.3F, 1.3F); GL11.glTranslatef(0, -0.6F, 0); GL11.glRotatef(Sys.getTime() / 30F % 360F + 45, 0F, 1F, 0F); } GL11.glRotatef(180, 0, 0, 1); }
protected void actionPerformed(GuiButton guibutton) { if (!guibutton.enabled) { return; } if (guibutton.id == 5) { Sys.openURL((new StringBuilder()).append("file://").append(fileLocation).toString()); } else if (guibutton.id == 6) { mc.renderEngine.refreshTextures(); mc.displayGuiScreen(guiScreen); } else { guiTexturePackSlot.actionPerformed(guibutton); } }
/** * Fired when a control is clicked. This is the equivalent of * ActionListener.actionPerformed(ActionEvent e). */ protected void actionPerformed(GuiButton par1GuiButton) { if (par1GuiButton.enabled) { if (par1GuiButton.id == 5) { File var2 = GuiScreenTemporaryResourcePackSelectSelectionList.func_110510_a(this.field_110346_c) .func_110612_e(); String var3 = var2.getAbsolutePath(); if (Util.func_110647_a() == EnumOS.MACOS) { try { this.mc.getLogAgent().logInfo(var3); Runtime.getRuntime().exec(new String[] {"/usr/bin/open", var3}); return; } catch (IOException var9) { var9.printStackTrace(); } } else if (Util.func_110647_a() == EnumOS.WINDOWS) { String var4 = String.format("cmd.exe /C start \"Open file\" \"%s\"", new Object[] {var3}); try { Runtime.getRuntime().exec(var4); return; } catch (IOException var8) { var8.printStackTrace(); } } boolean var10 = false; try { Class var5 = Class.forName("java.awt.Desktop"); Object var6 = var5.getMethod("getDesktop", new Class[0]).invoke((Object) null, new Object[0]); var5.getMethod("browse", new Class[] {URI.class}) .invoke(var6, new Object[] {var2.toURI()}); } catch (Throwable var7) { var7.printStackTrace(); var10 = true; } if (var10) { this.mc.getLogAgent().logInfo("Opening via system class!"); Sys.openURL("file://" + var3); } } else if (par1GuiButton.id == 6) { this.mc.displayGuiScreen(this.field_110347_a); } else { this.field_110346_c.actionPerformed(par1GuiButton); } } }
/** * Create an OpenGL application with one window. The application behavior is controlled by the * <code>App</code> object. * * @param title The string that is displayed in the title bar of the application window. * @param multisampling Multisampling is used if true. May not work on all platforms. * @param application The application object. */ public OpenGLApp(String title, App application, boolean multisampling) { this.title = title; this.application = application; this.multisampling = multisampling && System.getProperty("os.name").equals("Mac OS X"); System.out.println( "LWJGL version " + Sys.getVersion() + " running on " + System.getProperty("os.name") + " version " + System.getProperty("os.version") + "."); }
/** * Fired when a control is clicked. This is the equivalent of * ActionListener.actionPerformed(ActionEvent e). */ protected void actionPerformed(GuiButton par1GuiButton) { if (par1GuiButton.enabled) { if (par1GuiButton.id == 5) { if (Minecraft.getOs() == EnumOS.MACOS) { try { this.mc.getLogAgent().logInfo(this.fileLocation); Runtime.getRuntime().exec(new String[] {"/usr/bin/open", this.fileLocation}); return; } catch (IOException var7) { var7.printStackTrace(); } } else if (Minecraft.getOs() == EnumOS.WINDOWS) { String var2 = String.format( "cmd.exe /C start \"Open file\" \"%s\"", new Object[] {this.fileLocation}); try { Runtime.getRuntime().exec(var2); return; } catch (IOException var6) { var6.printStackTrace(); } } boolean var8 = false; try { Class var3 = Class.forName("java.awt.Desktop"); Object var4 = var3.getMethod("getDesktop", new Class[0]).invoke((Object) null, new Object[0]); var3.getMethod("browse", new Class[] {URI.class}) .invoke( var4, new Object[] {(new File(Minecraft.getMinecraftDir(), "texturepacks")).toURI()}); } catch (Throwable var5) { var5.printStackTrace(); var8 = true; } if (var8) { this.mc.getLogAgent().logInfo("Opening via system class!"); Sys.openURL("file://" + this.fileLocation); } } else if (par1GuiButton.id == 6) { this.mc.displayGuiScreen(this.guiScreen); } else { this.guiTexturePackSlot.actionPerformed(par1GuiButton); } } }
protected void func_73875_a(GuiButton p_73875_1_) { if (p_73875_1_.field_73742_g) { if (p_73875_1_.field_73741_f == 5) { if (Minecraft.func_71376_c() == EnumOS.MACOS) { try { this.field_73882_e.func_98033_al().func_98233_a(this.field_73966_c); Runtime.getRuntime().exec(new String[] {"/usr/bin/open", this.field_73966_c}); return; } catch (IOException var7) { var7.printStackTrace(); } } else if (Minecraft.func_71376_c() == EnumOS.WINDOWS) { String var2 = String.format( "cmd.exe /C start \"Open file\" \"%s\"", new Object[] {this.field_73966_c}); try { Runtime.getRuntime().exec(var2); return; } catch (IOException var6) { var6.printStackTrace(); } } boolean var8 = false; try { Class var3 = Class.forName("java.awt.Desktop"); Object var4 = var3.getMethod("getDesktop", new Class[0]).invoke((Object) null, new Object[0]); var3.getMethod("browse", new Class[] {URI.class}) .invoke( var4, new Object[] {(new File(Minecraft.func_71380_b(), "texturepacks")).toURI()}); } catch (Throwable var5) { var5.printStackTrace(); var8 = true; } if (var8) { this.field_73882_e.func_98033_al().func_98233_a("Opening via system class!"); Sys.openURL("file://" + this.field_73966_c); } } else if (p_73875_1_.field_73741_f == 6) { this.field_73882_e.func_71373_a(this.field_73967_a); } else { this.field_73964_d.func_77219_a(p_73875_1_); } } }
public void run() { System.out.println("Hello LWJGL " + Sys.getVersion() + "!"); try { init(); loop(); // Release window and window callbacks glfwDestroyWindow(window); keyCallback.release(); } finally { // Terminate GLFW and release the GLFWerrorfun glfwTerminate(); errorCallback.release(); } }
/** * Get the Sound based on a specified OGG file * * @param ref The reference to the OGG file in the classpath * @param in The stream to the OGG to load * @return The Sound read from the OGG file * @throws IOException Indicates a failure to load the OGG */ public Audio getOgg(String ref, InputStream in) throws IOException { if (!soundWorks) { return new NullAudio(); } if (!inited) { throw new RuntimeException( "Can't load sounds until SoundStore is init(). Use the container init() method."); } if (deferred) { return new DeferredSound(ref, in, DeferredSound.OGG); } int buffer = -1; if (loaded.get(ref) != null) { buffer = ((Integer) loaded.get(ref)).intValue(); } else { try { IntBuffer buf = BufferUtils.createIntBuffer(1); OggDecoder decoder = new OggDecoder(); OggData ogg = decoder.getData(in); AL10.alGenBuffers(buf); AL10.alBufferData( buf.get(0), ogg.channels > 1 ? AL10.AL_FORMAT_STEREO16 : AL10.AL_FORMAT_MONO16, ogg.data, ogg.rate); loaded.put(ref, new Integer(buf.get(0))); buffer = buf.get(0); } catch (Exception e) { Log.error(e); Sys.alert("Error", "Failed to load: " + ref + " - " + e.getMessage()); throw new IOException("Unable to load: " + ref); } } if (buffer == -1) { throw new IOException("Unable to load: " + ref); } return new AudioImpl(this, buffer); }
private static void checkOpenGlCaps() { log(""); log(getVersion()); log("" + new Date()); log( "OS: " + System.getProperty("os.name") + " (" + System.getProperty("os.arch") + ") version " + System.getProperty("os.version")); log("Java: " + System.getProperty("java.version") + ", " + System.getProperty("java.vendor")); log( "VM: " + System.getProperty("java.vm.name") + " (" + System.getProperty("java.vm.info") + "), " + System.getProperty("java.vm.vendor")); log("LWJGL: " + Sys.getVersion()); log( "OpenGL: " + GL11.glGetString(GL11.GL_RENDERER) + " version " + GL11.glGetString(GL11.GL_VERSION) + ", " + GL11.glGetString(GL11.GL_VENDOR)); int var0 = getOpenGlVersion(); String var1 = "" + var0 / 10 + "." + var0 % 10; log("OpenGL Version: " + var1); if (!GLContext.getCapabilities().OpenGL12) { log("OpenGL Mipmap levels: Not available (GL12.GL_TEXTURE_MAX_LEVEL)"); } if (!GLContext.getCapabilities().GL_NV_fog_distance) { log("OpenGL Fancy fog: Not available (GL_NV_fog_distance)"); } if (!GLContext.getCapabilities().GL_ARB_occlusion_query) { log("OpenGL Occlussion culling: Not available (GL_ARB_occlusion_query)"); } }
protected void printContextInitInfo() { logger.log( Level.INFO, "Lwjgl {0} context running on thread {1}", new Object[] {Sys.getVersion(), Thread.currentThread().getName()}); logger.log(Level.INFO, "Adapter: {0}", Display.getAdapter()); logger.log(Level.INFO, "Driver Version: {0}", Display.getVersion()); String vendor = GL11.glGetString(GL11.GL_VENDOR); logger.log(Level.INFO, "Vendor: {0}", vendor); String version = GL11.glGetString(GL11.GL_VERSION); logger.log(Level.INFO, "OpenGL Version: {0}", version); String renderGl = GL11.glGetString(GL11.GL_RENDERER); logger.log(Level.INFO, "Renderer: {0}", renderGl); if (GLContext.getCapabilities().OpenGL20) { String shadingLang = GL11.glGetString(GL20.GL_SHADING_LANGUAGE_VERSION); logger.log(Level.INFO, "GLSL Ver: {0}", shadingLang); } }
public static void init(SpriteSheet sheet) { spritesheet = sheet; // Initialize Tile type Dictionary tileTypes = new HashMap<Integer, Tile>(); // Initialize Tile name Dictionaries tileNames = new HashMap<String, Integer>(); // Initialize Tile types try { fog = new Fog(FOG, "fog", sheet.getCustomTileTexture(5, 6, 5, 3)); addTile(new Tile(AIR, "air")); addTile(new Tile(NULL, "null", sheet.getTileTexture(9 * sheet.width))); addTile(new DirtTile(DIRT, "dirt", sheet.getCustomTileTexture(0, 0, 5, 3))); addTile(new MultitextureTile(GRASS, "grass", sheet.getCustomTileTexture(1, 9, 3, 1))); addTile(new LakeTile(LAKE, "lake", sheet.getCustomTileTexture(10, 3, 5, 3))); addTile(new SandTile(SAND, "sand", sheet.getCustomTileTexture(10, 0, 5, 3))); addTile(new RoadTile(COBBLESTONE_ROAD, "road", sheet.getCustomTileTexture(5, 0, 5, 3))); addTile( new SnowyGrassTile(SNOWY_GRASS, "snowy grass", sheet.getCustomTileTexture(0, 6, 5, 3))); addTile( new FrozenLakeTile(LAKE_FROZEN, "frozen lake", sheet.getCustomTileTexture(5, 3, 3, 3))); addTile(new MultitextureForegroundTile(TREE, "tree", sheet.getCustomTileTexture(4, 9, 2, 1))); addTile(new MultitextureForegroundTile(BUSH, "bush", sheet.getCustomTileTexture(6, 9, 1, 1))); addTile(new MultitextureForegroundTile(SIGN, "sign", sheet.getCustomTileTexture(7, 9, 3, 1))); addTile( new MultitextureForegroundTile(ROCK, "rock", sheet.getCustomTileTexture(11, 9, 1, 1))); addTile(new MountainTile(MOUNTAIN, "mountain", sheet.getCustomTileTexture(0, 3, 5, 3))); addTile(new PotTile(POT, "pot", sheet.getTileTexture(0 + 10 * sheet.width))); addTile( new BrokenPotTile(BROKEN_POT, "broken_pot", sheet.getTileTexture(1 + 10 * sheet.width))); } catch (IOException ex) { Sys.alert("TileLand", "Unable to load tiletypes!"); MenuManager.getMenuManager().openMenu("mainmenu"); } }
@Accessors(fluent = true) @Data public class Timer { public static final long ticksPerSecond = Sys.getTimerResolution(); @Setter(AccessLevel.NONE) private long start; @Setter(AccessLevel.NONE) private long elapsed; @Setter(AccessLevel.NONE) private long delta; public Timer() { reset(); } public void reset() { start = currentTimeInMilliseconds(); elapsed = 0; delta = 0; } public long tick() { final long oldElapsed = elapsed; elapsed = currentTimeInMilliseconds() - start; delta = elapsed - oldElapsed; return delta; } private long currentTimeInMilliseconds() { return (Sys.getTime() * 1000) / ticksPerSecond; } }
@Override public double Timer() { return (double) Sys.getTime() / Sys.getTimerResolution(); }
@Override public void transform(ItemStack itemstack, ItemRenderType type) { final EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; long var10 = this.spaceship.entityId * 493286711L; var10 = var10 * var10 * 4392167121L + var10 * 98761L; final float var12 = (((var10 >> 16 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; final float var13 = (((var10 >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; final float var14 = (((var10 >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; if (type == ItemRenderType.EQUIPPED) { if (itemstack.getItemDamage() >= 10) { GL11.glTranslatef(0.5F, 0.2F, 0F); } GL11.glRotatef(70, 1.0F, 0, 0); GL11.glRotatef(-10, 0.0F, 1, 0); GL11.glRotatef(50, 0.0F, 1, 1); GL11.glTranslatef(0F, 2.0F, 0F); GL11.glScalef(5.2F, 5.2F, 5.2F); if (itemstack.getItemDamage() >= 10) { GL11.glTranslatef(0F, 0.45F, 0F); GL11.glScalef(0.45F, 0.45F, 0.45F); } if (player != null && player.ridingEntity != null && player.ridingEntity instanceof GCCoreEntityRocketT1) { GL11.glScalef(0.0F, 0.0F, 0.0F); } } if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(-0.5F, 4.2F, 0F); if (itemstack.getItemDamage() >= 10) { GL11.glTranslatef(0F, 1.5F, -6.0F); } GL11.glRotatef(28, 0.0F, 0, 1); GL11.glRotatef(50 + 180, 0.0F, 1, 0); GL11.glRotatef(73, 1.0F, 0, 0); GL11.glScalef(5.2F, 5.2F, 5.2F); if (player != null && player.ridingEntity != null && player.ridingEntity instanceof GCCoreEntityRocketT1) { GL11.glScalef(0.0F, 0.0F, 0.0F); } } GL11.glTranslatef(var12, var13 - 0.1F, var14); GL11.glScalef(-0.4F, -0.4F, 0.4F); if (type == ItemRenderType.INVENTORY || type == ItemRenderType.ENTITY) { if (type == ItemRenderType.INVENTORY) { GL11.glRotatef(85F, 1F, 0F, 1F); GL11.glRotatef(20F, 1F, 0F, 0F); GL11.glScalef(0.9F, 0.9F, 0.9F); } else { GL11.glTranslatef(0, -0.9F, 0); GL11.glScalef(0.5F, 0.5F, 0.5F); } if (itemstack.getItemDamage() >= 10) { GL11.glRotatef(90F, 1F, 0F, 1F); GL11.glScalef(0.45F, 0.45F, 0.45F); GL11.glTranslatef(0, -0.9F, 0); GL11.glTranslatef(0, -0.9F, 0); GL11.glTranslatef(0, -0.9F, 0); } GL11.glScalef(1.3F, 1.3F, 1.3F); GL11.glTranslatef(0, -0.6F, 0); GL11.glRotatef( Sys.getTime() / 90F % 360F * (itemstack.getItemDamage() >= 10 ? -1 : 1), 0F, 1F, 0F); } }
@Override protected void actionPerformed(GuiButton button) { UpdateManagerMod mod = null; if (selected >= 0) mod = mods.get(getSelected()); if (button.enabled) switch (button.id) { case 0: { ModLoader.openGUI( ModLoader.getMinecraftInstance().thePlayer, new GuiModListWithUMButton(parentGui)); break; } case 1: { UpdateManager.openWebpage(UpdateManager.umWebpage); break; } case 2: { try { URL url = new URL("https://dl.dropbox.com/u/43671482/Update%20Manager/MotW.txt"); BufferedReader r = new BufferedReader(new InputStreamReader(url.openStream())); UpdateManager.openWebpage(r.readLine()); } catch (IOException e) { e.printStackTrace(); } break; } case 3: { ModLoader.openGUI(ModLoader.getMinecraftInstance().thePlayer, new GuiSettings(this)); break; } case 4: { UpdateManager.openWebpage(mod.getModURL()); break; } case 5: { ModLoader.openGUI( ModLoader.getMinecraftInstance().thePlayer, new GuiChangelog(this, mod)); break; } case 6: { if (mod.getDisclaimerURL() == null) { if (!ThreadDownloadMod.downloadings.contains(mod.getModName())) { new ThreadDownloadMod(mod.getDirectDownloadURL(), mod); button.enabled = false; } } else ModLoader.openGUI( ModLoader.getMinecraftInstance().thePlayer, new GuiDisclaimer(this, mod)); break; } case 7: { Sys.openURL( "file://" + new File(Minecraft.getMinecraftDir(), "downloadedMods").getAbsolutePath()); break; } case 8: { mod.onSpecialButtonClicked(); break; } } super.actionPerformed(button); }
/** * Get the time in milliseconds * * @return The system time in milliseconds */ private long getTime() { return (Sys.getTime() * 1000) / Sys.getTimerResolution(); }
/** @see AbstractComponent#keyPressed(int, char) */ public void keyPressed(int key, char c) { if (hasFocus()) { if (key != -1) { if ((key == Input.KEY_V) && ((input.isKeyDown(Input.KEY_LCONTROL)) || (input.isKeyDown(Input.KEY_RCONTROL)))) { String text = Sys.getClipboard(); if (text != null) { doPaste(text); } return; } if ((key == Input.KEY_Z) && ((input.isKeyDown(Input.KEY_LCONTROL)) || (input.isKeyDown(Input.KEY_RCONTROL)))) { if (oldText != null) { doUndo(oldCursorPos, oldText); } return; } // alt and control keys don't come through here if (input.isKeyDown(Input.KEY_LCONTROL) || input.isKeyDown(Input.KEY_RCONTROL)) { return; } if (input.isKeyDown(Input.KEY_LALT) || input.isKeyDown(Input.KEY_RALT)) { return; } } if (lastKey != key) { lastKey = key; repeatTimer = System.currentTimeMillis() + INITIAL_KEY_REPEAT_INTERVAL; } else { repeatTimer = System.currentTimeMillis() + KEY_REPEAT_INTERVAL; } lastChar = c; if (key == Input.KEY_LEFT) { if (cursorPos > 0) { cursorPos--; } // Nobody more will be notified if (consume) { container.getInput().consumeEvent(); } } else if (key == Input.KEY_RIGHT) { if (cursorPos < value.length()) { cursorPos++; } // Nobody more will be notified if (consume) { container.getInput().consumeEvent(); } } else if (key == Input.KEY_BACK) { if ((cursorPos > 0) && (value.length() > 0)) { if (cursorPos < value.length()) { value = value.substring(0, cursorPos - 1) + value.substring(cursorPos); } else { value = value.substring(0, cursorPos - 1); } cursorPos--; } // Nobody more will be notified if (consume) { container.getInput().consumeEvent(); } } else if (key == Input.KEY_DELETE) { if (value.length() > cursorPos) { value = value.substring(0, cursorPos) + value.substring(cursorPos + 1); } // Nobody more will be notified if (consume) { container.getInput().consumeEvent(); } } else if ((c < 127) && (c > 31) && (value.length() < maxCharacter)) { if (cursorPos < value.length()) { value = value.substring(0, cursorPos) + c + value.substring(cursorPos); } else { value = value.substring(0, cursorPos) + c; } cursorPos++; // Nobody more will be notified if (consume) { container.getInput().consumeEvent(); } } else if (key == Input.KEY_RETURN) { notifyListeners(); // Nobody more will be notified if (consume) { container.getInput().consumeEvent(); } } } }