Fix setting blocks in null sections

Dieser Commit ist enthalten in:
Jesse Boyd 2019-11-17 19:30:28 +00:00
Ursprung 868554367a
Commit e661652c12
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
5 geänderte Dateien mit 22 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -227,7 +227,7 @@ public final class BukkitAdapter_1_14 {
for (; i < 4096; i++) { for (; i < 4096; i++) {
char ordinal = set[i]; char ordinal = set[i];
switch (ordinal) { switch (ordinal) {
case 0: case BlockID.__RESERVED__:
break outer; break outer;
case BlockID.AIR: case BlockID.AIR:
case BlockID.CAVE_AIR: case BlockID.CAVE_AIR:
@ -247,14 +247,17 @@ public final class BukkitAdapter_1_14 {
for (; i < 4096; i++) { for (; i < 4096; i++) {
char ordinal = set[i]; char ordinal = set[i];
switch (ordinal) { switch (ordinal) {
case 0: case BlockID.__RESERVED__:
ordinal = getArr[i]; ordinal = getArr[i];
set[i] = ordinal;
switch (ordinal) { switch (ordinal) {
case BlockID.__RESERVED__:
ordinal = BlockID.AIR;
case BlockID.AIR: case BlockID.AIR:
case BlockID.CAVE_AIR: case BlockID.CAVE_AIR:
case BlockID.VOID_AIR: case BlockID.VOID_AIR:
air++; air++;
default:
set[i] = ordinal;
} }
break; break;
case BlockID.AIR: case BlockID.AIR:

Datei anzeigen

@ -38,6 +38,7 @@ import java.util.concurrent.Future;
import java.util.function.Function; import java.util.function.Function;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.minecraft.server.v1_14_R1.BiomeBase; import net.minecraft.server.v1_14_R1.BiomeBase;
import net.minecraft.server.v1_14_R1.Block;
import net.minecraft.server.v1_14_R1.BlockPosition; import net.minecraft.server.v1_14_R1.BlockPosition;
import net.minecraft.server.v1_14_R1.Chunk; import net.minecraft.server.v1_14_R1.Chunk;
import net.minecraft.server.v1_14_R1.ChunkSection; import net.minecraft.server.v1_14_R1.ChunkSection;
@ -564,17 +565,20 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
return data; return data;
} }
char[] paletteToBlockChars = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get(); char[] paletteToOrdinal = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get();
try { try {
final int size = num_palette; if (num_palette != 1) {
if (size != 1) { for (int i = 0; i < num_palette; i++) {
for (int i = 0; i < size; i++) {
char ordinal = ordinal(palette.a(i), adapter); char ordinal = ordinal(palette.a(i), adapter);
paletteToBlockChars[i] = ordinal; paletteToOrdinal[i] = ordinal;
} }
for (int i = 0; i < 4096; i++) { for (int i = 0; i < 4096; i++) {
char paletteVal = data[i]; char paletteVal = data[i];
char val = paletteToBlockChars[paletteVal]; char val = paletteToOrdinal[paletteVal];
if (val == Character.MAX_VALUE) {
val = ordinal(palette.a(i), adapter);
paletteToOrdinal[i] = val;
}
data[i] = val; data[i] = val;
} }
} else { } else {
@ -583,14 +587,14 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
} }
} finally { } finally {
for (int i = 0; i < num_palette; i++) { for (int i = 0; i < num_palette; i++) {
paletteToBlockChars[i] = Character.MAX_VALUE; paletteToOrdinal[i] = Character.MAX_VALUE;
} }
} }
return data;
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return data;
} }
} }

Datei anzeigen

@ -304,7 +304,7 @@ public class Fawe {
br.close(); br.close();
this.version = FaweVersion.tryParse(versionString, commitString, dateString); this.version = FaweVersion.tryParse(versionString, commitString, dateString);
Settings.IMP.DATE = new Date(100 + version.year, version.month, version.day).toGMTString(); Settings.IMP.DATE = new Date(100 + version.year, version.month, version.day).toGMTString();
Settings.IMP.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit-Breaking/" + version.build; Settings.IMP.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit-commanding-pipeline/" + version.build;
Settings.IMP.COMMIT = "https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/commit/" + Integer.toHexString(version.hash); Settings.IMP.COMMIT = "https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/commit/" + Integer.toHexString(version.hash);
} catch (Throwable ignore) {} } catch (Throwable ignore) {}
try { try {

Datei anzeigen

@ -64,8 +64,6 @@ public interface IBlocks extends Trimable {
for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) { for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
if (!this.hasSection(layer) || (bitMask & (1 << layer)) == 0) continue; if (!this.hasSection(layer) || (bitMask & (1 << layer)) == 0) continue;
System.out.println("Write section " + layer);
char[] ids = this.load(layer); char[] ids = this.load(layer);
int nonEmpty = 0; // TODO optimize into same loop as toPalette int nonEmpty = 0; // TODO optimize into same loop as toPalette

Datei anzeigen

@ -20,6 +20,9 @@ public abstract class CharBlocks implements IBlocks {
char[] arr = blocks.blocks[layer]; char[] arr = blocks.blocks[layer];
if (arr == null) { if (arr == null) {
arr = blocks.blocks[layer] = blocks.update(layer, null); arr = blocks.blocks[layer] = blocks.update(layer, null);
if (arr == null) {
throw new IllegalStateException("Array cannot be null: " + blocks.getClass());
}
} else { } else {
blocks.blocks[layer] = blocks.update(layer, arr); blocks.blocks[layer] = blocks.update(layer, arr);
} }