# Move Blocks

## Recommended Posts

Hello, I would like to know how can I do to move a block, as the "redstone in motion", example: I hit with a pick on a block and he walks forward.

how to do this?

Thank you.

##### Share on other sites

Try to destroy block and place another in another place

##### Share on other sites

Try to destroy block and place another in another place

I think destroy and recreate the block would not quite right first because that would leave the particles block, moreover would not be the same block

would not have a way to change the position of the block type:

```public void foward(Block block){
b = block.getPositon();
b.z+1;
}
```

##### Share on other sites

You can check if the player starts to break the block then remove the block and place it where you want.

I think you cannot move blocks.

##### Share on other sites

Well, I am not sure what author ment by "redstone in motion", but if you simply want to move block then all above is probably the best way to handle it.

Then there are ofc few "extras" that depend on what you actually want to archieve.

1. "Pushing" block in x/z plane with "cross" style:

You simply use:

public void onBlockClicked(world, x, y, z, player)

Since you have player here you can calculate its relative position and setBlock to 0, then set the same block on +1 cooridnate (in given direction).

2. "Pushing" block in x/z circle plane:

In case you want to get farther "push" and you want block to go in some direction under angle I suggest learning Java Math and sin/cos. You can always look/get code from MC source (it is commonly used in a lot of classes).

3. Actually making MOTION - this is fun.

You will again use onBlockClicked() but this time you have to use entity and some math. The momnt you click/hit block you generate new Entity and give it a block render with same texture. Every entity has a motion X,Y,Z. Use this to give it a speed and actually move it in some direction, then get it's position, calculate the coordinate and "kill" the entity, then place there your block.

Last option will require some expo with renderers and enTITIES (lol) so if you are "new" don't expect miracles.

P.S: if you want to apply "pushy" effect to all blocks (even vanilla ones) you can use PlayerEvents to get when player hits stuff, get this "stuff" data and then do same like in any of 1,2,3, only this time not in block class.

1.7.10 is no longer supported by forge, you are on your own.

##### Share on other sites

In the moment all i want is change the block of position , maybe animations after.

thank you

##### Share on other sites

Hi

Falling sand does something similar, you could look at that for inspiration (i.e. Ernio's 3rd option below).

See BlockSand and EntityFallingSand.

-TGG

##### Share on other sites

This topic is now closed to further replies.

• ### Posts

• version used : minecraft forge 1.20.1 Logs : https://bytebin.lucko.me/rtG4EA0vfb hi! so when i try to create a new minecraft world in single player, it just crashes?? does anyone has an idea what could be causing this ?
• These forums are for Minecraft Forge, not Fabric. You would probably be better served posting this question wherever fabric support is given, most likely their discord server.
• Add the new latest.log (logs-folder) with sites like https://mclo.gs/ and paste the link to it here
• Update: I tried to reproduce the bug and found out that if I place a flare on a block and then dismantle it with the pickarang (Quark), the flare gets no NBT Tag after getting assigned an empty one through the offhand.

• ### Who's Online (See full list)

×

• #### Activity

×
• Create New...