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. I'm also considering a rewrite of the Anvil Mechanics page, which will be developing here.

Summary findings

 * I've been working with swords, but I have various reasons to think this will apply to other tools:
 * Swords and tools of a given material generically have the same durabilities.
 * The complexity of the diamond unit-repair costs -- I somehow doubt that would be used solely for swords.
 * Limited experiments with iron picks suggest they follow the identical repair pattern to iron swords.
 * The level cost to repair a tool (including swords) with materials is the item's base cost plus a per-unit cost, - you need more units of material for a heavily-damaged item. Each unit restores up to 25% of the item's maximum durability.  The per-unit cost in levels varies with material:
 * for most materials, it is 1 plus the number of enchantments (regardless of level).
 * For diamonds, besides paying the number of enchantments, each unit costs up to three levels depending how much durability is restored. It looks like one level gets you 199 units, two levels covers up to 299, and three gets a full 390.
 * Repairing with a matching, non-enchanted item is different. You always pay the base cost for the target item, but the additional costs vary by material, and sometimes the durability of the "sacrifice" item.
 * The resulting durability appears to be floor(a+b+0.12*m), up to the item's maximum durability.. That is, it's the sum of the two item durabilities, plus a bonus of 12% of the maximum durability, rounded down (for swords, the bonus is 3 for gold, 7 for wood, 15 for stone, 30 for iron, 187 for diamonds).
 * For wood, gold, and stone, the repair cost is just 1.
 * For iron, it's 1 if the sacrifice has durability under 170, or 2 if its durability is 170 or above.
 * For diamonds, repair is quite expensive: For two unenchanted items, the actual formula is L=B+1+floor((D+87)/100) -- that is, the level cost increases at 13 past each hundred durability points, to a maximum of 17.
 * Naturally, if the sacrifice is enchanted, you will also pay for any enchantments transferred to the target, as noted under combining enchantments. You don't pay for enchantments that are weaker versions of what the target already has.

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
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)
 * Thanks! I knew there had to be a rule, but after two days enchanting swords I was short on durability myself.   --Mental Mouse 21:54, 8 November 2012 (UTC)  (P.S:  Any idea about the level costs?)
 * Hmm. Maybe. It seems that the level cost is given by the item in slot B only. 777+91=2 levels only, as does 573+91, but 573+871=10 levels, and 573+1123=13 levels. So, it's only based on slot B's durability I would say. I've found a formula, but it's not 100% right. It's *almost* there, but just not. It's floor(B/100)+2, with B being the durability of the item in slot B. The only problem with it is for the ones that have 101 durability. That formula says it should cost 3 levels, not 2. But the other values work. I'd need more data though - there's only 6 unique points, so maybe it's B/150 instead of 100 or something? Opaquer 23:58, 8 November 2012 (UTC)
 * Hey, I think I can test that with the stuff I have on hand.... --Mental Mouse 00:40, 9 November 2012 (UTC)
 * Yay! Tell me the numbers too :D! I think we're onto something big here! If this is right, most of the mechanics for anvils are done :D! Opaquer 00:56, 9 November 2012 (UTC)
 * Unfortunately, they don't really fit your formula, though it does seem to be all on the second sword. Data below...  I don't have the patience tonight to nail down all the transition points and missing values, but feel free to add any you find. --Mental Mouse 02:35, 9 November 2012 (UTC)

Enchanting Created Monday 05 November 2012

