public static int getBlacklistBiomeIDWithinRange(World world, int x, int z, int radius) { FRLog.debug("Checking Biomes..."); float reciprocalRootOf2 = 0.70710678f; int adjRadius = Math.round(radius * reciprocalRootOf2); BlockPos pos = new BlockPos(x, 64, z); EnumFacing[] NSEW = EnumFacing.values(); int biomeID = world.getBiomeGenForCoords(pos).biomeID; if (CommonUtils.isIDInList(biomeID, biomeIDBlacklist)) return biomeID; for (EnumFacing fd : NSEW) { for (int i = radius; i > 0; i = i - 2) { biomeID = world.getBiomeGenForCoords(pos.offset(fd, i)).biomeID; if (CommonUtils.isIDInList(biomeID, biomeIDBlacklist)) return biomeID; } } for (int ns = 0; ns < 2; ns++) for (int ew = 2; ew < 4; ew++) for (int r = adjRadius; r > 0; r = r - 2) { biomeID = world.getBiomeGenForCoords(pos.offset(NSEW[ns], r).offset(NSEW[ew], r)).biomeID; if (CommonUtils.isIDInList(biomeID, biomeIDBlacklist)) return biomeID; } return -1; }
/** * Method used during world generation that calculates all necessary generation variables and * determines if this x,z location is suitable for island generation. If conditions are met * doGenerateSurface() is called. */ public static void generateSurface(World world, Random random, int x, int z, boolean isWorldGen) { if (((world.getWorldInfo().getTerrainType() != WorldType.FLAT) || allowInSuperFlat)) { if (!CommonUtils.isIDInList(world.provider.getDimensionId(), dimensionIDBlacklist)) { random = getRandom(world, new BlockPos(x, 1, z)); int tgtY = getWeightedInt(heightMin, heightMean, heightMax, heightNorm, random); if (isWorldGen) { x += random.nextInt(16); z += random.nextInt(16); } BlockPos tgt = new BlockPos(x, tgtY, z); WorldGenFloatingIsland islandGenerator = getFloatingIslandGenerator(world, random, tgt); BlockPos tgtGround = new BlockPos(x, islandGenerator.yGround, z); if (!isWorldGen || (random.nextInt(rarity) == 0)) { FRLog.debug("Checking for region suitability..."); String debug = ""; int biomeID = getBlacklistBiomeIDWithinRange(world, x, z, islandGenerator.radius); if (isWorldGen && (biomeID > -1)) { debug = "Location %d,%d skipped due to proximity of a biomeID (%d) in the biomeIDBlackList"; debug(debug, x, z, biomeID); } else if (isWorldGen && isVillageNearby(world, tgtGround, islandGenerator.radius)) { debug = "Location %d, %d skipped due to a village being found nearby"; debug(debug, x, z); } else if (!doGenerateSurface(world, random, tgt, islandGenerator)) { debug = "Location %d, %d failed during island generation"; debug(debug, x, z); } } } } }
/** * Randomly calculates the variables needed to create a WorldGenFloatingIsland object and returns * a new WorldGenFloatingIsland object */ public static WorldGenFloatingIsland getFloatingIslandGenerator( World world, Random random, BlockPos pos) { int radius = getWeightedInt(radiusMin, radiusMean, radiusMax, radiusNorm, random); int yGround = CommonUtils.getHighestGroundBlock(world, pos); int depth = getWeightedInt(depthMin, depthMean, depthMax, depthNorm, random); int islandType = getWeightedIslandType(random); WorldType wt = world.getWorldInfo().getTerrainType(); if (depth > (yGround - (wt == WorldType.FLAT ? 1 : 5))) depth = yGround - (wt == WorldType.FLAT ? 1 : 5); return new WorldGenFloatingIsland(radius, depth, yGround, islandType); }