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);
}
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);
}
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);
}
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;
}
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;
}
Aggregations