Jump to content

How to make a block light up the area around it?


Toastrackenigma

Recommended Posts

The question's basically the title :)

How can I make my custom block like up the area around it? I tried setLightLevel(32F); but the appears to be inside the block rather than outside it. (Basically I want it to act like Glowstone)

I'm new to modding (I started my first mod yesterday) and so I'm sure it's a basic problem but I searched Google for over an hour without finding anything, so I came here!

Thanks in advance!

-Toastrackenigma

Link to comment
Share on other sites

While what Phyyrus said is true, you need to do more than look on google.

 

For trying to figure out how to do something, this is what I do:

Is there a vanilla object that does what I want?

Yes:

    Look at relevant code for inspiration on how to do it. (If this still doesn't help, google).

No:

    Google

 

Basically, please try to be a bit more of a... "research monkey". Don't ask me where that term came from... I have no idea myself. Hopefully the meaning is still there.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Link to comment
Share on other sites

@Phyyrus: Although that used to work in 1.6.4 I am trying to mod 1.7 (sorry, I forgot to mention that :P) and setLightValue has been replaced with setLightLevel which for some reason is not working for me

 

@Kwibble: I tried looking through the Vanilla code for Minecraft (specifically at the glowstone and torch java files) but I couldn't see any reference to emitting light no matter how hard I looked. Also, there seem to be no tutorials on Google/Youtube for adding this kind of functionality.

 

Thanks for your replies!

Link to comment
Share on other sites

@Toastrackenigma: .setLightLevel(float) should work. I checked in Block.java, and Glowstone's is .setLightLevel(1.0F).

 

This is Modder SUPPORT not Modder Ask-a-question-and-get-fed.

 

The point is for the OP to learn to do things for themselves.

 

(Also if you hadn't noticed the OP already tried setLightLevel(32F); Read before you post please)

 

@OP As an extra tidbit, DO NOT use a number any higher than 1.0F - it doesn't work.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Link to comment
Share on other sites

@F1repl4ce Thanks, it worked!

@Kwibble Thanks also, I didn't think to look there and had just found it when @F1repl4ce replied. I also didn't know that about numbers higher than 1.0F - I thought the higher the float the more light would be emitted... well there's why it wasn't working!

 

For anyone that's intrested / having the same problem my final code is now setLightLevel(1.0F);

Link to comment
Share on other sites

@F1repl4ce Thanks, it worked!

@Kwibble Thanks also, I didn't think to look there and had just found it when @F1repl4ce replied. I also didn't know that about numbers higher than 1.0F - I thought the higher the float the more light would be emitted... well there's why it wasn't working!

 

For anyone that's intrested / having the same problem my final code is now setLightLevel(1.0F);

Not sure why @Kwibble was being hard on you because you had actually tried the right method and if you hadn't encountered it before you may not ever have realized that the float value is really more of a percentage so has limited range.  1.0F = maximum, 0.0F = minimum and you can guess what values in between do.  Now you know.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

@F1repl4ce Thanks, it worked!

@Kwibble Thanks also, I didn't think to look there and had just found it when @F1repl4ce replied. I also didn't know that about numbers higher than 1.0F - I thought the higher the float the more light would be emitted... well there's why it wasn't working!

 

For anyone that's intrested / having the same problem my final code is now setLightLevel(1.0F);

Not sure why @Kwibble was being hard on you because you had actually tried the right method and if you hadn't encountered it before you may not ever have realized that the float value is really more of a percentage so has limited range.  1.0F = maximum, 0.0F = minimum and you can guess what values in between do.  Now you know.

 

I wasn't trying to be hard on them... I - yeah I got no excuse. Sorry mate.

 

But I still strongly suggest digging through anything you can find. What I did to figure out it can't be higher than 1.0 was to go to the actual implementation of setLightLevel() to see what it did. And I saw it would be illogical to be any higher than 1.

 

Once again, I apologize for my harsh nature and comment.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Link to comment
Share on other sites

@Kwibble That's fine :) It was my second day modding and I hadn't even realised I could look at MC's source code so you had a point!

@drok0920 That's actually a pretty interesting question. Also, before I figured out that 1.0F was the highest you could go I set the block to 16.0F and it actually darkened rather than lit... sort of acting as a blackout torch. It was kinda cool and I had half a mind to keep it in the mod :P

Link to comment
Share on other sites

@dork: It is posibble without editing the light engine!

You have to place an EnumSkyBlock(with .setLightValue) around the block you want to be brighter.

Minecraft gonna check for the incorrect light sometimes so you have to keep the light updated.

If you remove the block use .updateLightByType at the created EnumSkyBlocks to delete the light!

 

If you not realy understand this stay at 1.0F!

Link to comment
Share on other sites

@dork: It is posibble without editing the light engine!

You have to place an EnumSkyBlock(with .setLightValue) around the block you want to be brighter.

Minecraft gonna check for the incorrect light sometimes so you have to keep the light updated.

If you remove the block use .updateLightByType at the created EnumSkyBlocks to delete the light!

 

If you not realy understand this stay at 1.0F!

 

No offence, but I am not sure ANYONE is going to understand this :/

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Link to comment
Share on other sites

@Toastrackenigma i took a good hour one day and just messed around with the lighting for blocks and it turns out that anything higher than 1.0F darkens it and 0.0F(or mabey it was 0.1F) made the texture appear to glow.

Good to know. I think that must have been how they made the blackout curtains in Extra Utilities. Also, after thinking about it some more I thought that there could be an item that you throw on the ground and it makes everything dark. That would be awesome :)

@Kriki98 So you're basically adding more than one blocks emitting 1.0F light but they're sky blocks so they just surround the block that looks like it's emitting the light. Sounds like a plan!

Link to comment
Share on other sites

@Kriki98 So you're basically adding more than one blocks emitting 1.0F light but they're sky blocks so they just surround the block that looks like it's emitting the light. Sounds like a plan!

 

Well, I'm glad you got what he meant. Kriki98's English isn't the best so I am having a hard time understanding them.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Link to comment
Share on other sites

@Kriki98 So you're basically adding more than one blocks emitting 1.0F light but they're sky blocks so they just surround the block that looks like it's emitting the light. Sounds like a plan!

 

Well, I'm glad you got what he meant. Kriki98's English isn't the best so I am having a hard time understanding them.

 

Somehow I feel like @Toastrackenigma was misunderstanding him too.

To me it sounded like @Kriki98 was talking about duping minecraft into thinking this block was a sky block, and thus a source of sunlight??

Either way I'm confused and intrigued.

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