Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

  • Author

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

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

  • Author

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.