Fix Anti-Xray

This commit is contained in:
stonar96 2020-06-27 04:27:03 +02:00
parent 387571da58
commit f6227a0fc9

View file

@ -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();
+ }