@@ -51,13 +51,18 @@ public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, i
5151 public void renderConsole (GlobalConsoleBlockEntity globalConsoleBlock , Level level , PoseStack poseStack , VertexConsumer vertexConsumer , int packedLight , int packedOverlay , float red , float green , float blue , float alpha ) {
5252 root ().getAllParts ().forEach (ModelPart ::resetPose );
5353 TardisClientData reactions = TardisClientData .getInstance (level .dimension ());
54- if (globalConsoleBlock == null ) return ;
5554
56- Boolean powered = globalConsoleBlock .getBlockState () == null ? true : globalConsoleBlock .getBlockState ().getValue (GlobalConsoleBlock .POWERED );
55+ // Exit early if globalConsoleBlock is null
56+ if (globalConsoleBlock == null ) {
57+ root ().render (poseStack , vertexConsumer , packedLight , packedOverlay , red , green , blue , alpha );
58+ return ;
59+ }
5760
61+ // Safely determine if the console is powered
62+ boolean powered = globalConsoleBlock .getBlockState () != null
63+ && globalConsoleBlock .getBlockState ().getValue (GlobalConsoleBlock .POWERED );
5864
5965 if (powered ) {
60-
6166 if (!globalConsoleBlock .powerOn .isStarted ()) {
6267 globalConsoleBlock .powerOff .stop ();
6368 globalConsoleBlock .powerOn .start (Minecraft .getInstance ().player .tickCount );
@@ -72,30 +77,30 @@ public void renderConsole(GlobalConsoleBlockEntity globalConsoleBlock, Level lev
7277 this .animate (reactions .ROTOR_ANIMATION , FLIGHT , Minecraft .getInstance ().player .tickCount );
7378 } else {
7479 // Handle idle animation
75- if (TRConfig .CLIENT .PLAY_CONSOLE_IDLE_ANIMATIONS .get () && globalConsoleBlock != null ) {
80+ if (TRConfig .CLIENT .PLAY_CONSOLE_IDLE_ANIMATIONS .get ()) {
7681 this .animate (globalConsoleBlock .liveliness , IDLE , Minecraft .getInstance ().player .tickCount );
7782 }
7883 }
79-
8084 } else {
81- if (globalConsoleBlock != null ) {
82- if (!globalConsoleBlock .powerOff .isStarted ()) {
83- globalConsoleBlock .powerOn .stop ();
84- globalConsoleBlock .powerOff .start (Minecraft .getInstance ().player .tickCount );
85- }
86- this .animate (globalConsoleBlock .powerOff , POWER_OFF , Minecraft .getInstance ().player .tickCount );
85+ if (!globalConsoleBlock .powerOff .isStarted ()) {
86+ globalConsoleBlock .powerOn .stop ();
87+ globalConsoleBlock .powerOff .start (Minecraft .getInstance ().player .tickCount );
8788 }
89+ this .animate (globalConsoleBlock .powerOff , POWER_OFF , Minecraft .getInstance ().player .tickCount );
8890 }
8991
90- float rot = -125 - (30 * ((float ) reactions .getThrottleStage () / TardisPilotingManager .MAX_THROTTLE_STAGE ));
91- this .throttleLever .xRot = rot ;
92+ // Update throttle lever and handbrake animations
93+ float throttleRotation = -125 - (30 * ((float ) reactions .getThrottleStage () / TardisPilotingManager .MAX_THROTTLE_STAGE ));
94+ this .throttleLever .xRot = throttleRotation ;
9295
9396 this .handbrake .xRot = reactions .isHandbrakeEngaged () ? -155f : -125f ;
94- root ().render (poseStack , vertexConsumer , packedLight , packedOverlay , red , green , blue , alpha );
9597
98+ // Render the model
99+ root ().render (poseStack , vertexConsumer , packedLight , packedOverlay , red , green , blue , alpha );
96100 }
97101
98102
103+
99104 @ Override
100105 public ModelPart root () {
101106 return root ;
0 commit comments