Search in sources :

Example 21 with BiomeGenBase

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));
    }
}
Also used : List(java.util.List) DimletKey(mcjty.rftoolsdim.dimensions.dimlets.DimletKey) ControllerType(mcjty.rftoolsdim.dimensions.types.ControllerType) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase) HashSet(java.util.HashSet) Pair(org.apache.commons.lang3.tuple.Pair)

Example 22 with BiomeGenBase

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

Example 23 with BiomeGenBase

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

Example 24 with BiomeGenBase

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

Example 25 with BiomeGenBase

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())));
}
Also used : ArrayList(java.util.ArrayList) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase) IBeeGenome(forestry.api.apiculture.IBeeGenome)

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