@Override public String getText() { if (Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().theWorld.getWorldInfo().isHardcoreModeEnabled()) { return "Difficulty: Hardcore"; } String difficulty; switch (Minecraft.getMinecraft().gameSettings.difficulty) { case 0: difficulty = "Peaceful"; break; case 1: difficulty = "Easy"; break; case 2: difficulty = "Normal"; break; case 3: difficulty = "Hard"; break; default: difficulty = "Unknown"; break; } return "Difficulty: " + difficulty; }
/** Check if a render is necessary, and if so, do one. */ private void tryARender() { if (Minecraft.getMinecraft().thePlayer == null || Minecraft.getMinecraft().theWorld == null) return; try { double x = Minecraft.getMinecraft().thePlayer.posX; double z = Minecraft.getMinecraft().thePlayer.posZ; if (MinimapConfig.getInstance().isEnabled() && map.isDirty(x, z)) { // long start = System.currentTimeMillis(); if (MinimapConfig.getInstance().getScanRadius() > 0) { int radius = MinimapConfig.getInstance().getScanRadius() << 4; for (int cx = (int) (x - radius); cx <= (int) (x + radius); cx += 16) { for (int cz = (int) (z - radius); cz <= (int) (z + radius); cz += 16) { Chunk chunk = Minecraft.getMinecraft().theWorld.getChunkFromBlockCoords((int) cx, (int) cz); org.spoutcraft.client.chunkcache.HeightMapAgent.scanChunk(chunk); } } } // long dur = System.currentTimeMillis() - start; // int chunks = (int) Math.pow(MinimapConfig.getInstance().getScanRadius() * 2, 2); // System.out.println("Took " + dur + "ms to scan " + chunks + " chunks.\nThat is " + // (float) (dur/(float)chunks) + " per chunk!"); mapCalc(); entityCalc(); map.timer = 1; } } catch (RuntimeException e) { throw e; } finally { map.timer++; } }
@Override public void onButtonClick() { Minecraft.getMinecraft().gameSettings.difficulty++; if (Minecraft.getMinecraft().gameSettings.difficulty > 3) { Minecraft.getMinecraft().gameSettings.difficulty = 0; } Minecraft.getMinecraft().gameSettings.saveOptions(); }
private final int getBlockHeight(World world, int x, int z) { if (MinimapConfig.getInstance().isCavemap()) { Chunk chunk = world.getChunkFromBlockCoords(x, z); cmdist.setSeed((x & 0xffff) | ((z & 0xffff) << 16)); float dist = distance( (int) Minecraft.getMinecraft().thePlayer.posX, (int) Minecraft.getMinecraft().thePlayer.posZ, x, z); int y = (int) Minecraft.getMinecraft().thePlayer.posY; if (dist > 5) y -= (cmdist.nextInt((int) (dist)) - ((int) dist / 2)); x &= 0xf; z &= 0xf; if (y < 0) { y = 0; } else if (y > 255) { y = 255; } if (blockIsSolid(chunk, x, y, z)) { int itery = y; while (true) { itery++; if (itery > y + 10) return y + 10; if (!blockIsSolid(chunk, x, itery, z)) { return itery - 1; } } } while (y > -1) { y--; if (blockIsSolid(chunk, x, y, z)) { return y; } } return -1; } return world.getHeightValue(x, z) - 1; // return world.b(x, z).b(x & 0xf, z & 0xf); /* * li chunk = world.b(x, z); int y = (int)(game.h.aM); // starty; x &= * 0xf; z &= 0xf; * * //while (y > 0) // { * * * if (getBlockColor(id, meta).alpha == 0) return -1; // y--; else return * y + 1; // what //} */ // return -1; }
@Override public boolean isEnabled() { if (Minecraft.getMinecraft().theWorld == null) { return false; } if (!Minecraft.getMinecraft().isSingleplayer()) { return false; } if (Minecraft.getMinecraft().theWorld.getWorldInfo().isHardcoreModeEnabled()) { return false; } return true; }
@Override public String getTooltip() { if (Minecraft.getMinecraft().theWorld == null) { return "Can not change difficulty outside of the game"; } if (!Minecraft.getMinecraft().isSingleplayer()) { return "Can not change difficulty in multiplayer"; } if (Minecraft.getMinecraft().theWorld.getWorldInfo().isHardcoreModeEnabled()) { return "Can not change difficulty in hardcore mode"; } return super.getTooltip(); }
/** * 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); } } }
/** Attempts to find a config If there is one load it If there is not one create one */ private void loadConfig() { config = new Properties(defaults); try { configPath = Minecraft.getMinecraft().mcDataDir.getCanonicalPath() + File.separatorChar + "config" + File.separatorChar + "ServerListFolder" + File.separatorChar; File cfg = new File(configPath + "ServerListFolder.cfg"); if (cfg.exists()) { ServerListFolder.info("Config file found, loading..."); config.load(new FileInputStream(configPath + "ServerListFolder.cfg")); } else { ServerListFolder.info("No config file found, creating..."); createConfig(cfg); } } catch (Exception e) { ServerListFolder.warn(e.toString()); } }
@Override protected void keyTyped(char par1, int par2) { if (par2 == Keyboard.KEY_ESCAPE) { if (mod_Undercast.CONFIG.showGSClass && UndercastData.currentGSClass.equals("Unknown") && UndercastData.currentServerType == ServerType.ghostsquadron) { Minecraft.getMinecraft().thePlayer.sendChatMessage("/class"); } mc.displayGuiScreen(null); return; } }
/** Init the mod */ private void modInit() { // TODO: Mod initialization. modinstance = this; update(); guiStatesFile = new File(minecraft.mcDataDir, "/Cheating Essentials/gui.coords"); xrayBlocks = new File(minecraft.mcDataDir, "/Cheating Essentials/BlockList.txt"); CELogAgent.logInfo( Strings.MOD_NAME + " " + Strings.MOD_VERSION + " " + "starting in" + " " + Strings.MINECRAFT_VERSION + "..."); if (debugMode) { System.out.println( "You only can view this messages if you're viewing the code, using it, or anything else - Debugging and misc. system info."); CELogAgent.logInfo(Strings.MOD_AVALIABLE_MODULES); CELogAgent.logInfo("Instance Started in (Miliseconds): " + System.currentTimeMillis() / 1000); // WHY IT IS NOT IMPLEMENTED TO VANILLA MC :/ CELogAgent.logInfo("Open GL version: " + GL11.glGetString(GL11.GL_VERSION)); CELogAgent.logInfo("Open GL vendor: " + GL11.glGetString(GL11.GL_VENDOR)); System.out.println("I hate the Integrated Server! :("); } run(); mainModLoader = new ModManager(this); modUtils = new Utils(minecraft); MainGui = new ModuleGui(); minecraft = Minecraft.getMinecraft(); now = System.currentTimeMillis(); then = now + 250; modKeyManager = new KeyManager(); theConsoleHelper = new ConsoleHelper(); keys = new HashMap<Mod, Integer>(); theFriendManager = new FrenemyManager(); getModWrapper = new Wrapper(); CELogAgent.logInfo("Basic init finished with no errors."); for (Mod m : mainModLoader.mods) { keys.put(m, m.keyBind); } CELogAgent.logInfo( Strings.MOD_NAME + " " + Strings.MOD_VERSION + " started succefully in " + Strings.MINECRAFT_VERSION); }
/** Adds the buttons (and other controls) to the screen in question. */ public void initGui() { StringTranslate var1 = StringTranslate.getInstance(); this.buttonList.add( new GuiFancyButton( 5, this.width / 2 - 74, this.height - 48, var1.translateKey("texturePack.openFolder"), 3)); this.buttonList.add( new GuiFancyButton( 6, this.width / 2 + 74, this.height - 48, var1.translateKey("gui.done"), 3)); this.mc.texturePackList.updateAvaliableTexturePacks(); this.fileLocation = (new File(Minecraft.getMinecraftDir(), "texturepacks")).getAbsolutePath(); this.guiTexturePackSlot = new GuiFancyTexturePackSlot(this); this.guiTexturePackSlot.registerScrollButtons(this.buttonList, 7, 8); bg = new GuiFancyRotatingBackground(mc, width, height, zLevel); }
/** Handle GUI key press. */ @ModProp @Override public void handleKeyPress() { // TODO Keys if (KeyBinding.checkKey(Keyboard.KEY_G)) { minecraft.displayGuiScreen(MainGui); if (KeyBinding.checkKey(Keyboard.KEY_X)) { if (KeyBinding.checkKey(Keyboard.KEY_F)) { for (Map.Entry<Mod, Integer> e : keys.entrySet()) { if (KeyBinding.checkKey(e.getKey().keyBind)) { e.getKey().toggle(); } } } } } }
@Override protected void actionPerformed(GuiButton guibutton) { // If the button is clicked, toggle and save the setting if (guibutton instanceof SettingsToggleButton) { SettingsToggleButton button = (SettingsToggleButton) guibutton; button.buttonPressed(); } else if (guibutton.id == 15) { this.pageIndex++; this.buttonList.clear(); this.initGui(); } else if (guibutton.id == 16) { this.pageIndex--; this.buttonList.clear(); this.initGui(); } else { if (mod_Undercast.CONFIG.showGSClass && UndercastData.currentGSClass.equals("Unknown") && UndercastData.currentServerType == ServerType.ghostsquadron) { Minecraft.getMinecraft().thePlayer.sendChatMessage("/class"); } ModLoader.openGUI(mc.thePlayer, parentScreen); } }
public static void handleKeyboardInputs(Minecraft mc) { // TODO: Capture oculus key events if (mc.headTracker == null || mc.hmdInfo == null) { return; } // Reinitialise head tracking if (Keyboard.getEventKey() == Keyboard.KEY_O && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { PluginManager.destroyAll(); mc.setUseVRRenderer(mc.vrSettings.useVRRenderer); } // Distortion on / off if (Keyboard.getEventKey() == Keyboard.KEY_P && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { // Chromatic ab correction if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { mc.vrSettings.useChromaticAbCorrection = !mc.vrSettings.useChromaticAbCorrection; mc.vrSettings.saveOptions(); mc.vrRenderer._FBOInitialised = false; // Reinit FBO and shaders } else { mc.vrSettings.useDistortion = !mc.vrSettings.useDistortion; } } // Supersampling on/off if (Keyboard.getEventKey() == Keyboard.KEY_B && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { // FSAA on/off if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { mc.vrSettings.superSampleScaleFactor += 0.5f; if (mc.vrSettings.superSampleScaleFactor > 4.0f) { mc.vrSettings.superSampleScaleFactor = 1.5f; } mc.vrSettings.saveOptions(); mc.vrRenderer._FBOInitialised = false; } else { mc.vrSettings.useSupersample = !mc.vrSettings.useSupersample; mc.vrSettings.saveOptions(); mc.vrRenderer._FBOInitialised = false; // Reinit FBO and shaders } } // Head tracking on / off if (Keyboard.getEventKey() == Keyboard.KEY_L && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { mc.vrSettings.useHeadTrackPrediction = !mc.vrSettings.useHeadTrackPrediction; mc.headTracker.setPrediction( mc.vrSettings.headTrackPredictionTimeSecs, mc.vrSettings.useHeadTrackPrediction); mc.vrSettings.saveOptions(); } else { mc.vrSettings.useHeadTracking = !mc.vrSettings.useHeadTracking; } } // Lock distance if (Keyboard.getEventKey() == Keyboard.KEY_U && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { // HUD scale if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { mc.vrSettings.hudScale -= 0.01f; if (mc.vrSettings.hudScale < 0.15f) { mc.vrSettings.hudScale = 1.25f; } mc.vrSettings.saveOptions(); } else { mc.vrSettings.hudDistance -= 0.01f; if (mc.vrSettings.hudDistance < 0.15f) { mc.vrSettings.hudDistance = 1.25f; } mc.vrSettings.saveOptions(); // mc.vrSettings.lockHud = !mc.vrSettings.lockHud; // TOOD: HUD lock removed for now } } // Hud opacity on / off if (Keyboard.getEventKey() == Keyboard.KEY_Y && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { mc.vrSettings.hudOpacity = 1 - mc.vrSettings.hudOpacity; if (mc.vrSettings.hudOpacity < 0.15f) mc.vrSettings.hudOpacity = 0.15f; mc.vrSettings.saveOptions(); } // Render headwear / ON/off if (Keyboard.getEventKey() == Keyboard.KEY_M && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { mc.vrSettings.renderHeadWear = !mc.vrSettings.renderHeadWear; mc.vrSettings.saveOptions(); } // Allow mouse pitch if (Keyboard.getEventKey() == Keyboard.KEY_N && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { mc.vrSettings.allowMousePitchInput = !mc.vrSettings.allowMousePitchInput; mc.vrSettings.saveOptions(); } // FOV+ if (Keyboard.getEventKey() == Keyboard.KEY_PERIOD && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { // Distortion fit point mc.vrSettings.distortionFitPoint += 1; if (mc.vrSettings.distortionFitPoint > 14) mc.vrSettings.distortionFitPoint = 14; mc.vrSettings.saveOptions(); mc.vrRenderer._FBOInitialised = false; // Reinit FBO and shaders } else { // FOV mc.vrSettings.fovScaleFactor += 0.001f; mc.vrSettings.saveOptions(); } } // FOV- if (Keyboard.getEventKey() == Keyboard.KEY_COMMA && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { // Distortion fit point mc.vrSettings.distortionFitPoint -= 1; if (mc.vrSettings.distortionFitPoint < 0) mc.vrSettings.distortionFitPoint = 0; mc.vrSettings.saveOptions(); mc.vrRenderer._FBOInitialised = false; // Reinit FBO and shaders } else { // FOV mc.vrSettings.fovScaleFactor -= 0.001f; mc.vrSettings.saveOptions(); } } // Cycle head track sensitivity if (Keyboard.getEventKey() == Keyboard.KEY_V && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { mc.vrSettings.headTrackSensitivity += 0.1f; if (mc.vrSettings.headTrackSensitivity > 4.05f) { mc.vrSettings.headTrackSensitivity = 0.5f; } mc.vrSettings.saveOptions(); } // Increase IPD if (Keyboard.getEventKey() == Keyboard.KEY_EQUALS && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { float newIpd; if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { newIpd = mc.vrSettings.getIPD() + 0.0001f; } else { newIpd = mc.vrSettings.getIPD() + 0.0005f; } mc.hmdInfo.setIPD(newIpd); mc.vrSettings.setMinecraftIpd(newIpd); mc.vrSettings.saveOptions(); } // Decrease IPD if (Keyboard.getEventKey() == Keyboard.KEY_MINUS && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { float newIpd; if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { newIpd = mc.vrSettings.getIPD() - 0.0001f; } else { newIpd = mc.vrSettings.getIPD() - 0.0005f; } mc.hmdInfo.setIPD(newIpd); mc.vrSettings.setMinecraftIpd(newIpd); mc.vrSettings.saveOptions(); } // Render full player model or just an disembodied hand... if (Keyboard.getEventKey() == Keyboard.KEY_H && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { mc.vrSettings.renderFullFirstPersonModel = !mc.vrSettings.renderFullFirstPersonModel; mc.vrSettings.saveOptions(); } // Reset positional track origin if (Keyboard.getEventKey() == Keyboard.KEY_RETURN && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { mc.vrSettings.posTrackResetPosition = true; } // If an orientation plugin is performing calibration, space also sets the origin if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) { PluginManager.notifyAll(IOrientationProvider.EVENT_ORIENTATION_AT_ORIGIN); } }
/** Called each tick of the render. */ void onRenderTick() { if (Minecraft.getMinecraft() != null && Minecraft.getMinecraft().theWorld != null) { tryARender(); } }
public static void handleKeyboardInputs(Minecraft mc) { // TODO: Capture oculus key events if (mc.headTracker == null || mc.hmdInfo == null) { return; } // Reinitialise head tracking if (Keyboard.getEventKey() == Keyboard.KEY_O && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { PluginManager.destroyAll(); mc.setUseVRRenderer(mc.vrSettings.useVRRenderer); mc.printChatMessage("Re-initialising all plugins..."); } // Distortion on / off if (Keyboard.getEventKey() == Keyboard.KEY_P && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { // Chromatic ab correction if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { mc.vrSettings.useChromaticAbCorrection = !mc.vrSettings.useChromaticAbCorrection; mc.vrSettings.saveOptions(); mc.vrRenderer._FBOInitialised = false; // Reinit FBO and shaders if (mc.vrSettings.useChromaticAbCorrection) mc.printChatMessage("Chromatic Aberration Correction ON"); else mc.printChatMessage("Chromatic Aberration Correction OFF"); } else { if (mc.vrSettings.useDistortion == false) { mc.vrSettings.useDistortion = true; mc.vrSettings.useDistortionTextureLookupOptimisation = false; mc.printChatMessage("Distortion ON [Brute Force]"); } else if (mc.vrSettings.useDistortion == true && mc.vrSettings.useDistortionTextureLookupOptimisation == false) { mc.vrSettings.useDistortion = true; mc.vrSettings.useDistortionTextureLookupOptimisation = true; mc.printChatMessage("Distortion ON [Texture Lookup]"); } else { mc.vrSettings.useDistortion = false; mc.vrSettings.useDistortionTextureLookupOptimisation = false; mc.printChatMessage("Distortion OFF"); } mc.vrSettings.saveOptions(); mc.vrRenderer._FBOInitialised = false; // Reinit FBO and shaders } } // Supersampling on/off if (Keyboard.getEventKey() == Keyboard.KEY_B && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { // FSAA on/off if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { mc.vrSettings.superSampleScaleFactor += 0.5f; if (mc.vrSettings.superSampleScaleFactor > 4.0f) { mc.vrSettings.superSampleScaleFactor = 1.5f; } mc.vrSettings.saveOptions(); mc.vrRenderer._FBOInitialised = false; mc.printChatMessage( String.format( "FSAA scale factor: %.1f", new Object[] {Float.valueOf(mc.vrSettings.superSampleScaleFactor)})); } else { mc.vrSettings.useSupersample = !mc.vrSettings.useSupersample; mc.vrSettings.saveOptions(); mc.vrRenderer._FBOInitialised = false; // Reinit FBO and shaders mc.printChatMessage("FSAA: " + (mc.vrSettings.useSupersample ? "On" : "Off")); } } // Head tracking on / off if (Keyboard.getEventKey() == Keyboard.KEY_L && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { mc.vrSettings.useHeadTrackPrediction = !mc.vrSettings.useHeadTrackPrediction; mc.headTracker.setPrediction( mc.vrSettings.headTrackPredictionTimeSecs, mc.vrSettings.useHeadTrackPrediction); mc.vrSettings.saveOptions(); if (mc.vrSettings.useHeadTrackPrediction) mc.printChatMessage( String.format( "Head tracking prediction: On (%.2fms)", new Object[] {Float.valueOf(mc.vrSettings.headTrackPredictionTimeSecs * 1000)})); else mc.printChatMessage("Head tracking prediction: Off"); } else { mc.vrSettings.useHeadTracking = !mc.vrSettings.useHeadTracking; mc.printChatMessage("Head tracking: " + (mc.vrSettings.useHeadTracking ? "On" : "Off")); } } // Lock distance if (Keyboard.getEventKey() == Keyboard.KEY_U && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { // HUD scale if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { mc.vrSettings.hudScale -= 0.01f; if (mc.vrSettings.hudScale < 0.15f) { mc.vrSettings.hudScale = 1.25f; } mc.vrSettings.saveOptions(); mc.printChatMessage( String.format("HUD scale: %.2f", new Object[] {Float.valueOf(mc.vrSettings.hudScale)})); } else { mc.vrSettings.hudDistance -= 0.01f; if (mc.vrSettings.hudDistance < 0.15f) { mc.vrSettings.hudDistance = 1.25f; } mc.vrSettings.saveOptions(); mc.printChatMessage( String.format( "HUD distance: %.2f", new Object[] {Float.valueOf(mc.vrSettings.hudDistance)})); } } // Hud opacity on / off if (Keyboard.getEventKey() == Keyboard.KEY_Y && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { mc.vrSettings.hudOpacity = 1 - mc.vrSettings.hudOpacity; if (mc.vrSettings.hudOpacity < 0.15f) mc.vrSettings.hudOpacity = 0.15f; mc.vrSettings.saveOptions(); mc.printChatMessage( String.format( "HUD opacity: %.2f%%", new Object[] {Float.valueOf(mc.vrSettings.hudOpacity)})); } // Render headwear / ON/off if (Keyboard.getEventKey() == Keyboard.KEY_M && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { mc.vrSettings.renderHeadWear = !mc.vrSettings.renderHeadWear; mc.vrSettings.saveOptions(); mc.printChatMessage("Render headwear: " + (mc.vrSettings.renderHeadWear ? "On" : "Off")); } // Allow mouse pitch if (Keyboard.getEventKey() == Keyboard.KEY_N && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { mc.vrSettings.allowMousePitchInput = !mc.vrSettings.allowMousePitchInput; mc.vrSettings.saveOptions(); mc.printChatMessage( "Allow mouse pitch input: " + (mc.vrSettings.allowMousePitchInput ? "On" : "Off")); } // FOV+ if (Keyboard.getEventKey() == Keyboard.KEY_PERIOD && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { // Distortion fit point mc.vrSettings.distortionFitPoint += 1; if (mc.vrSettings.distortionFitPoint > 14) mc.vrSettings.distortionFitPoint = 14; mc.vrSettings.saveOptions(); mc.vrRenderer._FBOInitialised = false; // Reinit FBO and shaders mc.printChatMessage( String.format( "Distortion fit point: %.0f", new Object[] {Float.valueOf(mc.vrSettings.distortionFitPoint)})); } else { // FOV mc.vrSettings.fovScaleFactor += 0.001f; mc.vrSettings.saveOptions(); mc.vrRenderer._FBOInitialised = false; // Reinit FBO and shaders mc.printChatMessage( String.format( "FOV scale factor: %.3f", new Object[] {Float.valueOf(mc.vrSettings.fovScaleFactor)})); } } // FOV- if (Keyboard.getEventKey() == Keyboard.KEY_COMMA && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { // Distortion fit point mc.vrSettings.distortionFitPoint -= 1; if (mc.vrSettings.distortionFitPoint < 0) mc.vrSettings.distortionFitPoint = 0; mc.vrSettings.saveOptions(); mc.vrRenderer._FBOInitialised = false; // Reinit FBO and shaders mc.printChatMessage( String.format( "Distortion fit point: %.0f", new Object[] {Float.valueOf(mc.vrSettings.distortionFitPoint)})); } else { // FOV mc.vrSettings.fovScaleFactor -= 0.001f; mc.vrSettings.saveOptions(); mc.vrRenderer._FBOInitialised = false; // Reinit FBO and shaders mc.printChatMessage( String.format( "FOV scale factor: %.3f", new Object[] {Float.valueOf(mc.vrSettings.fovScaleFactor)})); } } // Cycle head track sensitivity if (Keyboard.getEventKey() == Keyboard.KEY_V && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { mc.vrSettings.headTrackSensitivity += 0.1f; if (mc.vrSettings.headTrackSensitivity > 4.05f) { mc.vrSettings.headTrackSensitivity = 0.5f; } mc.vrSettings.saveOptions(); mc.printChatMessage( String.format( "Head track sensitivity: * %.1f", new Object[] {Float.valueOf(mc.vrSettings.headTrackSensitivity)})); } // Increase IPD if (Keyboard.getEventKey() == Keyboard.KEY_EQUALS && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { if (mc.vrSettings.useOculusProfile) { mc.printChatMessage("IPD unchanged (set via Oculus Profile)"); } else { float newIpd; if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { newIpd = mc.vrSettings.getIPD() + 0.0005f; } else { newIpd = mc.vrSettings.getIPD() + 0.0001f; } mc.hmdInfo.setIPD(newIpd); mc.vrSettings.setMinecraftIpd(newIpd); mc.vrSettings.saveOptions(); mc.vrRenderer._FBOInitialised = false; // Reinit FBO and shaders mc.printChatMessage( String.format( "IPD: %.1fmm", new Object[] {Float.valueOf(mc.vrSettings.getIPD() * 1000f)})); } } // Decrease IPD if (Keyboard.getEventKey() == Keyboard.KEY_MINUS && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { if (mc.vrSettings.useOculusProfile) { mc.printChatMessage("IPD unchanged (set via Oculus Profile)"); } else { float newIpd; if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { newIpd = mc.vrSettings.getIPD() - 0.0005f; } else { newIpd = mc.vrSettings.getIPD() - 0.0001f; } mc.hmdInfo.setIPD(newIpd); mc.vrSettings.setMinecraftIpd(newIpd); mc.vrSettings.saveOptions(); mc.vrRenderer._FBOInitialised = false; // Reinit FBO and shaders mc.printChatMessage( String.format( "IPD: %.1fmm", new Object[] {Float.valueOf(mc.vrSettings.getIPD() * 1000f)})); } } // Render full player model or just an disembodied hand... if (Keyboard.getEventKey() == Keyboard.KEY_H && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { mc.vrSettings.renderFullFirstPersonModel = !mc.vrSettings.renderFullFirstPersonModel; mc.vrSettings.saveOptions(); mc.printChatMessage( "First person model: " + (mc.vrSettings.renderFullFirstPersonModel ? "Full" : "Hand only")); } // Reset positional track origin if (Keyboard.getEventKey() == Keyboard.KEY_RETURN && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { mc.vrSettings.posTrackResetPosition = true; mc.printChatMessage("Reset origin: done"); } // If an orientation plugin is performing calibration, space also sets the origin if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) { PluginManager.notifyAll(IOrientationProvider.EVENT_ORIENTATION_AT_ORIGIN); } }
private void mapCalc() { if (Minecraft.getMinecraft().thePlayer == null || Minecraft.getMinecraft().theWorld == null) return; try { final boolean square = MinimapConfig.getInstance().isSquare(); final World data = Minecraft.getMinecraft().theWorld; int renderSize; int startX; int startZ; synchronized (map) { if (map.zoom != MinimapConfig.getInstance().getZoom()) { map.zoom = MinimapConfig.getInstance().getZoom(); switch (map.zoom) { case 0: map.renderSize = Map.ZOOM_0; break; case 1: map.renderSize = Map.ZOOM_1; break; case 2: map.renderSize = Map.ZOOM_2; break; default: map.renderSize = Map.ZOOM_2; break; } map.renderOff = map.renderSize / 2; map.clear(); } map.square = square; map.update( Minecraft.getMinecraft().thePlayer.posX, Minecraft.getMinecraft().thePlayer.posZ); renderSize = map.renderSize; startX = (int) (map.getPlayerX() - map.renderOff); startZ = (int) (map.getPlayerZ() - map.renderOff); } for (int worldX = startX; worldX < startX + renderSize; worldX++) { for (int worldZ = startZ; worldZ < startZ + renderSize; worldZ++) { int worldY = getBlockHeight(data, worldX, worldZ); int pixelX = worldX - startX; if (pixelX >= renderSize) { pixelX -= renderSize; } int pixelZ = worldZ - startZ; pixelZ = renderSize - pixelZ; if (pixelZ >= renderSize) { pixelZ -= renderSize; } if (square || MinimapUtils.insideCircle( startX + renderSize / 2, startZ + renderSize / 2, renderSize / 2, worldX, worldZ)) { int color = getBlockColor(data, worldX, worldY, worldZ); if (color == 0) { map.clearColorPixel(pixelX, pixelZ); } else { map.setColorPixel(pixelX, pixelZ, color); } short height = (short) data.getHeightValue(worldX, worldZ); short reference = (short) data.getHeightValue(worldX + 1, worldZ + 1); map.heightimg.setARGB(pixelZ, pixelX, getHeightColor(height, reference)); map.setLightPixel(pixelX, pixelZ, getBlockLight(data, worldX, worldY, worldZ)); } else { map.clearColorPixel(pixelX, pixelZ); map.heightimg.setARGB(pixelX, pixelZ, 0); map.setLightPixel(pixelX, pixelZ, 255); } } } synchronized (map) { for (Waypoint pt : MinimapConfig.getInstance().getWaypoints(MinimapUtils.getWorldName())) { if (pt.enabled) { boolean render = false; if (square) { render = Math.abs(map.getPlayerX() - pt.x) < map.renderSize && Math.abs(map.getPlayerZ() - pt.z) < map.renderSize; } else { render = MinimapUtils.insideCircle( startX + map.renderSize / 2, startZ + map.renderSize / 2, map.renderSize / 2, pt.x, pt.z); } if (pt.deathpoint && !MinimapConfig.getInstance().isDeathpoints()) { render = false; } if (render) { int pixelX = pt.x - startX; int pixelZ = pt.z - startZ; pixelZ = map.renderSize - pixelZ; int scale = map.zoom + 2; if (map.zoom > 2) { scale += 2; } if (map.zoom > 1) { scale += 1; } int color = 0xEE2C2C; if (pt == MinimapConfig.getInstance().getFocussedWaypoint()) { color = 0xff00ffff; } drawCircle(pixelX, pixelZ, scale + map.zoom + 1, pt.deathpoint ? color : 0); drawCircle(pixelX, pixelZ, scale, pt.deathpoint ? 0 : color); } } } for (Waypoint pt : MinimapConfig.getInstance().getServerWaypoints()) { boolean render = false; if (square) { render = Math.abs(map.getPlayerX() - pt.x) < map.renderSize && Math.abs(map.getPlayerZ() - pt.z) < map.renderSize; } else { render = MinimapUtils.insideCircle( startX + map.renderSize / 2, startZ + map.renderSize / 2, map.renderSize / 2, pt.x, pt.z); } if (render) { int pixelX = pt.x - startX; int pixelZ = pt.z - startZ; pixelZ = map.renderSize - pixelZ; int scale = map.zoom + 2; if (map.zoom > 2) { scale += 2; } if (map.zoom > 1) { scale += 1; } int color = 0x3366CC; if (pt == MinimapConfig.getInstance().getFocussedWaypoint()) { color = 0xff00ffff; } drawCircle(pixelX, pixelZ, scale + map.zoom + 1, 0); drawCircle(pixelX, pixelZ, scale, color); } } } } catch (Throwable whatever) { } }