本文整理汇总了Java中cn.nukkit.level.format.generic.BaseFullChunk类的典型用法代码示例。如果您正苦于以下问题:Java BaseFullChunk类的具体用法?Java BaseFullChunk怎么用?Java BaseFullChunk使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BaseFullChunk类属于cn.nukkit.level.format.generic包,在下文中一共展示了BaseFullChunk类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populate
import cn.nukkit.level.format.generic.BaseFullChunk; //导入依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
BaseFullChunk chunk = level.getChunk(chunkX, chunkZ);
int bx = chunkX << 4;
int bz = chunkZ << 4;
int tx = bx + 15;
int tz = bz + 15;
ObjectOre ore = new ObjectOre(random, type, Block.AIR);
for (int i = 0; i < ore.type.clusterCount; ++i) {
int x = random.nextRange(0, 15);
int z = random.nextRange(0, 15);
int y = this.getHighestWorkableBlock(chunk, x, z);
if (y != -1) {
ore.placeObject(level, bx + x, y, bz + z);
}
}
}
示例2: populate
import cn.nukkit.level.format.generic.BaseFullChunk; //导入依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.random = random;
if (random.nextRange(0, 100) < 5) {
this.level = level;
int amount = random.nextRange(0, this.randomAmount + 1) + this.baseAmount;
BaseFullChunk chunk = level.getChunk(chunkX, chunkZ);
int bx = chunkX << 4;
int bz = chunkZ << 4;
int tx = bx + 15;
int tz = bz + 15;
for (int i = 0; i < amount; ++i) {
int x = random.nextRange(0, 15);
int z = random.nextRange(0, 15);
int y = this.getHighestWorkableBlock(chunk, x, z);
if (y != -1 && chunk.getBlockId(x, y, z) == Block.AIR) {
chunk.setBlock(x, y, z, Block.LAVA);
chunk.setBlockLight(x, y, z, Block.light[Block.LAVA]);
this.lavaSpread(bx + x, y, bz + z);
}
}
}
}
示例3: populate
import cn.nukkit.level.format.generic.BaseFullChunk; //导入依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
BaseFullChunk chunk = level.getChunk(chunkX, chunkZ);
int bx = chunkX << 4;
int bz = chunkZ << 4;
int tx = bx + 15;
int tz = bz + 15;
int amount = random.nextRange(0, this.randomAmount + 1) + this.baseAmount;
for (int i = 0; i < amount; ++i) {
int x = random.nextRange(0, 15);
int z = random.nextRange(0, 15);
int y = this.getHighestWorkableBlock(chunk, x, z);
if (y != -1 && this.canGroundFireStay(chunk, x, y, z)) {
chunk.setBlock(x, y, z, Block.FIRE);
chunk.setBlockLight(x, y, z, Block.light[Block.FIRE]);
}
}
}
示例4: close
import cn.nukkit.level.format.generic.BaseFullChunk; //导入依赖的package包/类
public void close() {
if (this.getAutoSave()) {
this.save();
}
for (BaseFullChunk chunk : new ArrayList<>(this.chunks.values())) {
this.unloadChunk(chunk.getX(), chunk.getZ(), false);
}
this.unregisterGenerator();
this.provider.close();
this.provider = null;
this.blockMetadata = null;
this.blockCache.clear();
this.temporalPosition = null;
this.server.getLevels().remove(this.levelId);
}
示例5: onCompletion
import cn.nukkit.level.format.generic.BaseFullChunk; //导入依赖的package包/类
@Override
public void onCompletion(Server server) {
Level level = server.getLevel(this.levelId);
if (level != null) {
if (!this.state) {
level.registerGenerator();
return;
}
BaseFullChunk chunk = this.chunk.clone();
if (chunk == null) {
return;
}
level.generateChunkCallback(chunk.getX(), chunk.getZ(), chunk);
}
}
示例6: setChunk
import cn.nukkit.level.format.generic.BaseFullChunk; //导入依赖的package包/类
@Override
public void setChunk(int chunkX, int chunkZ, BaseFullChunk chunk) {
if (chunk == null) {
this.chunks.remove(Level.chunkHash(chunkX, chunkZ));
return;
}
this.chunks.put(Level.chunkHash(chunkX, chunkZ), chunk);
}
示例7: onRun
import cn.nukkit.level.format.generic.BaseFullChunk; //导入依赖的package包/类
@Override
public void onRun() {
BaseFullChunk chunk = this.chunk.clone();
if (chunk == null) {
return;
}
chunk.recalculateHeightMap();
chunk.populateSkyLight();
chunk.setLightPopulated();
this.chunk = chunk.clone();
}
示例8: onCompletion
import cn.nukkit.level.format.generic.BaseFullChunk; //导入依赖的package包/类
@Override
public void onCompletion(Server server) {
Level level = server.getLevel(this.levelId);
BaseFullChunk chunk = this.chunk.clone();
if (level != null) {
if (chunk == null) {
return;
}
level.generateChunkCallback(chunk.getX(), chunk.getZ(), chunk);
}
}
示例9: PopulationTask
import cn.nukkit.level.format.generic.BaseFullChunk; //导入依赖的package包/类
public PopulationTask(Level level, BaseFullChunk chunk) {
this.state = true;
this.levelId = level.getId();
this.chunk = chunk;
for (int i = 0; i < 9; i++) {
if (i == 4) {
continue;
}
int xx = -1 + i % 3;
int zz = -1 + (i / 3);
BaseFullChunk ck = level.getChunk(chunk.getX() + xx, chunk.getZ() + zz, false);
this.chunks[i] = ck;
}
}
示例10: onCompletion
import cn.nukkit.level.format.generic.BaseFullChunk; //导入依赖的package包/类
@Override
public void onCompletion(Server server) {
Level level = server.getLevel(this.levelId);
if (level != null) {
if (!this.state) {
level.registerGenerator();
return;
}
BaseFullChunk chunk = this.chunk.clone();
if (chunk == null) {
return;
}
for (int i = 0; i < 9; i++) {
if (i == 4) {
continue;
}
BaseFullChunk c = this.chunks[i];
if (c != null) {
c = c.clone();
level.generateChunkCallback(c.getX(), c.getZ(), c);
}
}
level.generateChunkCallback(chunk.getX(), chunk.getZ(), chunk);
}
}
示例11: populateChunk
import cn.nukkit.level.format.generic.BaseFullChunk; //导入依赖的package包/类
public boolean populateChunk(int x, int z, boolean force) {
Long index = Level.chunkHash(x, z);
if (this.chunkPopulationQueue.containsKey(index) || this.chunkPopulationQueue.size() >= this.chunkPopulationQueueSize && !force) {
return false;
}
BaseFullChunk chunk = this.getChunk(x, z, true);
boolean populate;
if (!chunk.isPopulated()) {
Timings.populationTimer.startTiming();
populate = true;
for (int xx = -1; xx <= 1; ++xx) {
for (int zz = -1; zz <= 1; ++zz) {
if (this.chunkPopulationLock.containsKey(Level.chunkHash(x + xx, z + zz))) {
populate = false;
break;
}
}
}
if (populate) {
if (!this.chunkPopulationQueue.containsKey(index)) {
this.chunkPopulationQueue.put(index, true);
for (int xx = -1; xx <= 1; ++xx) {
for (int zz = -1; zz <= 1; ++zz) {
this.chunkPopulationLock.put(Level.chunkHash(x + xx, z + zz), true);
}
}
PopulationTask task = new PopulationTask(this, chunk);
this.server.getScheduler().scheduleAsyncTask(task);
}
}
Timings.populationTimer.stopTiming();
return false;
}
return true;
}
示例12: onRun
import cn.nukkit.level.format.generic.BaseFullChunk; //导入依赖的package包/类
@Override
public void onRun() {
Generator generator = GeneratorPool.get(this.levelId);
if (generator == null) {
this.state = false;
return;
}
SimpleChunkManager manager = (SimpleChunkManager) generator.getChunkManager();
if (manager == null) {
this.state = false;
return;
}
synchronized (manager) {
BaseFullChunk chunk = this.chunk.clone();
if (chunk == null) {
return;
}
manager.setChunk(chunk.getX(), chunk.getZ(), chunk);
generator.generateChunk(chunk.getX(), chunk.getZ());
chunk = manager.getChunk(chunk.getX(), chunk.getZ());
chunk.setGenerated();
this.chunk = chunk.clone();
manager.setChunk(chunk.getX(), chunk.getZ(), null);
}
}
示例13: getBlock
import cn.nukkit.level.format.generic.BaseFullChunk; //导入依赖的package包/类
public Block getBlock(Vector3 pos, boolean cached) {
long chunkIndex = Level.chunkHash((int) pos.x >> 4, (int) pos.z >> 4);
BlockVector3 index = Level.blockHash((int) pos.x, (int) pos.y, (int) pos.z);
int fullState;
Block block;
BaseFullChunk chunk;
if (cached && (block = (Block) this.blockCache.get(index)) != null) {
return block;
} else if (pos.y >= 0 && pos.y < 256 && (chunk = this.chunks.get(chunkIndex)) != null) {
fullState = chunk.getFullBlock((int) pos.x & 0x0f, (int) pos.y & 0xff,
(int) pos.z & 0x0f);
} else {
fullState = 0;
}
block = this.blockStates[fullState & 0xfff].clone();
block.x = pos.x;
block.y = pos.y;
block.z = pos.z;
block.level = this;
this.blockCache.put(index, block);
return block;
}
示例14: getChunk
import cn.nukkit.level.format.generic.BaseFullChunk; //导入依赖的package包/类
public BaseFullChunk getChunk(int chunkX, int chunkZ, boolean create) {
Long index = Level.chunkHash(chunkX, chunkZ);
if (this.chunks.containsKey(index)) {
return this.chunks.get(index);
} else if (this.loadChunk(chunkX, chunkZ, create)) {
return this.chunks.get(index);
}
return null;
}
示例15: generateChunkCallback
import cn.nukkit.level.format.generic.BaseFullChunk; //导入依赖的package包/类
public void generateChunkCallback(int x, int z, BaseFullChunk chunk) {
Timings.generationCallbackTimer.startTiming();
Long index = Level.chunkHash(x, z);
if (this.chunkPopulationQueue.containsKey(index)) {
FullChunk oldChunk = this.getChunk(x, z, false);
for (int xx = -1; xx <= 1; ++xx) {
for (int zz = -1; zz <= 1; ++zz) {
this.chunkPopulationLock.remove(Level.chunkHash(x + xx, z + zz));
}
}
this.chunkPopulationQueue.remove(index);
chunk.setProvider(this.provider);
this.setChunk(x, z, chunk, false);
chunk = this.getChunk(x, z, false);
if (chunk != null && (oldChunk == null || !oldChunk.isPopulated()) && chunk.isPopulated()
&& chunk.getProvider() != null) {
this.server.getPluginManager().callEvent(new ChunkPopulateEvent(chunk));
for (ChunkLoader loader : this.getChunkLoaders(x, z)) {
loader.onChunkPopulated(chunk);
}
}
} else if (this.chunkGenerationQueue.containsKey(index) || this.chunkPopulationLock.containsKey(index)) {
this.chunkGenerationQueue.remove(index);
this.chunkPopulationLock.remove(index);
chunk.setProvider(this.provider);
this.setChunk(x, z, chunk, false);
} else {
chunk.setProvider(this.provider);
this.setChunk(x, z, chunk, false);
}
Timings.generationCallbackTimer.stopTiming();
}