Search in sources :

Example 6 with DimensionTypeBridge

use of io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge in project Arclight by IzzelAliz.

the class MinecraftServerMixin method loadSpawn.

public void loadSpawn(IChunkStatusListener listener, ServerWorld serverWorld) {
    if (!((WorldBridge) serverWorld).bridge$getWorld().getKeepSpawnInMemory()) {
        return;
    }
    this.setUserMessage(new TranslationTextComponent("menu.generatingTerrain"));
    this.forceTicks = true;
    LOGGER.info("Preparing start region for dimension '{}'/{}", serverWorld.getWorldInfo().getWorldName(), DimensionType.getKey(((DimensionTypeBridge) serverWorld.dimension.getType()).bridge$getType()));
    BlockPos pos = serverWorld.getSpawnPoint();
    listener.start(new ChunkPos(pos));
    ServerChunkProvider chunkProvider = serverWorld.getChunkProvider();
    chunkProvider.getLightManager().func_215598_a(500);
    this.serverTime = Util.milliTime();
    chunkProvider.registerTicket(TicketType.START, new ChunkPos(pos), 11, Unit.INSTANCE);
    while (chunkProvider.getLoadedChunksCount() != 441) {
        this.executeModerately();
    }
    this.executeModerately();
    DimensionType type = serverWorld.dimension.getType();
    ForcedChunksSaveData chunks = serverWorld.getSavedData().get(ForcedChunksSaveData::new, "chunks");
    if (chunks != null) {
        ServerWorld world = this.getWorld(type);
        LongIterator iterator = chunks.getChunks().iterator();
        while (iterator.hasNext()) {
            long i = iterator.nextLong();
            ChunkPos chunkPos = new ChunkPos(i);
            world.getChunkProvider().forceChunk(chunkPos, true);
        }
    }
    this.executeModerately();
    listener.stop();
    chunkProvider.getLightManager().func_215598_a(5);
    this.forceTicks = false;
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) DimensionType(net.minecraft.world.dimension.DimensionType) WorldBridge(io.izzel.arclight.common.bridge.world.WorldBridge) DimensionTypeBridge(io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge) ForcedChunksSaveData(net.minecraft.world.ForcedChunksSaveData) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BlockPos(net.minecraft.util.math.BlockPos) ChunkPos(net.minecraft.util.math.ChunkPos) LongIterator(it.unimi.dsi.fastutil.longs.LongIterator) ServerChunkProvider(net.minecraft.world.server.ServerChunkProvider)

Aggregations

DimensionTypeBridge (io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge)6 WorldBridge (io.izzel.arclight.common.bridge.world.WorldBridge)4 BlockPos (net.minecraft.util.math.BlockPos)4 DimensionType (net.minecraft.world.dimension.DimensionType)4 ServerWorld (net.minecraft.world.server.ServerWorld)4 SChangeGameStatePacket (net.minecraft.network.play.server.SChangeGameStatePacket)3 SServerDifficultyPacket (net.minecraft.network.play.server.SServerDifficultyPacket)3 Vec3d (net.minecraft.util.math.Vec3d)3 WorldInfo (net.minecraft.world.storage.WorldInfo)3 Location (org.bukkit.Location)3 CraftWorld (org.bukkit.craftbukkit.v.CraftWorld)3 PlayerChangedWorldEvent (org.bukkit.event.player.PlayerChangedWorldEvent)3 ServerPlayerEntityBridge (io.izzel.arclight.common.bridge.entity.player.ServerPlayerEntityBridge)2 ServerPlayNetHandlerBridge (io.izzel.arclight.common.bridge.network.play.ServerPlayNetHandlerBridge)2 ServerWorldBridge (io.izzel.arclight.common.bridge.world.server.ServerWorldBridge)2 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)2 SPlayEntityEffectPacket (net.minecraft.network.play.server.SPlayEntityEffectPacket)2 SSetExperiencePacket (net.minecraft.network.play.server.SSetExperiencePacket)2 SSpawnPositionPacket (net.minecraft.network.play.server.SSpawnPositionPacket)2 SUpdateViewDistancePacket (net.minecraft.network.play.server.SUpdateViewDistancePacket)2