Add support for FREX Flawless Frames API (fixes #150)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.replaymod.render.hooks;
|
package com.replaymod.render.hooks;
|
||||||
|
|
||||||
|
import com.replaymod.render.utils.FlawlessFrames;
|
||||||
import net.minecraft.client.render.WorldRenderer;
|
import net.minecraft.client.render.WorldRenderer;
|
||||||
|
|
||||||
public class ForceChunkLoadingHook {
|
public class ForceChunkLoadingHook {
|
||||||
@@ -9,11 +10,13 @@ public class ForceChunkLoadingHook {
|
|||||||
public ForceChunkLoadingHook(WorldRenderer renderGlobal) {
|
public ForceChunkLoadingHook(WorldRenderer renderGlobal) {
|
||||||
this.hooked = renderGlobal;
|
this.hooked = renderGlobal;
|
||||||
|
|
||||||
|
FlawlessFrames.setEnabled(true);
|
||||||
IForceChunkLoading.from(renderGlobal).replayModRender_setHook(this);
|
IForceChunkLoading.from(renderGlobal).replayModRender_setHook(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void uninstall() {
|
public void uninstall() {
|
||||||
IForceChunkLoading.from(hooked).replayModRender_setHook(null);
|
IForceChunkLoading.from(hooked).replayModRender_setHook(null);
|
||||||
|
FlawlessFrames.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IBlockOnChunkRebuilds {
|
public interface IBlockOnChunkRebuilds {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.replaymod.render.hooks.ForceChunkLoadingHook;
|
|||||||
import com.replaymod.render.metadata.MetadataInjector;
|
import com.replaymod.render.metadata.MetadataInjector;
|
||||||
import com.replaymod.render.mixin.MainWindowAccessor;
|
import com.replaymod.render.mixin.MainWindowAccessor;
|
||||||
import com.replaymod.render.mixin.WorldRendererAccessor;
|
import com.replaymod.render.mixin.WorldRendererAccessor;
|
||||||
|
import com.replaymod.render.utils.FlawlessFrames;
|
||||||
import com.replaymod.replay.ReplayHandler;
|
import com.replaymod.replay.ReplayHandler;
|
||||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||||
import com.replaymod.replaystudio.pathing.path.Path;
|
import com.replaymod.replaystudio.pathing.path.Path;
|
||||||
@@ -707,11 +708,11 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
|
|
||||||
public static String[] checkCompat(RenderSettings settings) {
|
public static String[] checkCompat(RenderSettings settings) {
|
||||||
//#if FABRIC>=1
|
//#if FABRIC>=1
|
||||||
if (net.fabricmc.loader.api.FabricLoader.getInstance().isModLoaded("sodium")) {
|
if (net.fabricmc.loader.api.FabricLoader.getInstance().isModLoaded("sodium") && !FlawlessFrames.hasSodium()) {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
"Rendering is not currently supported while Sodium is installed.",
|
"Rendering is not supported with your Sodium version.",
|
||||||
"See https://github.com/ReplayMod/ReplayMod/issues/150",
|
"It is missing support for the FREX Flawless Frames API.",
|
||||||
"For now, you need to uninstall Sodium before rendering!"
|
"Either update to the latest version or uninstall Sodium before rendering!",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
//#if MC>=11700
|
//#if MC>=11700
|
||||||
@@ -721,7 +722,6 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
//$$ "ODS export requires Iris to be installed for Minecraft 1.17 and above.",
|
//$$ "ODS export requires Iris to be installed for Minecraft 1.17 and above.",
|
||||||
//$$ "Note that it is nevertheless incompatible with other shaders and will simply replace them.",
|
//$$ "Note that it is nevertheless incompatible with other shaders and will simply replace them.",
|
||||||
//$$ "Get it from: https://irisshaders.net/",
|
//$$ "Get it from: https://irisshaders.net/",
|
||||||
//$$ "Use the Standalone version! Sodium is not currently compatible with rendering!",
|
|
||||||
//$$ };
|
//$$ };
|
||||||
//$$ }
|
//$$ }
|
||||||
//#endif
|
//#endif
|
||||||
|
|||||||
40
src/main/java/com/replaymod/render/utils/FlawlessFrames.java
Normal file
40
src/main/java/com/replaymod/render/utils/FlawlessFrames.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package com.replaymod.render.utils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import static com.replaymod.core.ReplayMod.MOD_ID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses the "Flawless Frames" FREX feature which allows us to instruct third-party mods to sacrifice performance (even
|
||||||
|
* beyond the point where it can no longer achieve interactive frame rates) in exchange for a noticeable boost to
|
||||||
|
* quality.
|
||||||
|
* In particular also to force-load all chunks with Canvas/Sodium/Bobby.
|
||||||
|
*
|
||||||
|
* See https://github.com/grondag/frex/pull/9
|
||||||
|
*/
|
||||||
|
public class FlawlessFrames {
|
||||||
|
private static final List<Consumer<Boolean>> CONSUMERS = new CopyOnWriteArrayList<>();
|
||||||
|
private static boolean hasSodium;
|
||||||
|
|
||||||
|
private FlawlessFrames() {}
|
||||||
|
|
||||||
|
public static void registerConsumer(Function<String, Consumer<Boolean>> provider) {
|
||||||
|
Consumer<Boolean> consumer = provider.apply(MOD_ID);
|
||||||
|
CONSUMERS.add(consumer);
|
||||||
|
|
||||||
|
if (provider.getClass().getName().contains(".sodium.") || consumer.getClass().getName().contains(".sodium.")) {
|
||||||
|
hasSodium = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setEnabled(boolean enabled) {
|
||||||
|
CONSUMERS.forEach(it -> it.accept(enabled));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasSodium() {
|
||||||
|
return hasSodium;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,6 +25,9 @@
|
|||||||
"modmenu": [
|
"modmenu": [
|
||||||
"com.replaymod.core.gui.ModMenuApiImpl"
|
"com.replaymod.core.gui.ModMenuApiImpl"
|
||||||
],
|
],
|
||||||
|
"frex_flawless_frames": [
|
||||||
|
"com.replaymod.render.utils.FlawlessFrames::registerConsumer"
|
||||||
|
],
|
||||||
"preLaunch": [
|
"preLaunch": [
|
||||||
"com.replaymod.core.DummyChainLoadEntryPoint"
|
"com.replaymod.core.DummyChainLoadEntryPoint"
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user