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 org.gradle.jvmargs=-Xmx1G
# Fabric properties # Fabric properties
minecraft_version=20w21a minecraft_version=20w22a
yarn_mappings=20w21a+build.19 yarn_mappings=20w22a+build.1
loader_version=0.8.4+build.198 loader_version=0.8.4+build.198
#Fabric api #Fabric api
fabric_version=0.10.10+build.347-1.16 fabric_version=0.11.0+build.349-1.16
# Mod Properties # Mod Properties
mod_version = 1.4.3 mod_version = 1.4.3

View File

@ -222,7 +222,7 @@ public class SimpleAuth implements DedicatedServerModInitializer {
if (toSpawn) { if (toSpawn) {
// Teleports player to spawn // Teleports player to spawn
player.teleport( 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.x,
config.worldSpawn.y, config.worldSpawn.y,
config.worldSpawn.z, config.worldSpawn.z,
@ -234,7 +234,7 @@ public class SimpleAuth implements DedicatedServerModInitializer {
PlayerCache cache = deauthenticatedUsers.get(convertUuid(player)); PlayerCache cache = deauthenticatedUsers.get(convertUuid(player));
// Puts player to last cached position // Puts player to last cached position
player.teleport( 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.lastX,
cache.lastY, cache.lastY,
cache.lastZ, cache.lastZ,

View File

@ -8,9 +8,9 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText; 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.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.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.samo_lego.simpleauth.SimpleAuth; 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 org.samo_lego.simpleauth.utils.AuthHelper;
import java.io.File; import java.io.File;
import java.util.Objects;
import static com.mojang.brigadier.arguments.StringArgumentType.getString; import static com.mojang.brigadier.arguments.StringArgumentType.getString;
import static com.mojang.brigadier.arguments.StringArgumentType.word; import static com.mojang.brigadier.arguments.StringArgumentType.word;
@ -49,7 +48,7 @@ public class AuthCommand {
.then(literal("setSpawn") .then(literal("setSpawn")
.executes( ctx -> setSpawn( .executes( ctx -> setSpawn(
ctx.getSource(), ctx.getSource(),
ctx.getSource().getWorld().getDimension(), new Identifier(String.valueOf(ctx.getSource().getWorld().getDimension())),
ctx.getSource().getEntityOrThrow().getX(), ctx.getSource().getEntityOrThrow().getX(),
ctx.getSource().getEntityOrThrow().getY(), ctx.getSource().getEntityOrThrow().getY(),
ctx.getSource().getEntityOrThrow().getZ() ctx.getSource().getEntityOrThrow().getZ()
@ -57,11 +56,12 @@ public class AuthCommand {
.then(argument("dimension", DimensionArgumentType.dimension()) .then(argument("dimension", DimensionArgumentType.dimension())
.then(argument("position", BlockPosArgumentType.blockPos()) .then(argument("position", BlockPosArgumentType.blockPos())
.executes(ctx -> { .executes(ctx -> {
RegistryKey<DimensionType> registryKey = DimensionArgumentType.getDimensionArgument(ctx, "dimension"); RegistryKey<World> worldRegistryKey = DimensionArgumentType.getDimensionArgument(ctx, "dimension");
Registry<DimensionType> registry = ctx.getSource().getWorld().getServer().method_29174().getRegistry(); //Registry<DimensionType> registry = ctx.getSource().getWorld().getServer().method_29174().getRegistry();
return setSpawn( return setSpawn(
ctx.getSource(), ctx.getSource(),
Objects.requireNonNull(registry.get(registryKey)), //Objects.requireNonNull(registry.get(dimension.getValue())),
worldRegistryKey.getValue(),
//(ctx, "dimension id"), //(ctx, "dimension id"),
BlockPosArgumentType.getLoadedBlockPos(ctx, "position").getX(), BlockPosArgumentType.getLoadedBlockPos(ctx, "position").getX(),
// +1 to not spawn player in ground // +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) { private static int setSpawn(ServerCommandSource source, Identifier world, double x, double y, double z) {
// Getting dimension regitry // Getting dimension registry
Registry<DimensionType> registry = source.getWorld().getServer().method_29174().getRegistry(); //Registry<DimensionType> registry = source.getWorld().getServer().method_29435();
// Setting config values and saving // 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.x = x;
config.worldSpawn.y = y; config.worldSpawn.y = y;
config.worldSpawn.z = z; config.worldSpawn.z = z;

View File

@ -5,10 +5,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.registry.Registry; import net.minecraft.util.Identifier;
import net.minecraft.world.dimension.DimensionType;
import java.util.Objects;
import static org.samo_lego.simpleauth.SimpleAuth.config; import static org.samo_lego.simpleauth.SimpleAuth.config;
import static org.samo_lego.simpleauth.SimpleAuth.db; import static org.samo_lego.simpleauth.SimpleAuth.db;
@ -38,10 +35,10 @@ public class PlayerCache {
this.lastIp = player.getIp(); this.lastIp = player.getIp();
// Getting dimension registry // 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 // 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.lastX = player.getX();
this.lastY = player.getY(); this.lastY = player.getY();
this.lastZ = player.getZ(); this.lastZ = player.getZ();