Upload files to "src/openonyx/movement"
This commit is contained in:
1 parent
6628e46ab4
commit
fea7f8008d
5 files changed
+240
No files matched your search
@@ -0,0 +1,98 @@
|
||||
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<SimulatedTickState> 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<SimulatedTickState> 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<SimulatedTickState> 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<SimulatedTickState> L() {
|
||||
return new PredictionTrackCallback2(this);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user