Jump to content

ERROR: java.lang.NoSuchFieldError: world


serg_x

Recommended Posts

I`m writing a simple mod, that must find water block near player after command in chat.

Main mod class:

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.apache.logging.log4j.Logger;

@Mod(modid = QMod.MODID, useMetadata=true, clientSideOnly = true)
public class QMod {
    public static final String MODID = "qmod";

    public static Logger logger;

    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {
        logger = event.getModLog();
    }

    @EventHandler
    public void init(FMLInitializationEvent event) {
        logger.info("Init");
        MinecraftForge.EVENT_BUS.register(new ChatListener(logger));
    }
}

ChatListner:

import net.minecraft.client.Minecraft;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.apache.logging.log4j.Logger;


public class ChatListener {
    static Logger logger;

    ChatListener(Logger lg) {
        logger = lg;
    }

    @SubscribeEvent
    public void ClientChatEvent(ClientChatEvent e) {
        logger.info("MESSAGE");
        logger.info(e);
        Minecraft mc = FMLClientHandler.instance().getClient();
        logger.info(mc);
        logger.info(mc.world);
        if (e.getMessage().contains(".find")) {
            logger.info("EEEE");
            e.setCanceled(true);
            BottleFiller bottleFiller = new BottleFiller(logger, mc);
            bottleFiller.scanBlocks();
        }
    }
}

If I lauch client with "gradle lauchClient" everything is OK. But when I try to launch it from the launcher(placed builded .jar into mods folder) an error occurs:

[18:05:31] [Client thread/ERROR]: Exception caught during firing event net.minecraftforge.client.event.ClientChatEvent@e977f71:
java.lang.NoSuchFieldError: world
	at com.sergx.zmod.ChatListener.ClientChatEvent(ChatListener.java:25)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_13_ChatListener_ClientChatEvent_ClientChatEvent.invoke(.dynamic)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
	at net.minecraftforge.event.ForgeEventFactory.onClientSendMessage(ForgeEventFactory.java:436)
	at net.minecraft.client.gui.GuiScreen.func_175281_b(GuiScreen.java:416)
	at net.minecraft.client.gui.GuiScreen.func_175275_f(GuiScreen.java:411)
	at net.minecraft.client.gui.GuiChat.func_73869_a(SourceFile:81)
	at net.minecraft.client.gui.GuiScreen.func_146282_l(GuiScreen.java:558)
	at net.minecraft.client.gui.GuiScreen.func_146269_k(GuiScreen.java:512)
	at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1759)
	at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1098)
	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:398)
	at net.minecraft.client.main.Main.main(SourceFile:123)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

Also instead of FMLClientHandler.instance().getClient() I used Minecraft.getMinecraft() but this didn't help.

 

What am I doing wrong?

MCversion 1.12.2, Forge 14.23.5.2859

Edited by serg_x
Add mc and forge versions
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.