use of com.github.steveice10.mc.protocol.data.game.entity.metadata.Position in project DragonProxy by DragonetMC.
the class ChunkCache method translateBlock.
public final ItemEntry translateBlock(Position position) {
ChunkPos columnPos = new ChunkPos(position.getX() >> 4, position.getZ() >> 4);
if (chunkCache.containsKey(columnPos))
try {
Column column = chunkCache.get(columnPos);
BlockPosition blockPos = columnPos.getBlockInChunk(position.getX(), position.getY(), position.getZ());
Chunk chunk = column.getChunks()[position.getY() >> 4];
if (chunk != null) {
BlockState block = chunk.getBlocks().get(blockPos.x, blockPos.y, blockPos.z);
return ItemBlockTranslator.translateToPE(block.getId(), block.getData());
}
} catch (java.lang.ArrayIndexOutOfBoundsException ex) {
this.session.getProxy().getLogger().info("getBlock(" + position.toString() + ")) fail to get chunk " + (position.getX() >> 4) + "/" + (position.getY() >> 4) + "/" + (position.getZ() >> 4));
ex.printStackTrace();
}
return null;
}
Aggregations