net.minecraft.world.chunk.Chunk.getHeight()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(86)

本文整理了Java中net.minecraft.world.chunk.Chunk.getHeight()方法的一些代码示例,展示了Chunk.getHeight()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Chunk.getHeight()方法的具体详情如下:
包路径:net.minecraft.world.chunk.Chunk
类名称:Chunk
方法名:getHeight

Chunk.getHeight介绍

暂无

代码示例

代码示例来源:origin: Darkhax-Minecraft/Bookshelf

/**
 * Gets a random position within a chunk. This will load the chunk if it is not already
 * loaded.
 *
 * @param world The world to get a position within.
 * @param x The chunk X position.
 * @param z The chunk Y position.
 * @return A random position within the chunk.
 */
public static BlockPos getRandomChunkPosition (World world, int x, int z) {
  
  final Chunk chunk = world.getChunk(x, z);
  final int posX = x * 16 + world.rand.nextInt(16);
  final int posZ = z * 16 + world.rand.nextInt(16);
  final int height = MathHelper.roundUp(chunk.getHeight(new BlockPos(posX, 0, posZ)) + 1, 16);
  final int posY = world.rand.nextInt(height > 0 ? height : chunk.getTopFilledSegment() + 16 - 1);
  return new BlockPos(posX, posY, posZ);
}

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

protected BlockPos getGround(World world, BlockPos pos) {
  Chunk chunk = world.getChunkFromBlockCoords(pos);
  BlockPos currentPos;
  BlockPos ground;
  for (currentPos = new BlockPos(pos.getX(), chunk.getHeight(pos), pos.getZ()); currentPos.getY() >= world.provider.getAverageGroundLevel() - 16; currentPos = ground) {
    ground = currentPos.down();
    IBlockState state = chunk.getBlockState(ground);
    Material material = state.getMaterial();
    if (material == Material.GROUND || material == Material.SAND || material == Material.GRASS || material == Material.ROCK|| material.isLiquid()) {
      break;
    }
  }
  return currentPos;
}

代码示例来源:origin: TeamWizardry/Wizardry

pos.setY(event.player.world.getChunk(pos).getHeight(pos) + 1);
distance = pos.getDistance((int) event.player.posX, (int) event.player.posY, (int) event.player.posZ);

相关文章