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

View File

@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/use # check these on https://fabricmc.net/use
minecraft_version=1.16.1 minecraft_version=1.18.2
yarn_mappings=1.16.1+build.1 yarn_mappings=1.18.2+build.3
loader_version=0.8.8+build.202 loader_version=0.14.6
# Mod Properties # Mod Properties
maven_group = squeek.quakemovement maven_group = squeek.quakemovement
@ -13,4 +13,4 @@ archives_base_name = squake
# Dependencies # Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api # 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 distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 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; PlayerEntity player = mc.player;
double deltaX = player.getX() - player.prevX; double deltaX = player.getX() - player.prevX;
double deltaZ = player.getZ() - player.prevZ; 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); String speedString = String.format("%.02f", speed);
mc.textRenderer.drawWithShadow(matrixStack, speedString, 10, mc.getWindow().getScaledHeight() - mc.textRenderer.fontHeight - 10, 0xFFDDDDDD); mc.textRenderer.drawWithShadow(matrixStack, speedString, 10, mc.getWindow().getScaledHeight() - mc.textRenderer.fontHeight - 10, 0xFFDDDDDD);
} }

View File

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

View File

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

View File

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