Search in sources :

Example 56 with Biome

use of net.minecraft.world.biome.Biome in project NetherEx by LogicTechCorp.

the class ChunkProviderNether method prepareHeights.

@Override
public void prepareHeights(int chunkX, int chunkZ, ChunkPrimer primer) {
    buffer = generateHeightMap(buffer, chunkX * 4, 0, chunkZ * 4, 5, 17, 5);
    for (int x = 0; x < 4; x++) {
        for (int z = 0; z < 4; z++) {
            for (int y = 0; y < 16; y++) {
                double d1 = buffer[(x * 5 + z) * 17 + y];
                double d2 = buffer[(((x * 5) + z + 1) * 17) + y];
                double d3 = buffer[((((x + 1) * 5) + z) * 17) + y];
                double d4 = buffer[((x + 1) * 5 + z + 1) * 17 + y];
                double d5 = (buffer[(x * 5 + z) * 17 + y + 1] - d1) * 0.125D;
                double d6 = (buffer[(x * 5 + z + 1) * 17 + y + 1] - d2) * 0.125D;
                double d7 = (buffer[((x + 1) * 5 + z) * 17 + y + 1] - d3) * 0.125D;
                double d8 = (buffer[((x + 1) * 5 + z + 1) * 17 + y + 1] - d4) * 0.125D;
                for (int y2 = 0; y2 < 8; y2++) {
                    double d10 = d1;
                    double d11 = d2;
                    double d12 = (d3 - d1) * 0.25D;
                    double d13 = (d4 - d2) * 0.25D;
                    for (int x2 = 0; x2 < 4; x2++) {
                        double d15 = d10;
                        double d16 = (d11 - d10) * 0.25D;
                        for (int z2 = 0; z2 < 4; z2++) {
                            int posX = x2 + x * 4;
                            int posY = y2 + y * 8;
                            int posZ = z2 + z * 4;
                            Biome biome = biomesForGen[posX + posZ * 16];
                            IBlockState state = null;
                            NetherExBiomeType type = NetherExBiomeType.getTypeFromBiome(biome);
                            IBlockState oceanState = type.getBiomeOceanBlock(biome);
                            if (posY < 32) {
                                state = oceanState;
                            }
                            if (d15 > 0.0D) {
                                state = biome.fillerBlock;
                            }
                            primer.setBlockState(posX, posY, posZ, state);
                            d15 += d16;
                        }
                        d10 += d12;
                        d11 += d13;
                    }
                    d1 += d5;
                    d2 += d6;
                    d3 += d7;
                    d4 += d8;
                }
            }
        }
    }
}
Also used : NetherExBiomeType(nex.world.biome.NetherExBiomeType) Biome(net.minecraft.world.biome.Biome) IBlockState(net.minecraft.block.state.IBlockState)

Example 57 with Biome

use of net.minecraft.world.biome.Biome in project Pearcel-Mod by MiningMark48.

the class StructureGenPearcel1 method generate.

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    if (!(world instanceof WorldServer))
        return;
    if (!ConfigurationHandler.enableStructure1) {
        return;
    }
    WorldServer serverworld = (WorldServer) world;
    int x = chunkX * 16 + random.nextInt(16);
    int z = chunkZ * 16 + random.nextInt(16);
    BlockPos xzPos = new BlockPos(x, 1, z);
    Biome biome = world.getBiomeForCoordsBody(xzPos);
    if (biome == Biomes.PLAINS || biome == Biomes.DESERT || biome == Biomes.EXTREME_HILLS || biome == Biomes.BEACH || biome == Biomes.FOREST || biome == Biomes.FOREST_HILLS || biome == Biomes.ICE_PLAINS) {
        if (random.nextInt(ConfigurationHandler.structureRarity2) == 0) {
            //Rarity
            BlockPos pos = new BlockPos(x, WorldTools.findEmptySpot(world, x, z), z);
            generateStructure(serverworld, pos, random);
        }
    }
}
Also used : Biome(net.minecraft.world.biome.Biome) WorldServer(net.minecraft.world.WorldServer) BlockPos(net.minecraft.util.math.BlockPos)

Example 58 with Biome

use of net.minecraft.world.biome.Biome in project Pearcel-Mod by MiningMark48.

