Jump to content

Recommended Posts

Posted

So basically I'd like to get a players username and change it to something else, basically I'll be making a friendlist or whatever and I'd like the name to change appropriately.

 

I have no idea if I am doing this right as I am very new to forge and there does not seem to be many tutorials for 1.7. I also do have some basic java knowledge but I still haven't been able to figure this out.

 

This is my code so far, (ignore the name, the mod was going to edit item frames first but I was just too lazy to change it, I'll do that later.

 

I also heard I'll need a proxy to do that in Multiplayer but I really don't know how it works, most tutorials just show you how to make one. Now how to use one.

 

The EventHandler class

package com.czaarek99.FrameMod;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.NetworkCheckHandler;
import net.minecraftforge.event.entity.player.PlayerEvent;


/**
* Created by Czarek on 2014-08-09.
*/
public class EventHandler {
    @SubscribeEvent
    public String loginEvent(PlayerEvent.NameFormat event){
        if(event.username.equals("someone sexy")){
            String userName = event.username;
            return userName;
        }
        else{
            return null;
        }
    }
}



 

The main mod class (FrameMod)

package com.czaarek99.FrameMod;

/**
* Created by Czarek on 2014-08-09.
*/
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import net.minecraftforge.common.MinecraftForge;


import java.lang.String;




@Mod(modid = FrameMod.modid, version = FrameMod.version)
public class FrameMod {

    public static final String modid = "FrameMod";
    public static final String version = "1.0 ALPHA";


    EventHandler events = new EventHandler();


    @SidedProxy(clientSide = "com.czaarek99.FrameMod.ClientProxy",serverSide = "com.czaarek99.FrameMod.ServerProxy")
    public static ServerProxy proxy;



    @Mod.EventHandler
    public void PreLoad(FMLPreInitializationEvent event){
        proxy.registerRenderThings();
        FMLCommonHandler.instance().bus().register(events);
        MinecraftForge.EVENT_BUS.register(events);

    }
    }


 

ClientProxy

package com.czaarek99.FrameMod;

/**
* Created by Czarek on 2014-08-09.
*/
public class ClientProxy  {

    public void registerRenderThings() {

    }

}

 

 

ServerProxy

package com.czaarek99.FrameMod;

/**
* Created by Czarek on 2014-08-09.
*/
public class ServerProxy {

    public void registerRenderThings() {

    }

}

Posted
@SubscribeEvent
    public void getName(PlayerEvent.NameFormat event) {
        if(event.username.equals("MultiMote")) event.displayname="Spy";
    }

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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