Finalised wolves

This commit is contained in:
OakLoaf 2025-06-19 21:44:24 +01:00
parent d71c6bb25f
commit 5446b729f9
3 changed files with 12 additions and 12 deletions

View File

@ -95,14 +95,15 @@ public class CommonListener implements Listener {
NamespacedKey biomeKey = wolf.getWorld().getBiome(wolf.getLocation()).getKey(); NamespacedKey biomeKey = wolf.getWorld().getBiome(wolf.getLocation()).getKey();
pack.getBiomeProvider().stream() pack.getBiomeProvider().stream()
.filter(biome -> ((BukkitPlatformBiome) biome.getPlatformBiome()).getHandle() .filter(biome -> {
.getKey().equals(biomeKey)) NamespacedKey key = ((BukkitPlatformBiome) biome.getPlatformBiome()).getContext()
.get(BukkitBiomeInfo.class)
.biomeKey();
return key.equals(biomeKey);
})
.findFirst() .findFirst()
.ifPresent(biome -> { .ifPresent(biome -> {
NamespacedKey vanillaBiomeKey = ((BukkitPlatformBiome) biome.getPlatformBiome()).getContext() NamespacedKey vanillaBiomeKey = ((BukkitPlatformBiome) biome.getPlatformBiome()).getHandle().getKey();
.get(BukkitBiomeInfo.class)
.vanillaBiomeKey();
switch(vanillaBiomeKey.toString()) { switch(vanillaBiomeKey.toString()) {
case "minecraft:snowy_taiga" -> wolf.setVariant(Variant.ASHEN); case "minecraft:snowy_taiga" -> wolf.setVariant(Variant.ASHEN);
case "minecraft:old_growth_pine_taiga" -> wolf.setVariant(Variant.BLACK); case "minecraft:old_growth_pine_taiga" -> wolf.setVariant(Variant.BLACK);

View File

@ -5,4 +5,4 @@ import com.dfsek.terra.api.properties.Properties;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
public record BukkitBiomeInfo(NamespacedKey vanillaBiomeKey) implements Properties {} public record BukkitBiomeInfo(NamespacedKey biomeKey) implements Properties {}

View File

@ -56,15 +56,14 @@ public class AwfulBukkitHacks {
Biome platform = NMSBiomeInjector.createBiome(biomeRegistry.get(vanillaMinecraftKey).orElseThrow().value(), vanillaBiomeProperties); Biome platform = NMSBiomeInjector.createBiome(biomeRegistry.get(vanillaMinecraftKey).orElseThrow().value(), vanillaBiomeProperties);
ResourceKey<Biome> delegateKey = ResourceKey.create( ResourceLocation delegateMinecraftKey = ResourceLocation.fromNamespaceAndPath("terra", NMSBiomeInjector.createBiomeID(pack, key));
Registries.BIOME, NamespacedKey delegateBukkitKey = NamespacedKey.fromString(delegateMinecraftKey.toString());
ResourceLocation.fromNamespaceAndPath("terra", NMSBiomeInjector.createBiomeID(pack, key)) ResourceKey<Biome> delegateKey = ResourceKey.create(Registries.BIOME, delegateMinecraftKey);
);
Reference<Biome> holder = biomeRegistry.register(delegateKey, platform, RegistrationInfo.BUILT_IN); Reference<Biome> holder = biomeRegistry.register(delegateKey, platform, RegistrationInfo.BUILT_IN);
Reflection.REFERENCE.invokeBindValue(holder, platform); // IMPORTANT: bind holder. Reflection.REFERENCE.invokeBindValue(holder, platform); // IMPORTANT: bind holder.
platformBiome.getContext().put(new BukkitBiomeInfo(vanillaBukkitKey)); platformBiome.getContext().put(new BukkitBiomeInfo(delegateBukkitKey));
platformBiome.getContext().put(new NMSBiomeInfo(delegateKey)); platformBiome.getContext().put(new NMSBiomeInfo(delegateKey));
terraBiomeMap.computeIfAbsent(vanillaMinecraftKey, i -> new ArrayList<>()).add(delegateKey.location()); terraBiomeMap.computeIfAbsent(vanillaMinecraftKey, i -> new ArrayList<>()).add(delegateKey.location());