Jump to content

Recommended Posts

Posted

Finally some progress! The block can actually get to HIGH now. Still a problem, however. The lighting values aren't correct. In a cycle of HIGH -> MEDIUM -> LOW -> EMPTY it should, with the blockLightBulb instance I created, have a lighting cycle like this (if drained):

15 -> 6 -> 3 -> 0, but it goes like this:

0 -> 9 -> 12 -> 0. I tried using Math.round on the return values in getLightValue, but it didn't change. I definitely should've mentioned this earlier since it has always been a ever since I got the lighting to actually update at all.

 

Also, the block still doesn't update lighting when charging up. The main change from the previous code is that it actually logs HIGH, unlike any previous experiment.

 

Github

Posted (edited)

https://github.com/adudewithapc/Brighten-Up/blob/master/src/main/java/thatmartinguy/brightenup/block/BlockLamp.java#L34

Block::setLightLevel accepts a range of [0 - 1] and you are passing a 3.

https://github.com/adudewithapc/Brighten-Up/blob/master/src/main/java/thatmartinguy/brightenup/block/BlockLamp.java#L93

Block.lightValue is an integer that should be in range of [0 - 15]. In your case it is 45, as you are passing a 3 in your Block::setLightLevel.

Your light cycle is actually going to be

225 -> 90 -> 45 -> 0 (due to the way NibbleArray(the thing that stores the light values) functions it gets translated to 0 -> 9 -> 12 -> 0). 

 

If the code logs HIGH that means that you are either full of energy or your LightLevel calculations are off. Debug it further to see which case it is.

Edited by V0idWa1k3r
Posted

I managed to fix the lighting- somewhat. I just now realised that I was using Block#lightLevel to update my lighting, instead of the actual base light level like I had intended. A new variable has been introduced and the setLightLevel parameter that I passed in has also been updated. The multipliers for the lighting are a bit too high, though, and it gets brighter than minecraft can handle. A small tweak to them will fix it though.

 

Still, though, the lighting only updates when the block is draining, not when it gets charged. Why is this?

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.