Don't swallow exception with disk clipboard

This commit is contained in:
Jesse Boyd 2017-08-10 01:19:46 +10:00
parent 195e043f2c
commit 8d9914fafd
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -366,38 +366,26 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
@Override @Override
public void forEach(final BlockReader task, boolean air) { public void forEach(final BlockReader task, boolean air) {
try { mbb.force();
mbb.force(); int pos = HEADER_SIZE;
int pos = HEADER_SIZE; IntegerTrio trio = new IntegerTrio();
IntegerTrio trio = new IntegerTrio(); final boolean hasTile = !nbtMap.isEmpty();
final boolean hasTile = !nbtMap.isEmpty(); if (air) {
if (air) { if (hasTile) {
if (hasTile) { for (int y = 0; y < height; y++) {
for (int y = 0; y < height; y++) { for (int z = 0; z < length; z++) {
for (int z = 0; z < length; z++) { for (int x = 0; x < width; x++, pos += 2) {
for (int x = 0; x < width; x++, pos += 2) { char combinedId = mbb.getChar(pos);
char combinedId = mbb.getChar(pos); BaseBlock block = FaweCache.CACHE_BLOCK[combinedId];
BaseBlock block = FaweCache.CACHE_BLOCK[combinedId]; if (block.canStoreNBTData()) {
if (block.canStoreNBTData()) { trio.set(x, y, z);
trio.set(x, y, z); CompoundTag nbt = nbtMap.get(trio);
CompoundTag nbt = nbtMap.get(trio); if (nbt != null) {
if (nbt != null) { block = new BaseBlock(block.getId(), block.getData());
block = new BaseBlock(block.getId(), block.getData()); block.setNbtData(nbt);
block.setNbtData(nbt);
}
} }
task.run(x, y, z, block);
}
}
}
} else {
for (int y = 0; y < height; y++) {
for (int z = 0; z < length; z++) {
for (int x = 0; x < width; x++, pos += 2) {
char combinedId = mbb.getChar(pos);
BaseBlock block = FaweCache.CACHE_BLOCK[combinedId];
task.run(x, y, z, block);
} }
task.run(x, y, z, block);
} }
} }
} }
@ -405,25 +393,33 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
for (int y = 0; y < height; y++) { for (int y = 0; y < height; y++) {
for (int z = 0; z < length; z++) { for (int z = 0; z < length; z++) {
for (int x = 0; x < width; x++, pos += 2) { for (int x = 0; x < width; x++, pos += 2) {
int combinedId = mbb.getChar(pos); char combinedId = mbb.getChar(pos);
if (combinedId != 0) { BaseBlock block = FaweCache.CACHE_BLOCK[combinedId];
BaseBlock block = FaweCache.CACHE_BLOCK[combinedId]; task.run(x, y, z, block);
if (block.canStoreNBTData()) { }
trio.set(x, y, z); }
CompoundTag nbt = nbtMap.get(trio); }
if (nbt != null) { }
block = new BaseBlock(block.getId(), block.getData()); } else {
block.setNbtData(nbt); for (int y = 0; y < height; y++) {
} for (int z = 0; z < length; z++) {
} for (int x = 0; x < width; x++, pos += 2) {
task.run(x, y, z, block); int combinedId = mbb.getChar(pos);
} if (combinedId != 0) {
BaseBlock block = FaweCache.CACHE_BLOCK[combinedId];
if (block.canStoreNBTData()) {
trio.set(x, y, z);
CompoundTag nbt = nbtMap.get(trio);
if (nbt != null) {
block = new BaseBlock(block.getId(), block.getData());
block.setNbtData(nbt);
}
}
task.run(x, y, z, block);
} }
} }
} }
} }
} catch (Throwable e) {
MainUtil.handleError(e);
} }
} }