@@ -60,12 +60,13 @@ protected void renderSafe(ChainConveyorBlockEntity be, float partialTicks, PoseS
6060 frustum = getFrustumIntersection ();
6161 camPos = Minecraft .getInstance ().gameRenderer .getMainCamera ().getPosition ();
6262 }
63- renderChains (be , ms , buffer , light , overlay , frustum , camPos );
63+ boolean renderCentre = frustum != null && frustum .testAab (pos .getX () - 2 - (float ) camPos .x , pos .getY () - (float ) camPos .y , pos .getZ () - 2 - (float ) camPos .z , pos .getX () + 2 - (float ) camPos .x , pos .getY () + 1 - (float ) camPos .y , pos .getZ () + 2 - (float ) camPos .z );
64+ renderChains (be , ms , buffer , light , overlay , frustum , camPos , renderCentre );
6465
6566 if (VisualizationManager .supportsVisualization (be .getLevel ()))
6667 return ;
6768
68- if (frustum != null && frustum . testAab ( pos . getX () - 2 - ( float ) camPos . x , pos . getY () - ( float ) camPos . y , pos . getZ () - 2 - ( float ) camPos . z , pos . getX () + 2 - ( float ) camPos . x , pos . getY () + 1 - ( float ) camPos . y , pos . getZ () + 2 - ( float ) camPos . z ) )
69+ if (renderCentre )
6970 CachedBuffers .partial (AllPartialModels .CHAIN_CONVEYOR_WHEEL , be .getBlockState ())
7071 .light (light )
7172 .overlay (overlay )
@@ -153,7 +154,7 @@ private static Vec3 getClosestPointOnChain(Vec3 cam, Vec3 start, Vec3 end) {
153154 }
154155
155156 private void renderChains (ChainConveyorBlockEntity be , PoseStack ms , MultiBufferSource buffer , int light ,
156- int overlay , FrustumIntersection frustum , Vec3 camPos ) {
157+ int overlay , FrustumIntersection frustum , Vec3 camPos , boolean renderCentre ) {
157158 float time = AnimationTickHolder .getRenderTime (be .getLevel ()) / (360f / Math .abs (be .getSpeed ()));
158159 time %= 1 ;
159160 if (time < 0 )
@@ -166,22 +167,10 @@ private void renderChains(ChainConveyorBlockEntity be, PoseStack ms, MultiBuffer
166167 if (stats == null )
167168 continue ;
168169
169- if (frustum != null && !frustum .testLineSegment ((float ) (stats .start ().x - camPos .x ), (float ) (stats .start ().y - camPos .y ), (float ) (stats .start ().z - camPos .z ),
170- (float ) (stats .end ().x - camPos .x ), (float ) (stats .end ().y - camPos .y ), (float ) (stats .end ().z - camPos .z ))) {
171- continue ;
172- }
173170 Vec3 diff = stats .end ()
174171 .subtract (stats .start ());
175172 double yaw = (float ) Mth .RAD_TO_DEG * Mth .atan2 (diff .x , diff .z );
176- double pitch = (float ) Mth .RAD_TO_DEG * Mth .atan2 (diff .y , diff .multiply (1 , 0 , 1 )
177- .length ());
178-
179- Level level = be .getLevel ();
180- BlockPos tilePos = be .getBlockPos ();
181- Vec3 startOffset = stats .start ()
182- .subtract (Vec3 .atCenterOf (tilePos ));
183-
184- if (!VisualizationManager .supportsVisualization (be .getLevel ())) {
173+ if (!VisualizationManager .supportsVisualization (be .getLevel ()) && renderCentre ) {
185174 SuperByteBuffer guard =
186175 CachedBuffers .partial (AllPartialModels .CHAIN_CONVEYOR_GUARD , be .getBlockState ());
187176 guard .center ();
@@ -192,6 +181,18 @@ private void renderChains(ChainConveyorBlockEntity be, PoseStack ms, MultiBuffer
192181 .overlay (overlay )
193182 .renderInto (ms , buffer .getBuffer (RenderType .cutoutMipped ()));
194183 }
184+ if (frustum != null && !frustum .testLineSegment ((float ) (stats .start ().x - camPos .x ), (float ) (stats .start ().y - camPos .y ), (float ) (stats .start ().z - camPos .z ),
185+ (float ) (stats .end ().x - camPos .x ), (float ) (stats .end ().y - camPos .y ), (float ) (stats .end ().z - camPos .z ))) {
186+ continue ;
187+ }
188+
189+ double pitch = (float ) Mth .RAD_TO_DEG * Mth .atan2 (diff .y , diff .multiply (1 , 0 , 1 )
190+ .length ());
191+
192+ Level level = be .getLevel ();
193+ BlockPos tilePos = be .getBlockPos ();
194+ Vec3 startOffset = stats .start ()
195+ .subtract (Vec3 .atCenterOf (tilePos ));
195196
196197 ms .pushPose ();
197198 var chain = TransformStack .of (ms );
0 commit comments