Jump to content

Recommended Posts

Posted

So I'm still trying to create a serverside mod. Regardless of which version I try though (1.5.x, 1.6.x, 1.7.x), every time I try to get something to run when a player logs in, it always gives me an error telling me what I'm doing doesn't exist

 

For example I create an empty mod, with:

 

package tslat;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;

@Mod(modid="TRPG",version="0.9.b")
@NetworkMod(clientSideRequired=false,serverSideRequired=true)

public class mod {

@EventHandler
public void load(FMLInitializationEvent event) {
	NetworkRegistry.instance().registerConnectionHandler(new CustConnectionHandler());
}

}

 

Or something similar..

 

then set up the connection handler class with something like:

 

package tslat;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.NetLoginHandler;
import net.minecraft.network.packet.NetHandler;
import net.minecraft.network.packet.Packet1Login;
import net.minecraft.server.MinecraftServer;
import cpw.mods.fml.common.network.IConnectionHandler;
import cpw.mods.fml.common.network.Player;

public class CustConnectionHandler implements IConnectionHandler {

public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) {
	netHandler.getPlayer().addChatMessage("Hello... anyone...");

}

public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager) {
	// TODO Auto-generated method stub
	return null;
}

public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) {
	// TODO Auto-generated method stub

}

public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager) {
	// TODO Auto-generated method stub

}

public void connectionClosed(INetworkManager manager) {
}

public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) {

}

}

 

And no matter what I do, it always tells me there's no such thing..

In this case, it crashes telling me that there's no such method as addChatMessage

 

I can't do anything because everything I do doesn't exist

Posted

In 1.7:

 

Handler class:

 

package yourpackage;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import net.minecraft.util.ChatComponentText;

public class PlayerLoginHandler {
    @SubscribeEvent
    public void onLogin(PlayerEvent.PlayerLoggedInEvent event){
        event.player.addChatMessage(new ChatComponentText("Hello!"));
    }

    @SubscribeEvent
    public void onLogout(PlayerEvent.PlayerLoggedOutEvent event){
        //something else
    }
}

 

Register event in mod class:

 

@EventHandler
public void load(FMLInitializationEvent event) {
     FMLCommonHandler.instance().bus().register(new PlayerLoginHandler());
}

Posted

Just going out on a limb here, but maybe there really is no such method? In 1.7.2 there is a

void addChatMessage(IChatComponent var1);

method, but you are trying to use a method:

void addChatMessage(String var1);

Posted

but then why would it show up correctly in eclipse and on compile, but not when it's running in the server?

 

 

I should note that all 3 versions I tried on, I downloaded the installer and the src of the exact same version

Posted

First of all: Do not make mod under 1.7.2! Its unsupported and outdated!

Where is your CommonProxy and ClientProxy anyway?

You have to have them even if you don't need them!

Posted

Somehow the method that exists in your eclipse environment does not exist in the server. It is a pretty straightforward error message after all.

 

The code you posted at the beginning is far from compatible with forge for Minecraft 1.7.2. If you have that exact same code in an eclipse environment using forge for Minecraft 1.7.2 then reality is starting to break apart in your immediate vicinity. I would recommend learning hypothetical physics in a hurry. Or you could correct me and give a code example accompanied by the version of forge it uses.

 

The easiest answer (for me at any rate) is that you made a mistake somewhere with your versions. But I would be willing to try to reproduce the error.

 

And like Kriki98, I do prefer 1.7.2.

Posted

I understand and agree, I prefer 1.7.2 by a long way aswell.

 

The unfortunate truth is however, that the majority of mods in modpacks and such are not updated for 1.7.2, and some are likely never to be

 

Regardless that's not really the question, I was more curious as to what would cause the methods to disappear for the server but not the eclipse environment

Posted

Im not mean dont make mods for 1.7.2!

I mean dont make mods below version 1.7.2!

I know its supported and recommended!

(English is not my main language, sorry for mistakes)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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