diff --git a/src/main/java/biomesoplenty/common/command/BOPCommand.java b/src/main/java/biomesoplenty/common/command/BOPCommand.java index 14698e969..4f5988af1 100644 --- a/src/main/java/biomesoplenty/common/command/BOPCommand.java +++ b/src/main/java/biomesoplenty/common/command/BOPCommand.java @@ -129,10 +129,15 @@ public class BOPCommand extends CommandBase if (closestBiomePos != null) { - double x = (double)closestBiomePos.getX(); - double y = (double)world.getTopSolidOrLiquidBlock(closestBiomePos).getY(); - double z = (double)closestBiomePos.getZ(); - + double x = (double)closestBiomePos.getX(); + double y = (double)world.getTopSolidOrLiquidBlock(closestBiomePos).getY(); + double z = (double)closestBiomePos.getZ(); + + if (!world.provider.isSurfaceWorld()) + { + y = (double)getTopBlockNonOverworld(world, closestBiomePos).getY(); + } + player.connection.setPlayerLocation(x, y, z, player.rotationYaw, player.rotationPitch); sender.sendMessage(new TextComponentTranslation("commands.biomesoplenty.tpbiome.success", player.getName(), biomeName, x, y, z)); } @@ -142,6 +147,27 @@ public class BOPCommand extends CommandBase } } + public BlockPos getTopBlockNonOverworld(World world, BlockPos pos) + { + Chunk chunk = world.getChunkFromBlockCoords(pos); + BlockPos blockpos; + BlockPos blockpos1; + BlockPos blockpos2 = new BlockPos(pos.getX(), chunk.getTopFilledSegment() + 16, pos.getZ()); + + for (blockpos = blockpos2; blockpos.getY() >= 0; blockpos = blockpos1) + { + blockpos1 = blockpos.down(); + IBlockState state = chunk.getBlockState(blockpos1); + + if (!state.getMaterial().blocksMovement() && !world.isAirBlock(blockpos1.down()) && !state.getBlock().isLeaves(state, world, blockpos1) && !state.getBlock().isFoliage(world, blockpos1)) + { + return blockpos1; + } + } + + return blockpos2; + } + private void printStats(ICommandSender sender, String[] args) { TextComponentTranslation text = new TextComponentTranslation("commands.biomesoplenty.stats.blocks", blockCount); diff --git a/src/main/java/biomesoplenty/common/util/biome/GeneratorUtils.java b/src/main/java/biomesoplenty/common/util/biome/GeneratorUtils.java index d444ca806..d1c73a654 100644 --- a/src/main/java/biomesoplenty/common/util/biome/GeneratorUtils.java +++ b/src/main/java/biomesoplenty/common/util/biome/GeneratorUtils.java @@ -117,12 +117,12 @@ public class GeneratorUtils case NETHER_SURFACE: // random point above the nether surface tempY = world.getHeight(new BlockPos(x, 0, z)).getY(); - pos = getFirstBlockMatching(world, new BlockPos(x, nextIntBetween(random, 1, 127), z), BlockQuery.buildAnd().add(BlockQueries.solid).withAirAbove().create()); + pos = getFirstBlockMatching(world, new BlockPos(x, nextIntBetween(random, 1, 122), z), BlockQuery.buildAnd().add(BlockQueries.solid).withAirAbove().create()); return (pos == null ? new BlockPos(x, 1, z) : pos.up()); case NETHER_ROOF: // random point above the nether surface tempY = world.getHeight(new BlockPos(x, 0, z)).getY(); - pos = getFirstBlockMatching(world, new BlockPos(x, nextIntBetween(random, 1, 127), z), BlockQuery.buildAnd().add(BlockQueries.solid).withAirBelow().create()); + pos = getFirstBlockMatching(world, new BlockPos(x, nextIntBetween(random, 1, 122), z), BlockQuery.buildAnd().add(BlockQueries.solid).withAirBelow().create()); return (pos == null ? new BlockPos(x, 1, z) : pos.down()); case ANYWHERE: default: // random y coord