Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

  • Author

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

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.

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.

  • Author

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

 

thank you

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

Guest
This topic is now closed to further replies.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.