-
Notifications
You must be signed in to change notification settings - Fork 308
Expand file tree
/
Copy pathOptions.java
More file actions
225 lines (216 loc) · 12.1 KB
/
Options.java
File metadata and controls
225 lines (216 loc) · 12.1 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
package net.vulkanmod.config;
import com.mojang.blaze3d.platform.Window;
import net.minecraft.client.*;
import net.minecraft.network.chat.Component;
import net.vulkanmod.Initializer;
import net.vulkanmod.vulkan.Renderer;
public class Options {
static net.minecraft.client.Options minecraftOptions = Minecraft.getInstance().options;
static Config config = Initializer.CONFIG;
static Window window = Minecraft.getInstance().getWindow();
public static boolean fullscreenDirty = false;
public static Option<?>[] getVideoOpts() {
return new Option[] {
new CyclingOption<>("Resolution",
VideoResolution.getVideoResolutions(),
resolution -> Component.literal(resolution.toString()),
(value) -> {
config.resolution = value;
fullscreenDirty = true;
},
() -> config.resolution)
.setTooltip(Component.literal("Only works on fullscreen")),
new SwitchOption("Windowed Fullscreen",
value -> {
config.windowedFullscreen = value;
fullscreenDirty = true;
},
() -> config.windowedFullscreen)
.setTooltip(Component.nullToEmpty("Might not work properly")),
new SwitchOption("Fullscreen",
value -> {
minecraftOptions.fullscreen().set(value);
// window.toggleFullScreen();
fullscreenDirty = true;
},
() -> minecraftOptions.fullscreen().get()),
new RangeOption("Max Framerate", 10, 260, 10,
value -> value == 260 ? "Unlimited" : String.valueOf(value),
value -> {
minecraftOptions.framerateLimit().set(value);
window.setFramerateLimit(value);
},
() -> minecraftOptions.framerateLimit().get()),
new SwitchOption("VSync",
value -> {
minecraftOptions.enableVsync().set(value);
Minecraft.getInstance().getWindow().updateVsync(value);
},
() -> minecraftOptions.enableVsync().get()),
new CyclingOption<>("Gui Scale",
new Integer[]{0, 1, 2, 3, 4},
value -> value == 0 ? Component.literal("Auto") : Component.literal(value.toString()),
(value) -> {
minecraftOptions.guiScale().set(value);
Minecraft.getInstance().resizeDisplay();
},
() -> minecraftOptions.guiScale().get()),
new RangeOption("Brightness", 0, 100, 1,
value -> {
if(value == 0) return Component.translatable("options.gamma.min").getString();
else if(value == 50) return Component.translatable("options.gamma.default").getString();
else if(value == 100) return Component.translatable("options.gamma.max").getString();
return value.toString();
},
value -> minecraftOptions.gamma().set(value * 0.01),
() -> (int) (minecraftOptions.gamma().get() * 100.0)),
new SwitchOption("Smooth Lighting",
value -> minecraftOptions.ambientOcclusion().set(value),
() -> minecraftOptions.ambientOcclusion().get()),
new SwitchOption("View Bobbing",
(value) -> minecraftOptions.bobView().set(value),
() -> minecraftOptions.bobView().get()),
new CyclingOption<>("Attack Indicator",
AttackIndicatorStatus.values(),
value -> Component.translatable(value.getKey()),
value -> minecraftOptions.attackIndicator().set(value),
() -> minecraftOptions.attackIndicator().get()),
new SwitchOption("Autosave Indicator",
value -> minecraftOptions.showAutosaveIndicator().set(value),
() -> minecraftOptions.showAutosaveIndicator().get()),
new RangeOption("Distortion Effects", 0, 100, 1,
value -> minecraftOptions.screenEffectScale().set(value * 0.01),
() -> (int)(minecraftOptions.screenEffectScale().get() * 100.0f))
.setTooltip(Component.translatable("options.screenEffectScale.tooltip")),
new RangeOption("FOV Effects", 0, 100, 1,
value -> minecraftOptions.fovEffectScale().set(value * 0.01),
() -> (int)(minecraftOptions.fovEffectScale().get() * 100.0f))
.setTooltip(Component.translatable("options.fovEffectScale.tooltip"))
};
}
public static Option<?>[] getGraphicsOpts() {
return new Option[] {
new CyclingOption<>("Graphics",
new GraphicsStatus[]{GraphicsStatus.FAST, GraphicsStatus.FANCY},
graphicsMode -> Component.translatable(graphicsMode.getKey()),
value -> minecraftOptions.graphicsMode().set(value),
() -> minecraftOptions.graphicsMode().get()
),
new RangeOption("Biome Blend Radius", 0, 7, 1,
value -> {
int v = value * 2 + 1;
return v + " x " + v;
},
(value) -> {
minecraftOptions.biomeBlendRadius().set(value);
Minecraft.getInstance().levelRenderer.allChanged();
},
() -> minecraftOptions.biomeBlendRadius().get()),
new CyclingOption<>("Chunk Builder Mode",
PrioritizeChunkUpdates.values(),
value -> Component.translatable(value.getKey()),
value -> minecraftOptions.prioritizeChunkUpdates().set(value),
() -> minecraftOptions.prioritizeChunkUpdates().get()),
new RangeOption("Render Distance", 2, 32, 1,
(value) -> {
minecraftOptions.renderDistance().set(value);
Minecraft.getInstance().levelRenderer.needsUpdate();
},
() -> minecraftOptions.renderDistance().get()),
new RangeOption("Simulation Distance", 5, 32, 1,
(value) -> {
minecraftOptions.simulationDistance().set(value);
},
() -> minecraftOptions.simulationDistance().get()),
new CyclingOption<>("Clouds",
CloudStatus.values(),
value -> Component.translatable(value.getKey()),
value -> minecraftOptions.cloudStatus().set(value),
() -> minecraftOptions.cloudStatus().get()),
new SwitchOption("Entity Shadows",
value -> minecraftOptions.entityShadows().set(value),
() -> minecraftOptions.entityShadows().get()),
new RangeOption("Entity Distance", 50, 500, 25,
value -> minecraftOptions.entityDistanceScaling().set(value * 0.01),
() -> minecraftOptions.entityDistanceScaling().get().intValue() * 100),
new CyclingOption<>("Particles",
new ParticleStatus[]{ParticleStatus.MINIMAL, ParticleStatus.DECREASED, ParticleStatus.ALL},
particlesMode -> Component.translatable(particlesMode.getKey()),
value -> minecraftOptions.particles().set(value),
() -> minecraftOptions.particles().get()),
new SwitchOption("Unique opaque layer",
value -> {
config.uniqueOpaqueLayer = value;
Minecraft.getInstance().levelRenderer.allChanged();
},
() -> config.uniqueOpaqueLayer)
.setTooltip(Component.nullToEmpty("""
Improves performance by using a unique render layer for opaque terrain rendering.
It changes distant grass aspect and may cause unexpected texture behaviour""")),
new CyclingOption<>("Mipmap Levels",
new Integer[]{0, 1, 2, 3, 4},
value -> Component.nullToEmpty(value.toString()),
value -> {
minecraftOptions.mipmapLevels().set(value);
Minecraft.getInstance().delayTextureReload();
},
() -> minecraftOptions.mipmapLevels().get())
};
}
public static Option<?>[] getOtherOpts() {
return new Option[] {
new RangeOption("Queue Frames", 2,
5, 1,
value -> {
config.frameQueueSize = value;
Renderer.scheduleSwapChainUpdate();
}, () -> config.frameQueueSize)
.setTooltip(Component.nullToEmpty("""
Sets the number of queue frames""")),
new SwitchOption("Gui Optimizations",
value -> config.guiOptimizations = value,
() -> config.guiOptimizations)
.setTooltip(Component.nullToEmpty("""
Enable Gui optimizations (Stats bar, Chat, Debug Hud)
Might break mod compatibility
Restart is needed to take effect""")),
new CyclingOption<>("Advanced Chunk Culling",
new Integer[]{1, 2, 3, 10},
value -> {
String t = switch (value) {
case 1 -> "Aggressive";
case 2 -> "Normal";
case 3 -> "Conservative";
case 10 -> "Off";
default -> "Unk";
};
return Component.nullToEmpty(t);
},
value -> config.advCulling = value,
() -> config.advCulling)
.setTooltip(Component.nullToEmpty("""
Use a culling algorithm that might improve performance by
reducing the number of non visible chunk sections rendered.
""")),
new SwitchOption("Entity Culling",
value -> config.entityCulling = value,
() -> config.entityCulling)
.setTooltip(Component.nullToEmpty("""
Enables culling for entities on non visible sections.""")),
new SwitchOption("Indirect Draw",
value -> config.indirectDraw = value,
() -> config.indirectDraw)
.setTooltip(Component.nullToEmpty("""
Reduces CPU overhead but increases GPU overhead.
Enabling it might help in CPU limited systems."""))
};
}
public static void applyOptions(Config config, Option<?>[][] optionPages) {
for(Option<?>[] options : optionPages) {
for(Option<?> option : options) {
option.apply();
}
}
config.write();
}
}