#Applying custom_data to a recipe

1 messages · Page 1 of 1 (latest)

jaunty thunder
#

How would I add multiple custom tags to my recipe? Im using misode but there is no option to create a list for it. (The dropdown box has string and object)

Here is the give command with the NBT
/give @p compass[max_stack_size=1,max_damage=5,item_name='{"text":"Magic Compass"}',damage=5,custom_model_data=41300,custom_data={magic_compass_type:"minceraft:overworld",magic_compass:"true"},enchantments={levels:{}},enchantment_glint_override=false,food={nutrition:0,saturation:0,can_always_eat:true,eat_seconds:2147483647},lodestone_tracker={target:{dimension:"minecraft:overworld",pos:[I;0,60,0]},tracked:false}]

vestal chasmBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 After a while, hit the Summon Helpers button to ping the helper team. They'll be happy to help you

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

calm loom
#

You have to do it manually

#

For example: "minecraft:custom_data":{"some_key":12}

jaunty thunder
#

so i would just put this in the string: {magic_compass_type:"minceraft:overworld",magic_compass:"true"}

calm loom
#

Have you ever worked with JSON before?

jaunty thunder
#

a good bit, just very confused with the components thing

calm loom
#

{"magic_compass_type":"minceraft:overworld","magic_compass":true}

#

you spelt it minceraft in that btw

jaunty thunder
#

when i run the give command it automatically removes the "" in game

jaunty thunder
calm loom
jaunty thunder
#

thank you

calm loom
#

no problem, lmk if it works or not

jaunty thunder
#

how would I reference that in a predicate though? i cant seem to get the set_damage predicate to work

calm loom
#

Do you mean the loot table function?

#

this one

jaunty thunder
#

I meant the item modifier file

#
    {
      "function": "minecraft:set_damage",
      "damage": 1,
      "add": true,
      "conditions": [
        {
          "condition": "minecraft:match_tool",
          "predicate": {
            "items": [
              "minecraft:compass"
            ],
            "count": 1,
            "nbt": {} <-------- this is where it would go
          }
        }
      ]
    }
  ]
calm loom
#

Ah like that

jaunty thunder
#

i just cant seem to apply the damage even without the nbt specifications either

calm loom
#

Odd, neither can I

#

I've got no idea actually. When I run my own function to add damage, it just doesn't work

jaunty thunder
#

hmm

calm loom
#

Giving it works fine though

#

odd behaviour

#

lemme try some stuff rq

jaunty thunder
#

giving the item with damage in the nbt does

calm loom
#

OH i know

#

The damage is from 0 to 1

#

So like 0.5 would be half of it's full damage

jaunty thunder
#

i have add set to true though

#

and when i set it to 0.2 (1/5 the durability) it still didnt work

calm loom
#

It should be -0.2

#

Since it's default 1 and you want to change it to 0.8

jaunty thunder
#

lemme try that

#

nothing

#
    {
      "function": "minecraft:set_damage",
      "damage": -0.2,
      "add": true,
      "conditions": [
        {
          "condition": "minecraft:match_tool",
          "predicate": {
            "items": [
              "minecraft:compass"
            ],
            "count": 1
          }
        }
      ]
    }
  ]
calm loom
#

match_tool is only used for loot tables and checking what tool was used to break a block

#

