Skip to content

Commit 2bda7b5

Browse files
committed
fully wrap threadstone logger's operation
1 parent 0f4e8d3 commit 2bda7b5

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

patches/net/minecraft/block/BlockBeacon.java.patch

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,19 @@
2525
Chunk chunk = worldIn.getChunk(glassPos);
2626

2727
for (int i = glassPos.getY() - 1; i >= 0; --i)
28-
@@ -111,7 +123,16 @@
28+
@@ -111,7 +123,20 @@
2929
});
3030
}
3131
}
3232
+ // vanilla logic ends
3333

3434
+ // TISCM threadstone logger logs beacons add catch-finally
3535
+ } catch (Throwable throwable) {
36-
+ ThreadstoneLogger.getInstance().onExceptionallyEndedAsyncThread(throwable);
36+
+ if (logBeacons) {
37+
+ ThreadstoneLogger.getInstance().onExceptionallyEndedAsyncThread(throwable);
38+
+ } else {
39+
+ throw throwable;
40+
+ }
3741
+ } finally {
3842
+ if (logBeacons) {
3943
+ GlassThreadStatistic.getInstance().onGlassThreadTerminated(System.nanoTime() - startNano);

patches/net/minecraft/block/BlockNote.java.patch

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
if (flag)
5555
{
5656
this.triggerNote(worldIn, pos);
57-
@@ -55,6 +76,57 @@
57+
@@ -55,6 +76,60 @@
5858
}
5959
}
6060

@@ -83,7 +83,10 @@
8383
+ }
8484
+ catch (Throwable throwable)
8585
+ {
86-
+ ThreadstoneLogger.getInstance().onExceptionallyEndedAsyncThread(throwable);
86+
+ if (CarpetSettings.threadstoneLogger && LoggerRegistry.__threadstone)
87+
+ {
88+
+ ThreadstoneLogger.getInstance().onExceptionallyEndedAsyncThread(throwable);
89+
+ }
8790
+ }
8891
+ });
8992
+ }
@@ -112,7 +115,7 @@
112115
private void triggerNote(World worldIn, BlockPos pos)
113116
{
114117
if (worldIn.getBlockState(pos.up()).isAir())
115-
@@ -101,4 +173,16 @@
118+
@@ -101,4 +176,16 @@
116119
{
117120
builder.add(INSTRUMENT, POWERED, NOTE);
118121
}

src/main/java/carpet/logging/threadstone/ThreadstoneLogger.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ private void logFormat(String formatter, Object... args) {
7272
this.logText(Messenger.format(formatter, args));
7373
}
7474

75+
// ============================= hooks =============================
76+
// all hooks should be checked using CarpetSettings.threadstoneLogger && LoggerRegistry.__threadstone
77+
// to ensure that they only get triggered when necessary
78+
7579
public void onExceptionallyEndedAsyncThread(Throwable throwable) {
7680
this.logFormat("Exception occurred: %s", throwable);
7781
}

0 commit comments

Comments
 (0)