forked from anegostudios/vscreativemod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCore.cs
74 lines (60 loc) · 2.13 KB
/
Core.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System.IO;
using Vintagestory.API.Common;
using Vintagestory.API.Config;
using Vintagestory.API.Datastructures;
using Vintagestory.API.Server;
using Vintagestory.GameContent;
namespace Vintagestory.ServerMods
{
/// <summary>
/// This class contains core settings for the creative mod
/// </summary>
public class Core : ModSystem
{
ICoreServerAPI sapi;
public override double ExecuteOrder()
{
return 0.001;
}
public override bool ShouldLoad(EnumAppSide side)
{
return true;
}
public override void StartPre(ICoreAPI api)
{
api.Assets.AddModOrigin("game", Path.Combine(GamePaths.AssetsPath, "creative"));
}
public override void Start(ICoreAPI api)
{
base.Start(api);
api.RegisterItemClass("ItemMagicWand", typeof(ItemMagicWand));
api.RegisterBlockClass("BlockCommand", typeof(BlockCommand));
api.RegisterBlockEntityClass("BECommand", typeof(BlockEntityCommand));
}
public override void StartServerSide(ICoreServerAPI api)
{
base.StartServerSide(api);
sapi = api;
api.Event.SaveGameCreated += Event_SaveGameCreated;
api.Event.PlayerCreate += Event_PlayerCreate;
}
private void Event_PlayerCreate(IServerPlayer byPlayer)
{
ITreeAttribute worldConfig = sapi.WorldManager.SaveGame.WorldConfiguration;
string mode = worldConfig.GetString("gameMode");
if (mode == "creative")
{
byPlayer.WorldData.CurrentGameMode = EnumGameMode.Creative;
byPlayer.WorldData.PickingRange = 100;
byPlayer.BroadcastPlayerData();
}
}
private void Event_SaveGameCreated()
{
if (sapi.WorldManager.SaveGame.PlayStyle == "creativebuilding")
{
sapi.WorldManager.SaveGame.EntitySpawning = false;
}
}
}
}