This commit is contained in:
dordsor21
2023-07-05 22:03:13 +01:00
parent 67fd31ce4c
commit a669be2041
5 changed files with 34 additions and 17 deletions

View File

@ -30,8 +30,7 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl {
ordinal = BlockTypesCache.ReservedIDs.AIR;
nonAir--;
}
case BlockTypesCache.ReservedIDs.AIR, BlockTypesCache.ReservedIDs.CAVE_AIR, BlockTypesCache.ReservedIDs.VOID_AIR ->
nonAir--;
case BlockTypesCache.ReservedIDs.AIR, BlockTypesCache.ReservedIDs.CAVE_AIR, BlockTypesCache.ReservedIDs.VOID_AIR -> nonAir--;
}
int palette = blockToPalette[ordinal];
if (palette == Integer.MAX_VALUE) {
@ -74,8 +73,6 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl {
CachedBukkitAdapter adapter,
short[] nonEmptyBlockCount
) {
// Write to new array to avoid editing SET array
char[] copy = new char[set.length];
short nonAir = 4096;
int num_palette = 0;
char[] getArr = null;
@ -86,19 +83,23 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl {
if (getArr == null) {
getArr = get.apply(layer);
}
switch (ordinal = getArr[i]) {
// write to set array as this should be a copied array, and will be important when the changes are written
// to the GET chunk cached by FAWE. Future dords, actually read this comment please.
set[i] = switch (ordinal = getArr[i]) {
case BlockTypesCache.ReservedIDs.__RESERVED__ -> {
nonAir--;
ordinal = BlockTypesCache.ReservedIDs.AIR;
yield (ordinal = BlockTypesCache.ReservedIDs.AIR);
}
case BlockTypesCache.ReservedIDs.AIR, BlockTypesCache.ReservedIDs.CAVE_AIR, BlockTypesCache.ReservedIDs.VOID_AIR ->
nonAir--;
}
case BlockTypesCache.ReservedIDs.AIR, BlockTypesCache.ReservedIDs.CAVE_AIR,
BlockTypesCache.ReservedIDs.VOID_AIR -> {
nonAir--;
yield ordinal;
}
default -> ordinal;
};
}
case BlockTypesCache.ReservedIDs.AIR, BlockTypesCache.ReservedIDs.CAVE_AIR, BlockTypesCache.ReservedIDs.VOID_AIR ->
nonAir--;
case BlockTypesCache.ReservedIDs.AIR, BlockTypesCache.ReservedIDs.CAVE_AIR, BlockTypesCache.ReservedIDs.VOID_AIR -> nonAir--;
}
copy[i] = ordinal;
int palette = blockToPalette[ordinal];
if (palette == Integer.MAX_VALUE) {
blockToPalette[ordinal] = num_palette;
@ -116,7 +117,7 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl {
System.arraycopy(adapter.getOrdinalToIbdID(), 0, blockToPalette, 0, adapter.getOrdinalToIbdID().length);
}
for (int i = 0; i < 4096; i++) {
char ordinal = copy[i];
char ordinal = set[i];
if (ordinal == BlockTypesCache.ReservedIDs.__RESERVED__) {
LOGGER.error("Empty (__RESERVED__) ordinal given where not expected, default to air.");
ordinal = BlockTypesCache.ReservedIDs.AIR;