Search in sources :

Example 26 with BiomeGenBase

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;
}
Also used : EnumHumidity(forestry.api.core.EnumHumidity) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Example 27 with BiomeGenBase

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);
}
Also used : BiomeGenBase(net.minecraft.world.biome.BiomeGenBase) EnumTemperature(forestry.api.core.EnumTemperature)

Example 28 with BiomeGenBase

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;
}
Also used : BiomeDictionary(net.minecraftforge.common.BiomeDictionary) World(net.minecraft.world.World) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase) IBeeGenome(forestry.api.apiculture.IBeeGenome)

Example 29 with BiomeGenBase

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;
}
Also used : BiomeGenBase(net.minecraft.world.biome.BiomeGenBase) ITreeGenome(forestry.api.arboriculture.ITreeGenome)

Example 30 with BiomeGenBase

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);
        }
    }
}
Also used : BiomeGenBase(net.minecraft.world.biome.BiomeGenBase)

Aggregations

BiomeGenBase (net.minecraft.world.biome.BiomeGenBase)62 Block (net.minecraft.block.Block)9 BlockPos (net.minecraft.util.BlockPos)9 World (net.minecraft.world.World)6 Type (net.minecraftforge.common.BiomeDictionary.Type)5 ArrayList (java.util.ArrayList)4 EnumHumidity (forestry.api.core.EnumHumidity)3 IBlockState (net.minecraft.block.state.IBlockState)3 ChunkCoordIntPair (net.minecraft.world.ChunkCoordIntPair)3 Chunk (net.minecraft.world.chunk.Chunk)3 BiomeDictionary (net.minecraftforge.common.BiomeDictionary)3 HashMultimap (com.google.common.collect.HashMultimap)2 Multimap (com.google.common.collect.Multimap)2 IBeeGenome (forestry.api.apiculture.IBeeGenome)2 EnumTemperature (forestry.api.core.EnumTemperature)2 HashSet (java.util.HashSet)2 Random (java.util.Random)2 UUID (java.util.UUID)2 Entity (net.minecraft.entity.Entity)2 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)2