From 96bf9a52de90295ed92cef82037aeff1ab32cd84 Mon Sep 17 00:00:00 2001 From: samo_lego <34912839+samolego@users.noreply.github.com> Date: Fri, 29 May 2020 23:00:50 +0200 Subject: [PATCH] 20w22a. More dimension/world mess --- gradle.properties | 6 ++--- .../org/samo_lego/simpleauth/SimpleAuth.java | 4 ++-- .../simpleauth/commands/AuthCommand.java | 22 +++++++++---------- .../simpleauth/storage/PlayerCache.java | 9 +++----- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/gradle.properties b/gradle.properties index 40f047b..e966a32 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,12 +2,12 @@ org.gradle.jvmargs=-Xmx1G # Fabric properties -minecraft_version=20w21a -yarn_mappings=20w21a+build.19 +minecraft_version=20w22a +yarn_mappings=20w22a+build.1 loader_version=0.8.4+build.198 #Fabric api -fabric_version=0.10.10+build.347-1.16 +fabric_version=0.11.0+build.349-1.16 # Mod Properties mod_version = 1.4.3 diff --git a/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java b/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java index 231a0a0..86079c1 100644 --- a/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java +++ b/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java @@ -222,7 +222,7 @@ public class SimpleAuth implements DedicatedServerModInitializer { if (toSpawn) { // Teleports player to spawn player.teleport( - server.getWorld(RegistryKey.of(Registry.DIMENSION_TYPE_KEY, new Identifier(config.worldSpawn.dimension))), + server.getWorld(RegistryKey.of(Registry.DIMENSION, new Identifier(config.worldSpawn.dimension))), config.worldSpawn.x, config.worldSpawn.y, config.worldSpawn.z, @@ -234,7 +234,7 @@ public class SimpleAuth implements DedicatedServerModInitializer { PlayerCache cache = deauthenticatedUsers.get(convertUuid(player)); // Puts player to last cached position player.teleport( - server.getWorld(RegistryKey.of(Registry.DIMENSION_TYPE_KEY, new Identifier(cache.lastDim))), + server.getWorld(RegistryKey.of(Registry.DIMENSION, new Identifier(cache.lastDim))), cache.lastX, cache.lastY, cache.lastZ, diff --git a/src/main/java/org/samo_lego/simpleauth/commands/AuthCommand.java b/src/main/java/org/samo_lego/simpleauth/commands/AuthCommand.java index 011a06e..07246c0 100644 --- a/src/main/java/org/samo_lego/simpleauth/commands/AuthCommand.java +++ b/src/main/java/org/samo_lego/simpleauth/commands/AuthCommand.java @@ -8,9 +8,9 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.LiteralText; -import net.minecraft.util.registry.Registry; +import net.minecraft.util.Identifier; import net.minecraft.util.registry.RegistryKey; -import net.minecraft.world.dimension.DimensionType; +import net.minecraft.world.World; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.samo_lego.simpleauth.SimpleAuth; @@ -19,7 +19,6 @@ import org.samo_lego.simpleauth.storage.PlayerCache; import org.samo_lego.simpleauth.utils.AuthHelper; import java.io.File; -import java.util.Objects; import static com.mojang.brigadier.arguments.StringArgumentType.getString; import static com.mojang.brigadier.arguments.StringArgumentType.word; @@ -49,7 +48,7 @@ public class AuthCommand { .then(literal("setSpawn") .executes( ctx -> setSpawn( ctx.getSource(), - ctx.getSource().getWorld().getDimension(), + new Identifier(String.valueOf(ctx.getSource().getWorld().getDimension())), ctx.getSource().getEntityOrThrow().getX(), ctx.getSource().getEntityOrThrow().getY(), ctx.getSource().getEntityOrThrow().getZ() @@ -57,11 +56,12 @@ public class AuthCommand { .then(argument("dimension", DimensionArgumentType.dimension()) .then(argument("position", BlockPosArgumentType.blockPos()) .executes(ctx -> { - RegistryKey registryKey = DimensionArgumentType.getDimensionArgument(ctx, "dimension"); - Registry registry = ctx.getSource().getWorld().getServer().method_29174().getRegistry(); + RegistryKey worldRegistryKey = DimensionArgumentType.getDimensionArgument(ctx, "dimension"); + //Registry registry = ctx.getSource().getWorld().getServer().method_29174().getRegistry(); return setSpawn( ctx.getSource(), - Objects.requireNonNull(registry.get(registryKey)), + //Objects.requireNonNull(registry.get(dimension.getValue())), + worldRegistryKey.getValue(), //(ctx, "dimension id"), BlockPosArgumentType.getLoadedBlockPos(ctx, "position").getX(), // +1 to not spawn player in ground @@ -135,12 +135,12 @@ public class AuthCommand { } // - private static int setSpawn(ServerCommandSource source, DimensionType dimension, double x, double y, double z) { - // Getting dimension regitry - Registry registry = source.getWorld().getServer().method_29174().getRegistry(); + private static int setSpawn(ServerCommandSource source, Identifier world, double x, double y, double z) { + // Getting dimension registry + //Registry registry = source.getWorld().getServer().method_29435(); // Setting config values and saving - config.worldSpawn.dimension = String.valueOf(registry.getId(dimension)); + config.worldSpawn.dimension = String.valueOf(world); config.worldSpawn.x = x; config.worldSpawn.y = y; config.worldSpawn.z = z; diff --git a/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java b/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java index 00eaa7f..7e1e361 100644 --- a/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java +++ b/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java @@ -5,10 +5,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.dimension.DimensionType; - -import java.util.Objects; +import net.minecraft.util.Identifier; import static org.samo_lego.simpleauth.SimpleAuth.config; import static org.samo_lego.simpleauth.SimpleAuth.db; @@ -38,10 +35,10 @@ public class PlayerCache { this.lastIp = player.getIp(); // Getting dimension registry - Registry registry = Objects.requireNonNull(player.getServer()).method_29174().getRegistry(); + //Registry registry = Objects.requireNonNull(player.getServer()).method_29435().getRegistry(); // Setting position cache - this.lastDim = String.valueOf(registry.getId(player.getEntityWorld().getDimension())); + this.lastDim = String.valueOf(new Identifier(String.valueOf(player.getEntityWorld().getDimension()))); this.lastX = player.getX(); this.lastY = player.getY(); this.lastZ = player.getZ();