Search in sources :

Example 6 with ChunkManager

use of net.minecraft.world.chunk.ChunkManager in project FastAsyncWorldEdit by IntellectualSites.

the class FabricWorld method regenerate.

@Override
public boolean regenerate(Region region, EditSession editSession) {
    // Don't even try to regen if it's going to fail.
    ChunkManager provider = getWorld().getChunkManager();
    if (!(provider instanceof ServerChunkManager)) {
        return false;
    }
    File saveFolder = Files.createTempDir();
    // register this just in case something goes wrong
    // normally it should be deleted at the end of this method
    saveFolder.deleteOnExit();
    try {
        ServerWorld originalWorld = (ServerWorld) getWorld();
        MinecraftServer server = originalWorld.getServer();
        WorldSaveHandler saveHandler = new WorldSaveHandler(saveFolder, originalWorld.getSaveHandler().getWorldDir().getName(), server, server.getDataFixer());
        World freshWorld = new ServerWorld(server, server.getWorkerExecutor(), saveHandler, originalWorld.getLevelProperties(), originalWorld.dimension.getType(), originalWorld.getProfiler(), new NoOpChunkStatusListener());
        // Pre-gen all the chunks
        // We need to also pull one more chunk in every direction
        CuboidRegion expandedPreGen = new CuboidRegion(region.getMinimumPoint().subtract(16, 0, 16), region.getMaximumPoint().add(16, 0, 16));
        for (BlockVector2 chunk : expandedPreGen.getChunks()) {
            freshWorld.getChunk(chunk.getBlockX(), chunk.getBlockZ());
        }
        FabricWorld from = new FabricWorld(freshWorld);
        for (BlockVector3 vec : region) {
            editSession.setBlock(vec, from.getFullBlock(vec));
        }
    } catch (MaxChangedBlocksException e) {
        throw new RuntimeException(e);
    } finally {
        saveFolder.delete();
    }
    return true;
}
Also used : ServerChunkManager(net.minecraft.server.world.ServerChunkManager) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) ServerWorld(net.minecraft.server.world.ServerWorld) AbstractWorld(com.sk89q.worldedit.world.AbstractWorld) World(net.minecraft.world.World) BlockVector3(com.sk89q.worldedit.math.BlockVector3) BlockVector2(com.sk89q.worldedit.math.BlockVector2) MinecraftServer(net.minecraft.server.MinecraftServer) MaxChangedBlocksException(com.sk89q.worldedit.MaxChangedBlocksException) ServerWorld(net.minecraft.server.world.ServerWorld) File(java.io.File) ServerChunkManager(net.minecraft.server.world.ServerChunkManager) ChunkManager(net.minecraft.world.chunk.ChunkManager) WorldSaveHandler(net.minecraft.world.WorldSaveHandler)

Example 7 with ChunkManager

use of net.minecraft.world.chunk.ChunkManager in project dynmap by webbukkit.

the class FabricMapChunkCache method setChunks.

public void setChunks(FabricWorld dw, List<DynmapChunk> chunks) {
    this.w = dw.getWorld();
    if (dw.isLoaded()) {
        /* Check if world's provider is ServerChunkManager */
        ChunkManager cp = this.w.getChunkManager();
        if (cp instanceof ServerChunkManager) {
            cps = (ServerChunkManager) cp;
        } else {
            Log.severe("Error: world " + dw.getName() + " has unsupported chunk provider");
        }
    }
    super.setChunks(dw, chunks);
}
Also used : ServerChunkManager(net.minecraft.server.world.ServerChunkManager) ChunkManager(net.minecraft.world.chunk.ChunkManager) ServerChunkManager(net.minecraft.server.world.ServerChunkManager)

Example 8 with ChunkManager

use of net.minecraft.world.chunk.ChunkManager in project dynmap by webbukkit.

the class FabricMapChunkCache method setChunks.

