Implement level rewards

This commit is contained in:
Melledy
2025-11-07 06:23:42 -08:00
parent b08ad1b7a1
commit 86b2933aa1
6 changed files with 153 additions and 7 deletions

View File

@@ -39,6 +39,19 @@ public class Bitset {
this.data[longArrayOffset] |= (1L << bytePosition);
}
public void unsetBit(int index) {
int longArrayOffset = (int) Math.floor((index - 1) / 64D);
int bytePosition = ((index - 1) % 64);
if (longArrayOffset >= this.data.length) {
var oldData = this.data;
this.data = new long[longArrayOffset + 1];
System.arraycopy(oldData, 0, this.data, 0, oldData.length);
}
this.data[longArrayOffset] &= (1L << bytePosition);
}
public byte[] toByteArray() {
byte[] array = new byte[this.getData().length * 8];
@@ -53,4 +66,19 @@ public class Bitset {
return array;
}
public byte[] toBigEndianByteArray() {
byte[] array = new byte[this.getData().length * 8];
for (int i = 0; i < this.getData().length; i++) {
long value = this.getData()[i];
for (int x = 0; x <= 7; x++) {
array[(i * 8) + x] = (byte) (value & 0xFF);
value >>= Byte.SIZE;
}
}
return array;
}
}