From 7bd59f7b142fa186730fe536a3b955ba2703ac43 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Mon, 23 Sep 2024 11:16:45 -0700 Subject: [PATCH] Not pointing - Fix occasional npe in PlayerUniforms - Mark accessor method as Nullable --- .../flywheel/backend/engine/uniform/PlayerUniforms.java | 5 +++-- .../flywheel/backend/mixin/AbstractClientPlayerAccessor.java | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/common/src/backend/java/dev/engine_room/flywheel/backend/engine/uniform/PlayerUniforms.java b/common/src/backend/java/dev/engine_room/flywheel/backend/engine/uniform/PlayerUniforms.java index 8b8f31f85..34a974abe 100644 --- a/common/src/backend/java/dev/engine_room/flywheel/backend/engine/uniform/PlayerUniforms.java +++ b/common/src/backend/java/dev/engine_room/flywheel/backend/engine/uniform/PlayerUniforms.java @@ -40,7 +40,7 @@ public static void update(RenderContext context) { Vec3 eyePos = player.getEyePosition(context.partialTick()); ptr = writeVec3(ptr, (float) eyePos.x, (float) eyePos.y, (float) eyePos.z); - ptr = writeTeamColor(ptr, info.getTeam()); + ptr = writeTeamColor(ptr, info == null ? null : info.getTeam()); ptr = writeEyeBrightness(ptr, player); @@ -54,7 +54,8 @@ public static void update(RenderContext context) { ptr = writeInt(ptr, player.isShiftKeyDown() ? 1 : 0); - ptr = writeInt(ptr, info.getGameMode().getId()); + ptr = writeInt(ptr, info == null ? 0 : info.getGameMode() + .getId()); BUFFER.markDirty(); } diff --git a/common/src/backend/java/dev/engine_room/flywheel/backend/mixin/AbstractClientPlayerAccessor.java b/common/src/backend/java/dev/engine_room/flywheel/backend/mixin/AbstractClientPlayerAccessor.java index 6a0c6cdd3..284653596 100644 --- a/common/src/backend/java/dev/engine_room/flywheel/backend/mixin/AbstractClientPlayerAccessor.java +++ b/common/src/backend/java/dev/engine_room/flywheel/backend/mixin/AbstractClientPlayerAccessor.java @@ -1,5 +1,6 @@ package dev.engine_room.flywheel.backend.mixin; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; @@ -9,5 +10,6 @@ @Mixin(AbstractClientPlayer.class) public interface AbstractClientPlayerAccessor { @Invoker("getPlayerInfo") + @Nullable PlayerInfo flywheel$getPlayerInfo(); }