Skip to content

Commit

Permalink
chore: crash prevention
Browse files Browse the repository at this point in the history
  • Loading branch information
Naimadx123 committed Feb 11, 2025
1 parent 82b575e commit ee3faf9
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,21 @@ private PlacementPosition getAdjacentPlacementPosition(PlacementPosition start,
}

private PlacementPosition getRandomPlacementPosition(int chunkX, int chunkZ, LimitedRegion limitedRegion, Ore ore, Random random, WorldInfo worldInfo) {
int x = (chunkX << 4) + random.nextInt(16);
int z = (chunkZ << 4) + random.nextInt(16);
int y = ore.getMinLevel() + random.nextInt(ore.getMaxLevel() - ore.getMinLevel() + 1);
try {
int x = (chunkX << 4) + random.nextInt(16);
int z = (chunkZ << 4) + random.nextInt(16);
int y = ore.getMinLevel() + random.nextInt(ore.getMaxLevel() - ore.getMinLevel() + 1);

if (!limitedRegion.isInRegion(x, y, z)) return null;
if (!limitedRegion.isInRegion(x, y, z))
return null;

Material blockType = limitedRegion.getType(x, y, z);
Biome biome = limitedRegion.getBiome(x, y, z);
Material blockType = limitedRegion.getType(x, y, z);
Biome biome = limitedRegion.getBiome(x, y, z);

return new PlacementPosition(worldInfo, x, y, z, blockType, biome, limitedRegion);
return new PlacementPosition(worldInfo, x, y, z, blockType, biome, limitedRegion);
}catch(Exception ignored){
return null;
}
}

private boolean canReplaceBlock(PlacementPosition position, Ore ore) {
Expand Down

0 comments on commit ee3faf9

Please sign in to comment.