Commits
DerFrZocker authored and md_5 committed 97c59261404
1 1 | package org.bukkit.block; |
2 2 | |
3 + | import com.google.common.base.Preconditions; |
4 + | import com.google.common.collect.Lists; |
3 5 | import java.util.Locale; |
6 + | import org.bukkit.Bukkit; |
7 + | import org.bukkit.FeatureFlag; |
4 8 | import org.bukkit.Keyed; |
5 9 | import org.bukkit.MinecraftExperimental; |
6 10 | import org.bukkit.NamespacedKey; |
11 + | import org.bukkit.Registry; |
12 + | import org.bukkit.packs.DataPack; |
13 + | import org.bukkit.util.OldEnum; |
7 14 | import org.jetbrains.annotations.ApiStatus; |
8 15 | import org.jetbrains.annotations.NotNull; |
9 16 | |
10 17 | /** |
11 - | * Holds all accepted Biomes in the default server |
18 + | * Holds all accepted Biomes in the server. |
19 + | * <p> |
20 + | * The Biomes listed in this interface are present in the default server |
21 + | * or can be enabled via a {@link FeatureFlag}. |
22 + | * There may be additional biomes present in the server, for example from a {@link DataPack} |
23 + | * which can be accessed via {@link Registry#BIOME}. |
12 24 | */ |
13 - | public enum Biome implements Keyed { |
14 - | OCEAN, |
15 - | PLAINS, |
16 - | DESERT, |
17 - | WINDSWEPT_HILLS, |
18 - | FOREST, |
19 - | TAIGA, |
20 - | SWAMP, |
21 - | MANGROVE_SWAMP, |
22 - | RIVER, |
23 - | NETHER_WASTES, |
24 - | THE_END, |
25 - | FROZEN_OCEAN, |
26 - | FROZEN_RIVER, |
27 - | SNOWY_PLAINS, |
28 - | MUSHROOM_FIELDS, |
29 - | BEACH, |
30 - | JUNGLE, |
31 - | SPARSE_JUNGLE, |
32 - | DEEP_OCEAN, |
33 - | STONY_SHORE, |
34 - | SNOWY_BEACH, |
35 - | BIRCH_FOREST, |
36 - | DARK_FOREST, |
37 - | SNOWY_TAIGA, |
38 - | OLD_GROWTH_PINE_TAIGA, |
39 - | WINDSWEPT_FOREST, |
40 - | SAVANNA, |
41 - | SAVANNA_PLATEAU, |
42 - | BADLANDS, |
43 - | WOODED_BADLANDS, |
44 - | SMALL_END_ISLANDS, |
45 - | END_MIDLANDS, |
46 - | END_HIGHLANDS, |
47 - | END_BARRENS, |
48 - | WARM_OCEAN, |
49 - | LUKEWARM_OCEAN, |
50 - | COLD_OCEAN, |
51 - | DEEP_LUKEWARM_OCEAN, |
52 - | DEEP_COLD_OCEAN, |
53 - | DEEP_FROZEN_OCEAN, |
54 - | THE_VOID, |
55 - | SUNFLOWER_PLAINS, |
56 - | WINDSWEPT_GRAVELLY_HILLS, |
57 - | FLOWER_FOREST, |
58 - | ICE_SPIKES, |
59 - | OLD_GROWTH_BIRCH_FOREST, |
60 - | OLD_GROWTH_SPRUCE_TAIGA, |
61 - | WINDSWEPT_SAVANNA, |
62 - | ERODED_BADLANDS, |
63 - | BAMBOO_JUNGLE, |
64 - | SOUL_SAND_VALLEY, |
65 - | CRIMSON_FOREST, |
66 - | WARPED_FOREST, |
67 - | BASALT_DELTAS, |
68 - | DRIPSTONE_CAVES, |
69 - | LUSH_CAVES, |
70 - | DEEP_DARK, |
71 - | MEADOW, |
72 - | GROVE, |
73 - | SNOWY_SLOPES, |
74 - | FROZEN_PEAKS, |
75 - | JAGGED_PEAKS, |
76 - | STONY_PEAKS, |
77 - | CHERRY_GROVE, |
25 + | public interface Biome extends OldEnum<Biome>, Keyed { |
26 + | |
27 + | Biome OCEAN = getBiome("ocean"); |
28 + | Biome PLAINS = getBiome("plains"); |
29 + | Biome DESERT = getBiome("desert"); |
30 + | Biome WINDSWEPT_HILLS = getBiome("windswept_hills"); |
31 + | Biome FOREST = getBiome("forest"); |
32 + | Biome TAIGA = getBiome("taiga"); |
33 + | Biome SWAMP = getBiome("swamp"); |
34 + | Biome MANGROVE_SWAMP = getBiome("mangrove_swamp"); |
35 + | Biome RIVER = getBiome("river"); |
36 + | Biome NETHER_WASTES = getBiome("nether_wastes"); |
37 + | Biome THE_END = getBiome("the_end"); |
38 + | Biome FROZEN_OCEAN = getBiome("frozen_ocean"); |
39 + | Biome FROZEN_RIVER = getBiome("frozen_river"); |
40 + | Biome SNOWY_PLAINS = getBiome("snowy_plains"); |
41 + | Biome MUSHROOM_FIELDS = getBiome("mushroom_fields"); |
42 + | Biome BEACH = getBiome("beach"); |
43 + | Biome JUNGLE = getBiome("jungle"); |
44 + | Biome SPARSE_JUNGLE = getBiome("sparse_jungle"); |
45 + | Biome DEEP_OCEAN = getBiome("deep_ocean"); |
46 + | Biome STONY_SHORE = getBiome("stony_shore"); |
47 + | Biome SNOWY_BEACH = getBiome("snowy_beach"); |
48 + | Biome BIRCH_FOREST = getBiome("birch_forest"); |
49 + | Biome DARK_FOREST = getBiome("dark_forest"); |
50 + | Biome SNOWY_TAIGA = getBiome("snowy_taiga"); |
51 + | Biome OLD_GROWTH_PINE_TAIGA = getBiome("old_growth_pine_taiga"); |
52 + | Biome WINDSWEPT_FOREST = getBiome("windswept_forest"); |
53 + | Biome SAVANNA = getBiome("savanna"); |
54 + | Biome SAVANNA_PLATEAU = getBiome("savanna_plateau"); |
55 + | Biome BADLANDS = getBiome("badlands"); |
56 + | Biome WOODED_BADLANDS = getBiome("wooded_badlands"); |
57 + | Biome SMALL_END_ISLANDS = getBiome("small_end_islands"); |
58 + | Biome END_MIDLANDS = getBiome("end_midlands"); |
59 + | Biome END_HIGHLANDS = getBiome("end_highlands"); |
60 + | Biome END_BARRENS = getBiome("end_barrens"); |
61 + | Biome WARM_OCEAN = getBiome("warm_ocean"); |
62 + | Biome LUKEWARM_OCEAN = getBiome("lukewarm_ocean"); |
63 + | Biome COLD_OCEAN = getBiome("cold_ocean"); |
64 + | Biome DEEP_LUKEWARM_OCEAN = getBiome("deep_lukewarm_ocean"); |
65 + | Biome DEEP_COLD_OCEAN = getBiome("deep_cold_ocean"); |
66 + | Biome DEEP_FROZEN_OCEAN = getBiome("deep_frozen_ocean"); |
67 + | Biome THE_VOID = getBiome("the_void"); |
68 + | Biome SUNFLOWER_PLAINS = getBiome("sunflower_plains"); |
69 + | Biome WINDSWEPT_GRAVELLY_HILLS = getBiome("windswept_gravelly_hills"); |
70 + | Biome FLOWER_FOREST = getBiome("flower_forest"); |
71 + | Biome ICE_SPIKES = getBiome("ice_spikes"); |
72 + | Biome OLD_GROWTH_BIRCH_FOREST = getBiome("old_growth_birch_forest"); |
73 + | Biome OLD_GROWTH_SPRUCE_TAIGA = getBiome("old_growth_spruce_taiga"); |
74 + | Biome WINDSWEPT_SAVANNA = getBiome("windswept_savanna"); |
75 + | Biome ERODED_BADLANDS = getBiome("eroded_badlands"); |
76 + | Biome BAMBOO_JUNGLE = getBiome("bamboo_jungle"); |
77 + | Biome SOUL_SAND_VALLEY = getBiome("soul_sand_valley"); |
78 + | Biome CRIMSON_FOREST = getBiome("crimson_forest"); |
79 + | Biome WARPED_FOREST = getBiome("warped_forest"); |
80 + | Biome BASALT_DELTAS = getBiome("basalt_deltas"); |
81 + | Biome DRIPSTONE_CAVES = getBiome("dripstone_caves"); |
82 + | Biome LUSH_CAVES = getBiome("lush_caves"); |
83 + | Biome DEEP_DARK = getBiome("deep_dark"); |
84 + | Biome MEADOW = getBiome("meadow"); |
85 + | Biome GROVE = getBiome("grove"); |
86 + | Biome SNOWY_SLOPES = getBiome("snowy_slopes"); |
87 + | Biome FROZEN_PEAKS = getBiome("frozen_peaks"); |
88 + | Biome JAGGED_PEAKS = getBiome("jagged_peaks"); |
89 + | Biome STONY_PEAKS = getBiome("stony_peaks"); |
90 + | Biome CHERRY_GROVE = getBiome("cherry_grove"); |
78 91 | Experimental | .
79 92 | MinecraftExperimental.Requires.WINTER_DROP) | (
80 - | PALE_GARDEN, |
93 + | Biome PALE_GARDEN = Registry.BIOME.get(NamespacedKey.minecraft("pale_garden")); |
94 + | |
81 95 | /** |
82 96 | * Represents a custom Biome |
97 + | * |
98 + | * @deprecated Biome is no longer an enum, custom biomes will have their own biome instance. |
83 99 | */ |
84 - | CUSTOM; |
100 + | since = "1.21.3") ( |
101 + | Biome CUSTOM = Bukkit.getUnsafe().getCustomBiome(); |
102 + | |
103 + | |
104 + | private static Biome getBiome( String key) { |
105 + | return Registry.BIOME.getOrThrow(NamespacedKey.minecraft(key)); |
106 + | } |
85 107 | |
86 - | private final NamespacedKey key; |
108 + | /** |
109 + | * @param name of the biome. |
110 + | * @return the biome with the given name. |
111 + | * @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead. |
112 + | */ |
113 + | |
114 + | since = "1.21.3") ( |
115 + | static Biome valueOf( String name) { |
116 + | if ("CUSTOM".equals(name)) { |
117 + | return Biome.CUSTOM; |
118 + | } |
87 119 | |
88 - | private Biome() { |
89 - | this.key = NamespacedKey.minecraft(name().toLowerCase(Locale.ROOT)); |
120 + | Biome biome = Bukkit.getUnsafe().get(Registry.BIOME, NamespacedKey.fromString(name.toLowerCase(Locale.ROOT))); |
121 + | Preconditions.checkArgument(biome != null, "No biome found with the name %s", name); |
122 + | return biome; |
90 123 | } |
91 124 | |
125 + | /** |
126 + | * @return an array of all known biomes. |
127 + | * @deprecated use {@link Registry#iterator()}. |
128 + | */ |
92 129 | |
93 - | |
94 - | public NamespacedKey getKey() { |
95 - | return key; |
130 + | since = "1.21.3") ( |
131 + | static Biome[] values() { |
132 + | return Lists.newArrayList(Registry.BIOME).toArray(new Biome[0]); |
96 133 | } |
97 134 | } |