Skip to content

Commit cf9c9d8

Browse files
committed
fix
1 parent 62260af commit cf9c9d8

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

src/main/java/cn/ussshenzhou/channel/audio/client/rt/DebugRayTrace.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ public static void render(RenderLevelStageEvent.AfterTranslucentParticles event)
2727
var posestack = event.getPoseStack();
2828
posestack.pushPose();
2929
posestack.translate(Minecraft.getInstance().gameRenderer.getMainCamera().position().scale(-1));
30-
for (var ray : rays) {
31-
Gizmos.line(ray.from, ray.to, ray.color, 1f);
30+
synchronized (DebugRayTrace.rays) {
31+
for (var ray : rays) {
32+
Gizmos.line(ray.from, ray.to, ray.color, 1f);
33+
}
3234
}
3335
posestack.popPose();
3436
}

src/main/java/cn/ussshenzhou/channel/audio/client/rt/RayTraceManager.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ private static void clear() {
102102
synchronized (HIT_POINTS) {
103103
HIT_POINTS.clear();
104104
}
105-
DebugRayTrace.rays.clear();
105+
synchronized (DebugRayTrace.rays) {
106+
DebugRayTrace.rays.clear();
107+
}
106108
SOURCE_AUDIO_DATA_CACHE.clear();
107109
}
108110

@@ -150,11 +152,13 @@ private static void generateOneRay(Vec3 earPos, Vector3d ray, ClientLevel level,
150152
HIT_POINTS.add(new HitPoint(round, new Vec3(hitPos.x, hitPos.y, hitPos.z), journey, distance, BlockSoundProperty.get(soundType), hitResult.getDirection()));
151153
}
152154
if (debug) {
153-
DebugRayTrace.rays.add(new DebugRayTrace.Ray(
154-
new Vec3(startPos.x, startPos.y, startPos.z),
155-
new Vec3(startPos.x + ray.x * distance, startPos.y + ray.y * distance, startPos.z + ray.z * distance),
156-
color
157-
));
155+
synchronized (DebugRayTrace.rays) {
156+
DebugRayTrace.rays.add(new DebugRayTrace.Ray(
157+
new Vec3(startPos.x, startPos.y, startPos.z),
158+
new Vec3(startPos.x + ray.x * distance, startPos.y + ray.y * distance, startPos.z + ray.z * distance),
159+
color
160+
));
161+
}
158162
}
159163
switch (hitResult.getDirection()) {
160164
case UP, DOWN -> ray.mul(1, -1, 1);

0 commit comments

Comments
 (0)