The EntityPositionTracker now returns copies of its values to prevent them from being changed

This commit is contained in:
CrushedPixel
2015-09-10 12:59:17 +02:00
parent da9ce46613
commit 20df12128b
2 changed files with 5 additions and 1 deletions

View File

@@ -71,6 +71,10 @@ public class AdvancedPosition extends Position {
this.roll = toApply.getRoll(); this.roll = toApply.getRoll();
} }
public AdvancedPosition copy() {
return new AdvancedPosition(x, y, z, pitch, yaw, roll);
}
@Override @Override
public AdvancedPosition newInstance() { public AdvancedPosition newInstance() {
return new AdvancedPosition(); return new AdvancedPosition();

View File

@@ -109,7 +109,7 @@ public class EntityPositionTracker {
for(Pair<Integer, AdvancedPosition> pair : positions) { for(Pair<Integer, AdvancedPosition> pair : positions) {
if(pair.getKey() <= timestamp) exists = true; if(pair.getKey() <= timestamp) exists = true;
if(pair.getKey() >= timestamp) { if(pair.getKey() >= timestamp) {
if(exists) return pair.getValue(); if(exists) return pair.getValue().copy();
return null; return null;
} }
} }