mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Set empty block count when using fastmode on 1.17 (#1710)
* Set empty block count when using fastmode on 1.17 Fixes #1666 * Update legacy adapters
This commit is contained in:
parent
f5ef0cadb6
commit
65349392a6
@ -303,11 +303,20 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
final int[] blocksCopy = FaweCache.INSTANCE.SECTION_BLOCKS.get();
|
final int[] blocksCopy = FaweCache.INSTANCE.SECTION_BLOCKS.get();
|
||||||
try {
|
try {
|
||||||
int num_palette;
|
int num_palette;
|
||||||
|
final short[] nonEmptyBlockCount = fastMode ? new short[1] : null;
|
||||||
if (get == null) {
|
if (get == null) {
|
||||||
num_palette = createPalette(blockToPalette, paletteToBlock, blocksCopy, set, adapter
|
num_palette = createPalette(blockToPalette, paletteToBlock, blocksCopy, set, adapter, nonEmptyBlockCount);
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
num_palette = createPalette(layer, blockToPalette, paletteToBlock, blocksCopy, get, set, adapter);
|
num_palette = createPalette(
|
||||||
|
layer,
|
||||||
|
blockToPalette,
|
||||||
|
paletteToBlock,
|
||||||
|
blocksCopy,
|
||||||
|
get,
|
||||||
|
set,
|
||||||
|
adapter,
|
||||||
|
nonEmptyBlockCount
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// BlockStates
|
// BlockStates
|
||||||
int bitsPerEntry = MathMan.log2nlz(num_palette - 1);
|
int bitsPerEntry = MathMan.log2nlz(num_palette - 1);
|
||||||
@ -377,6 +386,12 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
|
|
||||||
if (!fastMode) {
|
if (!fastMode) {
|
||||||
levelChunkSection.recalcBlockCounts();
|
levelChunkSection.recalcBlockCounts();
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
fieldNonEmptyBlockCount.set(levelChunkSection, nonEmptyBlockCount[0]);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return levelChunkSection;
|
return levelChunkSection;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
|
@ -341,9 +341,9 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
try {
|
try {
|
||||||
int num_palette;
|
int num_palette;
|
||||||
if (get == null) {
|
if (get == null) {
|
||||||
num_palette = createPalette(blockToPalette, paletteToBlock, blocksCopy, set, adapter);
|
num_palette = createPalette(blockToPalette, paletteToBlock, blocksCopy, set, adapter, null);
|
||||||
} else {
|
} else {
|
||||||
num_palette = createPalette(layer, blockToPalette, paletteToBlock, blocksCopy, get, set, adapter);
|
num_palette = createPalette(layer, blockToPalette, paletteToBlock, blocksCopy, get, set, adapter, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bitsPerEntry = MathMan.log2nlz(num_palette - 1);
|
int bitsPerEntry = MathMan.log2nlz(num_palette - 1);
|
||||||
|
@ -342,9 +342,9 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
try {
|
try {
|
||||||
int num_palette;
|
int num_palette;
|
||||||
if (get == null) {
|
if (get == null) {
|
||||||
num_palette = createPalette(blockToPalette, paletteToBlock, blocksCopy, set, adapter);
|
num_palette = createPalette(blockToPalette, paletteToBlock, blocksCopy, set, adapter, null);
|
||||||
} else {
|
} else {
|
||||||
num_palette = createPalette(layer, blockToPalette, paletteToBlock, blocksCopy, get, set, adapter);
|
num_palette = createPalette(layer, blockToPalette, paletteToBlock, blocksCopy, get, set, adapter, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bitsPerEntry = MathMan.log2nlz(num_palette - 1);
|
int bitsPerEntry = MathMan.log2nlz(num_palette - 1);
|
||||||
|
Binary file not shown.
@ -14,13 +14,19 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl {
|
|||||||
int[] paletteToBlock,
|
int[] paletteToBlock,
|
||||||
int[] blocksCopy,
|
int[] blocksCopy,
|
||||||
char[] set,
|
char[] set,
|
||||||
CachedBukkitAdapter adapter
|
CachedBukkitAdapter adapter,
|
||||||
|
short[] nonEmptyBlockCount
|
||||||
) {
|
) {
|
||||||
|
short nonAir = 4096;
|
||||||
int num_palette = 0;
|
int num_palette = 0;
|
||||||
for (int i = 0; i < 4096; i++) {
|
for (int i = 0; i < 4096; i++) {
|
||||||
char ordinal = set[i];
|
char ordinal = set[i];
|
||||||
if (ordinal == BlockTypesCache.ReservedIDs.__RESERVED__) {
|
switch (ordinal) {
|
||||||
|
case BlockTypesCache.ReservedIDs.__RESERVED__ -> {
|
||||||
ordinal = BlockTypesCache.ReservedIDs.AIR;
|
ordinal = BlockTypesCache.ReservedIDs.AIR;
|
||||||
|
nonAir--;
|
||||||
|
}
|
||||||
|
case BlockTypesCache.ReservedIDs.AIR, BlockTypesCache.ReservedIDs.CAVE_AIR, BlockTypesCache.ReservedIDs.VOID_AIR -> nonAir--;
|
||||||
}
|
}
|
||||||
int palette = blockToPalette[ordinal];
|
int palette = blockToPalette[ordinal];
|
||||||
if (palette == Integer.MAX_VALUE) {
|
if (palette == Integer.MAX_VALUE) {
|
||||||
@ -46,6 +52,10 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl {
|
|||||||
int palette = blockToPalette[ordinal];
|
int palette = blockToPalette[ordinal];
|
||||||
blocksCopy[i] = palette;
|
blocksCopy[i] = palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nonEmptyBlockCount != null) {
|
||||||
|
nonEmptyBlockCount[0] = nonAir;
|
||||||
|
}
|
||||||
return num_palette;
|
return num_palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,20 +66,29 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl {
|
|||||||
int[] blocksCopy,
|
int[] blocksCopy,
|
||||||
Function<Integer, char[]> get,
|
Function<Integer, char[]> get,
|
||||||
char[] set,
|
char[] set,
|
||||||
CachedBukkitAdapter adapter
|
CachedBukkitAdapter adapter,
|
||||||
|
short[] nonEmptyBlockCount
|
||||||
) {
|
) {
|
||||||
|
short nonAir = 4096;
|
||||||
int num_palette = 0;
|
int num_palette = 0;
|
||||||
char[] getArr = null;
|
char[] getArr = null;
|
||||||
for (int i = 0; i < 4096; i++) {
|
for (int i = 0; i < 4096; i++) {
|
||||||
char ordinal = set[i];
|
char ordinal = set[i];
|
||||||
if (ordinal == BlockTypesCache.ReservedIDs.__RESERVED__) {
|
switch (ordinal) {
|
||||||
|
case BlockTypesCache.ReservedIDs.__RESERVED__ -> {
|
||||||
if (getArr == null) {
|
if (getArr == null) {
|
||||||
getArr = get.apply(layer);
|
getArr = get.apply(layer);
|
||||||
}
|
}
|
||||||
ordinal = getArr[i];
|
ordinal = getArr[i];
|
||||||
if (ordinal == BlockTypesCache.ReservedIDs.__RESERVED__) {
|
switch (ordinal) {
|
||||||
|
case BlockTypesCache.ReservedIDs.__RESERVED__ -> {
|
||||||
ordinal = BlockTypesCache.ReservedIDs.AIR;
|
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];
|
int palette = blockToPalette[ordinal];
|
||||||
if (palette == Integer.MAX_VALUE) {
|
if (palette == Integer.MAX_VALUE) {
|
||||||
@ -101,6 +120,9 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl {
|
|||||||
blocksCopy[i] = palette;
|
blocksCopy[i] = palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nonEmptyBlockCount != null) {
|
||||||
|
nonEmptyBlockCount[0] = nonAir;
|
||||||
|
}
|
||||||
return num_palette;
|
return num_palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user