1 package com.irtimaled.bbor.client.renderers;
3 import com.irtimaled.bbor.client.Player;
4 import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper;
5 import com.irtimaled.bbor.client.config.ColorHelper;
6 import com.irtimaled.bbor.client.config.ConfigManager;
7 import com.irtimaled.bbor.client.models.BoundingBoxSpawningSphere;
8 import com.irtimaled.bbor.client.models.Point;
9 import com.irtimaled.bbor.common.BoundingBoxType;
10 import net.minecraft.client.resource.language.I18n;
11 import net.minecraft.client.util.math.MatrixStack;
15 public class SpawningSphereRenderer extends AbstractRenderer<BoundingBoxSpawningSphere> {
17 public void render(MatrixStack matrixStack, BoundingBoxSpawningSphere boundingBox) {
18 Point point = boundingBox.getPoint();
19 OffsetPoint sphereCenter = new OffsetPoint(point);
21 Color safeAreaColor = ColorHelper.getColor(ConfigManager.colorAFKSpheresSafeArea);
22 renderSphere(matrixStack, point, BoundingBoxSpawningSphere.SAFE_RADIUS, safeAreaColor);
24 renderOuterSphere(matrixStack, boundingBox, point);
26 OffsetBox offsetBox = new OffsetBox(sphereCenter, sphereCenter).grow(0.5, 0, 0.5);
27 renderCuboid(matrixStack, offsetBox, safeAreaColor, false, 30);
29 Integer spawnableSpacesCount = boundingBox.getSpawnableSpacesCount();
30 if (spawnableSpacesCount != null) {
31 renderText(matrixStack, sphereCenter, I18n.translate("bbor.renderer.spawningSphere.spawnable"),
32 spawnableSpacesCount == 0 ?
33 I18n.translate("bbor.renderer.spawningSphere.none") :
34 String.format("%,d", spawnableSpacesCount));
36 renderSphere(matrixStack, point, BoundingBoxSpawningSphere.SAFE_RADIUS, safeAreaColor);
38 if (ConfigManager.renderAFKSpawnableBlocks.get() && boundingBox.isWithinSphere(Player.getPoint())) {
39 renderSpawnableSpaces(matrixStack, boundingBox);
43 private void renderOuterSphere(MatrixStack matrixStack, BoundingBoxSpawningSphere boundingBox, Point point) {
44 Color color = BoundingBoxTypeHelper.getColor(boundingBox.getType());
45 renderSphere(matrixStack, point, BoundingBoxSpawningSphere.SPAWN_RADIUS, color);
48 private void renderSpawnableSpaces(MatrixStack matrixStack, BoundingBoxSpawningSphere boundingBox) {
49 Color color = BoundingBoxTypeHelper.getColor(BoundingBoxType.SpawnableBlocks);
50 boundingBox.getBlocks().forEach(c -> {
54 OffsetBox offsetBox = new OffsetBox(x, y, z, x + 1, y, z + 1);
55 renderCuboid(matrixStack, offsetBox, color, false, 30);