Resolved: Creating Mods with Dependencies

Started by znaxcy on Tue, 06/18/2019 - 09:30

Topic category: Help with MCreator's application

Last seen on 12:47, 2. Jul 2019
Joined Jun 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Resolved: Creating Mods with Dependencies
Thu, 06/20/2019 - 09:21 (edited)

I've built a mod that adds custom-modeled crops to Minecraft. (Not "cross" or "texture" custom model but full, often double height blockmodels.)

By creating blocks and then using update tick events to call a procedure that checks light level and time of day before replacing the previous growth stage with the next growth stage, I have functional crop growth. Harvesting using a spawn gem procedure that can be called when the last growth-stage block is right-clicked works to harvest.

Apart from not being able to check blockstates in order to directionally orient trellis for certain vines and some other directionally-oriented crops, I'm happy enough with how it's working. I understand from this post that directional blockstate checking is a planned feature, so I'll just wait on that for now. Once custom blockstate creation and changing are features (I hope that they will be) I imagine I can just switch all growth over to an "age" blockstate like vanilla crops use. But with block models and not just "cross" or "double cross" texture-type models I don't know if that is possible, so I'll try it when I can. (If anyone knows an easy way to do this currently, please let me know.)

In the meantime, I'd like to build in additional requirements for growth. To be more specific, I'd like to include checks that would require dependency on other mods. For example: I'd like to be able to require grapevine growth to only happen during different seasons (those from the Serene Seasons mod, for instance.) In the spring a vine can grow to stage one, then early summer stage two, late summer stage three and the fall stages four and five (harvest). In the winter, it can be replaced by a "dormant" model.

I imagine being able to do this the same way I check for light level or time of day, but by checking a different, modded variable (is it a variable that I'm looking for?).

Can anyone help explain how I might be able to do this?

Please give detailed instructions, as I'm not familiar enough with how the code works yet.

I'll note that I do know how to install mods in the testing environment (place the mod in forge/run/mods, for those searching for an answer for this) but don't know how to find or call the variables(?) that would tell me what season it is.

Thanks for your help!

Edited by znaxcy on Thu, 06/20/2019 - 09:21
Last seen on 12:24, 20. Sep 2019
Joined Apr 2010
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
  • developer
You can use dependencies…
Tue, 06/18/2019 - 12:22

You can use dependencies from other mods, but you will need to write custom code for the functions of the other mod. One example of such mod is this: https://mcreator.net/modification/49541/lumina

Last seen on 12:47, 2. Jul 2019
Joined Jun 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Brilliant, thank you. I'll…
Tue, 06/18/2019 - 14:08

Brilliant, thank you.

I'll post solutions for posterity after I figure it out.

Last seen on 12:47, 2. Jul 2019
Joined Jun 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
I loaded the src from the…
Tue, 06/18/2019 - 21:57

I loaded the src from the SereneSeasons mod into the workspace (you can tell me if it's correct (I followed this tutorial)) but every time the project builds I get an error about one of the Minecraft classes the SereneSeasons mod uses being a private:

/Users/usr/Desktop/MCreator183/forge/build/sources/main/java/sereneseasons/init/ModHandlers.java:53: error: ColorResolver is not public in BiomeColorHelper; cannot be accessed from outside package
    private static BiomeColorHelper.ColorResolver originalGrassColorResolver;
                                   ^
/Users/usr/Desktop/MCreator183/forge/build/sources/main/java/sereneseasons/init/ModHandlers.java:55: error: ColorResolver is not public in BiomeColorHelper; cannot be accessed from outside package
    private static BiomeColorHelper.ColorResolver originalFoliageColorResolver;
                                   ^
2 errors
:compileJava FAILED
FAILURE: Build failed with an exception.

I can't seem to edit the minecraft source code for a workaround (why is that?) and I don't understand how the Seasons mod is working without this, but perhaps I'm doing something wrong here?

Any ideas? Thanks.

Last seen on 12:47, 2. Jul 2019
Joined Jun 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
It seems with some research…
Wed, 06/19/2019 - 09:31

It seems with some research that the better way to do this is to implement the correct forge hooks so SereneSeasons just identifies my "crops" as "crops" rather than the block-upgrading workaround it is. Perhaps in the future, a setting can be built into MCreator for this?

For now, this also requires some custom code, but hopefully much less. If someone reading this happens to know where I might be able to get an example of this code and can point it out to me, that'd be super helpful. (I obviously have no real coding experience.)

Last seen on 12:47, 2. Jul 2019
Joined Jun 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
It seems with more research…
Wed, 06/19/2019 - 09:53

It seems with more research that this will actually NOT suit my needs as well as I'd like. Back to not being able to build from the workspace because of this issue. Ugh.

Last seen on 12:24, 20. Sep 2019
Joined Apr 2010
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
  • developer
I can't really offer you…
Wed, 06/19/2019 - 14:10

I can't really offer you help on making your mod compatible with other mods as each mod has its own specifics. Doing this is actually pretty advanced stuff, especially if the mod does not have good documentation.

Last seen on 12:47, 2. Jul 2019
Joined Jun 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Yeah, I'm learning that. I…
Wed, 06/19/2019 - 15:19

Yeah, I'm learning that.

I guess I'm just having trouble understanding how to install the API. I can get as far as trying to figure out what the maven coordinates(?) for the build.gradle dependency block are, but I can't tell if it's just bad documentation for the dependency or my lack of knowledge that's not allowing me to find them.

I'll keep reading. Thanks anyway.

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
The maven repository you are…
Wed, 06/19/2019 - 19:48

The maven repository you are looking for is provided by Curseforge itself, so use that one. Then you can just compile it in the dependencies by its slug name:

 

repositories {
    maven {
        name = "CurseForge"
        url = "https://minecraft.curseforge.com/api/maven/"
    }
}

dependencies {
    compile 'serene-seasons:SereneSeasons-1.12.2:1.2.16:universal'
    //you could possibly also use deobfCompile??
}

 

You might find the official Curseforge documentation useful: https://authors.curseforge.com/knowledge-base/529-api

Last seen on 12:47, 2. Jul 2019
Joined Jun 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Thanks for your help!…
Wed, 06/19/2019 - 23:26

Thanks for your help!

Earlier, with advice from the SereneSeason's dev team, I'd managed to get the api building inside the workspace (I had to remove a line from one of the api packages to make it work) without changing anything within build.gradle. (I just loaded the mod's api source into the workspace source and it loaded without direction.

But since yours seems a cleaner, better way to do it, I've now removed the api source from the workspace source and updated the build.gradle with your entries above. According to the console, the api downloaded successfully. To where, I do not know, as the "code" editor inside MCreator has no dependency packages or classes and I can't find the files anywhere else.

But when the game loads the mod is present and some of the code I've written imports those packages so... got me.

Now to learn to actually code so I can use this api...