cn.nukkit.blockentity.BlockEntitySpawnable Java Examples
The following examples show how to use
cn.nukkit.blockentity.BlockEntitySpawnable.
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: ChunkRequestTask.java From Jupiter with GNU General Public License v3.0 | 6 votes |
public ChunkRequestTask(Level level, Chunk chunk) { this.levelId = level.getId(); this.chunk = chunk.toFastBinary(); this.chunkX = chunk.getX(); this.chunkZ = chunk.getZ(); byte[] buffer = new byte[0]; for (BlockEntity blockEntity : chunk.getBlockEntities().values()) { if (blockEntity instanceof BlockEntitySpawnable) { try { buffer = Binary.appendBytes(buffer, NBTIO.write(((BlockEntitySpawnable) blockEntity).getSpawnCompound(), ByteOrder.BIG_ENDIAN, true)); } catch (IOException e) { throw new RuntimeException(e); } } } this.blockEntities = buffer; }
Example #2
Source File: ChunkRequestTask.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public ChunkRequestTask(Level level, Chunk chunk) { this.timeStamp = chunk.getChanges(); this.levelId = level.getId(); this.chunk = chunk.toFastBinary(); this.chunkX = chunk.getX(); this.chunkZ = chunk.getZ(); byte[] buffer = new byte[0]; for (BlockEntity blockEntity : chunk.getBlockEntities().values()) { if (blockEntity instanceof BlockEntitySpawnable) { try { buffer = Binary.appendBytes(buffer, NBTIO.write(((BlockEntitySpawnable) blockEntity).getSpawnCompound(), ByteOrder.BIG_ENDIAN, true)); } catch (IOException e) { throw new RuntimeException(e); } } } this.blockEntities = buffer; }
Example #3
Source File: LevelDB.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public AsyncTask requestChunkTask(int x, int z) { Chunk chunk = this.getChunk(x, z, false); if (chunk == null) { throw new ChunkException("Invalid Chunk sent"); } long timestamp = chunk.getChanges(); BinaryStream stream = new BinaryStream(); stream.putByte((byte) 0); // subchunk version stream.put(chunk.getBlockIdArray()); stream.put(chunk.getBlockDataArray()); stream.put(chunk.getBlockSkyLightArray()); stream.put(chunk.getBlockLightArray()); stream.put(chunk.getHeightMapArray()); stream.put(chunk.getBiomeIdArray()); Map<Integer, Integer> extra = chunk.getBlockExtraDataArray(); stream.putLInt(extra.size()); if (!extra.isEmpty()) { for (Integer key : extra.values()) { stream.putLInt(key); stream.putLShort(extra.get(key)); } } 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 { stream.put(NBTIO.write(tagList, ByteOrder.LITTLE_ENDIAN)); } catch (IOException e) { throw new RuntimeException(e); } } this.getLevel().chunkRequestCallback(timestamp, x, z, 16, stream.getBuffer()); return null; }
Example #4
Source File: McRegion.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public AsyncTask requestChunkTask(int x, int z) throws ChunkException { BaseFullChunk chunk = this.getChunk(x, z, false); if (chunk == null) { throw new ChunkException("Invalid Chunk Sent"); } long timestamp = chunk.getChanges(); BinaryStream stream = new BinaryStream(); stream.putByte((byte) 0); // subchunk version stream.put(chunk.getBlockIdArray()); stream.put(chunk.getBlockDataArray()); stream.put(chunk.getBlockSkyLightArray()); stream.put(chunk.getBlockLightArray()); stream.put(chunk.getHeightMapArray()); stream.put(chunk.getBiomeIdArray()); Map<Integer, Integer> extra = chunk.getBlockExtraDataArray(); stream.putLInt(extra.size()); if (!extra.isEmpty()) { for (Integer key : extra.values()) { stream.putLInt(key); stream.putLShort(extra.get(key)); } } 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 { stream.put(NBTIO.write(tagList, ByteOrder.LITTLE_ENDIAN)); } catch (IOException e) { throw new RuntimeException(e); } } return null; }
Example #5
Source File: LevelDB.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public AsyncTask requestChunkTask(int x, int z) { Chunk chunk = this.getChunk(x, z, false); if (chunk == null) { throw new ChunkException("Invalid Chunk sent"); } long timestamp = chunk.getChanges(); byte[] tiles = 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 { tiles = NBTIO.write(tagList, ByteOrder.LITTLE_ENDIAN); } catch (IOException e) { throw new RuntimeException(e); } } Map<Integer, Integer> extra = chunk.getBlockExtraDataArray(); BinaryStream extraData; if (!extra.isEmpty()) { extraData = new BinaryStream(); extraData.putLInt(extra.size()); for (Integer key : extra.values()) { extraData.putLInt(key); extraData.putLShort(extra.get(key)); } } else { extraData = null; } BinaryStream stream = new BinaryStream(); stream.put(chunk.getBlockIdArray()); stream.put(chunk.getBlockDataArray()); stream.put(chunk.getBlockSkyLightArray()); stream.put(chunk.getBlockLightArray()); stream.put(chunk.getHeightMapArray()); for (int color : chunk.getBiomeColorArray()) { stream.put(Binary.writeInt(color)); } if (extraData != null) { stream.put(extraData.getBuffer()); } else { stream.putLInt(0); } stream.put(tiles); this.getLevel().chunkRequestCallback(timestamp, x, z, stream.getBuffer()); return null; }