Low-Drag-MC / Shimmer

A mod that integrates my passion for rendering
MIT License
70 stars 22 forks source link

No colored light visible when using java API LightManager.INSTANCE.registerBlockLight from the wiki, custom block #26

Closed Lothrazar closed 2 years ago

Lothrazar commented 2 years ago

Minecraft Version

1.18.2

Shimmer version

2:0.1.10

Modpack info or mod list

making a new mod

The latest.log file

https://pastebin.com/9k0as8Ee

optifine , Rubidium , flywheel or any rendering related mods. mod versrion is required.

Nope no other rendering mods, only forge 40.1.71 and my new custom mod. and JEI

Issue description

Im using the JAVA api from the wiki, and i wanted to give light to colored blocks.

However the light looks no different with or without the renderBlockLight call, i dont see anything. no colored light appears. i have a light block that changes color based on block state.

My code

    if (ModList.get().isLoaded("shimmer")) {
      LightManager.INSTANCE.registerBlockLight(LightBulbRegistry.BULB.get(), (state, pos) -> {
        if (state.hasProperty(BlockFlib.COLOUR)) {
          DyeColor colour = state.getValue(BlockFlib.COLOUR);
          System.out.println("LightManager.INSTANCE.registerBlockLight!colour" + colour.getMaterialColor().col);
          return new ColorPointLight.Template(16, colour.getMaterialColor().col);
        }
        return null;
      });

Which i targeted inside of FMLClientSetupEvent -> enqueueWork as said here https://github.com/Low-Drag-MC/Shimmer/wiki/Coloured-Lights

Steps to reproduce

i did not touch the configs at all, i simply added the mod with gradle.

Then i added only the call to LightManager.INSTANCE.registerBlockLight( for my block

Other information

Screenshot no show

Yefancy commented 2 years ago

are you sure that the code in LightWrapper.init be executed

Yefancy commented 2 years ago

btw, the color should be 0xAARRGGBB, I suppose your color is 0x00RRGGBB

Yefancy commented 2 years ago

int color = DyeColor.color | 0xff000000.

besides, light radius is better be set as the light value of the block (no more than 15)

Lothrazar commented 2 years ago

it works! thank you for that last tip. i had to mask the color just like you said , i guess the first two 'ff's add an alpha or something similar

I dont see a visual difference when i change that first value. but yeah my light Level on the block is hardcoded at 15 so this works

        DyeColor colour = state.getValue(BlockFlib.COLOUR);
        int col = colour.getMaterialColor().col | 0xff000000;
        return new ColorPointLight.Template(14, col);

works