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

I'm not sure if this is a bug or I'm (most likely) failing and doing it wrong. So I'll post just it here as a 'Help!' topic :)

 

When I use the ICraftingHandler's onCrafting method, it gets called twice. Here is the code:

 

The Client Proxy Class, registering the MCGCraftingHandler class.

public class MCGClientProxy extends MCGCommonProxy {

@Override
public void registerRenderInformation() {
	MCG mcg = new MCG();

	GameRegistry.registerCraftingHandler(new MCGCraftingHandler());

	KeyBindingRegistry.registerKeyBinding(new MCGKeyHandler(mcg));
	TickRegistry.registerTickHandler(mcg, Side.CLIENT);
}

}

The CraftingHandler Class implementing the ICraftingHandler interface

public class MCGCraftingHandler implements ICraftingHandler {

@Override
public void onCrafting(EntityPlayer player, ItemStack item,
		IInventory craftMatrix) {
	System.out.println("Crafted");

}

@Override
public void onSmelting(EntityPlayer player, ItemStack item) {
	System.out.println("Smelted");

}
}

 

As you may be able to see, the methods just displaying some text on the console and it should only do this once. However, after crafting (and smelting) I get the messages twice.

 

(I also have a MCGLoader class which has the @mod annotation, which calls the ClientProxy's registerRenderInformation())

 

Now I'm pretty sure I am doing something wrong here (but the methods work?). I first tried implementing the ICraftingHandler in the MCG class, as that is my 'main' class where I place all of the main code in there. That initially came out with the same result. I then created the Handler class and same result.

 

At the time I've come across this I was using the 200 build. I did (about half an ago?) update to the latest build at the time (225) and the same thing has happened.

 

I also saw the FML's ModLoaderCraftingHelper class, but I have a feeling I'll need to implement the BaseModProxy Interface somewhere (?). However, that is also implementing the ICraftingHandler so I guess I'll get the same result.

 

If I am doing it wrong, please tell me how and I'll fix it. If it is a bug, then I'll live with it (I'll also be glad I'm doing it right).

 

Thanks for reading.

Seems like you're being called twice, for both the client side, and the integrated server side.

If you toss a Thread.currentThread().getName() in the print you should be able to see that.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

  • Author

Seems like you're being called twice, for both the client side, and the integrated server side.

If you toss a Thread.currentThread().getName() in the print you should be able to see that.

 

Oh right. Okay then. That makes sense. Nothing that a simple If-statement can't 'fix'.

 

Thanks

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.