PolyhedralDev / Terra

Voxel world generation modding platform
MIT License
638 stars 83 forks source link

[Bug] Biome not able to be fetched from CraftBiome.bukkitToMinecraft() #453

Open Dueris opened 4 months ago

Dueris commented 4 months ago

Pre-Issue Checklist

Environment

Name Value
Terra Version Latest(6.4.3-BETA-bukkit - 1.20.4)
Platform / Platform Version Canvas(Purpur fork) 1.20.4
Any External Plugins or Mods GenesisMC, playit-gg, SkinsRestorer
Terra Packs In Use Origen
Terra Addons In Use none

Issue Description

When using the bukkitToMinecraft(Biome bukkit) method in CraftBiome to retrieve the NMS impl of the Biome, it returns null due to the NMS impl not being present in the CraftRegistry.getMinecraftRegistry().

Steps to reproduce

GenesisMC is the Paper plugin version of the Origins mod, and when running Biome conditions in a biome generated by terra, it fails to retrieve the Biome from the Pair<Biome, BlockPos> for the condition, because the Biome is null. The NMS Biome and BlockPos Pair is created by this: new oshi.util.tuples.Pair<Biome, BlockPos>(CraftBiome.bukkitToMinecraft(biome), CraftLocation.toBlockPosition(blockPos)))

The provided "biome" instance is of a org.bukkit.Biome which is given by blockPos.getBlock().getBiome(). The pair gets passed into the Condition tester and then throws null when attempting to access the Pairs "A" value(the biome). The condition being executed is the apoli "temperature" condition and is tested in the code bellow:

(condition, biome) -> {
            String comparison = condition.get("comparison").toString();
            float compare_to = Float.parseFloat(condition.get("compare_to").toString());
            return Comparison.getFromString(comparison).compare(biome.getA().getBaseTemperature(), compare_to);
        }

Line 50(the return statement) is where it throws, which is where it accesses biome.getA(). The github repo of GenesisMC is:

If the issue isnt actually fixable(or needs to be fixed), how can I access the NMS instance of the Biome provided by Terra, or find an alternate way to gain access to those features.

Expected behavior

The Biome should be returned correctly via CraftBiome.bukkitToMinecraft().

Actual behavior

Throws a NullPointerException

Full stacktrace

Exception Stacktrace ``` java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.biome.BiomeBase.g()" because the return value of "oshi.util.tuples.Pair.getA()" is null at me.dueris.genesismc.factory.conditions.types.BiomeConditions.lambda$prep$3(BiomeConditions.java:50) ~[genesis-mc1.20-v1.0.0.jar:?] at me.dueris.genesismc.factory.conditions.types.BiomeConditions$ConditionFactory.test(BiomeConditions.java:87) ~[genesis-mc1.20-v1.0.0.jar:?] at me.dueris.genesismc.factory.conditions.ConditionExecutor.testBiome(ConditionExecutor.java:201) ~[genesis-mc1.20-v1.0.0.jar:?] at me.dueris.genesismc.factory.conditions.types.EntityConditions.lambda$prep$46(EntityConditions.java:453) ~[genesis-mc1.20-v1.0.0.jar:?] at me.dueris.genesismc.factory.conditions.types.EntityConditions$ConditionFactory.test(EntityConditions.java:664) ~[genesis-mc1.20-v1.0.0.jar:?] at me.dueris.genesismc.factory.conditions.ConditionExecutor.testEntity(ConditionExecutor.java:394) ~[genesis-mc1.20-v1.0.0.jar:?] at me.dueris.genesismc.factory.powers.apoli.Burn.run(Burn.java:45) ~[genesis-mc1.20-v1.0.0.jar:?] at me.dueris.genesismc.OriginScheduler$OriginSchedulerTree.run(OriginScheduler.java:73) ~[genesis-mc1.20-v1.0.0.jar:?] at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftTask.run(CraftTask.java:101) ~[?:git-Canvas-"7b2242c"] at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:482) ~[?:git-Canvas-"7b2242c"] at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1750) ~[?:git-Canvas-"7b2242c"] at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:511) ~[?:git-Canvas-"7b2242c"] at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1629) ~[?:git-Canvas-"7b2242c"] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1316) ~[?:git-Canvas-"7b2242c"] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:335) ~[?:git-Canvas-"7b2242c"] at java.lang.Thread.run(Thread.java:833) ~[?:?] ```

latest.log