use of rtg.api.world.gen.feature.WorldGenShrubRTG in project Realistic-Terrain-Generation by Team-RTG.
the class DecoShrub 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) {
DecoBase.tweakShrubLeaves(this, false, true);
// Shrub size.
this.size = (this.size == -1) ? rand.nextInt(4) + 1 : this.size;
if (this.minSize > 0 && this.maxSize > 0 && this.maxSize >= this.minSize) {
this.size = this.minSize + rand.nextInt(this.maxSize - this.minSize + 1);
}
// Do we want random shrubs?
if (this.useDefaultRandom && this.randomLogBlocks.length > 0 && this.randomLogBlocks.length == this.randomLeavesBlocks.length) {
int rnd = rand.nextInt(this.randomLogBlocks.length);
this.setLogBlock(this.randomLogBlocks[rnd]);
this.setLeavesBlock(this.randomLeavesBlocks[rnd]);
}
WorldUtil worldUtil = new WorldUtil(rtgWorld.world);
WorldGenerator worldGenerator = new WorldGenShrubRTG(this.size, this.logBlock, this.leavesBlock, this.sand);
int loopCount = this.loops;
loopCount = (this.strengthFactor > 0f) ? (int) (this.strengthFactor * strength) : loopCount;
for (int i = 0; i < loopCount; i++) {
// + 8;
int intX = worldX + rand.nextInt(16);
// + 8;
int intZ = worldZ + rand.nextInt(16);
int intY = rtgWorld.world.getHeight(new BlockPos(intX, 0, intZ)).getY();
if (this.notEqualsZeroChance > 1) {
if (intY >= this.minY && intY <= this.maxY && rand.nextInt(this.notEqualsZeroChance) != 0) {
generateWorldGenerator(worldGenerator, worldUtil, rtgWorld.world, rand, intX, intY, intZ, hasPlacedVillageBlocks);
}
} else {
if (intY >= this.minY && intY <= this.maxY && rand.nextInt(this.chance) == 0) {
generateWorldGenerator(worldGenerator, worldUtil, rtgWorld.world, rand, intX, intY, intZ, hasPlacedVillageBlocks);
}
}
}
}
}
Aggregations