So that it's on the 2nd line with empty lines around it.
I want to know how to give a player an item from an item entity.
So I have an item entity on the ground with soulbound in the lore. I want this item entity to go away, and I want the player who died and dropped that item to be given the item.
So that it's on the 2nd line with empty lines around it.
I want to know how to give a player an item from an item entity.
So I have an item entity on the ground with soulbound in the lore. I want this item entity to go away, and I want the player who died and dropped that item to be given the item.
I see; you can't directly transfer data from an entity into a /give or /replaceitem command. While you could teleport the item to the player constantly so that they could pick it up when they respawn, teleporting could fail if the chunks the item is in are unloaded. It also will not work in a multiplayer environment.
Otherwise you'll need to know exactly which item the player is missing. A different approach is to detect whether or not the player has the item in their inventory at all and provide them the item if not, rather than trying to rely on physical entities. You'd then just /kill any of the item entities in question.
Example for 1.8:
Prerequisites:
Items to provide the player that are considered soulbound. Custom tags are applied for easier targeting and differentiation; you'd only need to target the custom tags rather than all of the other item data. "Soulbound" byte tag states the item is soulbound, while the "SoulboundID" integer tag is the unique ID for that type of soulbound item, used for re-providing the player with the item.
The following must be run in numerical order on a clock.
1. First, reset player's "Soulbound#" scores, as otherwise they would always be 1 even when they're missing.
/scoreboard players set @a Soulbound1 0
/scoreboard players set @a Soulbound2 0
2. Set player's "Soulbound#" scores to 1 if they have the item anywhere in their inventory.
/scoreboard players set @a Soulbound1 1 {Inventory:[{tag:{GAME:{SoulboundID:1}}}]}
/scoreboard players set @a Soulbound2 1 {Inventory:[{tag:{GAME:{SoulboundID:2}}}]}
3. Provide players the item after they respawn. @a targets dead players while @e cannot, so @e[type=Player] is used instead. Otherwise /give would just drop the item where their dead body is.
4. (optional) If you wanted players to be given the item again if it's not in their inventory but they're still alive, then you'll need an extra set of /give commands to only target them when they're alive.
5. Reset player's "DEATHS" score when they respawn.
/scoreboard players set @e[type=Player,score_DEATHS_min=1] DEATHS 0
6. Mark item entities as soulbound and then kill those item entities. We'll use the "DEATHS" objective just for simplification, though you could create another objective to track the item.
/scoreboard players set @e[type=Item] DEATHS 1 {Item:{tag:{GAME:{Soulbound:1b}}}}
/kill @e[type=Item,score_DEATHS_min=1]
Summary:
Each time the player dies, they'll be given the soulbound items when they respawn. They can optionally be given the items while they're alive and they remove the items from their inventory. If that was also a part of the goal, then the above contraption can be made much simpler without even needing to track deaths. You should provide as many details as possible if there's more to it than just dying. You should also state what version you're using, as 1.9 mechanics can make it even simpler.
The only problem I have now is that players can't enchant their soulbound stuff. I was really hoping for a more dynamic way to do it, hence why I said I wanted to be able to get the exact item from an entity. This isn't a sort of minigame thing where everyone will be getting the same soulbound items, it's a kitpvp server where each rankup gives you another piece of soulbound gear.
Any ideas on how it would be possible to make it more dynamic?
I'm trying to make a "soulbound item" system, and I can't find any way to find an item entity and give a player that item.
For example, @e[type=Item] {display:{Lore:[,Soulbound,]}}
Is there a way to set an itemname or a line of lore to a player's name and get the player in the name/lore?
The item format dictates that all tags that are not the root "id", "Damage", "Count", or "Slot" tags must be placed within a single "tag" compound.
Item entities store their items within an "Item" compound:
Unless you mean the /give command, which starts its dataTags directly within the "tag" compound:
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
Why is it like this? .
Instead of this. .Because that's what he has his set to.
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
So that it's on the 2nd line with empty lines around it.
I want to know how to give a player an item from an item entity.
So I have an item entity on the ground with soulbound in the lore. I want this item entity to go away, and I want the player who died and dropped that item to be given the item.
I see; you can't directly transfer data from an entity into a /give or /replaceitem command. While you could teleport the item to the player constantly so that they could pick it up when they respawn, teleporting could fail if the chunks the item is in are unloaded. It also will not work in a multiplayer environment.
Otherwise you'll need to know exactly which item the player is missing. A different approach is to detect whether or not the player has the item in their inventory at all and provide them the item if not, rather than trying to rely on physical entities. You'd then just /kill any of the item entities in question.
Example for 1.8:
Prerequisites:
Items to provide the player that are considered soulbound. Custom tags are applied for easier targeting and differentiation; you'd only need to target the custom tags rather than all of the other item data. "Soulbound" byte tag states the item is soulbound, while the "SoulboundID" integer tag is the unique ID for that type of soulbound item, used for re-providing the player with the item.
Objective to track when the player dies.
Objective to track whether or not the player has "SoulboundID" 1 and 2 (repeated for each type of soulbound item):Clock commands:
The following must be run in numerical order on a clock.
1. First, reset player's "Soulbound#" scores, as otherwise they would always be 1 even when they're missing.
2. Set player's "Soulbound#" scores to 1 if they have the item anywhere in their inventory.
3. Provide players the item after they respawn. @a targets dead players while @e cannot, so @e[type=Player] is used instead. Otherwise /give would just drop the item where their dead body is.
4. (optional) If you wanted players to be given the item again if it's not in their inventory but they're still alive, then you'll need an extra set of /give commands to only target them when they're alive.
5. Reset player's "DEATHS" score when they respawn.
6. Mark item entities as soulbound and then kill those item entities. We'll use the "DEATHS" objective just for simplification, though you could create another objective to track the item.
Summary:
Each time the player dies, they'll be given the soulbound items when they respawn. They can optionally be given the items while they're alive and they remove the items from their inventory. If that was also a part of the goal, then the above contraption can be made much simpler without even needing to track deaths. You should provide as many details as possible if there's more to it than just dying. You should also state what version you're using, as 1.9 mechanics can make it even simpler.
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
Why use "@e"? This means, you can give other entities items! .
.I explained why, please read the line directly above the section you quoted:
And no, you cannot give non-player entities items. The command will fail when attempting to give a non-player entity an item.
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
Thank you! I made the system.
The only problem I have now is that players can't enchant their soulbound stuff. I was really hoping for a more dynamic way to do it, hence why I said I wanted to be able to get the exact item from an entity. This isn't a sort of minigame thing where everyone will be getting the same soulbound items, it's a kitpvp server where each rankup gives you another piece of soulbound gear.
Any ideas on how it would be possible to make it more dynamic?