Modding:WorldGen API: Difference between revisions

From Vintage Story Wiki
no edit summary
No edit summary
No edit summary
Line 25: Line 25:
namespace Vintagestory.Mods.TreasureChest
namespace Vintagestory.Mods.TreasureChest
{
{
     public class VSTreasureChestMod : ModBase
     public class VSTreasureChestMod : ModSystem
     {
     {
         private ICoreServerAPI api;
         private ICoreServerAPI api;
Line 42: Line 42:
</syntaxhighlight>
</syntaxhighlight>


The first thing to note is the '''using''' directives at the top. Those that start with Vintagestory will allow us to access classes in the Vintagestory api. Next the '''StartServerSide''' is a method we are overriding from '''ModBase''' that is called once when the server is start up. Here we start by just storing a reference to the '''ICoreServerAPI''' for convenient access later. We will also be registering call backs for other events here. We also override '''ShouldLoad''' to tell the system to only load this on the server side and not the client side. It would work without this but it's not necessary for the client to load this mod since all our code happens server side.
The first thing to note is the '''using''' directives at the top. Those that start with Vintagestory will allow us to access classes in the Vintagestory api. Next the '''StartServerSide''' is a method we are overriding from '''ModSystem''' that is called once when the server is start up. Here we start by just storing a reference to the '''ICoreServerAPI''' for convenient access later. We will also be registering call backs for other events here. We also override '''ShouldLoad''' to tell the system to only load this on the server side and not the client side. It would work without this but it's not necessary for the client to load this mod since all our code happens server side.


== The /treasure command ==
== The /treasure command ==
Confirmedusers, editor, Administrators
886

edits