Magnus Nielsen

make a mod (mincraft 26.2) that adds a seperat consume consumeble botten so that right click still works as interact botton but there is a seperat botton for consuming. and is client side

Kodari AI
KodariOct 30 at 9:37 pm 1
DualActionConsume
DualActionConsume is a client-side Minecraft Fabric mod for version 26.2 that separates the consume action from the interact action. It adds a dedicated keybind for consuming consumable items (food, potions, etc.) while preserving the standard right-click for block/entity interaction. The mod intercepts the right-click input and, when the dedicated consume key is pressed, triggers the item-use action instead of the interact action. This allows players to eat or drink without accidentally interacting with blocks or entities. The mod is fully client-side, requires no server installation, and works seamlessly in both single-player and multiplayer. It features configurable keybindings, visual feedback when the consume key is active, and compatibility with all vanilla consumable items.
  1. Create a client-only Fabric mod with a dedicated “Consume held item” keybind; normal right-click interaction stays unchanged.

Created a client-only 26.2 mod with a separate Consume held item keybind, defaulting to V. It uses consumables held in the main hand; normal right-click interaction is unchanged. You can rebind it in Controls. The mod does not need to be installed on the server.

Magnus Nielsen

can you change the botton that is being used i settings, if not make it so that it can be changed

Kodari AI
KodariOct 30 at 9:38 pm 1

Yes. The Consume held item keybind is already configurable in Options → Controls → Key Binds (under Miscellaneous). Select it and press the key you want; it currently defaults to V.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
6 120
src/client/java/com/kodari/consumekey/ConsumeKeyClient.java
package com.kodari.consumekey;

import com.mojang.blaze3d.platform.InputConstants;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keymapping.v1.KeyMappingHelper;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.Consumable;

public class ConsumeKeyClient implements ClientModInitializer {
	private static final KeyMapping CONSUME_KEY = KeyMappingHelper.registerKeyMapping(
			new KeyMapping("key.consume_key.consume", InputConstants.KEY_V, KeyMapping.Category.MISC)
	);

	@Override
	public void onInitializeClient() {
		ClientTickEvents.END_CLIENT_TICK.register(client -> {
			if (!CONSUME_KEY.consumeClick() || client.player == null || client.gameMode == null) {
				return;
			}

			ItemStack heldItem = client.player.getMainHandItem();
			Consumable consumable = heldItem.get(DataComponents.CONSUMABLE);
			if (consumable != null && consumable.canConsume(client.player, heldItem)) {
				client.gameMode.useItem(client.player, InteractionHand.MAIN_HAND);
			}
		});
	}
}