use of net.minecraft.world.gen.NetherChunkGenerator in project ChocolateQuestRepoured by TeamChocoQuest.
the class StructureHelper method isStructureInRange.
public static boolean isStructureInRange(World world, BlockPos pos, int radius, String name) {
if (!world.getWorldInfo().isMapFeaturesEnabled()) {
return false;
}
if (name.equals("AW2")) {
// check for aw2 structures
if (!CQRMain.isAW2Installed) {
return false;
}
return AW2Integration.isAW2StructureInRange(world, pos, radius);
}
ChunkGenerator chunkGenerator = ((ServerWorld) world).getChunkProvider().chunkGenerator;
if (chunkGenerator instanceof OverworldChunkGenerator || chunkGenerator instanceof NetherChunkGenerator || chunkGenerator instanceof EndChunkGenerator || chunkGenerator instanceof FlatChunkGenerator || chunkGenerator instanceof DebugChunkGenerator) {
// vanilla chunk generator
Structure structureGenerator = getStructureGenerator(world, name);
if (structureGenerator != null) {
return isStructureInRange(world, structureGenerator, pos, radius);
}
return false;
}
// modded chunk generator
BlockPos structurePos;
try {
structurePos = chunkGenerator.getNearestStructurePos(world, name, pos, false);
if (structurePos != null && (Math.abs(structurePos.getX() - pos.getX()) <= radius || Math.abs(structurePos.getZ() - pos.getZ()) <= radius)) {
return true;
}
} catch (NullPointerException e) {
// ignore
}
try {
structurePos = chunkGenerator.getNearestStructurePos(world, name, pos, true);
if (structurePos != null && (Math.abs(structurePos.getX() - pos.getX()) <= radius || Math.abs(structurePos.getZ() - pos.getZ()) <= radius)) {
return true;
}
} catch (NullPointerException e) {
// ignore
}
return false;
}
Aggregations