Minetweaker compatibility

Forum intended for those developing plugins for or integration with MineTweaker. (Help with scripts is for Scripting Help)

Minetweaker compatibility

Postby hilburn » Sun Oct 19, 2014 8:03 pm

Hi, I was hoping I could get some help with this:

I've written a pair of MT classes to allow tweaking of Minechem recipes (https://github.com/hilburn/Minechem/blo ... poser.java, https://github.com/hilburn/Minechem/blo ... siser.java) - as far as I can tell, these are done correctly

I try to register those classes here: https://github.com/hilburn/Minechem/blo ... .java#L235

Yet when I try to run the file I get "[20:28:04] [Client thread/INFO]: [CHAT] ERROR: Error executing Minechem Recipes.zs: null"

I think the problem might be in the build script but I'm not sure how to fix it, if that's the case I'd appreciate some advice on how to set things up properly - actually even if it's not that and I've screwed up something else I'd appreciate some help because I'm out of ideas.

Cheers,
Hilburn
hilburn
 
Posts: 4
Joined: Sun Oct 19, 2014 10:09 am

Re: Minetweaker compatibility

Postby Stan » Sun Oct 19, 2014 8:26 pm

Do you get any additional error information? If you use 3.0.9, there should be a stack trace in the minetweaker log with more information.

Annotation and registration looks correct. Since it is erroring when it actually executes your script (and not during registration) I suspect there is a bug in your function implementation.

For your code, I recommend using MineTweakerMC.getExamples to convert an ingredient to an array of item stacks, and MineTweakerMC.getItemStack to convert an IItemStack to an ItemStack. For removeRecipe, it may be a better strategy to iterate over all your recipes and then find out which ones have a matching output, by using the IIngredient.matches method. It's slower, but since the script is loaded only once, it shouldn't have a noticeable effect in practice.
User avatar
Stan
Site Admin
 
Posts: 258
Joined: Fri Jul 11, 2014 9:04 pm

Re: Minetweaker compatibility

Postby hilburn » Sun Oct 19, 2014 9:11 pm

*facepalm*

I didn't realise there was a minetweaker log, would have helped me spot the issue sooner - part of one of the input parsing functions was returning a null item because somebody didn't fill up the array properly...

Now that I've got it working in some form, I'll work on improving the execution, thanks very much for the help!
hilburn
 
Posts: 4
Joined: Sun Oct 19, 2014 10:09 am

Re: Minetweaker compatibility

Postby hilburn » Tue Oct 21, 2014 5:20 pm

Ok having another issue that I just don't understand.

My test script

: [Select all] [/] [] ()
val H = <minechem:minechemElement:0>;
val He = <minechem:minechemElement:1>;
Decomposer.addRecipe(bedrock,[H*64,He*64],0.1);
GeSHi © Codebox Plus

is failing with the message "10 methods available but none matches the parameters (minetweaker.item.IItemStack, any[], double)"

Despite the following code in the relevant class
: [Select all] [/] [] ()
@ZenMethod
   public static void addRecipe(IIngredient input, IItemStack[] outputs,double chance)
   {
      ArrayList<PotionChemical> output = InputHelper.getChemicals(outputs);
      if (!output.isEmpty() && chance>0 && chance<=1)
      {
         add(input, chance, output);
      }
   }
   
   private static void add(IIngredient input, double chance, ArrayList<PotionChemical> output)
   {
      ArrayList<ItemStack> toAdd = InputHelper.getInputs(input);
      for (ItemStack addInput:toAdd)
         MineTweakerAPI.apply(new AddRecipeAction(addInput, (float) chance, InputHelper.getArray(output)));
   }
GeSHi © Codebox Plus


There are a number of other functions (well 9 to be exact) and I they are all experiencing similar issues - Any advice would be appreciated
hilburn
 
Posts: 4
Joined: Sun Oct 19, 2014 10:09 am

Re: Minetweaker compatibility

Postby Stan » Wed Oct 22, 2014 9:51 am

Can I see the code for the <minechem:...> bracket handler? Perhaps it couldn't match something around there.
User avatar
Stan
Site Admin
 
Posts: 258
Joined: Fri Jul 11, 2014 9:04 pm

Re: Minetweaker compatibility

Postby hilburn » Wed Oct 22, 2014 12:33 pm

the <minechem:..> is just a standard IItemStack - I've resolved the issue, I had another function slightly further down with arguments

: [Select all] [/] [] ()
public static void addRecipe(IIngredient input, IItemStack[][] outputs,double chance)
GeSHi © Codebox Plus


And Minetweaker was trying to parse the IItemStack[] [H*64,He*64] as an IItemStack[][] - renaming this second function seems to have fixed things
hilburn
 
Posts: 4
Joined: Sun Oct 19, 2014 10:09 am

Re: Minetweaker compatibility

Postby Stan » Fri Oct 24, 2014 5:14 am

Ah, thanks for telling me. I might be able to improve that in a future version.
User avatar
Stan
Site Admin
 
Posts: 258
Joined: Fri Jul 11, 2014 9:04 pm


Return to Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron