Search in sources :

Example 16 with ParallelChunk

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);
}
Also used : ParallelChunk(thpmc.engine.api.world.parallel.ParallelChunk)

Example 17 with ParallelChunk

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);
}
Also used : ParallelChunk(thpmc.engine.api.world.parallel.ParallelChunk)

Example 18 with ParallelChunk

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);
    }
}
Also used : ParallelWorld(thpmc.engine.api.world.parallel.ParallelWorld) ParallelChunk(thpmc.engine.api.world.parallel.ParallelChunk) EnginePlayer(thpmc.engine.api.player.EnginePlayer) SectionTypeArray(thpmc.engine.util.SectionTypeArray) SectionLevelArray(thpmc.engine.util.SectionLevelArray)

Example 19 with ParallelChunk

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);
}
Also used : ParallelChunk(thpmc.engine.api.world.parallel.ParallelChunk)

Example 20 with ParallelChunk

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);
}
Also used : ParallelChunk(thpmc.engine.api.world.parallel.ParallelChunk) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ParallelChunk (thpmc.engine.api.world.parallel.ParallelChunk)26 ParallelWorld (thpmc.engine.api.world.parallel.ParallelWorld)10 ParallelUniverse (thpmc.engine.api.world.parallel.ParallelUniverse)6 SectionTypeArray (thpmc.engine.util.SectionTypeArray)6 Nullable (org.jetbrains.annotations.Nullable)5 SectionLevelArray (thpmc.engine.util.SectionLevelArray)5 World (org.bukkit.World)4 BlockData (org.bukkit.block.data.BlockData)3 java.util (java.util)2 List (java.util.List)2 Bukkit (org.bukkit.Bukkit)2 ChunkSnapshot (org.bukkit.ChunkSnapshot)2 CraftWorld (org.bukkit.craftbukkit.v1_15_R1.CraftWorld)2 CraftBlockData (org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData)2 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)2 Player (org.bukkit.entity.Player)2 BlockPosition3i (thpmc.engine.util.BlockPosition3i)2 net.minecraft.server.v1_15_R1 (net.minecraft.server.v1_15_R1)1 BlockPosition (net.minecraft.server.v1_15_R1.BlockPosition)1 ChunkCoordIntPair (net.minecraft.server.v1_15_R1.ChunkCoordIntPair)1