Search in sources :

Example 6 with SectionLevelArray

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

the class ImplParallelChunk method hasSkyLight.

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

Example 7 with SectionLevelArray

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

the class ImplParallelChunk method setBlockLightLevel.

@Override
public void setBlockLightLevel(int blockX, int blockY, int blockZ, int level) {
    int sectionIndex = ChunkUtil.getSectionIndex(blockY);
    SectionLevelArray sectionLevelArray = blockLightArrays[sectionIndex];
    if (sectionLevelArray == null) {
        sectionLevelArray = new SectionLevelArray();
        blockLightArrays[sectionIndex] = sectionLevelArray;
    }
    sectionLevelArray.setLevel(blockX & 0xF, blockY & 0xF, blockZ & 0xF, (byte) level);
    lightUpdatePacketCache = null;
}
Also used : SectionLevelArray(thpmc.vanilla_source.util.SectionLevelArray)

Example 8 with SectionLevelArray

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

the class ImplParallelChunk method setSkyLightLevel.

@Override
public void setSkyLightLevel(int blockX, int blockY, int blockZ, int level) {
    int sectionIndex = ChunkUtil.getSectionIndex(blockY);
    SectionLevelArray sectionLevelArray = skyLightArrays[sectionIndex];
    if (sectionLevelArray == null) {
        sectionLevelArray = new SectionLevelArray();
        skyLightArrays[sectionIndex] = sectionLevelArray;
    }
    sectionLevelArray.setLevel(blockX & 0xF, blockY & 0xF, blockZ & 0xF, (byte) level);
    lightUpdatePacketCache = null;
}
Also used : SectionLevelArray(thpmc.vanilla_source.util.SectionLevelArray)

Example 9 with SectionLevelArray

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

the class ImplParallelChunk method removeBlockLight.

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

Example 10 with SectionLevelArray

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

the class ImplParallelUniverse method addDiffs.

@Override
public void addDiffs(ParallelUniverse universe) {
    int indexStart = NMSManager.isHigher_v1_18_R1() ? -4 : 0;
    int indexEnd = NMSManager.isHigher_v1_18_R1() ? 20 : 16;
    for (ParallelWorld diffWorld : universe.getAllWorld()) {
        for (ParallelChunk diffChunk : diffWorld.getAllChunk()) {
            for (int i = indexStart; i < indexEnd; i++) {
                ParallelWorld thisWorld = null;
                ParallelChunk thisChunk = null;
                SectionTypeArray sectionTypeArray = diffChunk.getSectionTypeArray(i);
                if (sectionTypeArray != null) {
                    thisWorld = this.getWorld(diffWorld.getName());
                    thisChunk = ((ImplParallelWorld) thisWorld).createChunkIfAbsent(diffChunk.getChunkX(), diffChunk.getChunkZ());
                    SectionTypeArray thisType = ((ImplParallelChunk) thisChunk).createSectionTypeArrayIfAbsent(i);
                    sectionTypeArray.threadsafeIteration(thisType::setType);
                }
                SectionLevelArray blockLightLevelArray = diffChunk.getBlockLightSectionLevelArray(i);
                if (blockLightLevelArray != null) {
                    if (thisWorld == null)
                        thisWorld = this.getWorld(diffWorld.getName());
                    if (thisChunk == null)
                        thisChunk = ((ImplParallelWorld) thisWorld).createChunkIfAbsent(diffChunk.getChunkX(), diffChunk.getChunkZ());
                    SectionLevelArray thisLevel = ((ImplParallelChunk) thisChunk).createBlockLightSectionLevelArrayIfAbsent(i);
                    blockLightLevelArray.threadsafeIteration(thisLevel::setLevel);
                }
                SectionLevelArray skyLightLevelArray = diffChunk.getSkyLightSectionLevelArray(i);
                if (skyLightLevelArray != null) {
                    if (thisWorld == null)
                        thisWorld = this.getWorld(diffWorld.getName());
                    if (thisChunk == null)
                        thisChunk = ((ImplParallelWorld) thisWorld).createChunkIfAbsent(diffChunk.getChunkX(), diffChunk.getChunkZ());
                    SectionLevelArray thisLevel = ((ImplParallelChunk) thisChunk).createSkyLightSectionLevelArrayIfAbsent(i);
                    skyLightLevelArray.threadsafeIteration(thisLevel::setLevel);
                }
            }
        }
    }
    for (EnginePlayer EnginePlayer : this.getResidents()) {
        ((ImplEnginePlayer) EnginePlayer).setUniverseRaw(null);
        EnginePlayer.setUniverse(this);
    }
}
Also used : ParallelWorld(thpmc.vanilla_source.api.world.parallel.ParallelWorld) ParallelChunk(thpmc.vanilla_source.api.world.parallel.ParallelChunk) EnginePlayer(thpmc.vanilla_source.api.player.EnginePlayer) SectionTypeArray(thpmc.vanilla_source.util.SectionTypeArray) 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