From f6227a0fc9a5879410a1de5c58206fc233581834 Mon Sep 17 00:00:00 2001 From: stonar96 Date: Sat, 27 Jun 2020 04:27:03 +0200 Subject: [PATCH] Fix Anti-Xray --- Spigot-Server-Patches/0372-Anti-Xray.patch | 44 +++++++++------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/Spigot-Server-Patches/0372-Anti-Xray.patch b/Spigot-Server-Patches/0372-Anti-Xray.patch index 35e3bced8e..0e6bb715a4 100644 --- a/Spigot-Server-Patches/0372-Anti-Xray.patch +++ b/Spigot-Server-Patches/0372-Anti-Xray.patch @@ -847,10 +847,10 @@ index 0000000000000000000000000000000000000000..e61421d87a19bf2f6ce8836b48c445ff +} diff --git a/src/main/java/com/destroystokyo/paper/antixray/DataBitsReader.java b/src/main/java/com/destroystokyo/paper/antixray/DataBitsReader.java new file mode 100644 -index 0000000000000000000000000000000000000000..c5a7b186e96901d55680283500f423025ededbe8 +index 0000000000000000000000000000000000000000..298ea423084dbcc1b61f991bcd82b8ae51bf0977 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/DataBitsReader.java -@@ -0,0 +1,56 @@ +@@ -0,0 +1,51 @@ +package com.destroystokyo.paper.antixray; + +public final class DataBitsReader { @@ -891,28 +891,23 @@ index 0000000000000000000000000000000000000000..c5a7b186e96901d55680283500f42302 + } + + public int read() { -+ int value = (int) (current >>> bitInLongIndex) & mask; -+ bitInLongIndex += bitsPerObject; -+ -+ if (bitInLongIndex > 63) { -+ bitInLongIndex -= 64; ++ if (bitInLongIndex + bitsPerObject > 64) { ++ bitInLongIndex = 0; + longInDataBitsIndex += 8; + init(); -+ -+ if (bitInLongIndex > 0) { -+ value |= current << bitsPerObject - bitInLongIndex & mask; -+ } + } + ++ int value = (int) (current >>> bitInLongIndex) & mask; ++ bitInLongIndex += bitsPerObject; + return value; + } +} diff --git a/src/main/java/com/destroystokyo/paper/antixray/DataBitsWriter.java b/src/main/java/com/destroystokyo/paper/antixray/DataBitsWriter.java new file mode 100644 -index 0000000000000000000000000000000000000000..2eff19f6aaa31245f80910c6fbb541e32c672a31 +index 0000000000000000000000000000000000000000..333763936897befda5bb6c077944d2667f922799 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/DataBitsWriter.java -@@ -0,0 +1,84 @@ +@@ -0,0 +1,79 @@ +package com.destroystokyo.paper.antixray; + +public final class DataBitsWriter { @@ -969,29 +964,24 @@ index 0000000000000000000000000000000000000000..2eff19f6aaa31245f80910c6fbb541e3 + } + + public void write(int value) { ++ if (bitInLongIndex + bitsPerObject > 64) { ++ finish(); ++ bitInLongIndex = 0; ++ longInDataBitsIndex += 8; ++ init(); ++ } ++ + current = current & ~(mask << bitInLongIndex) | (value & mask) << bitInLongIndex; + dirty = true; + bitInLongIndex += bitsPerObject; -+ -+ if (bitInLongIndex > 63) { -+ finish(); -+ bitInLongIndex -= 64; -+ longInDataBitsIndex += 8; -+ init(); -+ -+ if (bitInLongIndex > 0) { -+ current = current & ~(mask >>> bitsPerObject - bitInLongIndex) | (value & mask) >>> bitsPerObject - bitInLongIndex; -+ dirty = true; -+ } -+ } + } + + public void skip() { + bitInLongIndex += bitsPerObject; + -+ if (bitInLongIndex > 63) { ++ if (bitInLongIndex > 64) { + finish(); -+ bitInLongIndex -= 64; ++ bitInLongIndex = bitsPerObject; + longInDataBitsIndex += 8; + init(); + }