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 by 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).
 * The cost of the repair depends on durability as well. For items with low maximum durability (under 178), the cost is simply 1.  If the item has remaining durability of 200-floor(MaxDur * 0.12), it will cost another level, plus another for every 100 durability it has above that value.  This breaks down as follows:
 * For wood, gold, and stone, the repair cost is just 1.  This also applies to flint & steel, fishing rods, and carrot-on-a-sticks, also to leather and gold armor.
 * For iron tools, 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 diamond tools, the second level is paid at durability 13, and continues with each 100 afterwards up to 17 at 1513.
 * For iron and diamond armor, each piece has its own offset, but the pattern continues.
 * 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)
 * So far it looks like they are by hundreds with offsets, but the offsets are on another curve. Possibly a different divider?  --Mental Mouse 19:40, 11 November 2012 (UTC)

OK, I'm convinced the pattern holds for armor, probably not going to test the last column or two unless I need more worn-down stuff for unit repair. ETA: Guess not. All the armor costs one level per unit. --Mental Mouse 22:40, 11 November 2012 (UTC)
 * Regarding the formula: Perhaps it's always D=(L&times;100) + N.  But N depends inversely on max durability... and for diamond tools, that huge durability makes it negative. --Mental Mouse 22:49, 11 November 2012 (UTC)
 * Oh yeah, I just installed a plotting program and got a graph of offset vs. max durability, and it's a dead straight line. I'm not sure what the parameters are yet, but we'll figure it out.  (I was using the upper end of the ranges for the offset, thus -88, 56, etc.) --Mental Mouse 23:35, 11 November 2012 (UTC)
 * Got it. 100-floor(MaxDur * 0.12) gives the offset,  the shift to level N+1 is at N*100+Offset.  And where have we seen that number before?  --Mental Mouse 00:07, 12 November 2012 (UTC)
 * Very cool! So, let's see if I got this right: A general formula for the level cost for repairing is given by: 1+floor((D-n)/100), D being the durability of the second item, and n being an offset which we can find by using 100-floor(0.12*MaxD), with MaxD being the maximum durability of the item. Also, we can use 1+floor((D-n)/100) for everything including diamond (ignore the 2+ from before) because the n value=100-floor(0.12*1562)=100-floor(187.44)=100-187=-87. This then makes the level cost be 1+floor((D-(-87))/100)=1+floor((D+87)/100). Look familiar :P? The transition point that's between level P and P+1 (I won't call it N like you did to avoid getting n and N mixed up :P) can be found by using P*100+n, and this gives the lowest durability for level cost of P+1. So in diamond, the transition point between level 15 and 16 is 15*100+(-87)=1500-87=1413, which is the lowest durability you can have on a diamond sword to make it cost 16 levels (though if you want the max durability of level P instead of the lowest of P+1, you can simply take 1 away from this). This can of course be rearranged to get P=1+floor((D-n)/100) to give exactly what we had before. At least we're consistent :P! So, we've got a formula for the level cost of an item based on it's durability; now all we need is the amount of durability it will have at the end, which is given by floor(D1+D2+0.12*MaxD), with D1 and D2 being the durabilities of the first and second items, and MaxD again being the maximum durability of the tool. Have I missed anything here, or is this everything? It looks very complete to me :). Opaquer 00:58, 12 November 2012 (UTC)
 * Yup, you've got it. Now I was poking into combining enchantments again... I'm seeing that mystery +1, and wondering if it represents enchantments that didn't get merged.  I'll probably follow that up another night....  --Mental Mouse 02:03, 12 November 2012 (UTC)
 * Sweet! What do you mean by enchantments that didn't get merged? Opaquer 02:21, 12 November 2012 (UTC)
 * Like Smite over Sharpness... Anyway, I'll see what I can figure out. My first chest of diamond swords is overflowing. :-)  And yeah, I'll get back to the renaming thing eventually.  There, it looks like there are at least two parallel penalties going on -- that is, I think the frequent-flyer penalties are *not* actually part of the base cost, but apply separately to repair and renaming, with different rules.  It sucks that the anvil doesn't display the level of a single item anymore....  --Mental Mouse 10:57, 12 November 2012 (UTC)
 * A very good point. In one of my very first tests, I had a theory that worked for the 2 swords that had clashing enchantments, and then stopped working :P. Also, I just figured out something. I put in the formulas we have, and combined them and got something simpler. The durability thing is the same, but for the level cost, instead of having L=1+floor((D-n)/100) and n=100-floor(0.12*MaxD), we can combine these quite easily to get L=floor((D+0.12*MaxD)/100). Easier formula to use in my opinion. And if you really want to find where the transition points are, you can use the formula from above, though with the general formula for level cost, you don't really need it that much. Or you can plot the graph and find out that way :P. But yeah, I think all we have left to do is find out how renaming works, how it calculates the cost of enchantments that don't get merged, what happens when two items have no (or some) common links (like a sharpness 4 and knockback 2 sword), and if these combine (so, combining a damaged sharpness 4 with another damaged knockback 2 sword). I think once we figure that out (which looks like a lot, but won't be), that's it. We win anvils :P. Opaquer 12:43, 12 November 2012 (UTC)
 * Oh, good work combining the formulas! By the way, have you looked at the rewrite I'm working on for the original page?  It's not complete, but I'm planning to delete most of the stuff below my "progress header", once I finish ransack it for stray details and examples.  Given that, do you think it'll be a reasonable replacement? --Mental Mouse 01:07, 13 November 2012 (UTC)
 * I shall have a read of it now :D! Opaquer 01:10, 13 November 2012 (UTC)
 * OK, had a read. I'm assuming the "Old text follow... merge in" is what I wrote on the current anvil page as is, and just needs to be put in place into your one? As to your one though, it looks good. A few things that will need to be changed (some reordering of the headings - I think after you explain the base cost thing, the next thing should be combining enchantments instead of repairing, but that's just me). Also there are a few grammatical errors in, but nothing a big edit can't fix :). Also, a big thing is the formulas. We know what they mean, since we discovered them, but someone who hasn't been following this won't know what a, b and m are in floor(a+b+0.12*m). Also, we use m and MaxD as the maximum durability, so we'll need to fix that too, and go through and make all the variables the same. Other than that, I think a few more pictures would help, especially if we could predict what will happen. I don't know if it's just me, but people seem to understand better when they see what they've just predicted? Apart from that, I don't think I saw anything else that was too major. Looked good though :). Do you think we should change it once we completely figure out the combining of two items section and figure out that +1 penalty, or start fixing it up and merge it in even though it's not fully complete just yet? Opaquer 01:24, 13 November 2012 (UTC)

