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;
12 import net.minecraft.util.math.BlockPos;
16 public class SpawningSphereRenderer extends AbstractRenderer<BoundingBoxSpawningSphere> {
18 public void render(MatrixStack matrixStack, BoundingBoxSpawningSphere boundingBox) {
19 Point point = boundingBox.getPoint();
20 OffsetPoint sphereCenter = new OffsetPoint(point);
22 Color safeAreaColor = ColorHelper.getColor(ConfigManager.colorAFKSpheresSafeArea);
23 renderSphere(matrixStack, point, BoundingBoxSpawningSphere.SAFE_RADIUS, safeAreaColor);
25 renderOuterSphere(matrixStack, boundingBox, point);
27 OffsetBox offsetBox = new OffsetBox(sphereCenter, sphereCenter).grow(0.5, 0, 0.5);
28 renderCuboid(matrixStack, offsetBox, safeAreaColor, false, 30);
30 Integer spawnableSpacesCount = boundingBox.getSpawnableSpacesCount();
31 if (spawnableSpacesCount != null) {
32 renderText(matrixStack, sphereCenter, I18n.translate("bbor.renderer.spawningSphere.spawnable"),
33 spawnableSpacesCount == 0 ?
34 I18n.translate("bbor.renderer.spawningSphere.none") :
35 String.format("%,d", spawnableSpacesCount));
37 renderSphere(matrixStack, point, BoundingBoxSpawningSphere.SAFE_RADIUS, safeAreaColor);
39 if (ConfigManager.renderAFKSpawnableBlocks.get() && boundingBox.isWithinSphere(Player.getPoint())) {
40 renderSpawnableSpaces(matrixStack, boundingBox);
44 private void renderOuterSphere(MatrixStack matrixStack, BoundingBoxSpawningSphere boundingBox, Point point) {
45 Color color = BoundingBoxTypeHelper.getColor(boundingBox.getType());
46 renderSphere(matrixStack, point, BoundingBoxSpawningSphere.SPAWN_RADIUS, color);
49 private void renderSpawnableSpaces(MatrixStack matrixStack, BoundingBoxSpawningSphere boundingBox) {
50 Color color = BoundingBoxTypeHelper.getColor(BoundingBoxType.SpawnableBlocks);
51 for (BlockPos c : boundingBox.getBlocks()) {
55 OffsetBox offsetBox = new OffsetBox(x, y, z, x + 1, y, z + 1);
56 renderCuboid(matrixStack, offsetBox, color, false, 30);