package openonyx.movement; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.locks.ReentrantReadWriteLock; public class PredictionTrack { private final List simulatedTickStates = new ArrayList<>(); private final SimulatedPlayer simulatedPlayer; private final ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(); private int e; public SimulatedPlayer getSimulatedPlayer() { return this.simulatedPlayer; } public PredictionTrack(SimulatedPlayer simulatedPlayer) { this.simulatedPlayer = simulatedPlayerx; this.simulatedTickStates.add(new SimulatedTickState(simulatedPlayerx)); } public Iterator L(int i, int j) { if (j >= 1200) { throw new IllegalStateException("tried to simulate a player for more than a minute!"); } this.L(j + 1); return new PredictionTrackCallback(this, i, j); } // $VF: Could not inline inconsistent finally blocks // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!) public void L(int i) { if (i < 0) { throw new IllegalStateException("ticks may not be negative"); } if (this.e < i) { this.reentrantReadWriteLock.writeLock().lock(); try { while (this.e < i) { this.simulatedPlayer.L(); this.simulatedTickStates.add(new SimulatedTickState(this.simulatedPlayer)); this.e++; } } catch (Throwable throwable) { this.reentrantReadWriteLock.writeLock().unlock(); throw throwable; } this.reentrantReadWriteLock.writeLock().unlock(); } } // $VF: Could not inline inconsistent finally blocks // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!) public SimulatedTickState L(int i) { this.L(i); this.reentrantReadWriteLock.readLock().lock(); try { simulatedTickState = this.simulatedTickStates.get(i); } catch (Throwable throwable) { this.reentrantReadWriteLock.readLock().unlock(); throw throwable; } this.reentrantReadWriteLock.readLock().unlock(); return simulatedTickState; } // $VF: Could not inline inconsistent finally blocks // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!) public List L(int i, int j) { if (j >= 1200) { throw new IllegalStateException("tried to simulate a player for more than a minute!"); } this.L(j + 1); this.reentrantReadWriteLock.readLock().lock(); try { list = List.copyOf(this.simulatedTickStates.subList(i, j + 1)); } catch (Throwable throwable) { this.reentrantReadWriteLock.readLock().unlock(); throw throwable; } this.reentrantReadWriteLock.readLock().unlock(); return list; } public Iterator L() { return new PredictionTrackCallback2(this); } }