Pistons and the client ...

Discussion in 'Plugin Development' started by Bone008, Jun 30, 2011.

Thread Status:
Not open for further replies.
  1. So ever since pistons should be implemented, I was curious about how the server would tell the client to display the "smooth" block animation. I was hoping that it would be a new packet, but it apparently isn't (according to this page).

    So has anyone already figured out what packets are sent when a piston is (de)activated?
     
  2. Offline

    MadMonkeyCo

    My guess is that it uses some integer for the animation frame in the Piston class, therefore being client-side. That's how the arm swing animation is programmed.
     
  3. Well, but what does the server do to tell the client: "we have a funky piston there and it was just extended"?
    Or is it only treated as a regular block, and as soon as it has set its powered state to true, the client knows it has to extend it?
    What's with the blocks that are pushed? Is all the calculation for the new block positions client side?
    I don't really know how to track the sent packets by myself, so as long as it isn't written anywhere, I have to ask ;)
     
  4. Offline

    MadMonkeyCo

    If you're talking about the block that's being pushed it's probably an Entity being used, somewhat coded like EntityFallingSand but with a different onUpdate method, assuming they haven't replaced that class with EntityMovingBlock or something. I think you should just use MCP and look at the client code or see if you can find it on the Bukkit GitHub page.
     
  5. Offline

    feildmaster

    apparently, bukkit and everyone else believes a piston body receives power, byte 0x8, and then shoots off automatically on client side (which is wrong. it doesn't.)

    I have no idea why you want to know the packets though.
     
  6. @feildmaster
    Well, I want to make some blocks perform the smooth animation as if they were pushed by a piston.
    It would look best without actually needing to send a piston to the client and just telling it to move a block from a to b.

    Thus I need to know how the client is told to extend the piston and to move the blocks that need to be moved.
     
  7. Offline

    feildmaster

    oh i see... That would be an interesting thing to play with.
     
  8. Offline

    Afforess

    Smoothly moving blocks are special blocks, and coded as such on clients. Only a client mod can alter that.
     
  9. Did you even read the thread? Of course it wasn't possible so far. But with the new pistons, a smooth movement can be applied for any block(when it's pushed/pulled by a piston). The only problem is to figure out how to make the client know it.

    I'll try to take a look at the source, but I'm not really familar with it apart from the NetworkManager.
     
  10. Offline

    WinSock

    No what he is saying is that the piston effects are client sided only. There are no new packets to play with in the new update. I'm guessing @Afforess will add something in BukkitContrib that will allow smooth movement though :D
     
  11. No one is getting what I'm trying to say ...
    As we all agree, there actually are blocks moving smoothly when they are pushed by pistons. And there need to be sent anything to trigger this stuff for the client! It's hard to believe that only the block where the piston extends to is set to the piston-head-material and the client does all the rest with animating the pushed blocks etc. without getting any instructions from the server.

    Oh well, I'll just look at the source and hope that I will find something there.

    PS: Apart from what I am planning to do, what I originally asked for was an explanation of what happens when a piston is extended.
     
  12. Offline

    Afforess

    Incorrect, and I am bothered by your insults.

    The client detects the piston and applies the smooth movement all client side. There is no need for packets, because the client already knows what blocks are where, and it's just a rendering of movement. The only packet sent is likely the redstone change packet (which is actually a block change packet, since the 2 redstone states are 2 separate block ids), which causes the client to update the piston. Without more client side modding, moving bocks gracefully from the server is not possible.
     
  13. Offline

    nisovin

    The client doesn't even really need to watch for the block update. All it has to do is watch for a redstone update (switch, pressure plate, button, etc), then it can calculate the redstone path itself and see that the piston is now receiving power.

    I think everyone is getting what you're trying to say, you just don't want to accept their answers.
     
  14. Offline

    Afforess

    I am not familiar enough with MC source to say whether redstone is server only, or both server and client, but correct, the general point remains, there is no "magic" packet to do what the OP wants.
     
  15. YES, I know there is no new packet for moving blocks, but the only thing I want to have clarified is what actually makes the client display the smooth movement (let it only be the piston pushing out).


    So I just tested a bit with block-changes. If you have a PISTON_BASE-block and you send the "pushed out" bit to the client, the only thing that happens is that the piston base now looks like the piston was pushed out.
    Nothing happens to the surronding block and there is no PISTON_EXTENSION-block spawning out of nowhere (didn't surprise me).

    So I went ahead and sent a block change to the PISTON_EXTENSION for the block where the piston pushes out as soon as I update the PISTON_BASE. Result: A correct rendered, pushed out piston. But without animation, which again was pretty apparent to happen.

    Moving on, there is a PISTON_MOVING_PIECE block/material, that is not listed in the minecraftwiki (block id 36). That sounds like a working solution for me. So I'll keep trying out stuff with it.

    BTW, for the idea I have there is not an actual need for moving blocks out of nowhere, there can be a fake pistons to accomplish the movement, but I still need to get the correct order and content of packets for "the movement".
    So far it only looks like BlockChange-packets.


    PS: when an actual real piston is pushed out and you sent the client faked blocks in front of it, the movement will happen with the faked blocks and as soon as they reach their target they are set to the real blocks (thus updated). Not really important, but it definatly is more than just a change of the redstone-state of the piston ...

    What I was trying to say with the statement is only the following: The server needs to tell the client that there is a piston being extended and that there are new blocks in the positions where the piston pushes stuff.
    And if I'm not getting completely insane, this does happen.

    Sorry if I offended anyone with my statements. I might write something without knowing it would sound rude in english. I only wanted to explain what I was trying to figure out, I never intended to insult anyone.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
Thread Status:
Not open for further replies.

Share This Page