diff --git a/CHANGELOG.md b/CHANGELOG.md index 19ba7b0d..ef7e7990 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,2 @@ -- Removed dependency on Forgified Fabric API. \ No newline at end of file +- Its a secret. +- I sure hope this works on fabric tho. \ No newline at end of file diff --git a/common/src/main/java/nl/enjarai/doabarrelroll/compat/CompatMixinPlugin.java b/common/src/main/java/nl/enjarai/doabarrelroll/compat/CompatMixinPlugin.java deleted file mode 100644 index 471c0171..00000000 --- a/common/src/main/java/nl/enjarai/doabarrelroll/compat/CompatMixinPlugin.java +++ /dev/null @@ -1,52 +0,0 @@ -package nl.enjarai.doabarrelroll.compat; - -import nl.enjarai.doabarrelroll.platform.Services; -import org.objectweb.asm.tree.ClassNode; -import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; -import org.spongepowered.asm.mixin.extensibility.IMixinInfo; - -import java.util.List; -import java.util.Set; - -/** - * Mixin config plugin for compat, only applies mixins if specific mods are present. - */ -public interface CompatMixinPlugin extends IMixinConfigPlugin { - Set getRequiredMods(); - - @Override - default void onLoad(String mixinPackage) { - - } - - @Override - default String getRefMapperConfig() { - return null; - } - - @Override - default boolean shouldApplyMixin(String targetClassName, String mixinClassName) { - return getRequiredMods().stream() - .allMatch(Services.PLATFORM::checkModLoaded); - } - - @Override - default void acceptTargets(Set myTargets, Set otherTargets) { - - } - - @Override - default List getMixins() { - return null; - } - - @Override - default void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - - } - - @Override - default void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - - } -} diff --git a/fabric/src/main/java/nl/enjarai/doabarrelroll/compat/cameraoverhaul/CameraOverhaulPlugin.java b/fabric/src/main/java/nl/enjarai/doabarrelroll/compat/cameraoverhaul/CameraOverhaulPlugin.java index f5329bd9..0456f8d5 100644 --- a/fabric/src/main/java/nl/enjarai/doabarrelroll/compat/cameraoverhaul/CameraOverhaulPlugin.java +++ b/fabric/src/main/java/nl/enjarai/doabarrelroll/compat/cameraoverhaul/CameraOverhaulPlugin.java @@ -1,6 +1,6 @@ package nl.enjarai.doabarrelroll.compat.cameraoverhaul; -import nl.enjarai.doabarrelroll.compat.CompatMixinPlugin; +import nl.enjarai.cicada.api.compat.CompatMixinPlugin; import java.util.Set; diff --git a/fabric/src/main/java/nl/enjarai/doabarrelroll/compat/controlify/ControlifyPlugin.java b/fabric/src/main/java/nl/enjarai/doabarrelroll/compat/controlify/ControlifyPlugin.java index 8b822172..4ffea710 100644 --- a/fabric/src/main/java/nl/enjarai/doabarrelroll/compat/controlify/ControlifyPlugin.java +++ b/fabric/src/main/java/nl/enjarai/doabarrelroll/compat/controlify/ControlifyPlugin.java @@ -1,6 +1,6 @@ package nl.enjarai.doabarrelroll.compat.controlify; -import nl.enjarai.doabarrelroll.compat.CompatMixinPlugin; +import nl.enjarai.cicada.api.compat.CompatMixinPlugin; import java.util.Set; diff --git a/fabric/src/main/java/nl/enjarai/doabarrelroll/compat/modmenu/ModMenuPlugin.java b/fabric/src/main/java/nl/enjarai/doabarrelroll/compat/modmenu/ModMenuPlugin.java new file mode 100644 index 00000000..8f6dfe4f --- /dev/null +++ b/fabric/src/main/java/nl/enjarai/doabarrelroll/compat/modmenu/ModMenuPlugin.java @@ -0,0 +1,12 @@ +package nl.enjarai.doabarrelroll.compat.modmenu; + +import nl.enjarai.cicada.api.compat.CompatMixinPlugin; + +import java.util.Set; + +public class ModMenuPlugin implements CompatMixinPlugin { + @Override + public Set getRequiredMods() { + return Set.of("modmenu"); + } +} diff --git a/fabric/src/main/java/nl/enjarai/doabarrelroll/compat/modmenu/mixin/ModsScreenMixin.java b/fabric/src/main/java/nl/enjarai/doabarrelroll/compat/modmenu/mixin/ModsScreenMixin.java new file mode 100644 index 00000000..c96ce1ce --- /dev/null +++ b/fabric/src/main/java/nl/enjarai/doabarrelroll/compat/modmenu/mixin/ModsScreenMixin.java @@ -0,0 +1,64 @@ +package nl.enjarai.doabarrelroll.compat.modmenu.mixin; + +import com.terraformersmc.modmenu.gui.ModsScreen; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.util.GlfwUtil; +import net.minecraft.text.Text; +import net.minecraft.util.math.RotationAxis; +import nl.enjarai.doabarrelroll.config.ModConfig; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Locale; + +@Mixin(ModsScreen.class) +public abstract class ModsScreenMixin extends Screen { + @Unique + private double lastTime; + @Unique + private double rollSecs; + + protected ModsScreenMixin(Text title) { + super(title); + } + + @Inject( + method = "lambda$init$0", + at = @At("HEAD"), + remap = false + ) + private void onUpdateSearch(String string, CallbackInfo ci) { + if (ModConfig.INSTANCE.getEnableEasterEggs() && string.toLowerCase(Locale.ROOT).equals("do a barrel roll")) { + rollSecs += 1; + } + } + + @Inject( + method = "render", + at = @At("HEAD"), + remap = false + ) + private void onRender(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { + double time = GlfwUtil.getTime(); + double secsDelta = time - lastTime; + lastTime = time; + + if (rollSecs > 0) { + // Draw a nice background to prevent previous frames pixels from peeking through + context.fill(0, 0, width, height, 0xff000000); + + var matrices = context.getMatrices(); + rollSecs -= Math.max(0, secsDelta); + float roll = (float) (rollSecs * Math.PI * 2); + + // Rotate around center ofc + matrices.translate(width / 2f, height / 2f, 0); + matrices.multiply(RotationAxis.POSITIVE_Z.rotation(roll)); + matrices.translate(-width / 2f, -height / 2f, 0); + } + } +} diff --git a/fabric/src/main/resources/do_a_barrel_roll.compat.modmenu.mixins.json b/fabric/src/main/resources/do_a_barrel_roll.compat.modmenu.mixins.json new file mode 100644 index 00000000..76702374 --- /dev/null +++ b/fabric/src/main/resources/do_a_barrel_roll.compat.modmenu.mixins.json @@ -0,0 +1,16 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "nl.enjarai.doabarrelroll.compat.modmenu.mixin", + "plugin": "nl.enjarai.doabarrelroll.compat.modmenu.ModMenuPlugin", + "refmap": "${mod_id}.refmap.json", + "compatibilityLevel": "JAVA_17", + "client": [ + "ModsScreenMixin" + ], + "mixins": [ + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index aef47a8b..6e165dfc 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -42,7 +42,8 @@ "${mod_id}.mixins.json", "${mod_id}.fabric.mixins.json", "${mod_id}.compat.cameraoverhaul.mixins.json", - "${mod_id}.compat.controlify.mixins.json" + "${mod_id}.compat.controlify.mixins.json", + "${mod_id}.compat.modmenu.mixins.json" ], "accessWidener": "${mod_id}.accesswidener", diff --git a/gradle.properties b/gradle.properties index 8f29e24a..82b41f89 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false # Project -mod_version=3.5.0 +mod_version=3.5.1 group=nl.enjarai # Common