Close at least one of the streams in IBlocks.java

This commit is contained in:
MattBDev 2020-03-04 00:52:42 -05:00
parent b818c03f84
commit 8eab3d098c

View File

@ -52,13 +52,14 @@ public interface IBlocks extends Trimable {
buffer = new byte[1024];
}
BlockRegistry registry = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry();
BlockRegistry registry = WorldEdit.getInstance().getPlatformManager()
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry();
FastByteArrayOutputStream sectionByteArray = new FastByteArrayOutputStream(buffer);
FaweOutputStream sectionWriter = new FaweOutputStream(sectionByteArray);
try {
try (FaweOutputStream sectionWriter = new FaweOutputStream(sectionByteArray)) {
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;
}
char[] ids = this.load(layer);
@ -78,21 +79,6 @@ public interface IBlocks extends Trimable {
}
sectionWriter.writeShort(nonEmpty); // non empty
// if (false) { // short palette
// sectionWriter.writeByte(14); // globalPaletteBitsPerBlock
// BitArray4096 bits = new BitArray4096(14); // globalPaletteBitsPerBlock
// bits.setAt(0, 0);
// for (int i = 0; i < 4096; i++) {
// int ordinal = ids[i];
// BlockState state = BlockState.getFromOrdinal(ordinal);
// if (!state.getMaterial().isAir()) {
// int mcId = registry.getInternalBlockStateId(state).getAsInt();
// bits.setAt(i, mcId);
// }
// }
// sectionWriter.write(bits.getData());
// } else {
FaweCache.Palette palette = FaweCache.IMP.toPalette(0, ids);
sectionWriter.writeByte(palette.bitsPerEntry); // bits per block
@ -117,7 +103,6 @@ public interface IBlocks extends Trimable {
for (int i = 0; i < palette.blockStatesLength; i++) {
sectionWriter.writeLong(palette.blockStates[i]);
}
// }
}
if (full) {
for (int z = 0; z < 16; z++) {