Clamp
This commit is contained in:
@@ -184,7 +184,7 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
|
|
||||||
for(int i = e.len - 1; i >= 0; i--){
|
for(int i = e.len - 1; i >= 0; i--){
|
||||||
float nextpos = (i == e.len - 1 ? 100f : e.ys[i + 1]) - itemSpace;
|
float nextpos = (i == e.len - 1 ? 100f : e.ys[i + 1]) - itemSpace;
|
||||||
float maxmove = Math.min(nextpos - e.ys[i], speed * e.delta());
|
float maxmove = Mathf.clamp(nextpos - e.ys[i], 0, speed * e.delta());
|
||||||
|
|
||||||
e.ys[i] += maxmove;
|
e.ys[i] += maxmove;
|
||||||
|
|
||||||
@@ -362,16 +362,18 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream, byte revision) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream, revision);
|
||||||
len = Math.min(stream.readInt(), capacity);
|
len = stream.readInt();
|
||||||
|
|
||||||
for(int i = 0; i < len; i++){
|
for(int i = 0; i < len; i++){
|
||||||
int val = stream.readInt();
|
int val = stream.readInt();
|
||||||
byte id = (byte)(val >> 24);
|
byte id = (byte)(val >> 24);
|
||||||
float x = (float)((byte)(val >> 16)) / 127f;
|
float x = (float)((byte)(val >> 16)) / 127f;
|
||||||
float y = ((float)((byte)(val >> 8)) + 128f) / 255f;
|
float y = ((float)((byte)(val >> 8)) + 128f) / 255f;
|
||||||
ids[i] = content.item(id);
|
if(i < capacity){
|
||||||
xs[i] = x;
|
ids[i] = content.item(id);
|
||||||
ys[i] = i;
|
xs[i] = x;
|
||||||
|
ys[i] = y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user