Shemol Haywood

make a mod that allows u to increase the damage of tnt using keybinds and decrease also

Kodari AI
KodariNov 3 at 3:18 pm 5
TntDamageControl
A Minecraft Fabric mod that adds keybinds to dynamically adjust TNT explosion damage. Players can press configured keys to increase or decrease the blast damage of TNT explosions in real-time. The mod modifies the explosion damage calculation, allowing for customizable gameplay difficulty and creative experimentation. Includes configurable keybind assignments and damage adjustment increments, with visual feedback via chat messages when damage values change.
  • Add configurable keybinds to raise or lower TNT’s entity-damage multiplier.

  • Apply changes on the server, with operator permission required in multiplayer.

Added TNT damage controls:

  • ] increases damage; decreases it, in 25% steps from 0% to 1000%. Rebind them in Minecraft’s controls.

  • Affects entity damage, not blast radius or block destruction. The setting resets when the server restarts.

  • Multiplayer requires the mod on both client and server, and operator permission to change the setting.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
10 200
src/client/java/com/example/tntdamage/TntDamageClient.java
package com.example.tntdamage;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;

public class TntDamageClient implements ClientModInitializer {
    @Override
    public void onInitializeClient() {
        KeyBinding.Category category = KeyBinding.Category.create(Identifier.of("tntdamage", "controls"));
        KeyBinding increase = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.tntdamage.increase", GLFW.GLFW_KEY_RIGHT_BRACKET, category));
        KeyBinding decrease = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.tntdamage.decrease", GLFW.GLFW_KEY_LEFT_BRACKET, category));
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (increase.wasPressed()) {
                if (client.player != null) adjust(client, 1);
            }
            while (decrease.wasPressed()) {
                if (client.player != null) adjust(client, -1);
            }
        });
    }

    private static void adjust(net.minecraft.client.MinecraftClient client, int direction) {
        if (ClientPlayNetworking.canSend(AdjustDamagePayload.ID)) {
            ClientPlayNetworking.send(new AdjustDamagePayload(direction));
        } else {
            client.player.sendMessage(Text.literal("The server must have TNT Damage Control installed."), false);
        }
    }
}