CustomCrafting icon indicating copy to clipboard operation
CustomCrafting copied to clipboard

Be able to transfer ExecutableItems variables to another item sharing the same variable name.

Open ASlipperySlope opened this issue 3 years ago • 3 comments

The Problem

Imagine a diamond pickaxe that keeps track of the amount of stone you mined with a pickaxe. Every stone block you mine increases the variable by 1. I now want to use this diamond pickaxe to craft a better one, for instance, a netherite pickaxe. This netherite pickaxe would also be an ExecutableItems item, having the exact same variable. Crafting this however would reset the variable to 0.

Solution

Have the result item grab the variables from the input item, and apply it to the result item if the item in question has this variable.

Alternatives

There are no alternatives.

Additional Context

When editing an item, the first screen displays a book & quill item that reads Variables. In here, you can modify the variables the specific item will use. Using activators, these variables can be modified based on what the activator does.

Submit issue

  • [X] searched for and ensured there isn't already an open issue regarding this,
  • [X] are running the latest version of your server software (Spigot, Paper, etc.), and plugins (WolfyUtilities, CustomCrafting).

ASlipperySlope avatar Nov 23 '22 17:11 ASlipperySlope

I assume these variables are saved in the NBT of the item, right? If that is the case you could use the Result Target and the NBTMergeAdapter and copy the variable to the result item NBT.

I should be able to assist you with creating the NBTQuery for the variable, if you post the NBT of the item.

You can get the NBt of the item via /data get entity @s SelectedItem (Preferably via console, so that you can copy the output.)

WolfyScript avatar Nov 23 '22 17:11 WolfyScript

The variable values are indeed stored in NBT, under the PublicBukkitValues NBT.

https://pastebin.com/av7vnR8v The NBT values I need are score:score-oresmined, score:score-stonemined and score:score-obsdianmined

ASlipperySlope avatar Nov 23 '22 18:11 ASlipperySlope

ok so, adding this target to the result of the recipe (via the config), should take the variables from the ingredient in the specified slot and put them into the result item.

"target": {
    "mergeOptions" : [ {
      "slots" : [ 0 ],
      "adapters" : [ {
        "key" : "customcrafting:nbt/merge",
        "query": {
          "PublicBukkitValues": {
            "type": "compound",
            "score:score-stonemined": true,
            "score:score-oresmined": true,
            "score:score-obsidianmined": true
          }
        }
      } ]
    } ]
  }

The slot in slots is the position of the ingredient in the recipe, and you need to modify it if your item is in the second slot or something.

WolfyScript avatar Nov 23 '22 20:11 WolfyScript