CraftTweaker

CraftTweaker

151M Downloads

[1.12.2] onlyDamageAtMost functions incorrectly

ASpieler opened this issue ยท 5 comments

commented

Issue Description:

the .onlyDamageAtMost() item condition does not function properly, regardless of what value is given, it seems to function as though "0" was given, so only undamaged items are deemed valid inputs

What happens:

when attempting to filter crafting recipe input using .onlyDamageAtMost(), only undamaged items are registered as having been below the set damage value

What you expected to happen:

.onlyDamageAtMost() to filter items properly, and allow partially damaged item to be used in a crafting recipe

Script used (Please Pastebin or gist your script, posting an unpasted or ungist'd script will automatically close this issue):

val pick = <minecraft:iron_pickaxe>; recipes.addShaped("picktest",<minecraft:cobblestone>,[[pick.onlyDamageAtMost(pick.maxDamage - 16).transformDamage(16),<minecraft:stone>],[null,null]],null,null);

crafttweaker.log file (Please Pastebin or gist your file, posting an unpasted or ungist'd file will automatically close this issue):

https://gist.github.com/ASpieler/6dfabdd5304b1de73843b7058baada17


Affected Versions (Do not use "latest"):

  • Minecraft:1.12.2
  • Forge:14.23.5.2836
  • Crafttweaker: 4.1.17/4.1.19
  • Using a server: no
commented

Having just stumbled across this myself and beating my head against a wall for hours, I too would have appreciated this being left as a side note in the pick repair example here: https://docs.blamejared.com/1.12/en/#Vanilla/Recipes/Crafting/Recipe_Functions/#example-for-repairing-a-pickaxe

commented

as a side note, I tested this having removed the calculation from the recipe as well, just to make sure that was not the issue
pick.onlyDamageAtMost(50).transformDamage(16)

it still doesn't work with anything but a fully repaired pick

commented

just looked back at the minecraft log and noticed a note saying that forge was out of date, and that 4.1.19 was built against 14.23.5.2838, so I updated, no change in results, still cannot use an item with even a single point of durability missing as a crafting ingredient.

commented

IIngredientConditions work a little differently than you expect:
They do not modify what ingredients match but restrict it further.

You are effectively using <minecraft:iron_pickaxe>.onlyDamageAtMost(50).transformDamage(16)

So, whenever a conditioned ingredient is found, CraftTweaker will first check if the base ingredient matches, so in other words if
<minecraft:iron_pickaxe> would match.

Only if that is the case then the other conditions are checked.
<minecraft:iron_pickaxe> is a shorthand for <minecraft:iron_pickaxe:0> which means it only matcches for items with 0 damage.

So what the line above states is

This ingredient is an iron pick with 0 damage.
It may at most have 50 Damage.
Once you craft it, add 16 damage to it.

That is the order they are checked in, so of course it only works with a fully repaired pickaxe, as that's the directions given to the ingredient.
You can use <minecraft:iron_pickaxe:*> which should make it work as you want to.

commented

Thank you for the explanation, now, to avoid future confusion, you might want to update the documentation to include that tidbit, as it is not currently clear.