Java Code Examples for cn.nukkit.block.Block#WATER
The following examples show how to use
cn.nukkit.block.Block#WATER .
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: PopulatorCaves.java From Jupiter with GNU General Public License v3.0 | 5 votes |
protected boolean isSuitableBlock(int block, int blockAbove, Biome biome) { if (!(biome instanceof CaveBiome)) { return false; } CaveBiome caveBiome = (CaveBiome) biome; if (block == caveBiome.getStoneBlock()) { return true; } if (block == Block.SAND || block == Block.GRAVEL) { return !(blockAbove == Block.WATER || blockAbove == Block.STILL_WATER || blockAbove == Block.LAVA || blockAbove == Block.STILL_LAVA); } if (block == caveBiome.getGroundBlock()) { return true; } if (block == caveBiome.getSurfaceBlock()) { return true; } // Few hardcoded cases if (block == Block.TERRACOTTA) { return true; } if (block == Block.SANDSTONE) { return true; } // TODO: add red sandstone case in Minecraft 1.8 return block == Block.SNOW; }
Example 2
Source File: PopulatorSugarcane.java From Jupiter with GNU General Public License v3.0 | 5 votes |
private boolean findWater(int x, int y, int z) { int count = 0; for (int i = x - 4; i < (x + 4); i++) { for (int j = z - 4; j < (z + 4); j++) { int b = this.level.getBlockIdAt(i, y, j); if (b == Block.WATER || b == Block.STILL_WATER) { count++; } if (count > 10) { return true; } } } return (count > 10); }
Example 3
Source File: PopulatorSugarcane.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private boolean findWater(int x, int y, int z, Level level) { int count = 0; for (int i = x - 4; i < (x + 4); i++) { for (int j = z - 4; j < (z + 4); j++) { int b = level.getBlockIdAt(i, y, j); if (b == Block.WATER || b == Block.STILL_WATER) { count++; } if (count > 10) { return true; } } } return (count > 10); }
Example 4
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 5
Source File: PopulatorCaves.java From Nukkit with GNU General Public License v3.0 | 5 votes |
protected boolean isSuitableBlock(int block, int blockAbove, Biome biome) { if (!(biome instanceof CaveBiome)) { return false; } CaveBiome caveBiome = (CaveBiome) biome; if (block == caveBiome.getStoneBlock()) { return true; } if (block == Block.SAND || block == Block.GRAVEL) { return !(blockAbove == Block.WATER || blockAbove == Block.STILL_WATER || blockAbove == Block.LAVA || blockAbove == Block.STILL_LAVA); } if (block == caveBiome.getGroundBlock()) { return true; } if (block == caveBiome.getSurfaceBlock()) { return true; } // Few hardcoded cases if (block == Block.TERRACOTTA) { return true; } if (block == Block.SANDSTONE) { return true; } // TODO: add red sandstone case in Minecraft 1.8 return block == Block.SNOW; }
Example 6
Source File: PopulatorSugarcane.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private boolean findWater(int x, int y, int z) { int count = 0; for (int i = x - 4; i < (x + 4); i++) { for (int j = z - 4; j < (z + 4); j++) { int b = this.level.getBlockIdAt(i, y, j); if (b == Block.WATER || b == Block.STILL_WATER) { count++; } if (count > 10) { return true; } } } return (count > 10); }
Example 7
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); } }