From 81ffd52e9fe357728497c17f3f58fc20621da547 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Fri, 18 Aug 2017 15:05:38 +1000 Subject: [PATCH] Fixes #695 --- .../fawe/bukkit/v1_7/BukkitChunk_1_7.java | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java index 66b14af3..6749a1a9 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java @@ -306,13 +306,11 @@ public class BukkitChunk_1_7 extends CharFaweChunk { continue; } sections[j] = section = new ChunkSection(j << 4, flag); - section.setIdArray(null); - section.setIdArray(newIdArray); + BukkitQueue17.fieldCompactId.set(section, 0); + BukkitQueue17.fieldIds.set(section, newIdArray); getParent().setCount(0, count - this.getAir(j), section); - section.setDataArray(null); - if (newDataArray != null) { - section.setDataArray(newDataArray); - } + BukkitQueue17.fieldCompactData.set(section, (byte) 0); + BukkitQueue17.fieldData.set(section, newDataArray); continue; } if (count >= 4096) { @@ -320,13 +318,11 @@ public class BukkitChunk_1_7 extends CharFaweChunk { sections[j] = null; continue; } - section.setIdArray(null); - section.setIdArray(newIdArray); + BukkitQueue17.fieldCompactId.set(section, 0); + BukkitQueue17.fieldIds.set(section, newIdArray); getParent().setCount(0, count - this.getAir(j), section); - section.setDataArray(null); - if (newDataArray != null) { - section.setDataArray(newDataArray); - } + BukkitQueue17.fieldCompactData.set(section, (byte) 0); + BukkitQueue17.fieldData.set(section, newDataArray); continue; } char[] charArray = this.getIdArray(j); @@ -358,21 +354,21 @@ public class BukkitChunk_1_7 extends CharFaweChunk { int i2 = i << 1; int i3 = i2 + 1; byte val = newDataArray.a[i]; - if (newIdArray[i3] != 0) { - if (newIdArray[i2] != 0) continue; + if (charArray[i3] != 0) { + if (charArray[i2] != 0) continue; newDataArray.a[i] = (byte) (val & 240 | compactData); continue; } - if (newIdArray[i2] != 0) { - if (newIdArray[i3] != 0) continue; + if (charArray[i2] != 0) { + if (charArray[i3] != 0) continue; newDataArray.a[i] = (byte) (val & 15 | (compactData) << 4); continue; } newDataArray.a[i] = full; } } - section.setDataArray(null); - section.setDataArray(newDataArray); + BukkitQueue17.fieldCompactData.set(section, (byte) 0); + BukkitQueue17.fieldData.set(section, newDataArray); } } else if (newDataArray == null) { for (int i = 0; i < currentDataArray.a.length; i++) { @@ -402,8 +398,8 @@ public class BukkitChunk_1_7 extends CharFaweChunk { } else { for (int i = 0; i < 4096; i++) if (newIdArray[i] != 0) solid++; } - section.setIdArray(null); - section.setIdArray(newIdArray); + BukkitQueue17.fieldCompactId.set(section, 0); + BukkitQueue17.fieldIds.set(section, newIdArray); } else { for (int i = 0; i < 4096; i++) { if (charArray[i] != 0) currentIdArray[i] = newIdArray[i]; @@ -412,12 +408,15 @@ public class BukkitChunk_1_7 extends CharFaweChunk { } if (data) { 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); - } else { - currentDataArray.a[kShift] = (byte) (currentDataArray.a[kShift] & 15 | (dataByte) << 4); + int value = charArray[k]; + if (value != 0) { + int dataByte = FaweCache.getData(value); + int kShift = k >> 1; + if ((k & 1) == 0) { + currentDataArray.a[kShift] = (byte) (currentDataArray.a[kShift] & 240 | dataByte); + } else { + currentDataArray.a[kShift] = (byte) (currentDataArray.a[kShift] & 15 | (dataByte) << 4); + } } } }