On Forge Calling sponge API


#1

Hello!
Can sponge’s economic API be invoked in Forge development environment?


#2

Perhaps you can understand it as calling sponge API in Forge Mod


#3

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


#4

Sponge mixes PluginContainer into ModContainer, so just cast your ModContainer to PluginContainer when required and you’re good to go.


Mod develops and invokes economic API
#5

Sorry, my mother tongue is not English.

Could you elaborate on it, please?


#6

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.


#7

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?


#8


#9

I imported the jar Library in eclipse


#10

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


#11

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


#12

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.


#13

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.


#14

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).


#16

Wait. Your compiling via commands? That changes everything


#18

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


#21

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.


#22

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.


#23

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


#24

All right. Thank you for your reminder.