Skip to content

Commit

Permalink
chores: try-catch only when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Jun 18, 2024
1 parent 9b6de74 commit e670d20
Showing 1 changed file with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,6 @@ public CompletableFuture<Chunk> loadChunk(int x, int z) {
if (presentValue != null) {
return presentValue;
}
// if (AllayComputeThread.isAllayComputeThread(Thread.currentThread())) {
// // 若当前线程已经为计算线程,则直接在此线程上加载区块
// // 否则会出现一个计算线程等待另外一个计算线程的情况,造成线程资源的浪费
// // If the current thread is already a computing thread, load the block directly on this thread
// // Otherwise, one computing thread will wait for another computing thread, resulting in a waste of thread resources
// loadChunkSynchronously(x, z, future);
// return future;
// }
worldStorage.readChunk(x, z, dimension.getDimensionInfo())
.exceptionally(t -> {
log.error("Error while reading chunk ({},{}) !", x, z, t);
Expand Down Expand Up @@ -226,13 +218,13 @@ private Chunk loadChunkSynchronously(int x, int z, CompletableFuture<Chunk> futu
log.error("Error while reading chunk ({},{}) !", x, z, t);
chunk = AllayUnsafeChunk.builder().emptyChunk(x, z, dimension.getDimensionInfo()).toSafeChunk();
}
try {
if (chunk.getState() != FINISHED) {
if (chunk.getState() != FINISHED) {
try {
chunk = getWorldGenerator().generateChunk(x, z);
} catch (Throwable t) {
log.error("Error while generating chunk ({},{}) !", x, z, t);
chunk = AllayUnsafeChunk.builder().emptyChunk(x, z, dimension.getDimensionInfo()).toSafeChunk();
}
} catch (Throwable t) {
log.error("Error while generating chunk ({},{}) !", x, z, t);
chunk = AllayUnsafeChunk.builder().emptyChunk(x, z, dimension.getDimensionInfo()).toSafeChunk();
}
chunk.beforeSetChunk(dimension);
setChunk(x, z, chunk);
Expand Down

0 comments on commit e670d20

Please sign in to comment.