-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b592c0
commit 18f8927
Showing
3 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
docs/documentation/library/0.0.1-alpha/create-the-main-class.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
title: "Create the Main Class" | ||
layout: doc | ||
--- | ||
|
||
Create a new class in your mod package that implements `MModdingModInitializer`: | ||
|
||
`MModdingExempleMod.java` | ||
```java | ||
public class MModdingExempleMod implements MModdingModInitializer { | ||
|
||
public static MModdingModContainer mod; | ||
|
||
@Override | ||
public List<ElementsInitializer> getElementsInitializers() { | ||
List<ElementsInitializer> elementsInitializers = new ArrayList<>(); | ||
// Check the "Use ElementsInitializer" page | ||
return elementsInitializers; | ||
} | ||
|
||
@Override | ||
public void onInitialize(ModContainer mod) { | ||
MModdingModInitializer.super.onInitialize(); | ||
MModdingExempleMod.mod = MModdingModContainer.from(mod); | ||
|
||
// Your amazing code here | ||
} | ||
} | ||
``` | ||
|
||
<div class="notification is-warning">Warning: You must replace <code>MModdingExempleMod</code> by your mod's name!</div> |
48 changes: 48 additions & 0 deletions
48
...library/0.0.1-alpha/create-the-main-class/use-custom-blockentity-types.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
layout: doc | ||
title: "Use Custom BlockEntity Types" | ||
--- | ||
|
||
With the `CustomBlockEntityType` class provided by the MModding Library, registering a new BlockEntityType is more simple. | ||
|
||
## **Create your BlockEntity class** | ||
|
||
`MModdingBlockEntity.java` | ||
```java | ||
public class MModdingBlockEntity extends BlockEntity { | ||
|
||
public MModdingBlockEntity(BlockPos pos, BlockState state) { | ||
super(NOTHING, pos, state); | ||
} | ||
} | ||
``` | ||
|
||
<div class="notification is-warning">Warning: "NOTHING" is not permanent, we will replace it later.</div> | ||
|
||
## **Create and register your BlockEntityType** | ||
|
||
In your BlockEntityTypes class: | ||
|
||
`BlockEntityTypes.class` | ||
```java | ||
public class BlockEntityTypes { | ||
public static final CustomBlockEntityType<TestBlockEntity> TEST = new CustomBlockEntityType<>(MModdingBlockEntity::new, BLOCK) | ||
.createAndRegister(new Identifier("mmodding_exemple_mod", "testBlockEntityType")); | ||
} | ||
``` | ||
|
||
<div class="notification is-success">Tip: Replace "BLOCK" by the instance of the block that uses the BlockEntity.</div> | ||
|
||
**Update your BlockEntity class** | ||
|
||
Replace "NOTHING" by your BlockEntityType: | ||
|
||
`MModdingBlockEntity.java` | ||
```java | ||
public class MModdingBlockEntity extends BlockEntity { | ||
|
||
public MModdingBlockEntity(BlockPos pos, BlockState state) { | ||
super(BlockEntityTypes.TEST.getBlockEntityTypeIfCreated(), pos, state); | ||
} | ||
} | ||
``` |
49 changes: 49 additions & 0 deletions
49
...ion/library/0.0.1-alpha/create-the-main-class/use-element-initializers.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
layout: doc | ||
title: "Use Element Initializers" | ||
--- | ||
|
||
## **Create an Element Initializer** | ||
|
||
`MModdingModBlocks.java` | ||
```java | ||
public class MModdingModBlocks implements ElementsInitializer { | ||
|
||
// Init a block | ||
public static final CustomBlock MMODDING_BLOCK = new CustomBlock( | ||
QuiltBlockSettings.of(Material.METAL) | ||
) | ||
|
||
@Override | ||
public void register() { | ||
// And register it | ||
MMODDING_BLOCK.register( | ||
new Identifier("mmodding_exemple_mod", "mmodding_block") | ||
); | ||
} | ||
} | ||
``` | ||
|
||
<div class="notification is-success">Tip: For more information about the <code>CustomBlock</code>, go to the <code>CustomBlock</code> Page</div> | ||
|
||
# **Register an Elements Initializer** | ||
|
||
`MModdingExampleMod.java` | ||
```java | ||
public class MModdingExempleMod implements MModdingModInitializer { | ||
|
||
// ... | ||
|
||
@Override | ||
public List<ElementsInitializer> getElementsInitializers() { | ||
List<ElementsInitializer> elementsInitializers = new ArrayList<>(); | ||
// Add the Element Initializer in the List | ||
elementsInitializers.add(new MModdingModBlocks()); | ||
return elementsInitializers; | ||
} | ||
|
||
// ... | ||
} | ||
``` | ||
|
||
By doing this, you won't need to call `MModdingExempleMod#register`. |