You can write a command block that links to user-input (such as a button) for this to work. The reason for it being UI and not seamless is because the command only needs to be run when a player is sure they can pass it, because the command removes items from the player, regardless of whether they have all the items or not.
Commands:
Unconditional, needs redstone
/clear @p stick 0 1
Conditional, always active
/clear @p stick 0 1
Conditional, always active
/clear @p diamond 0 1
Conditional, always active
/give @p diamond_sword 1 0
Conditional, always active
/enchant @p sharpness 3
Notes: the player would need to press the button holding an empty inventory slot in their hotbar for the sword to be enchanted.
Hello:
Is there a way to code a command block to give the player an item (enchanted sword) only if the player is holding something (2 diamonds and a stick)?
If so, what is it?
Any assistance or direction will be greatly appreciated.
You can write a command block that links to user-input (such as a button) for this to work. The reason for it being UI and not seamless is because the command only needs to be run when a player is sure they can pass it, because the command removes items from the player, regardless of whether they have all the items or not.
Commands:
Unconditional, needs redstone
/clear @p stick 0 1
Conditional, always active
/clear @p stick 0 1
Conditional, always active
/clear @p diamond 0 1
Conditional, always active
/give @p diamond_sword 1 0
Conditional, always active
/enchant @p sharpness 3
Notes: the player would need to press the button holding an empty inventory slot in their hotbar for the sword to be enchanted.
Thank you very much for your response, RussianM4rksman.