use of net.minecraft.world.biome.BiomeGenBase in project ForestryMC by ForestryMC.
the class HiveDecorator method genHive.
public boolean genHive(World world, Random rand, int chunkX, int chunkZ, Hive hive) {
if (hive.genChance() * Config.getBeehivesRate() < rand.nextFloat() * 100.0f) {
return false;
}
int worldX = chunkX * 16;
int worldZ = chunkZ * 16;
BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ);
EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);
if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity)) {
return false;
}
for (int tries = 0; tries < 4; tries++) {
int x = worldX + rand.nextInt(16);
int z = worldZ + rand.nextInt(16);
if (tryGenHive(world, x, z, hive)) {
return true;
}
}
return false;
}
use of net.minecraft.world.biome.BiomeGenBase in project ForestryMC by ForestryMC.
the class HiveDecorator method tryGenHive.
private boolean tryGenHive(World world, int x, int z, Hive hive) {
int y = hive.getYForHive(world, x, z);
if (y < 0) {
return false;
}
if (!hive.canReplace(world, x, y, z)) {
return false;
}
BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
EnumTemperature temperature = EnumTemperature.getFromValue(biome.getFloatTemperature(x, y, z));
if (!hive.isGoodTemperature(temperature)) {
return false;
}
if (!hive.isValidLocation(world, x, y, z)) {
return false;
}
return setHive(world, x, y, z, hive);
}
use of net.minecraft.world.biome.BiomeGenBase in project ForestryMC by ForestryMC.
the class BeeMutation method getChance.
@Override
public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
World world = housing.getWorld();
if (requiresDay && !world.isDaytime()) {
return 0;
}
if (requiresNight && world.isDaytime()) {
return 0;
}
// Skip if we are restricted by biomes and this one does not match.
if (restrictBiomeTypes.size() > 0) {
boolean noneMatched = true;
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
if (strictBiomeCheck) {
BiomeDictionary.Type[] types = BiomeDictionary.getTypesForBiome(biome);
if (types.length == 1 && restrictBiomeTypes.contains(types[0])) {
noneMatched = false;
}
} else {
for (BiomeDictionary.Type type : restrictBiomeTypes) {
if (BiomeDictionary.isBiomeOfType(biome, type)) {
noneMatched = false;
break;
}
}
}
if (noneMatched) {
return 0;
}
}
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(housing.getXCoord(), housing.getZCoord());
if (biome.temperature < minTemperature || biome.temperature > maxTemperature) {
return 0;
}
if (biome.rainfall < minRainfall || biome.rainfall > maxRainfall) {
return 0;
}
float processedChance = chance * housing.getMutationModifier((IBeeGenome) genome0, (IBeeGenome) genome1, 1f) * PluginApiculture.beeInterface.getBeekeepingMode(world).getMutationModifier((IBeeGenome) genome0, (IBeeGenome) genome1, 1f);
if (processedChance <= 0) {
return 0;
}
if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID())) {
return processedChance;
}
if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID())) {
return processedChance;
}
return 0;
}
use of net.minecraft.world.biome.BiomeGenBase in project ForestryMC by ForestryMC.
the class TreeMutation method getChance.
@Override
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
float processedChance = chance;
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x, z);
if (biome.temperature < minTemperature || biome.temperature > maxTemperature) {
return 0;
}
if (biome.rainfall < minRainfall || biome.rainfall > maxRainfall) {
return 0;
}
processedChance *= PluginArboriculture.treeInterface.getTreekeepingMode(world).getMutationModifier((ITreeGenome) genome0, (ITreeGenome) genome1, 1f);
if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID())) {
return processedChance;
}
if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID())) {
return processedChance;
}
return 0;
}
use of net.minecraft.world.biome.BiomeGenBase in project BloodMagic by WayofTime.
the class OmegaArmour method onArmorTick.
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
super.onArmorTick(world, player, itemStack);
if (world.getWorldTime() % 50 == 0) {
if (this.storeBiomeID()) {
int xCoord = (int) Math.floor(player.posX);
int zCoord = (int) Math.floor(player.posZ);
BiomeGenBase biome = world.getBiomeGenForCoords(xCoord, zCoord);
if (biome != null) {
this.setBiomeIDStored(itemStack, biome.biomeID);
}
}
if (this.storeDimensionID()) {
this.setDimensionIDStored(itemStack, world.provider.dimensionId);
}
if (this.storeYLevel()) {
this.setYLevelStored(itemStack, (int) Math.floor(player.posY));
}
}
if (this.armorType == 1) {
paradigm.onUpdate(world, player, itemStack);
int duration = this.getOmegaStallingDuration(itemStack);
if (duration > 0) {
this.setOmegaStallingDuration(itemStack, duration - 1);
}
}
}
Aggregations