nimal gunathilaka

make a minecraft fabric 1.21.11 mod that sends message/command only if i pop my totem and don't have any more totems in my inventory. The commands should be this. 1 - "/team sethome" 2 - "/team warp trap kasun123" I made this mod before with kodari ai but there were some problems. The mod works but you need to fix these. The mod sometimes doesn't run those commnds when I pop my totem even if there aren't any totems in my inventory. And also can you add a debug in chat that shows how many totems I have left when I pop a totem. It should be called "TotemCount" and it should only be shown to me in chat. Not to other player. Make it colorfull. (Not just one color)

Kodari AI
KodariSep 6 at 6:34 pm 7
TotemLastStand
This Minecraft Fabric mod for version 1.21.11 monitors when a player consumes a Totem of Undying. Upon totem activation, it checks if the player has zero totems remaining in their inventory. If no totems are left, the mod automatically executes two server commands: "/team sethome" and "/team warp trap kasun123". Additionally, it displays a colorful, multi-colored debug message in chat, visible only to the triggering player, showing the remaining totem count labeled as "TotemCount". The mod ensures reliable detection of totem consumption and accurate inventory counting to prevent missed command execution.
  1. Add a client-side totem-pop hook that identifies only the local player.

  2. Wait for inventory synchronization, then count every remaining totem slot.

  3. Show a colorful local TotemCount message and send both commands only at zero.

  4. Create the Fabric 1.21.11 Gradle project and client mixin configuration.

Created TotemCount for Fabric 1.21.11.

  • Detects only your own totem pops client-side.

  • Waits briefly for inventory synchronization, then counts all remaining totems.

  • Shows a colorful private TotemCount chat message.

  • Runs /team sethome and /team warp trap kasun123 only when your count is zero.

nimal gunathilaka

The compilation failed with this error:

code
Compilation failed with 4 error(s):

ERROR in src/main/java/client/java/com/kodari/totemcount/TotemPopTracker.java at line 48: cannot find symbol
            player.sendChatCommand("team sethome");
                  ^
  symbol: method sendChatCommand(String)
  location: variable player of type ClientPlayerEntity

ERROR in src/main/java/client/java/com/kodari/totemcount/TotemPopTracker.java at line 49: cannot find symbol
            player.sendChatCommand("team warp trap kasun123");
                  ^
  symbol: method sendChatCommand(String)
  location: variable player of type ClientPlayerEntity

ERROR in   src/main/java/client/java/com/kodari/totemcount/TotemPopTracker.java at line 48: cannot find symbol
              player.sendChatCommand("team sethome");
                    ^
  symbol: method sendChatCommand(String)
  location: variable player of type ClientPlayerEntity

ERROR in   src/main/java/client/java/com/kodari/totemcount/TotemPopTracker.java at line 49: cannot find symbol
              player.sendChatCommand("team warp trap kasun123");
                    ^
  symbol: method sendChatCommand(String)
  location: variable player of type ClientPlayerEntity


=== COMPILATION ERROR ANALYSIS ===

MISSING METHODS:
  - sendChatCommand(String)
ACTION: Check method names and signatures

FILES TO INVESTIGATE:
  - src/main/java/client/java/com/kodari/totemcount/TotemPopTracker.java
  -   src/main/java/client/java/com/kodari/totemcount/TotemPopTracker.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariSep 6 at 6:35 pm 2
  • Use the client play network handler to send each command.

  • Preserve the delayed inventory check and local-only debug message.

Fixed the command calls in TotemPopTracker.

Commands now send through MinecraftClient.getNetworkHandler().sendChatCommand(...), which is the correct client-side API for Fabric 1.21.11.

nimal gunathilaka

The game lags sometimes when i use the mod. Especially when I open my inventory. It makes the CPU rate really high. Can you fix it?

Kodari AI
KodariSep 6 at 6:39 pm 3
  • Keep the delayed check, so inventory synchronization remains reliable.

  • Cache the inventory and each stack during the one-shot count.

  • Avoid carrying a pending check across a disconnected or replaced player.

Reduced the totem-count work to a single cached-inventory scan after each pop, rather than repeatedly resolving inventory and stack accessors. Pending checks are also discarded immediately if you disconnect, preventing stale work.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
8 203
src/client/java/com/kodari/totemcount/TotemCountClient.java
package com.kodari.totemcount;

import net.fabricmc.api.ClientModInitializer;

public class TotemCountClient implements ClientModInitializer {
    @Override
    public void onInitializeClient() {
        TotemPopTracker.initialize();
    }
}