User talk:MentalMouse42/Anvil Mechanics

I'm trying to build on Opaquer's excellent work on the anvil, and experimenting with item repair.

This started at Talk:Anvil_mechanics, but I figured I'll start dumping my data and findings here, so as not to clutter up the talk page. First, I'll type in my notes from the last few days. My experiments started in 1.4.3, with exceptions to be noted.

Summary findings

 * The cost of repair a tool with materials is the item's base cost plus a per-unit cost, which does not vary with the damage to the sword -- you just need more units of material for a heavily-damaged sword. The per-ingot cost varies with material:  for gold, it is 1 plus the number of enchantments (regardless of level).  For diamonds, it is at least 1, but up to 3, plus number of enchantments), depending on how much durability is restored by that unit.  Each ingot restores 25% of total durability.  It looks like one level gets you slightly over half of that, the second level gets you slightly more than half of the remainder, and the third gets you to the unit limit.
 * Repairing with a matching, non-enchanted item is trickier: For gold, it's just the target item's base cost plus (usually) 1.  For diamonds, it's disproportionately expensive, but cheaper if the "sacrifice" sword is damaged.

Golden Swords

 * When repairing an enchanted sword with a plain one, the damage of the plain one does not affect the cost. Also, doing this will be cheaper in levels than even the one-ingot cost for repairing with materials.  The cost appears to be the base cost plus 1.
 * ETA: When combining two enchanted swords, that "plus 1" penalty appears and disappears, I haven't quite nailed down what the rules are.
 * ETA2: When repairing a sword with a "subset" sword (that is, the target sword will not change its enchantments), it costs the same as with a plain sword.
 * [...] If you've read my forum/reddit post, you'll know I tried some theories as to how to calculate the cost of combining two enchanted swords without common links, and some got very close to working. I had that same problem. I found a way to make it work, tested in on 5 swords, and it worked perfectly. Then I tried on one more to be 100% sure, and I was missing 1 level. Couldn't figure out where. Kept trying, and I was always correct or 1 level short. Still haven't figured out why this happens or where that level comes from :(. Opaquer 00:37, 6 November 2012 (UTC)

Diamond swords
Early experiments with diamonds are bizarre. With plain diamond swords, I'm getting 2+1/diamond for repair... but combining a damaged one with a whole one costs 17 levels, and combining two damaged swords, only 13! And it gets worse: A damaged Bane 1 sword costs 20 to repair with a whole sword, but only 16 with a damaged one. For a Bane II sword, that's 22 and 18. It also costs 18 to repair the Bane 2 sword with the Bane 1 one (both damaged). Repairing them with diamonds costs 5+2/unit and 7+2/unit respectively. (In all cases I'm assuming the unit costs are in fact constant; it was hard enough wearing my "mother sword" down below 75%.)

[Deleting incorrect extrapolations about the unit costs]

The real shocker is the sword-on-sword costs -- Even if there's a cost dependent on damage, I would not expect using a damaged sword to be cheaper. The cost for combining two damaged plain swords is 13 (12 more than expected), and using a whole sword on a damaged one mysteriously adds another 4.

Given this, the Bane repair costs are as expected:
 * Combining the Bane swords with damaged plain ones, adds the cost of the Bane swords.
 * Combining the Bane 1 sword onto the Bane 2 one costs the same as repairing the Bane 2 one with a plain sword.
 * Repairing the Bane swords with diamonds adds the cost of the Bane swords, and 1/unit for a single enchantment.

Next I think I'll try enchanting some intact swords and further damaging another "blank" sword. These experimental entries are getting long... should I perhaps be moving these experiments to my own userspace? --Mental Mouse 11:23, 6 November 2012 (UTC)
 * Hmm. Sounds like it's going quite well. What's your method of damaging the swords quickly? I might be able to join you soon, but won't have a long time to damage the swords down :(. Also, if you want to send me the data so I can have a look over it too, I would be happy to. If so, is there some way to send stuff over the wiki, or you want to talk on the forums/reddit or something? Let me know though, I love looking at data (you should see my original spreadsheet for the anvil data stuff :P). Opaquer 11:27, 6 November 2012 (UTC)


 * I'm using /gamemode to go to survival, then swinging at dirt blocks. I just started using F3+H to get durability values.  Most of my data is scrawled onto graph paper, but I can probably type it in over at my own userspace.  Newest findings:  unit repair for diamond swords costs up to 3 levels per unit, depending on the durability gained with that unit.  The third unit goes from 1 at durability 595 (up to 777 or more), to 2 around 573, and 3 around 479.  None of these are exact, I was testing at intervals while beating down the sword. --Mental Mouse 13:36, 6 November 2012 (UTC)
 * Hmm... Fair enough. So you're saying that it could be that less than 1/3 durability, it costs 3 diamonds, between 1/3 and 2/3, it costs 2 diamonds, and above that, it costs 1 diamond? --Opaquer
 * Or rather, 1/12 of the entire durability (four units, each costing up to 3 levels). I'm about to test a transition point on that.  Another note on methods:  In creative mode, you can use frames and "pick block" to duplicate a damaged weapon.  Doesn't seem to copy enchantments, though.  :-( --Mental Mouse 13:45, 6 November 2012 (UTC)
 * The pick block in frames is amazing. It's how I made so many items to enchant for the first anvil tests :P. So, at 1/12th the durability, you're saying it'll cost 12 levels to fully repair? Not quite sure if I'm getting it right :(. Kinda tired :(. Opaquer 13:48, 6 November 2012 (UTC)
 * Right, if it's worn down to a nubbin. Latest findings:  For the first ingot, the cost changes from 1 level to 2, between durability 1371 and 1361.  That's a little awkward -- it could be half-way between the twelfths (that is, rounding to the nearest twelfth). --Mental Mouse 14:08, 6 November 2012 (UTC)
 * Hmm. That's a really weird number :S. That's around 10.5/12. Maybe it's split into 24 segments, and that would relate to the 21st segment out of the 24, and every second odd one, the cost changes? 21/24 makes me happier than 10.5/12 :P. Opaquer 14:14, 6 November 2012 (UTC)
 * Yeah, that's equivalent to the rounding. But the next transition happened between 1280 and 1251, which has distinctly high for that pattern (should be 1235).  :-(  --Mental Mouse 14:34, 6 November 2012 (UTC)
 * So it is D:. Those are some odd numbers then D:? Might certainly have to do more testing, maybe with other materials too. I doubt golden swords will be split up into 24 sections too :P. Opaquer 15:04, 6 November 2012 (UTC)

Costs for Unit Repair
Question marks indicate predicted values.

Next:
 * Pin down the transition points for unit repair (done)
 * figure out how costs for combining plain swords depend on the durability of each. Theory:  the sacrifice sword is considered as one or more ingots according to its remaining durability.  See below for initial data, feel free to add more or note your conclusions.

Costs for merging
All unenchanted diamond swords of various durability.

Getting a bit bored with this, so it may be a while before I continue, but I wanted to get this data up here. Looks like the cost is dominated by the second sword if that is less worn. --Mental Mouse 01:03, 7 November 2012 (UTC)


 * Just by looking at these numbers, for diamond swords at least, it looks like the formula for it can be given by: floor(a+b+0.12*m). Floor is rounding down a number (so, floor(12.95)=12), a is the durability of the first item, b is the durability of the second item, and m is the max durability for that item (1562 in the case of diamond swords). It should be noted that if this number is greater than the max number of uses for an item, the amount of uses on the tool is the max item (so, for the example with 573 and 1123: floor(573+1123+0.12*1562)=floor(1696+187.44)=floor(1883.44)=1883, which is more than 1562, so the uses for that sword is just 1562. Not sure if that 12% thing applies for non diamond stuff though, or if it's only for diamond swords. Opaquer 06:27, 7 November 2012 (UTC)