CraftTweaker

CraftTweaker

151M Downloads

.transformDamage() does not work as described

NosajDraw opened this issue ยท 18 comments

commented

Issue Description:

.transformDamage() does not work as described or expected.

What happens:

All items remain in the crafting grid, and the item transformed duplicates.

What you expected to happen:

The transformed item should take damage, everything else should vanish.

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

http://pastebin.com/sHhBCN5V

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

http://pastebin.com/VpxxH62E


Affected Versions:

  • Minecraft: 1.10.2
  • Forge: 12.18.3.2221
  • Crafttweaker: 1.10.2-3.0.30 (3.0.20)

Your most recent log file where the issue was present:

I already linked to the log file, not sure what you want here.

commented

Similar commands such as .reuse() don't seem to work properly either.

commented

OK did some playing around with RiverC's work around.

The work around kind of works, but what is important is the use of .anyDamage() first, not reuse of .transformDamage()

The work around works so long as ".anyDamage().tranformDamage()" is used. Caveats though are .anyDamage() does not work with the ore dictionary and the damaged items still visually (but not in reality) duplicates.

commented

I had brought up .reuse() before. One thing to consider that the minetweaker wiki does not address, but once you realize it's a script, it makes sense.

When you're taking an item, like this

val toolItem = <mod:tool>;

then you do

recipes.addShapeless(<mod:someitem>, [toolItem.transformDamage(),<mod:somerawmaterial>]);
recipes.addShapeless(<mod:someitem2>, [toolItem.transformDamage(),<mod:somerawmaterial2>]);

You're actually applying "transformDamage" to the toolItem multiple times. You might say, "but I specified it in the recipe", but that's not what is happening. You're making the recipe include the toolitem, and by the second recipe it includes a toolitem that has transformDamage() called on it twice! I don't know the specifics of the code, but I found this to remove the issue (hint: it seems that things like reuse(), transformdamage(), etc are not IDEMPOTENT)

val toolItem = <mod:tool>.anyDamage().transformDamage();
recipes.addShapeless(<mod:someitem>, [toolItem,<mod:somerawmaterial>]);
recipes.addShapeless(<mod:someitem2>, [toolItem,<mod:somerawmaterial2>]);

Once I did this, it properly damaged the tool, AND it was not duped.

I hope this assists you guys (and perhaps the developer.)

commented

OK I will give that a go, but what your describing seems to be a deeper bug still, my example code consists of one line, contains one example recipe lifted directly from the wiki itself and doesn't use variables, so the bug cannot (just) be about multiple calls

commented

yeah, I think it has to do with the type of object; itemStack types can have transformDamage, etc, but ingredients can't; oredict entries can be ingredients but are never itemStacks (recall the result can never be an oredict entry.) I ended up writing boilerplate to handle it - a good text editor is key.

commented

.transformDamage() works with oredictionary items, or at least does in the broken way discussed in the OP, if it should not, then again, perhaps that part of the underlying bug.

commented

the wiki isn't totally clear on that, but I expect the behavior to be undefined given I didn't see anything that addressed using .transformDamage, .reuse, .transformReplace, .noReturn, .return, .anyDamage, .withTag, .onlyWithTag, and so on, on oredictionary entries. All of the examples pertain to a variable created from an individual item (he uses picks and buckets.) Like I said I fooled around with it myself but ran into conflicts.

commented

Ok so, I've been out of the loop on this for a bit, so what is the current situation?

commented

no change

commented

There was a time when it worked, it may be worth testing in old versions until you can find the version where it broke, that would at least give you a much smaller scope of which could be broken.

commented

Further testing will be needed to work out why this issue is happening, and how other parts of the mod are affected by it. Once we have worked this out we can fix the issue.

commented

Ah, glad it's not just me. I thought it was odd that items started duplicating suddenly.

Is there a suggested workaround for now? I tried <betterwithmods:knife>.anyDamage().transformDamage(), but that still creates duplicate items on each craft. They're not ghost items either, but persist on world reloads.

commented

@WesCook Did you just put it like that on the recipe? I used the workaround mentioned above and all seems to work okay. Maybe try using that, edited for your item?

commented

I tried using it directly, as well as in the format described above. Both resulted in duplicated items however.

val damageKnife = <betterwithmods:knife>.anyDamage().transformDamage();
recipes.addShapeless(<betterwithmods:material:47>, [damageKnife, <ore:nuggetIron>]);
commented

I found a solution that worked unexpectedly. It seems for certain tools, they will already take damage when crafted with any item. Adding transformDamage() or reuse() simply duplicates them, but they work without that modifier.

This was true for the BetterWithMods knife, and HarvestCraft cookware.

For tools with durability, all you need to add is anyDamage() so they continue to work more than once.

commented

Even with the workaround, there seems no way to increase the taken damage:
val immSaw = immcraft:saw.anyDamage().transformDamage(); --> 1 Damage --> works
val immSaw = immcraft:saw.anyDamage().transformDamage(2);--> saw disappears
val immSaw = immcraft:saw.anyDamage().transformDamage().transformDamage(); --> saw duplicates but takes 2 damage

commented

I've had the same issue today (7/16/17) except using MC 1.10.2, Forge: 12.18.3.2185, and Crafttweaker: 1.10.2-3.0.26
I can also confirm everything Terpo said except while using vanilla shears.

commented

Fixed in later versions (aka 1.12)