@@ -162,67 +162,68 @@ public void registerAll() {
162162 }
163163
164164 public void onRender (Event <MatrixStack > renderEvent ){
165- RenderUtils .startDrawVirtual (renderEvent .context );
166- try {
167- if (mineRender .get () && mc .interactionManager != null && mc .player != null && mc .world != null ){
168- BlockPos blockPos = PlayerInteractionAccess .of (mc .interactionManager ).getCurrentMiningPos ();
169- Vec3d pos =Vec3d .of (blockPos );
170- //超过200格的不渲染
171- if (mc .player .getPos ().squaredDistanceTo (pos ) < 40000 ){
172- RenderUtils .setAsCurrentShaderColor (Color .BLUE , 1.0F );
173- RenderUtils .drawOutlinedBox (renderEvent .context , pos , pos .add (1.0 , 1.0 , 1.0 ));
174- float progress = PlayerInteractionAccess .of (mc .interactionManager ).getCurrentMiningProgress (true );
175- if (progress > 0.0F ){
176- BlockState state = mc .world .getBlockState (blockPos );
177- Box box ;
178- if (state .isAir ()){
179- box = new Box (0.0 , 0.0 , 0.0 , 1.0 , 1.0 , 1.0 );
180- }else {
181- VoxelShape shape = state .getOutlineShape (mc .world , blockPos );
182- box = shape .isEmpty ()? new Box (0.0 , 0.0 , 0.0 , 1.0 , 1.0 , 1.0 ): shape .getBoundingBox ();
183- }
184- Vec3d vec3 = box .getMaxPos ().subtract (box .getMinPos ()).multiply (0.5 );
185-
186- RenderUtils .setAsCurrentShaderColor (Color .YELLOW , 0.25F );
187- Vec3d vec3d = pos .add (box .getCenter ());
188- float clamped = MathHelper .clamp (progress , 0.0F , 1.0F ) ;
189- RenderUtils .drawSolidBox (renderEvent .context .peek ().getPositionMatrix (), vec3d .add (vec3 .multiply (-clamped )), vec3d .add (vec3 .multiply (clamped )));
190- }
191- }
192-
193-
194- BlockPos doubleMinePos = PlayerInteractionAccess .of (mc .interactionManager ).getCurrentFailBreakPos ();
195- if (doubleMinePos != null ){
196- Vec3d doubleMineVec = Vec3d .of (doubleMinePos );
197- if (mc .player .getPos ().squaredDistanceTo (doubleMineVec ) < 40000 && !Objects .equals (doubleMineVec , pos )){
198- float progressFail = PlayerInteractionAccess .of (mc .interactionManager ).getFailBreakMiningProgress ();
199- RenderUtils .setAsCurrentShaderColor (Color .MAGENTA , 1.0F );
200- RenderUtils .drawOutlinedBox (renderEvent .context , doubleMineVec , doubleMineVec .add (1.0 , 1.0 , 1.0 ));
201- if (progressFail > 0.0F ){
202- BlockState state = mc .world .getBlockState (doubleMinePos );
165+ if (mineRender .get ()){
166+ RenderUtils .startDrawVirtual (renderEvent .context );
167+ try {
168+ if (mc .interactionManager != null && mc .player != null && mc .world != null ){
169+ BlockPos blockPos = PlayerInteractionAccess .of (mc .interactionManager ).getCurrentMiningPos ();
170+ Vec3d pos =Vec3d .of (blockPos );
171+ //超过200格的不渲染
172+ if (mc .player .getPos ().squaredDistanceTo (pos ) < 40000 ){
173+ RenderUtils .setAsCurrentShaderColor (Color .BLUE , 1.0F );
174+ RenderUtils .drawOutlinedBox (renderEvent .context , pos , pos .add (1.0 , 1.0 , 1.0 ));
175+ float progress = PlayerInteractionAccess .of (mc .interactionManager ).getCurrentMiningProgress (true );
176+ if (progress > 0.0F ){
177+ BlockState state = mc .world .getBlockState (blockPos );
203178 Box box ;
204179 if (state .isAir ()){
205180 box = new Box (0.0 , 0.0 , 0.0 , 1.0 , 1.0 , 1.0 );
206181 }else {
207- VoxelShape shape = state .getOutlineShape (mc .world , doubleMinePos );
182+ VoxelShape shape = state .getOutlineShape (mc .world , blockPos );
208183 box = shape .isEmpty ()? new Box (0.0 , 0.0 , 0.0 , 1.0 , 1.0 , 1.0 ): shape .getBoundingBox ();
209184 }
210185 Vec3d vec3 = box .getMaxPos ().subtract (box .getMinPos ()).multiply (0.5 );
211186
212- RenderUtils .setAsCurrentShaderColor (Color .ORANGE , 0.25F );
213- Vec3d vec3d = doubleMineVec .add (box .getCenter ());
214- float clamped = MathHelper .clamp (progressFail , 0.0F , 1.0F ) ;
187+ RenderUtils .setAsCurrentShaderColor (Color .YELLOW , 0.25F );
188+ Vec3d vec3d = pos .add (box .getCenter ());
189+ float clamped = MathHelper .clamp (progress , 0.0F , 1.0F ) ;
215190 RenderUtils .drawSolidBox (renderEvent .context .peek ().getPositionMatrix (), vec3d .add (vec3 .multiply (-clamped )), vec3d .add (vec3 .multiply (clamped )));
216191 }
217192 }
218193
219- }
220194
195+ BlockPos doubleMinePos = PlayerInteractionAccess .of (mc .interactionManager ).getCurrentFailBreakPos ();
196+ if (doubleMinePos != null ){
197+ Vec3d doubleMineVec = Vec3d .of (doubleMinePos );
198+ if (mc .player .getPos ().squaredDistanceTo (doubleMineVec ) < 40000 && !Objects .equals (doubleMineVec , pos )){
199+ float progressFail = PlayerInteractionAccess .of (mc .interactionManager ).getFailBreakMiningProgress ();
200+ RenderUtils .setAsCurrentShaderColor (Color .MAGENTA , 1.0F );
201+ RenderUtils .drawOutlinedBox (renderEvent .context , doubleMineVec , doubleMineVec .add (1.0 , 1.0 , 1.0 ));
202+ if (progressFail > 0.0F ){
203+ BlockState state = mc .world .getBlockState (doubleMinePos );
204+ Box box ;
205+ if (state .isAir ()){
206+ box = new Box (0.0 , 0.0 , 0.0 , 1.0 , 1.0 , 1.0 );
207+ }else {
208+ VoxelShape shape = state .getOutlineShape (mc .world , doubleMinePos );
209+ box = shape .isEmpty ()? new Box (0.0 , 0.0 , 0.0 , 1.0 , 1.0 , 1.0 ): shape .getBoundingBox ();
210+ }
211+ Vec3d vec3 = box .getMaxPos ().subtract (box .getMinPos ()).multiply (0.5 );
212+
213+ RenderUtils .setAsCurrentShaderColor (Color .ORANGE , 0.25F );
214+ Vec3d vec3d = doubleMineVec .add (box .getCenter ());
215+ float clamped = MathHelper .clamp (progressFail , 0.0F , 1.0F ) ;
216+ RenderUtils .drawSolidBox (renderEvent .context .peek ().getPositionMatrix (), vec3d .add (vec3 .multiply (-clamped )), vec3d .add (vec3 .multiply (clamped )));
217+ }
218+ }
219+
220+ }
221+
222+ }
223+ }finally {
224+ RenderUtils .stopDrawVirtual (renderEvent .context );
221225 }
222- }finally {
223- RenderUtils .stopDrawVirtual (renderEvent .context );
224226 }
225-
226227 }
227228
228229
0 commit comments