Files
src
build.gradle
gradle.properties
settings.gradle
Code
19 1,006
src/client/java/com/example/knockbackmod/KnockbackModClient.java
package com.example.knockbackmod;
import com.example.knockbackmod.gui.ModuleScreen;
import com.example.knockbackmod.module.*;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.MinecraftClient;
public class KnockbackModClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
ModKeybindings.register();
// Register world-render events for Trajectories + PearlCountdown
TrajectoriesModule.register();
PearlCountdownModule.register();
// Register HUD overlay for simple status display
registerHud();
// Tick handler for all modules
ClientTickEvents.END_CLIENT_TICK.register(this::onTick);
}
private void onTick(MinecraftClient client) {
if (client.player == null) return;
// Open GUI
if (ModKeybindings.OPEN_GUI.wasPressed()) {
client.setScreen(new ModuleScreen());
}
// Knockback Displacement toggle
if (ModKeybindings.KNOCKBACK_DISPLACEMENT.wasPressed()) {
KnockbackDisplacementModule.enabled = !KnockbackDisplacementModule.enabled;
sendToast(client, "Knockback Displacement: " + (KnockbackDisplacementModule.enabled ? "ON" : "OFF"));
}
KnockbackDisplacementModule.tick(client);
// Trajectories toggle
if (ModKeybindings.TRAJECTORIES.wasPressed()) {
TrajectoriesModule.enabled = !TrajectoriesModule.enabled;
sendToast(client, "Trajectories: " + (TrajectoriesModule.enabled ? "ON" : "OFF"));
}
// Pearl Countdown toggle
if (ModKeybindings.PEARL_COUNTDOWN.wasPressed()) {
PearlCountdownModule.enabled = !PearlCountdownModule.enabled;
sendToast(client, "Pearl Countdown: " + (PearlCountdownModule.enabled ? "ON" : "OFF"));
}
// Error Killer
if (ModKeybindings.ERROR_KILLER.wasPressed()) {
if (ErrorKillerModule.enabled) {
ErrorKillerModule.onKeyPress(client);
}
}
// Toggle Error Killer with Shift+R
ErrorKillerModule.tick(client);
// No Cobweb Interact toggle — GUI only, no keybind
if (ModKeybindings.NO_COBWEB_INTERACT.wasPressed()) {
NoCobwebInteractModule.enabled = !NoCobwebInteractModule.enabled;
sendToast(client, "No Cobweb Interact: " + (NoCobwebInteractModule.enabled ? "ON" : "OFF"));
}
// Auto Bow Boost
if (ModKeybindings.AUTO_BOW_BOOST.wasPressed()) {
AutoBowBoostModule.onKeyPress(client);
}
AutoBowBoostModule.tick(client);
}
private void registerHud() {
net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry.addLast(
net.minecraft.util.Identifier.of(KnockbackMod.MOD_ID, "status"),
(context, tickCounter) -> {
if (!isAnyModuleEnabled()) return;
MinecraftClient client = MinecraftClient.getInstance();
if (client.player == null) return;
int y = 2;
int x = 2;
if (KnockbackDisplacementModule.enabled)
context.drawTextWithShadow(client.textRenderer, "§a[KBD]", x, y, 0xFFFFFF);
if (TrajectoriesModule.enabled)
context.drawTextWithShadow(client.textRenderer, "§b[TRAJ]", x + 38, y, 0xFFFFFF);
if (PearlCountdownModule.enabled)
context.drawTextWithShadow(client.textRenderer, "§e[PEARL]", x + 76, y, 0xFFFFFF);
if (ErrorKillerModule.enabled)
context.drawTextWithShadow(client.textRenderer, "§c[EK]", x + 120, y, 0xFFFFFF);
if (NoCobwebInteractModule.enabled)
context.drawTextWithShadow(client.textRenderer, "§d[NCW]", x + 150, y, 0xFFFFFF);
if (AutoBowBoostModule.enabled)
context.drawTextWithShadow(client.textRenderer, "§6[ABB]", x + 188, y, 0xFFFFFF);
}
);
}
private boolean isAnyModuleEnabled() {
return KnockbackDisplacementModule.enabled
|| TrajectoriesModule.enabled
|| PearlCountdownModule.enabled
|| ErrorKillerModule.enabled
|| NoCobwebInteractModule.enabled
|| AutoBowBoostModule.enabled;
}
private void sendToast(MinecraftClient client, String message) {
if (client.player != null) {
client.player.sendMessage(net.minecraft.text.Text.literal(message), true);
}
}
}