Search in sources :

Example 1 with IVeinPopulator

use of gregtech.api.worldgen.populator.IVeinPopulator in project GregTech by GregTechCE.

the class WorldGenRegistry method createVeinPopulator.

public IVeinPopulator createVeinPopulator(JsonObject object) {
    String identifier = object.get("type").getAsString();
    if (!veinPopulatorRegistry.containsKey(identifier))
        throw new IllegalArgumentException("No vein populator found for type " + identifier);
    IVeinPopulator veinPopulator = veinPopulatorRegistry.get(identifier).get();
    veinPopulator.loadFromConfig(object);
    return veinPopulator;
}
Also used : IVeinPopulator(gregtech.api.worldgen.populator.IVeinPopulator)

Example 2 with IVeinPopulator

use of gregtech.api.worldgen.populator.IVeinPopulator in project GregTech by GregTechCE.

the class CachedGridEntry method doGenerateVein.

private void doGenerateVein(OreDepositDefinition definition) {
    this.currentOreVein = definition;
    int topHeightOffset = currentOreVein.getShapeGenerator().getMaxSize().getY() / 2 + 4;
    int maximumHeight = Math.min(masterEntry.getMaxBottomHeight(), currentOreVein.getHeightLimit()[1] - topHeightOffset);
    int minimumHeight = Math.max(3, currentOreVein.getHeightLimit()[0]);
    if (minimumHeight >= maximumHeight) {
        return;
    }
    this.veinCenterX = calculateVeinCenterX();
    this.veinCenterY = minimumHeight + gridRandom.nextInt(maximumHeight - minimumHeight);
    this.veinCenterZ = calculateVeinCenterZ();
    this.currentOreVein.getShapeGenerator().generate(gridRandom, this);
    this.veinGeneratedMap.put(definition, new BlockPos(veinCenterX, veinCenterY, veinCenterZ));
    IVeinPopulator veinPopulator = currentOreVein.getVeinPopulator();
    if (veinPopulator instanceof VeinBufferPopulator) {
        ((VeinBufferPopulator) veinPopulator).populateBlockBuffer(gridRandom, this, this, currentOreVein);
    }
    this.currentOreVein = null;
}
Also used : MutableBlockPos(net.minecraft.util.math.BlockPos.MutableBlockPos) BlockPos(net.minecraft.util.math.BlockPos) IVeinPopulator(gregtech.api.worldgen.populator.IVeinPopulator) VeinBufferPopulator(gregtech.api.worldgen.populator.VeinBufferPopulator)

Example 3 with IVeinPopulator

use of gregtech.api.worldgen.populator.IVeinPopulator in project GregTech by GregTechCE.

the class CachedGridEntry method populateChunk.

public boolean populateChunk(World world, int chunkX, int chunkZ, Random random) {
    long chunkId = (long) chunkX << 32 | chunkZ & 0xFFFFFFFFL;
    ChunkDataEntry chunkDataEntry = dataByChunkPos.get(chunkId);
    GTWorldGenCapability capability = retrieveCapability(world, chunkX, chunkZ);
    capability.setFrom(masterEntry);
    if (chunkDataEntry != null && chunkDataEntry.populateChunk(world)) {
        for (OreDepositDefinition definition : chunkDataEntry.generatedOres) {
            IVeinPopulator veinPopulator = definition.getVeinPopulator();
            if (veinPopulator instanceof VeinChunkPopulator) {
                ((VeinChunkPopulator) veinPopulator).populateChunk(world, chunkX, chunkZ, random, definition, this);
            }
        }
        return true;
    }
    return false;
}
Also used : VeinChunkPopulator(gregtech.api.worldgen.populator.VeinChunkPopulator) OreDepositDefinition(gregtech.api.worldgen.config.OreDepositDefinition) IVeinPopulator(gregtech.api.worldgen.populator.IVeinPopulator)

Aggregations

IVeinPopulator (gregtech.api.worldgen.populator.IVeinPopulator)3 OreDepositDefinition (gregtech.api.worldgen.config.OreDepositDefinition)1 VeinBufferPopulator (gregtech.api.worldgen.populator.VeinBufferPopulator)1 VeinChunkPopulator (gregtech.api.worldgen.populator.VeinChunkPopulator)1 BlockPos (net.minecraft.util.math.BlockPos)1 MutableBlockPos (net.minecraft.util.math.BlockPos.MutableBlockPos)1