mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-05 16:49:39 +00:00
#1073: Make Biome an interface
This commit is contained in:
parent
a38581aa89
commit
97c5926140
3 changed files with 119 additions and 78 deletions
|
@ -105,7 +105,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||||
*
|
*
|
||||||
* @see Biome
|
* @see Biome
|
||||||
*/
|
*/
|
||||||
Registry<Biome> BIOME = new SimpleRegistry<>(Biome.class);
|
Registry<Biome> BIOME = Objects.requireNonNull(Bukkit.getRegistry(Biome.class), "No registry present for Biome. This is a bug.");
|
||||||
/**
|
/**
|
||||||
* Server block types.
|
* Server block types.
|
||||||
*
|
*
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.google.common.collect.Multimap;
|
||||||
import org.bukkit.advancement.Advancement;
|
import org.bukkit.advancement.Advancement;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.attribute.AttributeModifier;
|
import org.bukkit.attribute.AttributeModifier;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.damage.DamageEffect;
|
import org.bukkit.damage.DamageEffect;
|
||||||
import org.bukkit.damage.DamageSource;
|
import org.bukkit.damage.DamageSource;
|
||||||
|
@ -133,4 +134,7 @@ public interface UnsafeValues {
|
||||||
|
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
<B extends Keyed> B get(Registry<B> registry, NamespacedKey key);
|
<B extends Keyed> B get(Registry<B> registry, NamespacedKey key);
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
|
Biome getCustomBiome();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,97 +1,134 @@
|
||||||
package org.bukkit.block;
|
package org.bukkit.block;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.FeatureFlag;
|
||||||
import org.bukkit.Keyed;
|
import org.bukkit.Keyed;
|
||||||
import org.bukkit.MinecraftExperimental;
|
import org.bukkit.MinecraftExperimental;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.Registry;
|
||||||
|
import org.bukkit.packs.DataPack;
|
||||||
|
import org.bukkit.util.OldEnum;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds all accepted Biomes in the default server
|
* Holds all accepted Biomes in the server.
|
||||||
|
* <p>
|
||||||
|
* The Biomes listed in this interface are present in the default server
|
||||||
|
* or can be enabled via a {@link FeatureFlag}.
|
||||||
|
* There may be additional biomes present in the server, for example from a {@link DataPack}
|
||||||
|
* which can be accessed via {@link Registry#BIOME}.
|
||||||
*/
|
*/
|
||||||
public enum Biome implements Keyed {
|
public interface Biome extends OldEnum<Biome>, Keyed {
|
||||||
OCEAN,
|
|
||||||
PLAINS,
|
Biome OCEAN = getBiome("ocean");
|
||||||
DESERT,
|
Biome PLAINS = getBiome("plains");
|
||||||
WINDSWEPT_HILLS,
|
Biome DESERT = getBiome("desert");
|
||||||
FOREST,
|
Biome WINDSWEPT_HILLS = getBiome("windswept_hills");
|
||||||
TAIGA,
|
Biome FOREST = getBiome("forest");
|
||||||
SWAMP,
|
Biome TAIGA = getBiome("taiga");
|
||||||
MANGROVE_SWAMP,
|
Biome SWAMP = getBiome("swamp");
|
||||||
RIVER,
|
Biome MANGROVE_SWAMP = getBiome("mangrove_swamp");
|
||||||
NETHER_WASTES,
|
Biome RIVER = getBiome("river");
|
||||||
THE_END,
|
Biome NETHER_WASTES = getBiome("nether_wastes");
|
||||||
FROZEN_OCEAN,
|
Biome THE_END = getBiome("the_end");
|
||||||
FROZEN_RIVER,
|
Biome FROZEN_OCEAN = getBiome("frozen_ocean");
|
||||||
SNOWY_PLAINS,
|
Biome FROZEN_RIVER = getBiome("frozen_river");
|
||||||
MUSHROOM_FIELDS,
|
Biome SNOWY_PLAINS = getBiome("snowy_plains");
|
||||||
BEACH,
|
Biome MUSHROOM_FIELDS = getBiome("mushroom_fields");
|
||||||
JUNGLE,
|
Biome BEACH = getBiome("beach");
|
||||||
SPARSE_JUNGLE,
|
Biome JUNGLE = getBiome("jungle");
|
||||||
DEEP_OCEAN,
|
Biome SPARSE_JUNGLE = getBiome("sparse_jungle");
|
||||||
STONY_SHORE,
|
Biome DEEP_OCEAN = getBiome("deep_ocean");
|
||||||
SNOWY_BEACH,
|
Biome STONY_SHORE = getBiome("stony_shore");
|
||||||
BIRCH_FOREST,
|
Biome SNOWY_BEACH = getBiome("snowy_beach");
|
||||||
DARK_FOREST,
|
Biome BIRCH_FOREST = getBiome("birch_forest");
|
||||||
SNOWY_TAIGA,
|
Biome DARK_FOREST = getBiome("dark_forest");
|
||||||
OLD_GROWTH_PINE_TAIGA,
|
Biome SNOWY_TAIGA = getBiome("snowy_taiga");
|
||||||
WINDSWEPT_FOREST,
|
Biome OLD_GROWTH_PINE_TAIGA = getBiome("old_growth_pine_taiga");
|
||||||
SAVANNA,
|
Biome WINDSWEPT_FOREST = getBiome("windswept_forest");
|
||||||
SAVANNA_PLATEAU,
|
Biome SAVANNA = getBiome("savanna");
|
||||||
BADLANDS,
|
Biome SAVANNA_PLATEAU = getBiome("savanna_plateau");
|
||||||
WOODED_BADLANDS,
|
Biome BADLANDS = getBiome("badlands");
|
||||||
SMALL_END_ISLANDS,
|
Biome WOODED_BADLANDS = getBiome("wooded_badlands");
|
||||||
END_MIDLANDS,
|
Biome SMALL_END_ISLANDS = getBiome("small_end_islands");
|
||||||
END_HIGHLANDS,
|
Biome END_MIDLANDS = getBiome("end_midlands");
|
||||||
END_BARRENS,
|
Biome END_HIGHLANDS = getBiome("end_highlands");
|
||||||
WARM_OCEAN,
|
Biome END_BARRENS = getBiome("end_barrens");
|
||||||
LUKEWARM_OCEAN,
|
Biome WARM_OCEAN = getBiome("warm_ocean");
|
||||||
COLD_OCEAN,
|
Biome LUKEWARM_OCEAN = getBiome("lukewarm_ocean");
|
||||||
DEEP_LUKEWARM_OCEAN,
|
Biome COLD_OCEAN = getBiome("cold_ocean");
|
||||||
DEEP_COLD_OCEAN,
|
Biome DEEP_LUKEWARM_OCEAN = getBiome("deep_lukewarm_ocean");
|
||||||
DEEP_FROZEN_OCEAN,
|
Biome DEEP_COLD_OCEAN = getBiome("deep_cold_ocean");
|
||||||
THE_VOID,
|
Biome DEEP_FROZEN_OCEAN = getBiome("deep_frozen_ocean");
|
||||||
SUNFLOWER_PLAINS,
|
Biome THE_VOID = getBiome("the_void");
|
||||||
WINDSWEPT_GRAVELLY_HILLS,
|
Biome SUNFLOWER_PLAINS = getBiome("sunflower_plains");
|
||||||
FLOWER_FOREST,
|
Biome WINDSWEPT_GRAVELLY_HILLS = getBiome("windswept_gravelly_hills");
|
||||||
ICE_SPIKES,
|
Biome FLOWER_FOREST = getBiome("flower_forest");
|
||||||
OLD_GROWTH_BIRCH_FOREST,
|
Biome ICE_SPIKES = getBiome("ice_spikes");
|
||||||
OLD_GROWTH_SPRUCE_TAIGA,
|
Biome OLD_GROWTH_BIRCH_FOREST = getBiome("old_growth_birch_forest");
|
||||||
WINDSWEPT_SAVANNA,
|
Biome OLD_GROWTH_SPRUCE_TAIGA = getBiome("old_growth_spruce_taiga");
|
||||||
ERODED_BADLANDS,
|
Biome WINDSWEPT_SAVANNA = getBiome("windswept_savanna");
|
||||||
BAMBOO_JUNGLE,
|
Biome ERODED_BADLANDS = getBiome("eroded_badlands");
|
||||||
SOUL_SAND_VALLEY,
|
Biome BAMBOO_JUNGLE = getBiome("bamboo_jungle");
|
||||||
CRIMSON_FOREST,
|
Biome SOUL_SAND_VALLEY = getBiome("soul_sand_valley");
|
||||||
WARPED_FOREST,
|
Biome CRIMSON_FOREST = getBiome("crimson_forest");
|
||||||
BASALT_DELTAS,
|
Biome WARPED_FOREST = getBiome("warped_forest");
|
||||||
DRIPSTONE_CAVES,
|
Biome BASALT_DELTAS = getBiome("basalt_deltas");
|
||||||
LUSH_CAVES,
|
Biome DRIPSTONE_CAVES = getBiome("dripstone_caves");
|
||||||
DEEP_DARK,
|
Biome LUSH_CAVES = getBiome("lush_caves");
|
||||||
MEADOW,
|
Biome DEEP_DARK = getBiome("deep_dark");
|
||||||
GROVE,
|
Biome MEADOW = getBiome("meadow");
|
||||||
SNOWY_SLOPES,
|
Biome GROVE = getBiome("grove");
|
||||||
FROZEN_PEAKS,
|
Biome SNOWY_SLOPES = getBiome("snowy_slopes");
|
||||||
JAGGED_PEAKS,
|
Biome FROZEN_PEAKS = getBiome("frozen_peaks");
|
||||||
STONY_PEAKS,
|
Biome JAGGED_PEAKS = getBiome("jagged_peaks");
|
||||||
CHERRY_GROVE,
|
Biome STONY_PEAKS = getBiome("stony_peaks");
|
||||||
|
Biome CHERRY_GROVE = getBiome("cherry_grove");
|
||||||
@ApiStatus.Experimental
|
@ApiStatus.Experimental
|
||||||
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
|
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
|
||||||
PALE_GARDEN,
|
Biome PALE_GARDEN = Registry.BIOME.get(NamespacedKey.minecraft("pale_garden"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a custom Biome
|
* Represents a custom Biome
|
||||||
|
*
|
||||||
|
* @deprecated Biome is no longer an enum, custom biomes will have their own biome instance.
|
||||||
*/
|
*/
|
||||||
CUSTOM;
|
@Deprecated(since = "1.21.3")
|
||||||
|
Biome CUSTOM = Bukkit.getUnsafe().getCustomBiome();
|
||||||
private final NamespacedKey key;
|
|
||||||
|
|
||||||
private Biome() {
|
|
||||||
this.key = NamespacedKey.minecraft(name().toLowerCase(Locale.ROOT));
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
private static Biome getBiome(@NotNull String key) {
|
||||||
public NamespacedKey getKey() {
|
return Registry.BIOME.getOrThrow(NamespacedKey.minecraft(key));
|
||||||
return key;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name of the biome.
|
||||||
|
* @return the biome with the given name.
|
||||||
|
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
@Deprecated(since = "1.21.3")
|
||||||
|
static Biome valueOf(@NotNull String name) {
|
||||||
|
if ("CUSTOM".equals(name)) {
|
||||||
|
return Biome.CUSTOM;
|
||||||
|
}
|
||||||
|
|
||||||
|
Biome biome = Bukkit.getUnsafe().get(Registry.BIOME, NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
|
||||||
|
Preconditions.checkArgument(biome != null, "No biome found with the name %s", name);
|
||||||
|
return biome;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return an array of all known biomes.
|
||||||
|
* @deprecated use {@link Registry#iterator()}.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
@Deprecated(since = "1.21.3")
|
||||||
|
static Biome[] values() {
|
||||||
|
return Lists.newArrayList(Registry.BIOME).toArray(new Biome[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue