Java Code Examples for cn.nukkit.level.format.FullChunk#getX()
The following examples show how to use
cn.nukkit.level.format.FullChunk#getX() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Level.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public List<BlockUpdateEntry> getPendingBlockUpdates(FullChunk chunk) { int minX = (chunk.getX() << 4) - 2; int maxX = minX + 16 + 2; int minZ = (chunk.getZ() << 4) - 2; int maxZ = minZ + 16 + 2; return this.getPendingBlockUpdates(new AxisAlignedBB(minX, 0, minZ, maxX, 256, maxZ)); }
Example 2
Source File: Level.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private void performThunder(long index, FullChunk chunk) { if (areNeighboringChunksLoaded(index)) return; if (ThreadLocalRandom.current().nextInt(10000) == 0) { int LCG = this.getUpdateLCG() >> 2; int chunkX = chunk.getX() * 16; int chunkZ = chunk.getZ() * 16; Vector3 vector = this.adjustPosToNearbyEntity(new Vector3(chunkX + (LCG & 0xf), 0, chunkZ + (LCG >> 8 & 0xf))); Biome biome = Biome.getBiome(this.getBiomeId(vector.getFloorX(), vector.getFloorZ())); if (!biome.canRain()) { return; } int bId = this.getBlockIdAt(vector.getFloorX(), vector.getFloorY(), vector.getFloorZ()); if (bId != Block.TALL_GRASS && bId != Block.WATER) vector.y += 1; CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos").add(new DoubleTag("", vector.x)) .add(new DoubleTag("", vector.y)).add(new DoubleTag("", vector.z))) .putList(new ListTag<DoubleTag>("Motion").add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)).add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation").add(new FloatTag("", 0)) .add(new FloatTag("", 0))); EntityLightning bolt = (EntityLightning) Entity.createEntity("Lightning", chunk, nbt); if(bolt == null) return; LightningStrikeEvent ev = new LightningStrikeEvent(this, bolt); getServer().getPluginManager().callEvent(ev); if (!ev.isCancelled()) { bolt.spawnToAll(); } else { bolt.setEffect(false); } this.addLevelSoundEvent(vector, LevelSoundEventPacket.SOUND_THUNDER, -1, EntityLightning.NETWORK_ID); this.addLevelSoundEvent(vector, LevelSoundEventPacket.SOUND_EXPLODE, -1, EntityLightning.NETWORK_ID); } }
Example 3
Source File: Level.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public Set<BlockUpdateEntry> getPendingBlockUpdates(FullChunk chunk) { int minX = (chunk.getX() << 4) - 2; int maxX = minX + 16 + 2; int minZ = (chunk.getZ() << 4) - 2; int maxZ = minZ + 16 + 2; return this.getPendingBlockUpdates(new SimpleAxisAlignedBB(minX, 0, minZ, maxX, 256, maxZ)); }
Example 4
Source File: Level.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public void doChunkGarbageCollection() { this.timings.doChunkGC.startTiming(); // remove all invaild block entities. if (!blockEntities.isEmpty()) { ObjectIterator<BlockEntity> iter = blockEntities.values().iterator(); while (iter.hasNext()) { BlockEntity blockEntity = iter.next(); if (blockEntity != null) { if (!blockEntity.isValid()) { iter.remove(); blockEntity.close(); } } else { iter.remove(); } } } for (Map.Entry<Long, ? extends FullChunk> entry : provider.getLoadedChunks().entrySet()) { long index = entry.getKey(); if (!this.unloadQueue.containsKey(index)) { FullChunk chunk = entry.getValue(); int X = chunk.getX(); int Z = chunk.getZ(); if (!this.isSpawnChunk(X, Z)) { this.unloadChunkRequest(X, Z, true); } } } this.provider.doGarbageCollection(); this.timings.doChunkGC.stopTiming(); }
Example 5
Source File: Level.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private void performThunder(long index, FullChunk chunk) { if (areNeighboringChunksLoaded(index)) return; if (ThreadLocalRandom.current().nextInt(10000) == 0) { this.updateLCG = this.updateLCG * 3 + 1013904223; int LCG = this.updateLCG >> 2; int chunkX = chunk.getX() * 16; int chunkZ = chunk.getZ() * 16; Vector3 vector = this.adjustPosToNearbyEntity(new Vector3(chunkX + (LCG & 15), 0, chunkZ + (LCG >> 8 & 15))); int bId = this.getBlockIdAt(vector.getFloorX(), vector.getFloorY(), vector.getFloorZ()); if (bId != Block.TALL_GRASS && bId != Block.WATER) vector.y += 1; CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos").add(new DoubleTag("", vector.x)) .add(new DoubleTag("", vector.y)).add(new DoubleTag("", vector.z))) .putList(new ListTag<DoubleTag>("Motion").add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)).add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation").add(new FloatTag("", 0)) .add(new FloatTag("", 0))); EntityLightning bolt = new EntityLightning(chunk, nbt); LightningStrikeEvent ev = new LightningStrikeEvent(this, bolt); getServer().getPluginManager().callEvent(ev); if (!ev.isCancelled()) { bolt.spawnToAll(); } else { bolt.setEffect(false); } this.addLevelSoundEvent(vector, LevelSoundEventPacket.SOUND_THUNDER, 93, -1, false); this.addLevelSoundEvent(vector, LevelSoundEventPacket.SOUND_EXPLODE, 93, -1, false); } }
Example 6
Source File: Level.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public Set<BlockUpdateEntry> getPendingBlockUpdates(FullChunk chunk) { int minX = (chunk.getX() << 4) - 2; int maxX = minX + 16 + 2; int minZ = (chunk.getZ() << 4) - 2; int maxZ = minZ + 16 + 2; return this.getPendingBlockUpdates(new SimpleAxisAlignedBB(minX, 0, minZ, maxX, 256, maxZ)); }