Origins (Fabric)

Origins (Fabric)

15M Downloads

Having multiple layers causes strange issues

SekoiaTree opened this issue ยท 0 comments

commented

I was debugging issue Ladysnake/Requiem#258 which is caused by selecting Demon -> Wandering Spirit as an origin. There's then this error in the logs:
java.lang.NullPointerException: null at io.github.apace100.origins.networking.ModPacketsC2S.lambda$null$1(ModPacketsC2S.java:72) ~[origins-fabric-0.6.1.jar:?] at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] at io.github.apace100.origins.networking.ModPacketsC2S.lambda$null$2(ModPacketsC2S.java:72) ~[origins-fabric-0.6.1.jar:?] at java.util.HashMap$Values.forEach(HashMap.java:976) ~[?:?] at io.github.apace100.origins.networking.ModPacketsC2S.lambda$chooseOrigin$3(ModPacketsC2S.java:71) ~[origins-fabric-0.6.1.jar:?] at net.minecraft.server.ServerTask.run(ServerTask.java:17) ~[minecraft-1.16.5-mapped-net.fabricmc.yarn-1.16.5+build.5-v2.jar:?] at net.minecraft.util.thread.ThreadExecutor.executeTask(ThreadExecutor.java:136) ~[minecraft-1.16.5-mapped-net.fabricmc.yarn-1.16.5+build.5-v2.jar:?] at net.minecraft.util.thread.ReentrantThreadExecutor.executeTask(ReentrantThreadExecutor.java:22) ~[minecraft-1.16.5-mapped-net.fabricmc.yarn-1.16.5+build.5-v2.jar:?] at net.minecraft.server.MinecraftServer.executeTask(MinecraftServer.java:752) ~[minecraft-1.16.5-mapped-net.fabricmc.yarn-1.16.5+build.5-v2.jar:?] at net.minecraft.server.MinecraftServer.executeTask(MinecraftServer.java:1776) ~[minecraft-1.16.5-mapped-net.fabricmc.yarn-1.16.5+build.5-v2.jar:?] at net.minecraft.util.thread.ThreadExecutor.runTask(ThreadExecutor.java:109) ~[minecraft-1.16.5-mapped-net.fabricmc.yarn-1.16.5+build.5-v2.jar:?] at net.minecraft.server.MinecraftServer.method_20415(MinecraftServer.java:732) ~[minecraft-1.16.5-mapped-net.fabricmc.yarn-1.16.5+build.5-v2.jar:?] at net.minecraft.server.MinecraftServer.runTask(MinecraftServer.java:726) ~[minecraft-1.16.5-mapped-net.fabricmc.yarn-1.16.5+build.5-v2.jar:?] at net.minecraft.util.thread.ThreadExecutor.runTasks(ThreadExecutor.java:119) ~[minecraft-1.16.5-mapped-net.fabricmc.yarn-1.16.5+build.5-v2.jar:?] at net.minecraft.server.MinecraftServer.method_16208(MinecraftServer.java:712) ~[minecraft-1.16.5-mapped-net.fabricmc.yarn-1.16.5+build.5-v2.jar:?] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:666) ~[minecraft-1.16.5-mapped-net.fabricmc.yarn-1.16.5+build.5-v2.jar:?] at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:227) ~[minecraft-1.16.5-mapped-net.fabricmc.yarn-1.16.5+build.5-v2.jar:?] at java.lang.Thread.run(Thread.java:834) [?:?]
This does not crash the game, but the dirt screen stays until a button is pressed (try escape).
After debugging this issue for a long time, I believe the issue is with PlayerOriginComponent flushing out the wrong entries of the hashmap.
image
Before removing anything
image
After
Entries that return an OriginsRemnantPower mark a new origin layer. However, it seems to have removed the wrong ones from the hashmap. I believe this is caused by PlayerOriginComponent, line 120:
if(!hasPowerType(powerEntry.getKey())) {
private boolean hasPowerType(PowerType<?> powerType) { return origins.values().stream().anyMatch(o -> o.hasPowerType(powerType)); }
I think this means that it removes powers not owned by any origin, but it seems to mess up. In any case, something is messing up and removing a power before it's used. I think this is canalized by having 2 layers of origins, however I'm not sure why you need to select wandering spirit specifically.