package net.minecraft.gametest.framework;

import java.util.Iterator;
import java.util.List;

public class GameTestSequence {
    private final GameTestInfo parent;
    private final List<GameTestEvent> events;
    private long lastTick;
    
    public void tickAndContinue(final long long1) {
        try {
            this.tick(long1);
        }
        catch (Exception ex) {}
    }
    
    public void tickAndFailIfNotComplete(final long long1) {
        try {
            this.tick(long1);
        }
        catch (Exception exception4) {
            this.parent.fail(exception4);
        }
    }
    
    private void tick(final long long1) {
        final Iterator<GameTestEvent> iterator4 = this.events.iterator();
        while (iterator4.hasNext()) {
            final GameTestEvent kd5 = iterator4.next();
            kd5.assertion.run();
            iterator4.remove();
            final long long2 = long1 - this.lastTick;
            final long long3 = this.lastTick;
            this.lastTick = long1;
            if (kd5.expectedDelay != null && kd5.expectedDelay != long2) {
                this.parent.fail(new GameTestAssertException("Succeeded in invalid tick: expected " + (long3 + kd5.expectedDelay) + ", but current tick is " + long1));
                break;
            }
        }
    }
}
