use of net.minecraft.world.gen.feature.WorldGenerator in project MorePlanets by SteveKunG.
the class BlockNibiruFlower method generateBigMushroom.
private boolean generateBigMushroom(World world, BlockPos pos, IBlockState state, Random rand) {
world.setBlockToAir(pos);
WorldGenerator worldgenerator = new WorldGenTerrashroom();
if (worldgenerator.generate(world, rand, pos)) {
return true;
} else {
world.setBlockState(pos, state, 3);
return false;
}
}
use of net.minecraft.world.gen.feature.WorldGenerator in project Solar by Martacus.
the class WorldGenSilverOre method generateOverworld.
public void generateOverworld(World world, Random rand, int chunkX, int chunkZ) {
for (int k = 0; k < 8; k++) {
int blockCount = rand.nextInt(6) + 1;
WorldGenerator silverGen = new WorldGenMinable(ModBlocks.SILVER_ORE.getDefaultState(), blockCount);
int firstBlockXCoord = chunkX + rand.nextInt(16);
int firstBlockZCoord = chunkZ + rand.nextInt(16);
int blockY = rand.nextInt(28) + 2;
BlockPos blockPos = new BlockPos(firstBlockXCoord, blockY, firstBlockZCoord);
silverGen.generate(world, rand, blockPos);
}
}
use of net.minecraft.world.gen.feature.WorldGenerator in project Tropicraft by Tropicraft.
the class BlockTropicsSapling method grow.
@Override
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) {
// Change flag (and back) to make it show up when generated
TCGenBase.blockGenNotifyFlag = 3;
WorldGenerator gen;
TropicraftSaplings variant;
switch(variant = state.getValue(VARIANT)) {
case PALM:
int b = rand.nextInt(3);
if (b == 0) {
gen = new WorldGenLargePalmTrees(worldIn, rand);
} else if (b == 1) {
gen = new WorldGenCurvedPalms(worldIn, rand);
} else if (b == 2) {
gen = new WorldGenNormalPalms(worldIn, rand);
} else {
gen = null;
}
break;
case MAHOGANY:
gen = randomRainforestTreeGen(worldIn);
break;
default:
gen = new WorldGenFruitTrees(worldIn, rand, variant.getMeta() - 2);
break;
}
if (gen != null) {
worldIn.setBlockToAir(pos);
if (!gen.generate(worldIn, rand, pos)) {
worldIn.setBlockState(pos, state.withProperty(BlockTropicsSapling.VARIANT, variant), 3);
}
}
TCGenBase.blockGenNotifyFlag = TCGenBase.BLOCK_GEN_NOTIFY_FLAG_DEFAULT;
}
use of net.minecraft.world.gen.feature.WorldGenerator in project SpongeForge by SpongePowered.
the class SpongeChunkGeneratorForge method checkForgeEvent.
private boolean checkForgeEvent(Populator populator, IChunkGenerator chunkProvider, int chunkX, int chunkZ, List<String> flags, Chunk chunk) {
boolean village_flag = flags.contains(WorldGenConstants.VILLAGE_FLAG);
if (populator instanceof Ore && populator instanceof WorldGenerator) {
BlockType type = ((Ore) populator).getOreBlock().getType();
GenerateMinable.EventType otype = null;
if (type.equals(BlockTypes.DIRT)) {
otype = GenerateMinable.EventType.DIRT;
} else if (type.equals(BlockTypes.GRAVEL)) {
otype = GenerateMinable.EventType.GRAVEL;
} else if (type.equals(BlockTypes.STONE)) {
BlockState state = ((Ore) populator).getOreBlock();
Optional<StoneType> stype;
if ((stype = state.get(Keys.STONE_TYPE)).isPresent()) {
StoneType stoneType = stype.get();
if (stoneType.equals(StoneTypes.DIORITE)) {
otype = GenerateMinable.EventType.DIORITE;
} else if (stoneType.equals(StoneTypes.ANDESITE)) {
otype = GenerateMinable.EventType.ANDESITE;
} else if (stoneType.equals(StoneTypes.GRANITE)) {
otype = GenerateMinable.EventType.GRANITE;
} else {
return true;
}
}
} else if (type.equals(BlockTypes.COAL_ORE)) {
otype = GenerateMinable.EventType.COAL;
} else if (type.equals(BlockTypes.IRON_ORE)) {
otype = GenerateMinable.EventType.IRON;
} else if (type.equals(BlockTypes.GOLD_ORE)) {
otype = GenerateMinable.EventType.GOLD;
} else if (type.equals(BlockTypes.REDSTONE_ORE)) {
otype = GenerateMinable.EventType.REDSTONE;
} else if (type.equals(BlockTypes.DIAMOND_ORE)) {
otype = GenerateMinable.EventType.DIAMOND;
} else if (type.equals(BlockTypes.LAPIS_ORE)) {
otype = GenerateMinable.EventType.LAPIS;
} else if (type.equals(BlockTypes.QUARTZ_ORE)) {
otype = GenerateMinable.EventType.QUARTZ;
} else if (type.equals(BlockTypes.EMERALD_ORE)) {
otype = GenerateMinable.EventType.EMERALD;
} else if (type.equals(BlockTypes.MONSTER_EGG)) {
otype = GenerateMinable.EventType.SILVERFISH;
}
return otype == null || TerrainGen.generateOre((World) chunk.getWorld(), this.rand, (WorldGenerator) populator, VecHelper.toBlockPos(chunk.getBlockMin()), otype);
}
Populate.EventType etype = this.getForgeEventTypeForPopulator(populator, chunk);
boolean populate = TerrainGen.populate(chunkProvider, (net.minecraft.world.World) chunk.getWorld(), this.rand, chunkX, chunkZ, village_flag, etype);
Decorate.EventType detype = this.getForgeDecorateEventTypeForPopulator(populator, chunk);
boolean decorate = TerrainGen.decorate((World) chunk.getWorld(), this.rand, VecHelper.toBlockPos(chunk.getBlockMin()), detype);
// TODO May need to separate this..
return populate && decorate;
}
use of net.minecraft.world.gen.feature.WorldGenerator in project ForestryMC by ForestryMC.
the class TileSapling method tryGrow.
public void tryGrow(Random random, boolean bonemealed) {
ITree tree = getTree();
if (tree == null) {
return;
}
int maturity = getRequiredMaturity(world, tree);
if (timesTicked < maturity) {
if (bonemealed) {
timesTicked = maturity;
}
return;
}
WorldGenerator generator = tree.getTreeGenerator(world, getPos(), bonemealed);
final boolean generated;
if (generator instanceof WorldGenBase) {
generated = ((WorldGenBase) generator).generate(world, random, getPos(), false);
} else {
generated = generator.generate(world, random, getPos());
}
if (generated) {
IBreedingTracker breedingTracker = TreeManager.treeRoot.getBreedingTracker(world, getOwnerHandler().getOwner());
breedingTracker.registerBirth(tree);
}
}
Aggregations