Super Powers

Introduction

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. In this tutorial we’ll apply some effects that will give players some super powers!

Speed effect

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.

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)
})

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)
})

Levitate effect

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 2 and use just 1 for the strength of the effect.

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

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), FillOperation.Replace)
})

Try special effects

Go back into the Minecraft world and try all of the new super powers!