From dda5cfabea118e9da733ee0318613097b4ace636 Mon Sep 17 00:00:00 2001 From: jrbudda Date: Wed, 30 Nov 2016 09:45:49 -0500 Subject: [PATCH] v32 --- installer/Installer.java | 4 +- .../client/entity/EntityPlayerSP.java.patch | 31 ++++++------- .../minecraft/client/gui/GuiIngame.java.patch | 43 ++++++++++--------- .../client/renderer/EntityRenderer.java.patch | 12 +++--- .../client/renderer/ItemRenderer.java.patch | 37 ++++++++++------ patches/net/minecraft/util/Vec3.java.patch | 12 ++++-- src/com/mtbs3d/minecrift/api/Vec3History.java | 2 +- .../minecrift/gameplay/ClimbTracker.java | 4 +- .../minecrift/gameplay/EatingTracker.java | 12 +++--- .../mtbs3d/minecrift/gameplay/RunTracker.java | 21 ++++----- .../minecrift/gameplay/SwimTracker.java | 13 +++--- .../mtbs3d/minecrift/provider/MCOpenVR.java | 12 +++--- .../minecrift/provider/OpenVRPlayer.java | 31 +++++-------- 13 files changed, 118 insertions(+), 116 deletions(-) diff --git a/installer/Installer.java b/installer/Installer.java index 855cb306..7626740b 100644 --- a/installer/Installer.java +++ b/installer/Installer.java @@ -36,8 +36,8 @@ public class Installer extends JPanel implements PropertyChangeListener private static final boolean ALLOW_HYDRA_INSTALL = false; // TODO: Change to true once Hydra is fixed up private static final boolean ALLOW_SHADERSMOD_INSTALL = true; - private static final boolean NEEDS_2010_REDIST = true; - private static final boolean NEEDS_2012_REDIST = true; + private static final boolean NEEDS_2010_REDIST = false; + private static final boolean NEEDS_2012_REDIST = false; // Currently needed for Win boxes - C++ redists diff --git a/patches/net/minecraft/client/entity/EntityPlayerSP.java.patch b/patches/net/minecraft/client/entity/EntityPlayerSP.java.patch index 5788d957..f89235b8 100644 --- a/patches/net/minecraft/client/entity/EntityPlayerSP.java.patch +++ b/patches/net/minecraft/client/entity/EntityPlayerSP.java.patch @@ -41,7 +41,7 @@ import net.minecraft.world.World; public class EntityPlayerSP extends AbstractClientPlayer -@@ -61,6 +77,20 @@ +@@ -61,6 +77,19 @@ */ protected int sprintToggleTimer; @@ -56,13 +56,12 @@ + public double additionZ = 0; + public double additionY = 0; + public final float PIOVER180 = (float)Math.PI / 180.0F; -+ public Vec3 directionVec = Vec3.createVectorHelper(0, 0, 0); + /** END MINECRIFT **/ + /** Ticks left before sprinting is disabled. */ public int sprintingTicksLeft; public float renderArmYaw; -@@ -80,13 +110,46 @@ +@@ -80,13 +109,46 @@ public float prevTimeInPortal; private static final String __OBFID = "CL_00000938"; @@ -109,7 +108,7 @@ public void updateEntityActionState() { super.updateEntityActionState(); -@@ -99,6 +162,7 @@ +@@ -99,6 +161,7 @@ this.renderArmYaw = (float)((double)this.renderArmYaw + (double)(this.rotationYaw - this.renderArmYaw) * 0.5D); } @@ -117,7 +116,7 @@ /** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. -@@ -182,7 +246,9 @@ +@@ -182,7 +245,9 @@ } boolean var1 = this.movementInput.jump; @@ -128,7 +127,7 @@ boolean var3 = this.movementInput.moveForward >= var2; this.movementInput.updatePlayerMoveState(); -@@ -195,20 +261,28 @@ +@@ -195,20 +260,28 @@ if (this.movementInput.sneak && this.yOffset2 < 0.2F) { @@ -163,7 +162,7 @@ } else { -@@ -252,7 +326,7 @@ +@@ -252,7 +325,7 @@ this.motionY += 0.15D; } } @@ -172,7 +171,7 @@ if (this.isRidingHorse()) { if (this.horseJumpPowerCounter < 0) -@@ -296,6 +370,10 @@ +@@ -296,6 +369,10 @@ super.onLivingUpdate(); @@ -183,7 +182,7 @@ if (this.onGround && this.capabilities.isFlying) { this.capabilities.isFlying = false; -@@ -341,7 +419,14 @@ +@@ -341,7 +418,14 @@ var1 *= 1.0F - var4 * 0.15F; } @@ -199,7 +198,7 @@ } /** -@@ -524,70 +609,168 @@ +@@ -524,70 +608,168 @@ { return this.worldObj.getBlock(p_71153_1_, p_71153_2_, p_71153_3_).isNormalCube(); } @@ -414,7 +413,7 @@ return false; } -@@ -640,6 +823,15 @@ +@@ -640,6 +822,15 @@ public void playSound(String name, float volume, float pitch) { @@ -430,7 +429,7 @@ this.worldObj.playSound(this.posX, this.posY - (double)this.yOffset, this.posZ, name, volume, pitch, false); } -@@ -662,4 +854,285 @@ +@@ -662,4 +853,283 @@ } protected void sendHorseJump() {} @@ -520,9 +519,7 @@ + strafe *= speed; + forward *= speed; + -+ directionVec.xCoord = strafe; -+ directionVec.yCoord = 0; -+ directionVec.zCoord = forward; ++ Vec3 directionVec = Vec3.createVectorHelper(strafe, 0, forward); + + //VIVE DO PITCH FLYING + @@ -555,8 +552,8 @@ + directionVec.rotateAroundY(-con.getHMDYaw_World() * PIOVER180); + break; + case VRSettings.FREEMOVE_RUNINPLACE: -+ directionVec.rotateAroundY((float) (-mc.runTracker.getYaw() * PIOVER180)); -+ directionVec = OpenVRPlayer.vecMult(directionVec, (float)mc.runTracker.getSpeed()); ++ directionVec=directionVec.rotateYaw((float) (-mc.runTracker.getYaw() * PIOVER180)); ++ directionVec=directionVec.scale(mc.runTracker.getSpeed()); + break; + } + } diff --git a/patches/net/minecraft/client/gui/GuiIngame.java.patch b/patches/net/minecraft/client/gui/GuiIngame.java.patch index 4c3337de..39e292cc 100644 --- a/patches/net/minecraft/client/gui/GuiIngame.java.patch +++ b/patches/net/minecraft/client/gui/GuiIngame.java.patch @@ -365,7 +365,7 @@ int var25 = MathHelper.floor_double((double)(this.mc.thePlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; this.drawString(var8, "f: " + var25 + " (" + Direction.directions[var25] + ") / " + MathHelper.wrapAngleTo180_float(this.mc.thePlayer.rotationYaw), 2, 88, 14737632); -@@ -347,11 +421,28 @@ +@@ -347,11 +421,29 @@ { this.drawString(var8, String.format("shader: %s", new Object[] {this.mc.entityRenderer.getShaderGroup().getShaderGroupName()}), 2, 112, 14737632); } @@ -381,9 +381,10 @@ + this.drawString(var8,"Offhand Look: " + v3Format(mc.roomScale.getControllerOffhandDir_World()) , 2, 188 , 14737632); + this.drawString(var8,"World Scale: " + mc.vrSettings.vrWorldScale + " World Rotation " + mc.vrSettings.vrWorldRotation , 2, 196 , 14737632); + // this.drawString(var8,"Gui " + MCOpenVR.guiPos_World.x + " " + MCOpenVR.guiPos_World.y + " " + MCOpenVR.guiPos_World.z, 2, 204 , 14737632); -+ this.drawString(var8,"R Touchpad x " + String.format("%.2f",MCOpenVR.rtbX) + " y " + String.format("%.2f",MCOpenVR.rtbY), 2, 212 , 14737632); -+ this.drawString(var8,"3rd Person Camera: " + v3Format(mc.entityRenderer.getEyeRenderPos(renderPass.Third)), 2, 220 , 14737632); ++// this.drawString(var8,"R Touchpad x " + String.format("%.2f",MCOpenVR.rtbX) + " y " + String.format("%.2f",MCOpenVR.rtbY), 2, 212 , 14737632); ++ //this.drawString(var8,"3rd Person Camera: " + v3Format(mc.entityRenderer.getEyeRenderPos(renderPass.Third)), 2, 220 , 14737632); + //this.drawString(var8,"Depth: " + mc.getDepthOfPosition(mc.roomScale.getHMDPos_World()), 2, 228 , 14737632); ++ this.drawString(var8,"RunDir: " + mc.runTracker.getYaw() , 2, 212 , 14737632); + + } @@ -395,7 +396,7 @@ if (this.recordPlayingUpFor > 0) { this.mc.mcProfiler.startSection("overlayMessage"); -@@ -366,7 +457,7 @@ +@@ -366,7 +458,7 @@ if (var13 > 8) { GL11.glPushMatrix(); @@ -404,7 +405,7 @@ GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); var14 = 16777215; -@@ -388,14 +479,14 @@ +@@ -388,14 +480,14 @@ if (var37 != null) { @@ -421,7 +422,7 @@ this.mc.mcProfiler.startSection("chat"); this.persistantChatGUI.drawChat(this.updateCounter); this.mc.mcProfiler.endSection(); -@@ -422,7 +513,7 @@ +@@ -422,7 +514,7 @@ var46 = 150; } @@ -430,7 +431,7 @@ byte var47 = 10; drawRect(var19 - 1, var47 - 1, var19 + var46 * var17, var47 + 9 * var16, Integer.MIN_VALUE); -@@ -501,9 +592,10 @@ +@@ -501,9 +593,10 @@ { this.streamIndicator.render((int)(p_152126_1_ - 10.0F), 10); } @@ -444,7 +445,7 @@ Scoreboard var5 = p_96136_1_.getScoreboard(); Collection var6 = var5.getSortedScores(p_96136_1_); -@@ -549,9 +641,10 @@ +@@ -549,9 +642,10 @@ } } } @@ -458,7 +459,7 @@ boolean var3 = this.mc.thePlayer.hurtResistantTime / 3 % 2 == 1; if (this.mc.thePlayer.hurtResistantTime < 10) -@@ -559,52 +652,52 @@ +@@ -559,52 +653,52 @@ var3 = false; } @@ -535,7 +536,7 @@ { this.drawTexturedModalRect(var23, var18, 16, 9, 9, 9); } -@@ -616,7 +709,7 @@ +@@ -616,7 +710,7 @@ int var26; int var27; @@ -544,7 +545,7 @@ { var23 = 16; -@@ -636,16 +729,16 @@ +@@ -636,16 +730,16 @@ var24 = 1; } @@ -565,7 +566,7 @@ { var27 -= 2; } -@@ -661,12 +754,12 @@ +@@ -661,12 +755,12 @@ if (var3) { @@ -580,7 +581,7 @@ { this.drawTexturedModalRect(var26, var27, var23 + 63, 9 * var28, 9, 9); } -@@ -674,7 +767,7 @@ +@@ -674,7 +768,7 @@ if (var19 > 0.0F) { @@ -589,7 +590,7 @@ { this.drawTexturedModalRect(var26, var27, var23 + 153, 9 * var28, 9, 9); } -@@ -687,22 +780,22 @@ +@@ -687,22 +781,22 @@ } else { @@ -616,7 +617,7 @@ { this.mc.mcProfiler.endStartSection("food"); -@@ -718,7 +811,7 @@ +@@ -718,7 +812,7 @@ var38 = 13; } @@ -625,7 +626,7 @@ { var36 = var13 + (this.rand.nextInt(3) - 1); } -@@ -733,32 +826,32 @@ +@@ -733,32 +827,32 @@ if (var6) { @@ -664,7 +665,7 @@ var36 = (int)Math.ceil((double)var35.getHealth()); float var37 = var35.getMaxHealth(); var26 = (int)(var37 + 0.5F) / 2; -@@ -830,7 +923,9 @@ +@@ -830,7 +924,9 @@ /** * Renders dragon's (boss) health on the HUD */ @@ -675,7 +676,7 @@ { if (BossStatus.bossName != null && BossStatus.statusBarTime > 0) { -@@ -856,9 +951,15 @@ +@@ -856,9 +952,15 @@ this.mc.getTextureManager().bindTexture(icons); } } @@ -693,7 +694,7 @@ GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); OpenGlHelper.glBlendFunc(770, 771, 1, 0); -@@ -881,8 +982,15 @@ +@@ -881,8 +983,15 @@ /** * Renders the vignette. Args: vignetteBrightness, width, height */ @@ -710,7 +711,7 @@ p_73829_1_ = 1.0F - p_73829_1_; if (p_73829_1_ < 0.0F) -@@ -913,44 +1021,22 @@ +@@ -913,44 +1022,22 @@ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); OpenGlHelper.glBlendFunc(770, 771, 1, 0); } @@ -765,7 +766,7 @@ { ItemStack var5 = this.mc.thePlayer.inventory.mainInventory[p_73832_1_]; -@@ -1039,4 +1125,23 @@ +@@ -1039,4 +1126,23 @@ { return this.updateCounter; } diff --git a/patches/net/minecraft/client/renderer/EntityRenderer.java.patch b/patches/net/minecraft/client/renderer/EntityRenderer.java.patch index d5b9acd9..ddc1c111 100644 --- a/patches/net/minecraft/client/renderer/EntityRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/EntityRenderer.java.patch @@ -86,7 +86,7 @@ import net.minecraft.potion.Potion; import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.src.Config; -@@ -61,2593 +99,4840 @@ +@@ -61,2593 +99,4842 @@ import net.minecraft.world.World; import net.minecraft.world.WorldProvider; import net.minecraft.world.biome.BiomeGenBase; @@ -4326,7 +4326,7 @@ + if(mc.theWorld == null) mc.vrPlayer.worldRotationRadians = 0; + + Vec3 eye =mc.entityRenderer.getEyeRenderPos(currentPass); -+ if (mc.theWorld==null || mc.currentScreen instanceof GuiWinGame ) { ++ if (mc.theWorld==null) { + eye = mc.roomScale.getEyePos_Room(currentPass); + } + Vector3f guipos = MCOpenVR.guiPos_World; @@ -4448,10 +4448,12 @@ + } + } + } else { -+ -+ guipos = guipos.add(new Vector3f((float)interPolatedRoomOrigin.xCoord, ++ if (mc.theWorld==null || mc.currentScreen instanceof GuiWinGame){ ++ } ++ else { ++ guipos = guipos.add(new Vector3f((float)interPolatedRoomOrigin.xCoord, + (float) interPolatedRoomOrigin.yCoord, (float) interPolatedRoomOrigin.zCoord)); -+ ++ } + } + // otherwise, looking at inventory screen. use pose calculated when screen was opened + //where is this set up... should be here.... diff --git a/patches/net/minecraft/client/renderer/ItemRenderer.java.patch b/patches/net/minecraft/client/renderer/ItemRenderer.java.patch index 0390484f..b2ed4c0c 100644 --- a/patches/net/minecraft/client/renderer/ItemRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/ItemRenderer.java.patch @@ -264,7 +264,7 @@ GL11.glPopMatrix(); } -@@ -240,372 +257,587 @@ +@@ -240,372 +257,600 @@ p_78439_0_.draw(); } @@ -603,6 +603,7 @@ + EnumAction var23 = renderitem8.getItemUseAction(); + if (var23 == EnumAction.eat || var23 == EnumAction.drink) + { ++ if(!Minecraft.getMinecraft().autoFood.isEating()) { + var14 = (float)player.getItemInUseCount() - nano + 1.0F; + var15 = 1.0F - var14 / (float)renderitem8.getMaxItemUseDuration(); + var16 = 1.0F - var15; @@ -616,6 +617,10 @@ + GL11.glRotatef(var17 * 10.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(var17 * 30.0F, 0.0F, 0.0F, 1.0F); + swing = false; ++ } else { //OM NOM NOM NOM ++ long t = player.getItemInUseCount(); ++ GL11.glTranslatef(0,(float) (0.006*Math.sin(t)), 0); ++ } + } + } + @@ -1035,23 +1040,31 @@ + // VIVE start - screen flash when hurt instead of view tilt + EntityClientPlayerMP player = mc.thePlayer; + if (player!=null) { -+ if( player.getHealth() > 0.0f) ++ float var3 = (float)player.hurtTime - par1_; ++ ++ float percent = 1 - player.getHealth() / player.getMaxHealth(); ++ percent = percent * 0.15f; ++ ++ if (var3>0.0f) + { -+ float var3 = (float)player.hurtTime - par1_; -+ if (var3>0.0f) -+ { -+ var3 /= (float) player.maxHurtTime; -+ var3 = MathHelper.sin(var3 * var3 * var3 * var3 * (float) Math.PI) * 0.5f; -+ r = 1; -+ a = var3; -+ } -+ } ++ var3 /= (float) player.maxHurtTime; ++ var3 = percent + MathHelper.sin(var3 * var3 * var3 * var3 * (float) Math.PI) * 0.5f; ++ r = 1; ++ a = var3; ++ } else { ++ r = 1; ++ a = percent; ++ if (mc.playerController.isInCreativeMode()) a = 0; ++ } ++ + + if (player.isPlayerSleeping()){ ++ r=g=b=0; + a = .8f; + } + + if (MCOpenVR.isWalkingAbout){ ++ r=g=b=0; + a = .8f; + } + @@ -1189,7 +1202,7 @@ } /** -@@ -621,14 +853,17 @@ +@@ -621,14 +866,17 @@ GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); GL11.glPushMatrix(); diff --git a/patches/net/minecraft/util/Vec3.java.patch b/patches/net/minecraft/util/Vec3.java.patch index 55868e96..157873c4 100644 --- a/patches/net/minecraft/util/Vec3.java.patch +++ b/patches/net/minecraft/util/Vec3.java.patch @@ -10,7 +10,7 @@ { if (x == -0.0D) { -@@ -240,4 +241,27 @@ +@@ -240,4 +241,31 @@ double var8 = this.zCoord; this.setComponents(var4, var6, var8); } @@ -21,11 +21,15 @@ + } + + public Vec3 add(Vec3 other) { -+ return new Vec3(this.xCoord*+other.xCoord, this.yCoord+other.yCoord, this.zCoord+other.zCoord); ++ return new Vec3(this.xCoord+other.xCoord, this.yCoord+other.yCoord, this.zCoord+other.zCoord); + } + -+ public Vec3 subtract(double i, double d, double j) { -+ return new Vec3(this.xCoord-i, this.yCoord-d, this.zCoord-j); ++ public Vec3 subtractProperly(double x, double y, double z) { ++ return new Vec3(this.xCoord-x, this.yCoord-y, this.zCoord-z); ++ } ++ ++ public Vec3 subtractProperly(Vec3 other) { ++ return new Vec3(this.xCoord-other.xCoord, this.yCoord-other.yCoord, this.zCoord-other.zCoord); + } + + public Vec3 rotateYaw(float angle) { diff --git a/src/com/mtbs3d/minecrift/api/Vec3History.java b/src/com/mtbs3d/minecrift/api/Vec3History.java index 3806cf2c..d7a789ec 100644 --- a/src/com/mtbs3d/minecrift/api/Vec3History.java +++ b/src/com/mtbs3d/minecrift/api/Vec3History.java @@ -128,7 +128,7 @@ public Vec3 averagePosition(double seconds){ out=out.addVector(i.data.xCoord, i.data.yCoord, i.data.zCoord); } if(j==0) return out; - return Vec3.createVectorHelper(out.xCoord/j, out.yCoord/j, out.yCoord/j); + return Vec3.createVectorHelper(out.xCoord/j, out.yCoord/j, out.zCoord/j); } } diff --git a/src/com/mtbs3d/minecrift/gameplay/ClimbTracker.java b/src/com/mtbs3d/minecrift/gameplay/ClimbTracker.java index e0696653..450e3ae1 100644 --- a/src/com/mtbs3d/minecrift/gameplay/ClimbTracker.java +++ b/src/com/mtbs3d/minecrift/gameplay/ClimbTracker.java @@ -42,7 +42,7 @@ public boolean isActive(EntityPlayerSP p){ return false; if(p.isRiding()) return false; - if(p.moveForward > 0) + if(p.moveForward > 0 && Minecraft.getMinecraft().vrSettings.vrFreeMove ) return false; return true; } @@ -68,7 +68,7 @@ public void doProcess(Minecraft minecraft, EntityPlayerSP player){ Block b = minecraft.theWorld.getBlock(bx, by, bz); if(b == Blocks.ladder || b ==Blocks.vine){ - int meta = b.getDamageValue(minecraft.theWorld, bx, by, bz); + int meta = minecraft.theWorld.getBlockMetadata(bx, by, bz); Vec3 cpos = Vec3.createVectorHelper(controllerPos.xCoord - bx, controllerPos.yCoord - by, controllerPos.zCoord - bz); if(meta == 2){ diff --git a/src/com/mtbs3d/minecrift/gameplay/EatingTracker.java b/src/com/mtbs3d/minecrift/gameplay/EatingTracker.java index 0a688c61..7a7d1115 100644 --- a/src/com/mtbs3d/minecrift/gameplay/EatingTracker.java +++ b/src/com/mtbs3d/minecrift/gameplay/EatingTracker.java @@ -66,11 +66,13 @@ public void doProcess(Minecraft minecraft, EntityPlayerSP player){ } if(!eating[c]){ - if( Minecraft.getMinecraft().playerController.onPlayerRightClick(player, player.worldObj,is,0,0,0,0, new Vec3(0,0,0))){ - minecraft.entityRenderer.itemRenderer.resetEquippedProgress(); - eating[c]=true; - eatStart=Minecraft.getSystemTime(); - } + Minecraft.getMinecraft().playerController.sendUseItem(player, player.worldObj, is);//server + eating[c]=true; + eatStart=Minecraft.getSystemTime(); + +// if( Minecraft.getMinecraft().playerController.onPlayerRightClick(player, player.worldObj,is,0,0,0,0, new Vec3(0,0,0))){ +// //minecraft.entityRenderer.itemRenderer.resetEquippedProgress(); +// } } int crunchiness; if(is.getItemUseAction() == EnumAction.drink){ diff --git a/src/com/mtbs3d/minecrift/gameplay/RunTracker.java b/src/com/mtbs3d/minecrift/gameplay/RunTracker.java index 625d4653..92840f09 100644 --- a/src/com/mtbs3d/minecrift/gameplay/RunTracker.java +++ b/src/com/mtbs3d/minecrift/gameplay/RunTracker.java @@ -28,7 +28,7 @@ public boolean isActive(EntityPlayerSP p){ return true; } - public double direction = 0; + private double direction = 0; private double speed = 0; private Vec3 movedir; @@ -50,8 +50,8 @@ public void doProcess(Minecraft minecraft, EntityPlayerSP player){ //Vec3d middle= controllerL.subtract(controllerR).scale(0.5).add(controllerR); - double c0move = MCOpenVR.controllerHistory[0].averageSpeed(.5); - double c1move = MCOpenVR.controllerHistory[1].averageSpeed(.5); + double c0move = MCOpenVR.controllerHistory[0].averageSpeed(.33); + double c1move = MCOpenVR.controllerHistory[1].averageSpeed(.33); if(speed > 0) { if(c0move < 0.1 && c1move < 0.1){ @@ -99,26 +99,21 @@ public void doProcess(Minecraft minecraft, EntityPlayerSP player){ // movedir = movedir.normalize(); //todo: skip entries? is this computationally expensive? - Vec3 r = MCOpenVR.controllerHistory[0].averagePosition(.5); - Vec3 l = MCOpenVR.controllerHistory[1].averagePosition(.5); + Vec3 r = MCOpenVR.controllerHistory[0].averagePosition(.25); + Vec3 l = MCOpenVR.controllerHistory[1].averagePosition(.25); Vec3 diff; - if(Minecraft.getMinecraft().vrSettings.vrReverseHands){ - diff = l.subtract(r).rotateYaw(minecraft.getMinecraft().vrPlayer.worldRotationRadians); - } else { - diff = r.subtract(l).rotateYaw(minecraft.getMinecraft().vrPlayer.worldRotationRadians); - } + diff = l.subtractProperly(r).rotateYaw(minecraft.getMinecraft().vrPlayer.worldRotationRadians); - double ltor = Math.toDegrees(Math.atan2(-diff.xCoord, diff.zCoord)); direction = ltor + (Minecraft.getMinecraft().vrSettings.vrReverseHands ? -1 : 1) * 90; double spd = (c0move + c1move) / 2; this.speed = spd * 1 * 1.3; - if(this.speed > 1.3) this.speed = 1.3f; - + if(this.speed > .1) this.speed = 1.0f; + if(this.speed > 1.0) this.speed = 1.3f; } } diff --git a/src/com/mtbs3d/minecrift/gameplay/SwimTracker.java b/src/com/mtbs3d/minecrift/gameplay/SwimTracker.java index 3ff6aebc..c4966461 100644 --- a/src/com/mtbs3d/minecrift/gameplay/SwimTracker.java +++ b/src/com/mtbs3d/minecrift/gameplay/SwimTracker.java @@ -55,7 +55,7 @@ public void doProcess(Minecraft minecraft, EntityPlayerSP player){ if(!mat.isLiquid()) { - waterLine=bp.getBlockBoundsMinY(); + waterLine=by; break; } by++; @@ -127,11 +127,11 @@ public void doProcess(Minecraft minecraft, EntityPlayerSP player){ Vec3 controllerR= minecraft.roomScale.getControllerPos_World(0); Vec3 controllerL= minecraft.roomScale.getControllerPos_World(1); - Vec3 middle= controllerL.subtract(controllerR).scale(0.5).add(controllerR); + Vec3 middle= (controllerL.subtractProperly(controllerR).scale(0.5)).add(controllerR); - Vec3 hmdPos=minecraft.roomScale.getHMDPos_World().subtract(0,0.3,0); + Vec3 hmdPos=minecraft.roomScale.getHMDPos_World().subtractProperly(0,0.3,0); - Vec3 movedir=middle.subtract(hmdPos).normalize().add( + Vec3 movedir=middle.subtractProperly(hmdPos).normalize().add( minecraft.roomScale.getHMDDir_World()).scale(0.5); Vec3 contollerDir= minecraft.roomScale.getCustomControllerVector(0,new Vec3(0,0,-1)).add( @@ -142,9 +142,8 @@ public void doProcess(Minecraft minecraft, EntityPlayerSP player){ double distDelta=lastDist-distance; if(distDelta>0){ - Vec3 velo= OpenVRPlayer.vecMult(movedir, (float)(distDelta*swimspeed*dirfactor)); - - motion=motion.add(OpenVRPlayer.vecMult(velo,0.15f)); + Vec3 velo= movedir.scale(distDelta*swimspeed*dirfactor); + motion=motion.add(velo.scale(0.15)); } lastDist=distance; diff --git a/src/com/mtbs3d/minecrift/provider/MCOpenVR.java b/src/com/mtbs3d/minecrift/provider/MCOpenVR.java index cedbd978..204085c9 100644 --- a/src/com/mtbs3d/minecrift/provider/MCOpenVR.java +++ b/src/com/mtbs3d/minecrift/provider/MCOpenVR.java @@ -1754,7 +1754,7 @@ static void onGuiScreenChanged(GuiScreen previousScreen, GuiScreen newScreen) } // main menu/win game/ - if (mc.theWorld==null || mc.currentScreen instanceof GuiWinGame ) { + if (mc.theWorld==null || newScreen instanceof GuiWinGame ) { //TODO reset scale things MCOpenVR.guiScale = 2.0f; mc.vrPlayer.worldScale = 1; @@ -2012,9 +2012,8 @@ private static void updateAim() { // grab controller position in tracker space, scaled to minecraft units Vector3f controllerPos = OpenVRUtil.convertMatrix4ftoTranslationVector(controllerPose[0]); - aimSource[0].xCoord = controllerPos.x; - aimSource[0].yCoord = controllerPos.y; - aimSource[0].zCoord = controllerPos.z; + + aimSource[0] = Vec3.createVectorHelper(controllerPos.x, controllerPos.y, controllerPos.z); controllerHistory[0].add(aimSource[0]); @@ -2103,9 +2102,8 @@ private static void updateAim() { // update off hand aim Vector3f leftControllerPos = OpenVRUtil.convertMatrix4ftoTranslationVector(controllerPose[1]); - aimSource[1].xCoord = leftControllerPos.x; - aimSource[1].yCoord = leftControllerPos.y; - aimSource[1].zCoord = leftControllerPos.z; + + aimSource[1] = Vec3.createVectorHelper(leftControllerPos.x, leftControllerPos.y, leftControllerPos.z); controllerHistory[1].add(aimSource[1]); diff --git a/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java b/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java index be3ab2c1..c743b28a 100644 --- a/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java +++ b/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java @@ -1013,8 +1013,7 @@ public void updateSwingAttack() float speed = (float) MCOpenVR.controllerHistory[0].averageSpeed(0.1); - weaponEndlast = Vec3.createVectorHelper(weaponEnd.xCoord, weaponEnd.yCoord, weaponEnd.zCoord); - + weaponEndlast = Vec3.createVectorHelper(weaponEnd.xCoord, weaponEnd.yCoord, weaponEnd.zCoord); int bx = (int) MathHelper.floor_double(weaponEnd.xCoord); int by = (int) MathHelper.floor_double(weaponEnd.yCoord); @@ -1176,7 +1175,7 @@ Vec3 getWalkMultOffset() if(player==null || !player.initFromServer) return Vec3.createVectorHelper(0, 0, 0); float walkmult=Minecraft.getMinecraft().vrSettings.walkMultiplier; - Vec3 pos=vecMult(MCOpenVR.getCenterEyePosition(),worldScale); + Vec3 pos=MCOpenVR.getCenterEyePosition().scale(worldScale); return pos.subtract(Vec3.createVectorHelper(pos.xCoord*walkmult,pos.yCoord,pos.zCoord*walkmult)); } @@ -1191,17 +1190,9 @@ public boolean isHMDTracking() { return MCOpenVR.headIsTracking; } - public static Vec3 vecMult(Vec3 in, float factor){ - return Vec3.createVectorHelper(in.xCoord * factor, in.yCoord * factor, in.zCoord*factor); - } - - public static Vec3 vecAdd(Vec3 in, Vec3 in2){ - return Vec3.createVectorHelper(in.xCoord + in2.xCoord, in.yCoord + in2.yCoord, in.zCoord + in2.zCoord); - } - @Override public Vec3 getHMDPos_World() { - Vec3 out = vecMult(MCOpenVR.getCenterEyePosition(),worldScale); + Vec3 out = MCOpenVR.getCenterEyePosition().scale(worldScale); out.rotateAroundY(worldRotationRadians); Vec3 w = getWalkMultOffset(); return out.addVector(roomOrigin.xCoord + w.xCoord, roomOrigin.yCoord + w.yCoord, roomOrigin.zCoord + w.zCoord); @@ -1234,9 +1225,9 @@ public boolean isControllerMainTracking() { @Deprecated public Vec3 getControllerMainPos_World() { - Vec3 out = vecMult(MCOpenVR.getAimSource(0),worldScale); + Vec3 out = MCOpenVR.getAimSource(0).scale(worldScale); out.rotateAroundY(worldRotationRadians); - return vecAdd(out.addVector(roomOrigin.xCoord, roomOrigin.yCoord, roomOrigin.zCoord), getWalkMultOffset()); + return out.addVector(roomOrigin.xCoord, roomOrigin.yCoord, roomOrigin.zCoord).add(getWalkMultOffset()); } @Override @@ -1265,9 +1256,9 @@ public boolean isControllerOffhandTracking() { @Deprecated public Vec3 getControllerOffhandPos_World() { - Vec3 out = vecMult(MCOpenVR.getAimSource(1),worldScale); + Vec3 out = MCOpenVR.getAimSource(1).scale(worldScale); out.rotateAroundY(worldRotationRadians); - return vecAdd(out.addVector(roomOrigin.xCoord, roomOrigin.yCoord, roomOrigin.zCoord), getWalkMultOffset()); + return out.addVector(roomOrigin.xCoord, roomOrigin.yCoord, roomOrigin.zCoord).add(getWalkMultOffset()); } @Override @@ -1314,7 +1305,7 @@ public FloatBuffer getHMDMatrix_World() { @Override //always interpolated public Vec3 getEyePos_World(renderPass eye) { - Vec3 out = vecMult(MCOpenVR.getEyePosition(eye),worldScale); + Vec3 out = MCOpenVR.getEyePosition(eye).scale(worldScale); out.rotateAroundY(worldRotationRadians); Vec3 w = getWalkMultOffset(); return out.addVector(roomOrigin.xCoord + w.xCoord, roomOrigin.yCoord + w.yCoord, roomOrigin.zCoord + w.zCoord); @@ -1346,12 +1337,12 @@ public Vec3 getCustomControllerVector(int controller, Vec3 axis) { @Override public Vec3 getHMDPos_Room() { - return vecAdd(vecMult(MCOpenVR.getCenterEyePosition(),worldScale), getWalkMultOffset()); + return MCOpenVR.getCenterEyePosition().scale(worldScale).add(getWalkMultOffset()); } @Override public Vec3 getControllerPos_Room(int i) { - return vecAdd(vecMult(MCOpenVR.getAimSource(i),worldScale), getWalkMultOffset()); + return MCOpenVR.getAimSource(i).scale(worldScale).add(getWalkMultOffset()); } @Override @@ -1362,7 +1353,7 @@ public Vec3 getControllerDir_Room(int c) { @Override public Vec3 getEyePos_Room(renderPass eye) { - return vecAdd(vecMult(MCOpenVR.getEyePosition(eye),worldScale), getWalkMultOffset()); + return MCOpenVR.getEyePosition(eye).scale(worldScale).add(getWalkMultOffset()); } @Override