So, i know how do some parts of my command but the rest of it I'm completely lost. First I want be able to give a player a specific item. (I know how to do that) Then when that item is held, it disappears and a command block will be placed underneath the holder. ( know how to do that to) Now comes the part that I'm stuck on. The command block should have a pre-set command in it. (/test for @p[r=3,name=Blank]) Except for instead of blank it would have the players name in it instead. So to be clear, I'm not sure how to set a command block with a command already in it and i don't know how to give it specific syntax based on the variable that is a players name. I know this is a difficult one so to any command wizard that is willing to help me out, Thank You so much!
I realize how to do all of that. The reason why I want a specific player name is because I am selling the previously mentioned held item to players in survival. I want that player to just be able to set that command block anywhere they want and have it test for them and only them. Would there be a way to do this with a score? I know you mentioned it, but it doesn't really do anything for multiple people using different command blocks. Remember there is also the problem with setting the command block with command already in it. Would I need to use the /clone command for that? Ive heard people say that there is a way to anything using command blocks you just have to think creatively. Sadly I'm not very creative
They don't need to place the command block. You just have to hold an item. That item is deleted from your hand and a command block appears under your feet.
The Meaning of Life, the Universe, and Everything.
Join Date:
1/26/2018
Posts:
48
Member Details
You'll have to use a wrapper like Multicraft in order to insert a variable into the command block. Otherwise it's impossible, as vanilla doesn't support inserting variables.
Not necessarily, if the target player has a score of 1 on the "player" objective then the command block under the player can just test for a nearby player in a specific radius with the min score of 1.Therefor avoiding the need for a name.This system can be used in multiplayer as well with a few tweaks(more player objectives, so there are no conflicts).
So, i know how do some parts of my command but the rest of it I'm completely lost. First I want be able to give a player a specific item. (I know how to do that) Then when that item is held, it disappears and a command block will be placed underneath the holder. ( know how to do that to) Now comes the part that I'm stuck on. The command block should have a pre-set command in it. (/test for @p[r=3,name=Blank]) Except for instead of blank it would have the players name in it instead. So to be clear, I'm not sure how to set a command block with a command already in it and i don't know how to give it specific syntax based on the variable that is a players name. I know this is a difficult one so to any command wizard that is willing to help me out, Thank You so much!
Using variables is impossible.
However, why do u want the player name?
If it's like you want to summon the zombie with its name as same as the player, I can understand the pain.
If it's only for testing if somebody's nearby,
use /testfor @p[r=3] instead (use /execute if you are using 1.13+)
If you want to detect somebody specialy in the game (for example, he has the score trash of 1)
then do /testfor @p[r=3,score_trash_min=1]
If it's testing if only YOU(your username) can be detected,
use /testfor @p[r=3,name=Obsidijin] .
Ofc, there's a great possibility that I misunderstood your question. If so, feel free to correct it.
I realize how to do all of that. The reason why I want a specific player name is because I am selling the previously mentioned held item to players in survival. I want that player to just be able to set that command block anywhere they want and have it test for them and only them. Would there be a way to do this with a score? I know you mentioned it, but it doesn't really do anything for multiple people using different command blocks. Remember there is also the problem with setting the command block with command already in it. Would I need to use the /clone command for that? Ive heard people say that there is a way to anything using command blocks you just have to think creatively. Sadly I'm not very creative
They don't need to place the command block. You just have to hold an item. That item is deleted from your hand and a command block appears under your feet.
You'll have to use a wrapper like Multicraft in order to insert a variable into the command block. Otherwise it's impossible, as vanilla doesn't support inserting variables.
Ok thanks. Ill try to find a different solution. Hopefully someday they will add this to minecraft.
This is possible, I've just done it! ...you can use scoreboard instead of variables.
Tested in Mc.1.12.2
1.Use these commands to make two scoreboard objectives
/scoreboard objectives add heldItem dummy
/scoreboard objectives add player dummy
2.place down 4 command blocks as shown in the picture I included.
3.now it's time to program the command blocks
command block #1:
/scoreboard players set @a heldItem 1 {SelectedItem:{id:"minecraft:stick",tag:{display:{Name:"Special item"}}}}
command block #2:
/execute @a[score_heldItem_min=1] ~ ~ ~ setblock ~ ~-1 ~ command_block 0 replace {Command:"testfor @p[r=3,score_player_min=1]"}
command block #3:
/execute @a[score_heldItem_min=1] ~ ~ ~ scoreboard players set @a[score_heldItem_min=1,r=1] player 1
command block #4:
/execute @a[score_heldItem_min=1] ~ ~ ~ replaceitem entity @a[score_player_min=1] slot.weapon.mainhand air
and you're done. Just don't forget to change the item name and id in the first command.
oh, and the command block that is set beneath the player's feet is not activated so make sure you activate it.
Command block engineer // Developer // #TeamTrees
But he needs the players name to be inserted into the command block on placement, which isn't possible.
Not necessarily, if the target player has a score of 1 on the "player" objective then the command block under the player can just test for a nearby player in a specific radius with the min score of 1.Therefor avoiding the need for a name.This system can be used in multiplayer as well with a few tweaks(more player objectives, so there are no conflicts).
I have tested this myself and it works perfectly
Command block engineer // Developer // #TeamTrees
exactly what tweaks would be needed to be able to use it in multiplayer, because that was the need for it