Search in sources :

Example 16 with Biome

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

the class TransformerNatural method transformBlock.

@Override
public void transformBlock(InstanceData instanceData, Phase phase, StructureSpawnContext context, BlockPos sourcePos, BlockPos pos, IBlockState sourceState, double density) {
    World world = context.environment.world;
    Biome biome = context.environment.biome;
    IBlockState topBlock = biome.topBlock != null ? biome.topBlock : Blocks.AIR.getDefaultState();
    IBlockState fillerBlock = biome.fillerBlock != null ? biome.fillerBlock : Blocks.AIR.getDefaultState();
    IBlockState mainBlock = Blocks.STONE.getDefaultState();
    boolean useStoneBlock = pos.getY() < world.getSeaLevel();
    IBlockState setBlock = useStoneBlock ? mainBlock : (instanceData.cloud.containsKey(sourcePos.up()) ? fillerBlock : topBlock);
    if (world.provider.getDimension() == -1)
        setBlock = Blocks.NETHERRACK.getDefaultState();
    else if (world.provider.getDimension() == 1)
        setBlock = Blocks.END_STONE.getDefaultState();
    context.setBlock(pos, setBlock, 2);
}
Also used : Biome(net.minecraft.world.biome.Biome) IBlockState(net.minecraft.block.state.IBlockState) World(net.minecraft.world.World)

Example 17 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 18 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 19 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 20 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)110 BlockPos (net.minecraft.util.math.BlockPos)39 IBlockState (net.minecraft.block.state.IBlockState)16 ResourceLocation (net.minecraft.util.ResourceLocation)9 World (net.minecraft.world.World)9 Nullable (javax.annotation.Nullable)8 Random (java.util.Random)7 ChunkPos (net.minecraft.util.math.ChunkPos)7 DoubleRange (com.almuradev.toolbox.util.math.DoubleRange)6 HashMap (java.util.HashMap)6 FunctionPredicate (com.almuradev.content.component.predicate.FunctionPredicate)5 Map (java.util.Map)5 Block (net.minecraft.block.Block)5 WorldServer (net.minecraft.world.WorldServer)5 BiomeChunk (com.almuradev.almura.feature.biome.BiomeChunk)4 Overwrite (org.spongepowered.asm.mixin.Overwrite)4 Entity (net.minecraft.entity.Entity)3 IntRange (com.almuradev.toolbox.util.math.IntRange)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2