diff --git a/minecriftversion.py b/minecriftversion.py index 34977d8d..5ad541ac 100644 --- a/minecriftversion.py +++ b/minecriftversion.py @@ -4,7 +4,7 @@ of_json_name = "1.7.10_HD_U_D1" of_file_md5 = "57c724fe8335c82aef8d54c101043e60" minecrift_version_num = "1.7.10" -minecrift_build = "jrbudda-35r3" +minecrift_build = "jrbudda-36pre" of_file_extension = ".jar" mcp_version = "mcp908" mcp_uses_generics = False diff --git a/patches/net/minecraft/client/Minecraft.java.patch b/patches/net/minecraft/client/Minecraft.java.patch index 709119b1..e6b7358b 100644 --- a/patches/net/minecraft/client/Minecraft.java.patch +++ b/patches/net/minecraft/client/Minecraft.java.patch @@ -154,7 +154,7 @@ import net.minecraft.world.EnumDifficulty; import net.minecraft.world.WorldProviderEnd; import net.minecraft.world.WorldProviderHell; -@@ -150,2988 +225,4883 @@ +@@ -150,2988 +225,4887 @@ import net.minecraft.world.storage.ISaveFormat; import net.minecraft.world.storage.ISaveHandler; import net.minecraft.world.storage.WorldInfo; @@ -1245,7 +1245,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.7.10 jrbudda-35r3"; ++ public final String minecriftVerString = "Vivecraft 1.7.10 jrbudda-36pre"; + private boolean trigger; + /* end version */ + /** END MINECRIFT */ @@ -3224,6 +3224,10 @@ + + this.mcProfiler.endSection(); + ++ //VIVECRAFT ++ vrPlayer.preTick(); ++ // ++ + if (this.rightClickDelayTimer > 0) + { + --this.rightClickDelayTimer; @@ -5308,7 +5312,7 @@ + // Lanczos downsample FBOs + fsaaFirstPassResultFBO = new Framebuffer("FSAA Pass1 FBO",EyeTextureSize.w, displayFBHeight,false, false,false, 0, -1); + //TODO: ugh, support multiple color attachments in Framebuffer.... -+ fsaaLastPassResultFBO = new Framebuffer("FSAA Pass2 FBO",displayFBWidth, displayFBHeight,false, false,false, 0, -1); ++ fsaaLastPassResultFBO = new Framebuffer("FSAA Pass2 FBO",EyeTextureSize.w, EyeTextureSize.h,false, false,false, 0, -1); + + print(this.fsaaFirstPassResultFBO.toString()); + diff --git a/patches/net/minecraft/client/entity/EntityPlayerSP.java.patch b/patches/net/minecraft/client/entity/EntityPlayerSP.java.patch index f89235b8..0711923e 100644 --- a/patches/net/minecraft/client/entity/EntityPlayerSP.java.patch +++ b/patches/net/minecraft/client/entity/EntityPlayerSP.java.patch @@ -429,7 +429,7 @@ this.worldObj.playSound(this.posX, this.posY - (double)this.yOffset, this.posZ, name, volume, pitch, false); } -@@ -662,4 +853,283 @@ +@@ -662,4 +853,290 @@ } protected void sendHorseJump() {} @@ -616,7 +616,7 @@ + { + super.setPositionAndRotation(x, y, z, yaw, pitch); + -+ OpenVRPlayer.get().snapRoomOriginToPlayerEntity(this, true, false); ++ OpenVRPlayer.get().snapRoomOriginToPlayerEntity(this, true, false, 1); + + if(initFromServer == false){ + initFromServer = true; @@ -643,7 +643,7 @@ + + if(!initFromServer) return; + else { //still init. -+ mc.vrPlayer.snapRoomOriginToPlayerEntity(this, true, false); ++ mc.vrPlayer.snapRoomOriginToPlayerEntity(this, true, false, 1); + +// OpenVRPlayer.get().setRoomOrigin( +// posX + ox, @@ -655,28 +655,35 @@ + // VIVE START - update room origin when player entity is moved + public void setPosition(double x, double y, double z) + { //this is also called when riding to move this around. ++ ++ super.setPosition(x, y, z); ++ + if(this.isRiding()){ ++ + Vec3 roomOrigin = OpenVRPlayer.get().getRoomOriginPos_World(); -+ double ox = roomOrigin.xCoord - posX; -+ double oz = roomOrigin.zCoord - posZ; -+ super.setPosition(x, y, z); ++ Vec3 me = OpenVRPlayer.get().getHMDPos_World(); ++ double ox = roomOrigin.xCoord - me.xCoord; ++ double oy = roomOrigin.yCoord - me.yCoord; ++ double oz = roomOrigin.zCoord - me.zCoord; ++ + OpenVRPlayer.get().setRoomOrigin( -+ posX + ox, -+ this.ridingEntity.boundingBox.minY, -+ posZ + oz, false, false); -+ -+ } else -+ super.setPosition(x, y, z); ++ this.ridingEntity.posX + ox, ++ this.ridingEntity.posY + (this.ridingEntity instanceof EntityHorse ? this.ridingEntity.getMountedYOffset() : 0 ), ++ this.ridingEntity.posZ + oz, false, false); ++ ++ } ++ + + } + + @Override + public void moveEntity(double x, double y, double z) + { ++ if(this.isRiding())return; + boolean client = this instanceof EntityPlayerSP; + boolean freemove = OpenVRPlayer.get().getFreeMoveMode(); + boolean doY = freemove || (Minecraft.getMinecraft().vrSettings.simulateFalling && !this.isOnLadder()) && !this.isSneaking(); -+ ++ if(mc.climbTracker.isActive(this)) doY = true; + Vec3 roomOrigin = OpenVRPlayer.get().getRoomOriginPos_World(); + // Vec3 camloc = Minecraft.getMinecraft().roomScale.getHMDPos_World(); + diff --git a/patches/net/minecraft/client/gui/GuiScreen.java.patch b/patches/net/minecraft/client/gui/GuiScreen.java.patch index fa5ded40..78b590c9 100644 --- a/patches/net/minecraft/client/gui/GuiScreen.java.patch +++ b/patches/net/minecraft/client/gui/GuiScreen.java.patch @@ -17,7 +17,7 @@ import net.minecraft.util.EnumChatFormatting; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; -@@ -44,13 +49,22 @@ +@@ -44,13 +49,17 @@ public boolean allowUserInput; /** The FontRenderer used by GuiScreen */ @@ -29,19 +29,14 @@ private int eventButton; private long lastMouseEvent; -+ /** MINECRIFT */ -+ public static int mouseOffsetX = 0; -+ public static int mouseOffsetY = 0; -+ /** END MINECRIFT */ -+ ++ //VIVECRAFT + public boolean pressShiftFake; -+ -+ public int mouseX, mouseY; ++ /// + /** * Incremented when the game is in touchscreen mode and the screen is tapped, decremented if the screen isn't * tapped. Does not appear to be used. -@@ -84,6 +98,10 @@ +@@ -84,6 +93,10 @@ { if (keyCode == 1) { @@ -52,7 +47,7 @@ this.mc.displayGuiScreen((GuiScreen)null); this.mc.setIngameFocus(); } -@@ -142,21 +160,37 @@ +@@ -142,21 +155,37 @@ var4.set(var5, EnumChatFormatting.GRAY + (String)var4.get(var5)); } } @@ -94,7 +89,7 @@ if (!textLines.isEmpty()) { GL11.glDisable(GL12.GL_RESCALE_NORMAL); -@@ -169,7 +203,9 @@ +@@ -169,7 +198,9 @@ while (var5.hasNext()) { String var6 = (String)var5.next(); @@ -105,7 +100,7 @@ if (var7 > var4) { -@@ -214,7 +250,9 @@ +@@ -214,7 +245,9 @@ for (int var12 = 0; var12 < textLines.size(); ++var12) { String var13 = (String)textLines.get(var12); @@ -116,7 +111,7 @@ if (var12 == 0) { -@@ -246,10 +284,26 @@ +@@ -246,10 +279,26 @@ if (var5.mousePressed(this.mc, mouseX, mouseY)) { @@ -147,7 +142,7 @@ } } } -@@ -285,8 +339,22 @@ +@@ -285,8 +334,22 @@ this.fontRendererObj = mc.fontRendererObj; this.width = width; this.height = height; @@ -172,7 +167,7 @@ } /** -@@ -302,7 +370,14 @@ +@@ -302,7 +365,14 @@ if (Mouse.isCreated()) { while (Mouse.next()) @@ -188,7 +183,7 @@ this.handleMouseInput(); } } -@@ -321,9 +396,23 @@ +@@ -321,9 +391,19 @@ */ public void handleMouseInput() { @@ -203,18 +198,14 @@ + } + } + -+ // Reset mouse offset -+ mouseOffsetX = -1; -+ mouseOffsetY = -1; -+ -+ int var1 =mouseX = getMouseX(); -+ int var2 = mouseY= getMouseY(); ++ int var1 = getMouseXPos(); ++ int var2 = getMouseYPos(); int var3 = Mouse.getEventButton(); + /** END MINECRIFT */ if (Mouse.getEventButtonState()) { -@@ -388,8 +477,17 @@ +@@ -388,8 +468,17 @@ { if (this.mc.theWorld != null) { @@ -232,7 +223,7 @@ else { this.drawBackground(tint); -@@ -441,4 +539,82 @@ +@@ -441,4 +530,64 @@ { return Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54); } @@ -284,34 +275,16 @@ + this.mouseClickMove(guiX, guiY, this.eventButton, var3); + } + -+ public int getMouseX() ++ public int getMouseXPos() + { + int mX = Mouse.getX() * this.mc.currentScreen.width / this.mc.displayWidth; -+ mX += (this.mouseOffsetX == -1 ? 0 : this.mouseOffsetX); -+ return mX; -+ } -+ -+ public int getMouseY() -+ { -+ int mY = this.mc.currentScreen.height - Mouse.getY() * this.mc.currentScreen.height / this.mc.displayHeight - 1; -+ mY += (this.mouseOffsetY == -1 ? 0 : this.mouseOffsetY); -+ return mY; -+ } -+ -+ public int getActualMouseX() -+ { -+ int mX = Mouse.getX() * this.mc.currentScreen.width / this.mc.displayHeight; + return mX; + } + -+ public int getActualMouseY() ++ public int getMouseYPos() + { + int mY = this.mc.currentScreen.height - Mouse.getY() * this.mc.currentScreen.height / this.mc.displayHeight - 1; + return mY; + } + -+ public List getButtonList() -+ { -+ return this.buttonList; -+ } } diff --git a/patches/net/minecraft/client/gui/GuiTextField.java.patch b/patches/net/minecraft/client/gui/GuiTextField.java.patch index 0158fdc4..c01e6f27 100644 --- a/patches/net/minecraft/client/gui/GuiTextField.java.patch +++ b/patches/net/minecraft/client/gui/GuiTextField.java.patch @@ -49,12 +49,19 @@ } /** -@@ -673,6 +683,11 @@ +@@ -673,6 +683,18 @@ } this.isFocused = p_146195_1_; + + // VIVE START - show keyboard ++ ++ //Pixelmon hax ++ for (StackTraceElement ste : Thread.currentThread().getStackTrace()) { ++ if(ste.getClassName().contains("GuiChattableCamera")) return; ++ } ++ // ++ + if(p_146195_1_) MCOpenVR.setKeyboardOverlayShowing(p_146195_1_, this); + // VIVE END - show keyboard + diff --git a/patches/net/minecraft/client/renderer/EntityRenderer.java.patch b/patches/net/minecraft/client/renderer/EntityRenderer.java.patch index d5002be1..e628f2cb 100644 --- a/patches/net/minecraft/client/renderer/EntityRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/EntityRenderer.java.patch @@ -98,7 +98,7 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.MouseFilter; import net.minecraft.util.MovingObjectPosition; -@@ -61,2593 +104,5048 @@ +@@ -61,2593 +104,5051 @@ import net.minecraft.world.World; import net.minecraft.world.WorldProvider; import net.minecraft.world.biome.BiomeGenBase; @@ -1329,6 +1329,7 @@ + */ + private void orientCamera(float par1) + { ++ this.mc.gameSettings.thirdPersonView = 0; + EntityLivingBase var2 = this.mc.renderViewEntity; +// float var3 = var2.yOffset - 1.62F; + double var4 = var2.posX; @@ -2168,6 +2169,8 @@ +// { + this.prevFrameTime = Minecraft.getSystemTime(); +// } ++ ++ mc.vrPlayer.checkandUpdateRotateScale(true, par1); + + + /** END MINECRIFT */ @@ -4762,8 +4765,8 @@ + if (this.mc.currentScreen != null /*&& !this.blankGUIUntilWorldValid*/) + { + -+ final int mouseX1 = mouseX = this.mc.currentScreen.getMouseX(); -+ final int mouseY1 = mouseY = this.mc.currentScreen.getMouseY(); ++ final int mouseX1 = mouseX = this.mc.currentScreen.getMouseXPos(); ++ final int mouseY1 = mouseY = this.mc.currentScreen.getMouseYPos(); + + try + { @@ -4789,9 +4792,9 @@ + // Draw GUI crosshair + if (mc.stereoProvider.isStereo()){ + if(MCOpenVR.controllerMouseValid){ -+ mc.ingameGUI.drawMouseMenuQuad(this.mc.currentScreen.getMouseX(),this.mc.currentScreen.getMouseY()); ++ mc.ingameGUI.drawMouseMenuQuad(this.mc.currentScreen.getMouseXPos(),this.mc.currentScreen.getMouseYPos()); + } -+ } else mc.ingameGUI.drawMouseMenuQuad(this.mc.currentScreen.getMouseX(),this.mc.currentScreen.getMouseY()); ++ } else mc.ingameGUI.drawMouseMenuQuad(this.mc.currentScreen.getMouseXPos(),this.mc.currentScreen.getMouseYPos()); + } + } + catch (Throwable throwable) diff --git a/patches/net/minecraft/client/renderer/entity/RenderManager.java.patch b/patches/net/minecraft/client/renderer/entity/RenderManager.java.patch index 8cce1ce2..273c5611 100644 --- a/patches/net/minecraft/client/renderer/entity/RenderManager.java.patch +++ b/patches/net/minecraft/client/renderer/entity/RenderManager.java.patch @@ -37,3 +37,14 @@ } if (p_147938_6_.thirdPersonView == 2) +@@ -254,6 +262,10 @@ + + public boolean renderEntityStatic(Entity p_147936_1_, float p_147936_2_, boolean p_147936_3_) + { ++ ++ //pixelmon no 1st person model ++ if(p_147936_1_ == Minecraft.getMinecraft().thePlayer) return true; ++ + if (p_147936_1_.ticksExisted == 0) + { + p_147936_1_.lastTickPosX = p_147936_1_.posX; diff --git a/patches/net/minecraft/util/MovementInputFromOptions.java.patch b/patches/net/minecraft/util/MovementInputFromOptions.java.patch index d3290807..0dd0f27e 100644 --- a/patches/net/minecraft/util/MovementInputFromOptions.java.patch +++ b/patches/net/minecraft/util/MovementInputFromOptions.java.patch @@ -29,12 +29,12 @@ - this.jump = this.gameSettings.keyBindJump.getIsKeyPressed(); - this.sneak = this.gameSettings.keyBindSneak.getIsKeyPressed(); -+ -+ boolean ok = Minecraft.getMinecraft().currentScreen==null; ++ Minecraft mc = Minecraft.getMinecraft(); ++ boolean ok = Minecraft.getMinecraft().currentScreen==null && (mc.vrPlayer.getFreeMoveMode() || mc.vrSettings.simulateFalling); + + //VIVECRAFT DO ok. + this.jump = this.gameSettings.keyBindJump.getIsKeyPressed() && ok; -+ this.sneak = this.gameSettings.keyBindSneak.getIsKeyPressed() && ok; ++ this.sneak = this.gameSettings.keyBindSneak.getIsKeyPressed() && Minecraft.getMinecraft().currentScreen==null; if (this.sneak) { diff --git a/src/com/mtbs3d/minecrift/provider/MCOpenVR.java b/src/com/mtbs3d/minecrift/provider/MCOpenVR.java index 2462477a..8ccdf018 100644 --- a/src/com/mtbs3d/minecrift/provider/MCOpenVR.java +++ b/src/com/mtbs3d/minecrift/provider/MCOpenVR.java @@ -220,13 +220,13 @@ public String getID() { public String getVersion() { return "Version TODO"; } - static KeyBinding hotbarNext = new KeyBinding("Hotbar Next", 201, "key.categories.gameplay"); - static KeyBinding hotbarPrev = new KeyBinding("Hotbar Prev", 209, "key.categories.gameplay"); - static KeyBinding rotateLeft = new KeyBinding("Rotate Left", 203, "key.categories.movement"); - static KeyBinding rotateRight = new KeyBinding("Rotate Right", 205, "key.categories.movement"); - static KeyBinding walkabout = new KeyBinding("Walkabout", 207, "key.categories.movement"); - static KeyBinding rotateFree = new KeyBinding("Rotate Free", 199, "key.categories.movement"); - static KeyBinding quickTorch = new KeyBinding("Quick Torch", 210, "key.categories.gameplay"); + static KeyBinding hotbarNext = new KeyBinding("Hotbar Next", 201, "Vivecraft"); + static KeyBinding hotbarPrev = new KeyBinding("Hotbar Prev", 209, "Vivecraft"); + static KeyBinding rotateLeft = new KeyBinding("Rotate Left", 203, "Vivecraft"); + static KeyBinding rotateRight = new KeyBinding("Rotate Right", 205, "Vivecraft"); + static KeyBinding walkabout = new KeyBinding("Walkabout", 207, "Vivecraft"); + static KeyBinding rotateFree = new KeyBinding("Rotate Free", 199, "Vivecraft"); + static KeyBinding quickTorch = new KeyBinding("Quick Torch", 210, "Vivecraft"); public MCOpenVR() { @@ -606,38 +606,38 @@ public boolean initOpenVRControlPanel() public static void poll(long frameIndex) { Minecraft.getMinecraft().mcProfiler.startSection("input"); - - if(!mc.vrSettings.seated){ - pollInputEvents(); - - updateControllerButtonState(); - updateTouchpadSampleBuffer(); - updateSmoothedVelocity(); - - if(mc.theWorld != null){ - boolean sleeping = (mc.thePlayer != null && mc.thePlayer.isPlayerSleeping()); - if(MCOpenVR.isVive){ - processControllerButtons(sleeping, mc.currentScreen != null); - processTouchpadSampleBuffer(); - }else { - processControllerButtonsOculus(sleeping, mc.currentScreen != null); - processTouchpadSampleBufferOculus(); + boolean sleeping = (mc.theWorld !=null && mc.thePlayer != null && mc.thePlayer.isPlayerSleeping()); + if(!mc.vrSettings.seated){ + pollInputEvents(); + + updateControllerButtonState(); + updateTouchpadSampleBuffer(); + updateSmoothedVelocity(); + + if(mc.theWorld != null){ + if(MCOpenVR.isVive){ + processControllerButtons(sleeping, mc.currentScreen != null); + processTouchpadSampleBuffer(); + }else { + processControllerButtonsOculus(sleeping, mc.currentScreen != null); + processTouchpadSampleBufferOculus(); + } } - processVRFunctions(sleeping, mc.currentScreen != null); - } - // GUI controls - Minecraft.getMinecraft().mcProfiler.endStartSection("gui"); - if( mc.currentScreen != null ) - { - processGui(); - } + // GUI controls + Minecraft.getMinecraft().mcProfiler.endStartSection("gui"); + if( mc.currentScreen != null ) + { + processGui(); + } - if(mc.currentScreen == null && mc.vrSettings.vrTouchHotbar && mc.vrSettings.vrHudLockMode != mc.vrSettings.HUD_LOCK_HEAD && hudPopup){ - processHotbar(); + if(mc.currentScreen == null && mc.vrSettings.vrTouchHotbar && mc.vrSettings.vrHudLockMode != mc.vrSettings.HUD_LOCK_HEAD && hudPopup){ + processHotbar(); + } } - } - + + processVRFunctions(sleeping, mc.currentScreen != null); + Minecraft.getMinecraft().mcProfiler.endStartSection("updatePose"); updatePose(); Minecraft.getMinecraft().mcProfiler.endSection(); @@ -844,9 +844,6 @@ else if (controllerMouseX == -1.0f) mc.controllerPosZ = controllerPos.z; } - mc.currentScreen.mouseOffsetX = -1; - mc.currentScreen.mouseOffsetY = -1; - boolean lastpressedShift,pressedshift,lastpressedleftclick, lastpressedrightclick,lastpressedmiddleclick,pressedleftclick,pressedrightclick,pressedmiddleclick; @@ -2044,13 +2041,6 @@ private static void processVRFunctions(boolean sleeping, boolean gui) { moveModeSwitchcount = 0; } - //no jump key if cant.Not a good place for this check. - if(mc.gameSettings.keyBindJump.isPressed()) { - if(!mc.vrPlayer.getFreeMoveMode() && !mc.vrSettings.simulateFalling) { - mc.gameSettings.keyBindJump.unpressKey(); - } - } - if(rotateLeft.isPressed()){ mc.vrSettings.vrWorldRotation+=mc.vrSettings.vrWorldRotationIncrement; mc.vrSettings.vrWorldRotation = mc.vrSettings.vrWorldRotation % 360; @@ -2082,7 +2072,7 @@ private static void processVRFunctions(boolean sleeping, boolean gui) { else { mc.vrSettings.vrWorldRotation = walkaboutYawStart - yaw; mc.vrSettings.vrWorldRotation %= 360; // Prevent stupidly large values (can they even happen here?) - mc.vrPlayer.checkandUpdateRotateScale(true); + // mc.vrPlayer.checkandUpdateRotateScale(true); } } else { isWalkingAbout = false; @@ -2109,7 +2099,7 @@ private static void processVRFunctions(boolean sleeping, boolean gui) { } else { mc.vrSettings.vrWorldRotation = walkaboutYawStart + yaw; - mc.vrPlayer.checkandUpdateRotateScale(true); + // mc.vrPlayer.checkandUpdateRotateScale(true); } } else { isFreeRotate = false; @@ -2828,7 +2818,7 @@ private static void updateAim() { mc.vrSettings.vrWorldRotation += rotSpeed * rotMul * mc.getFrameDelta(); mc.vrSettings.vrWorldRotation %= 360; // Prevent stupidly large values hmdForwardYaw = (float)Math.toDegrees(Math.atan2(headDirection.x, headDirection.z)); - mc.vrPlayer.checkandUpdateRotateScale(true); + // mc.vrPlayer.checkandUpdateRotateScale(true); Mouse.setCursorPosition(leftedge,Mouse.getY()); h=-rotStart; } @@ -2836,7 +2826,7 @@ private static void updateAim() { mc.vrSettings.vrWorldRotation -= rotSpeed * rotMul * mc.getFrameDelta(); mc.vrSettings.vrWorldRotation %= 360; // Prevent stupidly large values hmdForwardYaw = (float)Math.toDegrees(Math.atan2(headDirection.x, headDirection.z)); - mc.vrPlayer.checkandUpdateRotateScale(true); + // mc.vrPlayer.checkandUpdateRotateScale(true); Mouse.setCursorPosition(rightedge,Mouse.getY()); h=rotStart; } diff --git a/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java b/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java index 9eab8ae8..cb627bcf 100644 --- a/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java +++ b/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java @@ -22,6 +22,7 @@ import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.passive.EntityAnimal; @@ -105,11 +106,7 @@ public void setRoomOrigin(double x, double y, double z, boolean reset, boolean o //interPolatedRoomOrigin = Vec3.createVectorHelper(x, y, z); lastroomOrigin = Vec3.createVectorHelper(x, y, z); Minecraft.getMinecraft().entityRenderer.interPolatedRoomOrigin = Vec3.createVectorHelper(x, y, z); - } else { - this.lastroomOrigin.xCoord = roomOrigin.xCoord ; - this.lastroomOrigin.yCoord = roomOrigin.yCoord ; - this.lastroomOrigin.zCoord = roomOrigin.zCoord ; } } @@ -120,34 +117,67 @@ public void setRoomOrigin(double x, double y, double z, boolean reset, boolean o Minecraft.getMinecraft().entityRenderer.irpUpdatedThisFrame = onframe; } + + public Vec3 getPosition(Entity entity, float p_70666_1_) + { + if (p_70666_1_ == 1.0F) + { + return Vec3.createVectorHelper(entity.posX, entity.posY, entity.posZ); + } + else + { + double var2 = entity.prevPosX + (entity.posX - entity.prevPosX) * (double)p_70666_1_; + double var4 = entity.prevPosY + (entity.posY - entity.prevPosY) * (double)p_70666_1_; + double var6 = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)p_70666_1_; + return Vec3.createVectorHelper(var2, var4, var6); + } + } + //set room - public void snapRoomOriginToPlayerEntity(EntityPlayerSP player, boolean reset, boolean onFrame) + public void snapRoomOriginToPlayerEntity(EntityPlayerSP player, boolean reset, boolean onFrame, float nano) { - if (Thread.currentThread().getName().equals("Server thread")) - return; + if (Thread.currentThread().getName().equals("Server thread")) + return; - if(player.posX == 0 && player.posY == 0 &&player.posZ == 0) return; - - Minecraft mc = Minecraft.getMinecraft(); - - Vec3 campos = mc.roomScale.getHMDPos_Room(); - - campos.rotateAroundY(worldRotationRadians); - - double x,y,z; + if(player.posX == 0 && player.posY == 0 &&player.posZ == 0) return; - if(onFrame){ - x = mc.entityRenderer.interpolatedPlayerPos.xCoord - campos.xCoord; - y = mc.entityRenderer.interpolatedPlayerPos.yCoord - player.yOffset; - z = mc.entityRenderer.interpolatedPlayerPos.zCoord - campos.zCoord; - } else { - x = player.posX - campos.xCoord; - y = player.boundingBox.minY; - z = player.posZ - campos.zCoord; - } - - setRoomOrigin(x, y, z, reset, onFrame); - this.roomScaleMovementDelay = 3; + Minecraft mc = Minecraft.getMinecraft(); + + Vec3 campos = mc.roomScale.getHMDPos_Room(); + + campos.rotateAroundY(worldRotationRadians); + + double x,y,z; + + if(onFrame){ + x = mc.entityRenderer.interpolatedPlayerPos.xCoord - campos.xCoord; + + if(player.isRiding()){ + if (player.ridingEntity instanceof EntityHorse) + y = getPosition(player.ridingEntity, nano).yCoord + player.ridingEntity.getMountedYOffset(); + else + y = getPosition(player.ridingEntity, nano).yCoord; + } else + y = mc.entityRenderer.interpolatedPlayerPos.yCoord- player.yOffset; + + z = mc.entityRenderer.interpolatedPlayerPos.zCoord - campos.zCoord; + } else { + x = player.posX - campos.xCoord; + + if(player.isRiding()){ + if (player.ridingEntity instanceof EntityHorse) + y = player.ridingEntity.posY + player.ridingEntity.getMountedYOffset(); + else + y = player.ridingEntity.posY; + } + else + y = player.posY - player.yOffset + 5; + + z = player.posZ - campos.zCoord; + } + + setRoomOrigin(x, y, z, reset, onFrame); + this.roomScaleMovementDelay = 3; } public double topofhead = 1.62; @@ -155,7 +185,7 @@ public void snapRoomOriginToPlayerEntity(EntityPlayerSP player, boolean reset, b private float lastworldRotation= 0f; private float lastWorldScale; - public void checkandUpdateRotateScale(boolean onFrame){ + public void checkandUpdateRotateScale(boolean onFrame, float nano){ Minecraft mc = Minecraft.getMinecraft(); if(mc.currentScreen!=null) return; if(!onFrame) { @@ -176,12 +206,16 @@ public void checkandUpdateRotateScale(boolean onFrame){ if (worldRotationRadians!= lastworldRotation || worldScale != lastWorldScale) { if(mc.thePlayer!=null) - snapRoomOriginToPlayerEntity(mc.thePlayer, true, onFrame); + snapRoomOriginToPlayerEntity(mc.thePlayer, true, onFrame, nano); } - lastworldRotation = worldRotationRadians; if(!onFrame) lastWorldScale = worldScale; } + public void preTick(){ + lastworldRotation = worldRotationRadians; + lastroomOrigin = Vec3.createVectorHelper(roomOrigin.xCoord, roomOrigin.yCoord, roomOrigin.zCoord); + } + public void onLivingUpdate(EntityPlayerSP player, Minecraft mc, Random rand) { if(!player.initFromServer) return; @@ -195,7 +229,7 @@ public void onLivingUpdate(EntityPlayerSP player, Minecraft mc, Random rand) mc.autoFood.doProcess(mc,player); - this.checkandUpdateRotateScale(false); + this.checkandUpdateRotateScale(false, 1); mc.swimTracker.doProcess(mc,player); @@ -700,7 +734,7 @@ public void updateTeleportArc(Minecraft mc, Entity player) newPos.yCoord = pos.yCoord + velocity.yCoord; newPos.zCoord = pos.zCoord + velocity.zCoord; - MovingObjectPosition collision = mc.theWorld.rayTraceBlocks(pos, newPos, !mc.thePlayer.isInWater(), true, false); + MovingObjectPosition collision = tpRaytrace(player.worldObj, pos, newPos, !mc.thePlayer.isInWater(), true, false); if (collision != null && collision.typeOfHit != MovingObjectPosition.MovingObjectType.MISS) { @@ -732,6 +766,222 @@ public void updateTeleportArc(Minecraft mc, Entity player) } } + public MovingObjectPosition tpRaytrace(World w, Vec3 p_147447_1_, Vec3 p_147447_2_, boolean p_147447_3_, boolean p_147447_4_, boolean p_147447_5_) + { + if (!Double.isNaN(p_147447_1_.xCoord) && !Double.isNaN(p_147447_1_.yCoord) && !Double.isNaN(p_147447_1_.zCoord)) + { + if (!Double.isNaN(p_147447_2_.xCoord) && !Double.isNaN(p_147447_2_.yCoord) && !Double.isNaN(p_147447_2_.zCoord)) + { + int var6 = MathHelper.floor_double(p_147447_2_.xCoord); + int var7 = MathHelper.floor_double(p_147447_2_.yCoord); + int var8 = MathHelper.floor_double(p_147447_2_.zCoord); + int var9 = MathHelper.floor_double(p_147447_1_.xCoord); + int var10 = MathHelper.floor_double(p_147447_1_.yCoord); + int var11 = MathHelper.floor_double(p_147447_1_.zCoord); + Block var12 = w.getBlock(var9, var10, var11); + int var13 = w.getBlockMetadata(var9, var10, var11); + + if (var12 == Blocks.waterlily || (!p_147447_4_ || var12.getCollisionBoundingBoxFromPool(w, var9, var10, var11) != null) && var12.canStopRayTrace(var13, p_147447_3_)) + { + MovingObjectPosition var14 = var12.collisionRayTrace(w, var9, var10, var11, p_147447_1_, p_147447_2_); + + if (var14 != null) + { + return var14; + } + } + + MovingObjectPosition var40 = null; + var13 = 200; + + while (var13-- >= 0) + { + if (Double.isNaN(p_147447_1_.xCoord) || Double.isNaN(p_147447_1_.yCoord) || Double.isNaN(p_147447_1_.zCoord)) + { + return null; + } + + if (var9 == var6 && var10 == var7 && var11 == var8) + { + return p_147447_5_ ? var40 : null; + } + + boolean var41 = true; + boolean var15 = true; + boolean var16 = true; + double var17 = 999.0D; + double var19 = 999.0D; + double var21 = 999.0D; + + if (var6 > var9) + { + var17 = (double)var9 + 1.0D; + } + else if (var6 < var9) + { + var17 = (double)var9 + 0.0D; + } + else + { + var41 = false; + } + + if (var7 > var10) + { + var19 = (double)var10 + 1.0D; + } + else if (var7 < var10) + { + var19 = (double)var10 + 0.0D; + } + else + { + var15 = false; + } + + if (var8 > var11) + { + var21 = (double)var11 + 1.0D; + } + else if (var8 < var11) + { + var21 = (double)var11 + 0.0D; + } + else + { + var16 = false; + } + + double var23 = 999.0D; + double var25 = 999.0D; + double var27 = 999.0D; + double var29 = p_147447_2_.xCoord - p_147447_1_.xCoord; + double var31 = p_147447_2_.yCoord - p_147447_1_.yCoord; + double var33 = p_147447_2_.zCoord - p_147447_1_.zCoord; + + if (var41) + { + var23 = (var17 - p_147447_1_.xCoord) / var29; + } + + if (var15) + { + var25 = (var19 - p_147447_1_.yCoord) / var31; + } + + if (var16) + { + var27 = (var21 - p_147447_1_.zCoord) / var33; + } + + boolean var35 = false; + byte var42; + + if (var23 < var25 && var23 < var27) + { + if (var6 > var9) + { + var42 = 4; + } + else + { + var42 = 5; + } + + p_147447_1_.xCoord = var17; + p_147447_1_.yCoord += var31 * var23; + p_147447_1_.zCoord += var33 * var23; + } + else if (var25 < var27) + { + if (var7 > var10) + { + var42 = 0; + } + else + { + var42 = 1; + } + + p_147447_1_.xCoord += var29 * var25; + p_147447_1_.yCoord = var19; + p_147447_1_.zCoord += var33 * var25; + } + else + { + if (var8 > var11) + { + var42 = 2; + } + else + { + var42 = 3; + } + + p_147447_1_.xCoord += var29 * var27; + p_147447_1_.yCoord += var31 * var27; + p_147447_1_.zCoord = var21; + } + + Vec3 var36 = Vec3.createVectorHelper(p_147447_1_.xCoord, p_147447_1_.yCoord, p_147447_1_.zCoord); + var9 = (int)(var36.xCoord = (double)MathHelper.floor_double(p_147447_1_.xCoord)); + + if (var42 == 5) + { + --var9; + ++var36.xCoord; + } + + var10 = (int)(var36.yCoord = (double)MathHelper.floor_double(p_147447_1_.yCoord)); + + if (var42 == 1) + { + --var10; + ++var36.yCoord; + } + + var11 = (int)(var36.zCoord = (double)MathHelper.floor_double(p_147447_1_.zCoord)); + + if (var42 == 3) + { + --var11; + ++var36.zCoord; + } + + Block var37 = w.getBlock(var9, var10, var11); + int var38 = w.getBlockMetadata(var9, var10, var11); + + if (!p_147447_4_ || var37.getCollisionBoundingBoxFromPool(w, var9, var10, var11) != null) + { + if (var37.canStopRayTrace(var38, p_147447_3_)) + { + MovingObjectPosition var39 = var37.collisionRayTrace(w, var9, var10, var11, p_147447_1_, p_147447_2_); + + if (var39 != null) + { + return var39; + } + } + else + { + var40 = new MovingObjectPosition(var9, var10, var11, var42, p_147447_1_, false); + } + } + } + + return p_147447_5_ ? var40 : null; + } + else + { + return null; + } + } + else + { + return null; + } + } + public void updateTeleportDestinations(Minecraft mc, Entity player) { mc.mcProfiler.startSection("updateTeleportDestinations"); @@ -963,6 +1213,8 @@ public void updateSwingAttack() return; //dont hit things while RIPing. } + if(mc.vrSettings.seated)return ; + mc.mcProfiler.startSection("updateSwingAttack"); Vec3 forward = Vec3.createVectorHelper(0,0,-1);