Skip to content

Commit

Permalink
fix mixin error and frex
Browse files Browse the repository at this point in the history
  • Loading branch information
ferriarnus committed Aug 17, 2024
1 parent fe2997d commit d27df7f
Show file tree
Hide file tree
Showing 16 changed files with 132 additions and 63 deletions.
13 changes: 9 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'dev.architectury.loom' version '1.6-SNAPSHOT'
id 'dev.architectury.loom' version '1.7-SNAPSHOT'
id 'maven-publish'
id "com.github.johnrengelman.shadow" version "8.1.1"
}
Expand All @@ -24,6 +24,7 @@ loom {
"mixins.replay.replaymod.json"
]
}
accessWidenerPath = file("src/main/resources/replay.accesswidener")
runs {
it.configureEach {
vmArgs("-Xmx8G", "-XX:+UseZGC")
Expand Down Expand Up @@ -75,6 +76,7 @@ shadowJar {
remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
atAccessWideners.add('replay.accesswidener')
}

dependencies {
Expand All @@ -89,8 +91,9 @@ dependencies {
forge "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}"

bundle("com.github.ReplayMod:ReplayStudio:d9f7c11-slim")
minecraftRuntimeLibraries(implementation("com.github.ReplayMod:ReplayStudio:d9f7c11"))
minecraftRuntimeLibraries(implementation("com.github.ReplayMod:ReplayStudio:d9f7c11-slim"))
include(implementation("com.github.viaversion:opennbt:0a02214"))
minecraftClientRuntimeLibraries("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 @@ -108,16 +111,18 @@ dependencies {
}
include(implementation('com.googlecode.mp4parser:isoparser:1.1.7'))
include(implementation('org.apache.commons:commons-exec:1.3'))
minecraftClientRuntimeLibraries('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'))
include(implementation('com.google.oauth-client:google-oauth-client-jetty:1.20.0'))

modCompileOnly("maven.modrinth:oculus:1.20.1-1.7.0")
modRuntimeOnly("maven.modrinth:oculus:1.20.1-1.7.0")
//modRuntimeOnly("maven.modrinth:oculus:1.20.1-1.7.0")
minecraftRuntimeLibraries("org.anarres:jcpp:1.4.14")

modRuntimeOnly("maven.modrinth:embeddium:0.3.29+mc1.20.1")
modCompileOnly("maven.modrinth:embeddium:0.3.30+mc1.20.1")
modRuntimeOnly("maven.modrinth:embeddium:0.3.30+mc1.20.1")

testImplementation 'junit:junit:4.11'

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ loader_version=0.15.0
fabric_version=0.91.1+1.20.1

# Mod Properties
mod_version=0.3
mod_version=0.3.1
maven_group=com.replaymod
archives_base_name=replaymod
# Dependencies
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
68 changes: 34 additions & 34 deletions src/main/java/com/replaymod/core/mixin/GuiScreenAccessor.java
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
package com.replaymod.core.mixin;

import net.minecraft.client.gui.screen.Screen;
import org.spongepowered.asm.mixin.Mixin;

//#if MC>=11700
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.Selectable;
//#else
//#endif

//#if MC>=11400
import net.minecraft.client.gui.widget.ClickableWidget;
import org.spongepowered.asm.mixin.gen.Invoker;
//#else
//$$ import net.minecraft.client.gui.GuiButton;
//$$ import org.spongepowered.asm.mixin.gen.Accessor;
//$$ import java.util.List;
//#endif

@Mixin(Screen.class)
public interface GuiScreenAccessor {
//#if MC>=11700
@Invoker("addDrawableChild")
<T extends Element & Drawable & Selectable> T invokeAddButton(T drawableElement);
//#elseif MC>=11400
//$$ @Invoker
//$$ <T extends AbstractButtonWidget> T invokeAddButton(T button);
//#else
//$$ @Accessor("buttonList")
//$$ List<GuiButton> getButtons();
//#endif
}
//package com.replaymod.core.mixin;
//
//import net.minecraft.client.gui.screen.Screen;
//import org.spongepowered.asm.mixin.Mixin;
//
////#if MC>=11700
//import net.minecraft.client.gui.Drawable;
//import net.minecraft.client.gui.Element;
//import net.minecraft.client.gui.Selectable;
////#else
////#endif
//
////#if MC>=11400
//import net.minecraft.client.gui.widget.ClickableWidget;
//import org.spongepowered.asm.mixin.gen.Invoker;
////#else
////$$ import net.minecraft.client.gui.GuiButton;
////$$ import org.spongepowered.asm.mixin.gen.Accessor;
////$$ import java.util.List;
////#endif
//
//@Mixin(Screen.class)
//public interface GuiScreenAccessor {
// //#if MC>=11700
// @Invoker(value = "addDrawableChild")
// <T extends Element & Drawable & Selectable> T invokeAddButton(T drawableElement);
// //#elseif MC>=11400
// //$$ @Invoker
// //$$ <T extends AbstractButtonWidget> T invokeAddButton(T button);
// //#else
// //$$ @Accessor("buttonList")
// //$$ List<GuiButton> getButtons();
// //#endif
//}
7 changes: 4 additions & 3 deletions src/main/java/com/replaymod/core/versions/MCVer.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.replaymod.core.versions;

import com.mojang.blaze3d.systems.RenderSystem;
import com.replaymod.core.mixin.GuiScreenAccessor;
//import com.replaymod.core.mixin.GuiScreenAccessor;
import com.replaymod.replaystudio.lib.viaversion.api.protocol.packet.State;
import com.replaymod.replaystudio.lib.viaversion.api.protocol.version.ProtocolVersion;
import com.replaymod.replaystudio.protocol.PacketTypeRegistry;
Expand Down Expand Up @@ -252,12 +252,13 @@ public static void addButton(
//$$ GuiButton button
//#endif
) {
GuiScreenAccessor acc = (GuiScreenAccessor) screen;
//GuiScreenAccessor acc = (GuiScreenAccessor) screen;
//#if MC>=11400
acc.invokeAddButton(button);
//acc.invokeAddButton(button);
//#else
//$$ acc.getButtons().add(button);
//#endif
screen.addDrawableChild(button);
}

//#if MC>=11400
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
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.minecraftforge.fml.loading.LoadingModList;

public class ForceChunkLoadingHook {

Expand All @@ -10,13 +12,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(true);
}
}

public interface IBlockOnChunkRebuilds {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@Mixin(ParticleManager.class)
public abstract class MixinParticleManager {
//#if MC>=11500
@Redirect(method = "renderParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/Particle;buildGeometry(Lnet/minecraft/client/render/VertexConsumer;Lnet/minecraft/client/render/Camera;F)V"))
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/Particle;buildGeometry(Lnet/minecraft/client/render/VertexConsumer;Lnet/minecraft/client/render/Camera;F)V"))
private void buildOrientedGeometry(Particle particle, VertexConsumer vertexConsumer, Camera camera, float partialTicks) {
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) MCVer.getMinecraft().gameRenderer).replayModRender_getHandler();
if (handler == null || !handler.omnidirectional) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,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 it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.Camera;
Expand All @@ -13,6 +14,7 @@
import net.minecraft.client.render.chunk.ChunkBuilder;
import net.minecraft.client.render.chunk.ChunkRendererRegionBuilder;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraftforge.fml.loading.LoadingModList;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -64,7 +66,7 @@ private void forceAllChunks(MatrixStack matrices, float tickDelta, long limitTim
if (replayModRender_hook == null) {
return;
}
if (FlawlessFrames.hasSodium()) {
if (LoadingModList.get().getModFileById("embeddium") != null && FlawlessFramesHelper.hasEmbeddium()) {
return;
}

Expand Down
15 changes: 8 additions & 7 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 Down Expand Up @@ -666,13 +667,13 @@ 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 (LoadingModList.get().getModFileById("embeddium") != null && !FlawlessFramesHelper.hasEmbeddium()) {
return new String[] {
"Rendering is not supported with your embeddium version.",
"It is missing support for the FREX Flawless Frames API.",
"Update embeddium before rendering!",
};
}
// //#if MC>=11700
// if (settings.getRenderMethod() == RenderSettings.RenderMethod.ODS
// && LoadingModList.get().getModFileById("oculus") == null) {
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/replaymod/render/utils/FlawlessFrames.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.replaymod.render.utils;

import org.embeddedt.embeddium.api.service.FlawlessFramesService;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Consumer;
Expand All @@ -15,17 +17,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) {
public void acceptController(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.")) {
if (provider.getClass().getName().contains(".embeddium.") || consumer.getClass().getName().contains(".embeddium.")) {
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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@Mixin(WorldRenderer.class)
public class Mixin_UseReplayTime_ForTexture {
//#if MC>=11400
@Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Util;getMeasuringTimeMs()J"))
@Redirect(method = "renderWorldBorder", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Util;getMeasuringTimeMs()J"))
//#else
//$$ @Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
//#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public abstract class MixinMouseListener {
@Accessor // Note: for some reason Mixin doesn't include this in the refmap json if it's just a @Shadow field
abstract int getActiveButton();

@Inject(method = "method_1611", at = @At("HEAD"), cancellable = true)
@Inject(method = "method_1611", at = @At("HEAD"), cancellable = true, require = 0)
//#if MC>=11700
private void mouseDown(boolean[] result, Screen screen, double x, double y, int button, CallbackInfo ci) {
//#else
Expand All @@ -33,7 +33,19 @@ private void mouseDown(boolean[] result, Screen screen, double x, double y, int
}
}

@Inject(method = "method_1605", at = @At("HEAD"), cancellable = true)
@Inject(method = "m_168084_", at = @At("HEAD"), cancellable = true, remap = false, require = 0)
//#if MC>=11700
private void mouseDown2(boolean[] result, Screen screen, double x, double y, int button, CallbackInfo ci) {
//#else
//$$ private void mouseDown(boolean[] result, double x, double y, int button, CallbackInfo ci) {
//#endif
if (MouseCallback.EVENT.invoker().mouseDown(x, y, button)) {
result[0] = true;
ci.cancel();
}
}

@Inject(method = "method_1605", at = @At("HEAD"), cancellable = true, require = 0)
//#if MC>=11700
private void mouseUp(boolean[] result, Screen screen, double x, double y, int button, CallbackInfo ci) {
//#else
Expand All @@ -45,7 +57,19 @@ private void mouseUp(boolean[] result, Screen screen, double x, double y, int bu
}
}

@Inject(method = "method_1602", at = @At("HEAD"), cancellable = true)
@Inject(method = "m_168078_", at = @At("HEAD"), cancellable = true, remap = false, require = 0)
//#if MC>=11700
private void mouseUp2(boolean[] result, Screen screen, double x, double y, int button, CallbackInfo ci) {
//#else
//$$ private void mouseUp(boolean[] result, double x, double y, int button, CallbackInfo ci) {
//#endif
if (MouseCallback.EVENT.invoker().mouseUp(x, y, button)) {
result[0] = true;
ci.cancel();
}
}

@Inject(method = "method_1602", at = @At("HEAD"), cancellable = true, require = 0)
//#if MC>=11700
private void mouseDrag(Screen screen, double x, double y, double dx, double dy, CallbackInfo ci) {
//#else
Expand All @@ -56,6 +80,17 @@ private void mouseDrag(Screen screen, double x, double y, double dx, double dy,
}
}

@Inject(method = "m_168072_", at = @At("HEAD"), cancellable = true, remap = false, require = 0)
//#if MC>=11700
private void mouseDrag2(Screen screen, double x, double y, double dx, double dy, CallbackInfo ci) {
//#else
//$$ private void mouseDrag(Element element, double x, double y, double dx, double dy, CallbackInfo ci) {
//#endif
if (MouseCallback.EVENT.invoker().mouseDrag(x, y, getActiveButton(), dx, dy)) {
ci.cancel();
}
}

@Redirect(
method = "onMouseScroll",
at = @At(value = "INVOKE",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.replaymod.render.utils.FlawlessFrames
2 changes: 1 addition & 1 deletion src/main/resources/mixins.core.replaymod.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//#endif
"MixinKeyboardListener",
"MixinMinecraft",
"GuiScreenAccessor",
//"GuiScreenAccessor",
"KeyBindingAccessor",
"MinecraftAccessor",
//#if MC>=11900
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/replay.accesswidener
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessWidener v1 named

accessible method net/minecraft/client/gui/screen/Screen addDrawableChild (Lnet/minecraft/client/gui/Element;)Lnet/minecraft/client/gui/Element;

0 comments on commit d27df7f

Please sign in to comment.