Search in sources :

Example 1 with ChunkHolder

use of net.minecraft.world.server.ChunkHolder in project Arclight by IzzelAliz.

the class ServerChunkProviderMixin method func_217233_c.

/**
 * @author IzzelAliz
 * @reason
 */
@Overwrite
private CompletableFuture<Either<IChunk, ChunkHolder.IChunkLoadingError>> func_217233_c(int chunkX, int chunkZ, ChunkStatus requiredStatus, boolean load) {
    ChunkPos chunkpos = new ChunkPos(chunkX, chunkZ);
    long i = chunkpos.asLong();
    int j = 33 + ChunkStatus.getDistance(requiredStatus);
    ChunkHolder chunkholder = this.func_217213_a(i);
    boolean unloading = false;
    if (chunkholder != null) {
        ChunkHolder.LocationType chunkStatus = ChunkHolder.getLocationTypeFromLevel(((ChunkHolderBridge) chunkholder).bridge$getOldTicketLevel());
        ChunkHolder.LocationType currentStatus = ChunkHolder.getLocationTypeFromLevel(chunkholder.getChunkLevel());
        unloading = chunkStatus.isAtLeast(ChunkHolder.LocationType.BORDER) && !currentStatus.isAtLeast(ChunkHolder.LocationType.BORDER);
    }
    if (load && !unloading) {
        this.ticketManager.registerWithLevel(TicketType.UNKNOWN, chunkpos, j, chunkpos);
        if (this.func_217224_a(chunkholder, j)) {
            IProfiler iprofiler = this.world.getProfiler();
            iprofiler.startSection("chunkLoad");
            this.func_217235_l();
            chunkholder = this.func_217213_a(i);
            iprofiler.endSection();
            if (this.func_217224_a(chunkholder, j)) {
                throw new IllegalStateException("No chunk holder after ticket has been added");
            }
        }
    }
    return this.func_217224_a(chunkholder, j) ? ChunkHolder.MISSING_CHUNK_FUTURE : chunkholder.func_219276_a(requiredStatus, this.chunkManager);
}
Also used : IProfiler(net.minecraft.profiler.IProfiler) ChunkHolder(net.minecraft.world.server.ChunkHolder) ChunkPos(net.minecraft.util.math.ChunkPos) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 2 with ChunkHolder

use of net.minecraft.world.server.ChunkHolder in project dynmap by webbukkit.

the class DynmapExpCommand method registerEvents.

private void registerEvents() {
    // To trigger rendering.
    onblockchange = core.isTrigger("blockupdate");
    onchunkpopulate = core.isTrigger("chunkpopulate");
    onchunkgenerate = core.isTrigger("chunkgenerate");
    onblockchange_with_id = core.isTrigger("blockupdate-with-id");
    if (onblockchange_with_id)
        onblockchange = true;
    if ((worldTracker == null) && (onblockchange || onchunkpopulate || onchunkgenerate)) {
        worldTracker = new WorldTracker();
        MinecraftForge.EVENT_BUS.register(worldTracker);
    }
    // Prime the known full chunks
    if (onchunkgenerate && (server.getWorlds() != null)) {
        for (ServerWorld world : server.getWorlds()) {
            ForgeWorld fw = getWorld(world);
            if (fw == null)
                continue;
            Long2ObjectLinkedOpenHashMap<ChunkHolder> chunks = world.getChunkProvider().chunkManager.immutableLoadedChunks;
            for (Entry<Long, ChunkHolder> k : chunks.long2ObjectEntrySet()) {
                long key = k.getKey().longValue();
                ChunkHolder ch = k.getValue();
                IChunk c = null;
                try {
                    c = ch.func_219302_f().getNow(null);
                } catch (Exception x) {
                }
                if (c == null)
                    continue;
                ChunkStatus cs = c.getStatus();
                ChunkPos pos = ch.getPosition();
                if (cs == ChunkStatus.FULL) {
                    // Cooked?
                    // Add it as known
                    addKnownChunk(fw, pos);
                }
            }
        }
    }
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) ChunkHolder(net.minecraft.world.server.ChunkHolder) IChunk(net.minecraft.world.chunk.IChunk) ChunkStatus(net.minecraft.world.chunk.ChunkStatus) ChunkPos(net.minecraft.util.math.ChunkPos) CommandException(net.minecraft.command.CommandException) CancellationException(java.util.concurrent.CancellationException) ExecutionException(java.util.concurrent.ExecutionException) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) JsonParseException(com.google.gson.JsonParseException)

Example 3 with ChunkHolder

use of net.minecraft.world.server.ChunkHolder in project dynmap by webbukkit.

the class DynmapExpCommand method registerEvents.

