#Setting the luminance dynamically doesn't work

7 messages · Page 1 of 1 (latest)

maiden carbon
#

So anyways, been learning Fabric (A lot easier than Forge) and it has been easy getting around it. There was some hiccups from here to there. This one seems to be quite annoying. I know it should work but it doesn't. I am trying to set the luminance of this block dynamically so every one of those blocks has a random luminance value.

Here is my code for it. Pretty sure it's all right. ChatGPT gives me the same result as I already put down.
https://github.com/jonathan-x01/project-backroom-1.20.4/blob/main/src/main/java/projectbackroom/jonathanx/blocks/level_0_led_dropceiling.java

Any helps is greatly appreciated.

GitHub

Contribute to jonathan-x01/project-backroom-1.20.4 development by creating an account on GitHub.

crimson talon
#

define "doesn't work"

maiden carbon
#

@crimson talon
This block is the LED light. It doesn't light up. Which is what I meant by not working. Apologies for the lack of detail on that.

I have set the luminance before at a fixed number before before deciding to randomizing those. Funny thing is that the blocks that had them are still lit up. For in depth look. On the right, there is a block state called "power". You can tell by the provided code that it gets randomized when placing. During the placement, it's suppose to set the luminance to the random value that was provided.

crimson talon
#

When you register your block, use .luminance(), and pass the method an instance of the ToIntFunction functional interface, which takes in a BlockState and returns an int. See the vanilla Furnace in Blocks.class for an example of this

#

as far as I'm aware, this line getSettings().luminance((value) -> value.get(LIGHTING)); doesn't do anything - you can't change the Settings of a block after its been registered

maiden carbon
#

@crimson talon
Thanks a lot. I've tested my code, and your explanation helped so thanks a bunch.