mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-25 19:45:21 +01:00
Use integer for y coordinate in Position
This commit is contained in:
parent
3aa35395f4
commit
e56ff898eb
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user