Load default biomes into registry at earliest convenience, then load custom biomes later.

Dieser Commit ist enthalten in:
dordsor21 2021-08-19 13:48:24 +01:00
Ursprung 563ad7761a
Commit f412796f28
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
3 geänderte Dateien mit 12 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -236,18 +236,18 @@ public class WorldEditPlugin extends JavaPlugin {
// datapacks aren't loaded until just before the world is, and bukkit has no event for this
// so the earliest we can do this is in WorldInit
setupTags();
setupBiomes(); // FAWE - load biomes later
setupBiomes(); // FAWE - load biomes later. Initialize biomes twice to allow for the registry to be present for
// plugins requiring WE biomes during startup, as well as allowing custom biomes loaded later on to be present in WE.
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent(platform));
}
@SuppressWarnings({"deprecation", "unchecked"})
private void initializeRegistries() {
/* // FAWE start - move Biomes to their own method
for (Biome biome : Biome.values()) {
String lowerCaseBiomeName = biome.name().toLowerCase(Locale.ROOT);
BiomeType.REGISTRY.register("minecraft:" + lowerCaseBiomeName, new BiomeType("minecraft:" + lowerCaseBiomeName));
}
// FAWE start - move Biomes to their own method. Initialize biomes twice to allow for the registry to be present for
// plugins requiring WE biomes during startup, as well as allowing custom biomes loaded later on to be present in WE.
setupBiomes();
// FAWE end
/*
// Block & Item
for (Material material : Material.values()) {
@ -311,16 +311,13 @@ public class WorldEditPlugin extends JavaPlugin {
// FAWE start
private void setupBiomes() {
if (this.adapter.value().isPresent()) {
// We don't know which world is the one with the data packs
// so we just loop over them. Doesn't hurt
for (org.bukkit.World world : Bukkit.getWorlds()) {
// cast is needed, thanks to raw types <3
for (final NamespacedKey biome : ((BukkitImplAdapter<?>) adapter.value().get()).getRegisteredBiomes(world)) {
// Biomes are stored globally in the server. Registries are not kept per-world in Minecraft.
// The WorldServer get-registries method simply delegates to the MinecraftServer method.
for (final NamespacedKey biome : ((BukkitImplAdapter<?>) adapter.value().get()).getRegisteredBiomes()) {
if (BiomeType.REGISTRY.get(biome.toString()) == null) { // only register once
BiomeType.REGISTRY.register(biome.toString(), new BiomeType(biome.toString()));
}
}
}
} else {
LOGGER.warn("Failed to load biomes via adapter (not present). Will load via bukkit");
for (Biome biome : Biome.values()) {

Datei anzeigen

@ -311,10 +311,9 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
/**
* Returns an iterable of all biomes known to the server.
*
* @param world the world to load the registered biomes from.
* @return all biomes known to the server.
*/
default Iterable<NamespacedKey> getRegisteredBiomes(World world) {
default Iterable<NamespacedKey> getRegisteredBiomes() {
return Arrays.stream(Biome.values())
.map(Keyed::getKey)
.collect(Collectors.toList());