Comparing Java Coding and MCreator Procedures: Two Paths for Modding

Started by herobrine43 on

Topic category: General discussion

Last seen on 11:25, 13. Sep 2024
Joined Dec 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Comparing Java Coding and MCreator Procedures: Two Paths for Modding

When creating mods for Minecraft, two different methods are often used: **Java coding** and **MCreator’s procedure system** (often referred to as plantext style). Both approaches offer unique benefits, and each comes with its own set of challenges. Let’s explore the differences between the two, using examples that help illustrate how each works in practice.

---

### **Java Coding Example**:  

In Java, you have full control over the structure and functionality of your mod. This method allows for deep customization, but it requires knowledge of Java syntax and Minecraft’s modding API.

Here’s an example of Java code that spawns a certain number of Silverfish based on the type of block at specific coordinates:

```java

import java.util.Random;

public void spawnSilverfish(Block blockAtPos, int x, int y, int z, World world) {

    Random random = new Random();

    if (blockAtPos == Blocks.OBSIDIAN) {

        int numberOfSilverfish = random.nextInt(3) + 1; // Random number between 1 and 3

        for (int i = 0; i < numberOfSilverfish; i++) {

            world.spawnEntity(new EntitySilverfish(world), x, y, z);

        }

    } else if (blockAtPos == Blocks.DIRT) {

        int numberOfSilverfish = random.nextInt(2) + 1; // Random number between 1 and 2

        for (int i = 0; i < numberOfSilverfish; i++) {

            world.spawnEntity(new EntitySilverfish(world), x, y, z);

        }

    }

}

```

In this example:

- The **block at the given position** is checked. If it is Obsidian, a random number of Silverfish (between 1 and 3) is spawned. 

- For Dirt blocks, a similar process occurs, but the range is between 1 and 2.

This level of **manual control** allows for detailed logic, but it requires a solid understanding of Java syntax and how Minecraft’s world and entity systems function.

---

### **MCreator Procedures (Plantext Style) Example**:  

On the other hand, MCreator offers a **visual procedure system** that allows you to build mod logic without writing Java code. This system uses pre-built blocks that represent the same actions you’d write in Java, but it’s easier to use for non-programmers.

Here’s an example of how this might look in MCreator’s **procedure blocks** (plantext style):

1. **Trigger**: On a specific block being broken.

2. **Condition**: Check if the block at coordinates `x, y, z` is Obsidian.

3. **Action**: Set a global variable `numberOfSilverfish` to a random number between 1 and 3.

4. **Action**: Spawn Silverfish at the coordinates `x, y, z` based on the value of `numberOfSilverfish`.

5. **Else If Condition**: Check if the block is Dirt, and perform a similar action, but with a random number between 1 and 2.

This might look something like this when visualized as a procedure in MCreator:

```

If block at (x, y, z) == Obsidian:

    Set variable numberOfSilverfish = random between 1 and 3

    Spawn Silverfish at (x, y, z)

Else If block at (x, y, z) == Dirt:

    Set variable numberOfSilverfish = random between 1 and 2

    Spawn Silverfish at (x, y, z)

```

This visual **plantext format** removes the need to manually type Java code, allowing you to **drag and drop** actions and conditions into place. It simplifies mod creation but may lack the depth and flexibility that manual Java coding offers.

### **Key Takeaways**:

- **Java Coding**: Requires knowledge of programming but offers total control over the mod. It allows for complex behavior and deep customization, but the learning curve is steeper.

- **MCreator Procedures (Plantext Style)**: A great tool for beginners or those who want to build mods quickly without diving into code. It provides an easier, visual way to create mods, though it may be limited for more advanced features.

Both methods have their advantages, and which one you choose depends on what kind of mod you want to create and how comfortable you are with programming.