use of net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate in project MinecraftForge by MinecraftForge.
the class TerrainGen method populate.
public static boolean populate(IChunkGenerator chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, Populate.EventType type) {
PopulateChunkEvent.Populate event = new PopulateChunkEvent.Populate(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated, type);
MinecraftForge.TERRAIN_GEN_BUS.post(event);
return event.getResult() != Result.DENY;
}
use of net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate 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;
}
Aggregations