aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoringlettronald <inglettronald@gmail.com>2023-06-10 21:38:38 -0500
committeringlettronald <inglettronald@gmail.com>2023-06-10 21:38:38 -0500
commitf3f6da9f50edfbe9ed3be42fa16146210e60fbf3 (patch)
tree96c54aa7de1bd2d79d062ad0f787e46c88034a83 /src
parent22508bb83e8d5846a7a68dd5346e8a2013e1c710 (diff)
downloadDulkirMod-Fabric-f3f6da9f50edfbe9ed3be42fa16146210e60fbf3.tar.gz
DulkirMod-Fabric-f3f6da9f50edfbe9ed3be42fa16146210e60fbf3.tar.bz2
DulkirMod-Fabric-f3f6da9f50edfbe9ed3be42fa16146210e60fbf3.zip
yeah I'm not documenting this today
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/dulkirfabric/mixin/io/HandledScreenMixin.java1
-rw-r--r--src/main/java/com/dulkirfabric/mixin/render/CameraMixin.java9
-rw-r--r--src/main/java/com/dulkirfabric/mixin/render/GameRendererMixin.java28
-rw-r--r--src/main/java/com/dulkirfabric/mixin/render/PerspectiveMixin.java22
-rw-r--r--src/main/java/com/dulkirfabric/mixin/render/ScreenMixin.java2
-rw-r--r--src/main/java/com/dulkirfabric/mixin/render/TooltipMixin.java8
-rw-r--r--src/main/kotlin/com/dulkirfabric/Registrations.kt2
-rw-r--r--src/main/kotlin/com/dulkirfabric/commands/DynamicKeyCommand.kt48
-rw-r--r--src/main/kotlin/com/dulkirfabric/commands/RestArgumentType.kt12
-rw-r--r--src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt6
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt10
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/NoReverseCam.kt4
-rw-r--r--src/main/resources/1.0 TODO.txt22
-rw-r--r--src/main/resources/dulkirmod-fabric.mixins.json1
14 files changed, 150 insertions, 25 deletions
diff --git a/src/main/java/com/dulkirfabric/mixin/io/HandledScreenMixin.java b/src/main/java/com/dulkirfabric/mixin/io/HandledScreenMixin.java
index 430faa0..dbf8dbd 100644
--- a/src/main/java/com/dulkirfabric/mixin/io/HandledScreenMixin.java
+++ b/src/main/java/com/dulkirfabric/mixin/io/HandledScreenMixin.java
@@ -5,7 +5,6 @@ import com.dulkirfabric.events.SlotRenderEvent;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.screen.slot.Slot;
-import net.minecraft.screen.slot.SlotActionType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
diff --git a/src/main/java/com/dulkirfabric/mixin/render/CameraMixin.java b/src/main/java/com/dulkirfabric/mixin/render/CameraMixin.java
deleted file mode 100644
index 7ad4606..0000000
--- a/src/main/java/com/dulkirfabric/mixin/render/CameraMixin.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.dulkirfabric.mixin.render;
-
-import net.minecraft.client.render.Camera;
-import org.spongepowered.asm.mixin.Mixin;
-
-@Mixin(Camera.class)
-public class CameraMixin {
-
-}
diff --git a/src/main/java/com/dulkirfabric/mixin/render/GameRendererMixin.java b/src/main/java/com/dulkirfabric/mixin/render/GameRendererMixin.java
index ab86cd9..e8f21bb 100644
--- a/src/main/java/com/dulkirfabric/mixin/render/GameRendererMixin.java
+++ b/src/main/java/com/dulkirfabric/mixin/render/GameRendererMixin.java
@@ -1,12 +1,38 @@
package com.dulkirfabric.mixin.render;
+import com.dulkirfabric.config.DulkirConfig;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.screen.Screen;
+import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.render.GameRenderer;
import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(GameRenderer.class)
public class GameRendererMixin {
- // TODO: THIS CODE IS NOT WORKING
+ private double normalScale = -1;
+
+ @Inject(method = "render", at = @At(value = "HEAD"))
+ public void onRenderStart(float tickDelta, long startTime, boolean tick, CallbackInfo ci) {
+ if (!DulkirConfig.ConfigVars.getConfigOptions().getInvScaleBool()) return;
+ Screen screen = MinecraftClient.getInstance().currentScreen;
+ if (screen instanceof HandledScreen<?>) {
+ normalScale = MinecraftClient.getInstance().getWindow().getScaleFactor();
+ MinecraftClient.getInstance().getWindow().setScaleFactor(DulkirConfig.ConfigVars.getConfigOptions().getInventoryScale());
+ }
+ }
+
+ @Inject(method = "render", at = @At(value = "TAIL"))
+ public void onRenderEnd(float tickDelta, long startTime, boolean tick, CallbackInfo ci) {
+ if (!DulkirConfig.ConfigVars.getConfigOptions().getInvScaleBool()) return;
+ Screen screen = MinecraftClient.getInstance().currentScreen;
+ if (screen instanceof HandledScreen<?>) {
+ MinecraftClient.getInstance().getWindow().setScaleFactor(normalScale);
+ }
+ }
} \ No newline at end of file
diff --git a/src/main/java/com/dulkirfabric/mixin/render/PerspectiveMixin.java b/src/main/java/com/dulkirfabric/mixin/render/PerspectiveMixin.java
new file mode 100644
index 0000000..10b4f61
--- /dev/null
+++ b/src/main/java/com/dulkirfabric/mixin/render/PerspectiveMixin.java
@@ -0,0 +1,22 @@
+package com.dulkirfabric.mixin.render;
+
+import com.dulkirfabric.config.DulkirConfig;
+import net.minecraft.client.option.Perspective;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+@Mixin(Perspective.class)
+public abstract class PerspectiveMixin {
+ @Shadow public abstract boolean isFirstPerson();
+
+ @Inject(method = "next", at = @At("HEAD"), cancellable = true)
+ public void skipPerspective(CallbackInfoReturnable<Perspective> cir) {
+ if (DulkirConfig.ConfigVars.getConfigOptions().getIgnoreReverseThirdPerson()) {
+ if (this.isFirstPerson()) cir.setReturnValue(Perspective.THIRD_PERSON_BACK);
+ else cir.setReturnValue(Perspective.FIRST_PERSON);
+ }
+ }
+}
diff --git a/src/main/java/com/dulkirfabric/mixin/render/ScreenMixin.java b/src/main/java/com/dulkirfabric/mixin/render/ScreenMixin.java
index 56ed0f9..3c890c7 100644
--- a/src/main/java/com/dulkirfabric/mixin/render/ScreenMixin.java
+++ b/src/main/java/com/dulkirfabric/mixin/render/ScreenMixin.java
@@ -33,6 +33,6 @@ public abstract class ScreenMixin {
@Inject(method = "resize", at = @At("HEAD"))
private void beforeResizeScreen(MinecraftClient client, int width, int height, CallbackInfo ci) {
-
+ //todo: impl
}
} \ No newline at end of file
diff --git a/src/main/java/com/dulkirfabric/mixin/render/TooltipMixin.java b/src/main/java/com/dulkirfabric/mixin/render/TooltipMixin.java
deleted file mode 100644
index b484885..0000000
--- a/src/main/java/com/dulkirfabric/mixin/render/TooltipMixin.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.dulkirfabric.mixin.render;
-
-import net.minecraft.client.gui.tooltip.Tooltip;
-import org.spongepowered.asm.mixin.Mixin;
-
-@Mixin(Tooltip.class)
-public class TooltipMixin {
-}
diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt
index 31b1eb1..3122924 100644
--- a/src/main/kotlin/com/dulkirfabric/Registrations.kt
+++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt
@@ -2,6 +2,7 @@ package com.dulkirfabric
import com.dulkirfabric.DulkirModFabric.EVENT_BUS
import com.dulkirfabric.commands.ConfigCommand
+import com.dulkirfabric.commands.DynamicKeyCommand
import com.dulkirfabric.commands.JoinDungeonCommands
import com.dulkirfabric.events.ChatReceivedEvent
import com.dulkirfabric.events.ClientTickEvent
@@ -35,6 +36,7 @@ object Registrations {
cre.register(JoinDungeonCommands.M5Command::register)
cre.register(JoinDungeonCommands.M6Command::register)
cre.register(JoinDungeonCommands.M7Command::register)
+ cre.register(DynamicKeyCommand::register)
}
fun registerEventListeners() {
diff --git a/src/main/kotlin/com/dulkirfabric/commands/DynamicKeyCommand.kt b/src/main/kotlin/com/dulkirfabric/commands/DynamicKeyCommand.kt
new file mode 100644
index 0000000..f253957
--- /dev/null
+++ b/src/main/kotlin/com/dulkirfabric/commands/DynamicKeyCommand.kt
@@ -0,0 +1,48 @@
+package com.dulkirfabric.commands
+
+import com.dulkirfabric.util.TextUtils
+import com.mojang.brigadier.CommandDispatcher
+import com.mojang.brigadier.arguments.StringArgumentType
+import com.mojang.brigadier.builder.LiteralArgumentBuilder
+import com.mojang.brigadier.builder.RequiredArgumentBuilder
+import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
+import net.minecraft.command.CommandRegistryAccess
+
+object DynamicKeyCommand {
+ var command = ""
+ fun register(dispatcher: CommandDispatcher<FabricClientCommandSource>, registryAccess: CommandRegistryAccess) {
+ dispatcher.register(
+ LiteralArgumentBuilder.literal<FabricClientCommandSource>("dk")
+ .executes { context ->
+ TextUtils.info("§6Usage: /dk set <command>")
+ TextUtils.info("§6For more information about this command, run /dk help")
+ return@executes 0
+ }
+ .then(
+ LiteralArgumentBuilder.literal<FabricClientCommandSource>("set")
+ .then(
+ RequiredArgumentBuilder.argument<FabricClientCommandSource, String>("command", RestArgumentType)
+ .executes { context ->
+ command = StringArgumentType.getString(context, "command")
+ command = command.removePrefix("/")
+ TextUtils.info("§6§lCommand Registered: §7$command")
+ return@executes 1
+ }
+ )
+ )
+ .then(
+ LiteralArgumentBuilder.literal<FabricClientCommandSource>("help")
+ .executes {
+ TextUtils.info("§6§lDynamic Keybind Info")
+ TextUtils.info("§7 - There's a keybind setting inside your Dulkir Config you can use in order" +
+ " to make a chat macro for a particular in game command. This only works for commands.", prefix = false)
+ TextUtils.info("§7 - Usage: /dk set <command args>", prefix = false)
+ TextUtils.info("§7 (i made this cuz I have a mouse button that i use for a bunch of different useful " +
+ "actions depending upon what I'm doing, so don't worry if this feature doesn't apply to you lol)", prefix = false)
+ return@executes 2
+ }
+ )
+ )
+ }
+
+} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/commands/RestArgumentType.kt b/src/main/kotlin/com/dulkirfabric/commands/RestArgumentType.kt
new file mode 100644
index 0000000..a6f13ac
--- /dev/null
+++ b/src/main/kotlin/com/dulkirfabric/commands/RestArgumentType.kt
@@ -0,0 +1,12 @@
+package com.dulkirfabric.commands
+
+import com.mojang.brigadier.StringReader
+import com.mojang.brigadier.arguments.ArgumentType
+
+object RestArgumentType: ArgumentType<String> {
+ override fun parse(reader: StringReader): String {
+ val remaining = reader.remaining
+ reader.cursor += remaining.length
+ return remaining
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
index 9e3fbaf..16fa366 100644
--- a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
+++ b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
@@ -65,6 +65,9 @@ class DulkirConfig {
val shortcuts = builder.getOrCreateCategory(Text.literal("Shortcuts"))
shortcuts.addEntry(
+ entryBuilder.mkKeyField(Text.literal("Dynamic Key"), configOptions::dynamicKey)
+ )
+ shortcuts.addEntry(
ConfigHelper.mkConfigList(
Text.literal("Macros"),
configOptions::macrosList,
@@ -88,7 +91,8 @@ class DulkirConfig {
var invScaleBool: Boolean = false,
var inventoryScale: Int = 3,
var macrosList: List<Macro> = listOf(Macro(UNKNOWN_KEY, "")),
- var ignoreReverseThirdPerson: Boolean = false
+ var ignoreReverseThirdPerson: Boolean = false,
+ var dynamicKey: InputUtil.Key = UNKNOWN_KEY
)
@Serializable
diff --git a/src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt b/src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt
index c94c258..9d2d39f 100644
--- a/src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt
+++ b/src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt
@@ -6,10 +6,20 @@ import com.dulkirfabric.util.TextUtils
import meteordevelopment.orbit.EventHandler
object KeyShortCutImpl {
+ private var lastCommandHandle: Long = 0
+ private var prevCode: Int = 0;
+
@EventHandler
fun onKeyPress(event: WorldKeyPressEvent) {
DulkirConfig.configOptions.macrosList.forEach {
if (it.keyBinding.code == event.key) {
+ // Spam Prevention
+ if (event.key == prevCode && System.currentTimeMillis() - lastCommandHandle < 1000)
+ return
+
+ lastCommandHandle = System.currentTimeMillis()
+ prevCode = event.key
+
// This conditional allows for these shortcuts to work for commands or normal messages
if (it.command.startsWith("/"))
TextUtils.sendCommand(it.command.substring(1))
diff --git a/src/main/kotlin/com/dulkirfabric/features/NoReverseCam.kt b/src/main/kotlin/com/dulkirfabric/features/NoReverseCam.kt
deleted file mode 100644
index b8cb36d..0000000
--- a/src/main/kotlin/com/dulkirfabric/features/NoReverseCam.kt
+++ /dev/null
@@ -1,4 +0,0 @@
-package com.dulkirfabric.features
-
-class NoReverseCam {
-} \ No newline at end of file
diff --git a/src/main/resources/1.0 TODO.txt b/src/main/resources/1.0 TODO.txt
new file mode 100644
index 0000000..68d3262
--- /dev/null
+++ b/src/main/resources/1.0 TODO.txt
@@ -0,0 +1,22 @@
+1.0 TODO:
+
+ - Patcher Inventory scaling
+ - Tooltip Scaling
+ - Old animation/custom animation ?
+ - Reparty Command
+ - HUD ELEMENTS CODE
+
+LIST OF EASY STUFF:
+ - Block outlines?
+ - Secret Chime with a custom sound
+ - Broken Hyp
+ - Abiphone DND
+ - double hook noot noot
+
+- <details>
+ <summary>
+ <h1>
+
+ - JBR and hotswap plugin
+ - Slot Binding (emulate keypress) --- APPROACH LAST
+ - Custom Enchant Colors --- APPROACH LAST \ No newline at end of file
diff --git a/src/main/resources/dulkirmod-fabric.mixins.json b/src/main/resources/dulkirmod-fabric.mixins.json
index 808b58f..2b28d67 100644
--- a/src/main/resources/dulkirmod-fabric.mixins.json
+++ b/src/main/resources/dulkirmod-fabric.mixins.json
@@ -10,6 +10,7 @@
"render.GameMenuScreenMixin",
"render.GameRendererMixin",
"render.KeyboardMixin",
+ "render.PerspectiveMixin",
"render.ScreenMixin"
]
} \ No newline at end of file