Jump to content

Registering a event


Shprqness
 Share

Recommended Posts

So, i normally code bukkit. getting into forge is a big change, 1 issue i am running into is how to register events (i've been looking for 2 hours)

 

classes ->

Main:

@Mod(modid = Styles.MOD_ID, name = Styles.MOD_NAME, version = Styles.VERSION)
public class Client {
	@SidedProxy(clientSide = Styles.clientProxyClass, serverSide = Styles.serverProxyClass)
	public static ServerProxy proxy;
	
	
	@EventHandler
	public void preInit(FMLPreInitializationEvent e) {
		
		
		
	}
	
	@EventHandler
	public void init(FMLPreInitializationEvent e) {
		
		
	}
	
	@EventHandler
	public void postInit(FMLPostInitializationEvent e) {
		
		
		
	}
	
	

}

 

Event Class:

public class Knockback {

	@SubscribeEvent
	public void knockback(LivingAttackEvent e) {
		
		if(e.entity instanceof EntityPlayer && e.source.getEntity() instanceof EntityPlayer) {
			
			EntityPlayer target = (EntityPlayer) e.entity;
			
		    Vec3 look = e.source.getEntity().getLookVec().normalize();

		    double knockback = 0.5;

		    target.addVelocity(look.xCoord-knockback, look.yCoord-knockback, look.zCoord-knockback);
	
			
			
		}
		
	}
	
	
}

 

Server side: (Still a little confused here)

public class ServerProxy {

}

 

Client side: (once again, a little confused)

public class ClientProxy {

}

 

 

Help is much appreciated
 

(Yes i know, its a 1.8 build, however pointing me in the right direction would help)

Link to comment
Share on other sites

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
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.

 Share



×
×
  • Create New...

Important Information

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