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
For bows, durability up to 153 costs 1, each additional 100 durability costs another 1 level, up to 4.
 * 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.  This also applies to flint & steel, fishing rods, and carrot-on-a-sticks.
 * For iron, it's 1 if the sacrifice has durability under 170, or 2 if its durability is 170 or above. For shears, it's similarly 1 up to durability 171, 2 at durability 172 and up.
 * 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)


 * Hmm. Sounds like it was going well at first :S. Oh, how I wish there was an easy way to get an item down a lot of durability very quickly to make testing faster :P

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.
 * Doesn't look like shears and bows follow the same rule for level cost as the other stuff above D:. According to the thing before, it should have cost 3 levels for 172 durability, and 4 for 238 durability. Maybe there's not the same offset of 87 for shears? -- Opaquer
 * Oh, definitely not, I'm pretty sure the offset of 87 was just for diamonds... and might be just for diamond tools. Compare the iron tools, with yet another offset. --Mental Mouse 12:19, 11 November 2012 (UTC)
 * True, but once we find any transition point, assuming it follows the 1+floor((D+n)/100) rule, we can find out what n is for each tool, which make things a lot easier
 * Oop. Here might be something. For the bow, it looks like the formula for it is 1+floor((D-54)/100), with the condition that if the cost is less than 1, make it equal to 1. Or, at least, it works for all the values it seems... Opaquer


 * For the other tools, it could be that it does cost more than 1, but since the durability is so low, we don't get to see it? Just trying to figure out a general formula here :P. Opaquer 13:35, 11 November 2012 (UTC)


 * OK. This is interesting (to me at least :P). The n value for shears is -72 (1+floor((171-72)/100)=1, which for 172-72, it equals 2). What I find interesting though, is the value. the transition point for shears is 172, while the n point is -72. The transition point for the bows was 154, and the n value was -54. See a pattern :P? In fact, this can be applied to the swords. Instead of using 1+floor((D+87)/100), we could use 2+floor((D-13)/100), since the transition points for diamond swords are at the 13th of every level like you found! For iron (using transition point between 170 and 171 gives the formula to be 1+floor((D-71)/100). Why diamond is 2+ though, I'm not sure. I guess to make it more expensive? Or maybe it's based on how many total uses an item has? I guess without having lots of other items that have a lot more durability, we'll never know! Still though, a general formula could be something like: a+floor((D-n)/100), where a is either 1 or two (depending on the tool type, D is the durability, and n is the last two digits on the transition points. We're going to need a way to figure out an easy formula for them too :P. Let me know what you think :). Opaquer 14:07, 11 November 2012 (UTC)

Now you're editblocking me! I combined the data so far into the table. -MM
 * Haha, sorry :P. My bad :P. Hate it when it happens :P. Opaquer 14:13, 11 November 2012 (UTC)
 * OK, put in the iron armour. (I loaded up on skeleton eggs, then dropped them in survival/peaceful mode.  One shot per egg.)  The numbers look pretty arbitrary to me.  :-(  --Mental Mouse 15:16, 11 November 2012 (UTC)
 * Hmm. The transition points aren't jumping out at me just yet, but the formula is the same as above ^^^^. 1+floor((D-n)/100). I'm going to guess that diamond has the same formula as tools, just different transition points perhaps? Opaquer 15:19, 11 November 2012 (UTC)
 * Well, most of these only have one transition point, so X/100 is besides the point. The breakpoint for the second level actually rises as total durability drops (I reordered the table to show that) but the line isn't quite straight.  It's probably time to bite the bullet on diamond armor (or renaming, but that got weird).   BTW, regarding methods, I also set up some beacons a ways back to give me regeneration, speed, and haste.  Still managed to get killed once anyway, but I have a bed too.  --Mental Mouse 15:49, 11 November 2012 (UTC)
 * A very good point. But, for iron armour, n can be found by calculating floor(-m/10)+97, with m being the max durability of the armour. It seems to work, though why 97, I have no idea :(. Gives n=72, 74 and 77 for chestpiece, legs and boots. At least then for the formula, it's now something that can be calculated through one variable (like 97 for iron). It seems that from this n value, we can calculate the transition point by adding 100 to it. It also explains why iron helmets don't have a transition point - the n value of the helmet is 80, and 100+80 is 180, which is more than the max durability of the iron helmet (166). Diamond would need to be tested, but, guessing a theory here - if you give me a transition point, we should be able to make a formula for it assuming it follows the same rules as before (floor(-m/10)+b), and we'd only need a single transition point for it (in theory of course :P). Opaquer 16:03, 11 November 2012 (UTC)