Apply patch by @SirYwell to construct the ResourceKey without consulting the DimensionManager

This commit is contained in:
MeFisto94 2020-08-16 14:02:03 +02:00
parent 48d3c2105d
commit 6c9b73b100

View File

@ -100,12 +100,21 @@ public class OfflinePlayerUtil {
public static Object getWorldServer116() { public static Object getWorldServer116() {
Object server = getMinecraftServer(); Object server = getMinecraftServer();
Class<?> minecraftServerClass = getNmsClass("MinecraftServer"); Class<?> minecraftServerClass = getNmsClass("MinecraftServer");
Class<?> dimensionManager = getNmsClass("DimensionManager");
Class<?> genericResourceKey = getNmsClass("ResourceKey"); Class<?> genericResourceKey = getNmsClass("ResourceKey");
Object overworld = getField(makeField(dimensionManager, "OVERWORLD"), null); Class<?> minecraftKey = getNmsClass("MinecraftKey");
// MinecraftKey + MinecraftKey -> ResourceKey
Method constructResourceKey = makeMethod(genericResourceKey, "a", minecraftKey, minecraftKey);
// MinecraftKey(String)
Constructor<Object> minecraftKeyConstructor = makeConstructor(minecraftKey, String.class);
// minecraft:overworld
Object overworldKey = callConstructor(minecraftKeyConstructor, "overworld");
// minecraft:dimension
Object dimensionKey = callConstructor(minecraftKeyConstructor, "dimension");
// ResourceKey[minecraft:dimension / minecraft:overworld]
Object resourceKey = callMethod(constructResourceKey, null, dimensionKey, overworldKey);
Method getWorldServer = Method getWorldServer =
makeMethod(minecraftServerClass, "getWorldServer", genericResourceKey); makeMethod(minecraftServerClass, "getWorldServer", genericResourceKey);
return callMethod(getWorldServer, server, overworld); return callMethod(getWorldServer, server, resourceKey);
} }
public static Object getWorldServerNew() { public static Object getWorldServerNew() {