First of all, the VAPE Manager module is added to the Run/MODS directory of the project to facilitate debugging.
Then add a function to determine whether the module loads the Vape Manager module.
example:
<<<<<<<<<<], the, the, "assh: java;">> portatic?
For (Imodinfo Modinfo: Modlist.get (). Getmods ()) {) {) {
If (modinfo.getmodid (). Equals ("vm") {{
Return true;
}
}
Return false;
}
Then call him to judge in the main function. If not, it will throw Runtimeexception. On the contrary, the operation of the writing configuration file is performed (when the module is loaded, the configuration file is normal.Because the VAPE Manager module will be loaded by the last one by default).
example:
if (! Hasapi ())) {// to detect whether there is a front module Vape Manager.Throwing new runTimeexception ("NOFALL Requires Vape Manager mod.");
}
if (! New File ("Config/VM/MODS"). Exist ()) {// Judge and create the directory where the configuration file is located.
New file ("config/vm/mods"). Mkdirs ();
}
if (! New File ("Config/VM/MODS/NOFALL.json"). ExistS ()) {// Detect whether the configuration file exists.
JsonObject Object = New JSONObject ();
Object.addproperty ("name", "not"); // Write the configuration file item "name".
Object.addproperty ("ID", "nf"); // Write the configuration file item "ID".
Object.addproperty ("main", "cn.ksmcBrigade.nf.manager"); // Write the configuration file item "main".Object.addproperty ("function", "none"); // Write the configuration file item "function".
Object.addproperty ("function_2", "run"); // Write the configuration file item "Function_2".
Object.addproperty ("gui_main", "none"); // Write the configuration file "gui_main".
Object.addproperty ("gui_function", "none"); // Write the configuration file item "Gui_function".
Files.write (Paths.get ("Config/VM/Mods/NOFALL.JSON"), Object.tostring (). Getbytes ()); // Write the configuration file into the file.
}
The above code may be thrown out of IOEEXception. Please use the Try/Catch package or add an exception signature, otherwise it will not be able to compile and run normally.
Next create a class file specified in the configuration file, and then add a corresponding function to the class file.
example:
Package cn.ksmcbrigade.nf;import network.minecraft.World.entity.player.player;
public class manager {
Public Static Void Run (Player Player) {{
Player.FallDistance = 0;
}
}
Tip: If the function of the function is not needed, it must be added if it is not used, otherwise the function will be reported and the game crashes.
Note: You need to export the module after exporting the starter to test in the starter. Testing in the IDE may report an error.