]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blobdiff - src/main/java/com/irtimaled/bbor/client/renderers/SpawningSphereRenderer.java
Performance improvements
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / client / renderers / SpawningSphereRenderer.java
index 63080aeaaf40fd9d37af6c70a9b1cf53e10f7a03..2d543fdf3e0d3f806d49854b6dd6ccb04fc60c3d 100644 (file)
@@ -5,52 +5,55 @@ import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper;
 import com.irtimaled.bbor.client.config.ColorHelper;
 import com.irtimaled.bbor.client.config.ConfigManager;
 import com.irtimaled.bbor.client.models.BoundingBoxSpawningSphere;
+import com.irtimaled.bbor.client.models.Point;
 import com.irtimaled.bbor.common.BoundingBoxType;
-import com.irtimaled.bbor.common.models.Point;
-import net.minecraft.client.resources.I18n;
+import net.minecraft.client.resource.language.I18n;
+import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.util.math.BlockPos;
 
 import java.awt.*;
 
 public class SpawningSphereRenderer extends AbstractRenderer<BoundingBoxSpawningSphere> {
     @Override
-    public void render(BoundingBoxSpawningSphere boundingBox) {
+    public void render(MatrixStack matrixStack, BoundingBoxSpawningSphere boundingBox) {
         Point point = boundingBox.getPoint();
         OffsetPoint sphereCenter = new OffsetPoint(point);
 
-        OffsetBox offsetBox = new OffsetBox(sphereCenter, sphereCenter).grow(0.5, 0, 0.5);
         Color safeAreaColor = ColorHelper.getColor(ConfigManager.colorAFKSpheresSafeArea);
-        renderCuboid(offsetBox, safeAreaColor);
+        renderSphere(matrixStack, point, BoundingBoxSpawningSphere.SAFE_RADIUS, safeAreaColor);
+
+        renderOuterSphere(matrixStack, boundingBox, point);
+
+        OffsetBox offsetBox = new OffsetBox(sphereCenter, sphereCenter).grow(0.5, 0, 0.5);
+        renderCuboid(matrixStack, offsetBox, safeAreaColor, false, 30);
 
         Integer spawnableSpacesCount = boundingBox.getSpawnableSpacesCount();
         if (spawnableSpacesCount != null) {
-            renderText(sphereCenter, I18n.format("bbor.renderer.spawningSphere.spawnable"),
+            renderText(matrixStack, sphereCenter, I18n.translate("bbor.renderer.spawningSphere.spawnable"),
                     spawnableSpacesCount == 0 ?
-                            I18n.format("bbor.renderer.spawningSphere.none") :
+                            I18n.translate("bbor.renderer.spawningSphere.none") :
                             String.format("%,d", spawnableSpacesCount));
         }
-
-        renderSphere(point, BoundingBoxSpawningSphere.SAFE_RADIUS, safeAreaColor, 5, 5);
-
-        renderOuterSphere(boundingBox, point);
+        renderSphere(matrixStack, point, BoundingBoxSpawningSphere.SAFE_RADIUS, safeAreaColor);
 
         if (ConfigManager.renderAFKSpawnableBlocks.get() && boundingBox.isWithinSphere(Player.getPoint())) {
-            renderSpawnableSpaces(boundingBox);
+            renderSpawnableSpaces(matrixStack, boundingBox);
         }
     }
 
-    private void renderOuterSphere(BoundingBoxSpawningSphere boundingBox, Point point) {
+    private void renderOuterSphere(MatrixStack matrixStack, BoundingBoxSpawningSphere boundingBox, Point point) {
         Color color = BoundingBoxTypeHelper.getColor(boundingBox.getType());
-        renderSphere(point, BoundingBoxSpawningSphere.SPAWN_RADIUS, color, 5, 5);
+        renderSphere(matrixStack, point, BoundingBoxSpawningSphere.SPAWN_RADIUS, color);
     }
 
-    private void renderSpawnableSpaces(BoundingBoxSpawningSphere boundingBox) {
+    private void renderSpawnableSpaces(MatrixStack matrixStack, BoundingBoxSpawningSphere boundingBox) {
         Color color = BoundingBoxTypeHelper.getColor(BoundingBoxType.SpawnableBlocks);
-        boundingBox.getBlocks().forEach(c -> {
+        for (BlockPos c : boundingBox.getBlocks()) {
             int x = c.getX();
             int y = c.getY();
             int z = c.getZ();
             OffsetBox offsetBox = new OffsetBox(x, y, z, x + 1, y, z + 1);
-            renderCuboid(offsetBox, color);
-        });
+            renderCuboid(matrixStack, offsetBox, color, false, 30);
+        }
     }
 }