CraftTweaker

CraftTweaker

151M Downloads

Smithing recipe error

LILPRINCES opened this issue ยท 1 comments

commented

Issue description

I tried to use Smithing recipe to make a weapon upgrade function, the jei recipe shows correct but the actual situation is wrong.
001
002
003
004

Steps to reproduce

No response

Script used

https://pastebin.com/m6FV8Hfb

The crafttweaker.log file

https://pastebin.com/xYsuLMwc

Minecraft version

1.16

Modloader

Forge

Modloader version

36.2.2

CraftTweaker version

7.1.2.489

Other relevant information

No response

The latest.log file

https://pastebin.com/xYsuLMwc

commented

Smithing recipes use the original input to make the output, this means that it copies the NBT from the input to the output.

JEI shows the correct result because that is the base item that is being outputted, but because damage is done via NBT, it is transferred from the input item, to the output item when it is crafted, like so:

   public ItemStack getCraftingResult(IInventory inv) {
      ItemStack itemstack = this.result.copy(); // This gets the output that you wrote
      CompoundNBT compoundnbt = inv.getStackInSlot(0).getTag();
      if (compoundnbt != null) {
         itemstack.setTag(compoundnbt.copy()); // This sets the tag on the output to be the tag of the input, including the data.
      }

      return itemstack;
   }

Right now there isn't a solution for this, it is just how vanilla handles smithing recipes. I can maybe look into it in the future.