Fix block meta issues 1.7.10 bukkit

Fixes #655
Closes #679 (duplicate)
This commit is contained in:
Jesse Boyd 2017-08-07 23:27:31 +10:00
parent 6744a59d08
commit 755103a558
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
2 changed files with 51 additions and 47 deletions

View File

@ -334,7 +334,7 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
NibbleArray currentDataArray = (NibbleArray) BukkitQueue17.fieldData.get(section);
boolean data = currentDataArray != null && newDataArray != null;
if (currentDataArray == null) {
byte compactData = (byte) section.getData(0, 0, 0);
int compactData = ((byte) BukkitQueue17.fieldCompactData.get(section)) & 0xFF;
if (compactData != 0 && newDataArray == null) {
newDataArray = new NibbleArray(new byte[2048], 4);
byte full = (byte) ((compactData << 4) + compactData);
@ -358,13 +358,13 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
int i2 = i << 1;
int i3 = i2 + 1;
byte val = newDataArray.a[i];
if (charArray[i3] != 0) {
if (charArray[i2] != 0) continue;
if (newIdArray[i3] != 0) {
if (newIdArray[i2] != 0) continue;
newDataArray.a[i] = (byte) (val & 240 | compactData);
continue;
}
if (charArray[i2] != 0) {
if (charArray[i3] != 0) continue;
if (newIdArray[i2] != 0) {
if (newIdArray[i3] != 0) continue;
newDataArray.a[i] = (byte) (val & 15 | (compactData) << 4);
continue;
}
@ -374,42 +374,45 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
section.setDataArray(null);
section.setDataArray(newDataArray);
}
} else if (newDataArray == null) {
for (int i = 0; i < currentDataArray.a.length; i++) {
int i2 = i << 1;
int i3 = i2 + 1;
byte val = currentDataArray.a[i];
if (newIdArray[i3] == 0) {
if (newIdArray[i2] != 0) currentDataArray.a[i] = (byte) (val & 240);
continue;
}
if (newIdArray[i2] == 0) {
if (newIdArray[i3] != 0) currentDataArray.a[i] = (byte) (val & 15);
continue;
}
currentDataArray.a[i] = 0;
}
}
int solid = 0;
if (currentIdArray == null) {
byte id = (byte) ((int) BukkitQueue17.fieldCompactId.get(section));
if (id != 0) {
solid = 4096;
for (int i = 0; i < 4096; i++) {
if (charArray[i] == 0) newIdArray[i] = id;
else if (newIdArray[i] == 0) solid--;
}
} else {
for (int i = 0; i < 4096; i++) if (newIdArray[i] != 0) solid++;
}
if (currentIdArray == null && newIdArray != null) {
int id = (int) BukkitQueue17.fieldCompactId.get(section);
if (id == 0) {
section.setIdArray(null);
section.setIdArray(newIdArray);
getParent().setCount(0, count - this.getAir(j), section);
continue;
} else {
currentIdArray = section.getIdArray();
for (int i = 0; i < 4096; i++) {
if (charArray[i] != 0) currentIdArray[i] = newIdArray[i];
}
for (int i = 0; i < 4096; i++) if (currentIdArray[i] != 0) solid++;
}
int nonEmptyBlockCount = 0;
for (int k = 0; k < newIdArray.length; k++) {
char combined = charArray[k];
switch (combined) {
case 0:
continue;
case 1: {
byte existing = currentIdArray[k];
if (existing != 0) {
currentIdArray[k] = 0;
nonEmptyBlockCount--;
}
continue;
}
default:
byte existing = currentIdArray[k];
if (existing != 0) {
// TODO unlight
} else {
nonEmptyBlockCount++;
}
currentIdArray[k] = newIdArray[k];
if (data) {
int dataByte = FaweCache.getData(combined);
for (int k = 0; k < 4096; k++) {
int dataByte = FaweCache.getData(charArray[k]);
int kShift = k >> 1;
if ((k & 1) == 0) {
currentDataArray.a[kShift] = (byte) (currentDataArray.a[kShift] & 240 | dataByte);
@ -417,10 +420,8 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
currentDataArray.a[kShift] = (byte) (currentDataArray.a[kShift] & 15 | (dataByte) << 4);
}
}
continue;
}
}
getParent().setCount(0, getParent().getNonEmptyBlockCount(section) + nonEmptyBlockCount, section);
getParent().setCount(0, solid, section);
}
// Set biomes

View File

@ -70,6 +70,7 @@ public class BukkitQueue17 extends BukkitQueue_0<net.minecraft.server.v1_7_R4.Ch
protected static Field fieldData;
protected static Field fieldIds;
protected static Field fieldCompactId;
protected static Field fieldCompactData;
protected static Field fieldTickingBlockCount;
protected static Field fieldNonEmptyBlockCount;
protected static Field fieldBiomes;
@ -91,6 +92,8 @@ public class BukkitQueue17 extends BukkitQueue_0<net.minecraft.server.v1_7_R4.Ch
fieldIds.setAccessible(true);
fieldCompactId = ChunkSection.class.getDeclaredField("compactId");
fieldCompactId.setAccessible(true);
fieldCompactData = ChunkSection.class.getDeclaredField("compactData");
fieldCompactData.setAccessible(true);
fieldTickingBlockCount = ChunkSection.class.getDeclaredField("tickingBlockCount");
fieldNonEmptyBlockCount = ChunkSection.class.getDeclaredField("nonEmptyBlockCount");
fieldTickingBlockCount.setAccessible(true);