-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathStellarForgeEventHook.java
More file actions
44 lines (38 loc) · 1.61 KB
/
StellarForgeEventHook.java
File metadata and controls
44 lines (38 loc) · 1.61 KB
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
package stellarium;
import net.minecraft.world.World;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import stellarapi.api.SAPICapabilities;
import stellarium.stellars.StellarManager;
import stellarium.stellars.layer.CelestialManager;
public class StellarForgeEventHook {
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void preAttachCapabilities(AttachCapabilitiesEvent<World> event) {
World world = event.getObject();
// Check if it's initial
if(!world.isRemote && world.provider.getDimension() != 0)
return;
// Now setup StellarManager here
StellarManager manager = StellarManager.loadOrCreateManager(world);
if(!world.isRemote)
manager.setup(new CelestialManager(false));
// On client - load default before the packet arrives
manager.handleServerWithoutMod();
if(manager.getCelestialManager() == null && world.hasCapability(SAPICapabilities.CELESTIAL_CAPABILITY, null))
manager.setup(StellarSky.PROXY.getClientCelestialManager().copyFromClient());
}
@SubscribeEvent
public void onSyncConfig(ConfigChangedEvent.OnConfigChangedEvent event) {
if(StellarSkyReferences.MODID.equals(event.getModID()))
StellarSky.INSTANCE.getCelestialConfigManager().syncFromGUI();
}
@SubscribeEvent
public void onWorldUnload(WorldEvent.Unload event) {
World world = event.getWorld();
if(world.isRemote)
StellarSky.PROXY.removeSkyModel(world);
}
}