Durability Repair Script

Need help with your script? Want to know how to do something? Want to post an example? Post it here!

Durability Repair Script

Postby Paradisio » Sun Sep 21, 2014 5:58 am

So I've been working on a custom modpack, and one of the things I'm trying to add is some repair recipes.... and I haven't had any luck, sure I can spit a normal item out from a damaged one, but can someone give me any kind of an example on how to repair durability by a set amount?

For example, I want to put in a stone pickaxe of a damaged durability, combine it with a stone and durability heals by 10, stone is consumed. If I could figure this out I feel like I could overcome the other hurdles I am facing.

Appreciate any help!
Paradisio
 
Posts: 1
Joined: Sun Sep 21, 2014 5:56 am

Re: Durability Repair Script

Postby Stan » Mon Sep 22, 2014 7:08 am

Yes you can actually do that, with the (so far undocumented) recipe functions:

: [Select all] [/] [] ()
  1. recipes.addShapeless(<minecraft:stone_pickaxe>, [<minecraft:stone_pickaxe>.anyDamage().marked("pick"), <minecraft:cobblestone>], function (output, ingredients, crafting) {
  2.     // get the damage value from the input pick and repair it somewhat, then set that damage to the given item
  3.     return ingredients.pick.withDamage(max(0, ingredients.pick.damage - 10));
  4. });
  5.  
GeSHi © Codebox Plus


The marked modifier marks a specific ingredient with a name, and the function is then executed to determine what the output should be. Note that this would repair any kind of pick, including enchanted ones, without losing any of its enchantments or name. An alternative would be to return output.withDamage(max(0, ingredients.pick.damage - 10)); which would return a clean pick with the desired damage.
User avatar
Stan
Site Admin
 
Posts: 258
Joined: Fri Jul 11, 2014 9:04 pm

Re: Durability Repair Script

Postby mizaguquse » Mon Apr 15, 2019 11:35 am

.....
With use of latest version of script tool we can get best results of our works. Script users like to buy essay in uk online for submission of their projects. This tool is very good that provide best features for handling of all relevant tasks.
mizaguquse
 
Posts: 1
Joined: Mon Apr 15, 2019 11:26 am


Return to Scripting Help

Who is online

Users browsing this forum: Google [Bot] and 0 guests

cron