Search in sources :

Example 21 with Biome

use of net.minecraft.world.biome.Biome in project RecurrentComplex by Ivorforce.

the class WorldGenStructures method planStructuresInChunk.

public static void planStructuresInChunk(Random random, ChunkPos chunkPos, WorldServer world, Biome biomeGen, @Nullable Predicate<Structure> structurePredicate) {
    MixingStructureSelector<NaturalGeneration, NaturalStructureSelector.Category> structureSelector = StructureRegistry.INSTANCE.naturalStructureSelectors().get(biomeGen, world.provider);
    float distanceToSpawn = distance(new ChunkPos(world.getSpawnPoint()), chunkPos);
    // TODO Use STRUCTURE_TRIES
    List<Pair<Structure<?>, NaturalGeneration>> generated = structureSelector.generatedStructures(random, world.getBiome(chunkPos.getBlock(0, 0, 0)), world.provider, distanceToSpawn);
    generated.stream().filter(pair -> structurePredicate == null || structurePredicate.test(pair.getLeft())).forEach(pair -> planStructureInChunk(chunkPos, world, pair.getLeft(), pair.getRight(), random.nextLong()));
}
Also used : BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos) NaturalStructureSelector(ivorius.reccomplex.world.gen.feature.selector.NaturalStructureSelector) StaticGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.StaticGeneration) Structures(ivorius.reccomplex.world.gen.feature.structure.Structures) Predicate(java.util.function.Predicate) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) StructureSpawnContext(ivorius.reccomplex.world.gen.feature.structure.context.StructureSpawnContext) StructureRegistry(ivorius.reccomplex.world.gen.feature.structure.StructureRegistry) ChunkPos(net.minecraft.util.math.ChunkPos) BlockPos(net.minecraft.util.math.BlockPos) Random(java.util.Random) RCConfig(ivorius.reccomplex.RCConfig) Collectors(java.util.stream.Collectors) List(java.util.List) Pair(org.apache.commons.lang3.tuple.Pair) MathHelper(net.minecraft.util.math.MathHelper) MixingStructureSelector(ivorius.reccomplex.world.gen.feature.selector.MixingStructureSelector) NaturalGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.NaturalGeneration) RecurrentComplex(ivorius.reccomplex.RecurrentComplex) WorldServer(net.minecraft.world.WorldServer) IvVecMathHelper(ivorius.ivtoolkit.math.IvVecMathHelper) Biome(net.minecraft.world.biome.Biome) Nullable(javax.annotation.Nullable) ChunkPos(net.minecraft.util.math.ChunkPos) NaturalGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.NaturalGeneration) Pair(org.apache.commons.lang3.tuple.Pair)

Example 22 with Biome

use of net.minecraft.world.biome.Biome in project RecurrentComplex by Ivorforce.

the class RCBiomeDecorator method doDecorate.

protected static int doDecorate(WorldServer worldIn, Random random, BlockPos blockPos, DecorationType type, int amount, boolean lowChance) {
    ChunkPos chunkPos = new ChunkPos(blockPos);
    double baseWeight = RCConfig.baseDecorationWeights.get(type);
    if (baseWeight <= 0)
        return amount;
    Biome biomeIn = worldIn.getBiome(chunkPos.getBlock(16, 0, 16));
    StructureSelector<VanillaDecorationGeneration, DecorationType> selector = StructureRegistry.INSTANCE.decorationSelectors().get(biomeIn, worldIn.provider);
    double totalWeight = selector.totalWeight(type);
    if (totalWeight <= 0)
        return amount;
    return trySurface(worldIn, random, chunkPos, selector, type, totalWeight, baseWeight, amount, lowChance);
}
Also used : Biome(net.minecraft.world.biome.Biome) VanillaDecorationGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.VanillaDecorationGeneration) ChunkPos(net.minecraft.util.math.ChunkPos)

Example 23 with Biome

use of net.minecraft.world.biome.Biome in project RecurrentComplex by Ivorforce.

the class RCBiomeDecorator method doDecorate.

protected static Event.Result doDecorate(WorldServer worldIn, Random random, BlockPos chunkPos, DecorationType type) {
    Biome biomeIn = worldIn.getBiome(chunkPos.add(16, 0, 16));
    BiomeDecorator decorator = biomeIn.decorator;
    Adapter adapter = adapter(worldIn, chunkPos, type, biomeIn, decorator);
    int origAmount = adapter.amount(worldIn, random, biomeIn, decorator, chunkPos, type);
    // Don't interfere
    if (origAmount < 0)
        return null;
    int vanillaAmount = doDecorate(worldIn, random, chunkPos, type, origAmount, adapter.mayGiveUp(worldIn, random, biomeIn, decorator, chunkPos, type));
    // Replaced none, might as well give back
    if (vanillaAmount == origAmount)
        return null;
    for (int i = 0; i < vanillaAmount; ++i) adapter.generate(worldIn, random, biomeIn, decorator, chunkPos, type);
    // if < 0 we let vanilla do its thing
    return vanillaAmount >= 0 ? Event.Result.DENY : null;
}
Also used : Biome(net.minecraft.world.biome.Biome) BiomeDecorator(net.minecraft.world.biome.BiomeDecorator)

