Minecraft Blogs / Tutorial

How to make effect blocks

  • 454 views, 2 today
  • 2
  • 2
thereal_therealpika's Avatar thereal_therealpika
Level 12 : Journeyman Birb
3
This tutorial will show you how to make your own effect blocks, perfect for parkour maps. When you step on these blocks, you will get effects like speed, jump boost, etc.

Here's what it might look like when you're finished:



Ok, so let's get started. First, you're gonna need to make a datapack. Locate your world's folder and find the folder called datapacks. Make a new folder inside and call it whatever you want. Then inside that, make another folder called data. Now, inside that you need to create another folder. This one has be be called anything, but it has to be a namespace. So all lowercase and no spaces, or special characters. An example of a good namespace is "effect_blocks" an example of a bad namespace is "EFFECT bLoCks!". I'll be using the namespace "tutorial". Your file tree should now look as follows:
How to make effect blocks

Next, inside your original folder (not the data one or the namespace one) create a new file called "pack.mcmeta". Inside this file paste the following:

{
"pack": {
"pack_format": 6,
"description": "Effect blocks!"
}
}


Now in the namespace folder create a NEW folder called "functions" exactly like that. Now make a new file in it called "tick.mcfunction".

Great. Now go back to the folder you made called data and make a new folder called "minecraft".

How to make effect blocks

Then in the minecraft folder create a new folder called "tags" and inside that make one called "functions". Then make a new file called tick.json and place the following in it. (Replace the word tutorial with whatever you picked for your namespace.)

{
"values": [
"tutorial:tick"
]
}

Great, now your tick function will run every game tick. Now for the fun part; adding effects.
Paste this code into your tick.mcfunction file:

execute as @a at @s if block ~ ~-1 ~ magenta_glazed_terracotta run effect give @s minecraft:speed 1 2 false

Then, if you want you can swap out the block and effect to your liking. Copy / paste this for each effect block you want, and you're good!

Here's some tips:

  • If you want the effect to be hidden, set the false at the end to true, this will hide the particles and make you have to open your inventory to see the effect (it won't show up in the top right)
  • If you want to stop jumps like I showed in the video, just give the player jump boost 131 and they won't be able to jump!
  • The first number after the effect is the duration keep this at one if you want it to go away after you step off at it, or change it to anything you like, for example I changed the crying obsidian one to 5 so it lasts 5 seconds after you leave the block
  • The number after the duration is the amplifier. Set it to the level of effect you want (minus 1) It can be anything from 0 to 255. The higher the number, the more severe the effect will be.
  • The effects will last a second after you leave the block, and if you don't want this, you can include this line of code at the end of your function (do it for each effect block you have and replace the block and effect accordingly) Just keep in mind if you do this then you will not be able to use the effect you are using it for in any other way, so potions etc will be useless. And if you have multiple different blocks that give the effect in ANY way, they will not work. I wouldn't recommend doing this, it's kind of a last resort.
    execute as @a at @s unless block ~ ~-1 ~ magenta_glazed_terracotta run effect clear @s speed


That's it, thanks for reading!

If you're lazy or having problems you can download the pre made datapack here.
Tags

Create an account or sign in to comment.

Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome