i was thinking he had custom items in mind, so that it has to be hard-coded anyways. but if that has to be avoided, item list using the off-hand would be very complex, but could be done by
1, fill the customer-player’s inventory with unusable blocks, such as barrier-blocks.
2, replaceitem to clear said player’s offhand.
3, clone and setblock-destroy a chest containing the shop-item matching the B-score and tp the dropped entity to the player.
i was thinking he had custom items in mind, so that it has to be hard-coded anyways. but if that has to be avoided, item list using the off-hand would be very complex, but could be done by
1, fill the customer-player’s inventory with unusable blocks, such as barrier-blocks.
2, replaceitem to clear said player’s offhand.
3, clone and setblock-destroy a chest containing the shop-item matching the B-score and tp the dropped entity to the player.
4, clear the player of their barrier-blocks.
note that (3) must be done in a loaded chunk.
Reading all of that, it's probably better to hard code it
So uh... If Megacrafter107 (or others) cannot solve it, I'll give it a try after I finish my presentation homework. That would be like 4 days.
Hey, so I'm finally done with the stuff.
If you already got the solution, ignore it.
After looking into the case slightly further, I think that a workaround is needed. Like what torimorta said, there's (probably) not way to keep the items from stealing. The players might be able to craft the item before it disappears.
IF, I rly mean IF, the items are purely custom (like players only buy it for its special effects, not for crafting), that'll be another case. But, I now assume that you want to sell regular vanilla items, it's not entirely possible to prevent somebody from exploiting the system.
My workaround is to have an invisible chest-ed donkey at the villager, so that the players can still click and see the content of the item. If that works for you, and you don't have that special case mentioned above, inform me/us.
i have a scenario where if the player has a lime dye (which is a hat by using a resource pack) the command block will remove it from they're inv and add the hat count the scoreboard, idk how to do that though
i was thinking he had custom items in mind, so that it has to be hard-coded anyways. but if that has to be avoided, item list using the off-hand would be very complex, but could be done by
1, fill the customer-player’s inventory with unusable blocks, such as barrier-blocks.
2, replaceitem to clear said player’s offhand.
3, clone and setblock-destroy a chest containing the shop-item matching the B-score and tp the dropped entity to the player.
4, clear the player of their barrier-blocks.
note that (3) must be done in a loaded chunk.
Reading all of that, it's probably better to hard code it
Command block engineer // Developer // #TeamTrees
Hey, so I'm finally done with the stuff.
If you already got the solution, ignore it.
After looking into the case slightly further, I think that a workaround is needed. Like what torimorta said, there's (probably) not way to keep the items from stealing. The players might be able to craft the item before it disappears.
IF, I rly mean IF, the items are purely custom (like players only buy it for its special effects, not for crafting), that'll be another case. But, I now assume that you want to sell regular vanilla items, it's not entirely possible to prevent somebody from exploiting the system.
My workaround is to have an invisible chest-ed donkey at the villager, so that the players can still click and see the content of the item. If that works for you, and you don't have that special case mentioned above, inform me/us.
i have a scenario where if the player has a lime dye (which is a hat by using a resource pack) the command block will remove it from they're inv and add the hat count the scoreboard, idk how to do that though