Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted
package wmwwmnn.mod;


import java.awt.List;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ServerChatEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import wmwwmnn.mod.proxy.CommonProxy;
import wmwwmnn.mod.util.ref;
import net.minecraftforge.client.event.ClientChatEvent;
@Mod(modid = ref.MOD_ID, name = ref.NAME, version = ref.VERSION) 
public class Main {

	@Instance
	public static Main Instance;
	
	@SidedProxy(clientSide = ref.CLIENT_PROXY_CLASS, serverSide = ref.COMMON_PROXY_CLASS)
	public static CommonProxy proxy;
	
	@EventHandler
	public static void PreInit(FMLPreInitializationEvent event)
	{
	
	}
	
	@EventHandler
	public static void init(FMLInitializationEvent event)
	{
		MinecraftForge.EVENT_BUS.register(new ClientChatEvent(null));
	}
	
	@EventHandler
	public static void Postinit(FMLPostInitializationEvent event)
	{

	}
	@Mod.EventBusSubscriber
	public class MyForgeEventHandler {
		
	 	@SubscribeEvent
	 	
	 	public void onChat(ClientChatEvent event) {
	 		System.out.println("msg");
	 		String msg = event.getMessage();
	 		System.out.println("ClientChatEvent: " + msg);
	 		if (msg.contains("Hello")) {
	 			Minecraft.getMinecraft().player.sendChatMessage("Hi Yourself!");
	 		} else if (msg.contains("Bye")) {
	 			Minecraft.getMinecraft().player.sendChatMessage("Later!");
	 		}
	 	}
	 	}
}
	 	

im a noob btw im trying to port a bot from a javascript api to a mod instead of nodejs,

  • Author

yeah i did it the right way but its giving me an error on the event bus but its saying that i should create a variable of my handler, i guess it doesnt thing that myforgeeventhandler is real, 

 

package wmwwmnn.mod;


import java.awt.List;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ServerChatEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import wmwwmnn.mod.proxy.CommonProxy;
import wmwwmnn.mod.util.ref;
import net.minecraftforge.client.event.ClientChatEvent;
@Mod(modid = ref.MOD_ID, name = ref.NAME, version = ref.VERSION) 
public class Main {s
	@Instance
	public static Main Instance;
	
	@SidedProxy(clientSide = ref.CLIENT_PROXY_CLASS, serverSide = ref.COMMON_PROXY_CLASS)
	public static CommonProxy proxy;
	
	@EventHandler
	public static void PreInit(FMLPreInitializationEvent event)
	{
	
	}
	
	@EventHandler
	public static void init(FMLInitializationEvent event)
	{
		MinecraftForge.EVENT_BUS.register(MyForgeEventHandler()));
	}
	
	@EventHandler
	public static void Postinit(FMLPostInitializationEvent event)
	{

	}
	public class MyForgeEventHandler {
		
	 	@SubscribeEvent
	 	
	 	public void onChat(ClientChatEvent event) {
	 		System.out.println("msg");
	 		String msg = event.getMessage();
	 		System.out.println("ClientChatEvent: " + msg);
	 		if (msg.contains("Hello")) {
	 			Minecraft.getMinecraft().player.sendChatMessage("Hi Yourself!");
	 		} else if (msg.contains("Bye")) {
	 			Minecraft.getMinecraft().player.sendChatMessage("Later!");
	 		}
	 	}
	 	}
}
	 	

 

MinecraftForge.EVENT_BUS.register(MyForgeEventHandler()));

to

MinecraftForge.EVENT_BUS.register(new MyForgeEventHandler());

 

This is basic Java and you really should learn the basics for it before you start. Learning the absolutely needed basics can be done fairly quickly.

Also, you should ignore upper/lower case.

  • Author
3 hours ago, CAS_ual_TY said:

MinecraftForge.EVENT_BUS.register(MyForgeEventHandler()));

to

MinecraftForge.EVENT_BUS.register(new MyForgeEventHandler());

 

This is basic Java and you really should learn the basics for it before you start. Learning the absolutely needed basics can be done fairly quickly.

Also, you should ignore upper/lower case.

tried that already. i would have pasted that version but i just posted the current one that i had

 

also didnt work

Edited by kekmane

  • Author

i got i somewhat working, i accidentally made a problem with my syntax thanks tho

 

edit:nvm lol

Edited by kekmane

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.