Search in sources :

Example 1 with ForcedChunksSaveData

use of net.minecraft.world.ForcedChunksSaveData 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)

Example 2 with ForcedChunksSaveData

use of net.minecraft.world.ForcedChunksSaveData in project Arclight by IzzelAliz.

the class MinecraftServerMixin method loadInitialChunks.

/**
 * @author IzzelAliz
 * @reason
 */
@Overwrite
public void loadInitialChunks(IChunkStatusListener listener) {
    this.setUserMessage(new TranslationTextComponent("menu.generatingTerrain"));
    ServerWorld serverworld = this.getWorld(DimensionType.OVERWORLD);
    this.forceTicks = true;
    LOGGER.info("Preparing start region for dimension " + DimensionType.getKey(serverworld.dimension.getType()));
    BlockPos blockpos = serverworld.getSpawnPoint();
    listener.start(new ChunkPos(blockpos));
    ServerChunkProvider serverchunkprovider = serverworld.getChunkProvider();
    serverchunkprovider.getLightManager().func_215598_a(500);
    this.serverTime = Util.milliTime();
    serverchunkprovider.registerTicket(TicketType.START, new ChunkPos(blockpos), 11, Unit.INSTANCE);
    while (serverchunkprovider.getLoadedChunksCount() != 441) {
        this.executeModerately();
    }
    this.executeModerately();
    for (DimensionType dimensiontype : DimensionType.getAll()) {
        ServerWorld serverWorld = this.getWorld(dimensiontype);
        if (((WorldBridge) serverWorld).bridge$getWorld().getKeepSpawnInMemory()) {
            ForcedChunksSaveData forcedchunkssavedata = serverWorld.getSavedData().get(ForcedChunksSaveData::new, "chunks");
            if (forcedchunkssavedata != null) {
                LongIterator longiterator = forcedchunkssavedata.getChunks().iterator();
                while (longiterator.hasNext()) {
                    long i = longiterator.nextLong();
                    ChunkPos chunkpos = new ChunkPos(i);
                    serverWorld.getChunkProvider().forceChunk(chunkpos, true);
                }
            }
        }
        Bukkit.getPluginManager().callEvent(new WorldLoadEvent(((WorldBridge) serverWorld).bridge$getWorld()));
    }
    this.executeModerately();
    listener.stop();
    serverchunkprovider.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) ForcedChunksSaveData(net.minecraft.world.ForcedChunksSaveData) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BlockPos(net.minecraft.util.math.BlockPos) ChunkPos(net.minecraft.util.math.ChunkPos) WorldLoadEvent(org.bukkit.event.world.WorldLoadEvent) LongIterator(it.unimi.dsi.fastutil.longs.LongIterator) ServerChunkProvider(net.minecraft.world.server.ServerChunkProvider) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Aggregations

WorldBridge (io.izzel.arclight.common.bridge.world.WorldBridge)2 LongIterator (it.unimi.dsi.fastutil.longs.LongIterator)2 BlockPos (net.minecraft.util.math.BlockPos)2 ChunkPos (net.minecraft.util.math.ChunkPos)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2 ForcedChunksSaveData (net.minecraft.world.ForcedChunksSaveData)2 DimensionType (net.minecraft.world.dimension.DimensionType)2 ServerChunkProvider (net.minecraft.world.server.ServerChunkProvider)2 ServerWorld (net.minecraft.world.server.ServerWorld)2 DimensionTypeBridge (io.izzel.arclight.common.bridge.world.dimension.DimensionTypeBridge)1 WorldLoadEvent (org.bukkit.event.world.WorldLoadEvent)1 Overwrite (org.spongepowered.asm.mixin.Overwrite)1