8

I am trying to create handheld torches in vanilla minecraft with command blocks. I already have the way to detect a torch in hand and everything, now all i need is a way to get the lighting to that player.

The problem i have here is when i setblock a torch (setblock ~ ~ ~ torch), i have to fill an area around them with air (air 0 replace torch) to prevent them getting free torches. This does not fix that problem, as they can look down and break that torch and get the item. Is there a better way?

(PS. with end rod in 1.9 snapshots, they can't be passed through so you get stopped while walking.)

EDIT: to clarify, I am trying to get this working in a survival scenario, a player is going through a cave mining, so instead of placing torches they just switch to the torch to get light when they need it.

2
  • 1
    I think there may be a flag other than replace that causes the torch not to drop. I'll look into these things, because this sounds really cool
    – Unionhawk
    Commented Aug 13, 2015 at 15:10
  • I did this with 4 command blocks. I just wired them up to a fast clock Killing items @e[type=Item] and that worked. It wouldnt be good in a multiplayer scenario but for singleplayer it works with nearly no bugs ;)
    – Reflexive
    Commented Feb 18, 2017 at 18:01

4 Answers 4

4
+50

Seeing that you were desperate for a true answer, I built a prototype (Still adding the torch item drop prevention, as the one I made broke due to the execute detect function being really buggy).

This prototype does what you want for the most part. It uses 3 scoreboard objectives: Jump, jumpCool, and Torch.

Jump is basic. If you jumped it sets jumpCool to 5 and then sets itself to 0. jumpCool is the cooldown for when the light can be created. If you jumped it's set to 5, and if there is air below you it is set to 5. Torch is set to 1 if you're holding a torch.

From the prototype some issues do occur, one being that for every block torch's can't be placed on, you need to add a command block to blacklist it.

Here's the prototype setup and commands: http://imgur.com/a/i9Yo2

The command block not talked about in the above link is the broken drop protection. Basic armor stand to block access to the torch, and then have a despawn timer for the armor stand and then delete the torch along with it. Still working on that so when it's done I'll note that it is.

Finished version:

Download: https://www.dropbox.com/s/dn9q5xak462rhq9/Creative%20Mode%2015w32.zip?dl=0

8
  • Well, the contraption is finished. I'm going to make a quick video about it because it's... well... complicated... Commented Aug 15, 2015 at 22:48
  • What direction is ther comparator facing? it seems i may be building the same contraption as you in a different direction, therefor executing those commands in the wrong order.
    – Judge2020
    Commented Aug 16, 2015 at 1:08
  • it shouldn't matter. im uploading the video for the finished version atm, so i'd wait until its uploaded. Commented Aug 16, 2015 at 1:31
  • The video's up. Commented Aug 16, 2015 at 1:39
  • I'm sorry about this, but i don't think i can copy all of those command down through the video. A world download would be best for something this large.
    – Judge2020
    Commented Aug 16, 2015 at 2:16
1

This is a interesting question. Yes, it is possible, but an estimate of the amount of command blocks required would be 6-15.

One solution is placing torches at the players feet if they are holding a torch, and quickly placing and removing it will also continuously toggling the doTileDrops gamerule on and off.

There can be a slight problem with this method though.

  • Ticks. 20 ticks per second. The player can move on any one of these ticks. This means that if on a certain tick the player moves, then the torch may still be where it was placed.
  • Lighting offset is something else. The light will be 1 block below the handheld torch.

(I had some other reasons but after I typed them out I realized that the workaround I had typed was redundant).

I can't really think of a way to make this possible. Tick timings and other factors make this seem impossible at this current time.

0

If there is nothing else in that world, do /gamerule doTileDrops false. If there is something else in the world, you can try to fill up every space in that player's inventory with an item like stone, so they don't have enough space to take it.

2
  • I should have been more clear on this, I am trying to get this done in a survival scenario where the player is mining and just wants to switch to a torch for light.
    – Judge2020
    Commented Aug 13, 2015 at 15:13
  • @user3878893 Oh, sorry
    – APCoding
    Commented Aug 13, 2015 at 17:22
0

You could use command blocks (You said you had a way to test if the player was holding a torch) and have a comparator leading from the testfor command block giving that player night vision, /effect @a[] 16 1 5 (First number is ID, second is length, third is strength) Then all players holding a torch would get night vision.

1
  • 1
    I did consider this, but the problem is it's not limited light. I don't want them to see everything just by holding a torch, i want them to just see a few blocks ahead (basically just torch light distance)
    – Judge2020
    Commented Aug 20, 2015 at 15:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .