use of net.minecraftforge.event.world.StructureSpawnListGatherEvent in project MinecraftForge by MinecraftForge.
the class StructureSpawnManager method gatherEntitySpawns.
private static void gatherEntitySpawns(Map<StructureFeature<?>, StructureSpawnInfo> structuresWithSpawns, StructureFeature<?> structure) {
StructureSpawnListGatherEvent event = new StructureSpawnListGatherEvent(structure);
MinecraftForge.EVENT_BUS.post(event);
ImmutableMap.Builder<net.minecraft.world.entity.MobCategory, WeightedRandomList<MobSpawnSettings.SpawnerData>> builder = ImmutableMap.builder();
event.getEntitySpawns().forEach((classification, spawns) -> {
if (!spawns.isEmpty())
builder.put(classification, WeightedRandomList.create(spawns));
});
ImmutableMap<MobCategory, WeightedRandomList<MobSpawnSettings.SpawnerData>> entitySpawns = builder.build();
if (!entitySpawns.isEmpty())
structuresWithSpawns.put(structure, new StructureSpawnInfo(entitySpawns, event.isInsideOnly()));
}
Aggregations