This commit is contained in:
samo_lego 2020-08-30 21:46:24 +02:00
parent aff0241049
commit f480e93ed2
6 changed files with 49 additions and 34 deletions

View File

@ -58,9 +58,9 @@ dependencies {
// carpetMod // carpetMod
// from masa's maven // from masa's maven
//modImplementation "carpet:fabric-carpet:${project.minecraft_version}-${project.carpet_core_version}" //modImplementation "carpet:fabric-carpet:${project.minecraft_version}-${project.carpet_core_version}"
modImplementation "carpet:fabric-carpet:1.16-${project.carpet_core_version}" //modImplementation "carpet:fabric-carpet:1.16-${project.carpet_core_version}"
// jitpack for quicker updating // jitpack for quicker updating
//modImplementation "com.github.gnembon:fabric-carpet:${project.carpet_branch}-SNAPSHOT" modImplementation "com.github.gnembon:fabric-carpet:${project.carpet_branch}-SNAPSHOT"
} }
processResources { processResources {

View File

@ -21,4 +21,4 @@ bytes_version = 1.3.0
# Carpet for debugging # Carpet for debugging
carpet_core_version = 1.4.0+v200623 carpet_core_version = 1.4.0+v200623
carpet_branch = 1.16 carpet_branch = master

View File

@ -36,6 +36,7 @@ import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import static org.iq80.leveldb.impl.Iq80DBFactory.bytes; import static org.iq80.leveldb.impl.Iq80DBFactory.bytes;
import static org.samo_lego.simpleauth.utils.CarpetHelper.isPlayerCarpetFake; import static org.samo_lego.simpleauth.utils.CarpetHelper.isPlayerCarpetFake;
@ -160,6 +161,20 @@ public class SimpleAuth implements DedicatedServerModInitializer {
logError("Error saving player data! " + e.getMessage()); logError("Error saving player data! " + e.getMessage());
} }
// Closing threads
try {
THREADPOOL.shutdownNow();
TIMER.cancel();
TIMER.purge();
if (!THREADPOOL.awaitTermination(100, TimeUnit.MICROSECONDS)) {
System.out.println("Still waiting...");
Thread.currentThread().interrupt();
}
} catch (InterruptedException e) {
logError(e.getMessage());
THREADPOOL.shutdownNow();
}
// Closing DB connection // Closing DB connection
DB.close(); DB.close();
} }

View File

@ -99,15 +99,15 @@ public class AuthEventHandler {
if(config.main.tryPortalRescue && player.getBlockState().getBlock().equals(Blocks.NETHER_PORTAL)) { if(config.main.tryPortalRescue && player.getBlockState().getBlock().equals(Blocks.NETHER_PORTAL)) {
BlockPos pos = player.getBlockPos(); BlockPos pos = player.getBlockPos();
// Teleporting player to the middle of the block
player.teleport(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
// Faking portal blocks to be air // Faking portal blocks to be air
BlockUpdateS2CPacket feetPacket = new BlockUpdateS2CPacket(pos, Blocks.AIR.getDefaultState()); BlockUpdateS2CPacket feetPacket = new BlockUpdateS2CPacket(pos, Blocks.AIR.getDefaultState());
player.networkHandler.sendPacket(feetPacket); player.networkHandler.sendPacket(feetPacket);
BlockUpdateS2CPacket headPacket = new BlockUpdateS2CPacket(pos.up(), Blocks.AIR.getDefaultState()); BlockUpdateS2CPacket headPacket = new BlockUpdateS2CPacket(pos.up(), Blocks.AIR.getDefaultState());
player.networkHandler.sendPacket(headPacket); player.networkHandler.sendPacket(headPacket);
// Teleporting player to the middle of the block
player.teleport(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
} }
} }

View File

@ -68,10 +68,10 @@ public abstract class MixinServerPlayNetworkHandler {
cancellable = true cancellable = true
) )
private void onPlayerMove(PlayerMoveC2SPacket playerMoveC2SPacket, CallbackInfo ci) { private void onPlayerMove(PlayerMoveC2SPacket playerMoveC2SPacket, CallbackInfo ci) {
ActionResult result = PlayerMoveCallback.EVENT.invoker().onPlayerMove(this.player); ActionResult result = PlayerMoveCallback.EVENT.invoker().onPlayerMove(player);
if (result == ActionResult.FAIL) { if (result == ActionResult.FAIL) {
// A bit ugly, I know. (we need to update player position) // A bit ugly, I know. (we need to update player position)
this.player.requestTeleport(this.player.getX(), this.player.getY(), this.player.getZ()); player.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.yaw, player.pitch);
ci.cancel(); ci.cancel();
} }
} }