Java Code Examples for cn.nukkit.block.Block#getFullId()
The following examples show how to use
cn.nukkit.block.Block#getFullId() .
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: OreType.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public OreType(Block material, int clusterCount, int clusterSize, int minHeight, int maxHeight, int replaceBlockId) { this.fullId = material.getFullId(); this.clusterCount = clusterCount; this.clusterSize = clusterSize; this.maxHeight = maxHeight; this.minHeight = minHeight; this.replaceBlockId = replaceBlockId; }
Example 2
Source File: Level.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public synchronized boolean setBlock(int x, int y, int z, Block block, boolean direct, boolean update) { if (y < 0 || y >= 256) { return false; } BaseFullChunk chunk = this.getChunk(x >> 4, z >> 4, true); Block blockPrevious; // synchronized (chunk) { blockPrevious = chunk.getAndSetBlock(x & 0xF, y, z & 0xF, block); if (blockPrevious.getFullId() == block.getFullId()) { return false; } // } block.x = x; block.y = y; block.z = z; block.level = this; int cx = x >> 4; int cz = z >> 4; long index = Level.chunkHash(cx, cz); if (direct) { this.sendBlocks(this.getChunkPlayers(cx, cz).values().toArray(new Player[0]), new Block[]{block}, UpdateBlockPacket.FLAG_ALL_PRIORITY); this.sendBlocks(this.getChunkPlayers(cx, cz).values().toArray(new Player[0]), new Block[]{Block.get(Block.AIR, 0, block)}, UpdateBlockPacket.FLAG_ALL_PRIORITY, 1); } else { addBlockChange(index, x, y, z); } for (ChunkLoader loader : this.getChunkLoaders(cx, cz)) { loader.onBlockChanged(block); } if (update) { if (blockPrevious.isTransparent() != block.isTransparent() || blockPrevious.getLightLevel() != block.getLightLevel()) { addLightUpdate(x, y, z); } BlockUpdateEvent ev = new BlockUpdateEvent(block); this.server.getPluginManager().callEvent(ev); if (!ev.isCancelled()) { for (Entity entity : this.getNearbyEntities(new SimpleAxisAlignedBB(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1))) { entity.scheduleUpdate(); } block = ev.getBlock(); block.onUpdate(BLOCK_UPDATE_NORMAL); this.updateAround(x, y, z); } } return true; }
Example 3
Source File: Level.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public boolean setBlock(int x, int y, int z, Block block, boolean direct, boolean update) { if (y < 0 || y >= 256) { return false; } BaseFullChunk chunk = this.getChunk(x >> 4, z >> 4, true); Block blockPrevious; // synchronized (chunk) { blockPrevious = chunk.getAndSetBlock(x & 0xF, y, z & 0xF, block); if (blockPrevious.getFullId() == block.getFullId()) { return false; } // } block.x = x; block.y = y; block.z = z; block.level = this; int cx = x >> 4; int cz = z >> 4; long index = Level.chunkHash(cx, cz); if (direct) { this.sendBlocks(this.getChunkPlayers(cx, cz).values().stream().toArray(Player[]::new), new Block[]{block}, UpdateBlockPacket.FLAG_ALL_PRIORITY); } else { addBlockChange(index, x, y, z); } for (ChunkLoader loader : this.getChunkLoaders(cx, cz)) { loader.onBlockChanged(block); } if (update) { if (blockPrevious.isTransparent() != block.isTransparent() || blockPrevious.getLightLevel() != block.getLightLevel()) { addLightUpdate(x, y, z); } BlockUpdateEvent ev = new BlockUpdateEvent(block); this.server.getPluginManager().callEvent(ev); if (!ev.isCancelled()) { for (Entity entity : this.getNearbyEntities(new SimpleAxisAlignedBB(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1))) { entity.scheduleUpdate(); } block = ev.getBlock(); block.onUpdate(BLOCK_UPDATE_NORMAL); this.updateAround(x, y, z); } } return true; }