From b7236c2bcac69550521459d36aa083adc882aca9 Mon Sep 17 00:00:00 2001 From: jrbudda Date: Tue, 2 Aug 2016 20:02:06 -0400 Subject: [PATCH] srsly --- .../client/renderer/EntityRenderer.java.patch | 46 ++++++++++--------- .../mtbs3d/minecrift/provider/MCOpenVR.java | 32 ++++++++----- 2 files changed, 46 insertions(+), 32 deletions(-) diff --git a/patches/net/minecraft/client/renderer/EntityRenderer.java.patch b/patches/net/minecraft/client/renderer/EntityRenderer.java.patch index 60ec8fea..31047f30 100644 --- a/patches/net/minecraft/client/renderer/EntityRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/EntityRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/EntityRenderer.java +++ b/net/minecraft/client/renderer/EntityRenderer.java -@@ -1,27 +1,59 @@ +@@ -1,27 +1,60 @@ package net.minecraft.client.renderer; -import com.google.gson.JsonSyntaxException; @@ -54,6 +54,7 @@ +import net.minecraft.client.gui.GuiWinGame; import net.minecraft.client.gui.MapItemRenderer; import net.minecraft.client.gui.ScaledResolution; ++import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.particle.EffectRenderer; import net.minecraft.client.particle.EntityRainFX; @@ -62,7 +63,7 @@ import net.minecraft.client.renderer.culling.Frustrum; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.DynamicTexture; -@@ -29,10 +61,12 @@ +@@ -29,10 +62,12 @@ import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.resources.IResourceManagerReloadListener; @@ -75,7 +76,7 @@ import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -@@ -40,6 +74,9 @@ +@@ -40,6 +75,9 @@ import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -85,7 +86,7 @@ import net.minecraft.potion.Potion; import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.src.Config; -@@ -61,2593 +98,4849 @@ +@@ -61,2593 +99,4852 @@ import net.minecraft.world.World; import net.minecraft.world.WorldProvider; import net.minecraft.world.biome.BiomeGenBase; @@ -2294,8 +2295,9 @@ + + + this.mc.mcProfiler.endStartSection("getPointedBlock"); -+ this.getMouseOver(par1); -+ ++ //this.getMouseOver(par1); ++ //dont call this cause soemthing might inherit it ++ + if( this.mc.currentScreen == null ) + { + if(mc.currentPass == renderPass.Left) @@ -4550,11 +4552,12 @@ + GL11.glDisable(GL11.GL_ALPHA_TEST); + } + -+ if (this.mc.vrSettings.hudOcclusion == false || this.mc.currentScreen != null){ ++ if (this.mc.vrSettings.hudOcclusion == false){ + // Never use depth test for in game menu - so you can always see it! + GL11.glDisable(GL11.GL_DEPTH_TEST); -+ } -+ ++ } else GL11.glEnable(GL11.GL_DEPTH_TEST); ++ GL11.glDepthMask(true); ++ + //the framebuffer has to be drawn with color blending transparency to support non-alpha cursors. Always has a black background. + GL11.glDisable(GL11.GL_BLEND); + @@ -4567,7 +4570,6 @@ + + if(mc.currentPass == renderPass.Third){ + GL11.glEnable(GL11.GL_DEPTH_TEST); -+ GL11.glDepthMask(true); + } + + //Render framebuffer onto world projection @@ -4704,19 +4706,23 @@ + + if (!drawScreenHandled) + { -+ this.mc.currentScreen.drawScreen(mouseX, mouseY, renderPartialTicks); ++ try { ++ this.mc.currentScreen.drawScreen(mouseX, mouseY, renderPartialTicks); ++ } catch (Exception e) { ++ //wtf LOTR? ++ } + } + + if(mc.currentScreen !=null){ //wtf pixelmon? -+ -+ if(Reflector.EventBus_post.exists()) Reflector.postForgeBusEvent(Reflector.DrawScreenEvent_Post_Constructor, new Object[] {this.mc.currentScreen, Integer.valueOf(mouseX), Integer.valueOf(mouseY), Float.valueOf(renderPartialTicks)}); ++ ++ if(Reflector.EventBus_post.exists()) Reflector.postForgeBusEvent(Reflector.DrawScreenEvent_Post_Constructor, new Object[] {this.mc.currentScreen, Integer.valueOf(mouseX), Integer.valueOf(mouseY), Float.valueOf(renderPartialTicks)}); + -+ // Draw GUI crosshair -+ if (mc.stereoProvider.isStereo()){ -+ if(MCOpenVR.controllerMouseValid){ -+ mc.ingameGUI.drawMouseMenuQuad(mc.currentScreen.getMouseX(),mc.currentScreen.getMouseY()) ; -+ } -+ } else mc.ingameGUI.drawMouseMenuQuad(mc.currentScreen.getMouseX(),mc.currentScreen.getMouseY()) ; ++ // Draw GUI crosshair ++ if (mc.stereoProvider.isStereo()){ ++ if(MCOpenVR.controllerMouseValid){ ++ mc.ingameGUI.drawMouseMenuQuad(this.mc.currentScreen.getMouseX(),this.mc.currentScreen.getMouseY()); ++ } ++ } else mc.ingameGUI.drawMouseMenuQuad(this.mc.currentScreen.getMouseX(),this.mc.currentScreen.getMouseY()); + } + } + catch (Throwable throwable) @@ -5600,8 +5606,6 @@ + } + + if (mc.objectMouseOver == null) { -+ -+ + GL11.glRotatef(45, 0, 0, 1); + } + diff --git a/src/com/mtbs3d/minecrift/provider/MCOpenVR.java b/src/com/mtbs3d/minecrift/provider/MCOpenVR.java index 95c42f05..bbab5866 100644 --- a/src/com/mtbs3d/minecrift/provider/MCOpenVR.java +++ b/src/com/mtbs3d/minecrift/provider/MCOpenVR.java @@ -162,8 +162,8 @@ public class MCOpenVR public static boolean hudPopup = true; // For mouse menu emulation - private static float controllerMouseX = -1.0f; - private static float controllerMouseY = -1.0f; + public static float controllerMouseX = -1.0f; + public static float controllerMouseY = -1.0f; public static boolean controllerMouseValid; public static int controllerMouseTicks; @@ -741,18 +741,21 @@ else if (controllerMouseX == -1.0f) } //end Shift } + if (controllerMouseX >= 0 && controllerMouseX < mc.displayWidth && controllerMouseY >=0 && controllerMouseY < mc.displayHeight) { // clamp to screen - int mouseX = Math.min(Math.max((int) controllerMouseX, 0), mc.displayWidth); - int mouseY = Math.min(Math.max((int) controllerMouseY, 0), mc.displayHeight); + int mouseX =(int) (controllerMouseX = Math.min(Math.max((int) controllerMouseX, 0), mc.displayWidth)); + int mouseY =(int) (controllerMouseY = Math.min(Math.max((int) controllerMouseY, 0), mc.displayHeight)); if (controllerDeviceIndex[RIGHT_CONTROLLER] != -1) { - Mouse.setCursorPosition(mouseX, mouseY); + + Mouse.setCursorPosition((int)controllerMouseX, (int)controllerMouseY); controllerMouseValid = true; //LMB + if (mc.currentScreen != null && controllerStateReference[RIGHT_CONTROLLER].rAxis[k_EAxis_Trigger].x > triggerThreshold && lastControllerState[RIGHT_CONTROLLER].rAxis[k_EAxis_Trigger].x <= triggerThreshold @@ -1453,9 +1456,6 @@ private static void clearTouchpadSampleBuffer(int controller) private static void processTouchpadSampleBuffer() { - if (mc.thePlayer == null) - return; - if (mc.currentScreen != null){ // right touchpad controls mousewheel int c =0; @@ -1487,7 +1487,7 @@ private static void processTouchpadSampleBuffer() inventory_swipe[c] += swipeDistancePerInventorySlot; } } - } else { + } else if (mc.thePlayer != null) { // left touchpad controls inventory int c =1; boolean touchpadPressed = (controllerStateReference[c].ulButtonPressed & k_buttonTouchpad) > 0; @@ -1506,11 +1506,21 @@ private static void processTouchpadSampleBuffer() float swipeDistancePerInventorySlot = 0.4f; if (inventory_swipe[c] > swipeDistancePerInventorySlot) { - hotbarNext.pressKey(); + if (Display.isActive()) { + KeyboardSimulator.robot.mouseWheel(25); + short duration = 250; + vrsystem.TriggerHapticPulse.apply(controllerDeviceIndex[1], 0, duration); + } + else hotbarNext.pressKey(); inventory_swipe[c] -= swipeDistancePerInventorySlot; } else if (inventory_swipe[c] < -swipeDistancePerInventorySlot) { - hotbarPrev.pressKey(); + if (Display.isActive()) { + KeyboardSimulator.robot.mouseWheel(-25); + short duration = 250; + vrsystem.TriggerHapticPulse.apply(controllerDeviceIndex[1], 0, duration); + } + else hotbarPrev.pressKey(); inventory_swipe[c] += swipeDistancePerInventorySlot; } }