Skip to content

Your First Modification

Before starting it's recommended that you have a basic knowledge of Java (classes, variables, importing, etc).

Setup

To get started go to the MCPReborn Github Page and download the latest version (1.20.2 at the time of writing), and follow the instructions on the repo and come back here when you're done. You can also use this video to help get started as well.

All done? Good! Now we can start look through Minecraft's source code! To start, search for the MobEffects class (Double-Shift on Intellij), this class contains all the status effects present within the game.

Mob Effect Creation

In the MobEffects class, you should see something like:

public static final MobEffect MOVEMENT_SPEED = register("speed", (new MobEffect(MobEffectCategory.BENEFICIAL, 3402751)).addAttributeModifier(Attributes.MOVEMENT_SPEED, "91AEAA56-376B-4498-935B-2F7F68070635", (double)0.2F, AttributeModifier.Operation.MULTIPLY_TOTAL));
This is what effects being registered looks like. It contains the id, MobEffect instance, and an attribute modifier.

Basic Effect

We can now starting adding a new effect! To get started add:

public static final MobEffect NAME = register("name", (new MobEffect(MobEffectCategory.BENEFICIAL, 3402751)));

This creates and registers the new effect for us to use! The "name" is the name id of the effect, MAKE SURE IT IS NOT SOMETHING THAT ALREADY EXISTS, It WILL error if you do. Also make sure there are no special characters (', !, ., etc.), or uppercase keys.

The new MobEffect() part creates the effect itself, the MobEffectCategory within the new MobEffect() determines if its on the top row (BENEFICIAL) or bottom row (NEUTRAL/HARMFUL), the 3402751 is just the color in decimal.

From there you can start the game, and give yourself the effect! One thing you will notice is the effect.minecraft.name rather then name for the effect display name. You can learn how to set up resources here.

Attributes

Now to add attribute modifiers!

Adding attributes is fairly simple, but will require a UUID Generator for saving to work.

To start adding the attribute you want it to change add:

.addAttributeModifier(Attributes.MOVEMENT_SPEED)

to the end of (new MobEffect(MobEffectCategory.BENEFICIAL, 3402751)).

Next you'll need to generate a new UUID (link to one above), and insert it right after the chosen attribute like so:

.addAttributeModifier(Attributes.MOVEMENT_SPEED, "RANDOM UUID")

Now to set the modifier, simply add a double for the modifier:

.addAttributeModifier(Attributes.MOVEMENT_SPEED, "RANDOM UUID", 1D)

Finally, select the AttributeModifier.Operation you want to use. ADDITION adds the value to the attribute, MULTIPLY_TOTAL multiplies the attribute including other modifers, and MULTIPLY_BASE multiplies the attribute, ignoring the other modifiers.

After all that you should have something that looks like:

public static final MobEffect NAME = register("name", (new MobEffect(MobEffectCategory.BENEFICIAL, 3402751)).addAttributeModifier(Attributes.MOVEMENT_SPEED, "RANDOM UUID", 1D, AttributeModifier.Operation.ADDITION));

Now start the game and give it a test run!