mirror of
https://github.com/squeek502/Squake.git
synced 2025-09-08 11:37:54 -04:00
port to 1.16.1
This commit is contained in:
parent
2839df8e88
commit
a8e5c1508f
@ -17,7 +17,7 @@ dependencies {
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modCompile "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:0.16.2+build.261-1.14"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:0.16.2+build.385-1.16.1"
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/use
|
||||
minecraft_version=1.14.4
|
||||
yarn_mappings=1.14.4+build.5
|
||||
minecraft_version=1.16.1
|
||||
yarn_mappings=1.16.1+build.21
|
||||
loader_version=0.9.0+build.204
|
||||
|
||||
# Mod Properties
|
||||
|
@ -3,6 +3,7 @@ package squeek.quakemovement;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
@ -11,6 +12,7 @@ public class ModQuakeMovement implements ModInitializer
|
||||
@Override
|
||||
public void onInitialize()
|
||||
{
|
||||
//todo why is this here?
|
||||
}
|
||||
|
||||
public static float getFriction()
|
||||
@ -18,16 +20,16 @@ public class ModQuakeMovement implements ModInitializer
|
||||
return 0.6f;
|
||||
}
|
||||
|
||||
public static void drawSpeedometer()
|
||||
public static void drawSpeedometer(MatrixStack matrixStack)
|
||||
{
|
||||
GlStateManager.pushMatrix();
|
||||
MinecraftClient mc = MinecraftClient.getInstance();
|
||||
PlayerEntity player = mc.player;
|
||||
double deltaX = player.x - player.prevX;
|
||||
double deltaZ = player.z - player.prevZ;
|
||||
double deltaX = player.getX() - player.prevX;
|
||||
double deltaZ = player.getZ() - player.prevZ;
|
||||
double speed = MathHelper.sqrt(deltaX * deltaX + deltaZ * deltaZ);
|
||||
String speedString = String.format("%.02f", speed);
|
||||
mc.textRenderer.drawWithShadow(speedString, 10, mc.window.getScaledHeight() - mc.textRenderer.fontHeight - 10, 0xFFDDDDDD);
|
||||
mc.textRenderer.drawWithShadow(matrixStack, speedString, 10, mc.getWindow().getScaledHeight() - mc.textRenderer.fontHeight - 10, 0xFFDDDDDD);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
@ -32,9 +32,9 @@ public class QuakeClientPlayer
|
||||
return false;
|
||||
|
||||
boolean didQuakeMovement;
|
||||
double d0 = player.x;
|
||||
double d1 = player.y;
|
||||
double d2 = player.z;
|
||||
double d0 = player.getX();
|
||||
double d1 = player.getY();
|
||||
double d2 = player.getZ();
|
||||
|
||||
if ((player.abilities.flying || player.isFallFlying()) && !player.hasVehicle())
|
||||
return false;
|
||||
@ -42,7 +42,7 @@ public class QuakeClientPlayer
|
||||
didQuakeMovement = quake_travel(player, movementInput);
|
||||
|
||||
if (didQuakeMovement)
|
||||
player.method_7282(player.x - d0, player.y - d1, player.z - d2);
|
||||
player.increaseTravelMotionStats(player.getX() - d0, player.getY() - d1, player.getZ() - d2);
|
||||
|
||||
return didQuakeMovement;
|
||||
}
|
||||
@ -74,7 +74,7 @@ public class QuakeClientPlayer
|
||||
if (!ModConfig.ENABLED)
|
||||
return false;
|
||||
|
||||
if ((player.abilities.flying && !player.hasVehicle()) || player.isInsideWater() || player.isInLava() || !player.abilities.flying)
|
||||
if ((player.abilities.flying && !player.hasVehicle()) || player.isTouchingWater() || player.isInLava() || !player.abilities.flying)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -123,9 +123,9 @@ public class QuakeClientPlayer
|
||||
{
|
||||
float f2 = 1.0F;
|
||||
|
||||
if (player.onGround)
|
||||
if (player.isOnGround())
|
||||
{
|
||||
BlockPos groundPos = new BlockPos(MathHelper.floor(player.x), MathHelper.floor(player.getBoundingBox().minY) - 1, MathHelper.floor(player.z));
|
||||
BlockPos groundPos = new BlockPos(MathHelper.floor(player.getX()), MathHelper.floor(player.getBoundingBox().minY) - 1, MathHelper.floor(player.getZ()));
|
||||
Block ground = player.world.getBlockState(groundPos).getBlock();
|
||||
f2 = 1.0F - ground.getSlipperiness();
|
||||
}
|
||||
@ -136,10 +136,10 @@ public class QuakeClientPlayer
|
||||
private static float getSlipperiness(PlayerEntity player)
|
||||
{
|
||||
float f2 = 0.91F;
|
||||
if (player.onGround)
|
||||
if (player.isOnGround())
|
||||
{
|
||||
f2 = 0.54600006F;
|
||||
BlockPos groundPos = new BlockPos(MathHelper.floor(player.x), MathHelper.floor(player.getBoundingBox().minY) - 1, MathHelper.floor(player.z));
|
||||
BlockPos groundPos = new BlockPos(MathHelper.floor(player.getX()), MathHelper.floor(player.getBoundingBox().minY) - 1, MathHelper.floor(player.getZ()));
|
||||
Block ground = player.world.getBlockState(groundPos).getBlock();
|
||||
|
||||
f2 = ground.getSlipperiness() * 0.91F;
|
||||
@ -197,16 +197,16 @@ public class QuakeClientPlayer
|
||||
private static void spawnBunnyhopParticles(PlayerEntity player, int numParticles)
|
||||
{
|
||||
// taken from sprint
|
||||
int j = MathHelper.floor(player.x);
|
||||
int i = MathHelper.floor(player.y - 0.20000000298023224D - player.getHeightOffset());
|
||||
int k = MathHelper.floor(player.z);
|
||||
int j = MathHelper.floor(player.getX());
|
||||
int i = MathHelper.floor(player.getY() - 0.20000000298023224D - player.getHeightOffset());
|
||||
int k = MathHelper.floor(player.getZ());
|
||||
BlockState blockState = player.world.getBlockState(new BlockPos(j, i, k));
|
||||
|
||||
if (blockState.getRenderType() != BlockRenderType.INVISIBLE)
|
||||
{
|
||||
for (int iParticle = 0; iParticle < numParticles; iParticle++)
|
||||
{
|
||||
player.world.addParticle(new BlockStateParticleEffect(ParticleTypes.BLOCK, blockState), player.x + (random.nextFloat() - 0.5D) * player.getWidth(), player.y + 0.1D, player.z + (random.nextFloat() - 0.5D) * player.getWidth(), -player.getVelocity().x * 4.0D, 1.5D, -player.getVelocity().z * 4.0D);
|
||||
player.world.addParticle(new BlockStateParticleEffect(ParticleTypes.BLOCK, blockState), player.getX() + (random.nextFloat() - 0.5D) * player.getWidth(), player.getY() + 0.1D, player.getZ() + (random.nextFloat() - 0.5D) * player.getWidth(), -player.getVelocity().x * 4.0D, 1.5D, -player.getVelocity().z * 4.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -233,11 +233,11 @@ public class QuakeClientPlayer
|
||||
|
||||
private static void minecraft_ApplyGravity(PlayerEntity player)
|
||||
{
|
||||
BlockPos pos = new BlockPos((int) player.x, (int) player.y, (int) player.z);
|
||||
//BlockPos pos = new BlockPos((int) player.x, (int) player.y, (int) player.z);
|
||||
double velocityY = player.getVelocity().y;
|
||||
if (player.world.isClient && !player.world.isBlockLoaded(pos))
|
||||
if (/*player.world.isClient && !player.world.isBlockLoaded(pos)*/ false) //todo fix
|
||||
{
|
||||
if (player.y > 0.0D)
|
||||
if (player.getY() > 0.0D)
|
||||
{
|
||||
velocityY = -0.1D;
|
||||
}
|
||||
@ -317,8 +317,8 @@ public class QuakeClientPlayer
|
||||
private static void minecraft_SwingLimbsBasedOnMovement(PlayerEntity player)
|
||||
{
|
||||
player.lastLimbDistance = player.limbDistance;
|
||||
double d0 = player.x - player.prevX;
|
||||
double d1 = player.z - player.prevZ;
|
||||
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)
|
||||
@ -405,7 +405,7 @@ public class QuakeClientPlayer
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInsideWater() && !player.abilities.flying)
|
||||
else if (player.isTouchingWater() && !player.abilities.flying)
|
||||
{
|
||||
// if (ModConfig.SHARKING_ENABLED)
|
||||
// quake_WaterMove(player, (float) movementInput.x, (float) movementInput.y, (float) movementInput.z);
|
||||
@ -419,7 +419,7 @@ public class QuakeClientPlayer
|
||||
// get all relevant movement values
|
||||
float wishspeed = (movementInput.x != 0.0D || movementInput.z != 0.0D) ? quake_getMoveSpeed(player) : 0.0F;
|
||||
double[] wishdir = getMovementDirection(player, movementInput.x, movementInput.z);
|
||||
boolean onGroundForReal = player.onGround && !isJumping(player);
|
||||
boolean onGroundForReal = player.isOnGround() && !isJumping(player);
|
||||
float momentumRetention = getSlipperiness(player);
|
||||
|
||||
// ground movement
|
||||
@ -458,7 +458,7 @@ public class QuakeClientPlayer
|
||||
if (ModConfig.SHARKING_ENABLED && ModConfig.SHARKING_SURFACE_TENSION > 0.0D && isJumping(player) && player.getVelocity().y < 0.0F)
|
||||
{
|
||||
Box axisalignedbb = player.getBoundingBox().offset(player.getVelocity());
|
||||
boolean isFallingIntoWater = player.world.containsBlockWithMaterial(axisalignedbb, Material.WATER);
|
||||
boolean isFallingIntoWater = false;//player.world.containsBlockWithMaterial(axisalignedbb, Material.WATER); //todo fix
|
||||
|
||||
if (isFallingIntoWater)
|
||||
player.setVelocity(player.getVelocity().multiply(1.0D, ModConfig.SHARKING_SURFACE_TENSION, 1.0D));
|
||||
@ -566,12 +566,12 @@ public class QuakeClientPlayer
|
||||
|
||||
private static void quake_WaterMove(PlayerEntity player, float sidemove, float upmove, float forwardmove)
|
||||
{
|
||||
double lastPosY = player.y;
|
||||
double lastPosY = player.getY();
|
||||
|
||||
// get all relevant movement values
|
||||
float wishspeed = (sidemove != 0.0F || forwardmove != 0.0F) ? quake_getMaxMoveSpeed(player) : 0.0F;
|
||||
double[] wishdir = getMovementDirection(player, sidemove, forwardmove);
|
||||
boolean isOffsetInLiquid = player.world.getBlockState(new BlockPos(player.x, player.y + 1.0D, player.z)).getFluidState().isEmpty();
|
||||
boolean isOffsetInLiquid = player.world.getBlockState(new BlockPos(player.getX(), player.getY() + 1.0D, player.getZ())).getFluidState().isEmpty();
|
||||
boolean isSharking = isJumping(player) && isOffsetInLiquid;
|
||||
double curspeed = getSpeed(player);
|
||||
|
||||
@ -595,7 +595,7 @@ public class QuakeClientPlayer
|
||||
}
|
||||
|
||||
// water jump
|
||||
if (player.horizontalCollision && player.doesNotCollide(player.getVelocity().x, player.getVelocity().y + 0.6000000238418579D - player.y + lastPosY, player.getVelocity().z))
|
||||
if (player.horizontalCollision && player.doesNotCollide(player.getVelocity().x, player.getVelocity().y + 0.6000000238418579D - player.getY() + lastPosY, player.getVelocity().z))
|
||||
{
|
||||
player.setVelocity(player.getVelocity().x, 0.30000001192092896D, player.getVelocity().z);
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
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.ModConfig;
|
||||
import squeek.quakemovement.QuakeClientPlayer;
|
||||
import squeek.quakemovement.QuakeServerPlayer;
|
||||
@ -35,14 +37,14 @@ public abstract class PlayerEntityMixin
|
||||
QuakeClientPlayer.afterJump((PlayerEntity) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "handleFallDamage(FF)V")
|
||||
private void beforeFall(float fallDistance, float damageMultiplier, CallbackInfo info)
|
||||
@Inject(at = @At("HEAD"), method = "handleFallDamage")
|
||||
private void beforeFall(float fallDistance, float damageMultiplier, CallbackInfoReturnable<Boolean> info)
|
||||
{
|
||||
QuakeServerPlayer.beforeFall((PlayerEntity) (Object) this, fallDistance, damageMultiplier);
|
||||
}
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "handleFallDamage(FF)V")
|
||||
private void afterFall(float fallDistance, float damageMultiplier, CallbackInfo info)
|
||||
@Inject(at = @At("TAIL"), method = "handleFallDamage")
|
||||
private void afterFall(float fallDistance, float damageMultiplier, CallbackInfoReturnable<Boolean> info)
|
||||
{
|
||||
QuakeServerPlayer.afterFall((PlayerEntity) (Object) this, fallDistance, damageMultiplier);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
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;
|
||||
@ -10,10 +12,10 @@ import squeek.quakemovement.ModQuakeMovement;
|
||||
@Mixin(InGameHud.class)
|
||||
public class TestSpeedometerMixin
|
||||
{
|
||||
@Inject(at = @At("HEAD"), method = "renderStatusEffectOverlay()V")
|
||||
private void renderStatusEffectOverlay(CallbackInfo info)
|
||||
@Inject(at = @At("HEAD"), method = "renderStatusEffectOverlay")
|
||||
private void renderStatusEffectOverlay(MatrixStack matrixStack, CallbackInfo info)
|
||||
{
|
||||
ModQuakeMovement.drawSpeedometer();
|
||||
ModQuakeMovement.drawSpeedometer(matrixStack);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user