gigaherz / Survivalist

Spicing up the early game, without making it tedious
https://www.curseforge.com/minecraft/mc-mods/survivalist
BSD 3-Clause "New" or "Revised" License
18 stars 11 forks source link

Crafttweaker documentation? #32

Closed WolfieWaffle closed 6 years ago

WolfieWaffle commented 7 years ago

I've heard this mod supports Minetweaker/Crafttweaker, if this is true, where can I find some documentation on how to use it?

gigaherz commented 7 years ago

I need to make a wiki article for it or something:

gigaherz.survivalist.Dryable.addRecipe(<minecraft:fish>,<survivalist:jerky>,500);
gigaherz.survivalist.Choppable.addRecipe(<minecraft:bone>,<minecraft:dye:15>,1);
gigaherz commented 7 years ago

You can see the optional parameters in: https://github.com/gigaherz/Survivalist/blob/1.10.2/src/main/java/gigaherz/survivalist/integration/MineTweakerPlugin.java

The method signatures correspond to the things you can call from crafttweaker.

WolfieWaffle commented 7 years ago

Thanks!

WolfieWaffle commented 7 years ago

Hm I tried both example lines, but neither of them work. The file loads fine and there are no errors, but no recipes even after a restart.

WolfieWaffle commented 7 years ago

Or wait, it may be that it just didn't show im in JEI, let me check that

WolfieWaffle commented 7 years ago

Oh interesting, that's what it is. Doesn't show up in JEI but the recipe works.

gigaherz commented 7 years ago

I believe that may be because JEI scans recipes before CT has a chance to add them. Maybe. Sounds like a JEI/CT issue, in that case. Feel free to ping back if you discover it's my fault. ;P

WolfieWaffle commented 7 years ago

ah ok, I'll see if I can reach CT or JEI, another question is it possible to replace or remove current recipes?

gigaherz commented 7 years ago

I do not support replacing (the recipes get added to the list, and the first match wins), but if you look at the api bindings functions that I linked in the other comment, there's removeRecipe methods that take the given recipe output. You can then add the replacement after removing the original.

WolfieWaffle commented 7 years ago

Thanks! I'll go see if CT or JEI knows about the other issue.

jaredlll08 commented 7 years ago

So since JEI loads before CrT, we need to edit the cache directly (Mezz and I talked for months, this was the best / only solution), so when add/remove a recipe, you need to add / remove it from the cache, like so https://github.com/jaredlll08/MTLib/blob/master/src/main/java/com/blamejared/mtlib/utils/BaseListAddition.java#L32 and https://github.com/jaredlll08/MTLib/blob/master/src/main/java/com/blamejared/mtlib/utils/BaseListAddition.java#L53

gigaherz commented 7 years ago

Thanks, I'll take a look.

bookerthegeek commented 7 years ago

@gigaherz A few questions for you on your Minetweaker integration if you can spare a moment...

Ok I think I might have some documentation for you, but I'm a little confused about some things. Is the remove actually the output? Just asking as usually removes use the InputStack for the removal. Also, I know it does not matter but most mods use the OutputStack first, then the InputStack afterwards. Not that your way is wrong, just confusing when writing scripts. Also please don't change it now, I have about 500 scripts already written and it would be a complete bitch to have to go redo all of them, I was just curious as to why you went with the order you did.

Would it be possible to also add in a removeRecipe(InputStack, OutputStack) in case I just want to remove a single recipe instead of all recipes for a specific item if that item has multiple recipes? # The Drying rack seems simple enough. Question though, do either the InputStack or the OutputStack support multiple inputs or outputs as in turn 3 rotten flesh into 2 leather? Also does the InputStack support the Ore Dictionary?

// gigaherz.survivalist.Dryable.removeRecipe(OutputStack);
gigaherz.survivalist.Dryable.removeRecipe(<survivalist:jerky>);

// gigaherz.survivalist.Dryable.addRecipe(InputStack, OutputStack, Time in Ticks);
gigaherz.survivalist.Dryable.addRecipe(<minecraft:rotten_flesh>, <minecraft:leather>, 300);
gigaherz.survivalist.Dryable.addRecipe(<ore:fish>, <survivalist:jerky>, 300);

# For the Chopping recipes, what does the outputMultiplier & the hitCountMultiplier do? I can sorta read Java but not enough to get that. If you could get me a dumbed down explanation I'll make you a Wiki page for the ModTweaker Wiki with your mods information on it. Same question here about the InputStack support for the Ore Dictionary?

// removeRecipe(OutputStack);
gigaherz.survivalist.Choppable.removeRecipe(<minecraft:stick>);

// addRecipe(InputStack, OutputStack);
gigaherz.survivalist.Choppable.addRecipe(<minecraft:bone>, <minecraft:dye:15>);
gigaherz.survivalist.Choppable.addRecipe(<ore:bone>, <minecraft:dye:15>);

