Are IGlowingItem and ColoredLightManager usable API?
FirokOtaku opened this issue ยท 7 comments
Currently I tested API by following steps:
- Implement a Item:
GlowingStoneItem extends Item implements IGlowingItem
- Implement
IGlowingItem#produceColoredLight
method@Override public ColoredLight produceColoredLight(Entity entity, ItemStack stack) { return new ColoredLight.Builder() .pos(entity) .color(0xff0000, false) .radius(10f) .build(); }
- Call
org.zeith.hammerlib.api.lighting.ColoredLightManager#registerOperator(BooleanSupplier, BooleanSupplier, BooleanSupplier, BooleanSupplier, BooleanSupplier, BooleanSupplier)
Seems this API would set values of ColoredLightManager fields.BooleanSupplier setTrue = () -> true; ColoredLightManager.registerOperator(setTrue, setTrue, setTrue, setTrue, setTrue, setTrue); // //
Though I don't know what does those fields mean and influence. - Start game, hold a
GlowingStoneItem
instance in hand but nothing happens
Is colored light not a usable feature for now? Am I doing something wrong?
If I was doing something wrong, is there a Wiki/doc/example to show the corrently way of using that API?
I don't have enough time to research thru 1.19 rendering system to inject colored lighting into it either
Ohh okay. No wonder I didn't find a shader or anything related to colored lighting in the source code of Hammer Lib ๐คฃ๐คฃ
So is there a mod implemented colored lighting engine in 1.19.x+
? Colored Lux only supports 1.12.2
.
Hammer Lib does not provide a colored lighting engine itself, only an API for mods like Colored Lux.
The ColoredLightManager.registerOperator
is for those mods to declare how to handle everything.
๐ข๐ข๐ข
BTW calling ColoredLightManager.registerOperator
would print multiple errors
java.lang.NoSuchMethodException: sun.reflect.ReflectionFactory.newFieldAccessor(java.lang.reflect.Field,boolean)
at java.base/java.lang.Class.getDeclaredMethod(Class.java:2675)
at TRANSFORMER/[email protected]/org.zeith.hammerlib.util.java.ReflectionUtil.makeWritable(ReflectionUtil.java:201)
at TRANSFORMER/[email protected]/org.zeith.hammerlib.util.java.ReflectionUtil.setFinalField(ReflectionUtil.java:184)
at TRANSFORMER/[email protected]/org.zeith.hammerlib.util.java.ReflectionUtil.setStaticFinalField(ReflectionUtil.java:170)
at TRANSFORMER/[email protected]/org.zeith.hammerlib.util.java.ReflectionUtil.setStaticFinalField(ReflectionUtil.java:156)
at TRANSFORMER/[email protected]/org.zeith.hammerlib.api.lighting.ColoredLightManager.registerOperator(ColoredLightManager.java:67)
at TRANSFORMER/[email protected]/firok.mc.codebase.client.MinecraftCodebaseClient.onClientSetup(MinecraftCodebaseClient.java:60)
at TRANSFORMER/[email protected]/firok.mc.codebase.client.__MinecraftCodebaseClient_onClientSetup_FMLClientSetupEvent.invoke(.dynamic)
at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73)
at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:315)
at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:296)
at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.javafmlmod.FMLModContainer.acceptEvent(FMLModContainer.java:107)
at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$10(ModContainer.java:122)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run$$$capture(CompletableFuture.java:1804)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
at java.base/java.util.concurrent.ForkJoinTask.doExec$$$capture(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Is this because I'm using GraalVM 17 (graalvm-ce-java17-21.3.0
)?
(I found there is a static FieldAccessor newFieldAccessor(Field field, boolean isReadOnly)
in jdk.internal.reflect.UnsafeFieldAccessorFactory
)
Oh, yeah, I should have replaced that stuff ages ago. It's cuz java made things a bit different, so those "makeWritable" methods don't work on java 17.