-1

So, I'm trying to build a simple shop / trade place ,thing, where you simply just press a button and the item from the first hotbar's slot gets replaced with, coal for example, but I don't know how to do with the commands. I mean, I don't really want to use scoreboard techniques, i want something simpler, like /testfor combined with /replaceitem !?

Example: I have 26 Gunpowder, i want it to be replaced with exactly the same amount of coal, 26. I have 41 String, again, replaced with... 41 Andesite!

If can be done, (?) /testfor @p {SelectedItemSlot:0,Inventory:[{id:"minecraft:ITEM"}]} + /replaceitem entity @p slot.hotbar.0 minecraft:ITEM + SAME AMOUNT AS THE ITEM FROM HOTBAR.0

If you can help me, Thank you! :) otherwise, still Thank You for the lost time :D and yes, i know that my English is bad :/

EDIT: I tried to solve the problem, but it can get bugged if its used too fast, and ignore the directions of the comparator in the left and the repeater in the right,please, its modded minecraft :)

In the actual state the 1st command block checks if i have 64 Gunpowder, if its true, it goes to the 2nd one that replaces the Gunpowder with 64 Coal, then it simply replace the block underneath the 1st command block with a redstone block,then with air, to update it, to force the comparator to turn off, because he is the source of the "bug", if its used to fast,before the last command block gets to place air underneath the 1st comm. block, it stays like that, and WITH the redstone block stuck under it...

What i want.. is to not be forced to use exact amounts of item X and item Y, as i said, i want to simply replace 1st item with the 2nd X item of the same amount as the first, because i dont want multiple lil' "systems" like this one, one with 64, one with 32, one with 16.. ETC

EDIT 2: IF IT REALLY CAN'T BE DONE IN THE WAY I WANT,I'LL TRY THE /SCOREBOARD WAY

  • Have you made any attempt to solve this yourself? Arqade works better when askers show effort to solve their own problems; we see that you have a problem you've worked on, and answerers respond to that. You also get a more specific answer that's tailored exactly to the part you're stuck, and Arqade gets a very specific question. Everybody wins! – Frank Jun 10 '18 at 16:17
0

1st command: testfor @p {SelectedItem:{id:"minecraft:**blockname**",Count:**amount**}}

2nd command: replaceitem entity @p slot.weapon.mainhand **new blockname** **new amount** [data] [dataTag]

blockname stone? = will test for stone
amount = 6? = will test for 6 stone
new blockname dirt? = will replace current slot with dirt
new amount 12? = will give you 12 times the new blockname

No, its not possible in 2 commands to detect for every amount of blocks. You'll need 2 command per amount. So if you want every possible amount (1-64) you will have to program 128 command blocks. Otherwise this works fine!

  • Well, it can't be done in the... way i wanted, Thanks for help tho! :) 128 comm. blocks... hmmm -.- back to scoreboards then. – Kyliams Jun 10 '18 at 17:17
  • the positive thing about my commands is that they'll check for you Selected hand and replace your selected hand in two commands otherwise you would need 1152 command blocks so I saved you a lot of time xD – Khoeckman Jun 10 '18 at 18:17

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.