Hello!
Can sponge’s economic API be invoked in Forge development environment?
Perhaps you can understand it as calling sponge API in Forge Mod
Hi. Yes. As long as you have the dependent of sponge api you can call anything. The problem will come when sponge requests your plugincontainer. I don’t think the economy service provider requests that except in EventContext
Sponge mixes PluginContainer
into ModContainer
, so just cast your ModContainer
to PluginContainer
when required and you’re good to go.
Sorry, my mother tongue is not English.
Could you elaborate on it, please?
I have imported the Sponge API, but when compiling and generating mod, it prompts me that the package does not exist.
Thank you very much for your reply.
How have you imported the sponge api?
Aka via gradle or maven? If so can you show us your porm? Or did you import it by just pointing your ide at the sponge forge file?
I imported the jar Library in eclipse
Im not seeing a error on your image? Also this page may help (you can change language at the bottom left if your on desktop site)
https://docs.spongepowered.org/stable/en-GB/plugin/workspace/eclipse.html
C:\Users\Administrator\Desktop\Forge1.12.2-14.23.2.2654\build\sources\main\java
com\mon_lh\mcqwyPlu\McqwyPlu.java:5: Error: Package org.spongepowered.api.plugin Non-existent
:compileJava FAILED
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ‘:compileJava’.
Compilation failed; see the compiler error output for details.
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
In fact, it simply means developing mod to import sponge API. Then, when compiling and generating Mod, I am prompted that the sponge package does not exist.
Just like my question, call sponge API in Forge.
But when compiling and generating Mod, it prompts me that the package for the sponge API does not exist.
Thats eclipse saying that you didnt import the sponge api into your build target. It looks like your using gradle based on that error (could be eclipse. Not used it in so long that i can not remeber that context).
Wait. Your compiling via commands? That changes everything
Because your compiling via commands, you will need to target the sponge. You can do this using the following argument
-cp <path to sponge>
That goes with the compile command
The build command for mod is gradlew build.
I execute: gradlew build -cp C: Users Administrator Desktop Forge 1.12.2-14.23.2.2654 build libs spongeapi-7.0.0-shaded.jar correct?
Sorry, my English is terrible. Maybe I should take it seriously.
Thank you very much for your patience in answering this question, although in the end I did it by adding dependencies to the build. gradle file.
But thank you for your patience.
Sorry. I didnt know what build type you were using despite my second comment asking it. Glad its fixed though.
Remember to add the depenacy to your @mod
All right. Thank you for your reminder.