Skip to content

Commit

Permalink
add frex support
Browse files Browse the repository at this point in the history
  • Loading branch information
ferriarnus committed Aug 14, 2024
1 parent e711ce6 commit d567d62
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 29 deletions.
11 changes: 9 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id 'maven-publish'
id "com.github.johnrengelman.shadow" version "8.1.1"
}
//https://github.com/ReplayMod/ReplayMod/compare/1bf1e0d7be382b8a48208ef90ba9c8a6d3faec8a..9f5a8c3d0ff0ed80fe632496e929224e420a927d GuiKeyframeTimeline

version = project.mod_version
group = project.maven_group

Expand Down Expand Up @@ -57,6 +57,7 @@ repositories {
includeGroup "maven.modrinth"
}
}
maven { url = "https://maven.blamejared.com" }
}

shadowJar {
Expand Down Expand Up @@ -85,6 +86,7 @@ dependencies {
bundle("com.github.ReplayMod:ReplayStudio:master-SNAPSHOT-slim")
minecraftRuntimeLibraries(implementation("com.github.ReplayMod:ReplayStudio:master-SNAPSHOT-slim"))
include(implementation("com.github.viaversion:opennbt:0a02214"))
minecraftRuntimeLibraries(implementation("com.github.viaversion:opennbt:0a02214"))
include(implementation("com.github.ReplayMod:lwjgl-utils:27dcd66"))
minecraftRuntimeLibraries("com.github.ReplayMod:lwjgl-utils:27dcd66")
include(implementation("com.github.javagl.JglTF:jgltf-model:3af6de4"))
Expand All @@ -102,6 +104,7 @@ dependencies {
}
include(implementation('com.googlecode.mp4parser:isoparser:1.1.7'))
include(implementation('org.apache.commons:commons-exec:1.3'))
minecraftRuntimeLibraries(implementation('org.apache.commons:commons-exec:1.3'))
include(implementation('com.google.apis:google-api-services-youtube:v3-rev178-1.22.0'))
include(implementation('com.google.api-client:google-api-client-gson:1.20.0'))
include(implementation('com.google.api-client:google-api-client-java6:1.20.0'))
Expand All @@ -111,5 +114,9 @@ dependencies {

testImplementation 'junit:junit:4.11'

modCompileOnly "maven.modrinth:iris:1.7.0+1.20.6"
modCompileOnly("maven.modrinth:iris:1.7.0+1.20.6")

modCompileOnly("org.embeddedt:embeddium-1.21:1.0.8-beta.367+mc1.21")
//modRuntimeOnly("org.embeddedt:embeddium-1.21:1.0.8-beta.367+mc1.21")

}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ loader_version=0.15.0
fabric_version=0.91.1+1.20.1

# Mod Properties
mod_version=0.1
mod_version=0.2
maven_group=com.replaymod
archives_base_name=replaymod
# Dependencies
# check this on https://modmuss50.me/fabric.html
loom.platform=neoforge
neoforge_version=21.0.0-beta
neoforge_version=21.0.78-beta
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.replaymod.render.hooks;

import com.replaymod.render.utils.FlawlessFrames;
import com.replaymod.render.utils.FlawlessFramesHelper;
import net.minecraft.client.render.WorldRenderer;
import net.neoforged.fml.loading.FMLLoader;
import net.neoforged.fml.loading.LoadingModList;

public class ForceChunkLoadingHook {

Expand All @@ -10,13 +13,17 @@ public class ForceChunkLoadingHook {
public ForceChunkLoadingHook(WorldRenderer renderGlobal) {
this.hooked = renderGlobal;

FlawlessFrames.setEnabled(true);
if (LoadingModList.get().getModFileById("embeddium") != null) {
FlawlessFramesHelper.setEnabled(true);
}
IForceChunkLoading.from(renderGlobal).replayModRender_setHook(this);
}

public void uninstall() {
IForceChunkLoading.from(hooked).replayModRender_setHook(null);
FlawlessFrames.setEnabled(false);
if (LoadingModList.get().getModFileById("embeddium") != null) {
FlawlessFramesHelper.setEnabled(false);
}
}

public interface IBlockOnChunkRebuilds {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.replaymod.render.hooks.ForceChunkLoadingHook;
import com.replaymod.render.hooks.IForceChunkLoading;
import com.replaymod.render.utils.FlawlessFrames;
import com.replaymod.render.utils.FlawlessFramesHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.ChunkRenderingDataPreparer;
Expand All @@ -14,6 +15,7 @@
import net.minecraft.client.render.chunk.ChunkBuilder;
import net.minecraft.client.render.chunk.ChunkRendererRegionBuilder;
import net.minecraft.client.util.math.MatrixStack;
import net.neoforged.fml.loading.LoadingModList;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -55,7 +57,7 @@ private void forceAllChunks(CallbackInfo ci, @Local(argsOnly = true) Camera came
if (replayModRender_hook == null) {
return;
}
if (FlawlessFrames.hasSodium()) {
if (LoadingModList.get().getModFileById("embeddium") != null && FlawlessFramesHelper.hasEmbeddium()) {
return;
}

Expand Down
34 changes: 18 additions & 16 deletions src/main/java/com/replaymod/render/rendering/VideoRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.replaymod.render.metadata.MetadataInjector;
import com.replaymod.render.mixin.WorldRendererAccessor;
import com.replaymod.render.utils.FlawlessFrames;
import com.replaymod.render.utils.FlawlessFramesHelper;
import com.replaymod.replay.ReplayHandler;
import com.replaymod.replaystudio.pathing.path.Keyframe;
import com.replaymod.replaystudio.pathing.path.Path;
Expand All @@ -39,6 +40,7 @@
import net.minecraft.util.crash.CrashException;
import net.minecraft.sound.SoundCategory;
import net.minecraft.client.render.RenderTickCounter;
import net.neoforged.fml.loading.LoadingModList;
import org.lwjgl.glfw.GLFW;

//#if MC>=12000
Expand Down Expand Up @@ -681,22 +683,22 @@ public static String[] checkCompat(Stream<RenderSettings> settings) {

public static String[] checkCompat(RenderSettings settings) {
//#if FABRIC>=1
// if (LoadingModList.get().getModFileById("embeddium") != null && !FlawlessFrames.hasSodium()) {
// return new String[] {
// "Rendering is not supported with your Sodium version.",
// "It is missing support for the FREX Flawless Frames API.",
// "Either use the Sodium build from replaymod.com or uninstall Sodium before rendering!",
// };
// }
// //#if MC>=11700
// if (settings.getRenderMethod() == RenderSettings.RenderMethod.ODS
// && LoadingModList.get().getModFileById("oculus") == null) {
// return new String[] {
// "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.",
// "Get it from: https://irisshaders.net/",
// };
// }
if ((LoadingModList.get().getModFileById("embeddium") != null || LoadingModList.get().getModFileById("sodium") != null) && !FlawlessFramesHelper.hasEmbeddium()) {
return new String[] {
"Rendering is not supported with your Sodium version.",
"It is missing support for the FREX Flawless Frames API.",
"Either use the Sodium build from replaymod.com or uninstall Sodium before rendering!",
};
}
//#if MC>=11700
if (settings.getRenderMethod() == RenderSettings.RenderMethod.ODS
&& LoadingModList.get().getModFileById("iris") == null) {
return new String[] {
"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.",
"Get it from: https://irisshaders.net/",
};
}
//#endif
//#endif
return null;
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/com/replaymod/render/utils/FlawlessFrames.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.replaymod.render.utils;

import org.embeddedt.embeddium.api.service.FlawlessFramesService;
import org.embeddedt.embeddium.impl.asm.OptionalInterface;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Consumer;
Expand All @@ -15,17 +18,17 @@
*
* See https://github.com/grondag/frex/pull/9
*/
public class FlawlessFrames {
public class FlawlessFrames implements FlawlessFramesService {
private static final List<Consumer<Boolean>> CONSUMERS = new CopyOnWriteArrayList<>();
private static boolean hasSodium;

private FlawlessFrames() {}
public FlawlessFrames() {}

public static void registerConsumer(Function<String, Consumer<Boolean>> provider) {
Consumer<Boolean> consumer = provider.apply(MOD_ID);
public void acceptController(Function<String, Consumer<Boolean>> controller) {
Consumer<Boolean> consumer = controller.apply(MOD_ID);
CONSUMERS.add(consumer);

if (provider.getClass().getName().contains(".sodium.") || consumer.getClass().getName().contains(".sodium.")) {
if (controller.getClass().getName().contains(".embeddium.") || consumer.getClass().getName().contains(".sodium.")) {
hasSodium = true;
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/replaymod/render/utils/FlawlessFramesHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.replaymod.render.utils;

public class FlawlessFramesHelper {

public static boolean hasEmbeddium() {
return FlawlessFrames.hasSodium();
}

public static void setEnabled(boolean enabled) {
FlawlessFrames.setEnabled(enabled);
}

}
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ modId="reforgedplaymod"
version="${version}"
displayName="ReForgedPlay Mod"
displayTest = "IGNORE_SERVER_VERSION"
logoFile = "logo.png"
authors="CrushedPixel, johni0702, Ferri_Arnus"
description='''
A Mod which allows you to record, replay and share your Minecraft experience.
Expand Down Expand Up @@ -57,7 +58,7 @@ config = "mixins.replay.replaymod.json"

[[mods]]
modId="replaymod"
version="${version}"
version="2.6.18"
displayName="Replay Mod"
license="GPL-3.0-or-later"
displayTest = "IGNORE_SERVER_VERSION"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.replaymod.render.utils.FlawlessFrames
Binary file added src/main/resources/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
[
{
"modid": "reforgedplaymod",
"name": "ReForgedPlay Mod",
"description": "A Mod which allows you to record, replay and share your Minecraft experience.",
"version": "${version}",
"mcversion": "${mcversion}",
"authorList": [
"CrushedPixel",
"johni0702",
"Ferri_Arnus"
],
"logoFile": "logo.png",
"screenshots": [],
"dependencies": []
},
{
"modid": "replaymod",
"name": "Replay Mod",
Expand Down

0 comments on commit d567d62

Please sign in to comment.