Skip to content

Commit

Permalink
fix: lamp halos not rendering properly
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTJP committed Jul 16, 2024
1 parent 3f1b756 commit ed2aefc
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public class HaloRenderer {
private static final LinkedList<HaloRenderData> entityHalos = new LinkedList<>();
// Global offset for moving block entities
private static final Vector3 offset = Vector3.ZERO.copy();
// Used for Forge bug workaround. See onRenderLevelStageEvent
// TODO remove when porting to > 1.20.1
private static @Nullable PoseStack capturedPoseStack = null;

//region Init and event handlers
public static void init() {
Expand All @@ -108,7 +111,20 @@ public void onMovingPostRender() {
public static void onRenderLevelStageEvent(final RenderLevelStageEvent event) {
if (event.getStage().equals(AFTER_PARTICLES)) {
onRenderStageAfterParticles(event);
capturedPoseStack = event.getPoseStack();
} else if (event.getStage().equals(AFTER_LEVEL)) {
// Workaround for non-backported Forge bug where the AFTER_LEVEL call gets the wrong PoseStack. We will retain the valid
// PoseStack from the AFTER_PARTICLE call and reuse it here.
// https://github.com/neoforged/NeoForge/pull/231
// https://github.com/MrTJP/ProjectRed/issues/1868
// TODO remove when porting to > 1.20.1
if (capturedPoseStack != null) {
var e2 = new RenderLevelStageEvent(event.getStage(), event.getLevelRenderer(), capturedPoseStack, event.getProjectionMatrix(), event.getRenderTick(), event.getPartialTick(), event.getCamera(), event.getFrustum());
capturedPoseStack = null;
onRenderStageAfterLevel(e2);
return;
}

onRenderStageAfterLevel(event);
}
}
Expand Down Expand Up @@ -217,7 +233,7 @@ private static void onRenderStageAfterLevel(final RenderLevelStageEvent event) {
List<HaloRenderData> lightList = pollHalos(levelHalos);

// Prepare render
Vec3 cam = Minecraft.getInstance().getEntityRenderDispatcher().camera.getPosition();
Vec3 cam = event.getCamera().getPosition();
PoseStack stack = event.getPoseStack();
stack.pushPose();
stack.translate(-cam.x, -cam.y, -cam.z);
Expand Down

0 comments on commit ed2aefc

Please sign in to comment.