A lot of players on my server have been ticked by the revised anvil mechanics. They had some gear they worked ages on that used to be repairable with xp after renaming, but now will soon wear out. This includes really rare items like chainmail sets with near-max enchantments that won't last long under the new system.
As a solution I wanted to build a command-block console that targets the nearest player and if they have >40 levels of xp or something will look at the currently held item of their hotbar (or alternatively in #1 slot of a target chest nearby) and repairs the durability. Then subtracts 40 levels from the player and announces that the chosen item has been restored for 40 lvls. I like this idea because it still fits into the existing xp economy system but does not make any item unrepairable. I chose 40 lvls because the anvil can repair items up to 39 levels and I'm wanting them to use the console when they can no longer repair via anvil. So effectively a repair-level cap at 40.
I'm kinda new to command blocks but know redstone well.
So I know how to check levels of nearest player and subtract them. I also know how to give items to the player. I just need to know if there is a command to alter durability on existing items or look in a chest or player inventory. If there isn't, is there a way to copy the stats of the item in question but create the new item with full durability and destroy the old? Either will work.
Space Expedition to EPIC 204:Go on a Space-Age Adventure to visit and explore EPIC 204, a wacky world of dense asteroids and full of alien life! Experience Custom Seasons, Weather, Over 50 new creatures, Beautiful Biomes, Alien Ruins, Dungeons, and new space age tech crafting recipes!
And to clarify, i'm not asking this to be built for me, just the relevant commands or a "no, sorry, that can't be done" answer. I see some of what I need but can't see a way to do this with the basic commands, but they may just be because I'm new to command blocks.
I will need commands to address the following:
1. Reading a player's level and subtracting levels (I know how to do this one)
2. A command to read durability on an item (I only want this will only work if a repairable item is there so the player's levels aren't wasted. I also don't want it to to work if the item doesn't have a durability)
3. A command to either change the durability of an item (so I can set it to full) or to create a new, identical item with the same specifications including changes to name and enchantments and destroy the old. (this could be easier if there is no easy way to tell what "full" durability is on the item as I know it varies and may not be recorded with the item)
Space Expedition to EPIC 204:Go on a Space-Age Adventure to visit and explore EPIC 204, a wacky world of dense asteroids and full of alien life! Experience Custom Seasons, Weather, Over 50 new creatures, Beautiful Biomes, Alien Ruins, Dungeons, and new space age tech crafting recipes!
well, I really wish someone had taken the time to help me as I'm sure this has been done before.
However, I have finally, after about 5 hours of research figured out how to do it. the wiki was very vague with the datatag "damage". It was not clear at all that this was what determined the amount of uses left but I finally figured it out through trial and error investigating the error reports of the command blocks. also, there apparently is some bogus variable "Health" which I thought was damage but seemed to do nothign when I addressed it. I finally figured out that this only governs the damage due to lava/fire/explosions and is separate.
The solution:
I ended up having to switch to a method where you drop the item to be restored because then I can access the data as a dropped item entity with entitydata and reset the damage on the item to zero. It works perfectly and only works if a player with 41+ levels is in the area and a damaged item is dropped in the altar area. I orginally wanted it to be placed in a furnace slot as then I could flame the furnace and make it look like something happened, but whenever I used blockdata and got to the variables of the stored item using Item:{slot:0,Damage:0s} it overwrote the item there. I'm unsure why as I only changed the variable damage, however, it acted like I was creating a new item there because if I manually set an id the item with that id popped into existence with the variables set as I did. I'm gonna guess this is a bug from addressing the stored item within the furnace. It assumes id and other vars are zero if you don't set them, effectively erasing the item if you just try to talk to one of the stored variables. However, this dropped item idea I had works perfectly, so problems solved! I even found a nice way using comparators to not run the xp subtraction step if the item dropped had damage already set to 0! Flawless!
Space Expedition to EPIC 204:Go on a Space-Age Adventure to visit and explore EPIC 204, a wacky world of dense asteroids and full of alien life! Experience Custom Seasons, Weather, Over 50 new creatures, Beautiful Biomes, Alien Ruins, Dungeons, and new space age tech crafting recipes!
I have not found a way to clone items like you can clone blocks which is why I eventually settled on what I did. I figured it might be too complicated trying to replicate all the enchantments,name,etc on the item. If you know how to do that I'd be interested in knowing how as that might be useful to me for future systems. Would cloning a container block also clone the items in it? I didn't try that.
My system needs 3 command blocks effectively, but I ended up needing to up it to 6 to govern the logic and reset the output state of the first blocks afterwards (because I was using comparator logic). The system wouldn't fire again if I didn't do this. I was wondering if you knew a more efficient way to reset block state of command blocks so the comparators would turn off. As it is I need an extra command block currently for every block that I use logic on. I am using blockdata to reset their successCount variable.
Since you expressed interest here is how I accessed the datatag:
/entitydata @e[type=Item,x=,y=,z=,r=1] {Item:{Damage:0s}}
x,y,z is the position of the altar of healing. Basically a depression in the floor that they drop items into.
Each entity has a lot of new datatags that can be accessed, but dropped item entities from using type=Item still act like they are an object with a single slot and thus have the Item:{...} format like there is an item inside them. For whatever reason addressing it this way did not overrwrite the item like when I tried accessing within a block but I might have just made a mistake previously.
Space Expedition to EPIC 204:Go on a Space-Age Adventure to visit and explore EPIC 204, a wacky world of dense asteroids and full of alien life! Experience Custom Seasons, Weather, Over 50 new creatures, Beautiful Biomes, Alien Ruins, Dungeons, and new space age tech crafting recipes!
I know this is an old thread but thank you so much for this! It helped tremendously! I actually tried using the entitydata command too but I had it written entitydata @e[tag=whatever] {Damage:0}, I wasn't aware that you had to add the {Item:} part lol I am making a system where you throw three lapis and a damaged weapon/armor/tool into a special altar and they get repaired (five lapis and one experience level for enchanted items)
cool man! Sounds like fun! Glad this old thread helped.
These days if I'm unsure of the formatting of a datastructure I can access it using open curly braces on a command.
For instance if I want to see the data of an entity I run
/entitydata @e[r=2] {} - standing 2 blocks away from it. It can't access you so it accesses the other entity and prints all their data exactly as it should be. Open curly braces changes nothing, just prints what's already there. If you want to be able to copy it run that command from a command block and check the feedback line.
Space Expedition to EPIC 204:Go on a Space-Age Adventure to visit and explore EPIC 204, a wacky world of dense asteroids and full of alien life! Experience Custom Seasons, Weather, Over 50 new creatures, Beautiful Biomes, Alien Ruins, Dungeons, and new space age tech crafting recipes!
As a solution I wanted to build a command-block console that targets the nearest player and if they have >40 levels of xp or something will look at the currently held item of their hotbar (or alternatively in #1 slot of a target chest nearby) and repairs the durability. Then subtracts 40 levels from the player and announces that the chosen item has been restored for 40 lvls. I like this idea because it still fits into the existing xp economy system but does not make any item unrepairable. I chose 40 lvls because the anvil can repair items up to 39 levels and I'm wanting them to use the console when they can no longer repair via anvil. So effectively a repair-level cap at 40.
I'm kinda new to command blocks but know redstone well.
So I know how to check levels of nearest player and subtract them. I also know how to give items to the player. I just need to know if there is a command to alter durability on existing items or look in a chest or player inventory. If there isn't, is there a way to copy the stats of the item in question but create the new item with full durability and destroy the old? Either will work.
Download and play my new Survival Map!
Space Expedition to EPIC 204: Go on a Space-Age Adventure to visit and explore EPIC 204, a wacky world of dense asteroids and full of alien life! Experience Custom Seasons, Weather, Over 50 new creatures, Beautiful Biomes, Alien Ruins, Dungeons, and new space age tech crafting recipes!
And to clarify, i'm not asking this to be built for me, just the relevant commands or a "no, sorry, that can't be done" answer. I see some of what I need but can't see a way to do this with the basic commands, but they may just be because I'm new to command blocks.
I will need commands to address the following:
1. Reading a player's level and subtracting levels (I know how to do this one)
2. A command to read durability on an item (I only want this will only work if a repairable item is there so the player's levels aren't wasted. I also don't want it to to work if the item doesn't have a durability)
3. A command to either change the durability of an item (so I can set it to full) or to create a new, identical item with the same specifications including changes to name and enchantments and destroy the old. (this could be easier if there is no easy way to tell what "full" durability is on the item as I know it varies and may not be recorded with the item)
Download and play my new Survival Map!
Space Expedition to EPIC 204: Go on a Space-Age Adventure to visit and explore EPIC 204, a wacky world of dense asteroids and full of alien life! Experience Custom Seasons, Weather, Over 50 new creatures, Beautiful Biomes, Alien Ruins, Dungeons, and new space age tech crafting recipes!
However, I have finally, after about 5 hours of research figured out how to do it. the wiki was very vague with the datatag "damage". It was not clear at all that this was what determined the amount of uses left but I finally figured it out through trial and error investigating the error reports of the command blocks. also, there apparently is some bogus variable "Health" which I thought was damage but seemed to do nothign when I addressed it. I finally figured out that this only governs the damage due to lava/fire/explosions and is separate.
The solution:
I ended up having to switch to a method where you drop the item to be restored because then I can access the data as a dropped item entity with entitydata and reset the damage on the item to zero. It works perfectly and only works if a player with 41+ levels is in the area and a damaged item is dropped in the altar area. I orginally wanted it to be placed in a furnace slot as then I could flame the furnace and make it look like something happened, but whenever I used blockdata and got to the variables of the stored item using Item:{slot:0,Damage:0s} it overwrote the item there. I'm unsure why as I only changed the variable damage, however, it acted like I was creating a new item there because if I manually set an id the item with that id popped into existence with the variables set as I did. I'm gonna guess this is a bug from addressing the stored item within the furnace. It assumes id and other vars are zero if you don't set them, effectively erasing the item if you just try to talk to one of the stored variables. However, this dropped item idea I had works perfectly, so problems solved! I even found a nice way using comparators to not run the xp subtraction step if the item dropped had damage already set to 0! Flawless!
Download and play my new Survival Map!
Space Expedition to EPIC 204: Go on a Space-Age Adventure to visit and explore EPIC 204, a wacky world of dense asteroids and full of alien life! Experience Custom Seasons, Weather, Over 50 new creatures, Beautiful Biomes, Alien Ruins, Dungeons, and new space age tech crafting recipes!
I have not found a way to clone items like you can clone blocks which is why I eventually settled on what I did. I figured it might be too complicated trying to replicate all the enchantments,name,etc on the item. If you know how to do that I'd be interested in knowing how as that might be useful to me for future systems. Would cloning a container block also clone the items in it? I didn't try that.
My system needs 3 command blocks effectively, but I ended up needing to up it to 6 to govern the logic and reset the output state of the first blocks afterwards (because I was using comparator logic). The system wouldn't fire again if I didn't do this. I was wondering if you knew a more efficient way to reset block state of command blocks so the comparators would turn off. As it is I need an extra command block currently for every block that I use logic on. I am using blockdata to reset their successCount variable.
Since you expressed interest here is how I accessed the datatag:
/entitydata @e[type=Item,x=,y=,z=,r=1] {Item:{Damage:0s}}
x,y,z is the position of the altar of healing. Basically a depression in the floor that they drop items into.
Each entity has a lot of new datatags that can be accessed, but dropped item entities from using type=Item still act like they are an object with a single slot and thus have the Item:{...} format like there is an item inside them. For whatever reason addressing it this way did not overrwrite the item like when I tried accessing within a block but I might have just made a mistake previously.
Download and play my new Survival Map!
Space Expedition to EPIC 204: Go on a Space-Age Adventure to visit and explore EPIC 204, a wacky world of dense asteroids and full of alien life! Experience Custom Seasons, Weather, Over 50 new creatures, Beautiful Biomes, Alien Ruins, Dungeons, and new space age tech crafting recipes!
I know this is an old thread but thank you so much for this! It helped tremendously! I actually tried using the entitydata command too but I had it written entitydata @e[tag=whatever] {Damage:0}, I wasn't aware that you had to add the {Item:} part lol I am making a system where you throw three lapis and a damaged weapon/armor/tool into a special altar and they get repaired (five lapis and one experience level for enchanted items)
Runes In 4 Commands! Link: http://www.minecraftforum.net/forums/minecraft-discussion/redstone-discussion-and/command-blocks/2665723-runes-in-vanilla-minecraft
cool man! Sounds like fun! Glad this old thread helped.
These days if I'm unsure of the formatting of a datastructure I can access it using open curly braces on a command.
For instance if I want to see the data of an entity I run
/entitydata @e[r=2] {} - standing 2 blocks away from it. It can't access you so it accesses the other entity and prints all their data exactly as it should be. Open curly braces changes nothing, just prints what's already there. If you want to be able to copy it run that command from a command block and check the feedback line.
You can do the same thing with blockdata
Download and play my new Survival Map!
Space Expedition to EPIC 204: Go on a Space-Age Adventure to visit and explore EPIC 204, a wacky world of dense asteroids and full of alien life! Experience Custom Seasons, Weather, Over 50 new creatures, Beautiful Biomes, Alien Ruins, Dungeons, and new space age tech crafting recipes!
@Batr3k is your Y-Coord the ground level or the one above it?
~MS
I never realised you had wrote the new snapshots before that is my fault... in them they have removed the ENTITYDATA command you need to use this now
~MS