3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-03 14:50:30 +01:00

Use integer for y coordinate in Position

Dieser Commit ist enthalten in:
KennyTV 2020-12-03 11:14:46 +01:00
Ursprung 3aa35395f4
Commit e56ff898eb
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
5 geänderte Dateien mit 14 neuen und 7 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -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 -> { public static final PacketHandler POS_TO_3_INT = wrapper -> {
Position position = wrapper.read(Type.POSITION); Position position = wrapper.read(Type.POSITION);
wrapper.write(Type.INT, position.getX()); 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()); wrapper.write(Type.INT, position.getZ());
}; };

Datei anzeigen

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