Fix misaligned patch causing monsters to not spawn in nether fortresses correctly.

This commit is contained in:
LexManos committed 2021-08-21 18:30:13 -07:00
1 parent aa97ddad8b
commit 559b801cc4
9 files changed
+65 -25

No files matched your search

@@ -33,10 +33,28 @@ public interface IForgeStructureFeature
return (StructureFeature<?>) this;
}
/**
* Gets the default list of spawns for this structure, of the specified category.
*
* @apiNote Implement this over any of the type specific getSpecial functions in StructureFeature.
*/
@SuppressWarnings("incomplete-switch")
default List<MobSpawnSettings.SpawnerData> getDefaultSpawnList(MobCategory category)
{
if (category == MobCategory.MONSTER)
return getDefaultSpawnList();
else if (category == MobCategory.CREATURE)
return getDefaultCreatureSpawnList();
return Collections.emptyList();
}
/**
* Gets the default list of {@link EntityClassification#MONSTER} spawns for this structure.
*
* @apiNote Implement this over {@link Structure#getSpawnList()}
*
* @Deprecated Use {@link IForgeStructureFeature#getDefaultSpawnList(MobCategory)}
* TODO: Remove in 1.18
*/
default List<MobSpawnSettings.SpawnerData> getDefaultSpawnList()
{
@@ -47,6 +65,9 @@ public interface IForgeStructureFeature
* Gets the default list of {@link EntityClassification#CREATURE} spawns for this structure.
*
* @apiNote Implement this over {@link Structure#getCreatureSpawnList()}
*
* @Deprecated Use {@link IForgeStructureFeature#getDefaultSpawnList(MobCategory)}
* TODO: Remove in 1.18
*/
default List<MobSpawnSettings.SpawnerData> getDefaultCreatureSpawnList()
{
@@ -111,8 +111,9 @@ public class StructureSpawnManager
*/
public static WeightedRandomList<MobSpawnSettings.SpawnerData> getSpawnList(StructureFeature<?> structure, MobCategory classification)
{
if (structuresWithSpawns.containsKey(structure))
return structuresWithSpawns.get(structure).spawns.getOrDefault(classification, WeightedRandomList.create());
StructureSpawnInfo info = structuresWithSpawns.get(structure);
if (info != null)
return info.spawns.getOrDefault(classification, WeightedRandomList.create());
return WeightedRandomList.create();
}
@@ -25,7 +25,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.SpawnData;
import net.minecraft.world.level.biome.MobSpawnSettings;
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraftforge.eventbus.api.Event;
@@ -55,8 +57,12 @@ public class StructureSpawnListGatherEvent extends Event
{
this.structure = structure;
this.insideOnly = this.structure.getDefaultRestrictsSpawnsToInside();
addEntitySpawns(MobCategory.MONSTER, this.structure.getDefaultSpawnList());
addEntitySpawns(MobCategory.CREATURE, this.structure.getDefaultCreatureSpawnList());
for (MobCategory cat : MobCategory.values()) {
List<SpawnerData> lst = this.structure.getDefaultSpawnList(cat);
if (!lst.isEmpty())
addEntitySpawns(cat, lst);
}
}
/**