Use integer for y coordinate in Position

This commit is contained in:
KennyTV 2020-12-03 11:14:46 +01:00
parent 3aa35395f4
commit e56ff898eb
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
5 changed files with 14 additions and 7 deletions

View File

@ -2,9 +2,15 @@ package us.myles.ViaVersion.api.minecraft;
public class Position {
private final int x;
private final short y;
private final int y;
private final int z;
public Position(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public Position(int x, short y, int z) {
this.x = x;
this.y = y;
@ -23,7 +29,7 @@ public class Position {
return x;
}
public short getY() {
public int getY() {
return y;
}
@ -44,7 +50,7 @@ public class Position {
@Override
public int hashCode() {
int result = x;
result = 31 * result + (int) y;
result = 31 * result + y;
result = 31 * result + z;
return result;
}

View File

@ -19,7 +19,8 @@ public class OptPosition1_14Type extends Type<Position> {
@Override
public void write(ByteBuf buffer, Position object) throws Exception {
buffer.writeBoolean(object != null);
if (object != null)
if (object != null) {
Type.POSITION1_14.write(buffer, object);
}
}
}

View File

@ -17,7 +17,7 @@ public class Position1_14Type extends Type<Position> {
long y = val << 52 >> 52;
long z = val << 26 >> 38;
return new Position((int) x, (short) y, (int) z);
return new Position((int) x, (int) y, (int) z);
}
@Override

View File

@ -61,7 +61,7 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
public static final PacketHandler POS_TO_3_INT = wrapper -> {
Position position = wrapper.read(Type.POSITION);
wrapper.write(Type.INT, position.getX());
wrapper.write(Type.INT, (int) position.getY());
wrapper.write(Type.INT, position.getY());
wrapper.write(Type.INT, position.getZ());
};

View File

@ -343,7 +343,7 @@ public class WorldPackets {
return;
Position p = wrapper.get(Type.POSITION, 0);
int x = p.getX();
short y = p.getY();
int y = p.getY();
int z = p.getZ();
switch (face) {
case 0: