Autogeneration of Biome enum

This commit is contained in:
jglrxavpok 2020-06-29 20:37:48 +02:00
parent 7c3d3f6f07
commit a8e607626e
4 changed files with 161 additions and 96 deletions

View File

@ -0,0 +1,103 @@
//==============================
// AUTOGENERATED BY EnumGenerator
//==============================
package net.minestom.server.instance;
public enum Biome {
OCEAN("minecraft:ocean"),
PLAINS("minecraft:plains"),
DESERT("minecraft:desert"),
MOUNTAINS("minecraft:mountains"),
FOREST("minecraft:forest"),
TAIGA("minecraft:taiga"),
SWAMP("minecraft:swamp"),
RIVER("minecraft:river"),
NETHER("minecraft:nether"),
THE_END("minecraft:the_end"),
FROZEN_OCEAN("minecraft:frozen_ocean"),
FROZEN_RIVER("minecraft:frozen_river"),
SNOWY_TUNDRA("minecraft:snowy_tundra"),
SNOWY_MOUNTAINS("minecraft:snowy_mountains"),
MUSHROOM_FIELDS("minecraft:mushroom_fields"),
MUSHROOM_FIELD_SHORE("minecraft:mushroom_field_shore"),
BEACH("minecraft:beach"),
DESERT_HILLS("minecraft:desert_hills"),
WOODED_HILLS("minecraft:wooded_hills"),
TAIGA_HILLS("minecraft:taiga_hills"),
MOUNTAIN_EDGE("minecraft:mountain_edge"),
JUNGLE("minecraft:jungle"),
JUNGLE_HILLS("minecraft:jungle_hills"),
JUNGLE_EDGE("minecraft:jungle_edge"),
DEEP_OCEAN("minecraft:deep_ocean"),
STONE_SHORE("minecraft:stone_shore"),
SNOWY_BEACH("minecraft:snowy_beach"),
BIRCH_FOREST("minecraft:birch_forest"),
BIRCH_FOREST_HILLS("minecraft:birch_forest_hills"),
DARK_FOREST("minecraft:dark_forest"),
SNOWY_TAIGA("minecraft:snowy_taiga"),
SNOWY_TAIGA_HILLS("minecraft:snowy_taiga_hills"),
GIANT_TREE_TAIGA("minecraft:giant_tree_taiga"),
GIANT_TREE_TAIGA_HILLS("minecraft:giant_tree_taiga_hills"),
WOODED_MOUNTAINS("minecraft:wooded_mountains"),
SAVANNA("minecraft:savanna"),
SAVANNA_PLATEAU("minecraft:savanna_plateau"),
BADLANDS("minecraft:badlands"),
WOODED_BADLANDS_PLATEAU("minecraft:wooded_badlands_plateau"),
BADLANDS_PLATEAU("minecraft:badlands_plateau"),
SMALL_END_ISLANDS("minecraft:small_end_islands"),
END_MIDLANDS("minecraft:end_midlands"),
END_HIGHLANDS("minecraft:end_highlands"),
END_BARRENS("minecraft:end_barrens"),
WARM_OCEAN("minecraft:warm_ocean"),
LUKEWARM_OCEAN("minecraft:lukewarm_ocean"),
COLD_OCEAN("minecraft:cold_ocean"),
DEEP_WARM_OCEAN("minecraft:deep_warm_ocean"),
DEEP_LUKEWARM_OCEAN("minecraft:deep_lukewarm_ocean"),
DEEP_COLD_OCEAN("minecraft:deep_cold_ocean"),
DEEP_FROZEN_OCEAN("minecraft:deep_frozen_ocean"),
THE_VOID("minecraft:the_void"),
SUNFLOWER_PLAINS("minecraft:sunflower_plains"),
DESERT_LAKES("minecraft:desert_lakes"),
GRAVELLY_MOUNTAINS("minecraft:gravelly_mountains"),
FLOWER_FOREST("minecraft:flower_forest"),
TAIGA_MOUNTAINS("minecraft:taiga_mountains"),
SWAMP_HILLS("minecraft:swamp_hills"),
ICE_SPIKES("minecraft:ice_spikes"),
MODIFIED_JUNGLE("minecraft:modified_jungle"),
MODIFIED_JUNGLE_EDGE("minecraft:modified_jungle_edge"),
TALL_BIRCH_FOREST("minecraft:tall_birch_forest"),
TALL_BIRCH_HILLS("minecraft:tall_birch_hills"),
DARK_FOREST_HILLS("minecraft:dark_forest_hills"),
SNOWY_TAIGA_MOUNTAINS("minecraft:snowy_taiga_mountains"),
GIANT_SPRUCE_TAIGA("minecraft:giant_spruce_taiga"),
GIANT_SPRUCE_TAIGA_HILLS("minecraft:giant_spruce_taiga_hills"),
MODIFIED_GRAVELLY_MOUNTAINS("minecraft:modified_gravelly_mountains"),
SHATTERED_SAVANNA("minecraft:shattered_savanna"),
SHATTERED_SAVANNA_PLATEAU("minecraft:shattered_savanna_plateau"),
ERODED_BADLANDS("minecraft:eroded_badlands"),
MODIFIED_WOODED_BADLANDS_PLATEAU("minecraft:modified_wooded_badlands_plateau"),
MODIFIED_BADLANDS_PLATEAU("minecraft:modified_badlands_plateau"),
BAMBOO_JUNGLE("minecraft:bamboo_jungle"),
BAMBOO_JUNGLE_HILLS("minecraft:bamboo_jungle_hills"),
;
private String namespaceID;
Biome(String namespaceID) {
this.namespaceID = namespaceID;
}
public int getId() {
return ordinal();
}
public String getNamespaceID() {
return namespaceID;
}
public static Biome fromId(int id) {
if(id >= 0 && id < values().length) {
return values()[id];
}
return null;
}
}