// addRecipe(InputStack, OutputStack, outputMultiplier);
gigaherz.survivalist.Choppable.addRecipe(<minecraft:bone>,<minecraft:dye:15>, #);

// addRecipe(InputStack, OutputStack, outputMultiplier, hitCountMultiplier);
gigaherz.survivalist.Choppable.addRecipe(<minecraft:bone>,<minecraft:dye:15>, #, #);

# Thanks for taking the time to read this and explain it.

gigaherz commented 7 years ago

For the add methods, I literally just exposed my internal helpers to zenscript, and those were already in that order. I did not consider the "standard" order at the time. And yes, both input parameters support OreDict names.

As for the remove using the output, I think I looked at some existing code for inspiration, but I don't really remember. I guess it just felt right. I mean, I thought of it in terms of "I want to make X not craftable", rather than "I want to remove the recipe that consumes X"

bookerthegeek commented 7 years ago

And for the Chopping recipes, what does the outputMultiplier & the hitCountMultiplier do?

Sorta figured as much as for the reasoning, was just curious. 😄

gigaherz commented 7 years ago

outputMultiplier changes how many outputs result from the recipe. hitCountMultiplier changes how many times you have to hit the chopblock with an axe.

In both cases the default is 1.0.

bookerthegeek commented 7 years ago

Happy Christmas & Merry New Years! Did I get anything wrong on it, or do I have your....

Approval Seal

bookerthegeek commented 7 years ago

If you ever change or add anything just tag me and I'll update it for you if you like.

gigaherz commented 7 years ago

@bookerthegeek Hmm you called the page "ModTweaker:..." but my integration is in my mod, not in ModTweaker. Also, I support both 1.10.2 and 1.11.2 -- same API. ;P

I'm preparing a release which fixes the JEI database after adding/removing recipes. I fixed adding recipes, now in the process of fixing removing recipes.

gigaherz commented 7 years ago

Oh and, this update will add an optional parameter to removeRecipe, to also match the input when removing.

gigaherz commented 7 years ago

The release is up. Took a while for the curse people to review it: https://minecraft.curseforge.com/projects/survivalist/files

bookerthegeek commented 7 years ago

Nice, I'll make sureto update. Yes i know that is the mod tweaker wiki, but as that is where most documentation is hosted they have asked to have it their for ease of accessability.

If you like i can build your wiki page for it here on github?

DevOpDan commented 7 years ago

@gigaherz Thanks for the latest release; whilst the new recipes do now show in JEI, they are added again, and again, with each /mt reload. You end up with pages full of repeated drying recipes in a short time of tweaking and perfecting a single recipe.

gigaherz commented 7 years ago

Right. Welp, that's all I have time to do right now. You'll have to restart the game every now and then... ;P

DevOpDan commented 7 years ago

Yeah it's no big deal for now; just wanted to throw it out there.

bookerthegeek commented 7 years ago

@LordDan1989 just so you know, that mt reload is only supported for Vanilla. Just so you know.

@gigaherz Thank you verdy much.

DevOpDan commented 7 years ago

@bookerthegeek I'm going to assume I am misunderstanding what you mean by "only supported for Vanilla." If you're saying /mt reload only works with Vanilla stuff you're most certainly incorrect.

mods.betterwithmods.Cauldron.add(<primal:leather_boiled> *1, null, [<ore:foodSalt>, <ore:furBearingPelt>]);

The above allows Fur bearing Pelts from Primal to be boiled, with salt in a Better with Mods Cauldron in order to De-fur the Pelt for Leatherworking.. I literally just wrote this, hit /mt reload 10 times, without a restart. The recipe shows up in JEI, once. Better with Mods has flawless MT integration and proves the duplicate recipe issue with each /mt reload is most definitely a bug.

gigaherz commented 7 years ago

I assume he meant "only expected to work with vanilla". So it's up to the mods to choose to implement support for reloading, which mine doesn't do yet.

bookerthegeek commented 7 years ago

Correct. Minetweaker only supports it for vanilla recipes. I know it works with modded recipes, sometimes due to happenstance and other might be because they support it, but the official reponse from minetweaker is that any errors from using mt reload must be reproducable on a fresh server restart without using that command or it is not a valid error.

That being said, it is anoying as hell when I'm building recipies and it adds in the recipe ever reload.

jaredlll08 commented 7 years ago

The thing with reloading is that some mods cache their recipes and don't allow them to be changed during runtime, which then causes a huge mess. Another issue with reloading usually happens with auto crafting, if a reload is ran while something is crafting, like a buildcraft laser for example, then the recipe it is crafting (if it was added via crafttweaker), is temporarily removed and then re-added (to handle undoing and applying), so this does lead to some crashes, so you don't need to do anything special to add reload stuff to your mod, just make sure it doesn't crash I guess? x)

But as @bookerthegeek said, unless you can replicate an issue without reloading, I don't support it (unless it is something small, like the undo code in the action causing the actual issue), this is because in a normal world, the scripts are only loaded once, so issues caused by a reload won't affect many people, and reload caused issues are hard to fix.

@bookerthegeek unrelated note, could you hop on discord when you get a chance?

bookerthegeek commented 7 years ago

@jaredlll08 I'll be home around 9pm PST if thats not to late for you.

bookerthegeek commented 7 years ago

@gigaherz Update the modtweaker wiki.