Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing BiomeParser118 and BlockParser118 #96

Open
wants to merge 1 commit into
base: nbt7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,28 @@ public void apply() {
int newLength = (int) Math.ceil(64D / bytesPerLong);
newBiomes = data == null || newLength != data.length ? new long[newLength] : data;

int index = 0;
for (int i = 0; i < newLength; i++) {
for (int i = 0; i < newLength - 1; i++) {
long l = 0L;
for (int j = 0; j < bytesPerLong; j++, index++) {
l += parsedIndexes[index];
for (int j = 0; j < bytesPerLong - 1; j++) {
l += parsedIndexes[(i + 1) * bytesPerLong - j - 1];
l <<= numberOfBits;
}
l += parsedIndexes[i * bytesPerLong];

newBiomes[i] = l;
}
{
int i = newLength - 1;
long l = 0L;
int jm = 64 - (newLength - 1) * bytesPerLong;
for (int j = 0; j < jm - 1; j++) {
l += parsedIndexes[i * bytesPerLong + jm - j - 1];
l <<= numberOfBits;
}
l += parsedIndexes[i * bytesPerLong];

newBiomes[newLength - 1] = l;
}
data = newBiomes;
applyToHandle(palette, data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ private void parseIndexes() {
int mask = (1 << numberOfBits) - 1;
int i = 0;
for (long l : data) {
for (int s = 0; s < shortsPerLong && i < 4096; s++) {
parsedIndexes[i++] = (short) (l & mask);
l >>= numberOfBits;
for (int s = 0; s < shortsPerLong && i < 4096; s++, i++) {
parsedIndexes[i] = (short) (l & mask);
l = l >> numberOfBits;
}
}
}
Expand Down Expand Up @@ -99,6 +99,9 @@ public int getSize() {
public void apply() {
// collect all used block states
Short[] usedBlockStates = new Short[palette.size()];
if (parsedIndexes == null) {
parseIndexes();
}
for (short b : parsedIndexes) {
usedBlockStates[b] = b;
}
Expand Down Expand Up @@ -140,19 +143,36 @@ public void apply() {

long[] newBlockStates;
int shortsPerLong = Math.floorDiv(64, numberOfBits);
int freePerLong = Math.floorMod(64, numberOfBits);
int newLength = (int) Math.ceil(4096D / shortsPerLong);
newBlockStates = data == null || newLength != data.length ? new long[newLength] : data;


int index = 0;
for (int i = 0; i < newLength; i++) {
long l = 0L;
for (int j = 0; j < shortsPerLong; j++, index++) {
l += parsedIndexes[index];
for (int i = 0; i < newLength - 1; i++) {
long l = 0;
for (int j = 0; j < shortsPerLong - 1; j++) {
l += parsedIndexes[(i + 1) * shortsPerLong - j - 1];
l <<= numberOfBits;
}
l += parsedIndexes[i * shortsPerLong];
if(newBlockStates[i] != l){
int g =4;
}
newBlockStates[i] = l;
}
{
int i = newLength - 1;
long l = 0L;
int jm = 4096 - (newLength - 1) * shortsPerLong;
for(int j = 0; j < jm - 1; j++){
l += parsedIndexes[i * shortsPerLong + jm - j - 1];
l <<= numberOfBits;
}
l += parsedIndexes[i * shortsPerLong];

newBlockStates[newLength - 1] = l;
}


data = newBlockStates;
applyToHandle(palette, data);
}
Expand Down