Skip to content

Commit

Permalink
git u r drunk
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbudda committed May 21, 2017
1 parent 82d9202 commit c2b1f7f
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 13 deletions.
17 changes: 6 additions & 11 deletions patches/net/minecraft/client/Minecraft.java.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/Minecraft.java
+++ b/net/minecraft/client/Minecraft.java
@@ -1,40 +1,110 @@
@@ -1,40 +1,109 @@
package net.minecraft.client;

-import com.google.common.collect.Iterables;
Expand Down Expand Up @@ -113,7 +113,6 @@
+import de.fruitfly.ovr.structs.Sizei;
+import de.fruitfly.ovr.structs.Vector3f;
+import io.netty.util.concurrent.GenericFutureListener;
+import net.aib42.mumblelink.MumbleLink;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.audio.MusicTicker;
Expand All @@ -122,7 +121,7 @@
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiChat;
@@ -68,6 +138,8 @@
@@ -68,6 +137,8 @@
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
Expand All @@ -131,15 +130,15 @@
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.TextureManager;
@@ -97,6 +169,7 @@
@@ -97,6 +168,7 @@
import net.minecraft.client.settings.GameSettings;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.shader.Framebuffer;
+import net.minecraft.client.shader.ShaderGroup;
import net.minecraft.client.stream.IStream;
import net.minecraft.client.stream.NullStream;
import net.minecraft.client.stream.TwitchStream;
@@ -127,6 +200,8 @@
@@ -127,6 +199,8 @@
import net.minecraft.profiler.Profiler;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.integrated.IntegratedServer;
Expand All @@ -148,15 +147,15 @@
import net.minecraft.stats.AchievementList;
import net.minecraft.stats.IStatStringFormat;
import net.minecraft.stats.StatFileWriter;
@@ -142,6 +217,7 @@
@@ -142,6 +216,7 @@
import net.minecraft.util.Session;
import net.minecraft.util.Timer;
import net.minecraft.util.Util;
+import net.minecraft.util.Vec3;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.WorldProviderEnd;
import net.minecraft.world.WorldProviderHell;
@@ -150,2988 +226,4966 @@
@@ -150,2988 +225,4962 @@
import net.minecraft.world.storage.ISaveFormat;
import net.minecraft.world.storage.ISaveHandler;
import net.minecraft.world.storage.WorldInfo;
Expand Down Expand Up @@ -1180,7 +1179,6 @@
+ public Method fieldResizedMethod = null;
+ public IStereoProvider stereoProvider;
+ public VRSettings vrSettings;
+ public MumbleLink mumbleLink;
+ public long lastIntegratedServerLaunchCheck = 0;
+ public boolean integratedServerLaunchInProgress = false;
+ public boolean lastEnableVsync = true;
Expand Down Expand Up @@ -6005,9 +6003,6 @@
+ } catch (NullPointerException what) {} // I don't know
+ }
+ //}
+ if( mumbleLink != null ) {
+ mumbleLink.updateMumble((float)hmdPos.xCoord, (float)hmdPos.yCoord, (float)hmdPos.zCoord, (float)hmdDir.xCoord, (float)hmdDir.yCoord, (float)hmdDir.zCoord, (float)up.xCoord, (float)up.yCoord, (float)up.zCoord);
+ }
+ }
+
+
Expand Down
7 changes: 5 additions & 2 deletions src/com/mtbs3d/minecrift/provider/MCOpenVR.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.mtbs3d.minecrift.render.QuaternionHelper;
import com.mtbs3d.minecrift.settings.VRHotkeys;
import com.mtbs3d.minecrift.settings.VRSettings;
import com.mtbs3d.minecrift.utils.InputInjector;
import com.mtbs3d.minecrift.utils.KeyboardSimulator;
import com.mtbs3d.minecrift.utils.MCReflection;
import com.sun.jna.Memory;
Expand Down Expand Up @@ -1872,7 +1873,9 @@ private static void pollInputEvents()
try {
for (char ch : str.toCharArray()) {
int[] codes = KeyboardSimulator.getLWJGLCodes(ch);
mc.currentScreen.keyTypedPublic(ch, codes.length > 0 ? codes[codes.length - 1] : 0);
int code = codes.length > 0 ? codes[codes.length - 1] : 0;
if (InputInjector.isSupported()) InputInjector.typeKey(code, ch);
else mc.currentScreen.keyTypedPublic(ch, code);
break;
}
} catch (Exception e) {
Expand Down Expand Up @@ -2174,7 +2177,7 @@ static void onGuiScreenChanged(GuiScreen previousScreen, GuiScreen newScreen)
guiPos_World = new Vector3f(
(float) (0 + mc.vrPlayer.getRoomOriginPos_World().xCoord),
(float) (1.3f + mc.vrPlayer.getRoomOriginPos_World().yCoord),
(float) ((playArea != null ? -playArea[1] / 2 : 1.5f) - 0.3f + mc.vrPlayer.getRoomOriginPos_World().zCoord));
(float) ((playArea != null ? -playArea[1] / 2 : -1.5f) - 0.3f + mc.vrPlayer.getRoomOriginPos_World().zCoord));


guiRotationPose = new Matrix4f();
Expand Down
93 changes: 93 additions & 0 deletions src/com/mtbs3d/minecrift/utils/InputInjector.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package com.mtbs3d.minecrift.utils;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;

import org.lwjgl.LWJGLUtil;
import org.lwjgl.opengl.Display;

import com.google.common.base.Throwables;

/**
* This is super dirty hacks into LWJGL core code.
* Do not look unless you want your eyeballs to implode.
*/
public class InputInjector {
private static boolean supported = true;
//private static Method putMouseEvent;
private static Method putKeyboardEvent;
private static Object keyboard;
private static Object mouse;
private static Class keyboardClass;
private static Class mouseClass;

private static void lazyLoad() {
if (supported && (keyboard == null || mouse == null)) {
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");
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");
break;
default:
supported = false;
System.out.println("InputInjector is not supported on this platform");
return;
}
} catch (Exception e) {
Throwables.propagate(e);
}
}
}

private static Object getFieldValue(Class clazz, String name, Object obj) throws ReflectiveOperationException {
Field field = clazz.getDeclaredField(name);
field.setAccessible(true);
return field.get(obj);
}

private static void putKeyboardEvent(int keycode, boolean state, int ch) throws ReflectiveOperationException {
lazyLoad();
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);
putKeyboardEvent.setAccessible(true);
}
putKeyboardEvent.invoke(keyboard, keycode, state ? (byte)1 : (byte)0, ch, windows ? System.nanoTime() / 1000000 : System.nanoTime(), false);
}

public static void pressKey(int code, char ch) {
try {
putKeyboardEvent(code, true, ch);
} catch (Exception e) {
Throwables.propagate(e);
}
}

public static void releaseKey(int code, char ch) {
try {
putKeyboardEvent(code, false, ch);
} catch (Exception e) {
Throwables.propagate(e);
}
}

public static void typeKey(int code, char ch) {
pressKey(code, ch);
releaseKey(code, ch);
}

public static boolean isSupported() {
return supported;
}
}

0 comments on commit c2b1f7f

Please sign in to comment.