View File

@ -7,6 +7,7 @@ import net.minestom.codegen.items.ItemEnumGenerator;
import net.minestom.codegen.particles.ParticleEnumGenerator;
import net.minestom.codegen.potions.PotionEnumGenerator;
import net.minestom.codegen.sounds.SoundEnumGenerator;
import net.minestom.codegen.stats.BiomesEnumGenerator;
import net.minestom.codegen.stats.StatsEnumGenerator;
import java.io.IOException;
@ -22,5 +23,6 @@ public class AllGenerators {
SoundEnumGenerator.main(args);
ParticleEnumGenerator.main(args);
StatsEnumGenerator.main(args);
BiomesEnumGenerator.main(args);
}
}

View File

@ -0,0 +1,56 @@
package net.minestom.codegen.stats;
import net.minestom.codegen.BasicEnumGenerator;
import net.minestom.server.registry.ResourceGatherer;
import java.io.File;
import java.io.IOException;
public class BiomesEnumGenerator extends BasicEnumGenerator {
public static void main(String[] args) throws IOException {
String targetVersion;
if(args.length < 1) {
System.err.println("Usage: <MC version> [target folder]");
return;
}
targetVersion = args[0];
try {
ResourceGatherer.ensureResourcesArePresent(targetVersion, null); // TODO
} catch (IOException e) {
e.printStackTrace();
}
String targetPart = DEFAULT_TARGET_PATH;
if(args.length >= 2) {
targetPart = args[1];
}
File targetFolder = new File(targetPart);
if(!targetFolder.exists()) {
targetFolder.mkdirs();
}
new BiomesEnumGenerator(targetFolder);
}
private BiomesEnumGenerator(File targetFolder) throws IOException {
super(targetFolder);
}
@Override
protected String getCategoryID() {
return "minecraft:biome";
}
@Override
public String getPackageName() {
return "net.minestom.server.instance";
}
@Override
public String getClassName() {
return "Biome";
}
}

View File

@ -1,96 +0,0 @@
package net.minestom.server.instance;
import java.util.Arrays;
public enum Biome {
OCEAN(0),
DEEP_OCEAN(24),
FROZEN_OCEAN(10),
DEEP_FROZEN_OCEAN(50),
COLD_OCEAN(46),
DEEP_COLD_OCEAN(49),
LUKEWARM_OCEAN(45),
DEEP_LUKEWARM_OCEAN(48),
WARM_OCEAN(44),
DEEP_WARM_OCEAN(47),
RIVER(7),
FROZEN_RIVER(11),
BEACH(16),
STONE_SHORE(25),
SNOWY_BEACH(26),
FOREST(4),
WOODED_HILLS(18),
FLOWER_FOREST(132),
BIRCH_FOREST(27),
BIRCH_FOREST_HILLS(28),
TALL_BIRCH_FOREST(155),
TALL_BIRCH_HILLS(156),
DARK_FOREST(29),
DARK_FOREST_HILLS(157),
JUNGLE(21),
JUNGLE_HILLS(22),
MODIFIED_JUNGLE(149),
JUNGLE_EDGE(23),
MODIFIED_JUNGLE_EDGE(151),
BAMBOO_JUNGLE(168),
BAMBOO_JUNGLE_HILLS(169),
TAIGA(5),
TAIGA_HILLS(19),
TAIGA_MOUNTAINS(133),
SNOWY_TAIGA(30),
SNOWY_TAIGA_HILLS(31),
SNOWY_TAIGA_MOUNTAINS(158),
GIANT_TREE_TAIGA(32),
GIANT_TREE_TAIGA_HILLS(33),
GIANT_SPRUCE_TAIGA(160),
GIANT_SPRUCE_TAIGA_HILLS(161),
MUSHROOM_FIELDS(14),
MUSHROOM_FIELDS_SHORE(15),
SWAMP(6),
SWAMP_HILLS(134),
SAVANA(35),
SAVANA_PLATEAU(36),
SHATTERED_SAVANA(163),
SHATTERED_SAVANA_PLATEAU(164),
PLAINS(1),
SUNFLOWER_PLAINS(129),
DESERT(2),
DESERT_HILLS(17),
DESERT_LAKES(130),
SNOWY_TUNDRA(12),
SNOWY_MOUNTAINS(13),
ICE_SPIKES(140),
MOUNTAINS(3),
WOODED_MOUTAINS(34),
GRAVELLY_MOUNTAINS(131),
MODIFIED_GRAVELLY_MOUNTAINS(162),
MOUNTAIN_EDGE(20),
BADLANDS(37),
BADLANDS_PLATEAU(39),
MODIFIED_BADLANDS_PLATEAU(167),
WOODED_BADLANDS_PLATEAU(38),
MODIFIED_WOODED_BADLANDS_PLATEAU(166),
ERODED_BADLANDS(165),
NETHER(8),
THE_END(9),
SMALL_END_ISLANDS(40),
END_MIDLANDS(41),
END_HIGHLANDS(42),
END_BARRENS(43),
VOID(127);
private int id;
Biome(int id) {
this.id = id;
}
public static Biome fromId(int id) {
return Arrays.stream(values()).filter(customBiome -> customBiome.id == id).findFirst().get();
}
public int getId() {
return id;
}
}