feat: updated FlatWorldModule
This commit is contained in:
parent
6f28568a17
commit
fb04fbe692
@ -1,17 +1,16 @@
|
||||
package ru.dragonestia.msb3.api.module;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.GameMode;
|
||||
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
|
||||
import net.minestom.server.instance.Chunk;
|
||||
import net.minestom.server.instance.DynamicChunk;
|
||||
import net.minestom.server.instance.IChunkLoader;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.instance.*;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.world.DimensionType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.dragonestia.msb3.api.world.World;
|
||||
import ru.dragonestia.msb3.api.world.WorldFactory;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@ -19,13 +18,11 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class FlatWorldModule {
|
||||
|
||||
private static boolean used = false;
|
||||
@Getter private static World world;
|
||||
|
||||
private FlatWorldModule() {}
|
||||
|
||||
public static synchronized void init(GameMode gameMode) {
|
||||
if (used) return;
|
||||
used = true;
|
||||
|
||||
public static void init(GameMode gameMode) {
|
||||
var dimension = MinecraftServer.getDimensionTypeRegistry().register("msb3:full_bright", DimensionType.builder()
|
||||
.ambientLight(2f)
|
||||
.build());
|
||||
@ -58,12 +55,19 @@ public class FlatWorldModule {
|
||||
}
|
||||
});
|
||||
|
||||
var world = factory.createWorldSync();
|
||||
init(gameMode, factory.createWorldSync(), new Pos(0, 11, 0));
|
||||
}
|
||||
|
||||
public static synchronized void init(GameMode gameMode, World world, Pos spawnPos) {
|
||||
if (used) return;
|
||||
used = true;
|
||||
|
||||
FlatWorldModule.world = world;
|
||||
|
||||
MinecraftServer.getGlobalEventHandler().addListener(AsyncPlayerConfigurationEvent.class, event -> {
|
||||
var player = event.getPlayer();
|
||||
|
||||
player.setRespawnPoint(new Pos(0, 11, 0));
|
||||
player.setRespawnPoint(spawnPos);
|
||||
player.setGameMode(gameMode);
|
||||
|
||||
event.setSpawningInstance(world.getInstance());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user