private void registerEvents() {
    // To trigger rendering.
    onblockchange = core.isTrigger("blockupdate");
    onchunkpopulate = core.isTrigger("chunkpopulate");
    onchunkgenerate = core.isTrigger("chunkgenerate");
    onblockchange_with_id = core.isTrigger("blockupdate-with-id");
    if (onblockchange_with_id)
        onblockchange = true;
    if ((worldTracker == null) && (onblockchange || onchunkpopulate || onchunkgenerate)) {
        worldTracker = new WorldTracker();
        MinecraftForge.EVENT_BUS.register(worldTracker);
    }
    // Prime the known full chunks
    if (onchunkgenerate && (server.getWorlds() != null)) {
        for (ServerWorld world : server.getWorlds()) {
            ForgeWorld fw = getWorld(world);
            if (fw == null)
                continue;
            Long2ObjectLinkedOpenHashMap<ChunkHolder> chunks = world.getChunkProvider().chunkManager.field_219252_f.clone();
            for (Entry<Long, ChunkHolder> k : chunks.long2ObjectEntrySet()) {
                long key = k.getKey().longValue();
                ChunkHolder ch = k.getValue();
                IChunk c = null;
                try {
                    c = ch.func_219302_f().getNow(null);
                } catch (Exception x) {
                }
                if (c == null)
                    continue;
                ChunkStatus cs = c.getStatus();
                ChunkPos pos = ch.getPosition();
                if (cs == ChunkStatus.FULL) {
                    // Cooked?
                    // Add it as known
                    addKnownChunk(fw, pos);
                }
            }
        }
    }
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) ChunkHolder(net.minecraft.world.server.ChunkHolder) IChunk(net.minecraft.world.chunk.IChunk) ChunkStatus(net.minecraft.world.chunk.ChunkStatus) ChunkPos(net.minecraft.util.math.ChunkPos) CommandException(net.minecraft.command.CommandException) CancellationException(java.util.concurrent.CancellationException) ExecutionException(java.util.concurrent.ExecutionException) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) JsonParseException(com.google.gson.JsonParseException)

Example 4 with ChunkHolder

use of net.minecraft.world.server.ChunkHolder in project dynmap by webbukkit.

the class DynmapExpCommand method registerEvents.

private void registerEvents() {
    // To trigger rendering.
    onblockchange = core.isTrigger("blockupdate");
    onchunkpopulate = core.isTrigger("chunkpopulate");
    onchunkgenerate = core.isTrigger("chunkgenerate");
    onblockchange_with_id = core.isTrigger("blockupdate-with-id");
    if (onblockchange_with_id)
        onblockchange = true;
    if ((worldTracker == null) && (onblockchange || onchunkpopulate || onchunkgenerate)) {
        worldTracker = new WorldTracker();
        MinecraftForge.EVENT_BUS.register(worldTracker);
    }
    // Prime the known full chunks
    if (onchunkgenerate && (server.getWorlds() != null)) {
        for (ServerWorld world : server.getWorlds()) {
            ForgeWorld fw = getWorld(world);
            if (fw == null)
                continue;
            Long2ObjectLinkedOpenHashMap<ChunkHolder> chunks = world.getChunkProvider().chunkManager.immutableLoadedChunks;
            for (Entry<Long, ChunkHolder> k : chunks.long2ObjectEntrySet()) {
                long key = k.getKey().longValue();
                ChunkHolder ch = k.getValue();
                IChunk c = null;
                try {
                    c = ch.func_219302_f().getNow(null);
                } catch (Exception x) {
                }
                if (c == null)
                    continue;
                ChunkStatus cs = c.getStatus();
                ChunkPos pos = ch.getPosition();
                if (cs == ChunkStatus.FULL) {
                    // Cooked?
                    // Add it as known
                    addKnownChunk(fw, pos);
                }
            }
        }
    }
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) IServerWorld(net.minecraft.world.IServerWorld) ChunkHolder(net.minecraft.world.server.ChunkHolder) IChunk(net.minecraft.world.chunk.IChunk) ChunkStatus(net.minecraft.world.chunk.ChunkStatus) ChunkPos(net.minecraft.util.math.ChunkPos) CommandException(net.minecraft.command.CommandException) CancellationException(java.util.concurrent.CancellationException) ExecutionException(java.util.concurrent.ExecutionException) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) JsonParseException(com.google.gson.JsonParseException)

Aggregations

ChunkPos (net.minecraft.util.math.ChunkPos)4 ChunkHolder (net.minecraft.world.server.ChunkHolder)4 JsonParseException (com.google.gson.JsonParseException)3 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)3 CancellationException (java.util.concurrent.CancellationException)3 ExecutionException (java.util.concurrent.ExecutionException)3 CommandException (net.minecraft.command.CommandException)3 ChunkStatus (net.minecraft.world.chunk.ChunkStatus)3 IChunk (net.minecraft.world.chunk.IChunk)3 ServerWorld (net.minecraft.world.server.ServerWorld)3 IProfiler (net.minecraft.profiler.IProfiler)1 IServerWorld (net.minecraft.world.IServerWorld)1 Overwrite (org.spongepowered.asm.mixin.Overwrite)1