Jump to content

Move Blocks


btripoloni

Recommended Posts

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

Link to comment
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.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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