-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathClientProxy.java
130 lines (103 loc) · 5.22 KB
/
ClientProxy.java
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package stellarium;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.client.Minecraft;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import stellarium.config.EnumViewMode;
import stellarium.config.IConfigHandler;
import stellarium.stellars.Optics;
import stellarium.stellars.StellarManager;
public class ClientProxy extends CommonProxy implements IProxy {
private static final String clientConfigCategory = "clientconfig";
private static final String clientConfigOpticsCategory = "clientconfig.optics";
@Override
public void preInit(FMLPreInitializationEvent event) {
manager = new StellarManager(Side.CLIENT);
this.setupConfigManager(event.getSuggestedConfigurationFile());
MinecraftForge.EVENT_BUS.register(new StellarClientHook());
FMLCommonHandler.instance().bus().register(new StellarKeyHook());
}
@Override
public void load(FMLInitializationEvent event) throws IOException {
super.load(event);
manager.initializeStars();
}
@Override
public void postInit(FMLPostInitializationEvent event) {
super.postInit(event);
}
@Override
public void setupConfigManager(File file) {
super.setupConfigManager(file);
cfgManager.register(clientConfigCategory, new IConfigHandler() {
Property mag_Limit, turb, moon_Frac, minuteLength, hourToMinute, viewMode;
@Override
public void setupConfig(Configuration config, String category) {
config.setCategoryComment(category, "Configurations for client modifications.\n"
+ "Most of them are for rendering/view.");
config.setCategoryLanguageKey(category, "config.category.client");
config.setCategoryRequiresMcRestart(category, false);
mag_Limit=config.get(category, "Mag_Limit", 5.0);
mag_Limit.comment="Limit of magnitude can be seen on naked eye.\n" +
"If you want to increase FPS, you can set this property a bit little (e.g. 0.3)\n" +
"and FPS will be exponentially improved";
mag_Limit.setRequiresMcRestart(false);
mag_Limit.setLanguageKey("config.property.client.maglimit");
turb=config.get(category, "Twinkling(Turbulance)", 1.0);
turb.comment="Degree of the twinkling effect of star.\n"
+ "It determines the turbulance of atmosphere, which actually cause the twinkling effect";
turb.setRequiresMcRestart(false);
turb.setLanguageKey("config.property.client.turbulance");
moon_Frac=config.get(category, "Moon_Fragments_Number", 16);
moon_Frac.comment="Moon is drawn with fragments\n" +
"Less fragments will increase FPS, but the moon become more defective";
moon_Frac.setRequiresMcRestart(false);
moon_Frac.setLanguageKey("config.property.client.moonfrac");
minuteLength = config.get(category, "Minute_Length", 20.0);
minuteLength.comment = "Length of minute in tick. (The minute & hour is displayed on HUD as HH:MM format)";
minuteLength.setRequiresMcRestart(false);
minuteLength.setLanguageKey("config.property.client.minutelength");
hourToMinute = config.get(category, "Hour_Length", 60);
hourToMinute.comment = "Length of hour in minute. (The minute & hour is displayed on HUD as HH:MM format)";
hourToMinute.setRequiresMcRestart(false);
hourToMinute.setLanguageKey("config.property.client.hourlength");
viewMode = config.get(category, "Mode_HUD_Time_View", "empty")
.setValidValues(EnumViewMode.names);
viewMode.comment = "Mode for HUD time view.\n"
+ " 3 modes available: empty, hhmm, tick.\n"
+ "Can also be changed in-game using key.";
viewMode.setRequiresMcRestart(false);
viewMode.setLanguageKey("config.property.client.modeview");
viewMode.setValue(manager.getViewMode().getName());
List<String> propNameList = Arrays.asList(mag_Limit.getName(),
moon_Frac.getName(), turb.getName(), viewMode.getName(),
minuteLength.getName(), hourToMinute.getName());
config.setCategoryPropertyOrder(category, propNameList);
}
@Override
public void loadFromConfig(Configuration config, String category) {
manager.mag_Limit=(float)mag_Limit.getDouble();
manager.turb=(float)turb.getDouble();
manager.imgFrac=moon_Frac.getInt();
manager.minuteLength = minuteLength.getDouble();
manager.anHourToMinute = hourToMinute.getInt();
manager.setViewMode(EnumViewMode.getModeForName(viewMode.getString()));
}
});
cfgManager.register(clientConfigOpticsCategory, Optics.instance);
}
@Override
public World getDefWorld() {
return Minecraft.getMinecraft().theWorld;
}
}