]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/client/models/BoundingBoxFlowerForest.java
Several fixes
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / client / models / BoundingBoxFlowerForest.java
1 package com.irtimaled.bbor.client.models;
2
3 import com.irtimaled.bbor.client.RenderCulling;
4 import com.irtimaled.bbor.client.config.ColorHelper;
5 import com.irtimaled.bbor.client.config.HexColor;
6 import com.irtimaled.bbor.client.config.Setting;
7 import com.irtimaled.bbor.client.renderers.AbstractRenderer;
8 import com.irtimaled.bbor.client.renderers.FlowerForestRenderer;
9 import com.irtimaled.bbor.common.BoundingBoxType;
10 import com.irtimaled.bbor.common.interop.CommonInterop;
11 import com.irtimaled.bbor.common.models.AbstractBoundingBox;
12 import com.irtimaled.bbor.common.models.Coords;
13
14 import java.awt.*;
15
16 public class BoundingBoxFlowerForest extends AbstractBoundingBox {
17     private static final AbstractRenderer<BoundingBoxFlowerForest> RENDERER = CommonInterop.registerRenderer(BoundingBoxFlowerForest.class, () -> new FlowerForestRenderer());
18
19     private final Coords coords;
20     private final Setting<HexColor> colorSetting;
21
22     public BoundingBoxFlowerForest(Coords coords, Setting<HexColor> colorSetting) {
23         super(BoundingBoxType.FlowerForest);
24         this.coords = coords;
25         this.colorSetting = colorSetting;
26     }
27
28     @Override
29     public Boolean intersectsBounds(int minX, int minZ, int maxX, int maxZ) {
30         return coords.getX() >= minX && coords.getZ() >= minZ && coords.getX() <= maxX && coords.getZ() <= maxZ;
31     }
32
33     public Color getColor() {
34         return ColorHelper.getColor(colorSetting);
35     }
36
37     public Coords getCoords() {
38         return coords;
39     }
40
41     @Override
42     public double getDistanceX(double x) {
43         return x - coords.getX();
44     }
45
46     @Override
47     public double getDistanceY(double y) {
48         return y - coords.getY();
49     }
50
51     @Override
52     public double getDistanceZ(double z) {
53         return z - coords.getZ();
54     }
55
56     @Override
57     public AbstractRenderer<?> getRenderer() {
58         return RENDERER;
59     }
60
61     @Override
62     public boolean isVisibleCulling() {
63         return RenderCulling.isVisibleCulling(coords.getX(), coords.getY() + 0.01d, coords.getZ(), coords.getX() + 1, coords.getY(), coords.getZ() + 1);
64     }
65 }