port to 1.18

This commit is contained in:
Zach Mehall 2022-10-11 15:01:12 -07:00
parent 1e07dbda1c
commit cebb96aada
7 changed files with 32 additions and 33 deletions

View File

@ -1,9 +1,10 @@
plugins {
id 'fabric-loom' version '0.4-SNAPSHOT'
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
archivesBaseName = project.archives_base_name
group = project.maven_group
@ -20,13 +21,10 @@ dependencies {
}
processResources {
inputs.property "vars", project.version
from(sourceSets.main.resources.srcDirs) {
include '**/fabric.mod.json'
expand 'version':project.version
}
from(sourceSets.main.resources.srcDirs) {
exclude '**/fabric.mod.json'
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}

View File

@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.16.1
yarn_mappings=1.16.1+build.1
loader_version=0.8.8+build.202
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.3
loader_version=0.14.6
# Mod Properties
maven_group = squeek.quakemovement
@ -13,4 +13,4 @@ archives_base_name = squake
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.13.1+build.370-1.16
fabric_version=0.53.0+1.18.2

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists

View File

@ -25,7 +25,7 @@ public class ModQuakeMovement implements ModInitializer
PlayerEntity player = mc.player;
double deltaX = player.getX() - player.prevX;
double deltaZ = player.getZ() - player.prevZ;
double speed = MathHelper.sqrt(deltaX * deltaX + deltaZ * deltaZ);
double speed = MathHelper.sqrt((float)(deltaX * deltaX + deltaZ * deltaZ));
String speedString = String.format("%.02f", speed);
mc.textRenderer.drawWithShadow(matrixStack, speedString, 10, mc.getWindow().getScaledHeight() - mc.textRenderer.fontHeight - 10, 0xFFDDDDDD);
}

View File

@ -1,6 +1,5 @@
package squeek.quakemovement;
import com.sun.istack.internal.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
@ -15,6 +14,7 @@ import net.minecraft.particle.BlockStateParticleEffect;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.tag.FluidTags;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagKey;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.MathHelper;
@ -43,7 +43,7 @@ public class QuakeClientPlayer
double d1 = player.getY();
double d2 = player.getZ();
if ((player.abilities.flying || player.isFallFlying()) && !player.hasVehicle())
if ((player.getAbilities().flying || player.isFallFlying()) && !player.hasVehicle())
return false;
else
didQuakeMovement = quake_travel(player, movementInput);
@ -76,7 +76,7 @@ public class QuakeClientPlayer
public static boolean isInWater(PlayerEntity player) {
FluidState fluidState = player.world.getFluidState(player.getBlockPos());
return player.isTouchingWater() && player.method_29920() && !player.canWalkOnFluid(fluidState.getFluid());
return player.isTouchingWater() && player.shouldSwimInFluids() && !player.canWalkOnFluid(fluidState);
}
public static boolean updateVelocityPlayer(PlayerEntity player, Vec3d movementInput, float movementSpeed)
@ -87,7 +87,7 @@ public class QuakeClientPlayer
if (!ModConfig.ENABLED)
return false;
if ((player.abilities.flying && !player.hasVehicle()) || isInWater(player) || player.isInLava() || !player.abilities.flying)
if ((player.getAbilities().flying && !player.hasVehicle()) || isInWater(player) || player.isInLava() || !player.getAbilities().flying)
{
return false;
}
@ -113,7 +113,7 @@ public class QuakeClientPlayer
// undo this dumb thing
if (player.isSprinting())
{
float f = player.yaw * 0.017453292F;
float f = player.getYaw() * 0.017453292F;
Vec3d deltaVelocity = new Vec3d(MathHelper.sin(f) * 0.2F, 0, -(MathHelper.cos(f) * 0.2F));
player.setVelocity(player.getVelocity().add(deltaVelocity));
}
@ -129,7 +129,7 @@ public class QuakeClientPlayer
private static double getSpeed(PlayerEntity player)
{
Vec3d velocity = player.getVelocity();
return MathHelper.sqrt(velocity.x * velocity.x + velocity.z * velocity.z);
return MathHelper.sqrt((float) (velocity.x * velocity.x + velocity.z * velocity.z));
}
/// Assumes the player is on the ground
@ -178,7 +178,7 @@ public class QuakeClientPlayer
if (f3 >= 1.0E-4F)
{
f3 = MathHelper.sqrt(f3);
f3 = MathHelper.sqrt((float) f3);
if (f3 < 1.0F)
{
@ -188,8 +188,8 @@ public class QuakeClientPlayer
f3 = 1.0F / f3;
sidemove *= f3;
forwardmove *= f3;
double f4 = MathHelper.sin(player.yaw * (float) Math.PI / 180.0F);
double f5 = MathHelper.cos(player.yaw * (float) Math.PI / 180.0F);
double f4 = MathHelper.sin(player.getYaw() * (float) Math.PI / 180.0F);
double f5 = MathHelper.cos(player.getYaw() * (float) Math.PI / 180.0F);
dir[0] = (sidemove * f5 - forwardmove * f4);
dir[1] = (forwardmove * f5 + sidemove * f4);
}
@ -287,7 +287,7 @@ public class QuakeClientPlayer
private static void minecraft_SwingLimbsBasedOnMovement(PlayerEntity player)
{
// this got extracted out in the Minecraft code, so just use that
player.method_29242(player, false);
player.updateLimbs(player, false);
}
private static void minecraft_WaterMove(PlayerEntity player, Vec3d movementInput)
@ -361,7 +361,7 @@ public class QuakeClientPlayer
return false;
}
// take care of lava movement using default code
else if ((player.isInLava() && !player.abilities.flying))
else if ((player.isInLava() && !player.getAbilities().flying))
{
return false;
}
@ -446,7 +446,7 @@ public class QuakeClientPlayer
}
// copied from WorldView.containsFluid but with the ability to specify the fluid
static private boolean containsFluid(WorldView world, Box box, Tag<Fluid> tag) {
static private boolean containsFluid(WorldView world, Box box, TagKey<Fluid> tag) {
int i = MathHelper.floor(box.minX);
int j = MathHelper.ceil(box.maxX);
int k = MathHelper.floor(box.minY);

View File

@ -1,5 +1,6 @@
package squeek.quakemovement.mixin;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Mixin;
@ -14,7 +15,7 @@ import squeek.quakemovement.QuakeServerPlayer;
@Mixin(PlayerEntity.class)
public abstract class PlayerEntityMixin
{
@Inject(at = @At("HEAD"), method = "travel(Lnet/minecraft/util/math/Vec3d;)V", cancellable = true)
@Inject(at = @At("HEAD"), method = "travel", cancellable = true)
private void travel(Vec3d movementInput, CallbackInfo info)
{
if (!ModConfig.ENABLED)
@ -37,13 +38,13 @@ public abstract class PlayerEntityMixin
}
@Inject(at = @At("HEAD"), method = "handleFallDamage")
private void beforeFall(float fallDistance, float damageMultiplier, CallbackInfoReturnable<Boolean> info)
private void beforeFall(float fallDistance, float damageMultiplier, DamageSource damageSource, CallbackInfoReturnable<Boolean> cir)
{
QuakeServerPlayer.beforeFall((PlayerEntity) (Object) this, fallDistance, damageMultiplier);
}
@Inject(at = @At("TAIL"), method = "handleFallDamage")
private void afterFall(float fallDistance, float damageMultiplier, CallbackInfoReturnable<Boolean> info)
private void afterFall(float fallDistance, float damageMultiplier, DamageSource damageSource, CallbackInfoReturnable<Boolean> cir)
{
QuakeServerPlayer.afterFall((PlayerEntity) (Object) this, fallDistance, damageMultiplier);
}

View File

@ -3,7 +3,7 @@ pluginManagement {
jcenter()
maven {
name = 'Fabric'
url = 'http://maven.fabricmc.net/'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}