Anvil mechanics rewrite
The last section had gotten too long... so, new section.

I've just finished the merger. At this point, if you see grammatical errors, feel free to fix them. I will continue on the variable consistency and such. Also, we need more examples. I'm dubious about screenshots of the anvil GUI -- they say less than the text, and take up a lot of screen space. Once we've got the niggling details done, I'd say propose a replacement on the original talk page, and give it a few days. (I think we're the only ones working on it, but it's still polite to ask first.) After that, we can add new findings as we discover them. Just to recap, we're looking for:
 * How renaming works:
 * how the cost is figured
 * how the penalties work for future repairs and future renames.
 * How it affects the prior-repair penalty
 * Is there a mystery cost for enchantments that don't get merged? If not, where is that dratted +1 coming from?

(Knockback and sharpness would certainly combine without incident. If the target is damaged, you just pay for the repair too.) --Mental Mouse 01:49, 13 November 2012 (UTC)


 * Good thinking! So, by merger, you mean the thing you wrote up? I'll go through it now quickly and fix some stuff up :). Opaquer 01:52, 13 November 2012 (UTC)
 * Cool. By the way, I put unit-repair before because it's ultimately simpler -- one item, and doesn't involve the second-slot cost.  Then sacrifice repair of unenchanted items, because adding in the base cost is easy, and finally the complexities of merging enchantments, because that potentially involves both of the previous plus the second-slot values.  --Mental Mouse 02:01, 13 November 2012 (UTC)
 * A very good point. I guess it made more sense to me beforehand because that's how I had it before :P. But now that we've got the whole repairing thing, it's easier to do it your way :P. Going through the page now and fixing up stuff :). Opaquer 02:02, 13 November 2012 (UTC)
 * Hey, can you stop editting your page for a bit? I'm editting it too, and don't want to get edit blocked :P. I'm taking in your edits though so far, so you won't have to do them again :)
 * OK, I was just fixing up the equations and such. Oh yeah... I forgot to check, and I'm almost ready for bed:  Do you pay prior-repair penalties for a sacrifice item?  Either way, it should go in the page. --Mental Mouse 02:15, 13 November 2012 (UTC)
 * Yup, doing that too :P. Won't be too much longer :). And yeah, I'm pretty sure you do. I did a test with 2 sharpness 4 swords that I made using 2 sharpness 3 swords, and it cost me 7 levels for the first sword in the anvil (as expected), then I'm pretty sure it was an extra 4 to cost 11 levels total, which meant that sharpness 4 sword had the extra 2 levels. Opaquer 02:17, 13 November 2012 (UTC)
 * OK, done my editting. Took in your things too, but expanded slightly on the formulas. Let me know what you think :). Opaquer 02:23, 13 November 2012 (UTC)
 * Looks good, though I've still been tweaking it some more. Yep, I get Sharpness 4 &rarr; BV 5, with 2 for the second-slot cost.  If it cost 11, that's two penalties.  --Mental Mouse 03:25, 13 November 2012 (UTC)
 * It is indeed 2 penalties :). But I'll need to double check my notes when I get home to be sure. Also, with your example "And a simple one: A Sharpness 4 sword (BV 5) for the target, and a Looting 2 sword (BV 9) for the sacrifice. You pay 5+8&arr;13 levels, for a sword with Sharpness 4, Looting 2 (BV 4+8+3&arr;15)". Is that right? I didn't think for things with no common links you could just add them up like that? Opaquer 03:26, 13 November 2012 (UTC)

