Jump to content

Recommended Posts

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.

Posted

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

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

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

Announcements



×
×
  • Create New...

Important Information

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