The Meaning of Life, the Universe, and Everything.
Join Date:
3/5/2011
Posts:
313
Member Details
Hi,
So let me try and explain what I got:
I have a clock and every 0.1 seconds it triggers a commandblock that checks if there is a player on top of a mobspawner.
So it checks @a Y:-1 to see if there is a mobspawner.
However now I want to give 1 diamond to the person that is standing on the mobspawner.
I do not know how to select only this player.
So the idea is that if with @a Y:-1 mobspawner then give that and only that player 1 diamond and then I remove the mobspawner.
My only problem here is finding that person. If I know how to select only that person then I can make a commandblock that deletes the block under that specific person and give him a diamond.
So if you know the answer, I really appreciate the help.
Check out the Wiki article on /execute for some more info. There's an extra detect part of the syntax that comes into play here that checks only for players with a specified block at a specified location.
The Meaning of Life, the Universe, and Everything.
Join Date:
3/5/2011
Posts:
313
Member Details
Ah I knew there was a way to do this.
Thanks a lot.
Tomorrow I'll test it out and see how it goes.
That is exactly what I need, I just use that and then with 0.1 tick delay delete the block under them so they only get 1 diamond for each mobspawner they jump on
The reason for the -1 after mob_spawner in the second command is because a mob spawner can have a lot of different damage values. Using 0 as geo1088 suggested, will only look for one specific type, not any like -1 does.
Check out the Wiki article on /execute for some more info. There's an extra detect part of the syntax that comes into play here that checks only for players with a specified block at a specified location.
The detect part of the command filters that to only those players who have a monster spawner underneath them.
The give is obvious.
That ought to be all you need.
But if he was in multiplayer, it would give the nearest player to the command block a diamond.
You should do some scoreboard command:
First you type in the chat /scoreboard objectives add spawnerDetected dummy
Second make a redstone clock using fill command so it will be so fast.
In that redstone clock, you put a command block beside it with this command /execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:mob_spawner 0 scoreboard players set @p spawnerDetected 1
Third put another command block in the redstone block with this command /execute @a ~ ~ ~ give @p[score_spawnerDetected_min=1,score_spawnerDetected=1] diamond
But if he was in multiplayer, it would give the nearest player to the command block a diamond.
That is incorrect. /execute's purpose is to modify the origin of a command to its target. From then on, those targets will be considered the center and command sender, so a simple @p will always target the executor.
The commands you've presented still rely on the same mechanic. However, the final /execute command has a major flaw. You're causing all players to give all players with a particular score a diamond. That can result in a large number of duplicate diamonds the more players are online. You should not use /execute for commands that do not need an origin change; /give works fine without it while targeting all players with a particular score:
Hi,
So let me try and explain what I got:
I have a clock and every 0.1 seconds it triggers a commandblock that checks if there is a player on top of a mobspawner.
So it checks @a Y:-1 to see if there is a mobspawner.
However now I want to give 1 diamond to the person that is standing on the mobspawner.
I do not know how to select only this player.
So the idea is that if with @a Y:-1 mobspawner then give that and only that player 1 diamond and then I remove the mobspawner.
My only problem here is finding that person. If I know how to select only that person then I can make a commandblock that deletes the block under that specific person and give him a diamond.
So if you know the answer, I really appreciate the help.
Check out the Wiki article on /execute for some more info. There's an extra detect part of the syntax that comes into play here that checks only for players with a specified block at a specified location.
execute <target> <x> <y> <z> detect <x> <y> <z> <block damage value> <command...>
Basically what you're looking for is this to put on a clock:
execute @a ~ ~ ~ detect ~ ~-1 ~ mob_spawner 0 give @p diamond
Basically, what this is doing:
That ought to be all you need.
Ah I knew there was a way to do this.
Thanks a lot.
Tomorrow I'll test it out and see how it goes.
That is exactly what I need, I just use that and then with 0.1 tick delay delete the block under them so they only get 1 diamond for each mobspawner they jump on
Ya.That worked for me
You should use the scoreboard so you only have to test once and you can give the diamond and remove the block next:
Type this into chat:
/scoreboard objectives add spawnerDiamond dummy
Place these on your clock:
/scoreboard players set @a spawnerDiamond 0
/execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:mob_spawner -1 scoreboard players set @p spawnerDiamond 1
/give @a[score_spawnerDiamond_min=1] minecraft:diamond 1
/execute @a[score_spawnerDiamond_min=1] ~ ~-1 ~ setblock ~ ~ ~ minecraft:air
The reason for the -1 after mob_spawner in the second command is because a mob spawner can have a lot of different damage values. Using 0 as geo1088 suggested, will only look for one specific type, not any like -1 does.
Now a way harder question.
All of yours work with mobspawners but now how can I check for a specific mobspawner ?
So for a spider spawner people get 2 diamonds, zombie 1 diamond, skeleton 3 diamonds etc...
I see no valid way to check for a specific mobspawner since data values don't work on them.
But if he was in multiplayer, it would give the nearest player to the command block a diamond.
You should do some scoreboard command:
First you type in the chat /scoreboard objectives add spawnerDetected dummy
Second make a redstone clock using fill command so it will be so fast.
In that redstone clock, you put a command block beside it with this command /execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:mob_spawner 0 scoreboard players set @p spawnerDetected 1
Third put another command block in the redstone block with this command /execute @a ~ ~ ~ give @p[score_spawnerDetected_min=1,score_spawnerDetected=1] diamond
And that's it. It's complete, hope you the best.
That is incorrect. /execute's purpose is to modify the origin of a command to its target. From then on, those targets will be considered the center and command sender, so a simple @p will always target the executor.
The commands you've presented still rely on the same mechanic. However, the final /execute command has a major flaw. You're causing all players to give all players with a particular score a diamond. That can result in a large number of duplicate diamonds the more players are online. You should not use /execute for commands that do not need an origin change; /give works fine without it while targeting all players with a particular score:
Regardless, their command will work just fine.
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/
Yeah guys it works but now how can I check for a specific mob spawner ?
I want it so zombie spawners are worth 1 diamond, skeletons 2 and spiders 3 ?