First response to that last: Why not, isn't that what the anvil is for? Second thought: Better check. After churning out way too many diamond swords, I had the sense to switch to iron pickaxes. And... WTF. Unbreaking II (BV 5, SS 4) + Efficiency I (BV 2, SS 2) does work, but it costs 9. Switch them and it costs 12. Damage each of them and it's 11 and 14, so sacrifice repair isn't involved. Either way, the combination does work, but there's 2 or more points unaccounted for. Also, and on a tangent: there seems to be some explicit surcharge for having the more powerful item in the second slot, but I don't see how that works. --Mental Mouse 13:42, 13 November 2012 (UTC)
 * There's always been that extra cost for having the higher level item in the second slot. I think I mentioned it in the anvil page? And the problem we were having was that things without any common links don't just add up simply unfortunately (from my testing). A sword with looting 3 combined with a sharpness 1 doesn't just cost the base values of each of the swords, does it? Opaquer 13:44, 13 November 2012 (UTC)
 * Part of my testing problem is that I haven't gotten a pure Looting sword. That's why I switched to pickaxes, where both Efficiency and Unbreaking are common.   Have you verified any more complex cases where the second item is transferring a new enchantment?  I thought I had, but I may not have time to double check before I leave for work.  Do you have any ideas on how the higher-item penalty works, or at least the conditions?  Is it "any enchantment with a higher level than the target's highest?" --Mental Mouse 13:55, 13 November 2012 (UTC)
 * 1.4.4 has a nice new feature that could be very handy! use /enchant [enchantment id] [level] to enchant anything that can be enchanted. And the best part, it doesn't undergo any penalties! So, we can get pure sharpness 5 swords to test stuff with! The enchantment id is given from the enchanting page (left column of the table is the id). Might make things a bit easier :D. Also, any time there's a lower level item in the left slot, it will cost more and have this weird penalty. Haven't quite figured out much else about it other than "you have to have the lower base cost of the two items in the first slot" :(. Opaquer 13:58, 13 November 2012 (UTC)
 * Base cost, well, that's something. I started experimenting, and realized there's a lot about combination that we really haven't verified.  First try:  Smite 2 KB 1 (BV 4+3=7) + Bane 2 KB 1 (BV 7, SS (4+) 2) costs... 15?  Either way, which is good because those should have identical BV and SS profiles.  And now I need to sign off until evening. --Mental Mouse 14:05, 13 November 2012 (UTC)
 * Yeah, combining things without common links has always been problematic. We've got to sort that out unfortunately :(. I suspect once we figure out how stuff without any common links works, we'll also figure out how stuff with only some common links work :). Also, it's quite late here, so I might be forgetting something, but what's SS? Second Slot? Opaquer 14:07, 13 November 2012 (UTC)
 * Yes, SS is Second Slot. The new /enchant command should make things much easier, but it'll still be tricky... I need to think up suitable test cases.  --Mental Mouse 22:23, 13 November 2012 (UTC)
 * You can try Looting 3 combined with a sharpness 1, 2, 3, 4 and 5, then with a bane and see how the level change. I suspect that there will be a constant value between them. Next you can try it with looting 2 instead, or knockback or something. Just make sure that the higher of the two items is in the left slot unless you want it to be a lot harder :P. Opaquer 22:24, 13 November 2012 (UTC)
 * Yeah, that's similar to what I was thinking. Unfortunately, I just realized that 1.4.4 is the next release, which doesn't come out until tomorrow.  Also, it's a pity that frame-duplication doesn't retain enchantments.  :-(  --Mental Mouse 22:46, 13 November 2012 (UTC)
 * 1.4.4 pre release is out though :). And doesn't it :S? I thought item frames kept everything? Otherwise do what I did to get all my stuff - use the pick block button on the sword in your inventory. Easiest way to get 15-20 double chests full of swords like I have :P. Opaquer 22:48, 13 November 2012 (UTC)
 * I did not know you could pick block from inventory! Picking an enchanted weapon from a frame gets an unenchanted version with the same durability.  And I Do Not Want to manage 15-20 double-chests of anything, I've already got 8! --Mental Mouse 00:29, 14 November 2012 (UTC)
 * It's handy, isn't it :P? I figured it out by accident while playing around with the original anvil stuff :P. I think what I did though was just get unenchanted swords and then enchant them :P. And yeah, 15-20 double chests of swords are not fun, especially when you're trying to find the one you need that has the exact enchantment you need :P

