use of net.minecraft.world.biome.Biome in project RFToolsDimensions by McJty.
the class BiomeControllerMapping method makeFilteredBiomeMap.
public static void makeFilteredBiomeMap(Map<Integer, Integer> map, ControllerType.BiomeFilter filter) {
map.clear();
// First check if there exist biomes for a certain filter.
boolean ok = false;
for (Biome biome : Biome.REGISTRY) {
if (biome != null) {
if (filter.match(biome)) {
ok = true;
break;
}
}
}
if (!ok) {
// No biomes found! We just map every biome to itself as a fallback.
for (Biome biome : Biome.REGISTRY) {
if (biome != null) {
map.put(Biome.getIdForBiome(biome), Biome.getIdForBiome(biome));
}
}
} else {
for (Biome biome : Biome.REGISTRY) {
if (biome != null) {
if (filter.match(biome)) {
map.put(Biome.getIdForBiome(biome), Biome.getIdForBiome(biome));
} else {
map.put(Biome.getIdForBiome(biome), findSuitableBiomes(biome, filter));
}
}
}
}
}
use of net.minecraft.world.biome.Biome in project RFToolsDimensions by McJty.
the class BiomeDimletType method constructDimension.
@Override
public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
Set<DimletKey> biomeKeys = new HashSet<DimletKey>();
List<Pair<DimletKey, List<DimletKey>>> biomeDimlets = DimensionInformation.extractType(DimletType.DIMLET_BIOME, dimlets);
List<Pair<DimletKey, List<DimletKey>>> controllerDimlets = DimensionInformation.extractType(DimletType.DIMLET_CONTROLLER, dimlets);
ControllerType controllerType;
// First determine the controller to use.
if (controllerDimlets.isEmpty()) {
if (random.nextFloat() < WorldgenConfiguration.randomControllerChance) {
DimletKey key = DimletRandomizer.getRandomController(random);
if (key != null) {
controllerType = DimletObjectMapping.getController(key);
} else {
controllerType = ControllerType.CONTROLLER_DEFAULT;
}
} else {
if (biomeDimlets.isEmpty()) {
controllerType = ControllerType.CONTROLLER_DEFAULT;
} else if (biomeDimlets.size() > 1) {
controllerType = ControllerType.CONTROLLER_FILTERED;
} else {
controllerType = ControllerType.CONTROLLER_SINGLE;
}
}
} else {
DimletKey key = controllerDimlets.get(random.nextInt(controllerDimlets.size())).getLeft();
controllerType = DimletObjectMapping.getController(key);
}
dimensionInformation.setControllerType(controllerType);
// Now see if we have to add or randomize biomes.
for (Pair<DimletKey, List<DimletKey>> dimletWithModifiers : biomeDimlets) {
DimletKey key = dimletWithModifiers.getKey();
biomeKeys.add(key);
}
int neededBiomes = controllerType.getNeededBiomes();
if (neededBiomes == -1) {
// Can work with any number of biomes.
if (biomeKeys.size() >= 2) {
// We already have enough biomes
neededBiomes = biomeKeys.size();
} else {
neededBiomes = random.nextInt(10) + 3;
}
}
while (biomeKeys.size() < neededBiomes) {
DimletKey key = DimletRandomizer.getRandomBiome(random);
while (key == null || biomeKeys.contains(key)) {
key = DimletRandomizer.getRandomBiome(random);
}
biomeKeys.add(key);
}
List<Biome> biomes = dimensionInformation.getBiomes();
biomes.clear();
for (DimletKey key : biomeKeys) {
biomes.add(DimletObjectMapping.getBiome(key));
}
}
use of net.minecraft.world.biome.Biome in project Pearcel-Mod by MiningMark48.
the class StructureGenPearcel2 method generate.
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
if (!(world instanceof WorldServer))
return;
if (!ConfigurationHandler.enableStructure2) {
return;
}
WorldServer serverworld = (WorldServer) world;
int x = chunkX * 16 + random.nextInt(16);
int z = chunkZ * 16 + random.nextInt(16);
BlockPos xzPos = new BlockPos(x, 1, z);
Biome biome = world.getBiomeForCoordsBody(xzPos);
if (biome == Biomes.PLAINS || biome == Biomes.DESERT || biome == Biomes.EXTREME_HILLS || biome == Biomes.BEACH || biome == Biomes.FOREST || biome == Biomes.FOREST_HILLS || biome == Biomes.ICE_PLAINS) {
if (random.nextInt(ConfigurationHandler.structureRarity2) == 1) {
//Rarity
BlockPos pos = new BlockPos(x, WorldTools.findEmptySpot(world, x, z) + 1, z);
generateStructure(serverworld, pos, random);
}
}
}
use of net.minecraft.world.biome.Biome in project Railcraft by Railcraft.
the class Populator method populate.
@SubscribeEvent
public final void populate(PopulateChunkEvent.Pre event) {
World world = event.getWorld();
if (!TerrainGen.populate(event.getGenerator(), world, event.getRand(), event.getChunkX(), event.getChunkZ(), event.isHasVillageGenerated(), eventType)) {
return;
}
BlockPos chunkCenterPos = new BlockPos(event.getChunkX() * 16 + 8, yHeight, event.getChunkZ() * 16 + 8);
Biome biome = world.getBiome(chunkCenterPos);
if (canGen(event.getWorld(), event.getRand(), chunkCenterPos, biome)) {
populate(event.getWorld(), event.getRand(), chunkCenterPos);
}
}
use of net.minecraft.world.biome.Biome in project Realistic-Terrain-Generation by Team-RTG.
the class WorldGenPond method generate.
@Override
public boolean generate(World world, Random rand, BlockPos pos) {
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
x -= 8;
for (z -= 8; y > 5 && world.isAirBlock(new BlockPos(x, y, z)); --y) {
;
}
if (y <= 4) {
return false;
} else {
y -= 4;
boolean[] aboolean = new boolean[2048];
int l = rand.nextInt(4) + 4;
int i1;
for (i1 = 0; i1 < l; ++i1) {
double d0 = rand.nextDouble() * 6.0D + 3.0D;
double d1 = rand.nextDouble() * 4.0D + 2.0D;
double d2 = rand.nextDouble() * 6.0D + 3.0D;
double d3 = rand.nextDouble() * (16.0D - d0 - 2.0D) + 1.0D + d0 / 2.0D;
double d4 = rand.nextDouble() * (8.0D - d1 - 4.0D) + 2.0D + d1 / 2.0D;
double d5 = rand.nextDouble() * (16.0D - d2 - 2.0D) + 1.0D + d2 / 2.0D;
for (int k1 = 1; k1 < 15; ++k1) {
for (int l1 = 1; l1 < 15; ++l1) {
for (int i2 = 1; i2 < 7; ++i2) {
double d6 = ((double) k1 - d3) / (d0 / 2.0D);
double d7 = ((double) i2 - d4) / (d1 / 2.0D);
double d8 = ((double) l1 - d5) / (d2 / 2.0D);
double d9 = d6 * d6 + d7 * d7 + d8 * d8;
if (d9 < 1.0D) {
aboolean[(k1 * 16 + l1) * 8 + i2] = true;
}
}
}
}
}
int j1;
int j2;
boolean flag;
// this algorithm can't put pond to the edge so we'll set all edges to not-pond
for (j1 = 0; j1 < 8; j1++) {
for (j2 = 0; j2 < 16; ++j2) {
i1 = 0;
aboolean[(i1 * 16 + j2) * 8 + j1] = false;
i1 = 15;
aboolean[(i1 * 16 + j2) * 8 + j1] = false;
}
for (i1 = 0; i1 < 16; ++i1) {
j2 = 0;
aboolean[(i1 * 16 + j2) * 8 + j1] = false;
j2 = 15;
aboolean[(i1 * 16 + j2) * 8 + j1] = false;
}
}
// Zeno410
// we're going to add some code to improve the sanity of the pond generation
// first let's make an array of what columns will be in the pond
boolean[] willBePond = new boolean[256];
for (i1 = 1; i1 < 15; ++i1) {
for (j2 = 1; j2 < 15; ++j2) {
for (//up to 4 because that becomes the material
j1 = 0; //up to 4 because that becomes the material
j1 < 4; //up to 4 because that becomes the material
++j1) {
if (aboolean[(i1 * 16 + j2) * 8 + j1]) {
willBePond[(i1 * 16 + j2)] = true;
}
}
}
}
// now let's get the lake edges
boolean[] willBeShore = new boolean[256];
for (i1 = 1; i1 < 14; ++i1) {
for (j2 = 1; j2 < 14; ++j2) {
if (willBePond[(i1 * 16 + j2)]) {
continue;
}
if (j2 < 15 && willBePond[(i1 * 16 + j2 + 1)]) {
willBeShore[(i1 * 16 + j2)] = true;
}
if (j2 > 0 && willBePond[(i1 * 16 + j2 - 1)]) {
willBeShore[(i1 * 16 + j2)] = true;
}
if (i1 < 15 && willBePond[((i1 + 1) * 16 + j2)]) {
willBeShore[(i1 * 16 + j2)] = true;
}
if (i1 > 0 && willBePond[((i1 - 1) * 16 + j2)]) {
willBeShore[(i1 * 16 + j2)] = true;
}
}
}
// now let's get the heights of the edges
int[] heightCounts = new int[257];
int shoreBlockCount = 0;
for (i1 = 1; i1 < 15; ++i1) {
for (j2 = 1; j2 < 15; ++j2) {
if (willBeShore[(i1 * 16 + j2)]) {
int topHeight = world.getTopSolidOrLiquidBlock(new BlockPos(x + i1, 0, z + j2)).getY();
if (topHeight < 1 || topHeight > 255) {
//empty or too high column
return false;
}
heightCounts[topHeight] += 1;
shoreBlockCount++;
}
}
}
// now get the median height and use for the lake level
// unless it's more than 1 above the lowest shore level;
int shoreSoFar = 0;
int lakeLevel = 0;
int bottomBlock = 257;
for (int height = 0; height < 257; height++) {
shoreSoFar += heightCounts[height];
if (heightCounts[height] > 0) {
if (bottomBlock > height) {
bottomBlock = height;
}
}
if (shoreSoFar * 2 >= shoreBlockCount) {
lakeLevel = height;
//if (lakeLevel - bottomBlock > 2) return false; //it was going to be ugly
if (lakeLevel > bottomBlock) {
lakeLevel = bottomBlock;
}
continue;
}
}
// set y to 3 below lake level so the top of the shore is the top of the lake level
y = lakeLevel - 4;
for (i1 = 0; i1 < 16; ++i1) {
for (j2 = 0; j2 < 16; ++j2) {
if (willBePond[(i1 * 16 + j2)]) {
int top = world.getTopSolidOrLiquidBlock(new BlockPos(x + i1, 0, z + j2)).getY();
if (top > lakeLevel + 4) {
return false;
}
}
}
}
// make sure the shore is at lake level
for (i1 = 1; i1 < 15; ++i1) {
for (j2 = 1; j2 < 15; ++j2) {
if (willBeShore[(i1 * 16 + j2)]) {
int shoreHeight = world.getTopSolidOrLiquidBlock(new BlockPos(x + i1, 0, z + j2)).getY();
if (shoreHeight < lakeLevel) {
Biome biomegenbase = world.getBiome(new BlockPos(x + i1, 0, z + j2));
for (int height = shoreHeight; height < lakeLevel; height++) {
if (biomegenbase.topBlock == Blocks.MYCELIUM.getDefaultState()) {
world.setBlockState(new BlockPos(x + i1, height, z + j2), Blocks.MYCELIUM.getDefaultState(), 2);
} else {
world.setBlockState(new BlockPos(x + i1, height, z + j2), Blocks.GRASS.getDefaultState(), 2);
}
}
}
}
}
}
for (i1 = 0; i1 < 16; ++i1) {
for (j2 = 0; j2 < 16; ++j2) {
for (j1 = 0; j1 < 8; ++j1) {
flag = !aboolean[(i1 * 16 + j2) * 8 + j1] && (i1 < 15 && aboolean[((i1 + 1) * 16 + j2) * 8 + j1] || i1 > 0 && aboolean[((i1 - 1) * 16 + j2) * 8 + j1] || j2 < 15 && aboolean[(i1 * 16 + j2 + 1) * 8 + j1] || j2 > 0 && aboolean[(i1 * 16 + (j2 - 1)) * 8 + j1] || j1 < 7 && aboolean[(i1 * 16 + j2) * 8 + j1 + 1] || j1 > 0 && aboolean[(i1 * 16 + j2) * 8 + (j1 - 1)]);
if (flag) {
Material material = world.getBlockState(new BlockPos(x + i1, y + j1, z + j2)).getMaterial();
if (j1 >= 4 && material.isLiquid()) {
return false;
}
if (j1 < 4 && !material.isSolid() && world.getBlockState(new BlockPos(x + i1, y + j1, z + j2)) != this.fill) {
return false;
}
}
}
}
}
for (i1 = 0; i1 < 16; ++i1) {
for (j2 = 0; j2 < 16; ++j2) {
for (j1 = 0; j1 < 8; ++j1) {
if (j1 < 4) {
if (aboolean[(i1 * 16 + j2) * 8 + j1]) {
world.setBlockState(new BlockPos(x + i1, y + j1, z + j2), fill, 2);
}
} else {
// air
if (willBePond[i1 * 16 + j2]) {
world.setBlockState(new BlockPos(x + i1, y + j1, z + j2), Blocks.AIR.getDefaultState(), 2);
}
}
}
}
}
for (i1 = 0; i1 < 16; ++i1) {
for (j2 = 0; j2 < 16; ++j2) {
for (j1 = 4; j1 < 8; ++j1) {
if (aboolean[(i1 * 16 + j2) * 8 + j1] && world.getBlockState(new BlockPos(x + i1, y + j1 - 1, z + j2)) == Blocks.DIRT.getDefaultState() && world.getLightFor(EnumSkyBlock.SKY, new BlockPos(x + i1, y + j1, z + j2)) > 0) {
Biome biomegenbase = world.getBiome(new BlockPos(x + i1, 0, z + j2));
if (biomegenbase.topBlock == Blocks.MYCELIUM.getDefaultState()) {
world.setBlockState(new BlockPos(x + i1, y + j1 - 1, z + j2), Blocks.MYCELIUM.getDefaultState(), 2);
} else {
world.setBlockState(new BlockPos(x + i1, y + j1 - 1, z + j2), biomegenbase.topBlock, 2);
}
}
}
}
}
if (this.fill.getMaterial() == Material.LAVA) {
for (i1 = 0; i1 < 16; ++i1) {
for (j2 = 0; j2 < 16; ++j2) {
for (j1 = 0; j1 < 8; ++j1) {
flag = !aboolean[(i1 * 16 + j2) * 8 + j1] && (i1 < 15 && aboolean[((i1 + 1) * 16 + j2) * 8 + j1] || i1 > 0 && aboolean[((i1 - 1) * 16 + j2) * 8 + j1] || j2 < 15 && aboolean[(i1 * 16 + j2 + 1) * 8 + j1] || j2 > 0 && aboolean[(i1 * 16 + (j2 - 1)) * 8 + j1] || j1 < 7 && aboolean[(i1 * 16 + j2) * 8 + j1 + 1] || j1 > 0 && aboolean[(i1 * 16 + j2) * 8 + (j1 - 1)]);
if (flag && (j1 < 4 || rand.nextInt(2) != 0) && world.getBlockState(new BlockPos(x + i1, y + j1, z + j2)).getMaterial().isSolid()) {
world.setBlockState(new BlockPos(x + i1, y + j1, z + j2), Blocks.STONE.getDefaultState(), 2);
}
}
}
}
}
if (this.fill.getMaterial() == Material.WATER) {
for (i1 = 0; i1 < 16; ++i1) {
for (j2 = 0; j2 < 16; ++j2) {
byte b0 = 4;
if (world.canBlockFreezeWater(new BlockPos(x + i1, y + b0, z + j2))) {
world.setBlockState(new BlockPos(x + i1, y + b0, z + j2), Blocks.ICE.getDefaultState(), 2);
}
}
}
}
// cut down shore above lake level
for (i1 = 1; i1 < 15; ++i1) {
for (j2 = 1; j2 < 15; ++j2) {
if (willBeShore[(i1 * 16 + j2)]) {
int shoreHeight = world.getTopSolidOrLiquidBlock(new BlockPos(x + i1, 0, z + j2)).getY();
if (shoreHeight > lakeLevel) {
shoreHeight--;
Biome biomegenbase = world.getBiome(new BlockPos(x + i1, 0, z + j2));
world.setBlockState(new BlockPos(x + i1, shoreHeight, z + j2), Blocks.AIR.getDefaultState(), 2);
shoreHeight--;
if (biomegenbase.topBlock == Blocks.MYCELIUM.getDefaultState()) {
world.setBlockState(new BlockPos(x + i1, shoreHeight, z + j2), Blocks.MYCELIUM.getDefaultState(), 2);
} else {
world.setBlockState(new BlockPos(x + i1, shoreHeight, z + j2), biomegenbase.topBlock, 2);
}
}
}
}
}
return true;
}
}
Aggregations