Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void setInGameScreenSize(int width, int height) {
- int widthDif = Window.getWindows()[0].getWidth() - Display.getParent().getWidth();
- int heightDif = Window.getWindows()[0].getHeight() - Display.getParent().getHeight();
- if (Display.isFullscreen()) {
- try {
- int x = 100000;
- int y = 100000;
- DisplayMode mode = null;
- for (DisplayMode dm : Display.getAvailableDisplayModes()) {
- if ((Math.abs(dm.getWidth() - width) <= x) && (Math.abs(dm.getHeight() - height) <= y)) {
- x = Math.abs(dm.getWidth() - width);
- y = Math.abs(dm.getHeight() - height);
- mode = dm;
- }
- }
- for (DisplayMode dm : Display.getAvailableDisplayModes())
- if ((Math.abs(dm.getWidth() - width) == x) && (Math.abs(dm.getHeight() - height) == y) && mode.getBitsPerPixel() <= dm.getBitsPerPixel()
- && mode.getFrequency() <= dm.getFrequency())
- mode = dm;
- if (mode != null) {
- Display.setDisplayMode(mode);
- mc.displayWidth = Display.getDisplayMode().getWidth();
- mc.displayHeight = Display.getDisplayMode().getHeight();
- if (mc.displayWidth <= 0)
- mc.displayWidth = 1;
- if (mc.displayHeight <= 0)
- mc.displayHeight = 1;
- Display.update();
- Method method = null;
- try {
- method = Minecraft.class.getDeclaredMethod("a", int.class, int.class);
- }
- catch (NoSuchMethodException e) {
- try {
- method = Minecraft.class.getDeclaredMethod("resize", int.class, int.class);
- }
- catch (NoSuchMethodException e1) {
- }
- }
- if (method != null) {
- method.setAccessible(true);
- method.invoke(mc, mc.displayWidth, mc.displayHeight);
- }
- }
- }
- catch (LWJGLException e) {
- e.printStackTrace();
- }
- catch (IllegalArgumentException e) {
- e.printStackTrace();
- }
- catch (SecurityException e) {
- e.printStackTrace();
- }
- catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- }
- else {
- if (width == 10000 && height == 10000)
- Frame.getFrames()[0].setExtendedState(Frame.MAXIMIZED_BOTH);
- Window.getWindows()[0].setSize(width + widthDif, height + heightDif);
- }
- }
Advertisement