Jump to content

Recommended Posts

Posted

Hi guys,

 

I saw few posts on the subject, but they are quite old so I am not sure if the info is still good.

 

I would like to do an item, that when held in hand would emit light. I saw a small mod somewhere that let the player emit light when he is holding a torch. Any ideas how it is done?

 

I know that my shader does that also...

 

Any hint?

Posted

Actually, I found way to do it without Dynamic Lights. It seems to work pretty well: here is video showing the result:

 

I wrote a tutorial on how to do this here: http://jabelarminecraft.blogspot.com/p/minecraft-modding-making-hand-held.html

Fascinating. Could you have extended BlockAir instead of starting with just Block?

 

I started thinking about other blocktypes that a player can walk through (grass, water etc). You could take some of your methods into an interface and then extend each walk-through block class that you want to illuminate, implementing the interface. Then when walking, like would replace like (air becomes air-light, water becomes water-light etc). I can imagine the bugs... sugar cane uprooting when real water isn't adjacent. On expiration, the interface would put the parent block back in its place.

 

I'll give it a go when I get around to doing the mining helmet (or helm enchantment) on my to-do list.

 

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

The problem with using an invisible light block is that it needs to be in the gridspace.

 

If there are other blocks in the way, the block won't show up because it can't be placed.

 

The hacky method used in Dynamic Lights doesn't need a block to be set.

Posted

The problem with using an invisible light block is that it needs to be in the gridspace. If there are other blocks in the way...

How often will a block be in the way where a player has his head?

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

yes, the way I'm doing it is to find a space around the player's head, which presumably should already be free so collisions with other blocks shouldn't be an issue. In the case of being underwater though there is not space and so the light goes out, and same thing if you're entirely surrounded by tall grass, but that I think is realistic.

 

Jeffry, definitely you should see about extending the method. I probably did effectively make it like a BlockAir, so perhaps extending that would be a more logical approach. I mostly did the code to prove that it was possible, but I'm sure there are some issues with the way I'm doing it, but it seems to work well enough to be worthwhile for some mods.

 

One thing I want to do when I get around to it is to vary the light value based on the light value of the item. Right now they all cast the same amount of light. This would be pretty easy to fix, but I haven't got around to it.

 

Overall though I was pretty happy with the result.

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

Posted

Yeah I am kind of blocked on this because I wanted to add a hand held underwater light ... its pretty dark down there.

 

With the SEUS shader I can use a torch underwater, adding light. But it vanilla minecraft, I am stucked in the dark.

 

Still looking for a solution ...

Posted

Yeah I am kind of blocked on this because I wanted to add a hand held underwater light ... its pretty dark down there.

 

With the SEUS shader I can use a torch underwater, adding light. But it vanilla minecraft, I am stucked in the dark.

 

Still looking for a solution ...

 

You can make it work underwater. Instead of looking for air blocks you'd look for water blocks and your light-emitting block could extend water so it would look and act like water but otherwise do the stuff that I did (i.e. have tile entity that tracks whether it should be destroyed as player moves farther away). Instead of just destroying it you might want to replace it back with water block.

 

Anyway, the general idea should work under water, but instead of an air-like block you'd use a water-like block.

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

Posted

If thinking outside the box, then maybe a helm enchantment conferring night vision. If that's OP, then maybe a helm conferring night vision but very little protection.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

You can make it work underwater. Instead of looking for air blocks you'd look for water blocks and your light-emitting block could extend water so it would look and act like water but otherwise do the stuff that I did (i.e. have tile entity that tracks whether it should be destroyed as player moves farther away). Instead of just destroying it you might want to replace it back with water block.

 

Anyway, the general idea should work under water, but instead of an air-like block you'd use a water-like block.

Exactly, and the prospect of extending several different block types in the same way had me thinking that the first step is to move the tricks into an interface that each extension would implement (Java's way to achieve something like multiple inheritance).

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

If thinking outside the box, then maybe a helm enchantment conferring night vision. If that's OP, then maybe a helm conferring night vision but very little protection.

 

I did that already. I have a diver mask that provide this power. But it is still too dark for  my taste...

Posted

You could make a block that has Material.Water and renders like water for when the player is under water.

 

For things like tall grass and reeds you can check the block just above the player (to see if it is air) and place there instead of directly where the player's head is.

 

Also, it's a good idea to not update the light's position very often.  In the mod I have that does this I only move the light source if the player is about 5 or more blocks away from the current light source (and store the coordinates of said lightsource in the item).  That way the engine isn't getting hit with lighting updates every tick.  As you're underwater you'll have to experiment with how much distance you'll allow between the player's current position and the lightsource's, but it'll likely be 2 blocks.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

You could make a block that has Material.Water and renders like water for when the player is under water.

 

For things like tall grass and reeds you can check the block just above the player (to see if it is air) and place there instead of directly where the player's head is.

 

Also, it's a good idea to not update the light's position very often.  In the mod I have that does this I only move the light source if the player is about 5 or more blocks away from the current light source (and store the coordinates of said lightsource in the item).  That way the engine isn't getting hit with lighting updates every tick.  As you're underwater you'll have to experiment with how much distance you'll allow between the player's current position and the lightsource's, but it'll likely be 2 blocks.

 

Yes, that is pretty much what I did -- I search multiple positions around the player's head since it really doesn't need to be exactly in same place each time. I also use a tile entity to detect when the player has moved far away and then it self-destructs. There is probably some room for optimization though.

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

Posted

This is how I did it:

https://github.com/Draco18s/Artifacts/blob/master/main/java/com/draco18s/artifacts/components/ComponentLight.java

 

Note that this class is analogous to the Item class.  It has a different inheritance, due to how my mod works, but the functions are all called from an Item and do the same things (with a couple of convenience functions for certain other actions).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I have a diver mask that provides this power. But it is still too dark for  my taste...

Then you need to add the poor-man's vision enhancement: Boost the brightness on your monitor. YMMV, but for me it does wonders for the nether (changing nether-brick from solid black to dull-brown brick).

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.