-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
BetterClient
committed
Aug 31, 2024
1 parent
37ffbc2
commit df6f640
Showing
19 changed files
with
257 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
# Fabric Example Mod | ||
# SnapTapMC | ||
|
||
## Setup | ||
- The controversial feature from Wooting/Razer keyboards for minecraft! | ||
|
||
For setup instructions please see the [fabric wiki page](https://fabricmc.net/wiki/tutorial:setup) that relates to the IDE that you are using. | ||
# DISCLAIMER: Please check server rules before using this on your favorite server, this may be considered a ***CHEAT*** | ||
|
||
## License | ||
[![Showcase](https://img.youtube.com/vi/Y6VBWgT2YH4/0.jpg)](https://www.youtube.com/watch?v=Y6VBWgT2YH4) | ||
|
||
This template is available under the CC0 license. Feel free to learn from it and incorporate it in your own projects. | ||
# What does it do? | ||
|
||
- When both strafing keys (A & D) is pressed, the one pressed last is prioritized.- | ||
- This allows for very-accurate strafing, causing this feature to be banned in CS2. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/client/java/com/example/mixin/client/ExampleClientMixin.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
src/main/java/io/github/betterclient/snaptap/KeybindingAccess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package io.github.betterclient.snaptap; | ||
|
||
public interface KeybindingAccess { | ||
boolean snapTap$isPressedReal(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package io.github.betterclient.snaptap; | ||
|
||
import net.fabricmc.api.ModInitializer; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.client.option.KeyBinding; | ||
import net.minecraft.client.util.InputUtil; | ||
import net.minecraft.text.Style; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Formatting; | ||
|
||
public class SnapTap implements ModInitializer { | ||
public static long LEFT_STRAFE_LAST_PRESS_TIME = 0; | ||
public static long RIGHT_STRAFE_LAST_PRESS_TIME = 0; | ||
public static KeyBinding TOGGLE_BIND; | ||
public static boolean TOGGLED = true; | ||
|
||
public static KeyBinding KEYSTROKES_TOGGLE_BIND; | ||
public static boolean KEYSTROKES_TOGGLED = true; | ||
|
||
@Override | ||
public void onInitialize() { | ||
LEFT_STRAFE_LAST_PRESS_TIME = 0; | ||
RIGHT_STRAFE_LAST_PRESS_TIME = 0; | ||
TOGGLE_BIND = new KeyBinding("text.snaptap.toggle", InputUtil.GLFW_KEY_F8, "key.categories.misc") { | ||
@Override | ||
public void setPressed(boolean pressed) { | ||
if(pressed) { | ||
TOGGLED = !TOGGLED; | ||
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage( | ||
Text.translatable("text.snaptap.toggled", | ||
Text.translatable(TOGGLED ? "text.snaptap.enabled" : "options.ao.off") | ||
.fillStyle(Style.EMPTY | ||
.withColor(TOGGLED ? Formatting.GREEN : Formatting.RED)))); | ||
} | ||
|
||
super.setPressed(pressed); | ||
} | ||
}; | ||
|
||
KEYSTROKES_TOGGLE_BIND = new KeyBinding("text.snaptap.keystrokestoggle", InputUtil.GLFW_KEY_F7, "key.categories.misc") { | ||
@Override | ||
public void setPressed(boolean pressed) { | ||
if(pressed) { | ||
KEYSTROKES_TOGGLED = !KEYSTROKES_TOGGLED; | ||
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage( | ||
Text.translatable("text.snaptap.toggledkeystokes", | ||
Text.translatable(KEYSTROKES_TOGGLED ? "text.snaptap.enabled" : "options.ao.off") | ||
.fillStyle(Style.EMPTY | ||
.withColor(KEYSTROKES_TOGGLED ? Formatting.GREEN : Formatting.RED)))); | ||
} | ||
|
||
super.setPressed(pressed); | ||
} | ||
}; | ||
} | ||
|
||
public static void render(DrawContext context) { | ||
MinecraftClient client = MinecraftClient.getInstance(); | ||
|
||
KeyBinding leftKey = client.options.leftKey; | ||
KeyBinding rightKey = client.options.rightKey; | ||
|
||
KeybindingAccess left = (KeybindingAccess) leftKey; | ||
KeybindingAccess right = (KeybindingAccess) rightKey; | ||
|
||
if (left.snapTap$isPressedReal()) { | ||
context.fill(5, 5, 25, 25, 0xFF444444); | ||
} else { | ||
context.fill(5, 5, 25, 25, 0xFF000000); | ||
} | ||
|
||
if (right.snapTap$isPressedReal()) { | ||
context.fill(30, 5, 50, 25, 0xFF444444); | ||
} else { | ||
context.fill(30, 5, 50, 25, 0xFF000000); | ||
} | ||
|
||
context.drawCenteredTextWithShadow(client.textRenderer, leftKey.getBoundKeyLocalizedText(), 15, 11, -1); | ||
context.drawCenteredTextWithShadow(client.textRenderer, rightKey.getBoundKeyLocalizedText(), 40, 11, -1); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/io/github/betterclient/snaptap/mixins/MixinGameOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.github.betterclient.snaptap.mixins; | ||
|
||
import io.github.betterclient.snaptap.SnapTap; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.option.GameOptions; | ||
import net.minecraft.client.option.KeyBinding; | ||
import org.apache.commons.lang3.ArrayUtils; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Mutable; | ||
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.CallbackInfo; | ||
|
||
import java.io.File; | ||
|
||
@Mixin(GameOptions.class) | ||
public class MixinGameOptions { | ||
@Mutable @Shadow @Final public KeyBinding[] allKeys; | ||
|
||
@Inject(method = "<init>", at = @At("RETURN")) | ||
public void onInit(MinecraftClient client, File optionsFile, CallbackInfo ci) { | ||
this.allKeys = ArrayUtils.addAll(this.allKeys, SnapTap.TOGGLE_BIND, SnapTap.KEYSTROKES_TOGGLE_BIND); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/io/github/betterclient/snaptap/mixins/MixinInGameHud.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.github.betterclient.snaptap.mixins; | ||
|
||
import io.github.betterclient.snaptap.SnapTap; | ||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.client.gui.hud.InGameHud; | ||
import net.minecraft.client.render.RenderTickCounter; | ||
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(InGameHud.class) | ||
public class MixinInGameHud { | ||
@Inject(method = "render", at = @At("RETURN")) | ||
public void onRender(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { | ||
if(SnapTap.KEYSTROKES_TOGGLED) | ||
SnapTap.render(context); | ||
} | ||
} |
Oops, something went wrong.