Fix issue when entities populator could check position outside world bounds for roofless and floorless worlds.

This commit is contained in:
BONNe1704 2019-02-01 11:05:47 +02:00
parent a14f076c65
commit ce6c85aef6

View File

@ -221,25 +221,28 @@ public class EntitiesPopulator extends BlockPopulator
break;
}
Block otherBlock = world.getBlockAt(block.getX(), block.getY() + 1, block.getZ());
if (!otherBlock.getType().equals(originalMaterial))
if (block.getY() > 1 && block.getY() < world.getMaxHeight() - 2)
{
otherBlock = world.getBlockAt(block.getX(), block.getY() - 1, block.getZ());
}
Block otherBlock = world.getBlockAt(block.getX(), block.getY() + 1, block.getZ());
if (otherBlock.getType().equals(originalMaterial))
{
block.setType(Material.CAVE_AIR);
otherBlock.setType(Material.CAVE_AIR);
if (otherBlock.getY() < block.getY())
if (!otherBlock.getType().equals(originalMaterial))
{
world.spawnEntity(otherBlock.getLocation(), entity);
otherBlock = world.getBlockAt(block.getX(), block.getY() - 1, block.getZ());
}
else
if (otherBlock.getType().equals(originalMaterial))
{
world.spawnEntity(block.getLocation(), entity);
block.setType(Material.CAVE_AIR);
otherBlock.setType(Material.CAVE_AIR);
if (otherBlock.getY() < block.getY())
{
world.spawnEntity(otherBlock.getLocation(), entity);
}
else
{
world.spawnEntity(block.getLocation(), entity);
}
}
}
}