Skip to content

Instantly share code, notes, and snippets.

@kindlich
Last active January 14, 2019 13:51
Show Gist options
  • Save kindlich/a5000a60e4d4d4b53b4af419a7e13e81 to your computer and use it in GitHub Desktop.
Save kindlich/a5000a60e4d4d4b53b4af419a7e13e81 to your computer and use it in GitHub Desktop.
val craftingItem = <immersiveengineering:tool>.transformNew(function(item){
if(!item.hasTag){
return item.withTag({Damage: 1});
}
val tag = item.tag;
if(!(tag has "Damage")){
return item.withTag(tag + {Damage: 1});
}
val newDamage = tag.Damage.asInt() + 1;
if(damage > 250) {
//Tool breaks, so returns nothing
return null;
}
return item.updateTag(tag + {Damage: newDamage});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment