#Is the result of /query gametime cast to integer when storing the result to score ?

1 messages · Page 1 of 1 (latest)

copper lion
#

For one of my pack, I would like to have a delay after some action is performed. The delay has to be stored inside a storage for various reason. For now, I was planning to store the current gametime in a score, add the delay to it and store everything that I need into the storage.

Then, when needing the storage, check if stored time is greater than current gametime.

robust vault
#

Yes

jagged lynx
#

better use schedules for that than manually checking the time

robust vault
#

Or even a predicate/advancement

woeful hearth
#

There are plenty of reasons to not use schedule

jagged lynx
copper lion
#

Thing is that the subsequent event should not happen before specified time but can happen at anytime after that

jagged lynx
#

if it is something that can happen often, just add the check to the tick function. If not and it might be a more expensive check, naybe make a temporary shedule loop that only exists when it waits for the event to trigger and after that, it stops until someone starts it again.

copper lion
#

It is for my mailbox datapack. I'd like to implement a delay between when a player send a mail and when a player can retieve it. For now, I was planning to : when a player check their mailbox, drop all the mails that have their delay gone by checking their delivery time versus the current time

#

Apparently checking against current time is easy :

{
    "condition": "minecraft:time_check",
    "value": {
        "min": {
            "type": "minecraft:storage",
            "storage": "a",
            "path": "a"
        }
    }
}
jagged lynx
#

This predicate is all you need. And when you send the mails, you can simply get the current time, add your delay and store that.

copper lion
#

I still have a problem for when gametime goes past integer limit. How can I add a fixed/scoreboard value in this case ?

jagged lynx
#

You don't have to worry about that. To go over the integer limit you would have to be in the game world for litteral years.

copper lion
#

yep 3 years i know

#

Very unlikely but could happen on old servers if they have been running 24/7

jagged lynx
#

I'd say add an additional check that if the gametime is negative and mail arrival timestamp is above 1000000 the condition also resolves to true.

#

That would be the simplest way to handle this scenario

#

The worst thing that could happen with this is that if someone sends a mail 1 tick before the overflow, the recieving player immediately gets it but this will be a one time event every 3.5 years

copper lion
#

Problem is that as far as I can tell, any value bigger than max int is cast to max int and does not wrap around int limits. At least when trying to execute store score run data get 4000000000L

jagged lynx
#

But that's not a problem. If the game time is negative and the mail timestamp clamps to max int, it is still over 1000000 and that means it returns true (meaning it arrived) for the next ~2 years. That's what I mean with they get immediately delivered. Once the gametime is negative, all new timestamps are also negative and the sytstem works like before.

copper lion
#

Yep I get that but I don't think gametime can actually become negative

jagged lynx
#

it did overflow, last time I checked.

#

I'll check again if that changed

copper lion
#

in 1.20.6

jagged lynx
#

ok, yeah, don't worry about the limit

#

they use longs now

#

that's over 214 years to reach the limit

#

that won't happen

#

ever

woeful hearth
jagged lynx
#

We have very simple solutions for all of those things and sub tick ordering is rarely a problem in my experience

woeful hearth
jagged lynx
#

no, I mean for what you said we have sinple solutions. Their problem is already solved. I was not talking about that.

jagged lynx
#

Have read anything at all that came after this message?

#

We are way past that

woeful hearth
#

Im responding to your response to me

#

My point is you shouldn't have presumed that you knew their problem well enough to say they needed schedules

jagged lynx
#

This is not even worth arguing about.

woeful hearth
#

Kk