Block Effects

This is a tutorial for effects with blocks.

We will now start with a radius from the location of a block. This code loops entities in a radius of 5 around the block's position.

loop all entities in radius 5 around blocks's location:


Now we will add an event for in which this loop will occur. For example, I will be using On Place as the event

on place:
loop all entities in radius 5 around block's location:


Now, we will add an effect to the loop. Some effects can only be used for some things like blocks or entities.

on place:
loop all entities in radius 5 around block's location:
teleport loop-entity to block

Now, when we place a block, it will loop all entities in a radius of 5, and teleport them to the block. But we want only dropped items, not animals or monsters. We can define 'loop-entity' by adding a condition.

on place:
loop all entities in radius 5 around block's location
if loop-entity is a dropped item:
teleport loop-entity to block


This makes it so when you place some block like sandstone, it teleports all dropped items in a radius of 5 blocks to the location of the block you placed

You can also change the event to be more specific, like instead of on place (of any block), we can change it to on place of sandstone.

on place of sandstone:
loop all entities in radius 5 around block's location:
if loop-entity is a dropped item:
teleport loop-entity to block


This makes it so when you place a sandstone block, it loops all dropped items around it (radius of 5 blocks) and teleports it to the sandstone block.

Now, we want it to keep on doing this process over and over again. We can add loops and a wait time to make this process repeat.

on place of sandstone:
loop all entities in radius 5 around block's location:
loop 10 times:
wait 1 second
if loop-entity is a dropped item:
teleport loop-entity to block


This makes it so when you place a sandstone block, it loops all dropped items in a radius of 5 blocks, then it waits one second and teleports the dropped item to the block. This process repeats 10 times, caused by the
'loop 10 times'



That's it for the tutorial, if you have any questions, please feel free to message me.