3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-19 09:20:08 +01:00

fix: create new biome paletted container when writing (#2791)

- resizing a paletted container copy alters the original paletted container
 - copy is not clone
 - fixes #2790
Dieser Commit ist enthalten in:
Jordan 2024-06-20 20:49:16 +02:00 committet von GitHub
Ursprung d69dc97958
Commit 705df34c12
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
10 geänderte Dateien mit 95 neuen und 120 gelöschten Zeilen

Datei anzeigen

@ -824,7 +824,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
nmsChunk.mustNotSave = false; nmsChunk.mustNotSave = false;
nmsChunk.setUnsaved(true); nmsChunk.setUnsaved(true);
// send to player // send to player
if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING || finalMask == 0 && biomes != null) {
this.send(); this.send();
} }
if (finalizer != null) { if (finalizer != null) {
@ -1109,25 +1109,14 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
if (biomes == null || (sectionBiomes = biomes[sectionIndex]) == null) { if (biomes == null || (sectionBiomes = biomes[sectionIndex]) == null) {
return null; return null;
} }
PalettedContainer<Holder<Biome>> biomeData; PalettedContainer<Holder<Biome>> biomeData = data.recreate();
if (data instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
biomeData = palettedContainer.copy();
} else {
LOGGER.warn(
"Cannot correctly set biomes to world, existing biomes may be lost. Expected class " +
"type {} but got {}",
PalettedContainer.class.getSimpleName(),
data.getClass().getSimpleName()
);
biomeData = data.recreate();
}
for (int y = 0, index = 0; y < 4; y++) { for (int y = 0, index = 0; y < 4; y++) {
for (int z = 0; z < 4; z++) { for (int z = 0; z < 4; z++) {
for (int x = 0; x < 4; x++, index++) { for (int x = 0; x < 4; x++, index++) {
BiomeType biomeType = sectionBiomes[index]; BiomeType biomeType = sectionBiomes[index];
if (biomeType == null) { if (biomeType == null) {
continue; biomeData.set(x, y, z, data.get(x, y, z));
} } else {
biomeData.set( biomeData.set(
x, x,
y, y,
@ -1137,6 +1126,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
} }
} }
} }
}
return biomeData; return biomeData;
} }

Datei anzeigen

@ -45,7 +45,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
private final int maxHeight; private final int maxHeight;
final ServerLevel serverLevel; final ServerLevel serverLevel;
final LevelChunk levelChunk; final LevelChunk levelChunk;
private PalettedContainer<Holder<Biome>>[] biomes = null; private Holder<Biome>[][] biomes = null;
protected PaperweightGetBlocks_Copy(LevelChunk levelChunk) { protected PaperweightGetBlocks_Copy(LevelChunk levelChunk) {
this.levelChunk = levelChunk; this.levelChunk = levelChunk;
@ -144,7 +144,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
@Override @Override
public BiomeType getBiomeType(int x, int y, int z) { public BiomeType getBiomeType(int x, int y, int z) {
Holder<Biome> biome = biomes[(y >> 4) - getMinSectionPosition()].get(x >> 2, (y & 15) >> 2, z >> 2); Holder<Biome> biome = biomes[(y >> 4) - getMinSectionPosition()][(y & 12) << 2 | (z & 12) | (x & 12) >> 2];
return PaperweightPlatformAdapter.adapt(biome, serverLevel); return PaperweightPlatformAdapter.adapt(biome, serverLevel);
} }
@ -173,10 +173,15 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
protected void storeBiomes(int layer, PalettedContainerRO<Holder<Biome>> biomeData) { protected void storeBiomes(int layer, PalettedContainerRO<Holder<Biome>> biomeData) {
if (biomes == null) { if (biomes == null) {
biomes = new PalettedContainer[getSectionCount()]; biomes = new Holder[getSectionCount()][];
}
if (biomes[layer] == null) {
biomes[layer] = new Holder[64];
} }
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) { if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
biomes[layer] = palettedContainer.copy(); for (int i = 0; i < 64; i++) {
biomes[layer][i] = palettedContainer.get(i);
}
} else { } else {
LOGGER.error( LOGGER.error(
"Cannot correctly save biomes to history. Expected class type {} but got {}", "Cannot correctly save biomes to history. Expected class type {} but got {}",

Datei anzeigen

@ -822,7 +822,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
nmsChunk.mustNotSave = false; nmsChunk.mustNotSave = false;
nmsChunk.setUnsaved(true); nmsChunk.setUnsaved(true);
// send to player // send to player
if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING || finalMask == 0 && biomes != null) {
this.send(); this.send();
} }
if (finalizer != null) { if (finalizer != null) {
@ -1106,25 +1106,14 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
if (biomes == null || (sectionBiomes = biomes[sectionIndex]) == null) { if (biomes == null || (sectionBiomes = biomes[sectionIndex]) == null) {
return null; return null;
} }
PalettedContainer<Holder<Biome>> biomeData; PalettedContainer<Holder<Biome>> biomeData = data.recreate();
if (data instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
biomeData = palettedContainer.copy();
} else {
LOGGER.warn(
"Cannot correctly set biomes to world, existing biomes may be lost. Expected class " +
"type {} but got {}",
PalettedContainer.class.getSimpleName(),
data.getClass().getSimpleName()
);
biomeData = data.recreate();
}
for (int y = 0, index = 0; y < 4; y++) { for (int y = 0, index = 0; y < 4; y++) {
for (int z = 0; z < 4; z++) { for (int z = 0; z < 4; z++) {
for (int x = 0; x < 4; x++, index++) { for (int x = 0; x < 4; x++, index++) {
BiomeType biomeType = sectionBiomes[index]; BiomeType biomeType = sectionBiomes[index];
if (biomeType == null) { if (biomeType == null) {
continue; biomeData.set(x, y, z, data.get(x, y, z));
} } else {
biomeData.set( biomeData.set(
x, x,
y, y,
@ -1134,6 +1123,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
} }
} }
} }
}
return biomeData; return biomeData;
} }

Datei anzeigen

@ -45,7 +45,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
private final int maxHeight; private final int maxHeight;
final ServerLevel serverLevel; final ServerLevel serverLevel;
final LevelChunk levelChunk; final LevelChunk levelChunk;
private PalettedContainer<Holder<Biome>>[] biomes = null; private Holder<Biome>[][] biomes = null;
protected PaperweightGetBlocks_Copy(LevelChunk levelChunk) { protected PaperweightGetBlocks_Copy(LevelChunk levelChunk) {
this.levelChunk = levelChunk; this.levelChunk = levelChunk;
@ -144,7 +144,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
@Override @Override
public BiomeType getBiomeType(int x, int y, int z) { public BiomeType getBiomeType(int x, int y, int z) {
Holder<Biome> biome = biomes[(y >> 4) - getMinSectionPosition()].get(x >> 2, (y & 15) >> 2, z >> 2); Holder<Biome> biome = biomes[(y >> 4) - getMinSectionPosition()][(y & 12) << 2 | (z & 12) | (x & 12) >> 2];
return PaperweightPlatformAdapter.adapt(biome, serverLevel); return PaperweightPlatformAdapter.adapt(biome, serverLevel);
} }
@ -173,10 +173,15 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
protected void storeBiomes(int layer, PalettedContainerRO<Holder<Biome>> biomeData) { protected void storeBiomes(int layer, PalettedContainerRO<Holder<Biome>> biomeData) {
if (biomes == null) { if (biomes == null) {
biomes = new PalettedContainer[getSectionCount()]; biomes = new Holder[getSectionCount()][];
}
if (biomes[layer] == null) {
biomes[layer] = new Holder[64];
} }
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) { if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
biomes[layer] = palettedContainer.copy(); for (int i = 0; i < 64; i++) {
biomes[layer][i] = palettedContainer.get(i);
}
} else { } else {
LOGGER.error( LOGGER.error(
"Cannot correctly save biomes to history. Expected class type {} but got {}", "Cannot correctly save biomes to history. Expected class type {} but got {}",

Datei anzeigen

@ -830,7 +830,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
nmsChunk.mustNotSave = false; nmsChunk.mustNotSave = false;
nmsChunk.setUnsaved(true); nmsChunk.setUnsaved(true);
// send to player // send to player
if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING || finalMask == 0 && biomes != null) {
this.send(); this.send();
} }
if (finalizer != null) { if (finalizer != null) {
@ -1114,25 +1114,14 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
if (biomes == null || (sectionBiomes = biomes[sectionIndex]) == null) { if (biomes == null || (sectionBiomes = biomes[sectionIndex]) == null) {
return null; return null;
} }
PalettedContainer<Holder<Biome>> biomeData; PalettedContainer<Holder<Biome>> biomeData = data.recreate();
if (data instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
biomeData = palettedContainer.copy();
} else {
LOGGER.warn(
"Cannot correctly set biomes to world, existing biomes may be lost. Expected class " +
"type {} but got {}",
PalettedContainer.class.getSimpleName(),
data.getClass().getSimpleName()
);
biomeData = data.recreate();
}
for (int y = 0, index = 0; y < 4; y++) { for (int y = 0, index = 0; y < 4; y++) {
for (int z = 0; z < 4; z++) { for (int z = 0; z < 4; z++) {
for (int x = 0; x < 4; x++, index++) { for (int x = 0; x < 4; x++, index++) {
BiomeType biomeType = sectionBiomes[index]; BiomeType biomeType = sectionBiomes[index];
if (biomeType == null) { if (biomeType == null) {
continue; biomeData.set(x, y, z, data.get(x, y, z));
} } else {
biomeData.set( biomeData.set(
x, x,
y, y,
@ -1142,6 +1131,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
} }
} }
} }
}
return biomeData; return biomeData;
} }

Datei anzeigen

@ -45,7 +45,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
private final int maxHeight; private final int maxHeight;
final ServerLevel serverLevel; final ServerLevel serverLevel;
final LevelChunk levelChunk; final LevelChunk levelChunk;
private PalettedContainer<Holder<Biome>>[] biomes = null; private Holder<Biome>[][] biomes = null;
protected PaperweightGetBlocks_Copy(LevelChunk levelChunk) { protected PaperweightGetBlocks_Copy(LevelChunk levelChunk) {
this.levelChunk = levelChunk; this.levelChunk = levelChunk;
@ -144,7 +144,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
@Override @Override
public BiomeType getBiomeType(int x, int y, int z) { public BiomeType getBiomeType(int x, int y, int z) {
Holder<Biome> biome = biomes[(y >> 4) - getMinSectionPosition()].get(x >> 2, (y & 15) >> 2, z >> 2); Holder<Biome> biome = biomes[(y >> 4) - getMinSectionPosition()][(y & 12) << 2 | (z & 12) | (x & 12) >> 2];
return PaperweightPlatformAdapter.adapt(biome, serverLevel); return PaperweightPlatformAdapter.adapt(biome, serverLevel);
} }
@ -173,10 +173,15 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
protected void storeBiomes(int layer, PalettedContainerRO<Holder<Biome>> biomeData) { protected void storeBiomes(int layer, PalettedContainerRO<Holder<Biome>> biomeData) {
if (biomes == null) { if (biomes == null) {
biomes = new PalettedContainer[getSectionCount()]; biomes = new Holder[getSectionCount()][];
}
if (biomes[layer] == null) {
biomes[layer] = new Holder[64];
} }
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) { if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
biomes[layer] = palettedContainer.copy(); for (int i = 0; i < 64; i++) {
biomes[layer][i] = palettedContainer.get(i);
}
} else { } else {
LOGGER.error( LOGGER.error(
"Cannot correctly save biomes to history. Expected class type {} but got {}", "Cannot correctly save biomes to history. Expected class type {} but got {}",

Datei anzeigen

@ -829,7 +829,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
nmsChunk.mustNotSave = false; nmsChunk.mustNotSave = false;
nmsChunk.setUnsaved(true); nmsChunk.setUnsaved(true);
// send to player // send to player
if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING || finalMask == 0 && biomes != null) {
this.send(); this.send();
} }
if (finalizer != null) { if (finalizer != null) {
@ -1111,25 +1111,14 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
if (biomes == null || (sectionBiomes = biomes[sectionIndex]) == null) { if (biomes == null || (sectionBiomes = biomes[sectionIndex]) == null) {
return null; return null;
} }
PalettedContainer<Holder<Biome>> biomeData; PalettedContainer<Holder<Biome>> biomeData = data.recreate();
if (data instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
biomeData = palettedContainer.copy();
} else {
LOGGER.warn(
"Cannot correctly set biomes to world, existing biomes may be lost. Expected class " +
"type {} but got {}",
PalettedContainer.class.getSimpleName(),
data.getClass().getSimpleName()
);
biomeData = data.recreate();
}
for (int y = 0, index = 0; y < 4; y++) { for (int y = 0, index = 0; y < 4; y++) {
for (int z = 0; z < 4; z++) { for (int z = 0; z < 4; z++) {
for (int x = 0; x < 4; x++, index++) { for (int x = 0; x < 4; x++, index++) {
BiomeType biomeType = sectionBiomes[index]; BiomeType biomeType = sectionBiomes[index];
if (biomeType == null) { if (biomeType == null) {
continue; biomeData.set(x, y, z, data.get(x, y, z));
} } else {
biomeData.set( biomeData.set(
x, x,
y, y,
@ -1139,6 +1128,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
} }
} }
} }
}
return biomeData; return biomeData;
} }

Datei anzeigen

@ -45,7 +45,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
private final int maxHeight; private final int maxHeight;
final ServerLevel serverLevel; final ServerLevel serverLevel;
final LevelChunk levelChunk; final LevelChunk levelChunk;
private PalettedContainer<Holder<Biome>>[] biomes = null; private Holder<Biome>[][] biomes = null;
protected PaperweightGetBlocks_Copy(LevelChunk levelChunk) { protected PaperweightGetBlocks_Copy(LevelChunk levelChunk) {
this.levelChunk = levelChunk; this.levelChunk = levelChunk;
@ -144,7 +144,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
@Override @Override
public BiomeType getBiomeType(int x, int y, int z) { public BiomeType getBiomeType(int x, int y, int z) {
Holder<Biome> biome = biomes[(y >> 4) - getMinSectionPosition()].get(x >> 2, (y & 15) >> 2, z >> 2); Holder<Biome> biome = biomes[(y >> 4) - getMinSectionPosition()][(y & 12) << 2 | (z & 12) | (x & 12) >> 2];
return PaperweightPlatformAdapter.adapt(biome, serverLevel); return PaperweightPlatformAdapter.adapt(biome, serverLevel);
} }
@ -173,10 +173,15 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
protected void storeBiomes(int layer, PalettedContainerRO<Holder<Biome>> biomeData) { protected void storeBiomes(int layer, PalettedContainerRO<Holder<Biome>> biomeData) {
if (biomes == null) { if (biomes == null) {
biomes = new PalettedContainer[getSectionCount()]; biomes = new Holder[getSectionCount()][];
}
if (biomes[layer] == null) {
biomes[layer] = new Holder[64];
} }
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) { if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
biomes[layer] = palettedContainer.copy(); for (int i = 0; i < 64; i++) {
biomes[layer][i] = palettedContainer.get(i);
}
} else { } else {
LOGGER.error( LOGGER.error(
"Cannot correctly save biomes to history. Expected class type {} but got {}", "Cannot correctly save biomes to history. Expected class type {} but got {}",

Datei anzeigen

@ -830,7 +830,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
nmsChunk.mustNotSave = false; nmsChunk.mustNotSave = false;
nmsChunk.setUnsaved(true); nmsChunk.setUnsaved(true);
// send to player // send to player
if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING || finalMask == 0 && biomes != null) {
this.send(); this.send();
} }
if (finalizer != null) { if (finalizer != null) {
@ -1114,25 +1114,14 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
if (biomes == null || (sectionBiomes = biomes[sectionIndex]) == null) { if (biomes == null || (sectionBiomes = biomes[sectionIndex]) == null) {
return null; return null;
} }
PalettedContainer<Holder<Biome>> biomeData; PalettedContainer<Holder<Biome>> biomeData = data.recreate();
if (data instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
biomeData = palettedContainer.copy();
} else {
LOGGER.warn(
"Cannot correctly set biomes to world, existing biomes may be lost. Expected class " +
"type {} but got {}",
PalettedContainer.class.getSimpleName(),
data.getClass().getSimpleName()
);
biomeData = data.recreate();
}
for (int y = 0, index = 0; y < 4; y++) { for (int y = 0, index = 0; y < 4; y++) {
for (int z = 0; z < 4; z++) { for (int z = 0; z < 4; z++) {
for (int x = 0; x < 4; x++, index++) { for (int x = 0; x < 4; x++, index++) {
BiomeType biomeType = sectionBiomes[index]; BiomeType biomeType = sectionBiomes[index];
if (biomeType == null) { if (biomeType == null) {
continue; biomeData.set(x, y, z, data.get(x, y, z));
} } else {
biomeData.set( biomeData.set(
x, x,
y, y,
@ -1142,6 +1131,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
} }
} }
} }
}
return biomeData; return biomeData;
} }

Datei anzeigen

@ -46,7 +46,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
private final int maxHeight; private final int maxHeight;
final ServerLevel serverLevel; final ServerLevel serverLevel;
final LevelChunk levelChunk; final LevelChunk levelChunk;
private PalettedContainer<Holder<Biome>>[] biomes = null; private Holder<Biome>[][] biomes = null;
protected PaperweightGetBlocks_Copy(LevelChunk levelChunk) { protected PaperweightGetBlocks_Copy(LevelChunk levelChunk) {
this.levelChunk = levelChunk; this.levelChunk = levelChunk;
@ -145,7 +145,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
@Override @Override
public BiomeType getBiomeType(int x, int y, int z) { public BiomeType getBiomeType(int x, int y, int z) {
Holder<Biome> biome = biomes[(y >> 4) - getMinSectionPosition()].get(x >> 2, (y & 15) >> 2, z >> 2); Holder<Biome> biome = biomes[(y >> 4) - getMinSectionPosition()][(y & 12) << 2 | (z & 12) | (x & 12) >> 2];
return PaperweightPlatformAdapter.adapt(biome, serverLevel); return PaperweightPlatformAdapter.adapt(biome, serverLevel);
} }
@ -174,10 +174,15 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
protected void storeBiomes(int layer, PalettedContainerRO<Holder<Biome>> biomeData) { protected void storeBiomes(int layer, PalettedContainerRO<Holder<Biome>> biomeData) {
if (biomes == null) { if (biomes == null) {
biomes = new PalettedContainer[getSectionCount()]; biomes = new Holder[getSectionCount()][];
}
if (biomes[layer] == null) {
biomes[layer] = new Holder[64];
} }
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) { if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
biomes[layer] = palettedContainer.copy(); for (int i = 0; i < 64; i++) {
biomes[layer][i] = palettedContainer.get(i);
}
} else { } else {
LOGGER.error( LOGGER.error(
"Cannot correctly save biomes to history. Expected class type {} but got {}", "Cannot correctly save biomes to history. Expected class type {} but got {}",