Vivecraft / VivecraftMod

An experimental port of Vivecraft to Forge/Fabric
Other
168 stars 45 forks source link

ferritcore makes menuworlds fail on 1.20.6 #279

Closed fayer3 closed 1 month ago

fayer3 commented 4 months ago

maybe I did something wrong here https://github.com/Vivecraft/VivecraftMod/blob/89e799195ea9b197a00a0a780fc98fff39b0b199/common/src/main/java/org/vivecraft/client_vr/menuworlds/MenuWorldRenderer.java#L1781

[20:29:37] [Worker-Main-17/ERROR]: Exception thrown when building main menu world, falling back to old menu room. 
 class malte0811.ferritecore.impl.FastMapEntryMap cannot be cast to class it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap (malte0811.ferritecore.impl.FastMapEntryMap and it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap are in unnamed module of loader net.fabricmc.loader.impl.launch.knot.KnotClassLoader @69b794e2)
[20:29:37] [Worker-Main-17/INFO]: [STDERR]: java.lang.ClassCastException: class malte0811.ferritecore.impl.FastMapEntryMap cannot be cast to class it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap (malte0811.ferritecore.impl.FastMapEntryMap and it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap are in unnamed module of loader net.fabricmc.loader.impl.launch.knot.KnotClassLoader @69b794e2)
[20:29:37] [Worker-Main-17/INFO]: [STDERR]:     at org.vivecraft.client_vr.menuworlds.MenuWorldRenderer$FluidStateWrapper.<init>(MenuWorldRenderer.java:1781)
[20:29:37] [Worker-Main-17/INFO]: [STDERR]:     at org.vivecraft.client_vr.menuworlds.MenuWorldRenderer.buildGeometry(MenuWorldRenderer.java:382)
[20:29:37] [Worker-Main-17/INFO]: [STDERR]:     at org.vivecraft.client_vr.menuworlds.MenuWorldRenderer.lambda$buildNext$2(MenuWorldRenderer.java:337)
[20:29:37] [Worker-Main-17/INFO]: [STDERR]:     at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
[20:29:37] [Worker-Main-17/INFO]: [STDERR]:     at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
[20:29:37] [Worker-Main-17/INFO]: [STDERR]:     at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
[20:29:37] [Worker-Main-17/INFO]: [STDERR]:     at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
[20:29:37] [Worker-Main-17/INFO]: [STDERR]:     at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
[20:29:37] [Worker-Main-17/INFO]: [STDERR]:     at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
[20:29:37] [Worker-Main-17/INFO]: [STDERR]:     at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
embeddedt commented 1 month ago

FerriteCore does not use a Reference2ObjectArrayMap to back blockstates, because it has very bad memory complexity as the number of states increases. This is accomplished by using ASM to widen the private values field type to Reference2ObjectMap. 99.9% of mods are not affected by this because the public getValues method already uses the more generic Reference2ObjectMap, and it returns the map directly, meaning no one else has a reason to AT the private field.

This creates a problem for you because you are no longer able to pass the return value of getValues() back into the constructor for another state object. I think your options are:

I would go with the first option because it doesn't look like this wrapper is used outside a very specific menu renderer and the fluid state values map shouldn't have enough properties that the performance of copying becomes a concern.

Techjar commented 1 month ago

The FluidState wrapper is necessary since certain checks for fluid types are tied to tags which aren't defined when a world isn't loaded. The renderer will not handle water/lava correctly if these checks don't return a correct result.

fayer3 commented 1 month ago

fixed with ab0eed7