Futurepack Mod - Now with flyable Spaceships!

Futurepack Mod - Now with flyable Spaceships!

1M Downloads

Need help with custom research

davqvist opened this issue · 17 comments

commented

I want to add custom research to my pack and reading the wiki entry about it, but I can't get it to work.
Here is my script which I changed a bit from your example: https://pastebin.com/68gxsCHp
This is the CraftTweaker Error I am getting: https://pastebin.com/c3PuqYwF
fp.zs only has mods.futurepack.research.addResearchFile("scripts/fp/example.json"); for now.

Can you maybe give a working example that I can try? I also don't know the syntax of "need" tag, especially when I want to require multiples of an item. Much appreciated if you can help me with that. (Btw, you don't have a discord or something where we can correspond better?)

commented

When does this scipt get executed ? Your example looks fine it should work. the needd tag is a simple JSON array. you can look at our research.json inside the Jar to see some examples.

commented

Long story short: somehow your script gets executed before the research system was fully initialisated, try to post pond the execution fo your script and it should work.

commented

When it does get executed? I don't know. I am not in control of when it does get executed. Whenever Crafttweaker does its thing I suppose. Can I control that somehow? I am not aware of anything.

commented

According to the log, it got executed very early when also vanilla recipes got loaded. I know from other people, it is possible to execute the scrips at world load. I am myself not familiar with Crafttweaker so I can not proide much help.

commented

As far I can see CraftTweaker exceutes the scripts during RecipeEvent which is in init. I don't think that can be changed. Any ideas?

commented

After digging around 1.12 made alot of things more complicated for crafttweaker, thats why their scripts are now executet at preinit.
THe researches need to get loaded this late because all the items have to be present and the are made at preInit.

commented

@jaredlll08 do you have an idea for this? Or will the best solution be a quee where I will handle the adding at the right time?

commented

Just store your IActions in a list, and then iterate the list and apply later, we do it for recipes to ensure we get all of them

commented

I dont have IActions but I do get the point.

commented
commented
@ZenRegister
@ZenClass("mods.futurepack.research")
public class ResearchBridge 
{

	@ZenMethod
	public static void addResearches(InputStream in)
	{
		ResearchLoader.instance.addResearchesFromReader(new InputStreamReader(in, StandardCharsets.UTF_8));
	}

	@ZenMethod
	public static void addResearchFile(String s)
	{
		try
		{
			InputStream in = new FileInputStream(new File(s));
			addResearches(in);
			in.close();
		}
		catch (FileNotFoundException e)
		{
			e.printStackTrace();
		} 
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}

Currently it works like this. When should I use an IAction? And can I time the exact execution of the IAction. I personaly think as this is a bridge I provide (and also have an own log)it should go into my mods log (if it fails).

commented

IAction in the @ZenMethod

You can just add then to a list, and apply them at a later stage

commented

As I optimise and bake the researches the IActions are not realy suited for my purposes. But I willl keep them in mind.

commented

@davqvist in this version it should be fixed: 26.3.258

commented

@davqvist did it work? or do you have not tested it yet?

commented

I have not tested yet because the modpack is released and I don't plan to add big changes like that to the pack, sorry.

commented

these and other changes are on curse now.