- Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathErrorPrevention-UsingModInfo.java
More file actions
Latest commit
55 lines (42 loc) · 1.93 KB
/
Copy pathErrorPrevention-UsingModInfo.java
File metadata and controls
55 lines (42 loc) · 1.93 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
45
46
47
48
49
50
51
52
53
54
55
/** Error Prevention: Creating a ModInfo file */
/*
This has been covered in other tutorials, but I feel it's important enough to mention again.
I always make a ModInfo class that defines my mod variables such as my mod id then I reference that instead of
hard-coding the ID everwhere.
Not only does this prevent me from making typos, but it also allows me to change my mod id, mod name or other
variable in one single location and all of my code will still be correct.
Here's how you can make one for yourself:
*/
@Mod(modid = ModInfo.ID, name = ModInfo.NAME, version = ModInfo.VERSION)
@NetworkMod(clientSideRequired=true, serverSideRequired=false,
channels = {ModInfo.CHANNEL}, packetHanlder = ALPacketHandler.class)
publicfinalclassArcaneLegacy
{
@Instance(ModInfo.ID)
publicstaticArcaneLegacyinstance;
// rest of main class here
}
// And ModInfo would look like this (in a separate class, not in the main mod):
publicclassModInfo
{
publicstaticfinalStringID = "coolaliasarcanelegacy";
publicstaticfinalStringNAME = "Arcane Legacy";
publicstaticfinalStringVERSION = "0.1.0";
publicstaticfinalStringCLIENT_PROXY = "coolalias.arcanelegacy.client.ClientProxy";
publicstaticfinalStringCOMMON_PROXY = "coolalias.arcanelegacy.common.CommonProxy";
publicstaticfinalStringCHANNEL = "ChannelCAAL";
}
/*
You can of course add any other information related to your mod here as well, such as CHANNELS for your packet handler.
Whenever you would put "modid" in your code, change it to ModInfo.ID, such as in the Item method registerIcons:
*/
@Override
@SideOnly(Side.CLIENT)
publicvoidregisterIcons(IconRegistericonRegister)
{
this.itemIcon = iconRegister.registerIcon(ModInfo.ID + ":" + this.getUnlocalizedName().substring(5));
}
/*
If you ever change your mod id, now you only need to change it in one place, ModInfo, and ALL of your code will still
be 100% correct. Also you won't ever have to worry about typos
*/