Java Code Examples for org.bukkit.ChunkSnapshot#getBlockData()
The following examples show how to use
org.bukkit.ChunkSnapshot#getBlockData() .
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: SnapshotMatchModule.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
public MaterialData getOriginalMaterial(int x, int y, int z) { if (y < 0 || y >= 256) return new MaterialData(Material.AIR); ChunkVector chunkVector = ChunkVector.ofBlock(x, y, z); ChunkSnapshot chunkSnapshot = chunkSnapshots.get(chunkVector); if (chunkSnapshot != null) { BlockVector chunkPos = chunkVector.worldToChunk(x, y, z); return new MaterialData( chunkSnapshot.getBlockTypeId( chunkPos.getBlockX(), chunkPos.getBlockY(), chunkPos.getBlockZ()), (byte) chunkSnapshot.getBlockData( chunkPos.getBlockX(), chunkPos.getBlockY(), chunkPos.getBlockZ())); } else { return match.getWorld().getBlockAt(x, y, z).getState().getMaterialData(); } }
Example 2
Source File: SnapshotMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
public MaterialData getOriginalMaterial(int x, int y, int z) { if(y < 0 || y >= 256) return new MaterialData(Material.AIR); ChunkVector chunkVector = ChunkVector.ofBlock(x, y, z); ChunkSnapshot chunkSnapshot = chunkSnapshots.get(chunkVector); if(chunkSnapshot != null) { BlockVector chunkPos = chunkVector.worldToChunk(x, y, z); return new MaterialData(chunkSnapshot.getBlockTypeId(chunkPos.getBlockX(), chunkPos.getBlockY(), chunkPos.getBlockZ()), (byte) chunkSnapshot.getBlockData(chunkPos.getBlockX(), chunkPos.getBlockY(), chunkPos.getBlockZ())); } else { return getMatch().getWorld().getBlockAt(x, y, z).getState().getMaterialData(); } }
Example 3
Source File: BukkitQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public int getCombinedId4Data(ChunkSnapshot chunk, int x, int y, int z) { if (chunk.isSectionEmpty(y >> 4)) { return 0; } int id = chunk.getBlockTypeId(x & 15, y, z & 15); if (FaweCache.hasData(id)) { int data = chunk.getBlockData(x & 15, y, z & 15); return (id << 4) + data; } else { return id << 4; } }
Example 4
Source File: ItemManager.java From civcraft with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("deprecation") public static int getBlockData(ChunkSnapshot snapshot, int x, int y, int z) { return snapshot.getBlockData(x, y, z); }
Example 5
Source File: ChunkManager.java From ThinkMap with Apache License 2.0 | 4 votes |
private void gzipChunk(ChunkSnapshot chunk, ByteBuf out) { int mask = 0; int count = 0; for (int i = 0; i < 16; i++) { if (!chunk.isSectionEmpty(i)) { mask |= 1 << i; count++; } } ByteBuf data = allocator.buffer(16 * 16 * 16 * 4 * count + 3 + 256); data.writeByte(1); // The chunk exists data.writeShort(mask); int offset = 0; int blockDataOffset = 16 * 16 * 16 * 2 * count; int skyDataOffset = blockDataOffset + 16 * 16 * 16 * count; for (int i = 0; i < 16; i++) { if (!chunk.isSectionEmpty(i)) { for (int oy = 0; oy < 16; oy++) { for (int oz = 0; oz < 16; oz++) { for (int ox = 0; ox < 16; ox++) { int y = oy + (i << 4); int id = chunk.getBlockTypeId(ox, y, oz); int dValue = chunk.getBlockData(ox, y, oz); data.setShort((offset << 1) + 3, (id << 4) | dValue); data.setByte(blockDataOffset + offset + 3, chunk.getBlockEmittedLight(ox, y, oz)); data.setByte(skyDataOffset + offset + 3, chunk.getBlockSkyLight(ox, y, oz)); offset++; } } } } } for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { data.setByte(skyDataOffset + offset + 3 + x + z * 16, ThinkBiome.bukkitToId(chunk.getBiome(x, z))); } } data.writerIndex(data.capacity()); try { GZIPOutputStream gzip = new GZIPOutputStream(new ByteBufOutputStream(out)); byte[] bytes = new byte[data.readableBytes()]; data.readBytes(bytes); gzip.write(bytes); gzip.close(); } catch (IOException e) { throw new RuntimeException(); } finally { data.release(); } }