Prevented Nether generation above the bedrock and fixed tpbiome command in Nether (Closes #1140, #1141)
This commit is contained in:
parent
5d08edd06a
commit
6717a9708c
2 changed files with 32 additions and 6 deletions
|
@ -129,9 +129,14 @@ public class BOPCommand extends CommandBase
|
||||||
|
|
||||||
if (closestBiomePos != null)
|
if (closestBiomePos != null)
|
||||||
{
|
{
|
||||||
double x = (double)closestBiomePos.getX();
|
double x = (double)closestBiomePos.getX();
|
||||||
double y = (double)world.getTopSolidOrLiquidBlock(closestBiomePos).getY();
|
double y = (double)world.getTopSolidOrLiquidBlock(closestBiomePos).getY();
|
||||||
double z = (double)closestBiomePos.getZ();
|
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);
|
player.connection.setPlayerLocation(x, y, z, player.rotationYaw, player.rotationPitch);
|
||||||
sender.sendMessage(new TextComponentTranslation("commands.biomesoplenty.tpbiome.success", player.getName(), biomeName, x, y, z));
|
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) {
|
private void printStats(ICommandSender sender, String[] args) {
|
||||||
TextComponentTranslation text = new TextComponentTranslation("commands.biomesoplenty.stats.blocks", blockCount);
|
TextComponentTranslation text = new TextComponentTranslation("commands.biomesoplenty.stats.blocks", blockCount);
|
||||||
|
|
||||||
|
|
|
@ -117,12 +117,12 @@ public class GeneratorUtils
|
||||||
case NETHER_SURFACE:
|
case NETHER_SURFACE:
|
||||||
// random point above the nether surface
|
// random point above the nether surface
|
||||||
tempY = world.getHeight(new BlockPos(x, 0, z)).getY();
|
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());
|
return (pos == null ? new BlockPos(x, 1, z) : pos.up());
|
||||||
case NETHER_ROOF:
|
case NETHER_ROOF:
|
||||||
// random point above the nether surface
|
// random point above the nether surface
|
||||||
tempY = world.getHeight(new BlockPos(x, 0, z)).getY();
|
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());
|
return (pos == null ? new BlockPos(x, 1, z) : pos.down());
|
||||||
case ANYWHERE: default:
|
case ANYWHERE: default:
|
||||||
// random y coord
|
// random y coord
|
||||||
|
|
Loading…
Reference in a new issue