use of net.minecraftforge.event.world.BiomeLoadingEvent in project SinoCore by SinoCraftProject.
the class PlacedFeatureRegister method onGenerator.
@SubscribeEvent(priority = EventPriority.HIGH)
public void onGenerator(BiomeLoadingEvent event) {
BiomeGenerationSettingsBuilder generation = event.getGeneration();
ResourceLocation name = event.getName();
Biome.BiomeCategory category = event.getCategory();
Biome.ClimateSettings climate = event.getClimate();
BiomeSpecialEffects effects = event.getEffects();
features.stream().filter(e -> e.test(name, category, climate, effects)).forEach(e -> generation.addFeature(e.decoration.ordinal(), e));
}
use of net.minecraftforge.event.world.BiomeLoadingEvent in project Mekanism by mekanism.
the class SpawnHelper method onBiomeLoad.
public static void onBiomeLoad(BiomeLoadingEvent event) {
// Add spawns to any biomes that have mob spawns for the "parent" types of our mobs
MobSpawnInfoBuilder spawns = event.getSpawns();
List<MobSpawnInfo.Spawners> monsterSpawns = spawns.getSpawner(EntityClassification.MONSTER);
if (!monsterSpawns.isEmpty()) {
// Fail quick if no monsters can spawn in this biome anyway
ResourceLocation biomeName = event.getName();
getSpawnConfigs().filter(spawnConfig -> spawnConfig.shouldSpawn.get() && !spawnConfig.biomeBlackList.get().contains(biomeName)).forEach(spawnConfig -> {
EntityType<?> parent = spawnConfig.parentTypeProvider.getEntityType();
monsterSpawns.stream().filter(monsterSpawn -> monsterSpawn.type == parent).findFirst().ifPresent(parentEntry -> {
// If the adult mob can spawn in this biome let the baby mob spawn in it
// Note: We adjust the mob's spawning based on the adult's spawn rates
MobSpawnInfo.Spawners spawner = getSpawner(spawnConfig, parentEntry);
spawns.addSpawn(EntityClassification.MONSTER, spawner);
MobSpawnInfo.SpawnCosts parentCost = spawns.getCost(parent);
if (parentCost == null) {
Mekanism.logger.debug("Adding spawn rate for '{}' in biome '{}', with weight: {}, minSize: {}, maxSize: {}", spawner.type.getRegistryName(), biomeName, spawner.weight, spawner.minCount, spawner.maxCount);
} else {
double spawnCostPerEntity = parentCost.getCharge() * spawnConfig.spawnCostPerEntityPercentage.get();
double maxSpawnCost = parentCost.getEnergyBudget() * spawnConfig.maxSpawnCostPercentage.get();
spawns.addMobCharge(spawner.type, spawnCostPerEntity, maxSpawnCost);
Mekanism.logger.debug("Adding spawn rate for '{}' in biome '{}', with weight: {}, minSize: {}, maxSize: {}, spawnCostPerEntity: {}, maxSpawnCost: {}", spawner.type.getRegistryName(), biomeName, spawner.weight, spawner.minCount, spawner.maxCount, spawnCostPerEntity, maxSpawnCost);
}
});
});
}
}
use of net.minecraftforge.event.world.BiomeLoadingEvent in project Magma-1.16.x by magmafoundation.
the class ForgeHooks method enhanceBiome.
public static Biome enhanceBiome(@Nullable final ResourceLocation name, final Biome.Climate climate, final Biome.Category category, final Float depth, final Float scale, final BiomeAmbience effects, final BiomeGenerationSettings gen, final MobSpawnInfo spawns, final RecordCodecBuilder.Instance<Biome> codec, final BiomeCallbackFunction callback) {
BiomeGenerationSettingsBuilder genBuilder = new BiomeGenerationSettingsBuilder(gen);
MobSpawnInfoBuilder spawnBuilder = new MobSpawnInfoBuilder(spawns);
BiomeLoadingEvent event = new BiomeLoadingEvent(name, climate, category, depth, scale, effects, genBuilder, spawnBuilder);
MinecraftForge.EVENT_BUS.post(event);
return callback.apply(event.getClimate(), event.getCategory(), event.getDepth(), event.getScale(), event.getEffects(), event.getGeneration().build(), event.getSpawns().build()).setRegistryName(name);
}
use of net.minecraftforge.event.world.BiomeLoadingEvent in project LoliServer by Loli-Server.
the class ForgeHooks method enhanceBiome.
public static Biome enhanceBiome(@Nullable final ResourceLocation name, final Biome.Climate climate, final Biome.Category category, final Float depth, final Float scale, final BiomeAmbience effects, final BiomeGenerationSettings gen, final MobSpawnInfo spawns, final RecordCodecBuilder.Instance<Biome> codec, final BiomeCallbackFunction callback) {
BiomeGenerationSettingsBuilder genBuilder = new BiomeGenerationSettingsBuilder(gen);
MobSpawnInfoBuilder spawnBuilder = new MobSpawnInfoBuilder(spawns);
BiomeLoadingEvent event = new BiomeLoadingEvent(name, climate, category, depth, scale, effects, genBuilder, spawnBuilder);
MinecraftForge.EVENT_BUS.post(event);
return callback.apply(event.getClimate(), event.getCategory(), event.getDepth(), event.getScale(), event.getEffects(), event.getGeneration().build(), event.getSpawns().build()).setRegistryName(name);
}
Aggregations