the class StructureGenPearcel3 method generate.

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    if (!(world instanceof WorldServer))
        return;
    if (!ConfigurationHandler.enableStructure3) {
        return;
    }
    WorldServer serverworld = (WorldServer) world;
    int x = chunkX * 16 + random.nextInt(16);
    int z = chunkZ * 16 + random.nextInt(16);
    BlockPos xzPos = new BlockPos(x, 1, z);
    Biome biome = world.getBiomeForCoordsBody(xzPos);
    if (biome == Biomes.PLAINS || biome == Biomes.DESERT || biome == Biomes.EXTREME_HILLS || biome == Biomes.FOREST || biome == Biomes.FOREST_HILLS) {
        if (random.nextInt(ConfigurationHandler.structureRarity1) == 2) {
            //Rarity
            BlockPos pos = new BlockPos(x, WorldTools.findEmptySpot(world, x, z) + 1, z);
            generateStructure(serverworld, pos, random);
        }
    }
}
Also used : Biome(net.minecraft.world.biome.Biome) WorldServer(net.minecraft.world.WorldServer) BlockPos(net.minecraft.util.math.BlockPos)

Example 59 with Biome

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

the class CommandSelectSetBiome method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    Biome biome = parameters.mc().biome().require();
    byte biomeID = (byte) (Biome.REGISTRY.getIDForObject(biome) & 255);
    World world = commandSender.getEntityWorld();
    // TODO Send to clients somehow
    BlockSurfaceArea.from(RCCommands.getSelectionOwner(commandSender, null, true).getSelection()).forEach(p -> {
        Chunk chunk = world.getChunkFromChunkCoords(p.getX() >> 4, p.getZ() >> 4);
        chunk.getBiomeArray()[biomeArrayIndex(p)] = biomeID;
        chunk.setModified(true);
    });
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) Biome(net.minecraft.world.biome.Biome) World(net.minecraft.world.World) Chunk(net.minecraft.world.chunk.Chunk)

Example 60 with Biome

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

the class WorldGenStructures method decorate.

public static boolean decorate(WorldServer world, Random random, ChunkPos chunkPos, @Nullable Predicate<Structure> structurePredicate) {
    boolean generated = false;
    boolean worldWantsStructures = world.getWorldInfo().isMapFeaturesEnabled();
    WorldStructureGenerationData data = WorldStructureGenerationData.get(world);
    // otherwise structures get lost in some chunks
    synchronized (data) {
        // TODO Synchronize on chunk pos instead (need to make sure these are only added on same sync though)
        // If not partially, complement before generating so we don't generate structures twice
        List<WorldStructureGenerationData.StructureEntry> complement = data.structureEntriesIn(chunkPos).collect(Collectors.toList());
        if (structurePredicate == null)
            data.checkChunk(chunkPos);
        if (!RecurrentComplex.PARTIALLY_SPAWN_NATURAL_STRUCTURES && structurePredicate == null)
            complementStructuresInChunk(chunkPos, world, complement);
        if ((!RCConfig.honorStructureGenerationOption || worldWantsStructures) && // If partially spawn, check chunks as having tried to add partial structures as into the thingy
        (structurePredicate == null || !RecurrentComplex.PARTIALLY_SPAWN_NATURAL_STRUCTURES || data.checkChunkFinal(chunkPos))) {
            Biome biomeGen = world.getBiome(chunkPos.getBlock(8, 0, 8));
            BlockPos spawnPos = world.getSpawnPoint();
            planStaticStructuresInChunk(random, chunkPos, world, spawnPos, structurePredicate);
            boolean mayGenerate = RCConfig.isGenerationEnabled(biomeGen) && RCConfig.isGenerationEnabled(world.provider);
            if (world.provider.getDimension() == 0) {
                double distToSpawn = IvVecMathHelper.distanceSQ(new double[] { chunkPos.x * 16 + 8, chunkPos.z * 16 + 8 }, new double[] { spawnPos.getX(), spawnPos.getZ() });
                mayGenerate &= distToSpawn >= RCConfig.minDistToSpawnForGeneration * RCConfig.minDistToSpawnForGeneration;
            }
            if (mayGenerate)
                planStructuresInChunk(random, chunkPos, world, biomeGen, structurePredicate);
            generated = true;
        }
        if (RecurrentComplex.PARTIALLY_SPAWN_NATURAL_STRUCTURES && structurePredicate == null)
            complementStructuresInChunk(chunkPos, world, complement);
    }
    return generated;
}
Also used : Biome(net.minecraft.world.biome.Biome) BlockPos(net.minecraft.util.math.BlockPos)

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