gnembon / fabric-carpet

Fabric Carpet
MIT License
1.65k stars 261 forks source link

schedule() doesn't work correctly during a tick sprint #1859

Open Yadokingu opened 5 months ago

Yadokingu commented 5 months ago

Since the delay in schedule() is tick-based I would expect it to behave the same in a tick sprint as it does while the game runs at normal speed. It does not. I made a small script that switches to hotbar slot 7 when the player picks up an item, then uses that item (throws the splash potion) and then switches quickly to slot 8 (looting sword). At normal game speed that works perfectly fine, during a sprint the potion isn't thrown.

My code probably isn't great, but it's the best I could come up with after reading the documentation and I don't think it's the cause of the problem:

__on_player_picks_up_item(player, item) -> (

    modify(player(), 'selected_slot', 7);
    schedule(2, splashfarm1() -> run(str('player %s %s', player(), 'use once')));
    schedule(3, splashfarm2() -> modify(player(), 'selected_slot', 8));

);

Carpet 1.4.128+v231205 Minecraft 1.20.4

altrisi commented 5 months ago

I'd suspect this to not be related to schedule itself, but to running /player there.

Yadokingu commented 4 months ago

I'd suspect this to not be related to schedule itself, but to running /player there.

Quite possible. It is hard to tell what the problem is. Is there a different way to make a player use an item? I could not find anything in the documentation.