use of thpmc.engine.api.world.parallel.ParallelChunk in project THP-Engine by TheHollowPlanetMC.
the class ImplParallelWorld method setType.
@Override
public void setType(int blockX, int blockY, int blockZ, Material material) {
int chunkX = blockX >> 4;
int chunkZ = blockZ >> 4;
long coord = ChunkUtil.getCoordinateKey(chunkX, chunkZ);
ParallelChunk parallelChunk = chunkMap.computeIfAbsent(coord, c -> new ImplParallelChunk(this, chunkX, chunkZ));
parallelChunk.setType(blockX, blockY, blockZ, material);
}
use of thpmc.engine.api.world.parallel.ParallelChunk in project THP-Engine by TheHollowPlanetMC.
the class ImplParallelWorld method hasBlockLight.
@Override
public boolean hasBlockLight(int blockX, int blockY, int blockZ) {
int chunkX = blockX >> 4;
int chunkZ = blockZ >> 4;
long coord = ChunkUtil.getCoordinateKey(chunkX, chunkZ);
ParallelChunk parallelChunk = chunkMap.get(coord);
if (parallelChunk == null)
return false;
return parallelChunk.hasBlockLight(blockX, blockY, blockZ);
}
use of thpmc.engine.api.world.parallel.ParallelChunk in project THP-Engine 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);
}
}
use of thpmc.engine.api.world.parallel.ParallelChunk in project THP-Engine by TheHollowPlanetMC.
the class ImplParallelWorld method setNMSBlockData.
@Override
public void setNMSBlockData(int blockX, int blockY, int blockZ, Object blockData) {
int chunkX = blockX >> 4;
int chunkZ = blockZ >> 4;
long coord = ChunkUtil.getCoordinateKey(chunkX, chunkZ);
ParallelChunk parallelChunk = chunkMap.computeIfAbsent(coord, c -> new ImplParallelChunk(this, chunkX, chunkZ));
parallelChunk.setNMSBlockData(blockX, blockY, blockZ, blockData);
}
use of thpmc.engine.api.world.parallel.ParallelChunk in project THP-Engine by TheHollowPlanetMC.
the class ImplParallelWorld method getType.
@Override
@Nullable
public Material getType(int blockX, int blockY, int blockZ) {
int chunkX = blockX >> 4;
int chunkZ = blockZ >> 4;
long coord = ChunkUtil.getCoordinateKey(chunkX, chunkZ);
ParallelChunk parallelChunk = chunkMap.get(coord);
if (parallelChunk == null)
return null;
return parallelChunk.getType(blockX, blockY, blockZ);
}
Aggregations