diff --git a/build.gradle b/build.gradle index 6975008..bdb0d7e 100644 --- a/build.gradle +++ b/build.gradle @@ -10,8 +10,8 @@ buildscript { plugins { - id "architectury-plugin" version "3.0.94" - id "forgified-fabric-loom" version "0.6.72" apply false + id "architectury-plugin" version "3.1-SNAPSHOT" + id "dev.architectury.loom" version "0.8.0-SNAPSHOT" apply false } @@ -20,7 +20,7 @@ architectury { } subprojects { - apply plugin: "forgified-fabric-loom" + apply plugin: "dev.architectury.loom" dependencies { minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" mappings("net.fabricmc:yarn:${rootProject.yarn_mappings}:v2") @@ -36,16 +36,15 @@ allprojects { version = rootProject.mod_version group = rootProject.maven_group - tasks.withType(JavaCompile) { - options.encoding = "UTF-8" + tasks.withType(JavaCompile).configureEach { + // ensure that the encoding is set to UTF-8, no matter what the system default is + // this fixes some edge cases with special characters not displaying correctly + // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html + // If Javadoc is generated, this must be specified in that task too. + it.options.encoding = "UTF-8" - // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too - // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. - // We'll use that if it's available, but otherwise we'll use the older option. - def targetVersion = 8 - if (JavaVersion.current().isJava9Compatible()) { - options.release = targetVersion - } + // Minecraft 1.17 (21w19a) upwards uses Java 16. + it.options.release = 8 } java { diff --git a/common/src/main/java/org/samo_lego/simpleauth/commands/AuthCommand.java b/common/src/main/java/org/samo_lego/simpleauth/commands/AuthCommand.java index d167495..282e8d8 100644 --- a/common/src/main/java/org/samo_lego/simpleauth/commands/AuthCommand.java +++ b/common/src/main/java/org/samo_lego/simpleauth/commands/AuthCommand.java @@ -49,8 +49,8 @@ public class AuthCommand { ctx.getSource().getEntityOrThrow().getX(), ctx.getSource().getEntityOrThrow().getY(), ctx.getSource().getEntityOrThrow().getZ(), - ctx.getSource().getEntityOrThrow().yaw, - ctx.getSource().getEntityOrThrow().pitch + ctx.getSource().getEntityOrThrow().getYaw(), + ctx.getSource().getEntityOrThrow().getPitch() )) .then(argument("dimension", DimensionArgumentType.dimension()) .then(argument("position", BlockPosArgumentType.blockPos()) diff --git a/common/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java b/common/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java index 77e7b31..8d37620 100644 --- a/common/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java +++ b/common/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java @@ -94,7 +94,7 @@ public class AuthEventHandler { // Tries to rescue player from nether portal - if(config.main.tryPortalRescue && player.getBlockState().getBlock().equals(Blocks.NETHER_PORTAL)) { + if(config.main.tryPortalRescue && player.getBlockStateAtPos().getBlock().equals(Blocks.NETHER_PORTAL)) { BlockPos pos = player.getBlockPos(); // Teleporting player to the middle of the block @@ -117,8 +117,8 @@ public class AuthEventHandler { if(playerCache.isAuthenticated) { playerCache.lastIp = player.getIp(); - playerCache.wasInPortal = player.getBlockState().getBlock().equals(Blocks.NETHER_PORTAL); - + playerCache.wasInPortal = player.getBlockStateAtPos().getBlock().equals(Blocks.NETHER_PORTAL); + // Setting the session expire time if(config.main.sessionTimeoutTime != -1) playerCache.validUntil = System.currentTimeMillis() + config.main.sessionTimeoutTime * 1000L; diff --git a/common/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerPlayNetworkHandler.java b/common/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerPlayNetworkHandler.java index 23bc51d..0038998 100644 --- a/common/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerPlayNetworkHandler.java +++ b/common/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerPlayNetworkHandler.java @@ -22,7 +22,7 @@ public abstract class MixinServerPlayNetworkHandler { public ServerPlayerEntity player; @Inject( - method = "method_31286(Lnet/minecraft/server/filter/TextStream$Message;)V", + method = "handleMessage(Lnet/minecraft/server/filter/TextStream$Message;)V", at = @At( value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;updateLastActionTime()V", @@ -68,7 +68,7 @@ public abstract class MixinServerPlayNetworkHandler { ActionResult result = AuthEventHandler.onPlayerMove(player); if (result == ActionResult.FAIL) { // A bit ugly, I know. (we need to update player position) - player.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.getYaw(0), player.getPitch(0)); + player.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.getYaw(), player.getPitch()); ci.cancel(); } } diff --git a/common/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerPlayerEntity.java b/common/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerPlayerEntity.java index f447dac..f9758a3 100644 --- a/common/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerPlayerEntity.java +++ b/common/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerPlayerEntity.java @@ -52,8 +52,8 @@ public class MixinServerPlayerEntity implements PlayerAuth { // Saving position cache.lastLocation.dimension = player.getServerWorld(); cache.lastLocation.position = player.getPos(); - cache.lastLocation.yaw = player.getYaw(0); - cache.lastLocation.pitch = player.getPitch(0); + cache.lastLocation.yaw = player.getYaw(); + cache.lastLocation.pitch = player.getPitch(); // Teleports player to spawn player.teleport( diff --git a/common/src/main/java/org/samo_lego/simpleauth/mixin/MixinWorldSaveHandler.java b/common/src/main/java/org/samo_lego/simpleauth/mixin/MixinWorldSaveHandler.java index 438e759..677820d 100644 --- a/common/src/main/java/org/samo_lego/simpleauth/mixin/MixinWorldSaveHandler.java +++ b/common/src/main/java/org/samo_lego/simpleauth/mixin/MixinWorldSaveHandler.java @@ -46,7 +46,7 @@ public class MixinWorldSaveHandler { * @param file */ @Inject( - method = "loadPlayerData(Lnet/minecraft/entity/player/PlayerEntity;)Lnet/minecraft/nbt/CompoundTag;", + method = "loadPlayerData(Lnet/minecraft/entity/player/PlayerEntity;)Lnet/minecraft/nbt/NbtCompound;", at = @At( value = "INVOKE", target = "Ljava/io/File;exists()Z" @@ -66,7 +66,7 @@ public class MixinWorldSaveHandler { * @return compoundTag containing migrated data. */ @ModifyVariable( - method = "loadPlayerData(Lnet/minecraft/entity/player/PlayerEntity;)Lnet/minecraft/nbt/CompoundTag;", + method = "loadPlayerData(Lnet/minecraft/entity/player/PlayerEntity;)Lnet/minecraft/nbt/NbtCompound;", at = @At( value = "INVOKE", target = "Ljava/io/File;exists()Z" diff --git a/common/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java b/common/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java index 988d658..5ec747e 100644 --- a/common/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java +++ b/common/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java @@ -95,11 +95,10 @@ public class PlayerCache { // Setting position cache playerCache.lastLocation.dimension = player.getServerWorld(); playerCache.lastLocation.position = player.getPos(); - playerCache.lastLocation.yaw = player.getYaw(0); - playerCache.lastLocation.pitch = player.getPitch(0); + playerCache.lastLocation.yaw = player.getYaw(); + playerCache.lastLocation.pitch = player.getPitch(); - playerCache.wasInPortal = player.getServerWorld().getBlockState(player.getBlockPos()).getBlock().equals(Blocks.NETHER_PORTAL); - //playerCache.wasInPortal = player.getBlockState().getBlock().equals(Blocks.NETHER_PORTAL); + playerCache.wasInPortal = player.getBlockStateAtPos().getBlock().equals(Blocks.NETHER_PORTAL); } return playerCache; diff --git a/common/src/main/resources/mixins.simpleauth.json b/common/src/main/resources/mixins.simpleauth.json index d7e8f40..1e15509 100644 --- a/common/src/main/resources/mixins.simpleauth.json +++ b/common/src/main/resources/mixins.simpleauth.json @@ -1,7 +1,7 @@ { "required": true, "package": "org.samo_lego.simpleauth.mixin", - "compatibilityLevel": "JAVA_8", + "compatibilityLevel": "JAVA_16", "mixins": [ "MixinPlayerAdvancementTracker", "MixinPlayerEntity",