use of rtg.api.world.gen.feature.WorldGenLog in project Realistic-Terrain-Generation by Team-RTG.
the class DecoFallenTree method generate.
@Override
public void generate(IRealisticBiome biome, RTGWorld rtgWorld, Random rand, int worldX, int worldZ, float strength, float river, boolean hasPlacedVillageBlocks) {
if (this.allowed) {
float noise = rtgWorld.simplex.noise2(worldX / this.distribution.noiseDivisor, worldZ / this.distribution.noiseDivisor) * this.distribution.noiseFactor + this.distribution.noiseAddend;
WorldUtil worldUtil = new WorldUtil(rtgWorld.world);
//Do we want to choose a random log?
if (this.randomLogBlocks.length > 0) {
this.setLogBlock(this.randomLogBlocks[rand.nextInt(this.randomLogBlocks.length)]);
}
WorldGenerator worldGenerator = null;
int finalSize = 4;
// Adjust the chance according to biome config.
this.setLogConditionChance(decoUtil.adjustChanceFromMultiplier(this.getLogConditionChance(), biome.getConfig().FALLEN_LOG_DENSITY_MULTIPLIER.get()));
if (this.maxSize > this.minSize) {
finalSize = this.minSize + rand.nextInt(this.maxSize - this.minSize);
worldGenerator = new WorldGenLog(this.logBlock, this.leavesBlock, finalSize);
} else if (this.maxSize == this.minSize) {
finalSize = this.minSize;
worldGenerator = new WorldGenLog(this.logBlock, this.leavesBlock, finalSize);
} else {
worldGenerator = new WorldGenLog(this.logBlock, this.leavesBlock, finalSize);
}
for (int i = 0; i < this.loops; i++) {
if (isValidLogCondition(noise, strength, rand)) {
// + 8;
int x22 = worldX + rand.nextInt(16);
// + 8;
int z22 = worldZ + rand.nextInt(16);
int y22 = rtgWorld.world.getHeight(new BlockPos(x22, 0, z22)).getY();
if (y22 <= this.maxY) {
// If we're in a village, check to make sure the log has extra room to grow to avoid corrupting the village.
if (hasPlacedVillageBlocks) {
if (!worldUtil.isSurroundedByBlock(Blocks.AIR.getDefaultState(), finalSize, WorldUtil.SurroundCheckType.CARDINAL, rand, x22, y22, z22)) {
return;
}
}
worldGenerator.generate(rtgWorld.world, rand, new BlockPos(x22, y22, z22));
}
}
}
}
}
Aggregations