Combining items
Last section was getting long, and I was tired of counting how many :'s I needed to be on the right level :P. Anyway, been playing around and found some stuff. Not much, but it's almost there!

Anyway. Mission almost completely successful. I had a bit of free time finally and got on Minecraft. Tested out anvil stuff. And tada. I got a more complete formula for level cost for combing items :). This includes:


 * Items that have some common links
 * Items that have no common links

This does not include:


 * Items that have clashing enchantments (like sharpness and bane)

The formula, which used to be:

LF=Bk+(nk-1)*Ik+E+2*A

Was used to find the level cost for the first item. Then L=LF+Ik was used to combine two items

Can now be made to (more complicated, I know, but that's the cost of it being more complete! Also, one formula!):

L=B1+nk*Ik+x(T-1)+1+2*A

Here, L is the level cost of the process, B1 is the base cost of the first item, nk is the tier of the kth enchantment, Ik is the initial increment value for the kth enchantment (so, looting 3, even though it's at maximum level, will still have an initial increment value of 8, not 4), x is the number of NEW enchantments on the second item, T is the total number of enchantments you end up with, and A is the number of times it's been through the anvil process.

So, that probably didn't make much sense, so to an example or two or three (assume new swords in these examples, so that A=0 always for these examples. That said, I didn't test with any examples where A>0, so it might break apart there):

Example 1: Combining a Sharpness 4, Knockback 2, Fire 1 sword with a looting 2 sword (no common links).

L=B1+nk*Ik+x(T-1)+1+2*A

B1=Base cost of first sword: 18 nk=4 for the sharpness, 2 for the knockback and 1 for the fire Ik=2 for the sharpness, 4 for the knockback and 8 for the fire x=1 new enchantment on the final item T=total number of enchants on the final item=4

So, we have:

L=18+4&times;2+2&times;4+1&times;8+1(4-1)+1

L=18+8+8+8+1(3)+1

L=46

Which is what I got from my tests :)

