diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index deedc7f..490fda8 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b9e1d2c..622ab64 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Mon Aug 22 17:36:22 EDT 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip diff --git a/gradlew b/gradlew index 9aa616c..2fe81a7 100755 --- a/gradlew +++ b/gradlew @@ -1,4 +1,20 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## ## @@ -28,16 +44,16 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -109,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` @@ -138,32 +154,30 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=`save "$@"` -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then - cd "$(dirname "$0")" -fi +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f955316..62bd9b9 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/java/squeek/quakemovement/ModQuakeMovement.java b/java/squeek/quakemovement/ModQuakeMovement.java index 10d0f17..868ebf6 100644 --- a/java/squeek/quakemovement/ModQuakeMovement.java +++ b/java/squeek/quakemovement/ModQuakeMovement.java @@ -26,7 +26,6 @@ public class ModQuakeMovement implements ModInitializer { public static void drawSpeedometer(MatrixStack matrixStack) { - GlStateManager.pushMatrix(); MinecraftClient mc = MinecraftClient.getInstance(); PlayerEntity player = mc.player; double deltaX = player.getX() - player.prevX; diff --git a/java/squeek/quakemovement/QuakeClientPlayer.java b/java/squeek/quakemovement/QuakeClientPlayer.java index 49a864f..df3b1a0 100644 --- a/java/squeek/quakemovement/QuakeClientPlayer.java +++ b/java/squeek/quakemovement/QuakeClientPlayer.java @@ -1,5 +1,6 @@ package squeek.quakemovement; +import com.sun.istack.internal.Nullable; import net.minecraft.block.Block; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; @@ -7,15 +8,18 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.MovementType; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.fluid.Fluid; import net.minecraft.fluid.FluidState; import net.minecraft.particle.BlockStateParticleEffect; import net.minecraft.particle.ParticleTypes; import net.minecraft.tag.FluidTags; +import net.minecraft.tag.Tag; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import net.minecraft.world.WorldView; import java.util.ArrayList; import java.util.List; @@ -49,6 +53,7 @@ public class QuakeClientPlayer if (didQuakeMovement) player.increaseTravelMotionStats(player.getX() - d0, player.getY() - d1, player.getZ() - d2); + System.out.println("didQuakeMovement: " + didQuakeMovement); return didQuakeMovement; } @@ -71,6 +76,11 @@ public class QuakeClientPlayer return updateVelocityPlayer((PlayerEntity) entity, movementInput, movementSpeed); } + public static boolean isInWater(PlayerEntity player) { + FluidState fluidState = player.world.getFluidState(player.getBlockPos()); + return player.isTouchingWater() && player.method_29920() && !player.canWalkOnFluid(fluidState.getFluid()); + } + public static boolean updateVelocityPlayer(PlayerEntity player, Vec3d movementInput, float movementSpeed) { if (!player.world.isClient) @@ -124,6 +134,14 @@ public class QuakeClientPlayer return MathHelper.sqrt(velocity.x * velocity.x + velocity.z * velocity.z); } + /// Assumes the player is on the ground + private static Block getGroundBlock(PlayerEntity player) + { + // copied from Entity.getVelocityAffectingPos + BlockPos groundPos = new BlockPos(player.getX(), player.getBoundingBox().minY - 0.5000001D, player.getZ()); + return player.world.getBlockState(groundPos).getBlock(); + } + private static float getSurfaceFriction(PlayerEntity player) { float f2 = 1.0F; @@ -281,7 +299,7 @@ public class QuakeClientPlayer velocityY = 0.0D; } } - else + else if (!player.hasNoGravity()) { // gravity velocityY -= 0.08D; @@ -299,18 +317,8 @@ public class QuakeClientPlayer private static void minecraft_SwingLimbsBasedOnMovement(PlayerEntity player) { - player.lastLimbDistance = player.limbDistance; - double d0 = player.getX() - player.prevX; - double d1 = player.getZ() - player.prevZ; - float f6 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F; - - if (f6 > 1.0F) - { - f6 = 1.0F; - } - - player.limbDistance += (f6 - player.limbDistance) * 0.4F; - player.limbAngle += player.limbDistance; + // this got extracted out in the Minecraft code, so just use that + player.method_29242(player, false); } private static void minecraft_WaterMove(PlayerEntity player, Vec3d movementInput) @@ -428,6 +436,30 @@ public class QuakeClientPlayer return true; } + // copied from WorldView.containsFluid but with the ability to specify the fluid + static private boolean containsFluid(WorldView world, Box box, Tag tag) { + int i = MathHelper.floor(box.minX); + int j = MathHelper.ceil(box.maxX); + int k = MathHelper.floor(box.minY); + int l = MathHelper.ceil(box.maxY); + int m = MathHelper.floor(box.minZ); + int n = MathHelper.ceil(box.maxZ); + BlockPos.Mutable mutable = new BlockPos.Mutable(); + + for(int o = i; o < j; ++o) { + for(int p = k; p < l; ++p) { + for(int q = m; q < n; ++q) { + BlockState blockState = world.getBlockState(mutable.set(o, p, q)); + if (blockState.getFluidState().isIn(tag)) { + return true; + } + } + } + } + + return false; + } + private static void quake_Jump(PlayerEntity player) { quake_ApplySoftCap(player, quake_getMaxMoveSpeed(player)); @@ -471,6 +503,7 @@ public class QuakeClientPlayer private static void quake_ApplyWaterFriction(PlayerEntity player, double friction) { + System.out.println("quake_ApplyWaterFriction"); player.setVelocity(player.getVelocity().multiply(friction)); } @@ -491,7 +524,7 @@ public class QuakeClientPlayer } } - private static void quake_WaterMove(PlayerEntity player, float sidemove, float upmove, float forwardmove) + private static boolean quake_WaterMove(PlayerEntity player, float sidemove, float upmove, float forwardmove) { double lastPosY = player.getY(); @@ -504,10 +537,14 @@ public class QuakeClientPlayer if (!isSharking || curspeed < 0.078F) { - minecraft_WaterMove(player, new Vec3d(sidemove, upmove, forwardmove)); + System.out.println("not sharking, falling back to minecraft"); + // fallback to Minecraft default movement + return false; } else { + System.out.println("sharking"); + if (curspeed > 0.09) quake_ApplyWaterFriction(player, ModQuakeMovement.CONFIG.getSharkingWaterFriction()); @@ -529,6 +566,7 @@ public class QuakeClientPlayer if (!baseVelocities.isEmpty()) { + System.out.println("has a base velocity"); float speedMod = wishspeed / quake_getMaxMoveSpeed(player); // add in base velocities for (double[] baseVel : baseVelocities) @@ -536,6 +574,8 @@ public class QuakeClientPlayer player.setVelocity(player.getVelocity().add(baseVel[0] * speedMod, 0, baseVel[1] * speedMod)); } } + + return true; } private static void quake_Accelerate(PlayerEntity player, float wishspeed, double wishX, double wishZ, double accel) diff --git a/java/squeek/quakemovement/mixin/PlayerEntityMixin.java b/java/squeek/quakemovement/mixin/PlayerEntityMixin.java index df1dbc1..87409b3 100644 --- a/java/squeek/quakemovement/mixin/PlayerEntityMixin.java +++ b/java/squeek/quakemovement/mixin/PlayerEntityMixin.java @@ -11,7 +11,6 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - import squeek.quakemovement.ModQuakeMovement; import squeek.quakemovement.QuakeClientPlayer; import squeek.quakemovement.QuakeClientPlayer.IsJumpingGetter; diff --git a/java/squeek/quakemovement/mixin/TestSpeedometerMixin.java b/java/squeek/quakemovement/mixin/TestSpeedometerMixin.java index 2161f4e..fce8fc3 100644 --- a/java/squeek/quakemovement/mixin/TestSpeedometerMixin.java +++ b/java/squeek/quakemovement/mixin/TestSpeedometerMixin.java @@ -2,7 +2,6 @@ package squeek.quakemovement.mixin; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.util.math.MatrixStack; - import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject;