CraftTweaker

CraftTweaker

151M Downloads

Make reuse a thing in 1.16

jaredlll08 opened this issue ยท 4 comments

commented

Feature request name
Make reuse a thing in 1.16

Feature request description

public static MCIngredientTransformed<IIngredient> transformReplace(IIngredient _this, IItemStack replaceWith) {

this but without the specified item

Feature request reason
Doing ```item:minecraft:glowstone.transformReplace(item:minecraft:glowstone)```` is stupid.

Feature request dependencies
Requires me to have more time and motivation

commented

No, transformReplace(IItemStack) and reuse() server different purposes!

<item:minecraft:iron_sword>.transformReplace(<item:minecraft:iron_sword>)

//is NOT the same as
<item:minecraft:iron_sword>.reuse()

Why not you ask?
The first one will always return a new iron sword without any tags
The second one will return exactly the sword that was inserted, including damage and tags

Think about it that way:
If you renamed your iron sword, it would still match, but after you performed the recipe, a new iron sword, without your custom name would lie in there.

commented

...could the IItemStack be made optional and default to whatever item stack is used at crafting, maybe somehow extracted from _this?

commented

Probably, I mean it would be the same as reuse would be at that point. The main reason I want reuse though is that it is easier for users to be like "I want this item to be reused, so I should use reuse", they may get confused like "replace with what? what is transforming, I just want the item to stay in the table".

It really is semantics to be honest, you could use use transformCustom to perform the same thing as well

commented

@jaredlll08 I meant in terms of implementation, so that you could then make the .reuse() method effectively call the .transformReplace() implementation without a replaceWith value. The methods in the scripts do vary, yes, but if the internal implementation is similar enough, then maybe just a parameter check to default the replacement to the thing being replaced would allow you to not need to write up a whole new method to do it. Which should save on the motivation and time needed to make it happen, right?

The core functionality, as I understand it, is "remove this item and put that one in its place" - but that particular functionality doesn't care what either item is, does it? So .reuse() calls that piece with the same item for both values ("replace $A with $A") and .transformReplace() calls it with different ones ("replace $A with $B") instead.

Bottom line, I saw the "dependencies" bit and hoped I could help make it take less time and motivation.