2024-12-10 17:47:06|Myriagame |source:minecraft skins
First of all, the ChatCommandsManager module is added to the Run/MODS directory of the project to facilitate debugging.
Then add a function to determine whether the module contains the ChatcommandsManager module.
example:
<<<<<<<<<<], the, the, "assh: java;">> portatic?
For (Imodinfo Modinfo: Modlist.get (). Getmods ()) {) {) {
If (modinfo.getmodid (). Equals ("ccm") {{
Return true;
}
}
Return false;
}
Then call this function to judge in the main function. If not, throw Runtimeexception. On the contrary, the operation of the configuration file is performed (when the module is loadedBecause the ChatCommandsManager module defaults to the last one to be loaded).
example:
Public POS () Throws IOEXCEPION {Minecraftforge.event_bus.register (this);
Init (); // The initialization function is called in the main class.
}
Public Static Void Init () Throws IOEXception {{
If (! Hasapi ()) {// Detect whether it contains the ChatcommandsManager module.
Throw New Runtimeexception ("POS MOD Requires ChatCommandsManager Mod!"););
}
If (! New File ("Config/CCM/MODS"). Exist ()) {// Detect and create a directory.
New file ("config/ccm/mods"). Mkdirs ();
}
If (! New File ("Config/CCM/MODS/FPOS.JSON"). ExistS ()) {// Test and write configuration files.
JsonObject Object = New JSONObject (); Object.addproperty ("name", "fpos"); // Write the configuration file "name"
Object.addproperty ("ID", "POS"); // Write the configuration file item "ID"
Object.addproperty ("main", "cn.ksmcbrigade.pos.manager"); // Write the configuration file item "main"
Object.addproperty ("function", "runfpos"); // write the configuration file item "Function"
Files.write (Paths.get ("Config/CCM/MODS/FPOS.JSON"), object.tostring (). Getbytes ()); // Write the configuration to the file.
}
}
The above code may be thrown out of IOEEXception. Please use the Try/Catch package or add an exception signature (the example is an exception signature), otherwise it will not be compiled 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.pos;import network.minecraft.client.minecraft;
import network.minecraft.network.chat.component;
import network.minecraft.World.entity.player.player;
Import java.util.arrays;
public class manager {
Pbstic static Void Runfpos
Player player = minecraft.getInstance (). Player;
If (Arrays.equals (Args, New String [0])) {{
Player.SendMessage (Component.nullToEMPTY ("POS:"+Player.getx ()+","+Player.get ()+","+Player.getz ()), Player.getuum ());}
Else {
Player friend = null;
for(Player entity:player.getLevel().getEntitiesOfClass(Player.class,player.getBoundingBox().inflate(1000))){
If (entity.getName (). GetString (). Equals (ARGS [0])) {) {
Friend = Entity;
}
}
If (friend == null) {
Player.SendMessage (component.nulltoEMPTY ("caner find friend!"), Player.getuuid ()););););););
}
Else {
Player.SendMessage (Component.nullToEMPTY ("POS:"+Friend.getx ()+","+Friend.get ()+","+Friend.getz ()), Player.Getuituum ());}
}
}
}
Tip: Player and ARGS parameters of the function must be added even if you do n’t need to add it, otherwise the input instruction will report an error and cause the game to collapse.
Note: You need to export the module after exporting the starter to test in the starter. Testing in the IDE may report an error.
National Service DNF Dark Ni
2025-01-28 09:19:27The new screenshot of the be
2025-01-28 09:18:57The 15th anniversary wallpap
2025-01-28 09:18:273DM Xuanyuan Sinicization Gr
2025-01-28 09:17:57French magazine is the first
2025-01-28 09:17:27The sneak game "Republic" wi
2025-01-28 09:16:57The story between humans and
2025-01-28 09:16:27Capture "Trinity 3: Artifact
2025-01-28 09:15:27Wind direction change "Myste
2025-01-28 09:14:57DICE's new project "Dream" w
2025-01-28 09:14:27Pirate Minecraft Skins
Minecraft Skins
2024-12-10 04:11:27Pirate Minecraft Skins
Minecraft Skins
2024-12-10 04:11:26Master Minecraft Skins
Minecraft Skins
2024-12-10 04:11:25King Minecraft Skins
Minecraft Skins
2024-12-10 04:11:25Guide Minecraft Skins
Minecraft Skins
2024-12-10 04:11:24Dark Knight Minecraft Skins
Minecraft Skins
2024-12-10 04:11:23Sparta Minecraft Skins
Minecraft Skins
2024-12-10 04:11:23Moncraft Skins of the War
Minecraft Skins
2024-12-10 04:11:22Red Witch Minecraft Skins
Minecraft Skins
2024-12-10 04:11:22Golden Cavaliers Minecraft S
Minecraft Skins
2024-12-10 04:11:22