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

Hello guys,

I tried to make a class, which registers my EventHandlers (there is only one yet). But I can't get it working. Here is, what I coded until now:

 

Main Class:

package de.Femtopedia.titantoolbox;

import de.Femtopedia.titantoolbox.Constants.Constants;
import de.Femtopedia.titantoolbox.Skype.skypemethods;
import net.minecraftforge.fml.common.FMLCommonHandler;
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.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

@Mod(modid=Constants.MODID, version=Constants.VERSION, name=Constants.NAME)
public class titantoolbox {

@Instance
public static titantoolbox instance = new titantoolbox();

@EventHandler
public void preInit(FMLPreInitializationEvent e)
{		

}

@EventHandler
public void init(FMLInitializationEvent e)
{
	FMLCommonHandler.instance().bus().register(new titantoolboxDCHandler());
}

@EventHandler
public void postInit(FMLPostInitializationEvent e)
{

}

}

 

EventHandler-Class:

package de.Femtopedia.titantoolbox;

import de.Femtopedia.titantoolbox.Constants.Constants;
import de.Femtopedia.titantoolbox.Skype.skypemethods;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent;

public class titantoolboxDCHandler {

@SubscribeEvent
    public void clientConnection(ClientConnectedToServerEvent e)
    {
	System.out.println("Message");
    }

}

Bringing the best mod back alive! Our mod REFORGED!

Balkon's Weapons for 1.8: https://github.com/TheOnlySilverClaw/Reforged/releases

You need to check if the connection is local when running a singleplayer world. To do this, do something like this:

 

@SubscribeEvent
public void onJoin(ClientConnectedToServerEvent event) {
	if(event.isLocal) {
		System.out.println("Local Connection");
	}else {
		System.out.println("Server Connection");
	}
}

 

As you can see, I check if the client is on a local server, and print in the console accordingly. When you do not check if it is local, you need to run a server within forge, and join it from the client. When you do, it will print out whatever you'd like in the server console. :)

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

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.