use of net.minecraft.world.biome.BiomeGenBase 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<BiomeGenBase> biomes = dimensionInformation.getBiomes();
biomes.clear();
for (DimletKey key : biomeKeys) {
biomes.add(DimletObjectMapping.getBiome(key));
}
}
use of net.minecraft.world.biome.BiomeGenBase in project ForestryMC by ForestryMC.
the class ItemHabitatLocator method getChunkCoordinates.
private static ChunkCoordinates getChunkCoordinates(Vect pos, World world, Collection<BiomeGenBase> biomesToSearch) {
// to avoid reporting very tiny patches, check around the point want
final int minBiomeRadius = 8;
BiomeGenBase biome;
biome = world.getBiomeGenForCoords(pos.x, pos.z);
if (!biomesToSearch.contains(biome)) {
return null;
}
biome = world.getBiomeGenForCoords(pos.x - minBiomeRadius, pos.z);
if (!biomesToSearch.contains(biome)) {
return null;
}
biome = world.getBiomeGenForCoords(pos.x + minBiomeRadius, pos.z);
if (!biomesToSearch.contains(biome)) {
return null;
}
biome = world.getBiomeGenForCoords(pos.x, pos.z - minBiomeRadius);
if (!biomesToSearch.contains(biome)) {
return null;
}
biome = world.getBiomeGenForCoords(pos.x, pos.z + minBiomeRadius);
if (!biomesToSearch.contains(biome)) {
return null;
}
return new ChunkCoordinates(pos.x, pos.y, pos.z);
}
use of net.minecraft.world.biome.BiomeGenBase in project ForestryMC by ForestryMC.
the class ItemHabitatLocator method addInformation.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) {
BiomeGenBase currentBiome = player.worldObj.getBiomeGenForCoords((int) player.posX, (int) player.posZ);
float temperatureValue = currentBiome.getFloatTemperature((int) player.posX, (int) player.posY, (int) player.posZ);
EnumTemperature temperature = EnumTemperature.getFromValue(temperatureValue);
EnumHumidity humidity = EnumHumidity.getFromValue(currentBiome.rainfall);
list.add(StringUtil.localize("gui.currentBiome") + ": " + currentBiome.biomeName);
list.add(StringUtil.localize("gui.temperature") + ": " + AlleleManager.climateHelper.toDisplay(temperature));
list.add(StringUtil.localize("gui.humidity") + ": " + AlleleManager.climateHelper.toDisplay(humidity));
}
use of net.minecraft.world.biome.BiomeGenBase in project ForestryMC by ForestryMC.
the class Bee method canWork.
@Override
public EnumErrorCode canWork(IBeeHousing housing) {
World world = housing.getWorld();
// / Rain needs tolerant flyers
if (world.isRaining() && !genome.getTolerantFlyer() && BiomeHelper.canRainOrSnow(housing.getBiomeId()) && !housing.isSealed()) {
return EnumErrorCode.ISRAINING;
}
// / Night or darkness requires nocturnal species
if (world.isDaytime()) {
if (!canWorkDuringDay()) {
return EnumErrorCode.NOTNIGHT;
}
} else if (!canWorkAtNight() && !housing.isSelfLighted()) {
return EnumErrorCode.NOTDAY;
}
if (world.getBlockLightValue(housing.getXCoord(), housing.getYCoord() + 2, housing.getZCoord()) > Defaults.APIARY_MIN_LEVEL_LIGHT) {
if (!canWorkDuringDay()) {
return EnumErrorCode.NOTGLOOMY;
}
} else if (!canWorkAtNight() && !housing.isSelfLighted()) {
return EnumErrorCode.NOTLUCID;
}
// / No sky, except if in hell
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
if (biome == null) {
return EnumErrorCode.NOSKY;
}
if (!BiomeHelper.isBiomeHellish(biome) && !world.canBlockSeeTheSky(housing.getXCoord(), housing.getYCoord() + 3, housing.getZCoord()) && !genome.getCaveDwelling() && !housing.isSunlightSimulated()) {
return EnumErrorCode.NOSKY;
}
// / And finally climate check
if (!isSuitableClimate(housing.getTemperature(), housing.getHumidity())) {
return EnumErrorCode.INVALIDBIOME;
}
return EnumErrorCode.OK;
}
use of net.minecraft.world.biome.BiomeGenBase in project ForestryMC by ForestryMC.
the class ComponentVillageBeeHouse method getVillageBee.
private IBee getVillageBee(World world, int xCoord, int yCoord, int zCoord) {
// Get current biome
BiomeGenBase biome = world.getBiomeGenForCoords(xCoord, zCoord);
ArrayList<IBeeGenome> candidates;
if (BeeManager.villageBees[1] != null && BeeManager.villageBees[1].size() > 0 && world.rand.nextDouble() < 0.2) {
candidates = BeeManager.villageBees[1];
} else {
candidates = BeeManager.villageBees[0];
}
// Add bees that can live in this environment
ArrayList<IBeeGenome> valid = new ArrayList<IBeeGenome>();
for (IBeeGenome genome : candidates) {
if (checkBiomeHazard(genome, biome.temperature, biome.rainfall)) {
valid.add(genome);
}
}
// No valid ones found, return any of the common ones.
if (valid.isEmpty()) {
return PluginApiculture.beeInterface.getBee(world, BeeManager.villageBees[0].get(world.rand.nextInt(BeeManager.villageBees[0].size())));
}
return PluginApiculture.beeInterface.getBee(world, valid.get(world.rand.nextInt(valid.size())));
}
Aggregations