2

I have a function triggered by an advancement that is supposed to give the player nausea and strength. It looks like this:

tellraw @s [{"text":"[","color":"dark_aqua"},{"selector":"@s","color":"dark_aqua"},{"text":"] ","color":"dark_aqua"},{"text":"I feel ill...","color":"aqua"}]
effect give @s minecraft:nausea 30 3 true
effect give @s minecraft:strength 30 1 true
advancement revoke @s only dark_magic:hidden/drink_blood

This is triggered by the player drinking a retextured milk bucket (a blood-filled bucket), which works fine. The advancement which triggers the function is very simple and looks like this:

{
  "criteria": {
    "drink_blood": {
      "trigger": "minecraft:consume_item",
      "conditions": {
        "item": {
          "item": "minecraft:milk_bucket",
          "nbt": "{BloodBucket:1b,CustomModelData:1}"
        }
      }
    }
  },
  "rewards": {
    "function": "dark_magic:progression/story_dialogue/i_feel_ill"
  }
}

When I drink a milk bucket with the custom NBT tag BloodBucket:1b, it works: the /tellraw triggers, and the advancement is revoked, reseting everything so I can drink it again and it will still work. However, the /effect commands don't work. I can run the function manually from the chat, as in /function dark_magic:progression/story_dialogue/i_feel_ill, and the effects work fine, but when run by the advancement, they don't work at all.

Does anyone know why this is? Moreover, does anyone know how to get around this? I know I could tag the player as drank_blood or something and /schedule a function for 1 tick later which executes the effects as all players tagged with drank_blood and removes the tag, but that seems unnecessarily complicated for something as simple as giving an effect.

Am I doing something wrong with a selector or missing something simple, or is this just not possible and I'll need to do the /schedule method?

  • /schedule wouldn't even help you, because it ignores all context: bugs.mojang.com/browse/MC-154325 What happens if you execute the function manually? – Fabian Röling Aug 4 at 10:23
  • @FabianRöling If I run the function from chat, as myself, all four of the commands work as expected. From the advancement, the /tellraw and /advancement commands work, but the /effect ones don't. I knew that /schedule ignored any /execute instructions, but I didn't know that was unintended. I hope it gets fixed because it's pretty annoying. That is what the tag is for: to give context so it could be executed by the server and still work. – Nik3141 Aug 4 at 15:28
  • Can you make a download link for the datapack, please? That makes it easier to experiment with it, instead of having to recreate it completely. – Fabian Röling Aug 4 at 20:39
  • @FabianRöling Uh sure. I'll just put the problematic files and remove the others, because there's about 50 right now. Do you have a download site you recommend? – Nik3141 Aug 4 at 22:45
  • @FabianRöling Ok so the download is here. The advancement in question is data\dark_magic\advancements\hidden\drink_blood, while the function in question is at data\dark_magic\functions\progression\story_dialogue\i_feel_ill – Nik3141 Aug 4 at 22:55
1

A long search for the cause, a short and simple answer:

Functions that are rewards for an advancement triggered by the consume_item trigger are executed before the item does what it does. For example your function first gives its effects to you, THEN the milk bucket clears all effects and the empty bucket it put into its slot.

  • 1
    Ok. I'll probably just tag the player as having drank the bucket and schedule a function to give all players with that tag the effects one tick later and remove the tag. Thanks for the help! – Nik3141 Aug 5 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.