#How do I send a message to the client?

15 messages · Page 1 of 1 (latest)

ashen ivy
#

The mod below does not run on Fabric. Is there anyone who knows how to resolve this issue?
It runs normally in debugging mode.

error:

Caused by: java.lang.ClassNotFoundException: net.minecraft.client.MinecraftClient
java.lang.ClassNotFoundException: net.minecraft.text.Text

mod:

package com.kimryungyo.fabrics.client;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.api.Environment;
import net.fabricmc.api.EnvType;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.text.Text;

@Environment(EnvType.CLIENT)
public class FabricsClient implements ClientModInitializer {
    private boolean hasJoinedWorld = false;

    @Override
    public void onInitializeClient() {
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            if (client.world != null && client.player != null && !hasJoinedWorld) {
                hasJoinedWorld = true;

                ClientPlayerEntity player = client.player;
                String uuid = player.getUuidAsString();
                String nickname = player.getName().getString();

                player.sendMessage(Text.literal("§a[ Client Info ] UUID: " + uuid), false);
                player.sendMessage(Text.literal("§a[ Client Info ] NICKNAME: " + nickname), false);

            } else if (client.world == null) {
                hasJoinedWorld = false;
            }
        });
    }
}
languid goblet
#

do you use split sources?

ashen ivy
#

sorry, I can't understand your question.
This is my project structure.

languid goblet
#

you are using split sources but where you've written the code is also correct

#

when are you getting the error?

#

oh nvm you said it works in your IDE

#

how did you make the .jar file?

ashen ivy
#

I added the following content to build.gradle and clicked the jar build button in the Gradle tab. I followed the steps in this post (https://discord.com/channels/507304429255393322/1264412816471883859), and it runs now. However, the message still doesn't show up.. 😭

tasks.jar {
    archiveFileName = 'FabricTests.jar'
    destinationDirectory = file('C:\\Users\\ROOT\\AppData\\Roaming\\.minecraft\\mods')
}
orchid kindle
#

did you run jar or build?

ashen ivy
#

this

#

Then I used the non sources file in build/libs/

orchid kindle
#

!!export

twilit geyserBOT
#

Exporting your mod as a JAR: run in a terminal from the same directory as the mod project directory ./gradlew build on GNU/Linux and Mac, or gradlew build on Windows. Alternatively, in IntelliJ IDEA, open the Gradle tab on the right and execute build under tasks. The JARs should appear in ${projectDir}/build/libs. Use the one with the shortest name outside development.