[help] Setting objective of entity based on another entity

1 emeralds3 replies423 views
Steve_OH started 12/15/14 12:06 am
and replied 12/16/2014 8:49 pm
As stated in the title, I'm curious if there's a way to set an objective for an entity based on another entity. For example, here's my command

execute @e[name=bcursor] ~ ~ ~ detect ~ ~5 ~ stained_hardened_clay 9 ~ ~ ~ scoreboard players set @e[type=Slime,~,~2,~] hit 1

Basically I have an entity [bcursor], who is used to point at things. I have an array of slimes 2 blocks above it (hence the [type=Slime,~,~2,~] section). The command seems to work based on this 'previous output' entry:

span>[22:23:31] Set score of hit for player @e[type=Slime,~,~2,~] to 1

The issue is that the entity in that location is supposed to perform an action based on that outcome, which has been tested by manually setting it for the objective, but yeah.

I'd prefer to use relative coordinates as there are 162 different entities above the bcursor entity and I'd really prefer not to have to make 162 command blocks if at all possible.

Posted by avatar
Level 38 : Artisan Engineer

Create an account or sign in to comment.

3 replies

12/16/2014 8:49 pm
Level 38 : Artisan Engineer
Steve_OH avatar
None of those worked. It just made all of the array entities increase in that objective. Thanks anyway though

I ended up doing a big workaround instead
12/15/2014 3:50 pm
Level 31 : Artisan Engineer
Jmal116 avatar
Is your issue here that you essentially have a bunch of slimes, and you want to detect and execute a command from the one that is directly above bcursor? If so I believe you can do this with a nested execute: execute @e[name=bcursor] ~ ~2 ~ execute @e[type=Slime,r=0] ~ ~ ~ detect ~ ~3 ~ stained_hardened_clay 9 scoreboard players set @e[type=Slime,r=0] hit 1Essentially this command finds bcursor and looks 2 blocks above it for a slime. If there is one there, then it will check if there is a clay 9 block 3 blocks above the slime (5 above bcursor). If there is, then that slime's hit score will be set to 1.

Also just a sidenote on the command you currently have, if your output looks like this: Set score of hit for player @e[type=Slime,~,~2,~] to 1then your command didn't work right. You can't use relative coordinates inside a player selector, and I think if you want to be able to cut off the x= prefixes like you did you have to put them in the very front of the brackets. What this does is saves a score to the fake player "@e[type=Slime,~,~2,~]". If the actual slime has its score set, it will show the slime's UUID.

EDIT probably should have read the post right above me... Would have saved me quite a lot of typing XD
12/15/2014 4:38 am
Level 19 : Journeyman Network
Imadbush avatar
/execute @e[name=bcursor] ~ ~2 ~ detect ~ ~3 ~ stained_hardened_clay 9 execute @e[type=Slime,c=1] ~ ~ ~ scoreboard players set @e[type=Slime,c=1] hit 1

This should work
Planet Minecraft


© 2010 - 2021