Example 24 with Biome

use of net.minecraft.world.biome.Biome in project BetterWithAddons by DaedalusGame.

the class TileEntityLureTree method attractAnimals.

public boolean attractAnimals(int amt) {
    Random random = world.rand;
    Biome biome = world.getBiome(pos);
    int spawned = 0;
    if (biome != null) {
        List<Biome.SpawnListEntry> spawnable = biome.getSpawnableList(EnumCreatureType.CREATURE);
        if (!spawnable.isEmpty())
            for (int i = 0; i < amt; i++) {
                Biome.SpawnListEntry entry = WeightedRandom.getRandomItem(random, spawnable);
                int x = pos.getX() + random.nextInt(InteractionBWA.RADIUS * 2 + 1) - InteractionBWA.RADIUS;
                int z = pos.getZ() + random.nextInt(InteractionBWA.RADIUS * 2 + 1) - InteractionBWA.RADIUS;
                if (!BLACKLIST.contains(entry.entityClass)) {
                    for (int y = pos.getY(); y > pos.getY() - 4; y--) {
                        BlockPos pos = new BlockPos(x, y, z);
                        if (world.isAirBlock(pos) && WorldEntitySpawner.canCreatureTypeSpawnAtLocation(EntityLiving.SpawnPlacementType.ON_GROUND, world, pos)) {
                            EntityLiving entityliving;
                            try {
                                entityliving = entry.entityClass.getConstructor(new Class[] { World.class }).newInstance(new Object[] { world });
                            } catch (Exception exception) {
                                exception.printStackTrace();
                                continue;
                            }
                            entityliving.setLocationAndAngles(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, random.nextFloat() * 360.0F, 0.0F);
                            world.spawnEntity(entityliving);
                            if (entityliving != null) {
                                entityliving.spawnExplosionParticle();
                                spawned++;
                            }
                            break;
                        } else if (world.isSideSolid(pos, EnumFacing.UP)) {
                            break;
                        }
                    }
                }
            }
    }
    return spawned > 0;
}
Also used : Biome(net.minecraft.world.biome.Biome) Random(java.util.Random) EntityLiving(net.minecraft.entity.EntityLiving) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World)

Example 25 with Biome

use of net.minecraft.world.biome.Biome in project BetterWithAddons by DaedalusGame.

the class BlockWorldScaleOre method exposedToElements.

public boolean exposedToElements(World world, BlockPos pos) {
    Biome biome = world.getBiome(pos);
    boolean isHot = biome.getTempCategory() == Biome.TempCategory.WARM;
    boolean isRaining = world.isRainingAt(pos);
    boolean isCold = biome.isSnowyBiome();
    boolean isHumid = biome.canRain();
    boolean isDaytime = world.isDaytime();
    boolean isWaterAbove = world.getBlockState(pos.up()).getMaterial() == Material.WATER;
    if (//TODO: Switch this out for a lens check maybe. That would push it back in the tech tree :/
    isHot && !isHumid && isDaytime)
        return true;
    if (isCold && isRaining)
        return true;
    if (isWaterAbove)
        return true;
    return false;
}
Also used : Biome(net.minecraft.world.biome.Biome)

Aggregations

Biome (net.minecraft.world.biome.Biome)66 BlockPos (net.minecraft.util.math.BlockPos)17 IBlockState (net.minecraft.block.state.IBlockState)8 World (net.minecraft.world.World)5 WorldServer (net.minecraft.world.WorldServer)5 Random (java.util.Random)4 Block (net.minecraft.block.Block)4 ChunkPos (net.minecraft.util.math.ChunkPos)4 ResourceLocation (net.minecraft.util.ResourceLocation)3 List (java.util.List)2 ChunkProviderSettings (net.minecraft.world.gen.ChunkProviderSettings)2 ChunkGeneratorEvent (net.minecraftforge.event.terraingen.ChunkGeneratorEvent)2 NetherExBiomeType (nex.world.biome.NetherExBiomeType)2 Pair (org.apache.commons.lang3.tuple.Pair)2 IRealisticBiome (rtg.api.world.biome.IRealisticBiome)2 RealisticBiomeBase (rtg.world.biome.realistic.RealisticBiomeBase)2 Gson (com.google.gson.Gson)1 BlockSurfacePos (ivorius.ivtoolkit.blocks.BlockSurfacePos)1 IvVecMathHelper (ivorius.ivtoolkit.math.IvVecMathHelper)1 RCConfig (ivorius.reccomplex.RCConfig)1