1 package com.irtimaled.bbor.client;
3 import com.irtimaled.bbor.client.renderers.*;
4 import com.irtimaled.bbor.common.models.*;
5 import com.irtimaled.bbor.config.ConfigManager;
6 import net.minecraft.world.DimensionType;
7 import org.lwjgl.opengl.GL11;
9 import java.util.HashMap;
13 public class ClientRenderer {
14 private final ClientBoundingBoxProvider clientBoundingBoxProvider;
15 private static final Map<Class<? extends BoundingBox>, Renderer> boundingBoxRendererMap = new HashMap<>();
17 ClientRenderer(ClientDimensionCache dimensionCache) {
18 this.clientBoundingBoxProvider = new ClientBoundingBoxProvider(dimensionCache);
19 boundingBoxRendererMap.put(BoundingBoxVillage.class, new VillageRenderer());
20 boundingBoxRendererMap.put(BoundingBoxSlimeChunk.class, new SlimeChunkRenderer());
21 boundingBoxRendererMap.put(BoundingBoxWorldSpawn.class, new WorldSpawnRenderer());
22 boundingBoxRendererMap.put(BoundingBoxStructure.class, new StructureRenderer());
25 public void render(DimensionType dimensionType, Boolean outerBoxesOnly) {
26 Set<BoundingBox> boundingBoxes = clientBoundingBoxProvider.getBoundingBoxes(dimensionType, outerBoxesOnly);
27 if (boundingBoxes == null || boundingBoxes.size() == 0)
30 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
31 GL11.glLineWidth(2.0f);
32 GL11.glDisable(GL11.GL_TEXTURE_2D);
33 GL11.glDisable(GL11.GL_CULL_FACE);
35 if (ConfigManager.alwaysVisible.getBoolean()) {
36 GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
38 for (BoundingBox bb : boundingBoxes) {
39 Renderer renderer = boundingBoxRendererMap.get(bb.getClass());
40 if (renderer != null) {
45 GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
46 GL11.glEnable(GL11.GL_CULL_FACE);
47 GL11.glEnable(GL11.GL_TEXTURE_2D);