Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.18.1] Making existing blocks emit light


Minetrinity
 Share

Recommended Posts

I am making a mod that is supposed to make wood emit light when clicked with a stick.

So far I have the RightClickBlock that tests for when a Player is clicking a planks block while holding a stick, but how do I make that single wood block emit light?

I have seen Blockstate#setLightLevel(), but that doesnt exist in 1.18.1. 

It probably would be doable using reflection to set the light of ALL wood blocks, but I need to set the light level ONLY for the CLICKED wood block.

Edited by Minetrinity
Link to comment
Share on other sites

  • Minetrinity changed the title to [1.18.1] Making existing blocks emit light

Yes, I thought about that, since Blockstate also has a function to get the Light.

But It lacks a method to change light.

Should I create a costum subclass of BlockState, or how do I create another Blockstate?

Edit: What is that MapCodec<BlockState> parameter in Blockstates constructor?

Edited by Minetrinity
Link to comment
Share on other sites

You cannot change the light level. The light level per BlockState is fixed. Hence: if you want to change the light level at a certain position, you must change the block state that is placed there. If you want a version of a block that is lit, you must create and register it yourself.

Link to comment
Share on other sites

Ok, how do I register a new blockstate for every block with the Tag "minecraft:planks" then?

I can not simply create a planks block class, because other mods might also add new planks blocks.

Edited by Minetrinity
Link to comment
Share on other sites

4 minutes ago, Minetrinity said:

Ok, how do I register a new blockstate for every block with the Tag "minecraft:planks" then?

you can't register a new BlockState you need a custom Block,
since the BlockStates are bind to the Block

4 minutes ago, Minetrinity said:

I can not simply create a planks block class, because other mods might also add new planks blocks.

thats a good idea, but unfortunately you can't use the planks Tag since it's initialize later than the registery is fired,
i would recommend you to only replace the vanilla planks, then create a way that allows other mods to add your PlankBlock

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.