Content: Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Background: Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Pattern: Blank Waves Notes Sharp Wood Rockface Leather Honey Vertical Triangles
Welcome to TerraFirmaCraft Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

  • Announcements

    • Dries007

      ATTENTION Forum Database Breach   03/04/2019

      There has been a breach of our database. Please make sure you change your password (use a password manager, like Lastpass).
      If you used this password anywhere else, change that too! The passwords themselves are stored hashed, but may old accounts still had old, insecure (by today's standards) hashes from back when they where created. This means they can be "cracked" more easily. Other leaked information includes: email, IP, account name.
      I'm trying my best to find out more and keep everyone up to date. Discord (http://invite.gg/TerraFirmaCraft) is the best option for up to date news and questions. I'm sorry for this, but the damage has been done. All I can do is try to make sure it doesn't happen again.
    • Claycorp

      This forum is now READ ONLY!   01/20/2020

      As of this post and forever into the future this forum has been put into READ ONLY MODE. There will be no new posts! A replacement is coming SoonTM . If you wish to stay up-to-date on whats going on or post your content. Please use the Discord or Sub-Reddit until the new forums are running.

      Any questions or comments can be directed to Claycorp on either platform.
TaeoG

Adding Anvil Recipes

7 posts in this topic

As I understand it, AnvilRecipes when instantiated have a crafting value that is set pseudo-randomly . It appears you send the seed information to the client when a player logs into the server, which sets up the Anvil Manager clientside to produce the same crafting values given the same recipe inputs.

 

By my reckoning, this should allow someone adding recipes using the same AnvilManager to have working recipes in multiplayer, as long as they register those recipes AFTER the SetupWorld() method has been called clientside. Is there a good way to do this? Is there a particular one time event that is guaranteed to trigger sometime afterward world setup, or is it possible that you could trigger an event that an addon creator could look for?

Edited by Kittychanley
Moved to addon discussion
0

Share this post


Link to post
Share on other sites

I know your anvil works a bit differently, but you could try just using the standard anvil manager and require the recipes to use your anvil.

Edited by Powerman913717
0

Share this post


Link to post
Share on other sites

Have you looked at how merchants and decorations addons implemented this? They add anvil recipes. They are open source and may give some insight.

1

Share this post


Link to post
Share on other sites

I was just poking around in the Decorations mod, I think I've got it sorted out.

 

For the record, as I'm sure others will have the same question, this is what seems to be a solid implementation:

 

1. Implement your own InitClientWorldPacket class, make sure it extends AbstractPacket. You can call it whatever you want. obviously.

2. In the packet's handleClientSide(EntityPlayer) method, call your anvil recipe register method, whatever it might be. Have a static boolean stored somewhere to check whether this has been done already, otherwise you'll end up with a bunch of copies of your recipes in the manager.

3. In your mod during the initialization phase, call TerraFirmaCraft.packetPipeline.registerPacket(), passing it your new packet

4. ???

5. PROFIT!

 

 

I'm going to test it now, I'll edit this post if I'm missing something.

 

EDIT: I was missing something fairly obvious.

 

4. a)Create a class to track the player that listens for a PlayerLoggedInEvent, and register it in your main mod file

    b)on PlayerLoggedInEvent, instantiate your new packet and send it through the pipeline using

TerraFirmaCraft.packetPipeline.sendTo(pkt, (EntityPlayerMP) event.player);
Edited by TaeoG
0

Share this post


Link to post
Share on other sites

Yep, after testing it this implementation works quite well. You still need to clear the recipes out and reset the "already registered" tag when moving from server to server or from single player to multiplayer, but restarting your client will do that in a pinch.

0

Share this post


Link to post
Share on other sites

Instead of using a world load event and network packets i used this:

@EventHandlerpublic void serverStarted(FMLServerStartedEvent e){    Recipes.loadAnvilRecipes();}

 

The problem is timing.

The anvil manager needs the world super-seed to randomize the recipes, so using this code in the main mod class seems to work.

0

Share this post


Link to post
Share on other sites

does the FMLServerStartedEvent get called clientside?

0

Share this post


Link to post
Share on other sites