Example 2: Combining a knockback 1, smite 3 sword with a fire 1, knockback 1 sword (1 common link)

L=B1+nk*Ik+x(T-1)+1+2*A

B1=Base cost of first sword: 11 nk=1 for the fire and 1 for the knockback Ik=8 for the fire and 4 for the knockback x=1 new enchantment on the final item (NOTE: Even though there's 2 enchantments on the second sword, knockback will combine with the knockback on the first sword, leaving you with only fire being a new enchantment) T=total number of enchants on the final item=3

L=11+1&times;8+1&times;4+1(3-1)+1

L=11+8+4+1(2)+1

L=26

Again, with my calculations :)

Now, while these calculations are good and all, it doesn't explain what happens if you have a bane a smite sword clash, or a unified formula. As a scientist, I love unified formulas. At the moment though, if every item is a common link, use the old formula. Otherwise if theres no clashes and no/some common links, use this new formula

Anyway, let me know what you think :). I think we're almost all the way through understanding everything there is to know about anvils! Opaquer 13:32, 14 November 2012 (UTC)


 * I still prefer seeing the components listed textually -- lists of parameter values make my eyes cross. :-~  I'd also suggest abstracting that "2*A" into "P", the prior-use penalty, because we know that renaming will make that more complicated.  And you're saying "increment", then using the SS values  (Increment was the per-level cost).  Also, the next question is how it break on disjoint (no common factor) combos?


 * Lets look at my pickaxes from above:  "Unbreaking II (BV 5, SS 4) + Efficiency I (BV 2, SS 2) does work, but it costs 9. Switch them and it costs 12. "   So, we have:
 * target BC: 5
 * target enchantment Unbreaking II: 2&times;4 &rarr; 8
 * new enchantments: 1&times;(2-1) &rarr; 1
 * constant 1
 * Total cost: 5+8+1+1 &rarr; 15 Hmm.


 * I haven't been offered the upgrade yet, but I think it'll be available in another hour or two. --Mental Mouse 14:06, 14 November 2012 (UTC)


 * What do you mean by seeing the components listen textually? I'm a scientist, so I love lists of parameter values :P. And yeah, 2A=P from now on :P. By "increment", I mean the base SS value (i.e., the value of the SS of each enchantment at level 1). So, looting 1 and 2 have a SS value of 8, while looting 3 has a SS value of 4. But, in the formula, when you're using the Ik, that's the initial SS value (so, 8 in the case of looting). Are you saying my formula didn't work at all for your example, or just when the lower level thing was in the first slot? If it's the latter (which is hopefully the case :P), my formula doesn't take into account the level costs. It assumes that you have the higher of the two items in the left slot :). Also, I think I've got a unified formula for the all common links, some common links and no common links :). Give me a few minutes to test it before I start talking and maybe making a fool of me :). Opaquer 14:13, 14 November 2012 (UTC)
 * OK, so my theory didn't quite work. Was off by one level again :(. Until a unified formula is figured, we might have to stick to the old one if everything is common. Anyway, I'm about to go to bed, but I'll hopefully be able to get back to testing in 12-13 hours :). I don't sleep for that long unfortunately, but I am getting up in 7 hours and going to be busy for another 5-6 hours after that :P. Opaquer 14:38, 14 November 2012 (UTC)


 * Another thing: The SS values previously applied to the sacrifice, but you're using the values for the target. That will certainly break at least some working prior examples!  I was trying to see how the disjoint example broke, and I got 6 above the measured cost, 8 above the old-formula cost.  Though actually, it works  if I use the sacrifice's n&times;SS instead:  2 instead of 8 gets us back down to 9.  Also, "initial" SS value is distracting, since we simplified the tables and made the halving a special case.


 * Textual description:
 * The total Level cost of the process is the sum of these values:
 * The base cost (BC) of the target item.
 * For each enchantment "k" on the target (???), the SS value (k)times the level (ELk).
 * Consider N as the number of new enchantments (on the sacrifice but not the target, not combined, (maybe?) not suppressed), and T as the total number of enchantments you will end up with. Add N&times;(T-1).
 * Add a constant 1, plus any penalties (P) for prior repair.
 * To summarize this as a formula, L=BC + (SS1&times;EL1 + ...) + N&times;(T-1) + 1+P
 * --Mental Mouse 14:45, 14 November 2012 (UTC)
 * Well, it wouldn't break the examples too much, will it? Especially if we can get a unified formula. I had an idea to use the difference between the current level of the enchantment from the second item and the current level of the enchantment from the first item, and if they were equal levels, make it do something. But it didn't quite work :(. Anyways, I'm also rather tired, so maybe if I sleep on it (for another 6 hours :, it'll come to me. Or maybe it'll come to you in your more alert state than I'm currently in :P. Opaquer


 * If it doesn't match prior measurements, then it doesn't cover the domain. We might indeed find one or two cases of "if this is so, add that factor", but notice how when we actually got sacrifice repair sorted out, all the fudge factors dropped out?  : Also, regarding descriptions: Notice how in item 3 above, I'm treating each enchantment as a unit.  The numbers for a list of enchantments are naturally a list of tuples, and you were presenting them like a parallel pair of lists -- which you then took a dot product of.  That's what got my eyes crossed, and will absolutely leave behind most readers.  --Mental Mouse 14:57, 14 November 2012 (UTC)
 * Nah, it's just a different thing. One way we used the level of the first item with all those extra thing, and just add the second slot value. The way I just found, it's just more complete. The old way didn't work at all for combining things that had no common links. Speaking of which, THIS is (hopefully) a more complete formula:

L=B1+(nk-Pk+1)*Ik+y+1+A


 * I know it's long, but it has to be complete :P


 * With everything the same (I've made the 2*A penalty become A now. I didn't want to use P because it makes more sense for the P variable to be called P :P), except for a few things. Pk now refers to the PREVIOUS level of enchantment that was on the first item. If the enchantment wasn't on the item, P=0. Sorry, this probably doesn't make too much sense yet, but just keep reading :). Hopefully it'll make more sense :P. The other difference is y (or whatever you want to call it. I just used y because it came to mind first :P)


 * Here, y depends on how many EXTRA enchantments are being added. If there are no extra enchantments being added to the target item, y=-1. Otherwise, y=x(T-1), with x being the number of extra enchantments and T being the total number of enchantments on the final item. Hopefully this makes sense :P.


 * Also, I totally blame the whole not making sense thing on being tired :P. I had like 3 hours of sleep because I wanted to get up to see the solar eclipse, and was quite tired :P. Feel free to edit the grammar if the time comes :D.


 * And it does work for previous examples. Let's look at the current one on the wiki page: first slot, a sword with sharpness 3, knockback 2 and looting 2 being combined with a sword that has sharpness 3 and looting 2. We use our formula. B1 is the base cost of the first sword: we know this is 21 (I trust you know this sword's base cost by now off by heart :P). For the (nk-Pk+1)*Ik part, we use the values from the second item. n1=3, since we have a sharpness 3, and n1=2 because the level of looting on the second sword is 2. P1 is the level of the first enchantment (sharpness) on the first item, which in this case is 3 as well, while P2 is the level of the second enchantment (looting), which is 2. I1 is the initial SS value for sharpness (we might have to define it as something else instead of the SS value, but for now, we'll call it that), which is 2 for sharpness and 8 for looting. Here we're adding no NEW enchantments onto the sword (since we've already got sharpness and looting on the first item, so y=-1. Subbing everything in, we get (when I have [] next to a number, it's showing where that number came from):

L=21[base cost of first item]+(3[level of sharpness on second sword]-3[level of sharpness on first sword]+1)*2[increment value of sharpness]+(2[level of looting on second sword]-2[level of looting on first sword]+1)*8[increment value of looting]-1[y value]+1+0[new swords, so no anvil penalty]


 * Which, with the text taken out to read it easier:

L=21+(3-3+1)*2+(2-2+1)*8-1+1+0

L=21+2+8

L=31


 * Look familiar :P? And, something I just noticed. The old formula added the SS value for each enchantment the second sword had. But, it also assumed that every enchantment on the second sword was on the first sword (y=-1), AND that they were at the same level (i.e. n1=Pk). When we put that into our new formula and simplify, we get:

L=B1+(1)*Ik-1+1+A

L=B1+Ik+A


 * Again, look familiar :P?


 * So yeah, hopefully that explains that. I know it's a much longer formula, but I much prefer it, probably because it's more unified. I haven't tested if this works if you combine a sharpness 3 and looting 2 sword with a sharpness 4 sword. I only tested it with same value enchantments, but if I'm right (which I could very well not be!), then it should work for any level thing :). Then all we've got to look at is the formula for when the item in the first slot isn't the higher level of the two (and do we still need to refine renaming :S?) :)


 * Let me know what you think though :)
 * Opaquer 08:25, 15 November 2012 (UTC)


 * Oh no D:. I was just re-reading this again and found a mistake. I knew I should have checked the formula since last night when I was tired :(. Don't try figure out math while you're tired! It doesn't quite work :(. Ach, I feel terrible now :(. The problem is that if there's no common link, then the P value is 0, so we end up with (n+1)*I, which when expanded in n*I+I, when we only want n*I. We can't get rid of that +1 though, because if P=n (i.e. the level of the enchantment on the previous item is the same as the level on the second item), we would end up with (n-P)*I [if we get rid of the +1], which gives 0, which is also wrong. What we want is to have something like (n-P+t)*I, where t is some random variable that I can't think up a proper name for. If n=P, t=1, otherwise t=0? Of course, based on the little testing I've done, that's actually t=1 when n=P, and t=0 when P=0... My first reaction is t=P/n, which would work for t=1 and t=0, but we need more testing to see if that's a universal thing. It might then need a bit of rounding :(. Though, if it does, it *might* explain that weird +1 thing if it's still coming up? maybe it was doing floor(12.2+16.7+4.4)=floor(33.3)=33, even though 12+16+4=32? I'm probably not making sense here, so I'll shut up and try figure this out (and double check it tomorrow before I post if I find anything!) Opaquer 15:04, 15 November 2012 (UTC)


 * OK, so, it's not a complete waste to read what I said up there. It's still not 100% right (first attempt works perfectly to combine items only if they have all common links, second attempt (if it makes sense - I'm rather tired here so it might make no sense) works perfectly to combine same level items regardless of common links or not (as long as you use t=1 for n=P and 0 otherwise). However, neither work for different level items such as Looting 1 and Bane 5 sword being combined with a looting 3 sword :(. If you have any ideas, let me know. I'm going to bed now (yay for 2AM!), but should check back tomorrow every so often. I feel like I'm so close with what I had, but it's just out of my reach :(. Opaquer 16:15, 15 November 2012 (UTC)


 * It's gonna be a while before I can evaluate that, as I've got real-world things going on this couple of days. More later when I have time.  --Mental Mouse 21:22, 15 November 2012 (UTC)