Jump to content

Hook to enable or disable recipes


Jimmynator

Recommended Posts

Hi, I'm the developer of the ResearchCraft mod here, and I have to edit some base classes for it to work. As I don't like editing base classes, I've tried removing all those edits and doing it with reflection. It works in SSP by removing and adding them again, but I have a problem in SMP, where I need the recipes to be enabled for some users and disabled for some others. The problem is that it isn't possible to remove a recipe from a client while not removing it from the other clients. What happens is that if you remove the recipe from the client, you can't see the recipe being craftable, but you can still craft it as it is in the server recipe list, and removing them from the server, removes them from all clients.

 

So what I need is a small hook to enable or disable recipes for each player instead of the full server.

Link to comment
Share on other sites

Love your ResearchCraft mod, ran across it recently and was actually thinking of adding it to a new server.

 

As for the researching and such, a couple of things.

 

There is a crafting hook that calls your own function to handle crafting if a recipe does not already exist.

I might propose to just remove all the existing recipes and make your own hook to handle all recipes instead, unsure how to link to a person as I am not looking at it, but there should be some way to see who is doing it.

Be alerted that non-players doing crafting (like BC's autocraftingtable) exist, and you may need to consider them and how they should work.

Link to comment
Share on other sites

Can you link your mod I like the ideal of restricted crafting. Also to solve your issue try using the hook like overlord described then make a nbt saver that list what a player can craft. Creat a function to load the list for the player and compare it to what is being crafted. This way you have a per player list that can be run threw without effecting other players.

Link to comment
Share on other sites

Yes, it can be found here: http://www.minecraftforum.net/topic/1012026-125smp-jimmynators-mods-classcraft-v231-researchcraft-v08-june-26/

 

About the hook, I can't see it. The only crafting hook I see is the onTakenFromCrafting() hook. Where is it?

 

BTW, is there any way to add a new variable to EntityPlayer without editing it?

Link to comment
Share on other sites

using player api but for what your doing you can just make a new nbt file that stores somewhere that saves a string list. Other than that i don't know anything about the hook just assumed it existed because overmind was talking about it. Your could just try your same method you use ssp but make a crafting manager that that works per player.

Link to comment
Share on other sites

OK, so I have been searching the hook you stated, but after looking into all forge hooks, I can say there is NOT such hook (or it is very VERY difficult to find). There is a hook to handle when an item is taken from crafting (which actually is repeated in FML), but it doesn't allow you to block crafting such item.

 

The solution for this isn't going to be easy, as it would only affect the basic crafting GUI. The only way to retrieve the player is with SlotCrafting, which hasn't got a generic way of retrieving it, so I have to deal with Container.getSlot(number), and that number may differ between crafting containers.

 

To sum up, there is actually no generic way to check who is crafting something, and I can't find a solution.

Link to comment
Share on other sites

The one I am speaking of would not 'block' an item, rather you would want to clear the crafting manager and have all crafting recipes go through your function instead.  Hmm, look at any mod source that has recipe items that use damage up as they are crafted from, it is that same hook.

 

Maybe Lex has a better idea when next he comes around?

Link to comment
Share on other sites

There should be a forge hook list, just to keep it simple to search hooks.

 

About the hook. Still can't find it. I have been searching in ForgeHooks, MinecraftForge, CraftingManager, ContainerWorkbench and InventoryCrafting with no luck.

 

Even then, having to handle the recipes in my mod would have serious compatibility issues, and I'd have to make it compatible with every conflicting mod by hand.

Link to comment
Share on other sites

There is no hook for that because it's stupid and thats not how the recipe system works.

However, you can write your own replacements for the crafting table to allow you to filter the recipies all you want.

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

Link to comment
Share on other sites

Ya there is no generic way to do it, you'd have to replace SlotCrafting and do it that route.

However, forge is always up for incoperating well designed hooks.

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

Link to comment
Share on other sites

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.