-
Notifications
You must be signed in to change notification settings - Fork 8
Developing with Grand Economy
The_Fireplace edited this page Feb 27, 2022
·
2 revisions
To use currency from Grand Economy and/or register your own currency, you'll want to use the entrypoint.
- Create a class that implements
GrandEconomyEntrypoint
- Add whatever logic you want to in your
GrandEconomyEntrypoint
'sinit
function - Add your entrypoint class to the
grandeconomy
entrypoint in yourfabric.mod.json
"entrypoints": {
"main": [
...
],
"grandeconomy": [
"your.package.YourEntrypointClass"
]
},
- Create your entrypoint
- Create an adapter class which implements
dev.the_fireplace.grandeconomy.api.interfaces.Economy
. The names of the methods and parameters should be fairly self explanatory, but javadocs are present in case more explanation is needed. - Within the entrypoint, call
economyRegistry.registerEconomyHandler
for your custom adapter.
If you're looking to do this as a quick one-time solution, you can do DIContainer.get().getInstance(CurrencyAPI.class)
to grab the currency API and use it for your needs. For a more in depth explanation of how the interfaces in the injectables API package work and how to properly use that throughout a mod, check out Fireplace Lib's API explanation.