mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-12 10:46:25 +00:00
Added biome-key-format configuration option to config.yml
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_21_7;
|
||||
|
||||
import com.dfsek.terra.bukkit.PlatformImpl;
|
||||
import com.dfsek.terra.bukkit.nms.v1_21_7.config.VanillaBiomeProperties;
|
||||
|
||||
import com.dfsek.terra.bukkit.world.BukkitBiomeInfo;
|
||||
@@ -28,7 +29,6 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.dfsek.terra.bukkit.world.BukkitPlatformBiome;
|
||||
import com.dfsek.terra.registry.master.ConfigRegistry;
|
||||
|
||||
|
||||
public class AwfulBukkitHacks {
|
||||
@@ -36,7 +36,7 @@ public class AwfulBukkitHacks {
|
||||
|
||||
private static final Map<ResourceLocation, List<ResourceLocation>> terraBiomeMap = new HashMap<>();
|
||||
|
||||
public static void registerBiomes(ConfigRegistry configRegistry) {
|
||||
public static void registerBiomes(PlatformImpl platform) {
|
||||
try {
|
||||
LOGGER.info("Hacking biome registry...");
|
||||
MappedRegistry<Biome> biomeRegistry = (MappedRegistry<Biome>) RegistryFetcher.biomeRegistry();
|
||||
@@ -45,7 +45,7 @@ public class AwfulBukkitHacks {
|
||||
Reflection.MAPPED_REGISTRY.setFrozen(biomeRegistry, false);
|
||||
|
||||
// Register the terra biomes to the registry
|
||||
configRegistry.forEach(pack -> pack.getRegistry(com.dfsek.terra.api.world.biome.Biome.class).forEach((key, biome) -> {
|
||||
platform.getRawConfigRegistry().forEach(pack -> pack.getRegistry(com.dfsek.terra.api.world.biome.Biome.class).forEach((key, biome) -> {
|
||||
try {
|
||||
BukkitPlatformBiome platformBiome = (BukkitPlatformBiome) biome.getPlatformBiome();
|
||||
NamespacedKey vanillaBukkitKey = platformBiome.getHandle().getKey();
|
||||
@@ -54,14 +54,13 @@ public class AwfulBukkitHacks {
|
||||
|
||||
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
||||
|
||||
Biome platform = NMSBiomeInjector.createBiome(biomeRegistry.get(vanillaMinecraftKey).orElseThrow().value(), vanillaBiomeProperties);
|
||||
|
||||
ResourceLocation delegateMinecraftKey = ResourceLocation.fromNamespaceAndPath("terra", NMSBiomeInjector.createBiomeID(pack, key));
|
||||
Biome nmsBiome = NMSBiomeInjector.createBiome(biomeRegistry.get(vanillaMinecraftKey).orElseThrow().value(), vanillaBiomeProperties);
|
||||
ResourceLocation delegateMinecraftKey = ResourceLocation.tryParse(platform.getTerraConfig().getBiomeKey(pack, key).toString());
|
||||
NamespacedKey delegateBukkitKey = NamespacedKey.fromString(delegateMinecraftKey.toString());
|
||||
ResourceKey<Biome> delegateKey = ResourceKey.create(Registries.BIOME, delegateMinecraftKey);
|
||||
|
||||
Reference<Biome> holder = biomeRegistry.register(delegateKey, platform, RegistrationInfo.BUILT_IN);
|
||||
Reflection.REFERENCE.invokeBindValue(holder, platform); // IMPORTANT: bind holder.
|
||||
Reference<Biome> holder = biomeRegistry.register(delegateKey, nmsBiome, RegistrationInfo.BUILT_IN);
|
||||
Reflection.REFERENCE.invokeBindValue(holder, nmsBiome); // IMPORTANT: bind holder.
|
||||
|
||||
platformBiome.getContext().put(new BukkitBiomeInfo(delegateBukkitKey));
|
||||
platformBiome.getContext().put(new NMSBiomeInfo(delegateKey));
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.dfsek.terra.bukkit.nms.Initializer;
|
||||
public class NMSInitializer implements Initializer {
|
||||
@Override
|
||||
public void initialize(PlatformImpl platform) {
|
||||
AwfulBukkitHacks.registerBiomes(platform.getRawConfigRegistry());
|
||||
AwfulBukkitHacks.registerBiomes(platform);
|
||||
Bukkit.getPluginManager().registerEvents(new NMSInjectListener(), platform.getPlugin());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user