I'm trying to create a macro mod for a for 1.16.5 but most examples I can find of similar projects are so old that the code has been changed, i've been trying myself to just send a message when the player logins to get "Minecraft.getInstance().player.sendMessage(new TextComponentString("test"));" to work but to be honest it feels like i'm just brute forcing it without it ever working. Just crashing when logging into the server...
It feels like it should be simple but I don't get why it won't work...
Here's the whole code; (yes I asked a qustion about this before but without basically any details)
package com.name.themod.core.event;
import com.name.themod.TheMod;
import net.minecraft.client.Minecraft;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.client.event.ClientPlayerNetworkEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
@Mod.EventBusSubscriber(modid = TheMod.MOD_ID, bus = Bus.FORGE)
public class EventHandler {
@SubscribeEvent
public static void onLogging(final ClientPlayerNetworkEvent.LoggedInEvent event) {
Minecraft.getInstance().player.sendMessage(new TextComponentString("test"));
}
}
I've used this as an example https://www.tabnine.com/code/java/classes/net.minecraft.util.text.TextComponentString but it says "TextComponentString" doesn't work, i've tried to change it to "StringTextComponent" but that doesn't work either., if anyone knows why this doesn't work i'd be grateful for the help!