Search in sources :

Example 26 with ChunkPos

use of net.minecraft.util.math.ChunkPos in project RecurrentComplex by Ivorforce.

the class WorldGenStructures method generateRandomStructureInChunk.

public static boolean generateRandomStructureInChunk(Random random, ChunkPos chunkPos, WorldServer world, Biome biomeGen) {
    MixingStructureSelector<NaturalGeneration, NaturalStructureSelector.Category> structureSelector = StructureRegistry.INSTANCE.naturalStructureSelectors().get(biomeGen, world.provider);
    float distanceToSpawn = distance(new ChunkPos(world.getSpawnPoint()), chunkPos);
    for (int i = 0; i < STRUCTURE_TRIES; i++) {
        Pair<Structure<?>, NaturalGeneration> pair = structureSelector.selectOne(random, world.provider, world.getBiome(chunkPos.getBlock(0, 0, 0)), null, distanceToSpawn);
        if (pair != null) {
            if (planStructureInChunk(chunkPos, world, pair.getLeft(), pair.getRight(), random.nextLong()))
                return true;
        }
    }
    return false;
}
Also used : ChunkPos(net.minecraft.util.math.ChunkPos) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) NaturalGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.NaturalGeneration)

Example 27 with ChunkPos

use of net.minecraft.util.math.ChunkPos in project Realistic-Terrain-Generation by Team-RTG.

the class MapGenStrongholdRTG method getClosestStrongholdPos.

public BlockPos getClosestStrongholdPos(World worldIn, BlockPos pos) {
    if (!this.ranBiomeCheck) {
        this.generatePositions();
        this.ranBiomeCheck = true;
    }
    BlockPos blockpos = null;
    BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(0, 0, 0);
    double d0 = Double.MAX_VALUE;
    for (ChunkPos chunkpos : this.structureCoords) {
        blockpos$mutableblockpos.setPos((chunkpos.chunkXPos << 4) + 8, 32, (chunkpos.chunkZPos << 4) + 8);
        double d1 = blockpos$mutableblockpos.distanceSq(pos);
        if (blockpos == null) {
            blockpos = new BlockPos(blockpos$mutableblockpos);
            d0 = d1;
        } else if (d1 < d0) {
            blockpos = new BlockPos(blockpos$mutableblockpos);
            d0 = d1;
        }
    }
    return blockpos;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) ChunkPos(net.minecraft.util.math.ChunkPos)

Example 28 with ChunkPos

use of net.minecraft.util.math.ChunkPos in project Realistic-Terrain-Generation by Team-RTG.

the class VolcanoGenerator method generateMapGen.

public void generateMapGen(ChunkPrimer primer, Long unusedSeed, World world, IBiomeProviderRTG cmr, Random unusedMapRand, int chunkX, int chunkY, OpenSimplexNoise simplex, CellNoise cell, float[] noise) {
    // Have volcanoes been disabled in the global config?
    if (!rtgConfig.ENABLE_VOLCANOES.get())
        return;
    final int mapGenRadius = 5;
    final int volcanoGenRadius = 15;
    // Volcanoes generation
    for (int baseX = chunkX - volcanoGenRadius; baseX <= chunkX + volcanoGenRadius; baseX++) {
        for (int baseY = chunkY - volcanoGenRadius; baseY <= chunkY + volcanoGenRadius; baseY++) {
            ChunkPos probe = new ChunkPos(baseX, baseY);
            if (noVolcano.contains(probe))
                continue;
            noVolcano.add(probe);
            mapRand.setSeed((long) baseX * l + (long) baseY * l1 ^ seed);
            rMapVolcanoes(primer, world, cmr, baseX, baseY, chunkX, chunkY, simplex, cell, noise);
        }
    }
}
Also used : ChunkPos(net.minecraft.util.math.ChunkPos)

Example 29 with ChunkPos

use of net.minecraft.util.math.ChunkPos in project Realistic-Terrain-Generation by Team-RTG.

the class LandscapeGenerator method noiseFor.

public float[] noiseFor(IBiomeProviderRTG cmr, int worldX, int worldZ) {
    ChunkPos location = new ChunkPos(worldX, worldZ);
    ChunkLandscape landscape = storage.get(location);
    float[] result = cache.get(landscape);
    if (result != null)
        return result;
    // not found; we have to make it;
    result = new float[256];
    // seems off? but decorations aren't matching their chunks.
    final int adjust = 24;
    TimeTracker.manager.start("Biome Layout");
    for (int bx = -4; bx <= 4; bx++) {
        for (int bz = -4; bz <= 4; bz++) {
            result[getBiomeDataAt(cmr, worldX + adjust + bx * 4, worldZ + adjust + bz * 4)] += 0.01234569f;
        }
    }
    TimeTracker.manager.stop("Biome Layout");
    TimeTracker.manager.stop("Features");
    cache.put(landscape, result);
    return result;
}
Also used : ChunkPos(net.minecraft.util.math.ChunkPos)

Example 30 with ChunkPos

use of net.minecraft.util.math.ChunkPos in project Realistic-Terrain-Generation by Team-RTG.

the class RealisticBiomeBase method rDecorate.

public void rDecorate(RTGWorld rtgWorld, Random rand, int worldX, int worldZ, float strength, float river, boolean hasPlacedVillageBlocks) {
    ArrayList<DecoBase> decos = this.getDecos();
    for (DecoBase deco : decos) {
        decoStack.add(new ChunkDecoration(new ChunkPos(worldX, worldZ), deco));
        if (decoStack.size() > 20) {
            String problem = "";
            for (ChunkDecoration inStack : decoStack) {
                problem += "" + inStack.chunkLocation.toString() + " " + inStack.decoration.getClass().getSimpleName();
            }
            throw new RuntimeException(problem);
        }
        if (deco.preGenerate(this, rtgWorld, rand, worldX, worldZ, strength, river, hasPlacedVillageBlocks)) {
            deco.generate(this, rtgWorld, rand, worldX, worldZ, strength, river, hasPlacedVillageBlocks);
        }
        decoStack.remove(decoStack.size() - 1);
    }
}
Also used : ChunkPos(net.minecraft.util.math.ChunkPos) DecoBase(rtg.api.world.deco.DecoBase)

Aggregations

ChunkPos (net.minecraft.util.math.ChunkPos)41 BlockPos (net.minecraft.util.math.BlockPos)15 Biome (net.minecraft.world.biome.Biome)7 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 NBTTagList (net.minecraft.nbt.NBTTagList)6 Random (java.util.Random)5 WorldServer (net.minecraft.world.WorldServer)5 Structure (ivorius.reccomplex.world.gen.feature.structure.Structure)3 World (net.minecraft.world.World)3 WorldGenLiquidLakes (stevekung.mods.moreplanets.util.world.gen.feature.WorldGenLiquidLakes)3 WorldGenSpaceDungeons (stevekung.mods.moreplanets.util.world.gen.feature.WorldGenSpaceDungeons)3 StructureSpawnContext (ivorius.reccomplex.world.gen.feature.structure.context.StructureSpawnContext)2 NaturalGeneration (ivorius.reccomplex.world.gen.feature.structure.generic.generation.NaturalGeneration)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 ItemStack (net.minecraft.item.ItemStack)2 SPacketEntityEffect (net.minecraft.network.play.server.SPacketEntityEffect)2 SPacketRespawn (net.minecraft.network.play.server.SPacketRespawn)2 SPacketSetExperience (net.minecraft.network.play.server.SPacketSetExperience)2