diff --git a/Spigot-Server-Patches/Anti-Xray.patch b/Spigot-Server-Patches/Anti-Xray.patch
index 2ce6dcd9e1..facbe05cd0 100644
--- a/Spigot-Server-Patches/Anti-Xray.patch
+++ b/Spigot-Server-Patches/Anti-Xray.patch
@@ -891,15 +891,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    }
 +
 +    public int read() {
-+        int value = (int) (current >>> bitInLongIndex) & mask;
-+        bitInLongIndex += bitsPerObject;
-+
-+        if (bitInLongIndex > 63) {
++        if (bitInLongIndex + bitsPerObject > 64) {
 +            bitInLongIndex = 0;
 +            longInDataBitsIndex += 8;
 +            init();
 +        }
 +
++        int value = (int) (current >>> bitInLongIndex) & mask;
++        bitInLongIndex += bitsPerObject;
 +        return value;
 +    }
 +}
@@ -965,24 +964,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    }
 +
 +    public void write(int value) {
-+        current = current & ~(mask << bitInLongIndex) | (value & mask) << bitInLongIndex;
-+        dirty = true;
-+        bitInLongIndex += bitsPerObject;
-+
-+        if (bitInLongIndex > 63) {
++        if (bitInLongIndex + bitsPerObject > 64) {
 +            finish();
 +            bitInLongIndex = 0;
 +            longInDataBitsIndex += 8;
 +            init();
 +        }
++
++        current = current & ~(mask << bitInLongIndex) | (value & mask) << bitInLongIndex;
++        dirty = true;
++        bitInLongIndex += bitsPerObject;
 +    }
 +
 +    public void skip() {
 +        bitInLongIndex += bitsPerObject;
 +
-+        if (bitInLongIndex > 63) {
++        if (bitInLongIndex > 64) {
 +            finish();
-+            bitInLongIndex = 0;
++            bitInLongIndex = bitsPerObject;
 +            longInDataBitsIndex += 8;
 +            init();
 +        }