Created
August 20, 2020 07:21
-
-
Save AzureDoom/45be3c88656e6d46d3b019dcd1f364a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.HashMap; | |
import java.util.List; | |
import com.google.common.collect.ImmutableMap; | |
import net.minecraft.entity.EntityType; | |
import net.minecraft.entity.SpawnGroup; | |
import net.minecraft.util.registry.BuiltinRegistries; | |
import net.minecraft.world.biome.Biome; | |
import net.minecraft.world.biome.SpawnSettings; | |
public class EntitySpawnsCheatSheetFabric { | |
//Iterate through all registered biomes in the WorldGenRegistries. | |
public static void addSpawnEntries() { | |
for (Biome biome : BuiltinRegistries.BIOME) { | |
if (biome.getCategory() != Biome.Category.NETHER && biome.getCategory() != Biome.Category.THEEND && biome.getCategory() != Biome.Category.NONE) { | |
addMobSpawnToBiome(biome, SpawnGroup.MONSTER, new SpawnSettings.SpawnEntry(EntityType.ENDERMAN, 100, 100, 100)); | |
} | |
} | |
} | |
//Add the normal info along with a list of "Spawners" | |
public static void addMobSpawnToBiome(Biome biome, SpawnGroup classification, SpawnSettings.SpawnEntry... spawners) { | |
convertImmutableSpawners(biome); | |
//Copy the list of spawners that already exist for the given biome. | |
List<SpawnSettings.SpawnEntry> spawnersList = new ArrayList<>(biome.getSpawnSettings().spawners.get(classification)); | |
//Add all the spawners within our list. | |
spawnersList.addAll(Arrays.asList(spawners)); | |
//Overwrite the list for the given classification with the old list and our new entries. | |
biome.getSpawnSettings().spawners.put(classification, spawnersList); | |
} | |
//Convert the immutable map to a mutable HashMap in order for us to change the data stored in these maps | |
private static void convertImmutableSpawners(Biome biome) { | |
if (biome.getSpawnSettings().spawners instanceof ImmutableMap) { | |
biome.getSpawnSettings().spawners = new HashMap<>(biome.getSpawnSettings().spawners); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here are the Access Wideners you need for this