From 5c091dca42c9393d244b1ea403f2d6c73550dd12 Mon Sep 17 00:00:00 2001 From: jrbudda Date: Thu, 20 Aug 2020 21:50:56 -0400 Subject: [PATCH] 1.16.2 beta update --- install.py | 18 ++--- installer/Installer.java | 6 +- minecriftversion.py | 8 +-- .../net/minecraft/client/Minecraft.java.patch | 2 +- .../client/renderer/GameRenderer.java.patch | 35 ++++++++- .../client/renderer/WorldRenderer.java.patch | 28 ++++---- .../net/optifine/shaders/Shaders.java.patch | 48 ++++++------- .../gameplay/trackers/SwingTracker.java | 71 ++++++++++++------- 8 files changed, 126 insertions(+), 90 deletions(-) diff --git a/install.py b/install.py index ecd78ef..45fec7e 100644 --- a/install.py +++ b/install.py @@ -214,25 +214,13 @@ def download_deps( mcp_dir, download_mc, forgedep=False ): optifine_jar = "OptiFine-"+of_file_name+".jar" optifine_dest_file = os.path.join( optifine_dest_dir, optifine_jar ) - download_optifine = False - optifine_md5 = '' - if not is_non_zero_file( optifine_dest_file ): - print 'Optifine not Found at' + optifine_dest_file - download_optifine = True - else: - optifine_md5 = get_md5( optifine_dest_file ) - print 'Optifine md5: %s' % optifine_md5 - if optifine_md5 != of_build_md5: - download_optifine = True - print 'Bad MD5!' - else: - print 'MD5 good!' + download_optifine = True if download_optifine: # Use optifine filename for URL optifine_url = "http://vivecraft.org/jar/build/OptiFine-"+of_file_name+of_file_extension print 'Downloading Optifine from ' + optifine_url - if not download_file( optifine_url, optifine_dest_file): + if not download_file( optifine_url, optifine_dest_file, of_build_md5): print 'FAILED to download Optifine!' sys.exit(1) else: @@ -567,6 +555,8 @@ def reallyrmtree(path): if os.path.exists(path): shutil.rmtree(path) else: + os.rename(path, path + "temp") + path = path + "temp" i = 0 try: while os.stat(path) and i < 20: diff --git a/installer/Installer.java b/installer/Installer.java index 999b2cc..db43a26 100644 --- a/installer/Installer.java +++ b/installer/Installer.java @@ -47,8 +47,8 @@ public class Installer extends JPanel implements PropertyChangeListener private static final String MINECRAFT_VERSION = "1.16.2"; private static final String MC_VERSION = "1.16.2"; private static final String MC_MD5 = "114f460c5ba72d0dd66a16ed399c0f6d"; - private static final String OF_FILE_NAME = "1.16.2_HD_U_G3_pre1"; - private static final String OF_MD5 = "a061306600eefbc9b3053d91bd94db71"; + private static final String OF_FILE_NAME = "1.16.2_HD_U_G3_pre2"; + private static final String OF_MD5 = "4a9988e83f85782cd40c80038c9b42b9"; private static final String OF_VERSION_EXT = ".jar"; private static String FORGE_VERSION = "33.0.5"; private static final String HOMEPAGE_LINK = "http://www.vivecraft.org"; @@ -824,7 +824,7 @@ else if (!optOnDiskMd5.equalsIgnoreCase(OF_MD5)) { } // Need to attempt download... - success = downloadFile("http://vivecraft.org/jar/Optifine/OptiFine_" + OF_FILE_NAME + "_LIB" + OF_VERSION_EXT, fo); + success = downloadFile("http://vivecraft.org/jar/Optifine/OptiFine-" + OF_FILE_NAME + "_LIB" + OF_VERSION_EXT, fo); // Check (potentially) downloaded optifine md5 optOnDiskMd5 = GetMd5(fo); if (success == false || optOnDiskMd5 == null || !optOnDiskMd5.equalsIgnoreCase(OF_MD5)) { diff --git a/minecriftversion.py b/minecriftversion.py index a612a67..30c283d 100644 --- a/minecriftversion.py +++ b/minecriftversion.py @@ -1,11 +1,11 @@ project_name = "Vivecraft" mc_version = "1.16.2" mc_file_md5 = "114f460c5ba72d0dd66a16ed399c0f6d" -of_file_name = "1.16.2_HD_U_G3_pre1" -of_file_md5 = "a061306600eefbc9b3053d91bd94db71" -of_build_md5 = "510dae3a2563d3cec725f30702c7d8a6" +of_file_name = "1.16.2_HD_U_G3_pre2" +of_file_md5 = "4a9988e83f85782cd40c80038c9b42b9" +of_build_md5 = "9cbaeb05e8cf97c84c4e3c37ae60c321" minecrift_version_num = "1.16.2" -minecrift_build = "jrbudda-4-r1b3" +minecrift_build = "jrbudda-4-r1b5" of_file_extension = ".jar" mcp_version = "mcp940" mcp_uses_generics = True diff --git a/patches/net/minecraft/client/Minecraft.java.patch b/patches/net/minecraft/client/Minecraft.java.patch index f9bff09..99534c3 100644 --- a/patches/net/minecraft/client/Minecraft.java.patch +++ b/patches/net/minecraft/client/Minecraft.java.patch @@ -202,7 +202,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.16.2 jrbudda-4-r1b3"; ++ public final String minecriftVerString = "Vivecraft 1.16.2 jrbudda-4-r1b5"; + /* end version */ + /** END MINECRIFT */ private static final Logger LOGGER = LogManager.getLogger(); diff --git a/patches/net/minecraft/client/renderer/GameRenderer.java.patch b/patches/net/minecraft/client/renderer/GameRenderer.java.patch index cc4f9e0..6d93fb9 100644 --- a/patches/net/minecraft/client/renderer/GameRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/GameRenderer.java.patch @@ -744,7 +744,7 @@ } } -@@ -1359,4 +1370,2195 @@ +@@ -1359,4 +1370,2224 @@ { return this.overlayTexture; } @@ -2432,7 +2432,31 @@ + return this.colorBuffer; + } + -+ ++ private void renderSwingDebug(int c) { ++ if(true) return; ++ if(mc.swingTracker.miningPoint[c] == null) return; ++ //Swing debug ++ GlStateManager.pushMatrix(); ++ GlStateManager.loadIdentity(); ++ applyVRModelViewLegacy(mc.currentPass); ++ Vector3d eye = mc.vrPlayer.vrdata_world_render.getEye(mc.currentPass).getPosition(); ++ GlStateManager.pushMatrix(); ++ GlStateManager.translated(mc.swingTracker.attackingPoint[c].x - eye.x, mc.swingTracker.attackingPoint[c].y - eye.y, mc.swingTracker.attackingPoint[c].z-eye.z); ++ if(mc.swingTracker.canact[c]) ++ renderDebugAxes(0, 255, 0, 0.03f); ++ else ++ renderDebugAxes(255, 0, 0, 0.03f); ++ GlStateManager.popMatrix(); ++ GlStateManager.pushMatrix(); ++ GlStateManager.translated(mc.swingTracker.miningPoint[c].x - eye.x, mc.swingTracker.miningPoint[c].y - eye.y, mc.swingTracker.miningPoint[c].z-eye.z); ++ if(mc.swingTracker.canact[c]) ++ renderDebugAxes(0, 255, 0, 0.02f); ++ else ++ renderDebugAxes(255, 255, 0, 0.02f); ++ GlStateManager.popMatrix(); ++ GlStateManager.popMatrix(); ++ } ++ + void renderVRHands(float partialTicks, boolean renderright, boolean renderleft, boolean menuhandright, boolean menuhandleft) { + this.mc.getProfiler().startSection("hands"); + @@ -2440,6 +2464,7 @@ + //mc.physicalGuiManager.doRender(partialTicks); + // + ++ + if(renderright) { + mc.getItemRenderer().ismainhand = true; + if(menuhandright) { @@ -2451,6 +2476,8 @@ + mat.getLast().getMatrix().setIdentity(); + applyVRModelView(mc.currentPass, mat); + this.renderVRHand_Main(mat, partialTicks); ++ //Testing ++ renderSwingDebug(0); + } + mc.getItemRenderer().ismainhand = false; + } @@ -2465,6 +2492,8 @@ + mat.getLast().getMatrix().setIdentity(); + applyVRModelView(mc.currentPass, mat); + this.renderVRHand_Offhand(partialTicks, true, mat); ++ //Testing ++ renderSwingDebug(1); + } + } + this.mc.getProfiler().endSection(); @@ -2475,7 +2504,7 @@ + matrix.push(); + //from HMD to controller + SetupRenderingAtController(0, matrix); -+ ++ + ItemStack item = mc.player.getHeldItemMainhand(); + ItemStack override=mc.physicalGuiManager.getHeldItemOverride(); + if(override!=null) diff --git a/patches/net/minecraft/client/renderer/WorldRenderer.java.patch b/patches/net/minecraft/client/renderer/WorldRenderer.java.patch index 55d2276..ffe429c 100644 --- a/patches/net/minecraft/client/renderer/WorldRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/WorldRenderer.java.patch @@ -334,32 +334,32 @@ irendertypebuffer$impl.finish(Atlases.getTranslucentCullBlockType()); irendertypebuffer$impl.finish(Atlases.getBannerType()); irendertypebuffer$impl.finish(Atlases.getShieldType()); -@@ -1833,13 +1917,21 @@ - +@@ -1834,13 +1918,21 @@ if (flag1) { + irendertypebuffer$impl.finish(); - Shaders.preRenderHand(); - ShadersRender.renderHand0(gameRendererIn, matrixStackIn, activeRenderInfoIn, partialTicks); + //Shaders.preRenderHand(); + //ShadersRender.renderHand0(gameRendererIn, matrixStackIn, activeRenderInfoIn, partialTicks); Shaders.preWater(); } -+ + + //Temporary hack til I can figure out whats wrong with this + if(mc.currentPass ==RenderPass.SCOPEL || mc.currentPass == RenderPass.SCOPER ) + this.field_239227_K_ = null; + // -+ ++ + boolean menuHandleft = gameRendererIn.isInMenuRoom() || mc.currentScreen != null || KeyboardHandler.Showing; + boolean menuhandright = menuHandleft || (mc.interactTracker.hotbar >= 0 && mc.vrSettings.vrTouchHotbar); - ++ if (this.field_239227_K_ != null) - { + { //fabulous! irendertypebuffer$impl.finish(RenderType.getLines()); irendertypebuffer$impl.finish(); this.field_239222_F_.framebufferClear(Minecraft.IS_RUNNING_ON_MAC); -@@ -1853,10 +1945,17 @@ +@@ -1854,10 +1946,17 @@ RenderState.field_239237_T_.setupRenderState(); iprofiler.endStartSection("particles"); this.mc.particles.renderParticles(matrixStackIn, irendertypebuffer$impl, lightmapIn, activeRenderInfoIn, partialTicks); @@ -379,7 +379,7 @@ iprofiler.endStartSection("translucent"); if (flag1) -@@ -1883,7 +1982,11 @@ +@@ -1884,7 +1983,11 @@ } this.mc.particles.renderParticles(matrixStackIn, irendertypebuffer$impl, lightmapIn, activeRenderInfoIn, partialTicks); @@ -392,7 +392,7 @@ if (flag1) { Shaders.endParticles(); -@@ -3189,10 +3292,11 @@ +@@ -3190,10 +3293,11 @@ { bufferIn.pos(xIn - camX, (double)yIn - camY, zIn - camZ).tex(texU, texV).endVertex(); } @@ -406,7 +406,7 @@ } public static void drawVoxelShapeParts(MatrixStack matrixStackIn, IVertexBuilder bufferIn, VoxelShape shapeIn, double xIn, double yIn, double zIn, float red, float green, float blue, float alpha) -@@ -3656,6 +3760,8 @@ +@@ -3661,6 +3765,8 @@ { Random random = this.world.rand; @@ -415,7 +415,7 @@ switch (type) { case 1000: -@@ -3718,18 +3824,26 @@ +@@ -3723,18 +3829,26 @@ break; case 1011: @@ -442,7 +442,7 @@ this.world.playSound(blockPosIn, SoundEvents.BLOCK_FENCE_GATE_CLOSE, SoundCategory.BLOCKS, 1.0F, random.nextFloat() * 0.1F + 0.9F, false); break; -@@ -3750,14 +3864,26 @@ +@@ -3755,14 +3869,26 @@ break; case 1019: @@ -469,7 +469,7 @@ this.world.playSound(blockPosIn, SoundEvents.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, SoundCategory.HOSTILE, 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false); break; -@@ -3786,10 +3912,17 @@ +@@ -3791,10 +3917,17 @@ break; case 1030: @@ -487,7 +487,7 @@ this.world.playSound(blockPosIn, SoundEvents.BLOCK_ANVIL_LAND, SoundCategory.BLOCKS, 0.3F, this.world.rand.nextFloat() * 0.1F + 0.9F, false); break; -@@ -3810,6 +3943,9 @@ +@@ -3815,6 +3948,9 @@ break; case 1036: @@ -497,7 +497,7 @@ this.world.playSound(blockPosIn, SoundEvents.BLOCK_IRON_TRAPDOOR_CLOSE, SoundCategory.BLOCKS, 1.0F, random.nextFloat() * 0.1F + 0.9F, false); break; -@@ -4402,4 +4538,40 @@ +@@ -4407,4 +4543,40 @@ super(p_i232463_1_, p_i232463_2_); } } diff --git a/patches/net/optifine/shaders/Shaders.java.patch b/patches/net/optifine/shaders/Shaders.java.patch index e39a17a..0e8fc72 100644 --- a/patches/net/optifine/shaders/Shaders.java.patch +++ b/patches/net/optifine/shaders/Shaders.java.patch @@ -20,7 +20,7 @@ public static boolean isInitializedOnce = false; public static boolean isShaderPackInitialized = false; public static GLCapabilities capabilities; -@@ -340,12 +345,12 @@ +@@ -341,12 +346,12 @@ static final int MaxShadowColorBuffers = 8; static final int MaxShadowDepthBuffers = 2; static int usedColorBuffers = 0; @@ -35,7 +35,7 @@ static int sfb = 0; private static int[] gbuffersFormat = new int[8]; public static boolean[] gbuffersClear = new boolean[8]; -@@ -435,7 +440,7 @@ +@@ -436,7 +441,7 @@ private static ShaderOption[] shaderPackOptions = null; private static Set shaderPackOptionSliders = null; static ShaderProfile[] shaderPackProfiles = null; @@ -44,7 +44,7 @@ static Map shaderPackProgramConditions = new HashMap<>(); public static final String PATH_SHADERS_PROPERTIES = "/shaders/shaders.properties"; public static PropertyDefaultFastFancyOff shaderPackClouds = new PropertyDefaultFastFancyOff("clouds", "Clouds", 0); -@@ -511,7 +516,7 @@ +@@ -512,7 +517,7 @@ static final FloatBuffer tempMatrixDirectBuffer = nextFloatBuffer(16); static final FloatBuffer tempDirectFloatBuffer = nextFloatBuffer(16); static final IntBuffer dfbColorTextures = nextIntBuffer(16); @@ -53,7 +53,7 @@ static final IntBuffer sfbColorTextures = nextIntBuffer(8); static final IntBuffer sfbDepthTextures = nextIntBuffer(2); static final IntBuffer dfbDrawBuffers = nextIntBuffer(8); -@@ -530,6 +535,11 @@ +@@ -531,6 +536,11 @@ { } @@ -65,7 +65,7 @@ private static ByteBuffer nextByteBuffer(int size) { ByteBuffer bytebuffer = bigBuffer; -@@ -832,7 +842,7 @@ +@@ -833,7 +843,7 @@ shaderPackOptions = null; shaderPackOptionSliders = null; shaderPackProfiles = null; @@ -74,7 +74,7 @@ shaderPackProgramConditions.clear(); shaderPackClouds.resetValue(); shaderPackOldHandLight.resetValue(); -@@ -888,6 +898,27 @@ +@@ -889,6 +899,27 @@ loadShaderPackResources(); loadShaderPackDimensions(); shaderPackOptions = loadShaderPackOptions(); @@ -102,7 +102,7 @@ loadShaderPackProperties(); boolean flag3 = shaderPackLoaded != flag; boolean flag4 = isOldLighting() != flag1; -@@ -1061,7 +1092,7 @@ +@@ -1062,7 +1093,7 @@ shaderPackFrustumCulling.loadFrom(properties); shaderPackOptionSliders = ShaderPackParser.parseOptionSliders(properties, shaderPackOptions); shaderPackProfiles = ShaderPackParser.parseProfiles(properties, shaderPackOptions); @@ -111,7 +111,7 @@ shaderPackProgramConditions = ShaderPackParser.parseProgramConditions(properties, shaderPackOptions); customTexturesGbuffers = loadCustomTextures(properties, 0); customTexturesComposite = loadCustomTextures(properties, 1); -@@ -1564,7 +1595,7 @@ +@@ -1565,7 +1596,7 @@ { ShaderOption[] ashaderoption = (ShaderOption[])shaderPackOptions.clone(); @@ -120,7 +120,7 @@ { if (shaderPackProfiles != null) { -@@ -1577,7 +1608,7 @@ +@@ -1578,7 +1609,7 @@ else { String s = screenName != null ? "screen." + screenName : "screen"; @@ -129,7 +129,7 @@ if (screenshaderoptions == null) { -@@ -1598,7 +1629,7 @@ +@@ -1599,7 +1630,7 @@ } else if (shaderoption instanceof ShaderOptionRest) { @@ -138,7 +138,7 @@ list.addAll(Arrays.asList(ashaderoption2)); } else -@@ -1616,13 +1647,13 @@ +@@ -1617,13 +1648,13 @@ { String s = screenName != null ? "screen." + screenName : "screen"; @@ -154,7 +154,7 @@ return screenshaderoptions == null ? def : screenshaderoptions.getColumns(); } } -@@ -2395,6 +2426,8 @@ +@@ -2396,6 +2427,8 @@ } checkGLError("Shaders.init"); @@ -163,7 +163,7 @@ } } -@@ -3512,8 +3545,14 @@ +@@ -3514,8 +3547,14 @@ setProgramUniform1f(uniform_viewWidth, (float)renderWidth); setProgramUniform1f(uniform_viewHeight, (float)renderHeight); setProgramUniform1f(uniform_near, 0.05F); @@ -180,7 +180,7 @@ setProgramUniform3f(uniform_moonPosition, moonPosition[0], moonPosition[1], moonPosition[2]); setProgramUniform3f(uniform_shadowLightPosition, shadowLightPosition[0], shadowLightPosition[1], shadowLightPosition[2]); setProgramUniform3f(uniform_upPosition, upPosition[0], upPosition[1], upPosition[2]); -@@ -3881,8 +3920,9 @@ +@@ -3884,8 +3923,9 @@ { renderDisplayWidth = mc.getMainWindow().getFramebufferWidth(); renderDisplayHeight = mc.getMainWindow().getFramebufferHeight(); @@ -192,7 +192,7 @@ setupFrameBuffer(); } -@@ -3912,20 +3952,23 @@ +@@ -3915,20 +3955,23 @@ GL32.glDrawBuffers(0); GL32.glReadBuffer(0); @@ -225,7 +225,7 @@ checkGLError("FT d"); for (int k = 0; k < usedColorBuffers; ++k) -@@ -4083,7 +4126,7 @@ +@@ -4086,7 +4129,7 @@ checkWorldChanged(mc.world); mc = minecraft; mc.getProfiler().startSection("init"); @@ -234,7 +234,7 @@ if (!isShaderPackInitialized) { -@@ -4103,9 +4146,10 @@ +@@ -4106,9 +4149,10 @@ } } @@ -246,7 +246,7 @@ } if (needResizeShadow) -@@ -4157,7 +4201,7 @@ +@@ -4160,7 +4204,7 @@ if (entity != null) { @@ -255,7 +255,7 @@ eyePosY = (float)activeRenderInfo.getProjectedView().getY(); eyeBrightness = mc.getRenderManager().getPackedLight(entity, partialTicks); float f2 = (float)diffSystemTime * 0.01F; -@@ -4186,7 +4230,6 @@ +@@ -4189,7 +4233,6 @@ if (livingentity.isPotionActive(Effects.NIGHT_VISION)) { @@ -263,7 +263,7 @@ nightVision = GameRenderer.getNightVisionBrightness(livingentity, partialTicks); } -@@ -4229,7 +4272,9 @@ +@@ -4232,7 +4275,9 @@ ((Buffer)previousModelView).position(0); ((Buffer)modelView).position(0); checkGLError("beginRender"); @@ -274,7 +274,7 @@ mc.getProfiler().endSection(); EXTFramebufferObject.glBindFramebufferEXT(36160, dfb); -@@ -4496,9 +4541,14 @@ +@@ -4499,9 +4544,14 @@ ((Buffer)projection).position(0); ((Buffer)projectionInverse).position(0); Matrix4f matrix4f = matrixStackIn.getLast().getMatrix(); @@ -292,7 +292,7 @@ ((Buffer)modelView).position(0); modelView.put(tempMat); SMath.invertMat4FBFA((FloatBuffer)((Buffer)modelViewInverse).position(0), (FloatBuffer)((Buffer)modelView).position(0), faModelViewInverse, faModelView); -@@ -4638,13 +4688,24 @@ +@@ -4641,13 +4691,24 @@ Matrix4f matrix4f1 = new Matrix4f(matrix4f); matrix4f1.transpose(); matrix4f1.write(tempMat); @@ -318,7 +318,7 @@ if (customUniforms != null) { customUniforms.update(); -@@ -5739,7 +5800,7 @@ +@@ -5742,7 +5803,7 @@ private static void loadShaderPackResources() { shaderPackResources = new HashMap<>(); @@ -327,7 +327,7 @@ if (shaderPackLoaded) { List list = new ArrayList<>(); -@@ -5772,6 +5833,7 @@ +@@ -5775,6 +5836,7 @@ { String s6 = properties.getProperty(s5); shaderPackResources.put(s5, s6); diff --git a/src/org/vivecraft/gameplay/trackers/SwingTracker.java b/src/org/vivecraft/gameplay/trackers/SwingTracker.java index c0f4fd3..214fd48 100644 --- a/src/org/vivecraft/gameplay/trackers/SwingTracker.java +++ b/src/org/vivecraft/gameplay/trackers/SwingTracker.java @@ -50,7 +50,10 @@ public class SwingTracker extends Tracker{ //VIVECRAFT SWINGING SUPPORT private Vector3d[] lastWeaponEndAir = new Vector3d[]{new Vector3d(0, 0, 0), new Vector3d(0,0,0)}; private boolean[] lastWeaponSolid = new boolean[2]; - public Vector3d[] weaponEnd= new Vector3d[2]; + + public Vector3d[] miningPoint= new Vector3d[2]; + public Vector3d[] attackingPoint= new Vector3d[2]; + public Vec3History[] tipHistory = new Vec3History[] { new Vec3History(), new Vec3History()}; public boolean[] canact= new boolean[2]; @@ -111,12 +114,12 @@ public static boolean isTool(Item item) { } Vector3d forward = new Vector3d(0,0,-1); - double speedthresh = 2.0f; + double speedthresh = 3.0f; public void doProcess(ClientPlayerEntity player){ //on tick - speedthresh = 2.0f; + speedthresh = 3.0f; if(player.isCreative()) - speedthresh *= 2; + speedthresh *= 1.5; mc.getProfiler().startSection("updateSwingAttack"); @@ -155,12 +158,12 @@ else if (isTool(item)) { // } if (sword){ - entityReachAdd = 1.8f; - weaponLength = 0.7f; + entityReachAdd = 1.9f; + weaponLength = 0.6f; tool = true; } else if (tool){ - entityReachAdd = 1.0f; - weaponLength = 0.5f; + entityReachAdd = 1.2f; + weaponLength = 0.3f; tool = true; } else if (!is.isEmpty()){ weaponLength = 0.1f; @@ -172,26 +175,31 @@ else if (isTool(item)) { weaponLength *= mc.vrPlayer.vrdata_world_pre.worldScale; - weaponEnd[c] = new Vector3d( - handPos.x + handDirection.x * weaponLength, - handPos.y + handDirection.y * weaponLength, - handPos.z + handDirection.z * weaponLength); - - tipHistory[c].add(weaponEnd[c].subtract(mc.vrPlayer.vrdata_world_pre.origin)); - - boolean inAnEntity = false; + miningPoint[c] = handPos.add(handDirection.scale(weaponLength)); + {//do speed calc in actual room coords + Vector3d vel = mc.vrPlayer.vrdata_room_pre.getController(c).getPosition().add(mc.vrPlayer.vrdata_room_pre.getHand(c).getCustomVector(forward).scale(0.3)); + tipHistory[c].add(vel); + } // at a 0.3m offset on index controllers a speed of 3m/s is a intended smack, 7 m/s is about as high as your arm can go. + float speed = (float) tipHistory[c].averageSpeed(0.33); - + boolean inAnEntity = false; canact[c] = speed > speedthresh && !lastWeaponSolid[c]; - + //Check EntityCollisions first { - AxisAlignedBB weaponBB = new AxisAlignedBB(handPos, weaponEnd[c]); - Vector3d extWeapon = new Vector3d( - handPos.x + handDirection.x * (weaponLength + entityReachAdd), - handPos.y + handDirection.y * (weaponLength + entityReachAdd), - handPos.z + handDirection.z * (weaponLength + entityReachAdd)); + boolean entityact = canact[c]; + if(entityact) { + BlockRayTraceResult test = mc.world.rayTraceBlocks(new RayTraceContext(mc.vrPlayer.vrdata_world_pre.hmd.getPosition(), handPos, BlockMode.OUTLINE, FluidMode.NONE, mc.player)); + if(test.getType() != Type.MISS) + entityact = false; + } + attackingPoint[c] = constrain(handPos, miningPoint[c]); + + Vector3d extWeapon = handPos.add(handDirection.scale(weaponLength + entityReachAdd)); + extWeapon = constrain(handPos, extWeapon); + + AxisAlignedBB weaponBB = new AxisAlignedBB(handPos, attackingPoint[c]); AxisAlignedBB weaponBBEXT = new AxisAlignedBB(handPos, extWeapon); List mobs = mc.world.getEntitiesWithinAABBExcludingEntity(mc.player, weaponBBEXT); @@ -206,7 +214,7 @@ else if (isTool(item)) { for (Entity hitEntity : mobs) { if (hitEntity.canBeCollidedWith() && !(hitEntity == mc.getRenderViewEntity().getRidingEntity()) ) { - if(canact[c]){ + if(entityact){ Minecraft.getInstance().physicalGuiManager.preClickAction(); mc.playerController.attackEntity(player, hitEntity); MCOpenVR.triggerHapticPulse(c, 1000); @@ -234,15 +242,15 @@ else if (isTool(item)) { if(c == 1 && MCOpenVR.keyClimbeyGrab.isKeyDown(ControllerType.LEFT) || !tool ) continue; } - BlockPos bp = new BlockPos(weaponEnd[c]); + BlockPos bp = new BlockPos(miningPoint[c]); BlockState block = mc.world.getBlockState(bp); // every time end of weapon enters a solid for the first time, trace from our previous air position // and damage the block it collides with... - BlockRayTraceResult blockHit = mc.world.rayTraceBlocks(new RayTraceContext(lastWeaponEndAir[c], weaponEnd[c], BlockMode.OUTLINE, FluidMode.NONE, mc.player)); + BlockRayTraceResult blockHit = mc.world.rayTraceBlocks(new RayTraceContext(lastWeaponEndAir[c], miningPoint[c], BlockMode.OUTLINE, FluidMode.NONE, mc.player)); if(block.isAir() || blockHit.getType() != Type.BLOCK || lastWeaponEndAir[c].length() == 0) { //reset - this.lastWeaponEndAir[c] = weaponEnd[c]; + this.lastWeaponEndAir[c] = miningPoint[c]; lastWeaponSolid[c] = false; continue; } @@ -307,6 +315,15 @@ private void clearBlockHitDelay() { } + public Vector3d constrain(Vector3d start, Vector3d end) { + BlockRayTraceResult test = mc.world.rayTraceBlocks(new RayTraceContext(start, end, BlockMode.OUTLINE, FluidMode.NONE, mc.player)); + if(test.getType() == Type.BLOCK) { + return test.getHitVec(); + } else { + return end; + } + } + //Get the transparency for held items to indicate attack power or sneaking. public static float getItemFade(ClientPlayerEntity p, ItemStack is) { float fade = p.getCooledAttackStrength(0)*.75f + .25f;