use of net.minecraft.world.gen.feature.WorldGenerator in project Realistic-Terrain-Generation by Team-RTG.
the class DecoGrassDoubleTallgrass 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) {
if (TerrainGen.decorate(rtgWorld.world, rand, new BlockPos(worldX, 0, worldZ), GRASS)) {
WorldGenerator worldGenerator = null;
if (this.doubleGrassChance > 0) {
if (rand.nextInt(this.doubleGrassChance) == 0) {
worldGenerator = new WorldGenGrass(Blocks.DOUBLE_PLANT.getStateFromMeta(2), 2);
} else {
worldGenerator = new WorldGenGrass(Blocks.TALLGRASS.getStateFromMeta(1), 1);
}
} else if (this.grassChance > 0) {
if (rand.nextInt(this.grassChance) == 0) {
worldGenerator = new WorldGenGrass(Blocks.TALLGRASS.getStateFromMeta(1), 1);
} else {
worldGenerator = new WorldGenGrass(Blocks.DOUBLE_PLANT.getStateFromMeta(2), 2);
}
} else {
if (rand.nextBoolean()) {
worldGenerator = new WorldGenGrass(Blocks.TALLGRASS.getStateFromMeta(1), 1);
} else {
worldGenerator = new WorldGenGrass(Blocks.DOUBLE_PLANT.getStateFromMeta(2), 2);
}
}
this.setLoops((this.strengthFactor > 0f) ? (int) (this.strengthFactor * strength) : this.loops);
for (int i = 0; i < this.loops; i++) {
int intX = worldX + rand.nextInt(16) + 8;
int intY = rand.nextInt(this.maxY);
int intZ = worldZ + rand.nextInt(16) + 8;
if (intY <= this.maxY) {
worldGenerator.generate(rtgWorld.world, rand, new BlockPos(intX, intY, intZ));
}
}
}
}
}
use of net.minecraft.world.gen.feature.WorldGenerator in project Realistic-Terrain-Generation by Team-RTG.
the class DecoLayer 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) {
WorldUtil worldUtil = new WorldUtil(rtgWorld.world);
WorldGenerator worldGenerator = new WorldGenLayers(this.layerBlock, this.layerProperty, this.dropHeight, this.layerRange, this.layerScatter);
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);
}
}
}
}
}
use of net.minecraft.world.gen.feature.WorldGenerator in project NetherEx by LogicTechCorp.
the class BlockElderMushroom method grow.
@Override
public void grow(World world, Random rand, BlockPos pos, IBlockState state) {
WorldGenerator elderMushroom;
if (state.getValue(TYPE) == EnumType.BROWN) {
elderMushroom = new WorldGenElderMushroom(WorldGenElderMushroom.brownVariants, false);
} else {
elderMushroom = new WorldGenElderMushroom(WorldGenElderMushroom.redVariants, false);
}
elderMushroom.generate(world, rand, pos.down());
}
use of net.minecraft.world.gen.feature.WorldGenerator in project BetterWithAddons by DaedalusGame.
the class BlockModSapling method generateTree.
public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand) {
if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(worldIn, rand, pos))
return;
WorldGenerator worldgenerator = isBig ? new WorldGenBigTrees(true, log, leaves, this) : new WorldGenTrees(true, 3, log, leaves, false);
int i = 0;
int j = 0;
IBlockState iblockstate2 = Blocks.AIR.getDefaultState();
worldIn.setBlockState(pos, iblockstate2, 4);
if (!worldgenerator.generate(worldIn, rand, pos.add(i, 0, j))) {
worldIn.setBlockState(pos, state, 4);
}
}
use of net.minecraft.world.gen.feature.WorldGenerator in project Realistic-Terrain-Generation by Team-RTG.
the class DecoTree 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) {
/*
* Determine how many trees we're going to try to generate (loopCount).
* The actual number of trees that end up being generated could be *less* than this value,
* depending on environmental conditions.
*/
float noise = rtgWorld.simplex.noise2(worldX / this.distribution.noiseDivisor, worldZ / this.distribution.noiseDivisor) * this.distribution.noiseFactor + this.distribution.noiseAddend;
int loopCount = this.loops;
loopCount = (this.strengthFactorForLoops > 0f) ? (int) (this.strengthFactorForLoops * strength) : loopCount;
loopCount = (this.strengthNoiseFactorForLoops) ? (int) (noise * strength) : loopCount;
loopCount = (this.strengthNoiseFactorXForLoops) ? (int) (noise * this.strengthFactorForLoops * strength) : loopCount;
if (loopCount < 1) {
return;
}
// Now let's check the configs to see if we should increase/decrease this value.
DecoUtil decoUtil = new DecoUtil(this);
loopCount = decoUtil.calculateLoopCountFromTreeDensity(loopCount, biome);
if (loopCount < 1) {
return;
}
/*
* Since RTG posts a TREE event for each batch of trees it tries to generate (instead of one event per chunk),
* we post this custom event so that we can pass the number of trees RTG expects to generate in each batch.
*
* This provides more contextual information to mods like Recurrent Complex, which can use the info to better
* determine how to handle each batch of trees.
*
* Because the custom event extends DecorateBiomeEvent.Decorate, it still works with mods that don't need
* the additional context.
*/
DecorateBiomeEventRTG.DecorateRTG event = new DecorateBiomeEventRTG.DecorateRTG(rtgWorld.world, rand, new BlockPos(worldX, 0, worldZ), TREE, loopCount);
MinecraftForge.TERRAIN_GEN_BUS.post(event);
if (event.getResult() != Event.Result.DENY) {
loopCount = event.getModifiedAmount();
if (loopCount < 1) {
return;
}
WorldUtil worldUtil = new WorldUtil(rtgWorld.world);
DecoBase.tweakTreeLeaves(this, false, true);
for (int i = 0; i < loopCount; i++) {
// + 8;
int intX = scatter.get(rand, worldX);
// + 8;
int intZ = scatter.get(rand, worldZ);
int intY = rtgWorld.world.getHeight(new BlockPos(intX, 0, intZ)).getY();
if (intY <= this.maxY && intY >= this.minY && isValidTreeCondition(noise, rand, strength)) {
// If we're in a village, check to make sure the tree has extra room to grow to avoid corrupting the village.
if (hasPlacedVillageBlocks) {
if (!worldUtil.isSurroundedByBlock(Blocks.AIR.getDefaultState(), 2, WorldUtil.SurroundCheckType.CARDINAL, rand, intX, intY, intZ)) {
return;
}
}
switch(this.treeType) {
case RTG_TREE:
//this.setLogBlock(strength < 0.2f ? BlockUtil.getStateLog(2) : this.logBlock);
this.tree.setLogBlock(this.logBlock);
this.tree.setLeavesBlock(this.leavesBlock);
this.tree.setTrunkSize(RandomUtil.getRandomInt(rand, this.minTrunkSize, this.maxTrunkSize));
this.tree.setCrownSize(RandomUtil.getRandomInt(rand, this.minCrownSize, this.maxCrownSize));
this.tree.setNoLeaves(this.noLeaves);
this.tree.generate(rtgWorld.world, rand, new BlockPos(intX, intY, intZ));
break;
case WORLDGEN:
WorldGenerator worldgenerator = this.worldGen;
worldgenerator.generate(rtgWorld.world, rand, new BlockPos(intX, intY, intZ));
break;
default:
break;
}
} else {
//Logger.debug("%d/%d/%d - minY = %d; maxY = %d; noise = %f", intX, intY, intZ, minY, maxY, noise);
}
}
} else {
//Logger.debug("Tree generation was cancelled.");
}
}
}
Aggregations