org.bukkit.ChunkSnapshot#getBlockTypeId ( )源码实例Demo

下面列出了org.bukkit.ChunkSnapshot#getBlockTypeId ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: PGM   文件: SnapshotMatchModule.java
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();
  }
}
 
源代码2 项目: ProjectAres   文件: SnapshotMatchModule.java
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();
    }
}
 
源代码3 项目: FastAsyncWorldedit   文件: BukkitQueue_All.java
@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;
    }
}
 
源代码4 项目: civcraft   文件: ItemManager.java
@SuppressWarnings("deprecation")
public static int getBlockTypeId(ChunkSnapshot snapshot, int x, int y, int z) {
	return snapshot.getBlockTypeId(x, y, z);
}
 
源代码5 项目: ThinkMap   文件: ChunkManager.java
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();
    }
}