I don't know the full context of what you are doing - if you know what slot it's gonna be in, you could check their held item (or any other slot) with entity_properties:```json
{
"function": "minecraft:set_damage",
"damage": -0.2,
"add": true,
"conditions": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"mainhand": {
"items": "minecraft:compass"
}
}
}
}
]
}

jaunty thunder
#

i need to have it to where when the player "eats" the compass it will remove the durability by 1 and teleport the player

calm loom
#

In that case, you can use the food component and an advancement to run a function when it's eaten

thick whaleBOT
#

Rightclick Detection Food

    >>> For this example, we will be using a stick for detection. For different items, replace `stick` with the id of your chosen item.

Note: You can use any item for this, but if it has existing right-click functionality (like placing a block), it will keep that.

This is the command to give you a stick with the custom food component (You can run this in the chat to test it, or put it in a function to trigger when you want):

give @s stick[minecraft:food={nutrition:0, saturation:0, can_always_eat:true, eat_seconds:999999999}]

click_food.json (located in your packs advancements folder)

{
  "criteria": {
    "requirement": {
      "trigger": "minecraft:using_item",
      "conditions": {
        "item": {
          "items": [
            "minecraft:stick"
          ]
        }
      }
    }
  },
  "rewards": {
    "function": "namespace:rightclick_run"
  }
}

rightclick_run.mcfunction (located in your packs functions folder)

# revokes the advancement from the player so it can be used again
advancement revoke @s only namespace:click_food

# announces the use of the item in chat, feel free to replace this with whatever
say I successfully used food component detection!
jaunty thunder
#

I'm aware of how to make food detection, i just need the damage part

#

im using durability to display usage

#

which has a max of five for this item

calm loom
#

In the advancement for the food detection you can just check if the item being used in using_item is your compass

#

And then only run the item modifier if it is (the function wouldnt get run anyway because the advancement checks the item before running the function)

jaunty thunder
#

So:

Advancement is granted,
advancement runs item modifiy entity @s magic_compass:apply_damage,
Advancement is revoked```
#

and the item modifier doesnt check for a tool?

calm loom
#

It's more like:

  1. Player Uses Compass,
  2. Advancement is granted if the compass is the right compass
  3. Adancement runs the item modifier
  4. Advancement is revoked
calm loom
jaunty thunder
#

okay

#

ill try that

calm loom
#

Your advancement should look like this```json
{
"criteria": {
"requirement": {
"trigger": "minecraft:using_item",
"conditions": {
"item": {
"items": [
"minecraft:compass"
],
"predicates": {
"minecraft:custom_data": {"whatever_key":12345}
}
}
}
}
},
"rewards": {
"function": "namespace:rightclick_run"
}
}

jaunty thunder
#

well that removes the need for the magic_compass custom nbt, i only need the type now so thats cool

calm loom
#

noice

jaunty thunder
#

so the damage still doesn't apply?

#

weirdly

calm loom
#

This modifier should work fine on it’s own. I tested it and it seemed fine for me```json
{
"function": "minecraft:set_damage",
"damage": -0.2,
"add": true
}

jaunty thunder
#

OOH i left the [] in the file

calm loom
#

That shouldn’t matter though

jaunty thunder
#

uhh

#

hmm

#

so its still not working

jaunty thunder
#

did you test the modifier on a compass?

calm loom
#

Yeah

#

If you run it manually in chat, does it work?

jaunty thunder
#

thats how i was testing it

calm loom
#

Hmm

#

I’ll try again in a sec

#

Doing this works: /item modify entity @s weapon.mainhand {function: "minecraft:set_damage", damage: -0.2, add: true}. I'm using an inline modifier to make it a lot easier to test, but it works the same

#

The give command I use is /give @s minecraft:compass[minecraft:max_damage=100,minecraft:max_stack_size=1]

jaunty thunder
#

can you try it with a max damage of 5

calm loom
#

That doesn't work hmm

#

It might be easier for you if you just set the max damage to a bigger number like 100 or 50. Since the only way to decrease the damage is through your datapack, it won't really matter

jaunty thunder
#

5 was more for an exact visual anyway

#

i set the max damage and its still not working?

#

oh wait i had to set damage to 0

#

also for some reason minecraft says applying -0.2 to 50 leaves you with 41?

calm loom
#

it’s probably better on 100

jaunty thunder
#

it did the same though

#

it left it on 81

calm loom
#

that’s just weird

jaunty thunder
#

so i changed it to -0.201 and that worked

calm loom
#

if it works, it works ig

jaunty thunder
#

yeah, might report that to bugs though

#

I got 5 dura to work

#

i used -0.201

calm loom
#

oh nice

#

that’s deffo a bug then

#

it probably tries to round it up

#

after getting 4.01 or whatever

tender sparrow
#

Didn’t read all of this but .2 out of 100 is not exactly 20 when it comes to durability, since 0 exists

#

So either set max damage to 99 to have 100 values or set the multiplier to 20/101

fiery dust
vestal chasmBOT
vestal chasmBOT
# vestal chasm
Question Closed

Your question, #1256270611244912650 (Applying custom_data to a recipe), was resolved!

Original Message

#1256270611244912650 message

Duration open

23h23m