3

I have made/gathered an elaborate ruse of command blocks to essentially not accomplish my goal correctly. I have an objective "InCar" that tests each player to see if they are in fact in a minecart.

/scoreboard players set @a InCar 1 {RootVehicle:{Entity:{id:"MinecartRideable"}}}

And then further down the line of chain-conditional command blocks, another check which I now think it also has to be another scoreboard record. Which I haven't tested yet because of my question.

I will just ask how to only execute on the one player who is both in a minecart and with a stone block in hand in correct slot of their inventory? Or how to execute on that specific player on just one of the scoreboard items? I could go from there maybe.

Currently when 2 people or more are riding carts, they are all ejected and all carts are destroyed (like they should, minus everyone else not holding the stone). I know it is because my code to execute is not "aimed" at the player I want.

CC:

/execute @p ~ ~ ~  /tp @p ~ ~ ~2
/execute @p ~ ~ ~  /kill @e[type=MinecartRideable,r=4]

EDIT Created the InHand scoreboard

/scoreboard players set @a InHand 1 {SelectedItemSlot:1,Inventory:[{Slot:1b,id:"minecraft:stone"}]}

Then had to create a 3rd scoreboard that basically only scores a point if the player has both other scoreboard items and then activates.

/execute @a[score_InCar_min=1,score_InHand=1,score_InHand_min=1] ~ ~ ~ /scoreboard players set @a eject 1

Then cleared all the scores with each command having a "negative" to their "positive" action

/execute @a[score_InCar_min=0,score_InHand=0,score_InHand_min=0] ~ ~ ~ /scoreboard players set @a eject 0

/scoreboard players set @a InHand 0

Then the final command that is working so far.

/execute @a[score_eject_min=1,score_eject=1] ~ ~ ~ /kill @e[r=2,type=MinecartRideable]

I was just tired of googling every step of the way. But I guess I am learning. I will report back any issues, or updates. Hope this finds someone well. I don't know if you can just run this and it will work, or if you do actually have to setup the scoreboard items like I did prior to creating the commands..

This is running on a SMP server with Forge and a few mods. Running 1.10.2

2ND EDIT

It worked different this time. It won't delete all the carts not occupied. But it will still delete ALL occupied carts.. -_-

3rd Edit

I am now using Venya's code to simplify the scoreboard, so my 2 command blocks for score are now.

/scoreboard players set @a eject 1 {RootVehicle:{Entity:{id:"MinecartRideable"}},SelectedItemSlot:1,Inventory:[{Slot:1b,id:"minecraft:stone"}]}

And then this inverted to that command block.

/scoreboard players set @a eject 0

And added r=2 to the first part of execute command, it went exactly how Venya said.. It was only in a 2 block radius of the command block with the command.

So the execute command isn't correct.

Just tried this execute, works good so far. Waiting for a friend or two to test out the MP implications. I think I am getting somewhere.

/execute @a ~ ~ ~ execute @a[score_eject_min=1,score_eject=1,r=2] ~ ~ ~ /kill @e[r=2,type=MinecartRideable]
  • "This is running on a SMP server with Forge and a few mods." Be aware that command mechanics rarely ever work outside vanilla. If you're experiencing oddities, I would recommend trying it in vanilla. If it works there, then it's Forge causing your problems. – Skylinerw Nov 1 '16 at 23:59
  • I will try this in vanilla, but I am pretty sure the code is just not correct. I only started looking at Minecraft commands last week. – ToClose Nov 2 '16 at 15:52
1

you have just about everything you need, all you have to do is combine these commands:

/scoreboard players set @a InCar 1 {RootVehicle:{Entity:{id:"MinecartRideable"}}}
/scoreboard players set @a InHand 1 {SelectedItemSlot:1,Inventory:[{Slot:1b,id:"minecraft:stone"}]}

into:

/scoreboard players set @a eject 1 {RootVehicle:{Entity:{id:"MinecartRideable"}},SelectedItemSlot:1,Inventory:[{Slot:1b,id:"minecraft:stone"}]}

then every player that has a eject score of one (or more) is riding a minecart and has a stone selected in their hot-bar

if this doesn't help, let me know, I'll see what I can do

note: ~ in /tp teleports relative to the player/entity, /teleport is relative to the command block (or person executing)

  • Yes, that is what I'm looking for. I will test this asap. Thank you Venya! – ToClose Nov 3 '16 at 19:57
  • I still do think my failure will be with the /execute command. I think i should add a radius to the player, and then again to the cart.. That may be the crux.. But the simplification of the scoreboard is gonna be perfect. – ToClose Nov 3 '16 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.