From ab445ae0c64aade89951bb5cb70360e418d976f8 Mon Sep 17 00:00:00 2001 From: NikitaCartes Date: Wed, 23 Jun 2021 20:13:17 +0300 Subject: [PATCH] It's working on 1.17 version but it use 21w10a mapping --- .../org/samo_lego/simpleauth/event/AuthEventHandler.java | 7 ++++--- .../simpleauth/mixin/MixinServerPlayNetworkHandler.java | 2 +- .../simpleauth/mixin/MixinServerPlayerEntity.java | 4 ++-- .../java/org/samo_lego/simpleauth/storage/PlayerCache.java | 7 ++++--- 4 files changed, 11 insertions(+), 9 deletions(-) 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..9832886 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,8 @@ 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.getBlockState().getBlock().equals(Blocks.NETHER_PORTAL)) { + if(config.main.tryPortalRescue && player.getServerWorld().getBlockState(player.getBlockPos()).getBlock().equals(Blocks.NETHER_PORTAL)) { BlockPos pos = player.getBlockPos(); // Teleporting player to the middle of the block @@ -117,8 +118,8 @@ public class AuthEventHandler { if(playerCache.isAuthenticated) { playerCache.lastIp = player.getIp(); - playerCache.wasInPortal = player.getBlockState().getBlock().equals(Blocks.NETHER_PORTAL); - + //playerCache.wasInPortal = player.getBlockState().getBlock().equals(Blocks.NETHER_PORTAL); + playerCache.wasInPortal = player.getServerWorld().getBlockState(player.getBlockPos()).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 5c7ee2a..23bc51d 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 @@ -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.yaw, player.pitch); + player.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.getYaw(0), player.getPitch(0)); 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 ea979cc..267a510 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.yaw; - cache.lastLocation.pitch = player.pitch; + cache.lastLocation.yaw = player.getYaw(0); + cache.lastLocation.pitch = player.getPitch(0); // Teleports player to spawn player.teleport( 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 7986772..35552e8 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 @@ -94,10 +94,11 @@ public class PlayerCache { // Setting position cache playerCache.lastLocation.dimension = player.getServerWorld(); playerCache.lastLocation.position = player.getPos(); - playerCache.lastLocation.yaw = player.yaw; - playerCache.lastLocation.pitch = player.pitch; + playerCache.lastLocation.yaw = player.getYaw(0); + playerCache.lastLocation.pitch = player.getPitch(0); - playerCache.wasInPortal = player.getBlockState().getBlock().equals(Blocks.NETHER_PORTAL); + playerCache.wasInPortal = player.getServerWorld().getBlockState(player.getBlockPos()).getBlock().equals(Blocks.NETHER_PORTAL); + //playerCache.wasInPortal = player.getBlockState().getBlock().equals(Blocks.NETHER_PORTAL); } return playerCache;