Skip to content

Commit

Permalink
Update embeddium hack (#80)
Browse files Browse the repository at this point in the history
* Remove Embeddium Hack

* Since there is no API for cloud rendering, we will temporarily hack the embeddium.

* remove version lock

* add version lock

* Update hack

* Clean

---------

Co-authored-by: dima_dencep <[email protected]>
  • Loading branch information
Takkkom and dima-dencep authored Jul 4, 2024
1 parent 6289b93 commit a26e4c6
Show file tree
Hide file tree
Showing 12 changed files with 252 additions and 135 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ loom.platform = neoforge
loader_version=21.0.38-beta

# Mod Properties
mod_version=0.5.7
mod_version=0.5.7a
maven_group=com.github.dima_dencep.mods
archives_base_name=rubidium-extra

# Dependencies
nanoliveconfig_version=2.2.0
oculus_version=1.20.1-1.6.9
embeddium_version=1.0.2-git-7f6f509+mc1.21
embeddium_version=1.0.3-git-b2dc012+mc1.21
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package me.flashyreese.mods.sodiumextra.client;

import net.minecraft.client.MinecraftClient;
import org.embeddedt.embeddium.api.render.chunk.RenderSectionDistanceFilter;

public class ExtraRenderSectionDistanceFilter implements RenderSectionDistanceFilter {
public static ExtraRenderSectionDistanceFilter INSTANCE = new ExtraRenderSectionDistanceFilter();

private ExtraRenderSectionDistanceFilter() {

}

@Override
public boolean isWithinDistance(float xDistance, float yDistance, float zDistance, float maxDistance) {
int fogDistance = SodiumExtraClientMod.options().renderSettings.multiDimensionFogControl ?
SodiumExtraClientMod.options().renderSettings.dimensionFogDistanceMap.getOrDefault(MinecraftClient.getInstance().world.getDimension().effects(), 0) :
SodiumExtraClientMod.options().renderSettings.fogDistance;
if (fogDistance == 33)
return ((xDistance * xDistance) + (zDistance * zDistance)) < (maxDistance * maxDistance);
else
return RenderSectionDistanceFilter.DEFAULT.isWithinDistance(xDistance, yDistance, zDistance, maxDistance);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package me.flashyreese.mods.sodiumextra.client;

import static me.flashyreese.mods.sodiumextra.mixin.SodiumExtraMixinConfigPlugin.EMBEDDIUM_HACKED;

import me.flashyreese.mods.sodiumextra.client.gui.EmbeddiumExtendedOptions;
import me.flashyreese.mods.sodiumextra.client.gui.SodiumExtraGameOptionPages;
import me.flashyreese.mods.sodiumextra.client.gui.SodiumExtraGameOptions;
import me.flashyreese.mods.sodiumextra.client.gui.SodiumExtraHud;
import net.caffeinemc.caffeineconfig.CaffeineConfig;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.fml.common.Mod;
Expand All @@ -13,8 +14,8 @@
import org.embeddedt.embeddium.api.OptionGUIConstructionEvent;
import org.embeddedt.embeddium.api.OptionGroupConstructionEvent;
import org.embeddedt.embeddium.api.OptionPageConstructionEvent;
import org.embeddedt.embeddium.api.options.OptionIdentifier;
import org.embeddedt.embeddium.api.options.structure.StandardOptions;
import org.embeddedt.embeddium.api.render.chunk.RenderSectionDistanceFilterEvent;

@Mod(value = SodiumExtraClientMod.MOD_ID, dist = Dist.CLIENT)
public class SodiumExtraClientMod {
Expand Down Expand Up @@ -59,12 +60,12 @@ public static CaffeineConfig mixinConfig() {
.addMixinOption("sky", true)
.addMixinOption("sky_colors", true)
.addMixinOption("sodium", true)
.addMixinOption("sodium.accessibility", true)
.addMixinOption("sodium.fog", true)
.addMixinOption("sodium.cloud", true)
.addMixinOption("sodium.resolution", true)
.addMixinOption("sodium.scrollable_page", true)
.addMixinOption("sodium.vsync", true)
//.addMixinOption("sodium.accessibility", true) in embeddium
// .addMixinOption("sodium.fog", true) via api
.addMixinOption("sodium.cloud", EMBEDDIUM_HACKED)
//.addMixinOption("sodium.resolution", true) via api
//.addMixinOption("sodium.scrollable_page", true) in embeddium
//.addMixinOption("sodium.vsync", true) via api
.addMixinOption("stars", true)
.addMixinOption("steady_debug_hud", true)
.addMixinOption("sun_moon", true)
Expand Down Expand Up @@ -111,9 +112,9 @@ public SodiumExtraClientMod() {
return EmbeddiumExtendedOptions.ADAPTIVE_VSYNC;
});
});
}

public static OptionIdentifier<Void> optionIdentifier(String path) {
return OptionIdentifier.create(MOD_ID, path);
RenderSectionDistanceFilterEvent.BUS.addListener(event -> {
event.setFilter(ExtraRenderSectionDistanceFilter.INSTANCE);
});
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package me.flashyreese.mods.sodiumextra.client.gui;

import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod;
import me.flashyreese.mods.sodiumextra.client.gui.options.control.SliderControlExtended;
import me.flashyreese.mods.sodiumextra.client.gui.options.storage.SodiumExtraOptions;
import me.flashyreese.mods.sodiumextra.common.util.ControlValueFormatterExtended;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.GameOptions;
import net.minecraft.client.util.VideoMode;
import net.minecraft.client.util.Window;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.embeddedt.embeddium.api.options.control.ControlValueFormatter;
import org.embeddedt.embeddium.api.options.control.CyclingControl;
import org.embeddedt.embeddium.api.options.control.SliderControl;
Expand All @@ -26,7 +25,7 @@ public class EmbeddiumExtendedOptions {

public static final Option<?> ADAPTIVE_VSYNC = OptionImpl.createBuilder(SodiumExtraGameOptions.VerticalSyncOption.class, SodiumExtraGameOptionPages.sodiumExtraOpts)
.setName(Text.translatable("options.vsync"))
.setId(Identifier.of(SodiumExtraClientMod.MOD_ID, "vsync"))
.setId(SodiumExtraOptions.Option.ADAPTIVE_VSYNC)
.setTooltip(Text.literal(Text.translatable("sodium.options.v_sync.tooltip").getString() + "\n- " + Text.translatable("sodium-extra.option.use_adaptive_sync.name").getString() + ": " + Text.translatable("sodium-extra.option.use_adaptive_sync.tooltip").getString()))
.setControl((opt) -> new CyclingControl<>(opt, SodiumExtraGameOptions.VerticalSyncOption.class,
SodiumExtraGameOptions.VerticalSyncOption.getAvailableOptions()))
Expand Down Expand Up @@ -59,8 +58,10 @@ public class EmbeddiumExtendedOptions {
.build();

public static final OptionGroup EFFECTS_GROUP = OptionGroup.createBuilder()
.setId(SodiumExtraOptions.Group.EFFECTS)
.add(OptionImpl.createBuilder(int.class, vanillaOpts)
.setName(Text.translatable("options.screenEffectScale"))
.setId(SodiumExtraOptions.Option.SCREEN_EFFECT_SCALE)
.setTooltip(Text.translatable("options.screenEffectScale.tooltip"))
.setControl(option -> new SliderControl(option, 0, 100, 1, ControlValueFormatter.percentage()))
.setBinding((opts, value) -> opts.getDistortionEffectScale().setValue((double) value / 100.0F), (opts) -> Math.toIntExact(Math.round(opts.getDistortionEffectScale().getValue() * 100.0F)))
Expand All @@ -69,6 +70,7 @@ public class EmbeddiumExtendedOptions {
)
.add(OptionImpl.createBuilder(int.class, vanillaOpts)
.setName(Text.translatable("options.fovEffectScale"))
.setId(SodiumExtraOptions.Option.FOV_EFFECT_SCALE)
.setTooltip(Text.translatable("options.fovEffectScale.tooltip"))
.setControl(option -> new SliderControl(option, 0, 100, 1, ControlValueFormatter.percentage()))
.setBinding((opts, value) -> opts.getFovEffectScale().setValue(Math.sqrt(value / 100.0F)), (opts) -> (int) Math.round(Math.pow(opts.getFovEffectScale().getValue(), 2.0D) * 100.0F))
Expand All @@ -78,8 +80,10 @@ public class EmbeddiumExtendedOptions {
.build();

public static final OptionGroup RESOLUTION_GROUP = OptionGroup.createBuilder()
.setId(SodiumExtraOptions.Group.RESOLUTIONS)
.add(OptionImpl.createBuilder(int.class, vanillaOpts)
.setName(Text.translatable("options.fullscreen.resolution"))
.setId(SodiumExtraOptions.Option.RESOLUTION)
.setTooltip(Text.translatable("sodium-extra.option.resolution.tooltip"))
.setControl(option -> new SliderControlExtended(option, 0, window().getMonitor() != null ? window().getMonitor().getVideoModeCount() : 0, 1, ControlValueFormatterExtended.resolution(), false))
.setBinding((options, value) -> {
Expand Down
Loading

0 comments on commit a26e4c6

Please sign in to comment.