From 8d1b9d15d98a9a22a17c6cd2c4850e0b7166466c Mon Sep 17 00:00:00 2001 From: FirstMegaGame4 <84094287+FirstMegaGame4@users.noreply.github.com> Date: Sat, 11 May 2024 13:23:16 +0200 Subject: [PATCH] push 0.0.2-alpha base docs --- .../create-the-main-class.markdown | 8 +-- .../use-element-initializers.markdown | 2 +- ...t-side-and-server-side-management.markdown | 59 +++++++++++++++++++ .../create-the-main-class.markdown | 36 +++++++++++ ...ements-with-elements-initializers.markdown | 45 ++++++++++++++ 5 files changed, 145 insertions(+), 5 deletions(-) diff --git a/docs/documentation/library/0.0.1-alpha/create-the-main-class.markdown b/docs/documentation/library/0.0.1-alpha/create-the-main-class.markdown index 4641864..3d5c354 100644 --- a/docs/documentation/library/0.0.1-alpha/create-the-main-class.markdown +++ b/docs/documentation/library/0.0.1-alpha/create-the-main-class.markdown @@ -5,9 +5,9 @@ layout: doc Create a new class in your mod package that implements `MModdingModInitializer`: -`MModdingExempleMod.java` +`MModdingExampleMod.java` ```java -public class MModdingExempleMod implements MModdingModInitializer { +public class MModdingExampleMod implements MModdingModInitializer { public static MModdingModContainer mod; @@ -21,11 +21,11 @@ public class MModdingExempleMod implements MModdingModInitializer { @Override public void onInitialize(ModContainer mod) { MModdingModInitializer.super.onInitialize(); - MModdingExempleMod.mod = MModdingModContainer.from(mod); + MModdingExampleMod.mod = MModdingModContainer.from(mod); // Your amazing code here } } ``` -
Warning: You must replace MModdingExempleMod by your mod's name!
+
Warning: You must replace MModdingExampleMod by your mod's name!
diff --git a/docs/documentation/library/0.0.1-alpha/create-the-main-class/use-element-initializers.markdown b/docs/documentation/library/0.0.1-alpha/create-the-main-class/use-element-initializers.markdown index c06031b..70e1e4d 100644 --- a/docs/documentation/library/0.0.1-alpha/create-the-main-class/use-element-initializers.markdown +++ b/docs/documentation/library/0.0.1-alpha/create-the-main-class/use-element-initializers.markdown @@ -12,7 +12,7 @@ public class MModdingModBlocks implements ElementsInitializer { // Init a block public static final CustomBlock MMODDING_BLOCK = new CustomBlock( QuiltBlockSettings.of(Material.METAL) - ) + ); @Override public void register() { diff --git a/docs/documentation/library/0.0.2-alpha/introduction/client-side-and-server-side-management.markdown b/docs/documentation/library/0.0.2-alpha/introduction/client-side-and-server-side-management.markdown index 316abee..e4af817 100644 --- a/docs/documentation/library/0.0.2-alpha/introduction/client-side-and-server-side-management.markdown +++ b/docs/documentation/library/0.0.2-alpha/introduction/client-side-and-server-side-management.markdown @@ -2,3 +2,62 @@ title: "Client-Side and Server-Side Classes with their Own Management" layout: doc --- + +# **Client-Side** + +To create a Client Side Main Class with the MModding Library Base Content, you must create a class that implements `MModdingClientModInitializer`: + +`MyMModdingClientMod.java` +```java +public class MyMModdingClientMod implements MModdingClientModInitializer { + + @Override + public Config getConfig() { + // We will keep this value as null for the moment + return null; + } + + @Override + public List getClientElementsInitializers() { + List clientElementsInitializers = new ArrayList<>(); + // ... + return clientElementsIntializers; + } + + @Override + public void onInitializeClient(AdvancedModContainer mod) { + mod.getLogger().log("Hello MModding Client World!"); + } +} +``` + +The `ClientElementsInitializer` creation is very likely the same as `ElementsInitializer`'s one, and it's up to you to use them to manage your Client Elements! + +# **Server-Side** + +To create a Server Side Main Class with the MModding Library Base Content, you must create a class that implements `MModdingServerModInitializer`: + +```java +public class MyMModdingServerMod implements MModdingServerModInitializer { + + @Override + public Config getConfig() { + // We will keep this value as null for the moment + return null; + } + + @Override + public List getServerElementsInitializers() { + List serverElementsInitializers = new ArrayList<>(); + // ... + return serverElementsInitializers; + } + + @Override + public void onInitializeClient(AdvancedModContainer mod) { + mod.getLogger().log("Hello MModding Server World!"); + } +} +``` + +The `ServerElementsInitializer` creation is very likely the same as `ElementsInitializer`'s one, and it's up to you to use them to manage your Server Elements! diff --git a/docs/documentation/library/0.0.2-alpha/introduction/create-the-main-class.markdown b/docs/documentation/library/0.0.2-alpha/introduction/create-the-main-class.markdown index e906801..657f683 100644 --- a/docs/documentation/library/0.0.2-alpha/introduction/create-the-main-class.markdown +++ b/docs/documentation/library/0.0.2-alpha/introduction/create-the-main-class.markdown @@ -2,3 +2,39 @@ title: "Create the Main Class" layout: doc --- + +Create a new class in your mod package that implements `MModdingModInitializer`: + +`MyMModdingMod.java` +```java +public class MyMModdingMod implements MModdingModInitializer { + + @Override + public Config getConfig() { + // We will keep this value as null for the moment + return null; + } + + @Override + public List getElementsInitializers() { + List elementsInitializers = new ArrayList<>(); + // Check the "Use ElementsInitializer" page + return elementsInitializers; + } + + @Override + public void onInitialize(AdvancedModContainer mod) { + mod.getLogger().log("Hello MModding World!"); + } + + public static String id() { + return "yourmodid"; + } + + public static Identifier createId(String path) { + return new Identifier(MyMModdingMod.id(), path); + } +} +``` + +
Warning: You must replace MyMModdingMod by your mod name in CamelCase (following Java Naming Conventions) and yourmodid by your mod identifier.
diff --git a/docs/documentation/library/0.0.2-alpha/introduction/manage-elements-with-elements-initializers.markdown b/docs/documentation/library/0.0.2-alpha/introduction/manage-elements-with-elements-initializers.markdown index e3e9114..43a2a14 100644 --- a/docs/documentation/library/0.0.2-alpha/introduction/manage-elements-with-elements-initializers.markdown +++ b/docs/documentation/library/0.0.2-alpha/introduction/manage-elements-with-elements-initializers.markdown @@ -2,3 +2,48 @@ title: "Manage Elements with Elements Initializers" layout: doc --- + +The MModding Library provide the `ElementsInitializer` interface. This interface is used to initialize mod elements, and register them. + +# **Create an Element Initializer** + +`MyMModdingModBlocks.java` +```java +public class MyMModdingModBlocks implements ElementsInitializer { + + // Creation of a Simple Block + public static final CustomBlock MMODDING_BLOCK = new CustomBlock( + QuiltBlockSettings.of(Material.METAL) + ); + + @Override + public void register() { + // And we register it + MMODDING_BLOCK.register(MyMModdingMod.createId("mmodding_block")); + } +} +``` + +
Tip: For more information about the CustomBlock, go to the Custom Elements Page
+ +# **Put an Elements Initializer in the Main Class** + +`MyMModdingMod.java` +```java +public class MyMModdingMod implements MModdingModInitializer { + + // ... + + @Override + public List getElementsInitializers() { + List elementsInitializers = new ArrayList<>(); + // Add the Element Initializer in the List + elementsInitializers.add(new MyMModdingModBlocks()); + return elementsInitializers; + } + + // ... +} +``` + +By doing this, the `MModdingModInitializer` interface will directly run your `ElementsInitializer` objects before the execution of the `MModdingModInitializer#onInitialize` method.