Sodium update + fog change
This commit is contained in:
21
build.gradle
21
build.gradle
@@ -24,6 +24,21 @@ repositories {
|
||||
includeGroup "maven.modrinth"
|
||||
}
|
||||
}
|
||||
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name "caffeinemcRepository"
|
||||
url "https://maven.caffeinemc.net/snapshots"
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroup "net.caffeinemc"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
maven { url = "https://maven.shedaniel.me/" }
|
||||
maven { url = "https://maven.terraformersmc.com/releases/" }
|
||||
|
||||
@@ -106,7 +121,9 @@ dependencies {
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
|
||||
//TODO: this is to eventually not need sodium installed as atm its just used for parsing shaders
|
||||
modImplementation "maven.modrinth:sodium:mc1.21.11-0.8.0-fabric"
|
||||
//modImplementation "maven.modrinth:sodium:mc1.21.11-0.8.0-fabric"
|
||||
modImplementation "net.caffeinemc:sodium-fabric:0.8.1-SNAPSHOT+mc1.21.11+"
|
||||
|
||||
|
||||
modImplementation("maven.modrinth:lithium:mc1.21.11-0.21.0-fabric")
|
||||
|
||||
@@ -117,7 +134,7 @@ dependencies {
|
||||
modRuntimeOnlyMsk("maven.modrinth:modmenu:17.0.0-alpha.1")
|
||||
|
||||
modCompileOnly("maven.modrinth:iris:1.10.0+1.21.11-fabric")
|
||||
modRuntimeOnlyMsk("maven.modrinth:iris:1.10.0+1.21.11-fabric")
|
||||
//modRuntimeOnlyMsk("maven.modrinth:iris:1.10.0+1.21.11-fabric")
|
||||
|
||||
//modCompileOnly("maven.modrinth:starlight:1.1.3+1.20.4")
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ loader_version=0.18.2
|
||||
loom_version=1.14-SNAPSHOT
|
||||
|
||||
# Fabric API
|
||||
fabric_version=0.139.4+1.21.11
|
||||
fabric_version=0.140.0+1.21.11
|
||||
|
||||
|
||||
# Mod Properties
|
||||
|
||||
@@ -3,9 +3,7 @@ package me.cortex.voxy.client.config;
|
||||
import me.cortex.voxy.common.util.Pair;
|
||||
import net.caffeinemc.mods.sodium.api.config.ConfigState;
|
||||
import net.caffeinemc.mods.sodium.api.config.StorageEventHandler;
|
||||
import net.caffeinemc.mods.sodium.api.config.option.ControlValueFormatter;
|
||||
import net.caffeinemc.mods.sodium.api.config.option.OptionFlag;
|
||||
import net.caffeinemc.mods.sodium.api.config.option.Range;
|
||||
import net.caffeinemc.mods.sodium.api.config.option.*;
|
||||
import net.caffeinemc.mods.sodium.api.config.structure.*;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.contents.TranslatableContents;
|
||||
@@ -144,15 +142,15 @@ public class SodiumConfigBuilder {
|
||||
}
|
||||
|
||||
|
||||
protected BiConsumer<TYPE, TYPE> postRunner;
|
||||
protected String[] postRunnerConflicts;
|
||||
protected String[] postChangeFlags;
|
||||
public OPTION setPostChangeRunner(BiConsumer<TYPE, TYPE> postRunner, String... dontRunIfChangedVars) {
|
||||
protected Consumer<TYPE> postRunner;
|
||||
protected Identifier[] postRunnerConflicts;
|
||||
protected Identifier[] postChangeFlags;
|
||||
public OPTION setPostChangeRunner(Consumer<TYPE> postRunner, String... dontRunIfChangedVars) {
|
||||
if (this.postChangeFlags != null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
this.postRunner = postRunner;
|
||||
this.postRunnerConflicts = dontRunIfChangedVars;
|
||||
this.postRunnerConflicts = mapIds(dontRunIfChangedVars);
|
||||
return (OPTION) this;
|
||||
}
|
||||
|
||||
@@ -160,7 +158,7 @@ public class SodiumConfigBuilder {
|
||||
if (this.postRunner != null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
this.postChangeFlags = flags;
|
||||
this.postChangeFlags = mapIds(flags);
|
||||
return (OPTION) this;
|
||||
}
|
||||
|
||||
@@ -171,54 +169,17 @@ public class SodiumConfigBuilder {
|
||||
option.setName(this.name);
|
||||
option.setTooltip(this.tooltip);
|
||||
|
||||
Consumer<TYPE> setter = this.setter;
|
||||
if (this.postRunner != null) {
|
||||
var pSetter = setter;
|
||||
var getter = this.getter;
|
||||
Object[] oldValue = new Object[1];
|
||||
var id = Identifier.parse(this.id).getPath();
|
||||
var flagAdder = ctx.addFlag;
|
||||
setter = v->{
|
||||
oldValue[0] = getter.get();
|
||||
pSetter.accept(v);
|
||||
flagAdder.accept(id);
|
||||
};
|
||||
var id = Identifier.parse(this.id);
|
||||
var runner = this.postRunner;
|
||||
ctx.postRunner.register(id, ()->{
|
||||
var old = (TYPE) oldValue[0];
|
||||
var cur = getter.get();
|
||||
if (old != cur) {
|
||||
runner.accept(old, cur);
|
||||
}
|
||||
oldValue[0] = null;
|
||||
}, this.postRunnerConflicts);
|
||||
var getter = this.getter;
|
||||
ctx.postRunner.register(id, ()->runner.accept(getter.get()), this.postRunnerConflicts);
|
||||
option.setFlags(id);
|
||||
} else if (this.postChangeFlags != null) {
|
||||
List<String> flags = new ArrayList<>();
|
||||
List<OptionFlag> oFlags = new ArrayList<>();
|
||||
for (var flag : this.postChangeFlags) {
|
||||
if (flag.equalsIgnoreCase("RENDERER_RELOAD")) {
|
||||
oFlags.add(OptionFlag.REQUIRES_RENDERER_RELOAD);
|
||||
}
|
||||
flags.add(flag);
|
||||
option.setFlags(this.postChangeFlags);
|
||||
}
|
||||
|
||||
option.setFlags(oFlags.toArray(OptionFlag[]::new));
|
||||
|
||||
if (!flags.isEmpty()) {
|
||||
var pSetter = setter;
|
||||
var flagAdder = ctx.addFlag;
|
||||
var sflags = flags.toArray(new String[0]);
|
||||
setter = v -> {
|
||||
pSetter.accept(v);
|
||||
for (var flag : sflags) {
|
||||
flagAdder.accept(flag);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
option.setBinding(setter, this.getter);
|
||||
option.setBinding(this.setter, this.getter);
|
||||
if (this.enabler != null) {
|
||||
var pred = this.enabler.tester;
|
||||
option.setEnabledProvider(s->pred.test(s), this.enabler.dependencies);
|
||||
@@ -263,7 +224,7 @@ public class SodiumConfigBuilder {
|
||||
if (this.rangeDependencies == null || this.rangeDependencies.length == 0) {
|
||||
option.setRange(this.rangeProvider.apply(null));
|
||||
} else {
|
||||
option.setRangeProvider(this.rangeProvider, mapIds(this.rangeDependencies));
|
||||
option.setRangeProvider((Function<ConfigState, SteppedValidator>)(Object) this.rangeProvider, mapIds(this.rangeDependencies));
|
||||
}
|
||||
option.setValueFormatter(this.formatter);
|
||||
return option;
|
||||
@@ -298,70 +259,67 @@ public class SodiumConfigBuilder {
|
||||
}
|
||||
|
||||
|
||||
public static class PostApplyOps {
|
||||
private Map<String, Set<String>> conflicts = new LinkedHashMap<>();
|
||||
private Map<String, Runnable> executors = new LinkedHashMap<>();
|
||||
private LinkedHashSet<String> localFlagChanges = new LinkedHashSet<>();
|
||||
public static class PostApplyOps implements FlagHook {
|
||||
private record Hook(Identifier name, Runnable runnable, Set<Identifier> conflicts) {}
|
||||
private Map<Identifier, Hook> hooks = new LinkedHashMap<>();
|
||||
|
||||
public void register(String name, Runnable postRunner, String... conflicts) {
|
||||
this.conflicts.put(name, new LinkedHashSet<>(List.of(conflicts)));
|
||||
this.executors.put(name, postRunner);
|
||||
public PostApplyOps register(String name, Runnable postRunner, String... conflicts) {
|
||||
return this.register(Identifier.parse(name), postRunner, mapIds(conflicts));
|
||||
}
|
||||
|
||||
protected void build() {
|
||||
public PostApplyOps register(Identifier name, Runnable postRunner, Identifier... conflicts) {
|
||||
this.hooks.put(name, new Hook(name, postRunner, new LinkedHashSet<>(List.of(conflicts))));
|
||||
return this;
|
||||
}
|
||||
|
||||
protected PostApplyOps build() {
|
||||
boolean changed = false;
|
||||
do {
|
||||
changed = false;
|
||||
for (var value : this.conflicts.values()) {
|
||||
for (var ref : new LinkedHashSet<>(value)) {
|
||||
changed |= value.addAll(this.conflicts.getOrDefault(ref, Collections.EMPTY_SET));
|
||||
for (var hook : this.hooks.values()) {
|
||||
for (var ref : new LinkedHashSet<>(hook.conflicts)) {
|
||||
var other = this.hooks.getOrDefault(ref, null);
|
||||
if (other != null) {
|
||||
changed |= hook.conflicts.addAll(other.conflicts);
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (changed);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void addFlag(String flag) {
|
||||
this.localFlagChanges.add(flag);
|
||||
@Override
|
||||
public Collection<Identifier> getTriggers() {
|
||||
return this.hooks.keySet();
|
||||
}
|
||||
|
||||
protected void run() {
|
||||
if (this.localFlagChanges.isEmpty()) return;
|
||||
var original = new HashSet<>(this.localFlagChanges);
|
||||
var iter = this.localFlagChanges.iterator();
|
||||
while (iter.hasNext()) {
|
||||
var flag = iter.next();
|
||||
if (!Collections.disjoint(this.conflicts.getOrDefault(flag, Collections.EMPTY_SET), original)) {
|
||||
iter.remove();
|
||||
@Override
|
||||
public void accept(Collection<Identifier> identifiers, ConfigState configState) {
|
||||
for (var id : identifiers) {
|
||||
var hook = this.hooks.get(id);
|
||||
if (hook != null) {
|
||||
if (Collections.disjoint(identifiers, hook.conflicts)) {
|
||||
hook.runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
for (var flag : this.localFlagChanges) {
|
||||
var exec = this.executors.get(flag);
|
||||
if (exec != null) exec.run();
|
||||
}
|
||||
|
||||
this.localFlagChanges.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final class BuildCtx {
|
||||
public PostApplyOps postRunner = new PostApplyOps();
|
||||
public Consumer<String> addFlag = this.postRunner::addFlag;
|
||||
public StorageEventHandler saveHandler;
|
||||
}
|
||||
|
||||
public static void buildToSodium(ConfigBuilder builder, ModOptionsBuilder options, Runnable saveHandler, Consumer<PostApplyOps> registerOps, Page... pages) {
|
||||
public static void buildToSodium(ConfigBuilder builder, ModOptionsBuilder options, StorageEventHandler saveHandler, Consumer<PostApplyOps> registerOps, Page... pages) {
|
||||
var ctx = new BuildCtx();
|
||||
registerOps.accept(ctx.postRunner);
|
||||
var post = ctx.postRunner;
|
||||
ctx.saveHandler = ()->{
|
||||
saveHandler.run();
|
||||
post.run();
|
||||
};
|
||||
ctx.saveHandler = saveHandler;
|
||||
for (var page : pages) {
|
||||
options.addPage(page.create(builder, ctx));
|
||||
}
|
||||
post.build();
|
||||
options.registerFlagHook(ctx.postRunner.build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ public class VoxyConfig {
|
||||
public int sectionRenderDistance = 16;
|
||||
public int serviceThreads = (int) Math.max(CpuLayout.getCoreCount()/1.5, 1);
|
||||
public float subDivisionSize = 64;
|
||||
public boolean renderVanillaFog = false;
|
||||
public boolean useEnvironmentalFog = false;
|
||||
public boolean useRenderFog = false;
|
||||
public boolean useEnvironmentalFog = true;
|
||||
public boolean dontUseSodiumBuilderThreads = false;
|
||||
|
||||
private static VoxyConfig loadOrCreate() {
|
||||
|
||||
@@ -25,12 +25,12 @@ public class VoxyConfigMenu implements ConfigEntryPoint {
|
||||
.setIcon(Identifier.parse("voxy:icon.png"));
|
||||
|
||||
SodiumConfigBuilder.buildToSodium(B, cc, CFG::save, postOp->{
|
||||
postOp.register("updateThreads", ()->{
|
||||
postOp.register("voxy:update_threads", ()->{
|
||||
var instance = VoxyCommon.getInstance();
|
||||
if (instance != null) {
|
||||
instance.updateDedicatedThreads();
|
||||
}
|
||||
}, "enabled");
|
||||
}, "voxy:enabled");
|
||||
},
|
||||
new Page(Component.translatable("voxy.config.general"),
|
||||
new Group(
|
||||
@@ -38,7 +38,7 @@ public class VoxyConfigMenu implements ConfigEntryPoint {
|
||||
"voxy:enabled",
|
||||
Component.translatable("voxy.config.general.enabled"),
|
||||
()->CFG.enabled, v->CFG.enabled=v)
|
||||
.setPostChangeRunner((p,c)->{
|
||||
.setPostChangeRunner(c->{
|
||||
if (c) {
|
||||
if (VoxyClientInstance.isInGame) {
|
||||
VoxyCommon.createInstance();
|
||||
@@ -61,12 +61,12 @@ public class VoxyConfigMenu implements ConfigEntryPoint {
|
||||
Component.translatable("voxy.config.general.serviceThreads"),
|
||||
()->CFG.serviceThreads, v->CFG.serviceThreads=v,
|
||||
new Range(1, CpuLayout.getCoreCount(), 1))
|
||||
.setPostChangeFlags("updateThreads"),
|
||||
.setPostChangeFlags("voxy:update_threads"),
|
||||
new BoolOption(
|
||||
"voxy:use_sodium_threads",
|
||||
Component.translatable("voxy.config.general.useSodiumBuilder"),
|
||||
()->!CFG.dontUseSodiumBuilderThreads, v->CFG.dontUseSodiumBuilderThreads=!v)
|
||||
.setPostChangeFlags("updateThreads")
|
||||
.setPostChangeFlags("voxy:update_threads")
|
||||
), new Group(
|
||||
new BoolOption(
|
||||
"voxy:ingest_enabled",
|
||||
@@ -80,7 +80,7 @@ public class VoxyConfigMenu implements ConfigEntryPoint {
|
||||
"voxy:rendering",
|
||||
Component.translatable("voxy.config.general.rendering"),
|
||||
()->CFG.enableRendering, v->CFG.enableRendering=v)
|
||||
.setPostChangeRunner((p,c)->{
|
||||
.setPostChangeRunner(c->{
|
||||
var vrsh = (IGetVoxyRenderSystem)Minecraft.getInstance().levelRenderer;
|
||||
if (vrsh != null) {
|
||||
if (c) {
|
||||
@@ -89,7 +89,7 @@ public class VoxyConfigMenu implements ConfigEntryPoint {
|
||||
vrsh.shutdownRenderer();
|
||||
}
|
||||
}
|
||||
},"enabled", "renderer_reload")
|
||||
},"voxy:enabled", "voxy:renderer_reload")
|
||||
.setEnabler("voxy:enabled")
|
||||
), new Group(
|
||||
new IntOption(
|
||||
@@ -104,7 +104,7 @@ public class VoxyConfigMenu implements ConfigEntryPoint {
|
||||
()->CFG.sectionRenderDistance, v->CFG.sectionRenderDistance=v,
|
||||
new Range(2, 64, 1))
|
||||
.setFormatter(v->Component.literal(Integer.toString(v*32)))//Top level rd == 32 chunks
|
||||
.setPostChangeRunner((p,c)->{
|
||||
.setPostChangeRunner(c->{
|
||||
var vrsh = (IGetVoxyRenderSystem)Minecraft.getInstance().levelRenderer;
|
||||
if (vrsh != null) {
|
||||
var vrs = vrsh.getVoxyRenderSystem();
|
||||
@@ -112,19 +112,25 @@ public class VoxyConfigMenu implements ConfigEntryPoint {
|
||||
vrs.setRenderDistance(c);
|
||||
}
|
||||
}
|
||||
}, "rendering", "renderer_reload")
|
||||
}, "voxy:rendering", "voxy:renderer_reload")
|
||||
), new Group(
|
||||
new BoolOption(
|
||||
"voxy:eviromental_fog",
|
||||
Component.translatable("voxy.config.general.environmental_fog"),
|
||||
()->CFG.useEnvironmentalFog, v->CFG.useEnvironmentalFog=v)
|
||||
.setPostChangeFlags("renderer_reload")
|
||||
.setPostChangeFlags(OptionFlag.REQUIRES_RENDERER_RELOAD.getId().toString())
|
||||
), new Group(
|
||||
new BoolOption(
|
||||
"voxy:render_distance_fog",
|
||||
Component.translatable("voxy.config.general.vanilla_fog"),
|
||||
()->CFG.useRenderFog, v->CFG.useRenderFog=v)
|
||||
.setPostChangeFlags(OptionFlag.REQUIRES_RENDERER_RELOAD.getId().toString())
|
||||
), new Group(
|
||||
new BoolOption(
|
||||
"voxy:render_debug",
|
||||
Component.translatable("voxy.config.general.render_statistics"),
|
||||
()-> RenderStatistics.enabled, v->RenderStatistics.enabled=v)
|
||||
.setPostChangeFlags("renderer_reload"))
|
||||
.setPostChangeFlags(OptionFlag.REQUIRES_RENDERER_RELOAD.getId().toString()))
|
||||
).setEnablerAND("voxy:enabled", "voxy:rendering"));
|
||||
|
||||
}
|
||||
|
||||
@@ -22,13 +22,15 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public class MixinFogRenderer {
|
||||
@Inject(method = "setupFog", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;getDevice()Lcom/mojang/blaze3d/systems/GpuDevice;", remap = false))
|
||||
private void voxy$modifyFog(Camera camera, int rdInt, DeltaTracker tracker, float pTick, ClientLevel lvl, CallbackInfoReturnable<Vector4f> cir, @Local(type=FogData.class) FogData data) {
|
||||
if (VoxyConfig.CONFIG.renderVanillaFog) {
|
||||
if (!(VoxyConfig.CONFIG.useRenderFog||VoxyConfig.CONFIG.useEnvironmentalFog)) {
|
||||
return;
|
||||
}
|
||||
var vrs = IGetVoxyRenderSystem.getNullable();
|
||||
if (vrs == null) return;
|
||||
if (!VoxyConfig.CONFIG.useRenderFog) {
|
||||
data.renderDistanceStart = 999999999;
|
||||
data.renderDistanceEnd = 999999999;
|
||||
}
|
||||
if (!VoxyConfig.CONFIG.useEnvironmentalFog) {
|
||||
data.environmentalStart = 99999999;
|
||||
data.environmentalEnd = 99999999;
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = VideoSettingsScreen.class, remap = false)
|
||||
public abstract class MixinVideoSettingsScreen implements IConfigPageSetter {
|
||||
@Shadow public abstract void jumpToPage(OptionPage page);
|
||||
@Shadow public abstract void jumpToPage(Page page);
|
||||
|
||||
@Shadow protected abstract void onSectionFocused(Page page);
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
"voxy.config.general.environmental_fog": "Enable environmental fog",
|
||||
"voxy.config.general.environmental_fog.tooltip": "Enables or disables voxy rendering environmental fog",
|
||||
|
||||
"voxy.config.general.vanilla_fog": "Enable vanilla fog",
|
||||
"voxy.config.general.vanilla_fog.tooltip": "Enables or disables vanilla fog effect",
|
||||
"voxy.config.general.render_fog": "Enable render fog",
|
||||
"voxy.config.general.render_fog.tooltip": "Enables or disables render fog effect",
|
||||
|
||||
"voxy.config.general.render_statistics": "Enable render statistics",
|
||||
"voxy.config.general.render_statistics.tooltip": "Enable render statistics in F3 menu, useful for debugging"
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
"minecraft": ["1.21.11"],
|
||||
"fabricloader": ">=0.14.22",
|
||||
"fabric-api": ">=0.91.1",
|
||||
"sodium": "=0.8.*"
|
||||
"sodium": "=0.8.1"
|
||||
},
|
||||
"accessWidener": "voxy.accesswidener"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user