Skip to content

Commit

Permalink
Fun stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
enjarai committed Feb 22, 2024
1 parent 0c21ae8 commit 27921f5
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 57 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Removed dependency on Forgified Fabric API.
- Its a secret.
- I sure hope this works on fabric tho.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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<String> getRequiredMods() {
return Set.of("modmenu");
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
3 changes: 2 additions & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 27921f5

Please sign in to comment.