Skip to content

Instantly share code, notes, and snippets.

@CorgiTaco
Last active August 24, 2020 00:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CorgiTaco/255976f58e56ee4f9e65db159b139438 to your computer and use it in GitHub Desktop.
Save CorgiTaco/255976f58e56ee4f9e65db159b139438 to your computer and use it in GitHub Desktop.
EntitySpawns 1.16.2 Cheat Sheet
/*
MIT License
Copyright (c) 2020 CorgiTaco
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import com.google.common.collect.ImmutableMap;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.util.registry.WorldGenRegistries;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.MobSpawnInfo;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
public class EntitySpawnsCheatSheet {
//Iterate through all registered biomes in the WorldGenRegistries.
public static void addSpawnEntries() {
for (Biome biome : WorldGenRegistries.field_243657_i) {
if (biome.getCategory() != Biome.Category.NETHER && biome.getCategory() != Biome.Category.THEEND && biome.getCategory() != Biome.Category.NONE) {
addMobSpawnToBiome(biome, EntityClassification.MONSTER, new MobSpawnInfo.Spawners(EntityType.ENDERMAN, 100, 100, 100));
}
}
}
//Add the normal info along with a list of "Spawners"
public static void addMobSpawnToBiome(Biome biome, EntityClassification classification, MobSpawnInfo.Spawners... spawners) {
convertImmutableSpawners(biome);
//Copy the list of spawners that already exist for the given biome.
List<MobSpawnInfo.Spawners> spawnersList = new ArrayList<>(biome.func_242433_b().field_242554_e.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.func_242433_b().field_242554_e.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.func_242433_b().field_242554_e instanceof ImmutableMap) {
biome.func_242433_b().field_242554_e = new HashMap<>(biome.func_242433_b().field_242554_e);
}
}
}
@AzureDoom
Copy link

Might to include you need to AT field_242554_e public
public-f net.minecraft.world.biome.MobSpawnInfo field_242554_e #field_242554_e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment