Topic category: Help with Minecraft modding (Java Edition)
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?
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
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:
(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)