diff --git a/minecriftversion.py b/minecriftversion.py index 7497d6f..db48627 100644 --- a/minecriftversion.py +++ b/minecriftversion.py @@ -4,7 +4,7 @@ of_json_name = "1.10.2_HD_U_D8" of_file_md5 = "d2a99a8d96d1067cb9e384bbdc560c70" minecrift_version_num = "1.10.2" -minecrift_build = "jrbudda-10pre5" +minecrift_build = "jrbudda-10pre7" of_file_extension = ".jar" mcp_version = "mcp931" mcp_uses_generics = True diff --git a/patches/net/minecraft/client/Minecraft.java.patch b/patches/net/minecraft/client/Minecraft.java.patch index 2beec1e..6db83b8 100644 --- a/patches/net/minecraft/client/Minecraft.java.patch +++ b/patches/net/minecraft/client/Minecraft.java.patch @@ -306,7 +306,7 @@ + * The minecriftVerString will be automatically updated by the build scripts, do not modify here. + * Modify minecriftversion.py in root minecrift dir. + */ -+ public final String minecriftVerString = "Vivecraft 1.10.2 jrbudda-10pre5"; ++ public final String minecriftVerString = "Vivecraft 1.10.2 jrbudda-10pre7"; + /* end version */ + /** END MINECRIFT */ + @@ -1612,7 +1612,7 @@ } this.processKeyBinds(); -@@ -2171,20 +2795,36 @@ +@@ -2171,20 +2795,38 @@ { for (; this.gameSettings.keyBindTogglePerspective.isPressed(); this.renderGlobal.setDisplayListEntitiesDirty()) { @@ -1644,8 +1644,10 @@ + e.printStackTrace(); + } + } else { -+ if(true) return; -+ ++this.gameSettings.thirdPersonView; ++ //this.displayGuiScreen(new net.minecraft.client.gui.GuiWinGame()); //ez mode ++ ++ // VIVE: No don't do this it's really bad ++ /*++this.gameSettings.thirdPersonView; + + if (this.gameSettings.thirdPersonView > 2) + { @@ -1659,11 +1661,11 @@ + else if (this.gameSettings.thirdPersonView == 1) + { + this.entityRenderer.loadEntityShader((Entity)null); -+ } ++ }*/ } } -@@ -2207,7 +2847,7 @@ +@@ -2207,7 +2849,7 @@ } } } @@ -1672,7 +1674,7 @@ while (this.gameSettings.keyBindInventory.isPressed()) { this.getConnection().sendPacket(new CPacketClientStatus(CPacketClientStatus.State.OPEN_INVENTORY_ACHIEVEMENT)); -@@ -2242,22 +2882,42 @@ +@@ -2242,22 +2884,42 @@ if (flag) { @@ -1722,7 +1724,7 @@ } label472: -@@ -2283,17 +2943,27 @@ +@@ -2283,17 +2945,27 @@ } } } @@ -1758,7 +1760,7 @@ while (this.gameSettings.keyBindPickBlock.isPressed()) { -@@ -2301,18 +2971,23 @@ +@@ -2301,18 +2973,23 @@ } } @@ -1785,7 +1787,7 @@ int i = Mouse.getEventButton(); KeyBinding.setKeyBindState(i - 100, Mouse.getEventButtonState()); -@@ -2327,6 +3002,13 @@ +@@ -2327,6 +3004,13 @@ KeyBinding.onTick(i - 100); } } @@ -1799,7 +1801,7 @@ long j = getSystemTime() - this.systemTime; -@@ -2381,6 +3063,15 @@ +@@ -2381,6 +3065,15 @@ */ public void launchIntegratedServer(String folderName, String worldName, @Nullable WorldSettings worldSettingsIn) { @@ -1815,7 +1817,7 @@ this.loadWorld((WorldClient)null); System.gc(); ISaveHandler isavehandler = this.saveLoader.getSaveLoader(folderName, false); -@@ -2423,6 +3114,16 @@ +@@ -2423,6 +3116,16 @@ while (!this.theIntegratedServer.serverIsInRunLoop()) { @@ -1832,7 +1834,7 @@ String s = this.theIntegratedServer.getUserMessage(); if (s != null) -@@ -2443,12 +3144,19 @@ +@@ -2443,12 +3146,19 @@ ; } } @@ -1854,7 +1856,7 @@ networkmanager.sendPacket(new CPacketLoginStart(this.getSession().getProfile())); this.myNetworkManager = networkmanager; } -@@ -2458,6 +3166,9 @@ +@@ -2458,6 +3168,9 @@ */ public void loadWorld(WorldClient worldClientIn) { @@ -1864,7 +1866,7 @@ this.loadWorld(worldClientIn, ""); } -@@ -2466,6 +3177,11 @@ +@@ -2466,6 +3179,11 @@ */ public void loadWorld(@Nullable WorldClient worldClientIn, String loadingMessage) { @@ -1876,7 +1878,7 @@ if (worldClientIn == null) { NetHandlerPlayClient nethandlerplayclient = this.getConnection(); -@@ -2477,9 +3193,25 @@ +@@ -2477,9 +3195,25 @@ if (this.theIntegratedServer != null && this.theIntegratedServer.isAnvilFileSet()) { @@ -1904,7 +1906,7 @@ this.theIntegratedServer = null; this.guiAchievement.clearAchievements(); this.entityRenderer.getMapItemRenderer().clearLoadedMaps(); -@@ -2501,6 +3233,11 @@ +@@ -2501,6 +3235,11 @@ this.ingameGUI.resetPlayersOverlayFooterHeader(); this.setServerData((ServerData)null); this.integratedServerIsRunning = false; @@ -1916,7 +1918,7 @@ } this.mcSoundHandler.stopSounds(); -@@ -2533,12 +3270,14 @@ +@@ -2533,12 +3272,14 @@ if (this.player == null) { @@ -1932,7 +1934,7 @@ this.player.movementInput = new MovementInputFromOptions(this.gameSettings); this.playerController.setPlayerCapabilities(this.player); this.renderViewEntity = this.player; -@@ -2576,6 +3315,7 @@ +@@ -2576,6 +3317,7 @@ this.player.preparePlayerToSpawn(); this.player.setServerBrand(s); this.world.spawnEntity(this.player); @@ -1940,7 +1942,7 @@ this.playerController.flipPlayer(this.player); this.player.movementInput = new MovementInputFromOptions(this.gameSettings); this.player.setEntityId(i); -@@ -2607,6 +3347,7 @@ +@@ -2607,6 +3349,7 @@ return theMinecraft == null || !theMinecraft.gameSettings.hideGUI; } @@ -1948,7 +1950,7 @@ public static boolean isFancyGraphicsEnabled() { return theMinecraft != null && theMinecraft.gameSettings.fancyGraphics; -@@ -2623,8 +3364,16 @@ +@@ -2623,8 +3366,16 @@ /** * Called when user clicked he's mouse middle button (pick block) */ @@ -1966,7 +1968,7 @@ if (this.objectMouseOver != null && this.objectMouseOver.typeOfHit != RayTraceResult.Type.MISS) { boolean flag = this.player.capabilities.isCreativeMode; -@@ -2788,7 +3537,8 @@ +@@ -2788,7 +3539,8 @@ } } @@ -1976,7 +1978,7 @@ { NBTTagCompound nbttagcompound = te.writeToNBT(new NBTTagCompound()); -@@ -3098,6 +3848,11 @@ +@@ -3098,6 +3850,11 @@ */ public static int getGLMaximumTextureSize() { @@ -1988,7 +1990,7 @@ for (int i = 16384; i > 0; i >>= 1) { GlStateManager.glTexImage2D(32868, 0, 6408, i, i, 0, 6408, 5121, (IntBuffer)null); -@@ -3264,7 +4019,7 @@ +@@ -3264,7 +4021,7 @@ } public void dispatchKeypresses() @@ -1997,7 +1999,7 @@ int i = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey(); if (i != 0 && !Keyboard.isRepeatEvent()) -@@ -3417,4 +4172,1209 @@ +@@ -3417,4 +4174,1209 @@ { return this.player != null && this.player.hasReducedDebug() || this.gameSettings.reducedDebugInfo; } diff --git a/patches/net/minecraft/client/entity/EntityPlayerSP.java.patch b/patches/net/minecraft/client/entity/EntityPlayerSP.java.patch index 0a071f0..59719a2 100644 --- a/patches/net/minecraft/client/entity/EntityPlayerSP.java.patch +++ b/patches/net/minecraft/client/entity/EntityPlayerSP.java.patch @@ -576,7 +576,7 @@ vec3d2 = new Vec3d((double)(f2 * f5 - f3 * f4), vec3d2.yCoord, (double)(f3 * f5 + f2 * f4)); f1 = (float)vec3d2.lengthSquared(); -@@ -1269,4 +1483,336 @@ +@@ -1269,4 +1483,338 @@ } } } @@ -584,6 +584,7 @@ + + // VIVECREAFT ADDITIONS + ++ boolean debugSpawn; + + /** + * Sets the location and Yaw/Pitch of an entity in the world @@ -595,7 +596,8 @@ +// Vec3 roomOrigin = OpenVRPlayer.get().getRoomOriginPos_World(); +// double ox = roomOrigin.xCoord - posX; +// double oz = roomOrigin.zCoord - posZ; -+// ++ if(debugSpawn)System.out.println("setlocangles " + x + " " + y + " " + z); ++ + super.setLocationAndAngles(x, y, z, yaw, pitch); + + if(!initFromServer) return; @@ -608,10 +610,11 @@ +// posZ + oz, false); + } + } -+ ++ + @Override + public void setPositionAndRotation(double x, double y, double z, float yaw, float pitch) + { ++ if(debugSpawn)System.out.println("setposrot " + x + " " + y + " " + z); + super.setPositionAndRotation(x, y, z, yaw, pitch); + + OpenVRPlayer.get().snapRoomOriginToPlayerEntity(this, true, false, 1); @@ -627,6 +630,8 @@ + @Override + public void setPosition(double x, double y, double z) + { //this is also called when riding to move this around. ++ if(debugSpawn)System.out.println("setpos " + x + " " + y + " " + z); ++ + super.setPosition(x, y, z); + if(this.isRiding()){ + Vec3d roomOrigin = OpenVRPlayer.get().getRoomOriginPos_World(); @@ -893,12 +898,9 @@ + */ + @Override + public void onDeath(DamageSource p_70645_1_){ -+ + super.onDeath(p_70645_1_); + MCOpenVR.triggerHapticPulse(0, 2000); + MCOpenVR.triggerHapticPulse(1, 2000); -+ System.out.println("Player DIED At " + this.posX + " " + this.posY + " " + this.posZ); //debug spawning in the damn ground. -+ + } + + diff --git a/patches/net/minecraft/client/gui/GuiChat.java.patch b/patches/net/minecraft/client/gui/GuiChat.java.patch index ca534f1..4af3c06 100644 --- a/patches/net/minecraft/client/gui/GuiChat.java.patch +++ b/patches/net/minecraft/client/gui/GuiChat.java.patch @@ -29,7 +29,7 @@ this.inputField = new GuiTextField(0, this.fontRendererObj, 4, this.height - 12, this.width - 4, 12); this.inputField.setMaxStringLength(100); this.inputField.setEnableBackgroundDrawing(false); -+ //this.inputField.setCanLoseFocus(false); ++ this.inputField.setCanLoseFocus(false); this.inputField.setFocused(true); this.inputField.setText(this.defaultInputFieldText); - this.inputField.setCanLoseFocus(false); diff --git a/patches/net/minecraft/client/gui/GuiIngame.java.patch b/patches/net/minecraft/client/gui/GuiIngame.java.patch index df9f653..68e3c2d 100644 --- a/patches/net/minecraft/client/gui/GuiIngame.java.patch +++ b/patches/net/minecraft/client/gui/GuiIngame.java.patch @@ -66,7 +66,7 @@ if (this.mc.playerController.isSpectator()) { -@@ -185,20 +186,55 @@ +@@ -185,20 +186,28 @@ { this.renderHotbar(scaledresolution, partialTicks); } @@ -89,34 +89,7 @@ - this.overlayBoss.renderBossHealth(); + this.overlayBoss.renderBossHealth(); this.mc.mcProfiler.endSection(); -+ -+ //VIVE SPRINTDICATOR -+ if (this.mc.getRenderViewEntity() instanceof EntityPlayer) -+ { -+ EntityPlayer entityplayer = (EntityPlayer)this.mc.getRenderViewEntity(); -+ int iconp = 0; -+ if(entityplayer.isSprinting()) iconp = 10; -+ if(entityplayer.isSneaking()) iconp = 13; -+ if(entityplayer.isElytraFlying()) iconp = -1; -+ if(iconp!=0){ -+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); -+ -+ if(iconp ==-1){ -+ int w = scaledresolution.getScaledWidth() / 2 - 109; -+ int h = scaledresolution.getScaledHeight() -39; -+ TextureAtlasSprite textureatlassprite = this.mc.getTextureMapBlocks().getAtlasSprite("minecraft:items/elytra"); -+ this.mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); -+ this.drawTexturedModalRect(w, h, textureatlassprite, 16, 16); -+ }else{ -+ this.mc.getTextureManager().bindTexture(INVENTORY_BACKGROUND); -+ int w = scaledresolution.getScaledWidth() / 2 - 109; -+ int h = scaledresolution.getScaledHeight() -39; -+ this.drawTexturedModalRect(w, h, 0 + iconp % 8 * 18, 198 + iconp / 8 * 18, 18, 18); -+ } -+ } -+ } -+ // -+ ++ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(ICONS); @@ -127,7 +100,7 @@ this.renderPlayerStats(scaledresolution); } -@@ -380,7 +416,7 @@ +@@ -380,7 +389,7 @@ GlStateManager.enableAlpha(); } @@ -136,7 +109,7 @@ { GameSettings gamesettings = this.mc.gameSettings; -@@ -553,6 +589,7 @@ +@@ -553,6 +562,7 @@ int j = 182; int k = 91; this.zLevel = -90.0F; @@ -144,7 +117,7 @@ this.drawTexturedModalRect(i - 91, sr.getScaledHeight() - 22, 0, 0, 182, 22); this.drawTexturedModalRect(i - 91 - 1 + entityplayer.inventory.currentItem * 20, sr.getScaledHeight() - 22 - 1, 0, 22, 24, 22); -@@ -571,7 +608,7 @@ +@@ -571,7 +581,7 @@ this.zLevel = f; GlStateManager.enableRescaleNormal(); GlStateManager.enableBlend(); @@ -153,7 +126,7 @@ RenderHelper.enableGUIStandardItemLighting(); CustomItems.setRenderOffHand(false); -@@ -749,7 +786,7 @@ +@@ -749,7 +759,7 @@ this.mc.mcProfiler.endSection(); } @@ -162,7 +135,7 @@ { Scoreboard scoreboard = objective.getScoreboard(); Collection collection = scoreboard.getSortedScores(objective); -@@ -966,7 +1003,7 @@ +@@ -966,7 +976,7 @@ } } } @@ -171,7 +144,7 @@ Entity entity = entityplayer.getRidingEntity(); if (entity == null) -@@ -1030,7 +1067,7 @@ +@@ -1030,7 +1040,7 @@ } } @@ -180,7 +153,7 @@ { if (this.mc.getRenderViewEntity() instanceof EntityPlayer) { -@@ -1084,7 +1121,7 @@ +@@ -1084,7 +1094,7 @@ } } @@ -189,7 +162,7 @@ { GlStateManager.disableDepth(); GlStateManager.depthMask(false); -@@ -1111,6 +1148,12 @@ +@@ -1111,6 +1121,12 @@ */ private void renderVignette(float lightLevel, ScaledResolution scaledRes) { @@ -202,7 +175,7 @@ if (!Config.isVignetteEnabled()) { GlStateManager.enableDepth(); -@@ -1166,36 +1209,7 @@ +@@ -1166,36 +1182,7 @@ private void renderPortal(float timeInPortal, ScaledResolution scaledRes) { @@ -240,7 +213,7 @@ } private void renderHotbarItem(int p_184044_1_, int p_184044_2_, float p_184044_3_, EntityPlayer player, @Nullable ItemStack stack) -@@ -1373,4 +1387,43 @@ +@@ -1373,4 +1360,43 @@ { return this.overlayBoss; } diff --git a/patches/net/minecraft/client/gui/GuiMainMenu.java.patch b/patches/net/minecraft/client/gui/GuiMainMenu.java.patch index c87a46e..ba7e3d5 100644 --- a/patches/net/minecraft/client/gui/GuiMainMenu.java.patch +++ b/patches/net/minecraft/client/gui/GuiMainMenu.java.patch @@ -1,6 +1,50 @@ --- a/net/minecraft/client/gui/GuiMainMenu.java +++ b/net/minecraft/client/gui/GuiMainMenu.java -@@ -277,6 +277,7 @@ +@@ -2,6 +2,7 @@ + + import com.google.common.base.Strings; + import com.google.common.collect.Lists; ++ + import java.io.BufferedReader; + import java.io.Closeable; + import java.io.IOException; +@@ -12,6 +13,7 @@ + import java.util.List; + import java.util.Random; + import java.util.concurrent.atomic.AtomicInteger; ++ + import net.minecraft.client.Minecraft; + import net.minecraft.client.renderer.GlStateManager; + import net.minecraft.client.renderer.OpenGlHelper; +@@ -23,6 +25,7 @@ + import net.minecraft.client.resources.IResource; + import net.minecraft.client.settings.GameSettings; + import net.minecraft.realms.RealmsBridge; ++import net.minecraft.src.Config; + import net.minecraft.src.CustomPanorama; + import net.minecraft.src.CustomPanoramaProperties; + import net.minecraft.src.Reflector; +@@ -32,6 +35,7 @@ + import net.minecraft.world.demo.DemoWorldServer; + import net.minecraft.world.storage.ISaveFormat; + import net.minecraft.world.storage.WorldInfo; ++ + import org.apache.commons.io.Charsets; + import org.apache.commons.io.IOUtils; + import org.apache.logging.log4j.LogManager; +@@ -168,6 +172,11 @@ + this.openGLWarning2 = I18n.format("title.oldgl2", new Object[0]); + this.openGLWarningLink = "https://help.mojang.com/customer/portal/articles/325948?ref=game"; + } ++ else if (Reflector.forgeExists() && Config.isShaders()) // We'll just piggyback off this, not like the OpenGL message should ever show up anyways ++ { ++ this.openGLWarning1 = "WARNING: You have shaders enabled under Forge! Some mods are"; ++ this.openGLWarning2 = "incompatible, so please set them to OFF if you experience issues."; ++ } + } + + /** +@@ -277,6 +286,7 @@ { this.modUpdateNotification = (GuiScreen)Reflector.call(Reflector.NotificationModUpdateScreen_init, new Object[] {this, this.modButton}); } @@ -8,7 +52,7 @@ } /** -@@ -709,6 +710,7 @@ +@@ -709,6 +719,7 @@ { this.modUpdateNotification.drawScreen(mouseX, mouseY, partialTicks); } diff --git a/patches/net/minecraft/client/gui/GuiTextField.java.patch b/patches/net/minecraft/client/gui/GuiTextField.java.patch index 665d4c2..3a78b2e 100644 --- a/patches/net/minecraft/client/gui/GuiTextField.java.patch +++ b/patches/net/minecraft/client/gui/GuiTextField.java.patch @@ -48,18 +48,19 @@ } boolean flag2 = this.cursorPosition < this.text.length() || this.text.length() >= this.getMaxStringLength(); -@@ -717,6 +729,15 @@ +@@ -717,6 +729,16 @@ } this.isFocused = isFocusedIn; + + // VIVE START - show keyboard -+ for (StackTraceElement ste : Thread.currentThread().getStackTrace()) { ++ //for (StackTraceElement ste : Thread.currentThread().getStackTrace()) { + // if(ste.getClassName().contains("GuiChattableCamera")) return; + // if(ste.toString().contains("journeymap.client.ui.fullscreen.Fullscreen")) return; -+ } ++ //} + -+ if(isFocusedIn && this.visible && this.canLoseFocus == false) MCOpenVR.setKeyboardOverlayShowing(isFocusedIn, this); ++ if(isFocusedIn && this.visible && (this.canLoseFocus == false || Minecraft.getMinecraft().vrSettings.autoOpenKeyboard)) ++ MCOpenVR.setKeyboardOverlayShowing(isFocusedIn, this); + //VIVE END - show keyboard } diff --git a/patches/net/minecraft/client/network/NetHandlerPlayClient.java.patch b/patches/net/minecraft/client/network/NetHandlerPlayClient.java.patch index 5637466..ae38941 100644 --- a/patches/net/minecraft/client/network/NetHandlerPlayClient.java.patch +++ b/patches/net/minecraft/client/network/NetHandlerPlayClient.java.patch @@ -174,20 +174,7 @@ } } } -@@ -1116,7 +1187,11 @@ - { - this.doneLoadingTerrain = false; - Scoreboard scoreboard = this.clientWorldController.getScoreboard(); -- this.clientWorldController = new WorldClient(this, new WorldSettings(0L, packetIn.getGameType(), false, this.gameController.world.getWorldInfo().isHardcoreModeEnabled(), packetIn.getWorldType()), packetIn.getDimensionID(), packetIn.getDifficulty(), this.gameController.mcProfiler); -+ int dimId = packetIn.getDimensionID(); -+ if (Reflector.forgeExists()){ -+ dimId = Reflector.callInt(Reflector.call(Reflector.NetworkDispatcher_get, getNetworkManager()), Reflector.NetworkDispatcher_getOverrideDimension, packetIn); -+ } -+ this.clientWorldController = new WorldClient(this, new WorldSettings(0L, packetIn.getGameType(), false, this.gameController.world.getWorldInfo().isHardcoreModeEnabled(), packetIn.getWorldType()), dimId, packetIn.getDifficulty(), this.gameController.mcProfiler); - this.clientWorldController.setWorldScoreboard(scoreboard); - this.gameController.loadWorld(this.clientWorldController); - this.gameController.player.dimension = packetIn.getDimensionID(); -@@ -1305,7 +1380,19 @@ +@@ -1305,7 +1376,19 @@ { tileentity.readFromNBT(packetIn.getNbtCompound()); } @@ -208,7 +195,7 @@ if (flag && this.gameController.currentScreen instanceof GuiCommandBlock) { ((GuiCommandBlock)this.gameController.currentScreen).updateGui(); -@@ -1416,15 +1503,41 @@ +@@ -1416,15 +1499,41 @@ } else if (f == 101.0F) { @@ -253,7 +240,7 @@ } } else if (i == 6) -@@ -1525,7 +1638,7 @@ +@@ -1525,7 +1634,7 @@ if (entity instanceof EntityLivingBase) { @@ -262,7 +249,7 @@ if (potion != null) { -@@ -1928,6 +2041,115 @@ +@@ -1928,6 +2037,115 @@ String s1 = packetbuffer2.readString(256); this.gameController.getSoundHandler().stop(s1, SoundCategory.getByName(s)); } @@ -378,7 +365,7 @@ } /** -@@ -2198,4 +2420,12 @@ +@@ -2198,4 +2416,12 @@ { return this.profile; } diff --git a/patches/net/minecraft/client/renderer/EntityRenderer.java.patch b/patches/net/minecraft/client/renderer/EntityRenderer.java.patch index bc823b7..aa5029b 100644 --- a/patches/net/minecraft/client/renderer/EntityRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/EntityRenderer.java.patch @@ -1129,7 +1129,7 @@ + itemRenderer.renderItemInFirstPerson(mc.player, partialTicks, 0, EnumHand.MAIN_HAND, mc.player.getSwingProgress(partialTicks), mc.player.getHeldItemOffhand(), 0); + } + -+ if(BowTracker.isHoldingBow(mc.player)){ ++ if(BowTracker.isBow(item)){ + int c = 0; + if (mc.vrSettings.vrReverseShootingEye) c = 1; + @@ -1175,11 +1175,10 @@ this.mc.getTextureManager().bindTexture(this.locationLightMap); GlStateManager.glTexParameteri(3553, 10241, 9729); GlStateManager.glTexParameteri(3553, 10240, 9729); -@@ -1220,708 +1312,815 @@ - } +@@ -1221,707 +1313,814 @@ } -- public float getNightVisionBrightness(EntityLivingBase entitylivingbaseIn, float partialTicks) + public float getNightVisionBrightness(EntityLivingBase entitylivingbaseIn, float partialTicks) - { - int i = entitylivingbaseIn.getActivePotionEffect(MobEffects.NIGHT_VISION).getDuration(); - return i > 200 ? 1.0F : 0.7F + MathHelper.sin(((float)i - partialTicks) * (float)Math.PI * 0.2F) * 0.3F; @@ -1653,7 +1652,6 @@ - - renderglobal.renderBlockLayer(BlockRenderLayer.CUTOUT, (double)partialTicks, pass, entity); - this.mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap(); -+ public float getNightVisionBrightness(EntityLivingBase entitylivingbaseIn, float partialTicks) + { + int i = entitylivingbaseIn.getActivePotionEffect(MobEffects.NIGHT_VISION).getDuration(); + return i > 200 ? 1.0F : 0.7F + MathHelper.sin(((float)i - partialTicks) * (float)Math.PI * 0.2F) * 0.3F; @@ -2912,7 +2910,7 @@ public static void drawNameplate(FontRenderer fontRendererIn, String str, float x, float y, float z, int verticalShift, float viewerYaw, float viewerPitch, boolean isThirdPersonFrontal, boolean isSneaking) { GlStateManager.pushMatrix(); -@@ -2927,4 +3050,2304 @@ +@@ -2927,4 +3050,2340 @@ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.popMatrix(); } @@ -3060,7 +3058,7 @@ + } else { + ItemStack i = ((EntityPlayerSP) entity).inventory.getCurrentItem(); + if(i !=null){ -+ if(mc.bowTracker.isBow(i) && mc.bowTracker.isNotched()){ ++ if(BowTracker.isBow(i) && mc.bowTracker.isNotched()){ + //use bow aim + Vec3d aim = mc.bowTracker.getAimVector(); + if (aim != null && aim.lengthSquared() > 0) { @@ -3672,6 +3670,7 @@ + + + //Render HUD elements ++ renderViveHudIcons(); //put this here cause Forge has its own guiingame. + this.mc.ingameGUI.renderGameOverlay(renderPartialTicks); + + if (this.mc.gameSettings.ofShowFps && !this.mc.gameSettings.showDebugInfo) @@ -5214,6 +5213,41 @@ + } + + } ++ ++ private void renderViveHudIcons(){ ++ //VIVE SPRINTDICATOR ++ if (this.mc.getRenderViewEntity() instanceof EntityPlayer) ++ { ++ ScaledResolution scaledresolution = new ScaledResolution(this.mc); ++ int i = scaledresolution.getScaledWidth(); ++ int j = scaledresolution.getScaledHeight(); ++ FontRenderer fontrenderer = mc.ingameGUI.getFontRenderer(); ++ this.mc.entityRenderer.setupOverlayRendering(); ++ EntityPlayer entityplayer = (EntityPlayer)this.mc.getRenderViewEntity(); ++ int iconp = 0; ++ if(entityplayer.isSprinting()) iconp = 10; ++ if(entityplayer.isSneaking()) iconp = 13; ++ if(entityplayer.isElytraFlying()) iconp = -1; ++ if(iconp!=0){ ++ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); ++ ++ if(iconp ==-1){ ++ int w = scaledresolution.getScaledWidth() / 2 - 109; ++ int h = scaledresolution.getScaledHeight() -39; ++ TextureAtlasSprite textureatlassprite = this.mc.getTextureMapBlocks().getAtlasSprite("minecraft:items/elytra"); ++ this.mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); ++ mc.ingameGUI.drawTexturedModalRect(w, h, textureatlassprite, 16, 16); ++ }else{ ++ this.mc.getTextureManager().bindTexture(mc.ingameGUI.INVENTORY_BACKGROUND); ++ int w = scaledresolution.getScaledWidth() / 2 - 109; ++ int h = scaledresolution.getScaledHeight() -39; ++ mc.ingameGUI.drawTexturedModalRect(w, h, 0 + iconp % 8 * 18, 198 + iconp / 8 * 18, 18, 18); ++ } ++ } ++ } ++ // ++ } ++ + // VIVE END - render functions + } diff --git a/patches/net/minecraft/client/renderer/ItemRenderer.java.patch b/patches/net/minecraft/client/renderer/ItemRenderer.java.patch index 90e4eae..db55c67 100644 --- a/patches/net/minecraft/client/renderer/ItemRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/ItemRenderer.java.patch @@ -49,7 +49,7 @@ import net.minecraft.src.Config; import net.minecraft.src.DynamicLights; import net.minecraft.src.Reflector; -@@ -31,9 +53,16 @@ +@@ -31,9 +53,17 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; @@ -57,6 +57,7 @@ import net.minecraft.world.storage.MapData; import shadersmod.client.Shaders; ++import com.mtbs3d.minecrift.gameplay.BowTracker; +import com.mtbs3d.minecrift.provider.MCOpenVR; +import com.mtbs3d.minecrift.render.OpenGLdebugging; +import com.mtbs3d.minecrift.render.RenderVRPlayer; @@ -66,7 +67,7 @@ public class ItemRenderer { private static final ResourceLocation RES_MAP_BACKGROUND = new ResourceLocation("textures/map/map_background.png"); -@@ -41,47 +70,60 @@ +@@ -41,47 +71,60 @@ /** A reference to the Minecraft object. */ private final Minecraft mc; @@ -118,15 +119,15 @@ Block block = Block.getBlockFromItem(item); GlStateManager.pushMatrix(); - boolean flag = this.itemRenderer.shouldRenderItemIn3D(heldStack) && this.isBlockTranslucent(block); -+ boolean flag = this.itemRenderer.shouldRenderItemIn3D(heldStack) && block != null && block.getBlockLayer() == BlockRenderLayer.TRANSLUCENT; - +- - if (flag && (!Config.isShaders() || !Shaders.renderItemKeepDepthMask)) - { - GlStateManager.depthMask(false); - } - - this.itemRenderer.renderItem(heldStack, entitylivingbaseIn, transform, leftHanded); -- ++ boolean flag = this.itemRenderer.shouldRenderItemIn3D(heldStack) && block != null && block.getBlockLayer() == BlockRenderLayer.TRANSLUCENT; + - if (flag) - { - GlStateManager.depthMask(true); @@ -145,7 +146,7 @@ GlStateManager.popMatrix(); } -@@ -107,7 +149,7 @@ +@@ -107,7 +150,7 @@ GlStateManager.popMatrix(); } @@ -154,7 +155,7 @@ { AbstractClientPlayer abstractclientplayer = this.mc.player; int i = this.mc.world.getCombinedLight(new BlockPos(abstractclientplayer.posX, abstractclientplayer.posY + (double)abstractclientplayer.getEyeHeight(), abstractclientplayer.posZ), 0); -@@ -122,6 +164,7 @@ +@@ -122,6 +165,7 @@ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, f, f1); } @@ -162,7 +163,7 @@ private void rotateArm(float p_187458_1_) { EntityPlayerSP entityplayersp = this.mc.player; -@@ -142,6 +185,7 @@ +@@ -142,6 +186,7 @@ return f; } @@ -170,7 +171,7 @@ private void renderArms() { if (!this.mc.player.isInvisible()) -@@ -156,6 +200,7 @@ +@@ -156,6 +201,7 @@ } } @@ -178,7 +179,7 @@ private void renderArm(EnumHandSide p_187455_1_) { this.mc.getTextureManager().bindTexture(this.mc.player.getLocationSkin()); -@@ -183,27 +228,29 @@ +@@ -183,27 +229,29 @@ private void renderMapFirstPersonSide(float p_187465_1_, EnumHandSide p_187465_2_, float p_187465_3_, ItemStack p_187465_4_) { float f = p_187465_2_ == EnumHandSide.RIGHT ? 1.0F : -1.0F; @@ -223,7 +224,7 @@ GlStateManager.popMatrix(); } -@@ -212,14 +259,17 @@ +@@ -212,14 +260,17 @@ float f = MathHelper.sqrt(p_187463_3_); float f1 = -0.2F * MathHelper.sin(p_187463_3_ * (float)Math.PI); float f2 = -0.4F * MathHelper.sin(f * (float)Math.PI); @@ -247,7 +248,7 @@ this.renderMapFirstPerson(this.itemStackMainHand); } -@@ -250,100 +300,132 @@ +@@ -250,100 +301,132 @@ GlStateManager.enableLighting(); } @@ -352,6 +353,17 @@ - GlStateManager.rotate((float)i * f3 * 90.0F, 0.0F, 1.0F, 0.0F); - GlStateManager.rotate(f3 * 10.0F, 1.0F, 0.0F, 0.0F); - GlStateManager.rotate((float)i * f3 * 30.0F, 0.0F, 0.0F, 1.0F); +- } +- +- private void transformFirstPerson(EnumHandSide p_187453_1_, float p_187453_2_) +- { +- int i = p_187453_1_ == EnumHandSide.RIGHT ? 1 : -1; +- float f = MathHelper.sin(p_187453_2_ * p_187453_2_ * (float)Math.PI); +- GlStateManager.rotate((float)i * (45.0F + f * -20.0F), 0.0F, 1.0F, 0.0F); +- float f1 = MathHelper.sin(MathHelper.sqrt(p_187453_2_) * (float)Math.PI); +- GlStateManager.rotate((float)i * f1 * -20.0F, 0.0F, 0.0F, 1.0F); +- GlStateManager.rotate(f1 * -80.0F, 1.0F, 0.0F, 0.0F); +- GlStateManager.rotate((float)i * -45.0F, 0.0F, 1.0F, 0.0F); + if(!Minecraft.getMinecraft().autoFood.isEating()) { + float f3 = 1.0F - (float) Math.pow((double) f1, 27.0D); + int i = side == EnumHandSide.RIGHT ? 1 : -1; @@ -392,17 +404,6 @@ +// GlStateManager.translate((float)i * 0.56F, -0.52F + equippingprogress * -0.6F, -0.72F); } -- private void transformFirstPerson(EnumHandSide p_187453_1_, float p_187453_2_) -- { -- int i = p_187453_1_ == EnumHandSide.RIGHT ? 1 : -1; -- float f = MathHelper.sin(p_187453_2_ * p_187453_2_ * (float)Math.PI); -- GlStateManager.rotate((float)i * (45.0F + f * -20.0F), 0.0F, 1.0F, 0.0F); -- float f1 = MathHelper.sin(MathHelper.sqrt(p_187453_2_) * (float)Math.PI); -- GlStateManager.rotate((float)i * f1 * -20.0F, 0.0F, 0.0F, 1.0F); -- GlStateManager.rotate(f1 * -80.0F, 1.0F, 0.0F, 0.0F); -- GlStateManager.rotate((float)i * -45.0F, 0.0F, 1.0F, 0.0F); -- } -- - private void transformSideFirstPerson(EnumHandSide p_187459_1_, float p_187459_2_) - { - int i = p_187459_1_ == EnumHandSide.RIGHT ? 1 : -1; @@ -423,6 +424,16 @@ - float f2 = abstractclientplayer.prevRotationYaw + (abstractclientplayer.rotationYaw - abstractclientplayer.prevRotationYaw) * partialTicks; - boolean flag = true; - boolean flag1 = true; +- +- if (abstractclientplayer.isHandActive()) +- { +- ItemStack itemstack = abstractclientplayer.getActiveItemStack(); +- +- if (itemstack != null && itemstack.getItem() == Items.BOW) +- { +- EnumHand enumhand1 = abstractclientplayer.getActiveHand(); +- flag = enumhand1 == EnumHand.MAIN_HAND; +- flag1 = !flag; + AbstractClientPlayer player = this.mc.player; + float swingprogress = player.getSwingProgress(partialTicks); + EnumHand hand = (EnumHand)Objects.firstNonNull(player.swingingHand, EnumHand.MAIN_HAND); @@ -430,18 +441,12 @@ + float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * partialTicks; + boolean doRighthand = true; + boolean doLeftHand = true; - -- if (abstractclientplayer.isHandActive()) ++ + if (player.isHandActive()) - { -- ItemStack itemstack = abstractclientplayer.getActiveItemStack(); ++ { + ItemStack itemstack = player.getActiveItemStack(); - - if (itemstack != null && itemstack.getItem() == Items.BOW) -- { -- EnumHand enumhand1 = abstractclientplayer.getActiveHand(); -- flag = enumhand1 == EnumHand.MAIN_HAND; -- flag1 = !flag; ++ ++ if (BowTracker.isBow(itemstack)) + {//bow mode + EnumHand enumhand1 = player.getActiveHand(); + doRighthand = enumhand1 == EnumHand.MAIN_HAND; @@ -449,7 +454,7 @@ } } -@@ -352,203 +434,555 @@ +@@ -352,203 +435,555 @@ this.rotateArm(partialTicks); GlStateManager.enableRescaleNormal(); @@ -691,7 +696,7 @@ + boolean vive = MCOpenVR.isVive; + + boolean sword = false, tool = false; -+ boolean bow = item.getItemUseAction(itemstack) == EnumAction.BOW; ++ boolean bow = BowTracker.isBow(itemstack); + + if(bow && item.getClass().getName().equals("FryPan")){ + bow = false; @@ -1001,8 +1006,8 @@ + } + + -+ GlStateManager.enableAlpha(); -+ } + GlStateManager.enableAlpha(); + } + + public boolean inwater, inportal, inblock, onfire; + public float inBlock = 0; @@ -1039,9 +1044,9 @@ + tessellator.draw(); + GlStateManager.depthMask(true); + GlStateManager.enableDepth(); - GlStateManager.enableAlpha(); ++ GlStateManager.enableAlpha(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - } ++ } + + public boolean isInsideOfMaterial(Vec3d pos, Material materialIn) + { @@ -1153,7 +1158,7 @@ vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX); vertexbuffer.pos(-1.0D, -1.0D, -0.5D).tex((double)f7, (double)f9).endVertex(); vertexbuffer.pos(1.0D, -1.0D, -0.5D).tex((double)f6, (double)f9).endVertex(); -@@ -572,17 +1006,14 @@ +@@ -572,17 +1007,14 @@ VertexBuffer vertexbuffer = tessellator.getBuffer(); float f = this.mc.player.getBrightness(partialTicks); GlStateManager.color(f, f, f, 0.5F); diff --git a/patches/net/minecraft/client/renderer/RenderGlobal.java.patch b/patches/net/minecraft/client/renderer/RenderGlobal.java.patch index 93881d6..58a0140 100644 --- a/patches/net/minecraft/client/renderer/RenderGlobal.java.patch +++ b/patches/net/minecraft/client/renderer/RenderGlobal.java.patch @@ -289,7 +289,7 @@ switch (type) { case 1000: -@@ -3147,14 +3164,21 @@ +@@ -3147,18 +3164,28 @@ break; case 1011: @@ -311,7 +311,14 @@ this.world.playSound(blockPosIn, SoundEvents.BLOCK_WOODEN_TRAPDOOR_CLOSE, SoundCategory.BLOCKS, 1.0F, this.world.rand.nextFloat() * 0.1F + 0.9F, false); break; -@@ -3179,14 +3203,26 @@ + case 1014: ++ if(playernear) ++ MCOpenVR.triggerHapticPulse(0,250); //VIVECRAFT go thump. ++ + this.world.playSound(blockPosIn, SoundEvents.BLOCK_FENCE_GATE_CLOSE, SoundCategory.BLOCKS, 1.0F, this.world.rand.nextFloat() * 0.1F + 0.9F, false); + break; + +@@ -3179,14 +3206,26 @@ break; case 1019: @@ -338,7 +345,7 @@ this.world.playSound(blockPosIn, SoundEvents.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, SoundCategory.HOSTILE, 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false); break; -@@ -3215,10 +3251,17 @@ +@@ -3215,10 +3254,17 @@ break; case 1030: @@ -356,7 +363,7 @@ this.world.playSound(blockPosIn, SoundEvents.BLOCK_ANVIL_LAND, SoundCategory.BLOCKS, 0.3F, this.world.rand.nextFloat() * 0.1F + 0.9F, false); break; -@@ -3239,6 +3282,9 @@ +@@ -3239,6 +3285,9 @@ break; case 1036: @@ -366,7 +373,7 @@ this.world.playSound(blockPosIn, SoundEvents.BLOCK_IRON_TRAPDOOR_CLOSE, SoundCategory.BLOCKS, 1.0F, this.world.rand.nextFloat() * 0.1F + 0.9F, false); break; -@@ -3278,7 +3324,10 @@ +@@ -3278,7 +3327,10 @@ { soundtype = (SoundType)Reflector.call(block, Reflector.ForgeBlock_getSoundType, new Object[] {Block.getStateById(data), this.world, blockPosIn, null}); } diff --git a/src/com/mtbs3d/minecrift/api/IRoomscaleAdapter.java b/src/com/mtbs3d/minecrift/api/IRoomscaleAdapter.java index 6667a7e..c62a12f 100644 --- a/src/com/mtbs3d/minecrift/api/IRoomscaleAdapter.java +++ b/src/com/mtbs3d/minecrift/api/IRoomscaleAdapter.java @@ -21,8 +21,11 @@ public interface IRoomscaleAdapter { public boolean isHMDTracking(); public Vec3d getHMDPos_World(); public Vec3d getHMDPos_Room(); - public Vec3d getHMDDir_World(); + public Vec3d getHMDDir_World(); + public Vec3d getHMDDir_Room(); + public float getHMDYaw_Room(); //degrees public float getHMDYaw_World(); //degrees + public float getHMDPitch_Room(); //degrees public float getHMDPitch_World(); //degrees public FloatBuffer getHMDMatrix_World(); @@ -47,6 +50,7 @@ public interface IRoomscaleAdapter { public Vec3d getCustomControllerVector(int controller, Vec3d axis); public Vec3d getCustomHMDVector(Vec3d axis); + public Vec3d getCustomHandVector(int controller, Vec3d axis); public Vec3d getRoomOriginPos_World(); //degrees public Vec3d getRoomOriginUpDir_World(); //what do you do diff --git a/src/com/mtbs3d/minecrift/control/VRControllerButtonMapping.java b/src/com/mtbs3d/minecrift/control/VRControllerButtonMapping.java index 70a623f..598aa14 100644 --- a/src/com/mtbs3d/minecrift/control/VRControllerButtonMapping.java +++ b/src/com/mtbs3d/minecrift/control/VRControllerButtonMapping.java @@ -2,11 +2,16 @@ import java.awt.event.KeyEvent; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.Display; + +import com.mtbs3d.minecrift.provider.MCOpenVR; import com.mtbs3d.minecrift.utils.KeyboardSimulator; import com.mtbs3d.minecrift.utils.MCReflection; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; +import net.minecraft.src.Reflector; public class VRControllerButtonMapping { @@ -103,10 +108,20 @@ public static void setKeyBindState(KeyBinding kb, boolean pressed) { } public static void pressKey(KeyBinding kb) { - setKeyBindState(kb, true); + int awtCode = KeyboardSimulator.translateToAWT(kb.getKeyCode()); + if (Display.isActive() && awtCode != Keyboard.KEY_NONE && !MCOpenVR.isVivecraftBinding(kb) && (!Reflector.forgeExists() || Reflector.call(kb, Reflector.ForgeKeyBinding_getKeyModifier) == Reflector.getFieldValue(Reflector.KeyModifier_NONE))) { + KeyboardSimulator.robot.keyPress(awtCode); + } else { + setKeyBindState(kb, true); + } } public static void unpressKey(KeyBinding kb) { - MCReflection.invokeMethod(MCReflection.KeyBinding_unpressKey, kb); + int awtCode = KeyboardSimulator.translateToAWT(kb.getKeyCode()); + if (Display.isActive() && awtCode != Keyboard.KEY_NONE && !MCOpenVR.isVivecraftBinding(kb) && (!Reflector.forgeExists() || Reflector.call(kb, Reflector.ForgeKeyBinding_getKeyModifier) == Reflector.getFieldValue(Reflector.KeyModifier_NONE))) { + KeyboardSimulator.robot.keyRelease(awtCode); + } else { + MCReflection.invokeMethod(MCReflection.KeyBinding_unpressKey, kb); + } } } diff --git a/src/com/mtbs3d/minecrift/gui/GuiHUDSettings.java b/src/com/mtbs3d/minecrift/gui/GuiHUDSettings.java index 6a99859..9ec375e 100644 --- a/src/com/mtbs3d/minecrift/gui/GuiHUDSettings.java +++ b/src/com/mtbs3d/minecrift/gui/GuiHUDSettings.java @@ -24,6 +24,7 @@ public class GuiHUDSettings extends BaseGuiSettings VRSettings.VrOptions.RENDER_MENU_BACKGROUND, VRSettings.VrOptions.TOUCH_HOTBAR, VRSettings.VrOptions.MENU_ALWAYS_FOLLOW_FACE, + VRSettings.VrOptions.AUTO_OPEN_KEYBOARD, }; public GuiHUDSettings(GuiScreen guiScreen, VRSettings guivrSettings) { @@ -213,6 +214,15 @@ protected String[] getTooltipLines(String displayString, int buttonId) "If enabled allow you to touch the hotbar with", "your main hand to select an item." }; + case AUTO_OPEN_KEYBOARD: + return new String[] { + "If disabled, SteamVR keyboard will only open when you", + "click a text field, or if a text field can't lose focus.", + "", + "If enabled, SteamVR keyboard will open automatically", + "any time a text field comes into focus. Enabling this will", + "cause it to open in unwanted situations with mods." + }; default: return null; } diff --git a/src/com/mtbs3d/minecrift/gui/GuiVRControlsList.java b/src/com/mtbs3d/minecrift/gui/GuiVRControlsList.java index f0511d5..6780da5 100644 --- a/src/com/mtbs3d/minecrift/gui/GuiVRControlsList.java +++ b/src/com/mtbs3d/minecrift/gui/GuiVRControlsList.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.Arrays; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiListExtended; @@ -14,6 +15,7 @@ import net.minecraft.util.text.TextFormatting; import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.input.Keyboard; import com.mtbs3d.minecrift.control.VRControllerButtonMapping; import com.mtbs3d.minecrift.control.ViveButtons; @@ -223,8 +225,10 @@ public boolean mousePressed(int p_148278_1_, int p_148278_2_, int p_148278_3_, i if (this.btnChangeKeyBinding.mousePressed(GuiVRControlsList.this.mc, p_148278_2_, p_148278_3_)) { //cycle? select from list? - myi++; + if (GuiScreen.isShiftKeyDown()) myi--; + else myi++; if(myi >= possibilites.size()) myi = 0; + if(myi < 0) myi = possibilites.size() - 1; this.myKey.FunctionDesc = possibilites.get(myi); bindKey(myKey); diff --git a/src/com/mtbs3d/minecrift/provider/MCOpenVR.java b/src/com/mtbs3d/minecrift/provider/MCOpenVR.java index 2fb1c90..6b259e3 100644 --- a/src/com/mtbs3d/minecrift/provider/MCOpenVR.java +++ b/src/com/mtbs3d/minecrift/provider/MCOpenVR.java @@ -9,6 +9,7 @@ import com.mtbs3d.minecrift.utils.InputInjector; import com.mtbs3d.minecrift.utils.KeyboardSimulator; import com.mtbs3d.minecrift.utils.MCReflection; +import com.mtbs3d.minecrift.utils.Utils; import com.sun.jna.Memory; import com.sun.jna.NativeLibrary; import com.sun.jna.Pointer; @@ -46,7 +47,6 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; -import optifine.Utils; import org.apache.commons.lang3.ArrayUtils; import org.apache.http.util.ByteArrayBuffer; @@ -285,7 +285,7 @@ public static boolean init() throws Exception mc = Minecraft.getMinecraft(); // look in .minecraft first for openvr_api.dll - File minecraftDir = Utils.getWorkingDirectory(); // misleading name, actually the .minecraft directory + File minecraftDir = optifine.Utils.getWorkingDirectory(); // misleading name, actually the .minecraft directory File workingDir = new File(System.getProperty("user.dir")); String osname = System.getProperty("os.name").toLowerCase(); @@ -466,7 +466,7 @@ public static void initOpenVROverlay() throws Exception vrOverlay.read(); System.out.println("OpenVR Overlay initialized OK"); } else { - if (getError() == 7) { + if (getError() != 0) { System.out.println("VROverlay init failed: " + jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(getError()).getString(0)); vrOverlay = null; } else { @@ -484,7 +484,7 @@ public static void initOpenVRSettings() throws Exception vrSettings.read(); System.out.println("OpenVR Settings initialized OK"); } else { - if (getError() == 7) { + if (getError() != 0) { System.out.println("VRSettings init failed: " + jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(getError()).getString(0)); vrSettings = null; } else { @@ -502,7 +502,7 @@ public static void initOpenVRRenderModels() throws Exception vrRenderModels.read(); System.out.println("OpenVR RenderModels initialized OK"); } else { - if (getError() == 7) { + if (getError() != 0) { System.out.println("VRRenderModels init failed: " + jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(getError()).getString(0)); vrRenderModels = null; } else { @@ -518,7 +518,7 @@ private static void initOpenVRChaperone() throws Exception { vrChaperone.read(); System.out.println("OpenVR chaperone initialized."); } else { - if (getError() == 7) { + if (getError() != 0) { System.out.println("VRChaperone init failed: " + jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(getError()).getString(0)); vrChaperone = null; } else { @@ -697,34 +697,16 @@ public static boolean setKeyboardOverlayShowing(boolean showingState, GuiTextFie Pointer empty = new Memory(1); empty.setString(0, ""); -// HmdMatrix34_t keyboardpos = new HmdMatrix34_t(); -// //keyboardpos.m[0] = guiRotationPose.M[0][0]; -// //keyboardpos.m[1] = guiRotationPose.M[0][1]; -// //keyboardpos.m[2] = guiRotationPose.M[0][2]; -// keyboardpos.m[3] = guiPos_Room.x; -// -// //keyboardpos.m[4] = guiRotationPose.M[1][0]; -// //keyboardpos.m[5] = guiRotationPose.M[1][1]; -// //keyboardpos.m[6] = guiRotationPose.M[1][2]; -// keyboardpos.m[7] = guiPos_Room.y; -// -// //keyboardpos.m[8] = guiRotationPose.M[2][0]; -// //keyboardpos.m[9] = guiRotationPose.M[2][1]; -// //keyboardpos.m[10] = guiRotationPose.M[2][2]; -// keyboardpos.m[11] = guiPos_Room.z; - - ret = vrOverlay.ShowKeyboard.apply(0, 0, pointer, 256, empty, (byte)1, 0); - - //vrOverlay.SetKeyboardTransformAbsolute.apply(JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseStanding,keyboardpos); - - keyboardShowing = 0 == ret; //0 = no error, > 0 see EVROverlayError + ret = vrOverlay.ShowKeyboard.apply(0, 0, pointer, 256, empty, (byte)1, 0); + keyboardShowing = 0 == ret; //0 = no error, > 0 see EVROverlayError if (ret != 0) { - String err = vrOverlay.GetOverlayErrorNameFromEnum.apply(ret).getString(0); + String err = vrOverlay.GetOverlayErrorNameFromEnum.apply(ret).getString(0); System.out.println("VR Overlay Error: " + err); if(err.equalsIgnoreCase("VROverlayError_KeyboardAlreadyInUse")) keyboardShowing = true; } + if (mc.currentScreen != null) orientKeyboardOverlay(true); } else { try { vrOverlay.HideKeyboard.apply(); @@ -736,6 +718,29 @@ public static boolean setKeyboardOverlayShowing(boolean showingState, GuiTextFie return keyboardShowing; } + + public static void orientKeyboardOverlay(boolean guiRelative) { + if (vrOverlay == null) return; + if (!keyboardShowing) return; + org.lwjgl.util.vector.Matrix4f matrix = new org.lwjgl.util.vector.Matrix4f(); + if (guiRelative) { + org.lwjgl.util.vector.Matrix4f guiRot = Utils.convertOVRMatrix(guiRotationPose); + Vec3d guiUp = new Vec3d(guiRot.m10, guiRot.m11, guiRot.m12); + guiUp = guiUp.scale(guiScale); + matrix.rotate((float)Math.toRadians(mc.vrSettings.vrWorldRotation), new org.lwjgl.util.vector.Vector3f(0, -1, 0)); // negate world rotation + matrix.translate(new org.lwjgl.util.vector.Vector3f(guiPos_Room.x - (float)guiUp.xCoord, guiPos_Room.y - (float)guiUp.yCoord, guiPos_Room.z - (float)guiUp.zCoord)); + org.lwjgl.util.vector.Matrix4f.mul(matrix, guiRot, matrix); + matrix.rotate((float)Math.toRadians(30), new org.lwjgl.util.vector.Vector3f(-1, 0, 0)); // tilt it a bit + } else { + Vec3d hmdPos = mc.roomScale.getHMDPos_Room(); + Vec3d hmdDir = mc.roomScale.getHMDDir_Room(); + hmdDir = hmdDir.scale(mc.vrSettings.hudDistance); + matrix.translate(new org.lwjgl.util.vector.Vector3f((float)hmdPos.xCoord + (float)hmdDir.xCoord, (float)hmdPos.yCoord - 1.0F, (float)hmdPos.zCoord + (float)hmdDir.zCoord)); + matrix.rotate((float)Math.toRadians(mc.roomScale.getHMDYaw_Room() + 180), new org.lwjgl.util.vector.Vector3f(0, -1, 0)); // +180 because it needs to face towards the HMD + matrix.rotate((float)Math.toRadians(30), new org.lwjgl.util.vector.Vector3f(-1, 0, 0)); // tilt it a bit + } + vrOverlay.SetKeyboardTransformAbsolute.apply(JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseStanding, Utils.convertToMatrix34(matrix)); + } private static Vec3d vecFromVector(Vector3f in){ return new Vec3d(in.x, in.y, in.z); @@ -954,8 +959,8 @@ else if (controllerMouseX == -1.0f) if (controllerDeviceIndex[RIGHT_CONTROLLER] != -1) { - Mouse.setCursorPosition(mouseX, mouseY); - //KeyboardSimulator.robot.mouseMove(Display.getX() + mouseX, Display.getY() + mouseY); + InputInjector.mouseMoveEvent(mouseX, mouseY); // Needs to be called first, since it only puts an event if delta != 0 + Mouse.setCursorPosition(mouseX, mouseY); controllerMouseValid = true; //LMB @@ -2685,6 +2690,10 @@ public static void resetPosition() { public static void clearOffset() { offset=new Vector3f(0,0,0); } + + public static boolean isVivecraftBinding(KeyBinding kb) { + return kb == hotbarNext || kb == hotbarPrev || kb == rotateLeft || kb == rotateRight || kb == walkabout || kb == rotateFree || kb == quickTorch; + } } diff --git a/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java b/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java index 74329a5..b90aae5 100644 --- a/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java +++ b/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java @@ -106,6 +106,8 @@ public OpenVRPlayer() } + public boolean debugSpawn; + public void setRoomOrigin(double x, double y, double z, boolean reset, boolean onframe ) { if(!onframe){ if (reset){ @@ -117,7 +119,10 @@ public void setRoomOrigin(double x, double y, double z, boolean reset, boolean o roomOrigin = new Vec3d(x, y, z); lastRoomUpdateTime = Minecraft.getMinecraft().stereoProvider.getCurrentTimeSecs(); Minecraft.getMinecraft().entityRenderer.irpUpdatedThisFrame = onframe; - //System.out.println("room origin " + x + " " + y + " " + z); + if(debugSpawn){ + System.out.println("room origin " + x + " " + y + " " + z + " " + onframe + " " + reset); + Thread.dumpStack(); + } } private int roomScaleMovementDelay = 10; @@ -127,9 +132,7 @@ public void snapRoomOriginToPlayerEntity(EntityPlayerSP player, boolean reset, b { if (Thread.currentThread().getName().equals("Server thread")) return; - - if(!Minecraft.getMinecraft().player.initFromServer) return; - + if(player.posX == 0 && player.posY == 0 &&player.posZ == 0) return; Minecraft mc = Minecraft.getMinecraft(); @@ -171,7 +174,7 @@ public void snapRoomOriginToPlayerEntity(EntityPlayerSP player, boolean reset, b public void checkandUpdateRotateScale(boolean onFrame, float nano){ Minecraft mc = Minecraft.getMinecraft(); - if(mc.player.initFromServer == false) return; + if(mc.player == null || mc.player.initFromServer == false) return; if(!onFrame && mc.currentScreen!=null) return; if(!onFrame) { @@ -215,14 +218,6 @@ public void onLivingUpdate(EntityPlayerSP player, Minecraft mc, Random rand) if(!player.initFromServer) return; if(!initdone){ - - System.out.println(""); - System.out.println("Room object: "+mc.roomScale); - System.out.println("Room origin: "+mc.roomScale.getRoomOriginPos_World()); - System.out.println("Hmd position room: "+mc.roomScale.getHMDPos_Room()); - System.out.println("Hmd position world: "+mc.roomScale.getHMDPos_World()); - System.out.println(""); - initdone =true; } @@ -636,6 +631,8 @@ else if ((mc.vrSettings.walkUpBlocks || (mc.climbTracker.isGrabbingLadder() && m } } } + if(debugSpawn) System.out.println("dpminR " + player.posX + " " + player.posY + " " + player.posZ); + } public void playFootstepSound( Minecraft mc, double x, double y, double z ) @@ -1484,12 +1481,24 @@ public Vec3d getHMDDir_World() { return out; } + @Override + public float getHMDYaw_Room() { + Vec3d dir = getHMDDir_Room(); + return (float)Math.toDegrees(Math.atan2(-dir.xCoord, dir.zCoord)); + } + @Override public float getHMDYaw_World() { Vec3d dir = getHMDDir_World(); return (float)Math.toDegrees(Math.atan2(-dir.xCoord, dir.zCoord)); } + @Override + public float getHMDPitch_Room() { + Vec3d dir = getHMDDir_Room(); + return (float)Math.toDegrees(Math.asin(dir.yCoord/dir.lengthVector())); + } + @Override public float getHMDPitch_World() { Vec3d dir = getHMDDir_World(); @@ -1636,12 +1645,14 @@ public boolean isControllerTracking(int c) { return MCOpenVR.controllerTracking[c]; } + @Override public Vec3d getCustomHandVector(int controller, Vec3d axis) { Vector3f v3 = MCOpenVR.getHandRotation(controller).transform(new Vector3f((float)axis.xCoord, (float)axis.yCoord,(float) axis.zCoord)); Vec3d out = new Vec3d(v3.x, v3.y, v3.z).rotateYaw(worldRotationRadians); return out; } + @Override public Vec3d getHMDDir_Room() { Vector3f v3 = MCOpenVR.headDirection; Vec3d out = new Vec3d(v3.x, v3.y, v3.z); diff --git a/src/com/mtbs3d/minecrift/settings/VRSettings.java b/src/com/mtbs3d/minecrift/settings/VRSettings.java index 8f1a43c..247966a 100644 --- a/src/com/mtbs3d/minecrift/settings/VRSettings.java +++ b/src/com/mtbs3d/minecrift/settings/VRSettings.java @@ -186,6 +186,7 @@ public class VRSettings public float menuCrosshairScale = 1f; public boolean useCrosshairOcclusion = false; public boolean seatedHudAltMode = true; + public boolean autoOpenKeyboard = false; // private Minecraft mc; @@ -621,6 +622,10 @@ public void loadOptions(JSONObject theProfiles) if(optionTokens[0].equals("alwaysSimulateKeyboard")){ this.alwaysSimulateKeyboard=optionTokens[1].equals("true"); } + + if(optionTokens[0].equals("autoOpenKeyboard")){ + this.autoOpenKeyboard=optionTokens[1].equals("true"); + } if (optionTokens[0].startsWith("BUTTON_") || optionTokens[0].startsWith("OCULUS_")) { @@ -924,6 +929,8 @@ else if (this.inertiaFactor == INERTIA_MASSIVE) } case FOV_REDUCTION: return this.useFOVReduction ? var4 + "ON" : var4 + "OFF"; + case AUTO_OPEN_KEYBOARD: + return this.autoOpenKeyboard ? var4 + "YES" : var4 + "NO"; default: return ""; } @@ -1191,6 +1198,9 @@ public void setOptionValue(VRSettings.VrOptions par1EnumOptions, int par2) case CROSSHAIR_SCALES_WITH_DISTANCE: crosshairScalesWithDistance = !crosshairScalesWithDistance; break; + case AUTO_OPEN_KEYBOARD: + autoOpenKeyboard = !autoOpenKeyboard; + break; default: break; } @@ -1392,6 +1402,7 @@ private void saveOptions(JSONObject theProfiles) var5.println("vehicleRotation:" + this.vehicleRotation); var5.println("fovReduction:" + this.useFOVReduction); var5.println("alwaysSimulateKeyboard:" + this.alwaysSimulateKeyboard); + var5.println("autoOpenKeyboard:" + this.autoOpenKeyboard); if (vrQuickCommands == null) vrQuickCommands = getQuickCommandsDefaults(); //defaults @@ -1499,6 +1510,7 @@ public static enum VrOptions RENDER_OWN_HEADWEAR("Render Own Headwear", false, true), RENDER_FULL_FIRST_PERSON_MODEL_MODE("First Person Model", false, true), RENDER_PLAYER_OFFSET("View Body Offset", true, false), + AUTO_OPEN_KEYBOARD("Auto Open Keyboard", false, true), //HMD/render diff --git a/src/com/mtbs3d/minecrift/utils/InputInjector.java b/src/com/mtbs3d/minecrift/utils/InputInjector.java index 2772c99..15bd024 100644 --- a/src/com/mtbs3d/minecrift/utils/InputInjector.java +++ b/src/com/mtbs3d/minecrift/utils/InputInjector.java @@ -5,6 +5,7 @@ import java.nio.ByteBuffer; import org.lwjgl.LWJGLUtil; +import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; import com.google.common.base.Throwables; @@ -14,40 +15,66 @@ * Do not look unless you want your eyeballs to implode. */ public class InputInjector { + private static boolean supportChecked = false; private static boolean supported = true; //private static Method putMouseEvent; private static Method putKeyboardEvent; + private static Method putMouseEventWithCoords; private static Object keyboard; private static Object mouse; + private static Class displayClass; private static Class keyboardClass; private static Class mouseClass; - private static void lazyLoad() { - if (supported && (keyboard == null || mouse == null)) { + private static void checkSupported() { + if (!supportChecked) { + supported = LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS || LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_LINUX; + if (supported) System.out.println("Yay, InputInjector is supported on this platform!"); + else System.out.println("InputInjector is not supported on this platform, will fall back to less compatible methods."); + supportChecked = true; + } + } + + private static boolean loadObjects() { + checkSupported(); + if (supported) { // They need to be loaded every time because apparently they can be recreated without warning + if (displayClass == null) loadClasses(); try { Object displayImpl = getFieldValue(Display.class, "display_impl", null); switch (LWJGLUtil.getPlatform()) { case LWJGLUtil.PLATFORM_WINDOWS: - keyboard = getFieldValue(Class.forName("org.lwjgl.opengl.WindowsDisplay"), "keyboard", displayImpl); - mouse = getFieldValue(Class.forName("org.lwjgl.opengl.WindowsDisplay"), "mouse", displayImpl); - keyboardClass = Class.forName("org.lwjgl.opengl.WindowsKeyboard"); - mouseClass = Class.forName("org.lwjgl.opengl.WindowsMouse"); + keyboard = getFieldValue(displayClass, "keyboard", displayImpl); + mouse = getFieldValue(displayClass, "mouse", displayImpl); break; case LWJGLUtil.PLATFORM_LINUX: - keyboard = getFieldValue(Class.forName("org.lwjgl.opengl.LinuxDisplay"), "keyboard", displayImpl); - mouse = getFieldValue(Class.forName("org.lwjgl.opengl.LinuxDisplay"), "mouse", displayImpl); - keyboardClass = Class.forName("org.lwjgl.opengl.LinuxKeyboard"); - mouseClass = Class.forName("org.lwjgl.opengl.LinuxMouse"); + keyboard = getFieldValue(displayClass, "keyboard", displayImpl); + mouse = getFieldValue(displayClass, "mouse", displayImpl); break; - default: - supported = false; - System.out.println("InputInjector is not supported on this platform"); - return; } } catch (Exception e) { Throwables.propagate(e); } } + return supported; + } + + private static void loadClasses() { + try { + switch (LWJGLUtil.getPlatform()) { + case LWJGLUtil.PLATFORM_WINDOWS: + displayClass = Class.forName("org.lwjgl.opengl.WindowsDisplay"); + keyboardClass = Class.forName("org.lwjgl.opengl.WindowsKeyboard"); + mouseClass = Class.forName("org.lwjgl.opengl.WindowsMouse"); + break; + case LWJGLUtil.PLATFORM_LINUX: + displayClass = Class.forName("org.lwjgl.opengl.LinuxDisplay"); + keyboardClass = Class.forName("org.lwjgl.opengl.LinuxKeyboard"); + mouseClass = Class.forName("org.lwjgl.opengl.LinuxMouse"); + break; + } + } catch (Exception e) { + Throwables.propagate(e); + } } private static Object getFieldValue(Class clazz, String name, Object obj) throws ReflectiveOperationException { @@ -56,22 +83,17 @@ private static Object getFieldValue(Class clazz, String name, Object obj) throws return field.get(obj); } - public static boolean putMouseEvent(byte button, byte state, int dz, long nanos) throws ReflectiveOperationException { - /*lazyLoad(); - if (putMouseEvent == null) { - if (LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS) - putMouseEvent = mouseClass.getDeclaredMethod("putMouseEvent", Byte.TYPE, Byte.TYPE, Integer.TYPE, Long.TYPE); - else - putMouseEvent = mouseClass.getDeclaredMethod("putMouseEvent", Boolean.TYPE, Byte.TYPE, Byte.TYPE, Integer.TYPE, Long.TYPE); - putMouseEvent.setAccessible(true); + private static void putMouseEventWithCoords(int button, boolean state, int coord1, int coord2, int dz, long nanos) throws ReflectiveOperationException { + if (!loadObjects()) return; + if (putMouseEventWithCoords == null) { + putMouseEventWithCoords = mouseClass.getDeclaredMethod("putMouseEventWithCoords", Byte.TYPE, Byte.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE, Long.TYPE); + putMouseEventWithCoords.setAccessible(true); } - return (Boolean)putMouseEvent.invoke(mouse, button, state, dz, nanos);*/ - throw new UnsupportedOperationException("Not supported yet"); - // TODO: maybe do some major hacking and finally fix window focus requirement? + putMouseEventWithCoords.invoke(mouse, (byte)button, state ? (byte)1 : (byte)0, coord1, coord2, dz, nanos); } private static void putKeyboardEvent(int keycode, boolean state, int ch) throws ReflectiveOperationException { - lazyLoad(); + if (!loadObjects()) return; boolean windows = LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS; if (putKeyboardEvent == null) { putKeyboardEvent = keyboardClass.getDeclaredMethod(windows ? "putEvent" : "putKeyboardEvent", Integer.TYPE, Byte.TYPE, Integer.TYPE, Long.TYPE, Boolean.TYPE); @@ -101,7 +123,25 @@ public static void typeKey(int code, char ch) { releaseKey(code, ch); } + public static void mouseMoveEvent(int x, int y) { + try { + int dx = x - Mouse.getX(); + int dy = y - Mouse.getY(); // TODO: Find out if linux needs transformed (inverted) Y + if (dx != 0 || dy != 0) { + long nanos = System.nanoTime(); + if (Mouse.isGrabbed()) { + putMouseEventWithCoords(-1, false, dx, dy, 0, nanos); + } else { + putMouseEventWithCoords(-1, false, x, y, 0, nanos); + } + } + } catch (Exception e) { + Throwables.propagate(e); + } + } + public static boolean isSupported() { + checkSupported(); return supported; } } diff --git a/src/com/mtbs3d/minecrift/utils/KeyboardSimulator.java b/src/com/mtbs3d/minecrift/utils/KeyboardSimulator.java index cd8be65..c0cc894 100644 --- a/src/com/mtbs3d/minecrift/utils/KeyboardSimulator.java +++ b/src/com/mtbs3d/minecrift/utils/KeyboardSimulator.java @@ -9,6 +9,7 @@ import java.awt.AWTException; import java.awt.Robot; +import java.awt.event.KeyEvent; public class KeyboardSimulator { @@ -48,6 +49,236 @@ public static void type(char character) { int[] chars = getCodes(character); doType(chars, 0, chars.length); } + + public static int translateFromAWT(int code) { + switch (code) { + case KeyEvent.VK_ESCAPE: return Keyboard.KEY_ESCAPE; + case KeyEvent.VK_1: return Keyboard.KEY_1; + case KeyEvent.VK_2: return Keyboard.KEY_2; + case KeyEvent.VK_3: return Keyboard.KEY_3; + case KeyEvent.VK_4: return Keyboard.KEY_4; + case KeyEvent.VK_5: return Keyboard.KEY_5; + case KeyEvent.VK_6: return Keyboard.KEY_6; + case KeyEvent.VK_7: return Keyboard.KEY_7; + case KeyEvent.VK_8: return Keyboard.KEY_8; + case KeyEvent.VK_9: return Keyboard.KEY_9; + case KeyEvent.VK_0: return Keyboard.KEY_0; + case KeyEvent.VK_MINUS: return Keyboard.KEY_MINUS; + case KeyEvent.VK_EQUALS: return Keyboard.KEY_EQUALS; + case KeyEvent.VK_BACK_SPACE: return Keyboard.KEY_BACK; + case KeyEvent.VK_TAB: return Keyboard.KEY_TAB; + case KeyEvent.VK_Q: return Keyboard.KEY_Q; + case KeyEvent.VK_W: return Keyboard.KEY_W; + case KeyEvent.VK_E: return Keyboard.KEY_E; + case KeyEvent.VK_R: return Keyboard.KEY_R; + case KeyEvent.VK_T: return Keyboard.KEY_T; + case KeyEvent.VK_Y: return Keyboard.KEY_Y; + case KeyEvent.VK_U: return Keyboard.KEY_U; + case KeyEvent.VK_I: return Keyboard.KEY_I; + case KeyEvent.VK_O: return Keyboard.KEY_O; + case KeyEvent.VK_P: return Keyboard.KEY_P; + case KeyEvent.VK_OPEN_BRACKET: return Keyboard.KEY_LBRACKET; + case KeyEvent.VK_CLOSE_BRACKET: return Keyboard.KEY_RBRACKET; + case KeyEvent.VK_ENTER: return Keyboard.KEY_RETURN; + case KeyEvent.VK_CONTROL: return Keyboard.KEY_LCONTROL; + case KeyEvent.VK_A: return Keyboard.KEY_A; + case KeyEvent.VK_S: return Keyboard.KEY_S; + case KeyEvent.VK_D: return Keyboard.KEY_D; + case KeyEvent.VK_F: return Keyboard.KEY_F; + case KeyEvent.VK_G: return Keyboard.KEY_G; + case KeyEvent.VK_H: return Keyboard.KEY_H; + case KeyEvent.VK_J: return Keyboard.KEY_J; + case KeyEvent.VK_K: return Keyboard.KEY_K; + case KeyEvent.VK_L: return Keyboard.KEY_L; + case KeyEvent.VK_SEMICOLON: return Keyboard.KEY_SEMICOLON; + case KeyEvent.VK_QUOTE: return Keyboard.KEY_APOSTROPHE; + case KeyEvent.VK_DEAD_GRAVE: return Keyboard.KEY_GRAVE; + case KeyEvent.VK_SHIFT: return Keyboard.KEY_LSHIFT; + case KeyEvent.VK_BACK_SLASH: return Keyboard.KEY_BACKSLASH; + case KeyEvent.VK_Z: return Keyboard.KEY_Z; + case KeyEvent.VK_X: return Keyboard.KEY_X; + case KeyEvent.VK_C: return Keyboard.KEY_C; + case KeyEvent.VK_V: return Keyboard.KEY_V; + case KeyEvent.VK_B: return Keyboard.KEY_B; + case KeyEvent.VK_N: return Keyboard.KEY_N; + case KeyEvent.VK_M: return Keyboard.KEY_M; + case KeyEvent.VK_COMMA: return Keyboard.KEY_COMMA; + case KeyEvent.VK_PERIOD: return Keyboard.KEY_PERIOD; + case KeyEvent.VK_SLASH: return Keyboard.KEY_SLASH; + case KeyEvent.VK_MULTIPLY: return Keyboard.KEY_MULTIPLY; + case KeyEvent.VK_ALT: return Keyboard.KEY_LMENU; + case KeyEvent.VK_SPACE: return Keyboard.KEY_SPACE; + case KeyEvent.VK_CAPS_LOCK: return Keyboard.KEY_CAPITAL; + case KeyEvent.VK_F1: return Keyboard.KEY_F1; + case KeyEvent.VK_F2: return Keyboard.KEY_F2; + case KeyEvent.VK_F3: return Keyboard.KEY_F3; + case KeyEvent.VK_F4: return Keyboard.KEY_F4; + case KeyEvent.VK_F5: return Keyboard.KEY_F5; + case KeyEvent.VK_F6: return Keyboard.KEY_F6; + case KeyEvent.VK_F7: return Keyboard.KEY_F7; + case KeyEvent.VK_F8: return Keyboard.KEY_F8; + case KeyEvent.VK_F9: return Keyboard.KEY_F9; + case KeyEvent.VK_F10: return Keyboard.KEY_F10; + case KeyEvent.VK_NUM_LOCK: return Keyboard.KEY_NUMLOCK; + case KeyEvent.VK_SCROLL_LOCK: return Keyboard.KEY_SCROLL; + case KeyEvent.VK_NUMPAD7: return Keyboard.KEY_NUMPAD7; + case KeyEvent.VK_NUMPAD8: return Keyboard.KEY_NUMPAD8; + case KeyEvent.VK_NUMPAD9: return Keyboard.KEY_NUMPAD9; + case KeyEvent.VK_SUBTRACT: return Keyboard.KEY_SUBTRACT; + case KeyEvent.VK_NUMPAD4: return Keyboard.KEY_NUMPAD4; + case KeyEvent.VK_NUMPAD5: return Keyboard.KEY_NUMPAD5; + case KeyEvent.VK_NUMPAD6: return Keyboard.KEY_NUMPAD6; + case KeyEvent.VK_ADD: return Keyboard.KEY_ADD; + case KeyEvent.VK_NUMPAD1: return Keyboard.KEY_NUMPAD1; + case KeyEvent.VK_NUMPAD2: return Keyboard.KEY_NUMPAD2; + case KeyEvent.VK_NUMPAD3: return Keyboard.KEY_NUMPAD3; + case KeyEvent.VK_NUMPAD0: return Keyboard.KEY_NUMPAD0; + case KeyEvent.VK_DECIMAL: return Keyboard.KEY_DECIMAL; + case KeyEvent.VK_F11: return Keyboard.KEY_F11; + case KeyEvent.VK_F12: return Keyboard.KEY_F12; + case KeyEvent.VK_F13: return Keyboard.KEY_F13; + case KeyEvent.VK_F14: return Keyboard.KEY_F14; + case KeyEvent.VK_F15: return Keyboard.KEY_F15; + case KeyEvent.VK_KANA: return Keyboard.KEY_KANA; + case KeyEvent.VK_CONVERT: return Keyboard.KEY_CONVERT; + case KeyEvent.VK_NONCONVERT: return Keyboard.KEY_NOCONVERT; + case KeyEvent.VK_CIRCUMFLEX: return Keyboard.KEY_CIRCUMFLEX; + case KeyEvent.VK_AT: return Keyboard.KEY_AT; + case KeyEvent.VK_COLON: return Keyboard.KEY_COLON; + case KeyEvent.VK_UNDERSCORE: return Keyboard.KEY_UNDERLINE; + case KeyEvent.VK_KANJI: return Keyboard.KEY_KANJI; + case KeyEvent.VK_STOP: return Keyboard.KEY_STOP; + case KeyEvent.VK_DIVIDE: return Keyboard.KEY_DIVIDE; + case KeyEvent.VK_PAUSE: return Keyboard.KEY_PAUSE; + case KeyEvent.VK_HOME: return Keyboard.KEY_HOME; + case KeyEvent.VK_UP: return Keyboard.KEY_UP; + case KeyEvent.VK_PAGE_UP: return Keyboard.KEY_PRIOR; + case KeyEvent.VK_LEFT: return Keyboard.KEY_LEFT; + case KeyEvent.VK_RIGHT: return Keyboard.KEY_RIGHT; + case KeyEvent.VK_END: return Keyboard.KEY_END; + case KeyEvent.VK_DOWN: return Keyboard.KEY_DOWN; + case KeyEvent.VK_PAGE_DOWN: return Keyboard.KEY_NEXT; + case KeyEvent.VK_INSERT: return Keyboard.KEY_INSERT; + case KeyEvent.VK_DELETE: return Keyboard.KEY_DELETE; + case KeyEvent.VK_META: return Keyboard.KEY_LWIN; + } + return Keyboard.KEY_NONE; + } + + public static int translateToAWT(int code) { + switch (code) { + case Keyboard.KEY_ESCAPE: return KeyEvent.VK_ESCAPE; + case Keyboard.KEY_1: return KeyEvent.VK_1; + case Keyboard.KEY_2: return KeyEvent.VK_2; + case Keyboard.KEY_3: return KeyEvent.VK_3; + case Keyboard.KEY_4: return KeyEvent.VK_4; + case Keyboard.KEY_5: return KeyEvent.VK_5; + case Keyboard.KEY_6: return KeyEvent.VK_6; + case Keyboard.KEY_7: return KeyEvent.VK_7; + case Keyboard.KEY_8: return KeyEvent.VK_8; + case Keyboard.KEY_9: return KeyEvent.VK_9; + case Keyboard.KEY_0: return KeyEvent.VK_0; + case Keyboard.KEY_MINUS: return KeyEvent.VK_MINUS; + case Keyboard.KEY_EQUALS: return KeyEvent.VK_EQUALS; + case Keyboard.KEY_BACK: return KeyEvent.VK_BACK_SPACE; + case Keyboard.KEY_TAB: return KeyEvent.VK_TAB; + case Keyboard.KEY_Q: return KeyEvent.VK_Q; + case Keyboard.KEY_W: return KeyEvent.VK_W; + case Keyboard.KEY_E: return KeyEvent.VK_E; + case Keyboard.KEY_R: return KeyEvent.VK_R; + case Keyboard.KEY_T: return KeyEvent.VK_T; + case Keyboard.KEY_Y: return KeyEvent.VK_Y; + case Keyboard.KEY_U: return KeyEvent.VK_U; + case Keyboard.KEY_I: return KeyEvent.VK_I; + case Keyboard.KEY_O: return KeyEvent.VK_O; + case Keyboard.KEY_P: return KeyEvent.VK_P; + case Keyboard.KEY_LBRACKET: return KeyEvent.VK_OPEN_BRACKET; + case Keyboard.KEY_RBRACKET: return KeyEvent.VK_CLOSE_BRACKET; + case Keyboard.KEY_RETURN: return KeyEvent.VK_ENTER; + case Keyboard.KEY_LCONTROL: return KeyEvent.VK_CONTROL; + case Keyboard.KEY_A: return KeyEvent.VK_A; + case Keyboard.KEY_S: return KeyEvent.VK_S; + case Keyboard.KEY_D: return KeyEvent.VK_D; + case Keyboard.KEY_F: return KeyEvent.VK_F; + case Keyboard.KEY_G: return KeyEvent.VK_G; + case Keyboard.KEY_H: return KeyEvent.VK_H; + case Keyboard.KEY_J: return KeyEvent.VK_J; + case Keyboard.KEY_K: return KeyEvent.VK_K; + case Keyboard.KEY_L: return KeyEvent.VK_L; + case Keyboard.KEY_SEMICOLON: return KeyEvent.VK_SEMICOLON; + case Keyboard.KEY_APOSTROPHE: return KeyEvent.VK_QUOTE; + case Keyboard.KEY_GRAVE: return KeyEvent.VK_DEAD_GRAVE; + case Keyboard.KEY_LSHIFT: return KeyEvent.VK_SHIFT; + case Keyboard.KEY_BACKSLASH: return KeyEvent.VK_BACK_SLASH; + case Keyboard.KEY_Z: return KeyEvent.VK_Z; + case Keyboard.KEY_X: return KeyEvent.VK_X; + case Keyboard.KEY_C: return KeyEvent.VK_C; + case Keyboard.KEY_V: return KeyEvent.VK_V; + case Keyboard.KEY_B: return KeyEvent.VK_B; + case Keyboard.KEY_N: return KeyEvent.VK_N; + case Keyboard.KEY_M: return KeyEvent.VK_M; + case Keyboard.KEY_COMMA: return KeyEvent.VK_COMMA; + case Keyboard.KEY_PERIOD: return KeyEvent.VK_PERIOD; + case Keyboard.KEY_SLASH: return KeyEvent.VK_SLASH; + case Keyboard.KEY_MULTIPLY: return KeyEvent.VK_MULTIPLY; + case Keyboard.KEY_LMENU: return KeyEvent.VK_ALT; + case Keyboard.KEY_SPACE: return KeyEvent.VK_SPACE; + case Keyboard.KEY_CAPITAL: return KeyEvent.VK_CAPS_LOCK; + case Keyboard.KEY_F1: return KeyEvent.VK_F1; + case Keyboard.KEY_F2: return KeyEvent.VK_F2; + case Keyboard.KEY_F3: return KeyEvent.VK_F3; + case Keyboard.KEY_F4: return KeyEvent.VK_F4; + case Keyboard.KEY_F5: return KeyEvent.VK_F5; + case Keyboard.KEY_F6: return KeyEvent.VK_F6; + case Keyboard.KEY_F7: return KeyEvent.VK_F7; + case Keyboard.KEY_F8: return KeyEvent.VK_F8; + case Keyboard.KEY_F9: return KeyEvent.VK_F9; + case Keyboard.KEY_F10: return KeyEvent.VK_F10; + case Keyboard.KEY_NUMLOCK: return KeyEvent.VK_NUM_LOCK; + case Keyboard.KEY_SCROLL: return KeyEvent.VK_SCROLL_LOCK; + case Keyboard.KEY_NUMPAD7: return KeyEvent.VK_NUMPAD7; + case Keyboard.KEY_NUMPAD8: return KeyEvent.VK_NUMPAD8; + case Keyboard.KEY_NUMPAD9: return KeyEvent.VK_NUMPAD9; + case Keyboard.KEY_SUBTRACT: return KeyEvent.VK_SUBTRACT; + case Keyboard.KEY_NUMPAD4: return KeyEvent.VK_NUMPAD4; + case Keyboard.KEY_NUMPAD5: return KeyEvent.VK_NUMPAD5; + case Keyboard.KEY_NUMPAD6: return KeyEvent.VK_NUMPAD6; + case Keyboard.KEY_ADD: return KeyEvent.VK_ADD; + case Keyboard.KEY_NUMPAD1: return KeyEvent.VK_NUMPAD1; + case Keyboard.KEY_NUMPAD2: return KeyEvent.VK_NUMPAD2; + case Keyboard.KEY_NUMPAD3: return KeyEvent.VK_NUMPAD3; + case Keyboard.KEY_NUMPAD0: return KeyEvent.VK_NUMPAD0; + case Keyboard.KEY_DECIMAL: return KeyEvent.VK_DECIMAL; + case Keyboard.KEY_F11: return KeyEvent.VK_F11; + case Keyboard.KEY_F12: return KeyEvent.VK_F12; + case Keyboard.KEY_F13: return KeyEvent.VK_F13; + case Keyboard.KEY_F14: return KeyEvent.VK_F14; + case Keyboard.KEY_F15: return KeyEvent.VK_F15; + case Keyboard.KEY_KANA: return KeyEvent.VK_KANA; + case Keyboard.KEY_CONVERT: return KeyEvent.VK_CONVERT; + case Keyboard.KEY_NOCONVERT: return KeyEvent.VK_NONCONVERT; + case Keyboard.KEY_CIRCUMFLEX: return KeyEvent.VK_CIRCUMFLEX; + case Keyboard.KEY_AT: return KeyEvent.VK_AT; + case Keyboard.KEY_COLON: return KeyEvent.VK_COLON; + case Keyboard.KEY_UNDERLINE: return KeyEvent.VK_UNDERSCORE; + case Keyboard.KEY_KANJI: return KeyEvent.VK_KANJI; + case Keyboard.KEY_STOP: return KeyEvent.VK_STOP; + case Keyboard.KEY_DIVIDE: return KeyEvent.VK_DIVIDE; + case Keyboard.KEY_PAUSE: return KeyEvent.VK_PAUSE; + case Keyboard.KEY_HOME: return KeyEvent.VK_HOME; + case Keyboard.KEY_UP: return KeyEvent.VK_UP; + case Keyboard.KEY_PRIOR: return KeyEvent.VK_PAGE_UP; + case Keyboard.KEY_LEFT: return KeyEvent.VK_LEFT; + case Keyboard.KEY_RIGHT: return KeyEvent.VK_RIGHT; + case Keyboard.KEY_END: return KeyEvent.VK_END; + case Keyboard.KEY_DOWN: return KeyEvent.VK_DOWN; + case Keyboard.KEY_NEXT: return KeyEvent.VK_PAGE_DOWN; + case Keyboard.KEY_INSERT: return KeyEvent.VK_INSERT; + case Keyboard.KEY_DELETE: return KeyEvent.VK_DELETE; + case Keyboard.KEY_LWIN: return KeyEvent.VK_META; + } + return Keyboard.KEY_NONE; + } public static int[] getCodes(char character) { switch (character) { diff --git a/src/com/mtbs3d/minecrift/utils/Utils.java b/src/com/mtbs3d/minecrift/utils/Utils.java index 3d81082..d38d72d 100644 --- a/src/com/mtbs3d/minecrift/utils/Utils.java +++ b/src/com/mtbs3d/minecrift/utils/Utils.java @@ -21,6 +21,8 @@ import java.util.Formatter; import java.util.List; +import jopenvr.HmdMatrix34_t; + import org.lwjgl.util.vector.Matrix3f; import org.lwjgl.util.vector.Matrix4f; import org.lwjgl.util.vector.Vector2f; @@ -69,6 +71,68 @@ public static Vector3f convertVector(de.fruitfly.ovr.structs.Vector3f vector) { public static de.fruitfly.ovr.structs.Vector3f convertToOVRVector(Vector3f vector) { return new de.fruitfly.ovr.structs.Vector3f(vector.x, vector.y, vector.z); } + + public static Matrix4f convertOVRMatrix(de.fruitfly.ovr.structs.Matrix4f matrix) { + Matrix4f mat = new Matrix4f(); + mat.m00 = matrix.M[0][0]; + mat.m01 = matrix.M[0][1]; + mat.m02 = matrix.M[0][2]; + mat.m03 = matrix.M[0][3]; + mat.m10 = matrix.M[1][0]; + mat.m11 = matrix.M[1][1]; + mat.m12 = matrix.M[1][2]; + mat.m13 = matrix.M[1][3]; + mat.m20 = matrix.M[2][0]; + mat.m21 = matrix.M[2][1]; + mat.m22 = matrix.M[2][2]; + mat.m23 = matrix.M[2][3]; + mat.m30 = matrix.M[3][0]; + mat.m31 = matrix.M[3][1]; + mat.m32 = matrix.M[3][2]; + mat.m33 = matrix.M[3][3]; + mat.transpose(mat); + return mat; + } + + public static de.fruitfly.ovr.structs.Matrix4f convertToOVRMatrix(Matrix4f matrixIn) { + Matrix4f matrix = new Matrix4f(); + matrixIn.transpose(matrix); + de.fruitfly.ovr.structs.Matrix4f mat = new de.fruitfly.ovr.structs.Matrix4f(); + mat.M[0][0] = matrix.m00; + mat.M[0][1] = matrix.m01; + mat.M[0][2] = matrix.m02; + mat.M[0][3] = matrix.m03; + mat.M[1][0] = matrix.m10; + mat.M[1][1] = matrix.m11; + mat.M[1][2] = matrix.m12; + mat.M[1][3] = matrix.m13; + mat.M[2][0] = matrix.m20; + mat.M[2][1] = matrix.m21; + mat.M[2][2] = matrix.m22; + mat.M[2][3] = matrix.m23; + mat.M[3][0] = matrix.m30; + mat.M[3][1] = matrix.m31; + mat.M[3][2] = matrix.m32; + mat.M[3][3] = matrix.m33; + return mat; + } + + public static HmdMatrix34_t convertToMatrix34(Matrix4f matrix) { + HmdMatrix34_t mat = new HmdMatrix34_t(); + mat.m[0 + 0 * 4] = matrix.m00; + mat.m[1 + 0 * 4] = matrix.m10; + mat.m[2 + 0 * 4] = matrix.m20; + mat.m[3 + 0 * 4] = matrix.m30; + mat.m[0 + 1 * 4] = matrix.m01; + mat.m[1 + 1 * 4] = matrix.m11; + mat.m[2 + 1 * 4] = matrix.m21; + mat.m[3 + 1 * 4] = matrix.m31; + mat.m[0 + 2 * 4] = matrix.m02; + mat.m[1 + 2 * 4] = matrix.m12; + mat.m[2 + 2 * 4] = matrix.m22; + mat.m[3 + 2 * 4] = matrix.m32; + return mat; + } public static Vector3f directionFromMatrix(Matrix4f matrix, float x, float y, float z) {