First, disclamer, I do not encourage smoking. I'm making a machine that allow you to "smoke" in minecraft only to add some gameplay to the smoking lounge of the victorian manor in my adventure map.
here is the circuit:
And here are the steps and related problem
1- Look if a player is holding a rabbit foor renamed "pipe" in his active slot (0 to 8) [not sure it would make the difference between 2 players who as it]
---ex: /testfor @p {SelectedItemSlot:5,Inventory:[{Slot:5b,tag:{display:{Name:"Pipe"}}}]}
2- Look if a player has cocoa beans renamed "tobaco" in his inventory [not sure it would make the difference between 2 players who as it]
---:/testfor @p {Inventory:[{tag:{display:{Name:"Tobaco"}}}]}
3- Look if a player as a "smoke" score of 0 [does not work, is always on or always of]
---:/testfor @p[smoke=0,smoke min=0]
4- remove one "tobaco" from the playrs inventory and give him a "smoke" score of 10 [not sure it would affect the right player in multi]]
---:/clear @p[smoke_min=1] dye 3 1 {display:{Name:Tobaco}}
---:/scoreboard players set @p smoke 10
5- give a puff of smoke particle, slowness and mining fatigue and reduce the "smoke" score by 1 to all player with at least 1 of smoke score
[does'nt work, on all the time, doesn't care about the score + particle aren't on the player, they are on the command block + not sure it would affect the right player in multi]
--:/effect @a[smoke_min=1] 2 8 1 hideParticles
--:/effect @a[smoke_min=1] 4 8 3 hideParticles
--:/particle smoke ~ ~ ~ 1 1 1 0.001 60 @a[smoke_min=1]
--:/scoreboard players remove @a[smoke_min=1] smoke 1
So yeah... feels like designing my slot machine all over again! ¬.¬
I've made a few bongs and even a blunt before. I'm actually going to smoke a cigarette right now. When I get back I'll help you with this.
Alright, so based on what you already have here, I'm going to assume you understand the majority of what I'll be showing you. So I'm just going to share my bong with you.
First some objectives need to be made:
Also you can use the tag SelectedItem instead of SelectedItemSlot and you don't need to check all the slots.
Basically where you have a /testfor, you should replace that with /execute and put the command from the block that gets powered from the comparator output in the /execute command. And always use @a instead of @p. And for the items you're testing for, it's best to put as much info about them as you can so someone can't rename dirt tobacco and smoke for free!
Now I'll explain what my bong does. First you have to build the bong. Simply place a tripwire hook anywhere with a block of air below it and any block below that. Next throw any kind of tall "grass" at the hook. This is loading the bong. When you do this, the tall grass will no longer despawn or able to be picked up. It will also put some green particle effects on the hook (bong). Then walk into the bong and right click on it with your flint and steel to take a hit. It will give you 4:20 of hunger and after a little while you will exhale the smoke. Each tall grass gives the bong 3 hits. The tall grass is killed after the third hit. If the bong is broken while loaded the tall grass disappears.
The /stats command allows us to run a command as the grass and set the output of the command as a scoreboard variable on that tall grass entity.
I know you are making something completely different, but I hope this helped!
i'm sure it will help one way or another. but since i'm no expert it really drain my brain power to do complexe redstone (it's pretty mush like codding, which is incompatible with me) i'm gonna use those infos in the near futur. I'm to tired at the moment but i still wanted to thank you right now. i'll be back to update my progress when... well when i'll have that progress done
Hey you're getting the hang of it quite better than a lot of people. Don't put yourself down. I'll help walk you through what you will need to do, step by step, but since doing it yourself will not only make you feel much more accomplished, but actually help you learn and feel better about your command block knowledge, I won't directly be giving you the commands.
So the first thing you want to do is check if any player is holding a rabbit foot. The best way to do this for multiplayer compatibility is with the scoreboard command.
So we will first need to setup the scoreboard objective. This objective will only handle values and operations that we tell it to, so we will use a "dummy" type. I think you already understand that much, so I'll give you that command:
/scoreboard objectives add hasPipe dummy
Now we need to set a players hasPipe objective to 1 if they are indeed holding a "pipe". Just like the /testfor command, /scoreboard allows you to check an entities data tags. You can think of this as a very basic "if-then statement".
/scoreboard players set (player) (objective) (value) {data tag}
So if the player is holding a pipe then mark them as so, otherwise unmark them. To do this, you will need to set hasPipe to 0 before checking and setting to 1, because there is no "else statement" to rely on only if the test was false.
/scoreboard players set @a hasPipe 0
/scoreboard players set @a hasPipe 1 {SelectedItem:{id:"minecraft:rabbit_foot",tag:{display:{Name:"Pipe"}}}}
Now you can test for the tobacco on @a[score_hasPipe_min=1] and no need to keep the /testfor @p[score_smoke=0,score_smoke_min=0]. Instead you can just do
/scoreboard players set @a[score_hasPipe_min=1,score_smoke=0] smoke 10
This is because hasPipe can only ever be 0 or 1, never higher, so we can just check if it is at least 1. Then score_smoke=0 means the largest number it can be is 0. It can only ever be 0-10 and when it is >0 we don't want it to trigger.
I'm gonna stop here and leave you to it. Of course if you need more help, just ask!
/scoreboard players set @a hasPipe 1 {SelectedItem:{id:"minecraft:rabbit_foot",tag:{display:{Name:"Pipe"}}}}
dosen't see me holding a pipe... idk if there is something wrong with it
i tried the following variation but it doesn't work either:
/scoreboard players set @a[{SelectedItem:{id:"minecraft:rabbit_foot",tag:{display:{Name:"Pipe"}}}}] hasPipe 1
also (maybe that was for the next part) this method appear to keep your score at 10 as long as you hold the pipe, i need it to stop going at 10 when it's above 0 so tobaco will only be consumed by the pipe when you are at 10 and last a bit before consuming another item. So i need an additionnal condition of having a smoke score below 1
/scoreboard players set @a hasPipe 1 {SelectedItem:{id:"minecraft:rabbit_foot",tag:{display:{Name:"Pipe"}}}}
dosen't see me holding a pipe... idk if there is something wrong with it
i tried the following variation but it doesn't work either:
/scoreboard players set @a[{SelectedItem:{id:"minecraft:rabbit_foot",tag:{display:{Name:"Pipe"}}}}] hasPipe 1
also (maybe that was for the next part) this method appear to keep your score at 10 as long as you hold the pipe, i need it to stop going at 10 when it's above 0 so tobaco will only be consumed by the pipe when you are at 10 and last a bit before consuming another item. So i need an additionnal condition of having a smoke score below 1
It does work. Your problem is your clock is activating the commands in the wrong order. Also, yes, I didn't finish it for you. You have to remove 1 from from all players with smoke_min=1. If you are using a fill clock then a score of 10 will be so quick (half a second) that it will seem to be constantly 10.
The order of execution for command blocks powered at the same time is least to most along the xyz. Setup a fill clock where the redstone_blocks are filling in the positive Z direction, now put the first command block on the least X side, least Z. This block will be executed first, next is the most X, least Z, next is least Z, least Y (under the first redstone block), finally, most Y, least Z. So after you have four connected you should have a plus sign with four command blocks around the redstone block. Now when you advance one Z you repeat the process. If you are standing looking at positive Z then the order is, right, left, bottom, top.
well, first, i had a mistake, i had a small "h" instead of a Cap. "H" in HasPipe,
i'm still a bit confuse because the commad that set my score to 0 is outputting:
Set score of HasPipe for player Classic_Stee1 to 0
but the one that give me a score of 1 is outputting:
Set score of HasPipe for player @a[{SelectedItem:{id:"minecraft:rabbit_foot",tag:{display:{Name:"Pipe"}}}}] to 1
instead of "for Classic_Stee1"
is it normal??
Also, i feel like each cycle of the clock i'm given 1 if i have a pipe, but the other command will always bring me back to zero, because nothing tells the other block not to reset my score when i do have a pipe
well, first, i had a mistake, i had a small "h" instead of a Cap. "H" in HasPipe,
i'm still a bit confuse because the commad that set my score to 0 is outputting:
Set score of HasPipe for player Classic_Stee1 to 0
but the one that give me a score of 1 is outputting:
Set score of HasPipe for player @a[{SelectedItem:{id:"minecraft:rabbit_foot",tag:{display:{Name:"Pipe"}}}}] to 1
instead of "for Classic_Stee1"
is it normal??
Also, i feel like each cycle of the clock i'm given 1 if i have a pipe, but the other command will always bring me back to zero, because nothing tells the other block not to reset my score when i do have a pipe
The scoreboard I used is called "hasPipe", in programming it's a common way of naming variables. Start with lower case and each following word/item, you capitalize the first letter.
The command block is outputting that because the command is incorrect.
the {}'s does not go inside the selector, it goes at the end of the command:
/scoreboard players set \<player\> \<objective\> \<score\> [dataTag]
The command should be exactly as I originally said it:
/scoreboard players set @a hasPipe 1 {SelectedItem:{id:"minecraft:rabbit_foot",tag:{display:{Name:"Pipe"}}}}
Finally, the reason we are setting hasPipe to 0 first, is because if we don't then the game will never know when you are not holding it. We are assuming that the player is not holding the pipe first. (Setting it to 0.) It is very important that this command is executing BEFORE the command setting it to 1 is executed. We now can set it to 1 only if the player is holding the pipe.
ok, it works now (i knew that whatever was wrong, it would be obvious)
Now i suppose we will do one that give you 10 "smoke score" if you have 1 "hasPipe", some tobaco in your inventory and a smoke score of exactly 0
something like:
Hey nice seeing you again nigathan <3 blood bird. As I have actually planned something like this before on a bukit server, I have a suggestion for this. What if you added some kind of addictive element, and if you don't want to encourage smoking, make it like blaze powder or something. What if you got a short buff and it restored your need levels on use (which optionally gradually increase in time)? And if your need levels go low, you get a negative effect, such as hunger. Also maybe some long term effect that increases with your use, such as weakness? The buff could be strength, speed, jump, or like night vision + nausea. But nothing that has "healthy" effects like Regen or healing.
I still have a weird proble with the following command:
/scoreboard players set @a[score_hasPipe_min=1,score_smoke=0] smoke 10 {Inventory:[{id:"minecraft:dye",Damage:3s,tag:{display:{Name:"Tobacco"}}}]}
at first the output was something like "the data tag does not match for [player name]" but then i moved it to make sure it was it the correct order (positive Z) and then, no output at all! :S even after moving it back to it's original position, and even after destroying it and putting the command in a new one instead of copying the NBT with Ctrl middle-click (how? why? this can only be a bug right??)
on another note, 0ct0ber, i had planed for negativ effect. In fact, i have already set a long hopper clock for the second part of my machine since it's mush easyier:
these command are called in order on the long hopper clock:
then i need a fifth one for the puff of smoke particles, i had one from a tutorial but the particles were on the block instead of on the player so i need help with it (also, i lost the command completly when i destroyed that command block by mistake XD)
When i said positive z i meant smaller z to bigger z, about the order of commandblock execution for command that happend at the same time (in nigathan's message of february 14)
also, i don't want the particle to happend on or above the command block, the whole circuit is going to be under the sea bed at spawn so it can work for everyone on the server (and eventualy in my adventure map) but those who smoke can be anywhere so i wonder if their is a way to get the particle on each player who smoke...
yet the "/scoreboard players set @a[score_hasPipe_min=1,score_smoke=0] smoke 10 {Inventory:[{id:"minecraft:dye",Damage:3s,tag:{display:{Name:"Tobacco"}}}]}" command still doesn't work, as i said for some weird reason... the command bloc doesn't do any output!
Keep in mind, this command block HAS been powered before this screenshot, i tryied ctrl-middle click to copy it and replace it, i tryied changing it to a new empty command block and re-type the command and tryied to place it somewhere esle. also, i checked for typos. I don't understand why their isn't an error message in the output! if you don't know, i'll try to rebuild everything in a new world alltogether
yet the "/scoreboard players set @a[score_hasPipe_min=1,score_smoke=0] smoke 10 {Inventory:[{id:"minecraft:dye",Damage:3s,tag:{display:{Name:"Tobacco"}}}]}" command still doesn't work, as i said for some weird reason... the command bloc doesn't do any output!
Keep in mind, this command block HAS been powered before this screenshot, i tryied ctrl-middle click to copy it and replace it, i tryied changing it to a new empty command block and re-type the command and tryied to place it somewhere esle. also, i checked for typos. I don't understand why their isn't an error message in the output! if you don't know, i'll try to rebuild everything in a new world alltogether
The output for that command block has been disabled. Press the X next to the "Previous Output" textbox.
actualy, i cliced that first because i didn't had an output in the first place and i wanted to see if it would change anything, i checked 5 minutes ago just to be sure and it doesn't change anything even when the "x" is an "o"
also, i tested that same command on another world, still no output (and never touched the "no ouput" thingy there)
the problem must come from the command because the same command block as no problem doign other commands and our command doesn't work in other commandblocks or in other worlds...
yet the "/scoreboard players set @a[score_hasPipe_min=1,score_smoke=0] smoke 10 {Inventory:[{id:"minecraft:dye",Damage:3s,tag:{display:{Name:"Tobacco"}}}]}" command still doesn't work, as i said for some weird reason... the command bloc doesn't do any output!
Keep in mind, this command block HAS been powered before this screenshot, i tryied ctrl-middle click to copy it and replace it, i tryied changing it to a new empty command block and re-type the command and tryied to place it somewhere esle. also, i checked for typos. I don't understand why their isn't an error message in the output! if you don't know, i'll try to rebuild everything in a new world alltogether
Well right off the bat, I can see that you have typed a different command into the command block. "Tobacco" is not the same as "Tabac". I assume that your cocoa beans are named "Tabac"? Also you need to be holding the rabbit foot before this command block will do anything. The only reason the command block wouldn't be outputting is if their is not a player with hasPipe > 0 and smoke < 1. Have you set these objectives up properly? If so, disable every other command block except for this one and type these into chat
/scoreboard players set @p hasPipe 1
/scoreboard players set @p smoke 1
If the command block still does not output anything and there are no errors when you type those commands, then your command is not a direct copy and paste. Something is messed up in your command.
i'll check that as soon as i'm back home, but i have to say i forgot to explain a really important thing, yes, i used Tabac instead of Tobacco, i said tobacco here on the forum because it's an english forum, my main language is french so i use Tabac in my command blocks, but every time i checked if the commands where typed correctly, i checked accordingly, making sure "Tabac" was the same everywhere
really sorry for the confution this might have caused
here is the circuit:
And here are the steps and related problem
1- Look if a player is holding a rabbit foor renamed "pipe" in his active slot (0 to 8) [not sure it would make the difference between 2 players who as it]
---ex: /testfor @p {SelectedItemSlot:5,Inventory:[{Slot:5b,tag:{display:{Name:"Pipe"}}}]}
2- Look if a player has cocoa beans renamed "tobaco" in his inventory [not sure it would make the difference between 2 players who as it]
---:/testfor @p {Inventory:[{tag:{display:{Name:"Tobaco"}}}]}
3- Look if a player as a "smoke" score of 0 [does not work, is always on or always of]
---:/testfor @p[smoke=0,smoke min=0]
4- remove one "tobaco" from the playrs inventory and give him a "smoke" score of 10 [not sure it would affect the right player in multi]]
---:/clear @p[smoke_min=1] dye 3 1 {display:{Name:Tobaco}}
---:/scoreboard players set @p smoke 10
5- give a puff of smoke particle, slowness and mining fatigue and reduce the "smoke" score by 1 to all player with at least 1 of smoke score
[does'nt work, on all the time, doesn't care about the score + particle aren't on the player, they are on the command block + not sure it would affect the right player in multi]
--:/effect @a[smoke_min=1] 2 8 1 hideParticles
--:/effect @a[smoke_min=1] 4 8 3 hideParticles
--:/particle smoke ~ ~ ~ 1 1 1 0.001 60 @a[smoke_min=1]
--:/scoreboard players remove @a[smoke_min=1] smoke 1
So yeah... feels like designing my slot machine all over again! ¬.¬
Alright, so based on what you already have here, I'm going to assume you understand the majority of what I'll be showing you. So I'm just going to share my bong with you.
First some objectives need to be made: Now the following need to be on a fill clock: Also you can use the tag SelectedItem instead of SelectedItemSlot and you don't need to check all the slots.
Basically where you have a /testfor, you should replace that with /execute and put the command from the block that gets powered from the comparator output in the /execute command. And always use @a instead of @p. And for the items you're testing for, it's best to put as much info about them as you can so someone can't rename dirt tobacco and smoke for free!
Now I'll explain what my bong does. First you have to build the bong. Simply place a tripwire hook anywhere with a block of air below it and any block below that. Next throw any kind of tall "grass" at the hook. This is loading the bong. When you do this, the tall grass will no longer despawn or able to be picked up. It will also put some green particle effects on the hook (bong). Then walk into the bong and right click on it with your flint and steel to take a hit. It will give you 4:20 of hunger and after a little while you will exhale the smoke. Each tall grass gives the bong 3 hits. The tall grass is killed after the third hit. If the bong is broken while loaded the tall grass disappears.
The /stats command allows us to run a command as the grass and set the output of the command as a scoreboard variable on that tall grass entity.
I know you are making something completely different, but I hope this helped!
So the first thing you want to do is check if any player is holding a rabbit foot. The best way to do this for multiplayer compatibility is with the scoreboard command.
So we will first need to setup the scoreboard objective. This objective will only handle values and operations that we tell it to, so we will use a "dummy" type. I think you already understand that much, so I'll give you that command: Now we need to set a players hasPipe objective to 1 if they are indeed holding a "pipe". Just like the /testfor command, /scoreboard allows you to check an entities data tags. You can think of this as a very basic "if-then statement". So if the player is holding a pipe then mark them as so, otherwise unmark them. To do this, you will need to set hasPipe to 0 before checking and setting to 1, because there is no "else statement" to rely on only if the test was false. Now you can test for the tobacco on @a[score_hasPipe_min=1] and no need to keep the /testfor @p[score_smoke=0,score_smoke_min=0]. Instead you can just do This is because hasPipe can only ever be 0 or 1, never higher, so we can just check if it is at least 1. Then score_smoke=0 means the largest number it can be is 0. It can only ever be 0-10 and when it is >0 we don't want it to trigger.
I'm gonna stop here and leave you to it. Of course if you need more help, just ask!
/scoreboard players set @a hasPipe 1 {SelectedItem:{id:"minecraft:rabbit_foot",tag:{display:{Name:"Pipe"}}}}
dosen't see me holding a pipe... idk if there is something wrong with it
i tried the following variation but it doesn't work either:
/scoreboard players set @a[{SelectedItem:{id:"minecraft:rabbit_foot",tag:{display:{Name:"Pipe"}}}}] hasPipe 1
also (maybe that was for the next part) this method appear to keep your score at 10 as long as you hold the pipe, i need it to stop going at 10 when it's above 0 so tobaco will only be consumed by the pipe when you are at 10 and last a bit before consuming another item. So i need an additionnal condition of having a smoke score below 1
It does work. Your problem is your clock is activating the commands in the wrong order. Also, yes, I didn't finish it for you. You have to remove 1 from from all players with smoke_min=1. If you are using a fill clock then a score of 10 will be so quick (half a second) that it will seem to be constantly 10.
The order of execution for command blocks powered at the same time is least to most along the xyz. Setup a fill clock where the redstone_blocks are filling in the positive Z direction, now put the first command block on the least X side, least Z. This block will be executed first, next is the most X, least Z, next is least Z, least Y (under the first redstone block), finally, most Y, least Z. So after you have four connected you should have a plus sign with four command blocks around the redstone block. Now when you advance one Z you repeat the process. If you are standing looking at positive Z then the order is, right, left, bottom, top.
i'm still a bit confuse because the commad that set my score to 0 is outputting:
Set score of HasPipe for player Classic_Stee1 to 0
but the one that give me a score of 1 is outputting:
Set score of HasPipe for player @a[{SelectedItem:{id:"minecraft:rabbit_foot",tag:{display:{Name:"Pipe"}}}}] to 1
instead of "for Classic_Stee1"
is it normal??
Also, i feel like each cycle of the clock i'm given 1 if i have a pipe, but the other command will always bring me back to zero, because nothing tells the other block not to reset my score when i do have a pipe
The scoreboard I used is called "hasPipe", in programming it's a common way of naming variables. Start with lower case and each following word/item, you capitalize the first letter.
The command block is outputting that because the command is incorrect.
the {}'s does not go inside the selector, it goes at the end of the command: The command should be exactly as I originally said it: Finally, the reason we are setting hasPipe to 0 first, is because if we don't then the game will never know when you are not holding it. We are assuming that the player is not holding the pipe first. (Setting it to 0.) It is very important that this command is executing BEFORE the command setting it to 1 is executed. We now can set it to 1 only if the player is holding the pipe.
Now i suppose we will do one that give you 10 "smoke score" if you have 1 "hasPipe", some tobaco in your inventory and a smoke score of exactly 0
something like:
/scoreboard players set @a smoke 10 { {{Inventory:{minecraft:dye 3}} , {tag:{display:{Name:"Tabaco"}}}} , {smoke=0,smoke min=0} , {hasPipe=1,hasPipe min=1}}
You can simply check only the max for smoke and the min for hasPipe, no need for the other. You will also need to remove their tobacco right after this:
/scoreboard players set @a[score_hasPipe_min=1,score_smoke=0] smoke 10 {Inventory:[{id:"minecraft:dye",Damage:3s,tag:{display:{Name:"Tobacco"}}}]}
at first the output was something like "the data tag does not match for [player name]" but then i moved it to make sure it was it the correct order (positive Z) and then, no output at all! :S even after moving it back to it's original position, and even after destroying it and putting the command in a new one instead of copying the NBT with Ctrl middle-click (how? why? this can only be a bug right??)
on another note, 0ct0ber, i had planed for negativ effect. In fact, i have already set a long hopper clock for the second part of my machine since it's mush easyier:
these command are called in order on the long hopper clock:
- /clear @a[score_smoke_min=10] minecraft:dye 3 1 {display:{Name:"Tobacco"}}
(consume the tobacco)
-/scoreboard players remove @a[smoke_min=1] smoke 1
(lower the smoke score)
-/effect @a[smoke_min=1] 2 20 1
(give slowness 1 for 20 sec)
-/effect @a[smoke_min=1] 4 20 2
(give mining fatigue 2 for 20 sec)
then i need a fifth one for the puff of smoke particles, i had one from a tutorial but the particles were on the block instead of on the player so i need help with it (also, i lost the command completly when i destroyed that command block by mistake XD)
/particle smoke ~ ~1.5 ~ 0 0 0 0.3 16
It might help if I can physically see the bug too
also, i don't want the particle to happend on or above the command block, the whole circuit is going to be under the sea bed at spawn so it can work for everyone on the server (and eventualy in my adventure map) but those who smoke can be anywhere so i wonder if their is a way to get the particle on each player who smoke...
Basically what maxaxik said, but without his typo.
Edit: If you go back and look at my first post in this thread, you will find the method I used to make the smoke in my bong:
yet the "/scoreboard players set @a[score_hasPipe_min=1,score_smoke=0] smoke 10 {Inventory:[{id:"minecraft:dye",Damage:3s,tag:{display:{Name:"Tobacco"}}}]}" command still doesn't work, as i said for some weird reason... the command bloc doesn't do any output!
Keep in mind, this command block HAS been powered before this screenshot, i tryied ctrl-middle click to copy it and replace it, i tryied changing it to a new empty command block and re-type the command and tryied to place it somewhere esle. also, i checked for typos. I don't understand why their isn't an error message in the output! if you don't know, i'll try to rebuild everything in a new world alltogether
The output for that command block has been disabled. Press the X next to the "Previous Output" textbox.
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
also, i tested that same command on another world, still no output (and never touched the "no ouput" thingy there)
the problem must come from the command because the same command block as no problem doign other commands and our command doesn't work in other commandblocks or in other worlds...
Well right off the bat, I can see that you have typed a different command into the command block. "Tobacco" is not the same as "Tabac". I assume that your cocoa beans are named "Tabac"? Also you need to be holding the rabbit foot before this command block will do anything. The only reason the command block wouldn't be outputting is if their is not a player with hasPipe > 0 and smoke < 1. Have you set these objectives up properly? If so, disable every other command block except for this one and type these into chat If the command block still does not output anything and there are no errors when you type those commands, then your command is not a direct copy and paste. Something is messed up in your command.
really sorry for the confution this might have caused