Skip to content

Commit

Permalink
push 0.0.2-alpha base docs
Browse files Browse the repository at this point in the history
  • Loading branch information
FirstMegaGame4 committed May 11, 2024
1 parent 3d29567 commit 8d1b9d1
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
}
}
```

<div class="notification is-warning is-dark">Warning: You must replace <code>MModdingExempleMod</code> by your mod's name!</div>
<div class="notification is-warning is-dark">Warning: You must replace <code>MModdingExampleMod</code> by your mod's name!</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ClientElementsInitializer> getClientElementsInitializers() {
List<ClientElementsInitializer> 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<ServerElementsInitializer> getServerElementsInitializers() {
List<ServerElementsInitializer> 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!
Original file line number Diff line number Diff line change
Expand Up @@ -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<ElementsInitializer> getElementsInitializers() {
List<ElementsInitializer> 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);
}
}
```

<div class="notification is-warning is-dark">Warning: You must replace <code>MyMModdingMod</code> by your mod name in CamelCase (following Java Naming Conventions) and <code>yourmodid</code> by your mod identifier.</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}
```

<div class="notification is-success is-dark">Tip: For more information about the <code>CustomBlock</code>, go to the Custom Elements Page</div>

# **Put an Elements Initializer in the Main Class**

`MyMModdingMod.java`
```java
public class MyMModdingMod implements MModdingModInitializer {

// ...

@Override
public List<ElementsInitializer> getElementsInitializers() {
List<ElementsInitializer> 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.

0 comments on commit 8d1b9d1

Please sign in to comment.