Minecraft
Advanced
40 mins
155 points
What you need:
  • Chromebook/Laptop/PC
  • Minecraft Education Edition

Super Powers

The capabilities of your player, other players, or mobs are changed when you apply effects to them. Depending on which effect is chosen, you can either add a special power or reduce the health of a player or mob. 

1 - Open Minecraft

In this project we are going to learn how to apply affects to players and mobs. In this tutorial we’ll apply some effects that will give players some super powers!

First, open Minecraft Education Edition, login, create a new world and open the Code Builder.

2 - Speed

First we are going to apply an effect to your player that makes you run super fast!

An effect applied to your player will last for the number of seconds you tell it to. This is the effect’s duration. You also give a value for the strength of the effect, called the amplifier amount.

Add the following code to make an interaction so that when your player eats an apple, they are nourished and can run with speed for 10 seconds. Amplify the speed effect by 120.

player.onItemInteracted(APPLE, function () {
    mobs.applyEffect(SPEED, mobs.target(LOCAL_PLAYER), 10, 120)
})

You will then need to add some apples to your inventory (press E) and eat an apple. When you do the code will trigger and you will be able to run super fast for 10 seconds!



3 - Night vision

If you could see in the dark, you could move around without being easily noticed by other players or mobs. You could also keep building when night comes.

Make a chat command that changes the time to night and apply the night vision affect to your player. Set the duration to 10 and amplify the effect by 120.

player.onChat("night", function () {
    gameplay.timeSet(gameplay.time(MIDNIGHT))
    mobs.applyEffect(NIGHT_VISION, mobs.target(LOCAL_PLAYER), 10, 120)
})

4 - Levitation

We’ve all dreamed of being able to fly. Well, make it happen on your command! Create a new chat command called fly. In the chat command, apply the levitation effect to all players and all mobs so that everyone will fly. Set the duration for 5 and use just 2 for the strength of the effect.

player.onChat("fly", function () {
    mobs.applyEffect(LEVITATION, mobs.target(ALL_ENTITIES), 5, 2)
})

5 - Fireproof

Can you take the heat? Well, you can if you’re fireproof. Make a chat command named fireproof. In the command, apply the fire resistance affect to your player and fill in fire all around you. When you use the command, see if you can walk through fire without getting burned!

player.onChat("fireproof", function () {
    mobs.applyEffect(FIRE_RESISTANCE, mobs.target(LOCAL_PLAYER), 10, 120)
    blocks.fill(FIRE, pos(-5, 0, -5), pos(5, 0, 5))
})

Join our club 😃

To view the remaining 1 steps and access hundreds of other coding projects please login or create an account.

Copyright Notice
This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.
🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more