From e56ff898ebb65e76f2111e98f54b0914550d2e06 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Thu, 3 Dec 2020 11:14:46 +0100 Subject: [PATCH] Use integer for y coordinate in Position --- .../us/myles/ViaVersion/api/minecraft/Position.java | 12 +++++++++--- .../type/types/minecraft/OptPosition1_14Type.java | 3 ++- .../api/type/types/minecraft/Position1_14Type.java | 2 +- .../protocol1_13to1_12_2/Protocol1_13To1_12_2.java | 2 +- .../protocol1_9to1_8/packets/WorldPackets.java | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/api/minecraft/Position.java b/common/src/main/java/us/myles/ViaVersion/api/minecraft/Position.java index c9498a147..9df1f9f7c 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/minecraft/Position.java +++ b/common/src/main/java/us/myles/ViaVersion/api/minecraft/Position.java @@ -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; } diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/OptPosition1_14Type.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/OptPosition1_14Type.java index 5b2fc945c..6c9c9aebb 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/OptPosition1_14Type.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/OptPosition1_14Type.java @@ -19,7 +19,8 @@ public class OptPosition1_14Type extends Type { @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); + } } } diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/Position1_14Type.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/Position1_14Type.java index 9014c7dc9..4e9872630 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/Position1_14Type.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/Position1_14Type.java @@ -17,7 +17,7 @@ public class Position1_14Type extends Type { 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 diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java index 18e687517..6b86d5970 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java @@ -61,7 +61,7 @@ public class Protocol1_13To1_12_2 extends Protocol { 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()); }; diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java index d700c8381..6c71ab29e 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java @@ -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: