use of thpmc.vanilla_source.util.SectionTypeArray in project VanillaSource by TheHollowPlanetMC.
the class ImplParallelChunk method setType.
@Override
public void setType(int blockX, int blockY, int blockZ, Material material) {
int sectionIndex = ChunkUtil.getSectionIndex(blockY);
SectionTypeArray sectionTypeArray = sectionTypeArrays[sectionIndex];
if (sectionTypeArray == null) {
sectionTypeArray = new SectionTypeArray();
sectionTypeArrays[sectionIndex] = sectionTypeArray;
}
Object iBlockData = NMSManager.getNMSHandler().getIBlockData(material.createBlockData());
sectionTypeArray.setType(blockX & 0xF, blockY & 0xF, blockZ & 0xF, iBlockData);
mapChunkPacketCache = null;
}
use of thpmc.vanilla_source.util.SectionTypeArray in project VanillaSource by TheHollowPlanetMC.
the class ImplParallelChunk method getType.
@Override
@Nullable
public Material getType(int blockX, int blockY, int blockZ) {
int sectionIndex = ChunkUtil.getSectionIndex(blockY);
SectionTypeArray sectionTypeArray = sectionTypeArrays[sectionIndex];
if (sectionTypeArray == null)
return null;
Object iBlockData = sectionTypeArray.getType(blockX & 0xF, blockY & 0xF, blockZ & 0xF);
if (iBlockData == null)
return null;
return NMSManager.getNMSHandler().getBukkitBlockData(iBlockData).getMaterial();
}
use of thpmc.vanilla_source.util.SectionTypeArray 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);
}
}
use of thpmc.vanilla_source.util.SectionTypeArray in project VanillaSource by TheHollowPlanetMC.
the class ImplParallelChunk method setBlockData.
@Override
public void setBlockData(int blockX, int blockY, int blockZ, BlockData blockData) {
int sectionIndex = ChunkUtil.getSectionIndex(blockY);
SectionTypeArray sectionTypeArray = sectionTypeArrays[sectionIndex];
if (sectionTypeArray == null) {
sectionTypeArray = new SectionTypeArray();
sectionTypeArrays[sectionIndex] = sectionTypeArray;
}
Object iBlockData = NMSManager.getNMSHandler().getIBlockData(blockData);
sectionTypeArray.setType(blockX & 0xF, blockY & 0xF, blockZ & 0xF, iBlockData);
mapChunkPacketCache = null;
}
use of thpmc.vanilla_source.util.SectionTypeArray in project VanillaSource by TheHollowPlanetMC.
the class ImplParallelChunk method hasBlockData.
@Override
public boolean hasBlockData(int blockX, int blockY, int blockZ) {
int sectionIndex = ChunkUtil.getSectionIndex(blockY);
SectionTypeArray sectionTypeArray = sectionTypeArrays[sectionIndex];
if (sectionTypeArray == null)
return false;
return sectionTypeArray.contains(blockX & 0xF, blockY & 0xF, blockZ & 0xF);
}
Aggregations