Search in sources :

Example 11 with SectionLevelArray

use of thpmc.vanilla_source.util.SectionLevelArray in project VanillaSource by TheHollowPlanetMC.

the class PacketManager method createLightUpdatePacketAtPrimaryThread.

@Nullable
public static Object createLightUpdatePacketAtPrimaryThread(ParallelChunk parallelChunk) {
    if (!Bukkit.isPrimaryThread())
        throw new IllegalStateException("DO NOT CALL FROM ASYNC THREAD!");
    org.bukkit.World world = Bukkit.getWorld(parallelChunk.getWorld().getName());
    if (world == null)
        return null;
    boolean has = false;
    for (int sectionIndex = 0; sectionIndex < 16; sectionIndex++) {
        SectionLevelArray blockLevelArray = parallelChunk.getBlockLightSectionLevelArray(sectionIndex);
        SectionLevelArray skyLevelArray = parallelChunk.getSkyLightSectionLevelArray(sectionIndex);
        if (blockLevelArray != null) {
            if (blockLevelArray.getSize() != 0)
                has = true;
        }
        if (skyLevelArray != null) {
            if (skyLevelArray.getSize() != 0)
                has = true;
        }
    }
    if (!has)
        return null;
    return new PacketPlayOutLightUpdate(new ChunkCoordIntPair(parallelChunk.getChunkX(), parallelChunk.getChunkZ()), ((CraftWorld) world).getHandle().getChunkProvider().getLightEngine(), true);
}
Also used : SectionLevelArray(thpmc.vanilla_source.util.SectionLevelArray) Nullable(org.jetbrains.annotations.Nullable)

Example 12 with SectionLevelArray

use of thpmc.vanilla_source.util.SectionLevelArray in project VanillaSource by TheHollowPlanetMC.

the class ImplParallelChunk method getBlockLightLevel.

@Override
public int getBlockLightLevel(int blockX, int blockY, int blockZ) {
    int sectionIndex = ChunkUtil.getSectionIndex(blockY);
    SectionLevelArray sectionLevelArray = blockLightArrays[sectionIndex];
    if (sectionLevelArray == null)
        return 0;
    return sectionLevelArray.getLevel(blockX & 0xF, blockY & 0xF, blockZ & 0xF);
}
Also used : SectionLevelArray(thpmc.vanilla_source.util.SectionLevelArray)

Example 13 with SectionLevelArray

use of thpmc.vanilla_source.util.SectionLevelArray in project VanillaSource by TheHollowPlanetMC.

the class ImplParallelChunk method hasBlockLight.

@Override
public boolean hasBlockLight(int blockX, int blockY, int blockZ) {
    int sectionIndex = ChunkUtil.getSectionIndex(blockY);
    SectionLevelArray sectionLevelArray = blockLightArrays[sectionIndex];
    if (sectionLevelArray == null)
        return false;
    return sectionLevelArray.contains(blockX & 0xF, blockY & 0xF, blockZ & 0xF);
}
Also used : SectionLevelArray(thpmc.vanilla_source.util.SectionLevelArray)

Example 14 with SectionLevelArray

use of thpmc.vanilla_source.util.SectionLevelArray in project VanillaSource by TheHollowPlanetMC.

the class ImplParallelChunk method createSkyLightSectionLevelArrayIfAbsent.

public SectionLevelArray createSkyLightSectionLevelArrayIfAbsent(int sectionY) {
    int sectionIndex = ChunkUtil.getSectionIndex(sectionY << 4);
    SectionLevelArray sectionLevelArray = skyLightArrays[sectionIndex];
    if (sectionLevelArray == null) {
        sectionLevelArray = new SectionLevelArray();
        skyLightArrays[sectionIndex] = sectionLevelArray;
    }
    return sectionLevelArray;
}
Also used : SectionLevelArray(thpmc.vanilla_source.util.SectionLevelArray)

Example 15 with SectionLevelArray

use of thpmc.vanilla_source.util.SectionLevelArray in project VanillaSource by TheHollowPlanetMC.

the class ImplParallelChunk method createBlockLightSectionLevelArrayIfAbsent.

public SectionLevelArray createBlockLightSectionLevelArrayIfAbsent(int sectionY) {
    int sectionIndex = ChunkUtil.getSectionIndex(sectionY << 4);
    SectionLevelArray sectionLevelArray = blockLightArrays[sectionIndex];
    if (sectionLevelArray == null) {
        sectionLevelArray = new SectionLevelArray();
        blockLightArrays[sectionIndex] = sectionLevelArray;
    }
    return sectionLevelArray;
}
Also used : SectionLevelArray(thpmc.vanilla_source.util.SectionLevelArray)

Aggregations

SectionLevelArray (thpmc.vanilla_source.util.SectionLevelArray)15 ParallelChunk (thpmc.vanilla_source.api.world.parallel.ParallelChunk)3 ParallelWorld (thpmc.vanilla_source.api.world.parallel.ParallelWorld)3 World (org.bukkit.World)2 Nullable (org.jetbrains.annotations.Nullable)2 ParallelUniverse (thpmc.vanilla_source.api.world.parallel.ParallelUniverse)2 NibbleArray (net.minecraft.server.v1_15_R1.NibbleArray)1 PacketPlayOutLightUpdate (net.minecraft.server.v1_15_R1.PacketPlayOutLightUpdate)1 NibbleArray (net.minecraft.server.v1_16_R3.NibbleArray)1 PacketPlayOutLightUpdate (net.minecraft.server.v1_16_R3.PacketPlayOutLightUpdate)1 EnginePlayer (thpmc.vanilla_source.api.player.EnginePlayer)1 SectionTypeArray (thpmc.vanilla_source.util.SectionTypeArray)1