Vivecraft

Vivecraft

5M Downloads

ferritcore makes menuworlds fail on 1.20.6

fayer3 opened this issue ยท 3 comments

commented

maybe I did something wrong here

super(fluidState.getType(), (Reference2ObjectArrayMap<Property<?>, Comparable<?>>) fluidState.getValues(), fluidState.propertiesCodec);

[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)
commented

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:

  • Copy the map into a Reference2ObjectArrayMap yourself, instead of assuming the return type is one.
  • Pass null to the super constructor and then use reflection to set the values field to the return value of getValues() (this will succeed with or without FC).
  • Don't wrap FluidStates at all, it's rather hacky. ๐Ÿ˜›

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.

commented

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.

commented

fixed with ab0eed7