当前位置: 首页>>代码示例>>Java>>正文


Java FullChunkDataPacket类代码示例

本文整理汇总了Java中cn.nukkit.network.protocol.FullChunkDataPacket的典型用法代码示例。如果您正苦于以下问题:Java FullChunkDataPacket类的具体用法?Java FullChunkDataPacket怎么用?Java FullChunkDataPacket使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FullChunkDataPacket类属于cn.nukkit.network.protocol包,在下文中一共展示了FullChunkDataPacket类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendChunk

import cn.nukkit.network.protocol.FullChunkDataPacket; //导入依赖的package包/类
public void sendChunk(int x, int z, byte[] payload) {
    if (!this.connected) {
        return;
    }

    this.usedChunks.put(Level.chunkHash(x, z), true);
    this.chunkLoadCount++;

    FullChunkDataPacket pk = new FullChunkDataPacket();
    pk.chunkX = x;
    pk.chunkZ = z;
    pk.data = payload;

    this.batchDataPacket(pk);

    if (this.spawned) {
        for (Entity entity : this.level.getChunkEntities(x, z).values()) {
            if (this != entity && !entity.closed && entity.isAlive()) {
                entity.spawnTo(this);
            }
        }
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:24,代码来源:Player.java

示例2: forceSendEmptyChunks

import cn.nukkit.network.protocol.FullChunkDataPacket; //导入依赖的package包/类
protected void forceSendEmptyChunks() {
    int chunkPositionX = this.getFloorX() >> 4;
    int chunkPositionZ = this.getFloorZ() >> 4;
    for (int x = -3; x < 3; x++) {
        for (int z = -3; z < 3; z++) {
            FullChunkDataPacket chunk = new FullChunkDataPacket();
            chunk.chunkX = chunkPositionX + x;
            chunk.chunkZ = chunkPositionZ + z;
            chunk.data = new byte[0];
            this.dataPacket(chunk);
        }
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:14,代码来源:Player.java

示例3: getEmptyChunkFullPacket

import cn.nukkit.network.protocol.FullChunkDataPacket; //导入依赖的package包/类
public static FullChunkDataPacket getEmptyChunkFullPacket(int x, int z) {
    if (cachedEmptyChunk == null) {
        cachedEmptyChunk = getEmptyChunkPayload();
    }
    FullChunkDataPacket pk = new FullChunkDataPacket();
    pk.chunkX = x;
    pk.chunkZ = z;
    pk.order = FullChunkDataPacket.ORDER_LAYERED;
    pk.data = cachedEmptyChunk;
    return pk;
}
 
开发者ID:PrismarineMC,项目名称:MagmaBlock,代码行数:12,代码来源:LevelUtil.java

示例4: requestChunkTask

import cn.nukkit.network.protocol.FullChunkDataPacket; //导入依赖的package包/类
@Override
public AsyncTask requestChunkTask(int x, int z) throws ChunkException {
    FullChunk chunk = this.getChunk(x, z, false);
    if (chunk == null) {
        throw new ChunkException("Invalid Chunk Set");
    }

    byte[] blockEntities = new byte[0];

    if (!chunk.getBlockEntities().isEmpty()) {
        List<CompoundTag> tagList = new ArrayList<>();

        for (BlockEntity blockEntity : chunk.getBlockEntities().values()) {
            if (blockEntity instanceof BlockEntitySpawnable) {
                tagList.add(((BlockEntitySpawnable) blockEntity).getSpawnCompound());
            }
        }

        try {
            blockEntities = NBTIO.write(tagList, ByteOrder.LITTLE_ENDIAN);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    BinaryStream extraData = new BinaryStream();
    extraData.putLInt(chunk.getBlockExtraDataArray().size());
    for (Integer key : chunk.getBlockExtraDataArray().values()) {
        extraData.putLInt(key);
        extraData.putLShort(chunk.getBlockExtraDataArray().get(key));
    }

    BinaryStream stream = new BinaryStream();
    stream.put(chunk.getBlockIdArray());
    stream.put(chunk.getBlockDataArray());
    stream.put(chunk.getBlockSkyLightArray());
    stream.put(chunk.getBlockLightArray());
    for (int height : chunk.getHeightMapArray()) {
        stream.putByte((byte) (height & 0xff));
    }
    for (int color : chunk.getBiomeColorArray()) {
        stream.put(Binary.writeInt(color));
    }
    stream.put(extraData.getBuffer());
    stream.put(blockEntities);

    this.getLevel().chunkRequestCallback(x, z, stream.getBuffer(), FullChunkDataPacket.ORDER_LAYERED);

    return null;
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:51,代码来源:Anvil.java


注:本文中的cn.nukkit.network.protocol.FullChunkDataPacket类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。