1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
package de.hysky.skyblocker.utils.waypoint;
import de.hysky.skyblocker.utils.render.RenderHelper;
import de.hysky.skyblocker.utils.render.Renderable;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import java.util.function.Supplier;
public class Waypoint implements Renderable {
protected static final float DEFAULT_HIGHLIGHT_ALPHA = 0.5f;
protected static final float DEFAULT_LINE_WIDTH = 5f;
public final BlockPos pos;
final Box box;
final Supplier<Type> typeSupplier;
protected final float[] colorComponents;
final float alpha;
final float lineWidth;
final boolean throughWalls;
private boolean shouldRender;
public Waypoint(BlockPos pos, Type type, float[] colorComponents) {
this(pos, type, colorComponents, DEFAULT_HIGHLIGHT_ALPHA);
}
public Waypoint(BlockPos pos, Supplier<Type> typeSupplier, float[] colorComponents) {
this(pos, typeSupplier, colorComponents, DEFAULT_HIGHLIGHT_ALPHA, DEFAULT_LINE_WIDTH);
}
public Waypoint(BlockPos pos, Type type, float[] colorComponents, float alpha) {
this(pos, () -> type, colorComponents, alpha, DEFAULT_LINE_WIDTH);
}
public Waypoint(BlockPos pos, Supplier<Type> typeSupplier, float[] colorComponents, float alpha, float lineWidth) {
this(pos, typeSupplier, colorComponents, alpha, lineWidth, true);
}
public Waypoint(BlockPos pos, Supplier<Type> typeSupplier, float[] colorComponents, boolean throughWalls) {
this(pos, typeSupplier, colorComponents, DEFAULT_HIGHLIGHT_ALPHA, DEFAULT_LINE_WIDTH, throughWalls);
}
public Waypoint(BlockPos pos, Supplier<Type> typeSupplier, float[] colorComponents, float alpha, float lineWidth, boolean throughWalls) {
this(pos, typeSupplier, colorComponents, alpha, lineWidth, throughWalls, true);
}
public Waypoint(BlockPos pos, Supplier<Type> typeSupplier, float[] colorComponents, float alpha, float lineWidth, boolean throughWalls, boolean shouldRender) {
this.pos = pos;
this.box = new Box(pos);
this.typeSupplier = typeSupplier;
this.colorComponents = colorComponents;
this.alpha = alpha;
this.lineWidth = lineWidth;
this.throughWalls = throughWalls;
this.shouldRender = shouldRender;
}
public boolean shouldRender() {
return shouldRender;
}
public void setFound() {
this.shouldRender = false;
}
public void setMissing() {
this.shouldRender = true;
}
public void toggle() {
this.shouldRender = !this.shouldRender;
}
protected float[] getColorComponents() {
return colorComponents;
}
@Override
public void render(WorldRenderContext context) {
switch (typeSupplier.get()) {
case WAYPOINT -> RenderHelper.renderFilledWithBeaconBeam(context, pos, getColorComponents(), alpha, throughWalls);
case OUTLINED_WAYPOINT -> {
float[] colorComponents = getColorComponents();
RenderHelper.renderFilledWithBeaconBeam(context, pos, colorComponents, alpha, throughWalls);
RenderHelper.renderOutline(context, box, colorComponents, lineWidth, throughWalls);
}
case HIGHLIGHT -> RenderHelper.renderFilled(context, pos, getColorComponents(), alpha, throughWalls);
case OUTLINED_HIGHLIGHT -> {
float[] colorComponents = getColorComponents();
RenderHelper.renderFilled(context, pos, colorComponents, alpha, throughWalls);
RenderHelper.renderOutline(context, box, colorComponents, lineWidth, throughWalls);
}
case OUTLINE -> RenderHelper.renderOutline(context, box, getColorComponents(), lineWidth, throughWalls);
}
}
public enum Type {
WAYPOINT,
OUTLINED_WAYPOINT,
HIGHLIGHT,
OUTLINED_HIGHLIGHT,
OUTLINE;
@Override
public String toString() {
return switch (this) {
case WAYPOINT -> "Waypoint";
case OUTLINED_WAYPOINT -> "Outlined Waypoint";
case HIGHLIGHT -> "Highlight";
case OUTLINED_HIGHLIGHT -> "Outlined Highlight";
case OUTLINE -> "Outline";
};
}
}
}
|