Search in sources :

Example 1 with FlatChunkGenerator

use of net.minecraft.world.gen.FlatChunkGenerator in project Geolosys by oitsjustjose.

the class DepositFeature method generate.

@Override
@ParametersAreNonnullByDefault
public boolean generate(ISeedReader reader, ChunkGenerator generator, Random rand, BlockPos pos, NoFeatureConfig config) {
    if (generator instanceof FlatChunkGenerator) {
        return false;
    }
    IDepositCapability cap = reader.getWorld().getCapability(GeolosysAPI.GEOLOSYS_WORLD_CAPABILITY).orElse(null);
    if (cap == null) {
        Geolosys.getInstance().LOGGER.error("NULL PLUTON CAPABILITY!!!");
        return false;
    }
    boolean placedPending = placePendingBlocks(reader, cap, pos);
    ChunkPos chunkPos = new ChunkPos(pos);
    if (cap.hasPlutonGenerated(chunkPos)) {
        return false;
    }
    IDeposit pluton = GeolosysAPI.plutonRegistry.pick(reader, pos, rand);
    if (pluton == null) {
        // Could be no pluton for the dimension
        return false;
    }
    if (rand.nextInt(CommonConfig.CHUNK_SKIP_CHANCE.get()) > pluton.getGenWt()) {
        return false;
    }
    boolean anyGenerated = pluton.generate(reader, pos, cap) > 0;
    if (anyGenerated) {
        pluton.afterGen(reader, pos, cap);
        cap.setPlutonGenerated(chunkPos);
        return true;
    }
    return placedPending;
}
Also used : IDeposit(com.oitsjustjose.geolosys.api.world.IDeposit) FlatChunkGenerator(net.minecraft.world.gen.FlatChunkGenerator) ChunkPos(net.minecraft.util.math.ChunkPos) IDepositCapability(com.oitsjustjose.geolosys.common.world.capability.IDepositCapability) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Aggregations

IDeposit (com.oitsjustjose.geolosys.api.world.IDeposit)1 IDepositCapability (com.oitsjustjose.geolosys.common.world.capability.IDepositCapability)1 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)1 ChunkPos (net.minecraft.util.math.ChunkPos)1 FlatChunkGenerator (net.minecraft.world.gen.FlatChunkGenerator)1