Various debugging and cleaning

This commit is contained in:
MattBDev
2020-01-03 12:02:18 -05:00
parent a5ee0b197d
commit cfb6e3bca4
21 changed files with 247 additions and 253 deletions

View File

@ -142,7 +142,7 @@ public class MCAChunk implements IChunk {
for (Map.Entry<String, String> entry : properties.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
Property property = type.getProperty(key);
Property<Object> property = type.getProperty(key);
state = state.with(property, property.getValueFor(value));
}
}
@ -246,8 +246,8 @@ public class MCAChunk implements IChunk {
int type = NBTConstants.TYPE_BYTE_ARRAY;
out.writeNamedTagName("Biomes", type);
out.writeInt(biomes.length);
for (int i = 0; i < biomes.length; i++) {
out.write(biomes[i].getLegacyId());
for (BiomeType biome : biomes) {
out.write(biome.getLegacyId());
}
}
int len = 0;
@ -430,9 +430,7 @@ public class MCAChunk implements IChunk {
if (tile != null) {
tiles.put(x, y, z, tile);
} else {
if (tiles.remove(x, y, z) == null) {
return false;
}
return tiles.remove(x, y, z) != null;
}
return true;
}
@ -520,18 +518,14 @@ public class MCAChunk implements IChunk {
@Override
public void setBlocks(int layer, char[] data) {
int offset = layer << 12;
for (int i = 0; i < 4096; i++) {
blocks[offset + i] = data[i];
}
System.arraycopy(data, 0, blocks, offset, 4096);
}
@Override
public char[] load(int layer) {
char[] tmp = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
int offset = layer << 12;
for (int i = 0; i < 4096; i++) {
tmp[i] = blocks[offset + i];
}
System.arraycopy(blocks, offset, tmp, 0, 4096);
return tmp;
}

View File

@ -34,6 +34,7 @@ import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.IntStream;
import java.util.zip.Deflater;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
@ -397,10 +398,8 @@ public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, ICh
}
public List<MCAChunk> getCachedChunks() {
int size = 0;
for (int i = 0; i < chunks.length; i++) {
if (chunks[i] != null && this.chunkInitialized[i]) size++;
}
int size = (int) IntStream.range(0, chunks.length)
.filter(i -> chunks[i] != null && this.chunkInitialized[i]).count();
ArrayList<MCAChunk> list = new ArrayList<>(size);
for (int i = 0; i < chunks.length; i++) {
MCAChunk chunk = chunks[i];