本文整理汇总了Java中cn.nukkit.blockentity.BlockEntitySpawnable类的典型用法代码示例。如果您正苦于以下问题:Java BlockEntitySpawnable类的具体用法?Java BlockEntitySpawnable怎么用?Java BlockEntitySpawnable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlockEntitySpawnable类属于cn.nukkit.blockentity包,在下文中一共展示了BlockEntitySpawnable类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: ChunkRequestTask
import cn.nukkit.blockentity.BlockEntitySpawnable; //导入依赖的package包/类
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;
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:22,代码来源:ChunkRequestTask.java
示例2: ChunkRequestTask
import cn.nukkit.blockentity.BlockEntitySpawnable; //导入依赖的package包/类
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));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
this.blockEntities = buffer;
}
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:22,代码来源:ChunkRequestTask.java
示例3: update
import cn.nukkit.blockentity.BlockEntitySpawnable; //导入依赖的package包/类
@Override
public final boolean update(boolean force, boolean applyPhysics) {
PokkitBlock block = getBlock();
if (!block.getTypeData().equals(materialData)) {
// Block type has changed
if (!force) {
return false;
}
block.setTypeAndData(materialData, applyPhysics);
}
// Update NBT data
BlockEntity blockEntity = getBlockEntity();
saveToTag(blockEntity.namedTag);
if (!(blockEntity instanceof BlockEntitySpawnable)) {
return false;
}
// Send updates
((BlockEntitySpawnable) blockEntity).spawnToAll();
if (blockEntity.chunk != null) {
blockEntity.chunk.setChanged();
blockEntity.level.clearChunkCache(blockEntity.chunk.getX(), blockEntity.chunk.getZ());
}
return true;
}
开发者ID:rutgerkok,项目名称:Pokkit,代码行数:28,代码来源:PokkitBlockState.java
示例4: requestChunkTask
import cn.nukkit.blockentity.BlockEntitySpawnable; //导入依赖的package包/类
@Override
public AsyncTask requestChunkTask(int x, int z) {
FullChunk chunk = this.getChunk(x, z, false);
if (chunk == null) {
throw new ChunkException("Invalid Chunk sent");
}
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());
for (int height : chunk.getHeightMapArray()) {
stream.putByte((byte) height);
}
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(x, z, stream.getBuffer());
return null;
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:61,代码来源:LevelDB.java
示例5: requestChunkTask
import cn.nukkit.blockentity.BlockEntitySpawnable; //导入依赖的package包/类
@Override
public byte[] requestChunkTask(int x, int z) {
FullChunk chunk = this.getChunk(x, z, false);
if (chunk == null) {
throw new ChunkException("Invalid Chunk sent");
}
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());
for (int height : chunk.getHeightMapArray()) {
stream.putByte((byte) height);
}
for (int color : chunk.getBiomeColorArray()) {
stream.put(Binary.writeInt(color));
}
if (extraData != null) {
stream.put(extraData.getBuffer());
} else {
stream.putLInt(0);
}
stream.put(tiles);
return stream.getBuffer();
}
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:59,代码来源:LevelDB.java
示例6: requestChunkTask
import cn.nukkit.blockentity.BlockEntitySpawnable; //导入依赖的package包/类
@Override
public AsyncTask requestChunkTask(int x, int z) {
FullChunk chunk = this.getChunk(x, z, false);
if (chunk == null) {
throw new ChunkException("Invalid Chunk sent");
}
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);
}
}
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(tiles);
this.getLevel().chunkRequestCallback(x, z, stream.getBuffer());
return null;
}
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:51,代码来源:LevelDB.java
示例7: requestChunkTask
import cn.nukkit.blockentity.BlockEntitySpawnable; //导入依赖的package包/类
@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");
}
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);
}
}
BinaryStream extraData = new BinaryStream();
extraData.putLInt(chunk.getBlockExtraDataArray().size());
for (Integer key : chunk.getBlockExtraDataArray().keySet()) {
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(tiles);
this.getLevel().chunkRequestCallback(x, z, stream.getBuffer());
return null;
}
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:51,代码来源:McRegion.java
示例8: requestChunkTask
import cn.nukkit.blockentity.BlockEntitySpawnable; //导入依赖的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.blockentity.BlockEntitySpawnable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论