diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/listeners/CommandBlockListener.java b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/listeners/CommandBlockListener.java index 35db915bc..f6a6911ab 100644 --- a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/listeners/CommandBlockListener.java +++ b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/listeners/CommandBlockListener.java @@ -122,11 +122,15 @@ public class CommandBlockListener implements Listener { private long[] getPosition(Object obj) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException { return new long[]{ (long) ReflectionUtil.getSuper(obj, "a", int.class), //X - (long) ReflectionUtil.getSuper(obj, "c", int.class), //Y - (long) ReflectionUtil.getSuper(obj, "d", int.class) //Z + (long) ReflectionUtil.getSuper(obj, isR1() ? "b" : "c", int.class), //Y + (long) ReflectionUtil.getSuper(obj, isR1() ? "c" : "d", int.class) //Z }; } + private boolean isR1() { + return ReflectionUtil.getVersion().equals("v1_8_R1"); + } + private CompoundTag getNBT(Object obj) throws Exception { ByteBuf buf = Unpooled.buffer(); Method m = ReflectionUtil.nms("NBTCompressedStreamTools").getMethod("a", ReflectionUtil.nms("NBTTagCompound"), DataOutput.class); diff --git a/src/main/java/us/myles/ViaVersion/util/ReflectionUtil.java b/src/main/java/us/myles/ViaVersion/util/ReflectionUtil.java index 7b0c51a6e..9bc115a82 100644 --- a/src/main/java/us/myles/ViaVersion/util/ReflectionUtil.java +++ b/src/main/java/us/myles/ViaVersion/util/ReflectionUtil.java @@ -22,6 +22,10 @@ public class ReflectionUtil { return Class.forName(BASE + "." + className); } + public static String getVersion() { + return BASE.substring(BASE.lastIndexOf('.') + 1); + } + public static Object invokeStatic(Class clazz, String method) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Method m = clazz.getDeclaredMethod(method); return m.invoke(null);