Moving block animation?

Discussion in 'Plugin Development' started by Chicken325, Aug 5, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Chicken325

    Pistons make animations of moving blocks all the time. Is it possible to animate a block moving 1 meter without a piston next to it using Bukkit?
     
  2. Offline

    AmberK

    I'm pretty sure that pistons just teleport the block, not actually animate the movement of it.

    Edit: Might be wrong on that, I can look though
     
  3. Offline

    Njol

    Pistons change all moved blocks to block 36s (each block #36 also has a tile entity associatied with it which stores the moved block's type) which do the move animation, and changes them back to the saved blocks when the animation is done.

    To spoof a piston you would thus have to do this all yourself (which likely includes doing animation and sending packets)
     
    AmberK likes this.
  4. Offline

    Chicken325

    Alright, thanks. Probably not going to do something like that any time soon xD
     
  5. I've did some in-depth testing with that when Beta 1.7 hit and pistons came out (and no documentation was out there about how they work in the protocol).
    The sad result was that "magical" moving blocks can't be done. Only to the extent of making a piston appear for a short time, trigger the extend animation and then remove it again. That can still be used programmatically to create some nice effects, though.

    What happens when a piston extends is a simple packet being sent to the client containing nothing but "block at X,Y,Z extended". Everything else is done client-side (creating the 36-id block, rendering the piston and block animation and so on). After the thing is complete, the server sends block change packets to verify the new block positions.

    Howver, the client will only trigger the animation if mentioned "block at X,Y,Z" is actually a piston. That makes it impossible for us to simply move a block.
    The prettiest possible approach:
    - send fake piston block to client
    - wait 1 tick
    - send piston extend/retract packet to client
    - wait 2 ticks
    - send another block update reverting the piston-block to its original state to the client
    - send changed block types of the pushed blocks to the client (otherwise it will revert the changes after some seconds)

    It works quite nicely for something where you don't actually see the pistons (coming out of a wall/the floor), but then you could just use "real" pistons and make them extend.

    TL;DR: The animation doesn't work in a way to simply allow a block to move from A to B without any visible piston. :(
     
Thread Status:
Not open for further replies.

Share This Page