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 new file mode 100644 index 0000000..3cdb383 --- /dev/null +++ b/docs/documentation/library/0.0.1-alpha/create-the-main-class.markdown @@ -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 getElementsInitializers() { + List 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 + } +} +``` + +
Warning: You must replace MModdingExempleMod by your mod's name!
diff --git a/docs/documentation/library/0.0.1-alpha/create-the-main-class/use-custom-blockentity-types.markdown b/docs/documentation/library/0.0.1-alpha/create-the-main-class/use-custom-blockentity-types.markdown new file mode 100644 index 0000000..0e0ec1b --- /dev/null +++ b/docs/documentation/library/0.0.1-alpha/create-the-main-class/use-custom-blockentity-types.markdown @@ -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); + } +} +``` + +
Warning: "NOTHING" is not permanent, we will replace it later.
+ +## **Create and register your BlockEntityType** + +In your BlockEntityTypes class: + +`BlockEntityTypes.class` +```java +public class BlockEntityTypes { + public static final CustomBlockEntityType TEST = new CustomBlockEntityType<>(MModdingBlockEntity::new, BLOCK) + .createAndRegister(new Identifier("mmodding_exemple_mod", "testBlockEntityType")); +} +``` + +
Tip: Replace "BLOCK" by the instance of the block that uses the BlockEntity.
+ +**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); + } +} +``` 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 new file mode 100644 index 0000000..bb0fd54 --- /dev/null +++ b/docs/documentation/library/0.0.1-alpha/create-the-main-class/use-element-initializers.markdown @@ -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") + ); + } +} +``` + +
Tip: For more information about the CustomBlock, go to the CustomBlock Page
+ +# **Register an Elements Initializer** + +`MModdingExampleMod.java` +```java +public class MModdingExempleMod implements MModdingModInitializer { + + // ... + + @Override + public List getElementsInitializers() { + List 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`.