20w22a. More dimension/world mess

This commit is contained in:
samo_lego 2020-05-29 23:00:50 +02:00
parent 7dfe1ff5b3
commit 96bf9a52de
4 changed files with 19 additions and 22 deletions

View File

@ -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

View File

@ -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,

View File

@ -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<DimensionType> registryKey = DimensionArgumentType.getDimensionArgument(ctx, "dimension");
Registry<DimensionType> registry = ctx.getSource().getWorld().getServer().method_29174().getRegistry();
RegistryKey<World> worldRegistryKey = DimensionArgumentType.getDimensionArgument(ctx, "dimension");
//Registry<DimensionType> 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<DimensionType> 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<DimensionType> 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;

View File

@ -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<DimensionType> registry = Objects.requireNonNull(player.getServer()).method_29174().getRegistry();
//Registry<DimensionType> 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();