NBT Delay not working?

Started by JustHaven on

Topic category: Help with modding (Java Edition)

Last seen on 21:46, 29. Dec 2022
Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
NBT Delay not working?

I have seen many posts about NBT delays, but none of them help me correctly because I'm trying to do this with a potion instead of a block. Basically, I have two potion effects. When you drink the potion for the first one, it'll show a screen overlay and a couple side effects like slowness. After a specified time, it'll remove the potion effect along with the side effects and give you the second potion effect. Here's the code:

if (Get (Event/target entity) data number NBT tag "timer") =/= 5000 do {
   repeat (5000) times do {
      (Set (Event/target entity) data number NBT tag "timer") to (Get (Event/target entity) data number NBT tag "timer") - 1
}
else if (Get (Event/target entity) data number NBT tag "timer") == 5000 do {
   Clear all potion effects of (Event/target entity)
   Add potion with level (1) for (99999) ticks ambient (true) particles (false) to (Event/target entity) type: (CUSTOM:Pot2)
)

{That's not the exact code, that is all in blocks. The typed code is probably much different. I'm just very neat and formatted it like code. Anyways..)

Of course, I change the 5000 with higher and lower values, however the delay is never longer than a millisecond. I also get these errors:

Block entity_nbt_num_get is not synced between client and server automatically, which means it may not work properly in some cases.
Block entity_nbt_num_get is not synced between client and server automatically, which means it may not work properly in some cases.
Block entity_nbt_num_set is not synced between client and server automatically, which means it may not work properly in some cases.
Block entity_nbt_num_get is not synced between client and server automatically, which means it may not work properly in some cases.

I've seen in one post that these warnings can just be ignored, but I thought it'd be best to include those as well.

Basically, I want the delay to be 5 seconds long, not 1 millisecond. Can someone help?

Last seen on 11:41, 19. Aug 2022
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Man, if ypu want the delay…
Tue, 08/09/2022 - 15:53

Man, if ypu want the delay to be 5 seconds the time in ticks are 100 ticks (1s = 20ticks).

I also have a similar problem that my number nbt tag is not detected

Last seen on 14:53, 23. Aug 2023
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
My mod has a very similar…
Thu, 08/03/2023 - 20:44

My mod has a very similar mechanic. 5 seconds long delay would be 100 ticks. I see that you overcomplicated things a bit on the procedure with repeat X times and stuff. If I got you right, you want a potion that removes itself after 5 seconds and gives the player another potion instead(my mod has a similar mechanic, so I know how to do this), then try this:

If ((Get (Event/target entity) data number NBT tag "timer") < (100))

(Don't pay attention at my potion effect name, put your potion effect there)
It should work(I hope the image shows up for you)