Search in sources :

Example 1 with DimensionManager

use of net.minecraft.world.level.dimension.DimensionManager in project TerraPlusMinus by Build-the-Earth-Germany.

the class NMSInjector method attemptInject.

public void attemptInject(World world) {
    CraftWorld cw = (CraftWorld) world;
    WorldServer ws = cw.getHandle();
    // getDimensionManager
    DimensionManager delegate = ws.q_();
    DimensionManager replacement = DimensionManager.a((OptionalLong) queryDimensionManagerPrivateField("w", delegate), (boolean) queryDimensionManagerPrivateField("x", delegate), (boolean) queryDimensionManagerPrivateField("y", delegate), (boolean) queryDimensionManagerPrivateField("z", delegate), (boolean) queryDimensionManagerPrivateField("A", delegate), (double) queryDimensionManagerPrivateField("B", delegate), (boolean) queryDimensionManagerPrivateField("C", delegate), (boolean) queryDimensionManagerPrivateField("D", delegate), (boolean) queryDimensionManagerPrivateField("E", delegate), (boolean) queryDimensionManagerPrivateField("F", delegate), (boolean) queryDimensionManagerPrivateField("G", delegate), // minY
    Terraplusminus.config.getInt("min-height"), // Height
    Terraplusminus.config.getInt("max-height"), // Logical Height
    Terraplusminus.config.getInt("max-height"), (MinecraftKey) queryDimensionManagerPrivateField("K", delegate), (MinecraftKey) queryDimensionManagerPrivateField("L", delegate), (float) queryDimensionManagerPrivateField("M", delegate));
    try {
        Terraplusminus.privateFieldHandler.injectField(ws, net.minecraft.world.level.World.class.getDeclaredField("C"), replacement);
        System.out.println("&aSuccessfully injected custom world height!");
        System.out.println("&aNew Heights (WorldServer, Bukkit World):");
        System.out.println("- minY " + ws.q_().k() + "   " + world.getMinHeight());
        System.out.println("- Height " + ws.q_().l() + "   " + world.getMaxHeight());
        System.out.println("- LogicalHeight " + ws.q_().m() + "   " + world.getLogicalHeight());
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
Also used : WorldServer(net.minecraft.server.level.WorldServer) DimensionManager(net.minecraft.world.level.dimension.DimensionManager) World(org.bukkit.World) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Aggregations

WorldServer (net.minecraft.server.level.WorldServer)1 DimensionManager (net.minecraft.world.level.dimension.DimensionManager)1 World (org.bukkit.World)1 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)1