use of net.minecraft.world.entity.MobCategory 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()));
}
use of net.minecraft.world.entity.MobCategory in project SpongeCommon by SpongePowered.
the class NaturalSpawnerMixin method spawnForChunk.
// @formatter:on
/**
* @author morph - January 3rd, 2021 - Minecraft 1.16.4
* @reason Use world configured spawn limits
*/
@Overwrite
public static void spawnForChunk(ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnState manager, boolean spawnFriendlies, boolean spawnEnemies, boolean doMobSpawning) {
world.getProfiler().push("spawner");
for (final MobCategory entityclassification : SPAWNING_CATEGORIES) {
if ((spawnFriendlies || !entityclassification.isFriendly()) && (spawnEnemies || entityclassification.isFriendly()) && (doMobSpawning || !entityclassification.isPersistent()) && NaturalSpawnerMixin.impl$canSpawnInLevel(manager, entityclassification, world)) {
// spawnCategoryForChunk(var0, param0, param1, (param1x, param2x, param3x) -> param2.canSpawn(param1x, param2x,
// param3x), (param1x, param2x) -> param2.afterSpawn(param1x, param2x));
NaturalSpawnerMixin.spawnCategoryForChunk(entityclassification, world, chunk, (p_234969_1_, p_234969_2_, p_234969_3_) -> ((NaturalSpawner_SpawnStateAccessor) manager).invoker$canSpawn(p_234969_1_, p_234969_2_, p_234969_3_), (p_234970_1_, p_234970_2_) -> ((NaturalSpawner_SpawnStateAccessor) manager).invoker$afterSpawn(p_234970_1_, p_234970_2_));
}
}
world.getProfiler().pop();
}
Aggregations