Search in sources :

Example 1 with ClientChunkManagerClientChunkMapAccessor

use of org.valkyrienskies.mod.mixin.accessors.client.world.ClientChunkManagerClientChunkMapAccessor in project Valkyrien-Skies-2 by ValkyrienSkies.

the class MixinClientChunkManager method preLoadChunkFromPacket.

@Inject(method = "loadChunkFromPacket", at = @At("HEAD"), cancellable = true)
private void preLoadChunkFromPacket(final int x, final int z, final BiomeArray biomes, final PacketByteBuf buf, final CompoundTag tag, final int verticalStripBitmask, final boolean complete, final CallbackInfoReturnable<WorldChunk> cir) {
    final ClientChunkManagerClientChunkMapAccessor clientChunkMapAccessor = ClientChunkManagerClientChunkMapAccessor.class.cast(chunks);
    if (!clientChunkMapAccessor.callIsInRadius(x, z)) {
        if (ChunkAllocator.isChunkInShipyard(x, z)) {
            final long chunkPosLong = ChunkPos.toLong(x, z);
            final WorldChunk worldChunk = new WorldChunk(this.world, new ChunkPos(x, z), biomes);
            worldChunk.loadFromPacket(biomes, buf, tag, verticalStripBitmask);
            shipChunks.put(chunkPosLong, worldChunk);
            final ChunkSection[] chunkSections = worldChunk.getSectionArray();
            final LightingProvider lightingProvider = this.getLightingProvider();
            lightingProvider.setColumnEnabled(new ChunkPos(x, z), true);
            for (int j = 0; j < chunkSections.length; ++j) {
                final ChunkSection chunkSection = chunkSections[j];
                lightingProvider.setSectionStatus(ChunkSectionPos.from(x, j, z), ChunkSection.isEmpty(chunkSection));
            }
            this.world.resetChunkColor(x, z);
            cir.setReturnValue(worldChunk);
        }
    }
}
Also used : WorldChunk(net.minecraft.world.chunk.WorldChunk) LightingProvider(net.minecraft.world.chunk.light.LightingProvider) ChunkPos(net.minecraft.util.math.ChunkPos) ChunkSection(net.minecraft.world.chunk.ChunkSection) ClientChunkManagerClientChunkMapAccessor(org.valkyrienskies.mod.mixin.accessors.client.world.ClientChunkManagerClientChunkMapAccessor) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

ChunkPos (net.minecraft.util.math.ChunkPos)1 ChunkSection (net.minecraft.world.chunk.ChunkSection)1 WorldChunk (net.minecraft.world.chunk.WorldChunk)1 LightingProvider (net.minecraft.world.chunk.light.LightingProvider)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1 ClientChunkManagerClientChunkMapAccessor (org.valkyrienskies.mod.mixin.accessors.client.world.ClientChunkManagerClientChunkMapAccessor)1