Again, question marks indicate predicted values.


 * I didn't think it would be perfect, but I though I'd try it! Anyway, this one is a bit more accurate. The only point it doesn't work on is 1123 costing 13 levels :(. This formula thinks it should cost 12 :(. But all the other ones it works, so hopefully that means I'm close :). The formula is: round(B/100)+1, where round is rounding to the nearest whole number, and B is the durability of the second item. So close though! Opaquer 03:07, 9 November 2012 (UTC)
 * Well, that tells me where to look for transitions. (Of course, the unit repair table turned out to be ad-hoc partitioning.)   I'll check it out within a day or two.  I realized tonight that I've probably broken 1000 blocks just on this investigation.   ;-)  And I haven't even gotten to iron swords, let alone armour.  But iron swords won't be nearly as much hassle.  Diamond armor, on the other hand....   :-(

--Mental Mouse 03:47, 9 November 2012 (UTC)
 * Yeah, the diamond stuff won't be too fun :(. I'm hoping it's the same formula for everything :P. Would be nice :P. Let me know how it goes. That 1123 point is annoying me though :(. Opaquer 03:48, 9 November 2012 (UTC)
 * While I'm at it I'll double-check the 1123 thing.I hope iron and wood/leather are the same as gold, too.. --Mental Mouse 04:26, 9 November 2012 (UTC)
 * Please do! I would love for it to actually cost 12 levels instead of 13 :P. Opaquer 04:27, 9 November 2012 (UTC)
 * OK... even without completing the table, it looks like a nice pattern is emerging: transitions at n13, that is is L=1+floor((D+87)/100) .  So you were almost there, there's just an offset. ETA:  Yeah, filled in another link in the middle.  I'm not going through all of them for completeness.  --Mental Mouse 15:15, 9 November 2012 (UTC)
 * Ah, cool! So close! And that works for everything too? Nice :D!. Opaquer 05:23, 10 November 2012 (UTC)

More Questions
Brief experiments with iron pickaxes indicate they follow the same rules as swords. I'm not quite up for testing diamond pickaxes right now, but I think it very likely they likewise match diamond swords.

The bigger questions are for armor...

Oh yeah, there's also the renaming business, and someone is now claiming that removes the "retread" penalty. I think I'll investigate that even before armour repair, because it's liable to be quicker. --Mental Mouse 20:28, 9 November 2012 (UTC)

Repair: My initial results don't seem to make much sense, but it may just be too late in the evening: First sword, durability 91: Renamed at a cost of 7, after which the next repair would have cost 5 (3+2, same as an unrenamed sword that had been repaired once before.

A more complex and detailed attempt, alternately repairing a sword one unit at a time, and renaming it: I have a nasty feeling the durability may be a player here too. --Mental Mouse 02:27, 10 November 2012 (UTC)
 * 1) Durability 101, rename presumably would have cost 7, but I repaired it. (cost 3).
 * 2) Durability 491, would cost 9 to rename, 3+2 for repair. I repaired it
 * 3) Durability 881, would cost 11 to rename or 7 (3+4) for repair. I repaired it.
 * 4) Durability 1271, would cost 8 (2+6) to repair or 13 to rename.    So far so good... then I renamed it.
 * 5) Durability 1271, 13 to rename or 2+3 to repair.  (Wait, what?  3?)
 * 6) wiped name (accidentally ;-) ):
 * 7) 2+6 to repair or 13 to rename.  Renamed it.  (umm...)
 * 8) 13 to rename or 2+3 to repair.  Repaired it.  (I'm so confused...)
 * 9) Durability max, 12 to rename, after some damage 1+2 to repair  (And that's it for the night.)

Followup experiments:
 * Repeatedly renaming a random object costs 5 the first time, then stays 9 for all later renames.
 * Doing the same for diamond swords or iron pickaxes, of low or max durability, costs 7 the first time, 12 for all later renames. The repair cost for the low-D ones is then 3 for the iron pick, 5 for the diamond sword (that is, 2 above usual) --Mental Mouse 15:21, 10 November 2012 (UTC)

And a slight distraction: shears can't be unit-repaired, but they can be merged, for 1 or 2 levels depending on sacrifice durability. ETA: Cost 2 is at is at durability 172, 72.3% of 238   --Mental Mouse 01:32, 11 November 2012 (UTC)

Oh dear... repairing with an intact bow costs 4 levels. --Mental Mouse 01:38, 11 November 2012 (UTC)

Values in table are durability ranges for the sacrifice.