public void setChunks(FabricWorld dw, List<DynmapChunk> chunks) {
    this.w = dw.getWorld();
    if (dw.isLoaded()) {
        /* Check if world's provider is ServerChunkManager */
        ChunkManager cp = this.w.getChunkManager();
        if (cp instanceof ServerChunkManager) {
            cps = (ServerChunkManager) cp;
        } else {
            Log.severe("Error: world " + dw.getName() + " has unsupported chunk provider");
        }
    }
    super.setChunks(dw, chunks);
}
Also used : ServerChunkManager(net.minecraft.server.world.ServerChunkManager) ChunkManager(net.minecraft.world.chunk.ChunkManager) ServerChunkManager(net.minecraft.server.world.ServerChunkManager)

Example 9 with ChunkManager

use of net.minecraft.world.chunk.ChunkManager in project dynmap by webbukkit.

the class FabricMapChunkCache method setChunks.

public void setChunks(FabricWorld dw, List<DynmapChunk> chunks) {
    this.w = dw.getWorld();
    if (dw.isLoaded()) {
        /* Check if world's provider is ServerChunkManager */
        ChunkManager cp = this.w.getChunkManager();
        if (cp instanceof ServerChunkManager) {
            cps = (ServerChunkManager) cp;
        } else {
            Log.severe("Error: world " + dw.getName() + " has unsupported chunk provider");
        }
    }
    super.setChunks(dw, chunks);
}
Also used : ServerChunkManager(net.minecraft.server.world.ServerChunkManager) ChunkManager(net.minecraft.world.chunk.ChunkManager) ServerChunkManager(net.minecraft.server.world.ServerChunkManager)

Example 10 with ChunkManager

use of net.minecraft.world.chunk.ChunkManager in project dynmap by webbukkit.

the class FabricMapChunkCache method setChunks.

public void setChunks(FabricWorld dw, List<DynmapChunk> chunks) {
    this.w = dw.getWorld();
    if (dw.isLoaded()) {
        /* Check if world's provider is ServerChunkManager */
        ChunkManager cp = this.w.getChunkManager();
        if (cp instanceof ServerChunkManager) {
            cps = (ServerChunkManager) cp;
        } else {
            Log.severe("Error: world " + dw.getName() + " has unsupported chunk provider");
        }
    }
    super.setChunks(dw, chunks);
}
Also used : ServerChunkManager(net.minecraft.server.world.ServerChunkManager) ChunkManager(net.minecraft.world.chunk.ChunkManager) ServerChunkManager(net.minecraft.server.world.ServerChunkManager)

Aggregations

ChunkManager (net.minecraft.world.chunk.ChunkManager)11 ServerChunkManager (net.minecraft.server.world.ServerChunkManager)7 WorldChunk (net.minecraft.world.chunk.WorldChunk)3 File (java.io.File)2 Entity (net.minecraft.entity.Entity)2 EdenClient (at.haha007.edenclient.EdenClient)1 PlayerTickCallback (at.haha007.edenclient.callbacks.PlayerTickCallback)1 CommandManager (at.haha007.edenclient.command.CommandManager)1 GetTo (at.haha007.edenclient.mods.GetTo)1 ChestShopItemNames (at.haha007.edenclient.mods.datafetcher.ChestShopItemNames)1 DataFetcher (at.haha007.edenclient.mods.datafetcher.DataFetcher)1 ChatColor (at.haha007.edenclient.utils.ChatColor)1 PlayerUtils (at.haha007.edenclient.utils.PlayerUtils)1 PlayerUtils.sendModMessage (at.haha007.edenclient.utils.PlayerUtils.sendModMessage)1 ConfigSubscriber (at.haha007.edenclient.utils.config.ConfigSubscriber)1 PerWorldConfig (at.haha007.edenclient.utils.config.PerWorldConfig)1 RunnableTask (at.haha007.edenclient.utils.tasks.RunnableTask)1 TaskManager (at.haha007.edenclient.utils.tasks.TaskManager)1 WaitForTicksTask (at.haha007.edenclient.utils.tasks.WaitForTicksTask)1 StringArgumentType (com.mojang.brigadier.arguments.StringArgumentType)1