Solved Making blocks invisible to certain players?

Discussion in 'Plugin Development' started by theCodeBro, Aug 19, 2013.

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

    theCodeBro

    Today I just have a short question. Can you make certain blocks invisible to certain players? If anyone knows if this is possible, or is sure that it is impossible, please tell :) .
     
  2. I am sure it is possible, but it would require some work though.

    You would need something like a hashmap that contains the name of the player that can't view the blocks and a list of all the blocks that player can't see. Than you would have to send block changes to that player only, that is possible with sendBlockChange().
     
  3. Offline

    theCodeBro

    Thnx! Worked Great!
     
  4. Offline

    dunbaratu

    That sounds like not only would it make the block invisible for the player but also completely nonexistent for the player because their client software doesn't know the block is there. Not only does it hide it from the sense of sight, but also from normal interactions. They can't mine the block, etc. Their client will constantly be "arguing" with the server about whether or not the player can walk forward through a wall made of these blocks, for example. The client will let them walk through the nonexistent blocks, and then the server won't. After they get certain distance in, the server will notice the position is out of sync and zap the player back to where it says they should be, causing that annoying rubber-banding wobble effect. When they shoot an arrow the client will believe it can go through the block but the server will not, etc. Be sure to test all these sorts of cases and make sure the behavior is acceptable.
     
  5. You got a point there.
     
  6. Offline

    dunbaratu

    One of the newer features that came out in 1.5.2 was the ability for a server admin to set up an official default texture pack for the server - so that people's clients logging in will automatically download the texture pack and use it. I wonder if there's a bukkit API for trapping that client/server communication and altering what it does, thus making a block have a transparent texture for a player despite it still existing in their client. Of course, to make this work the hidden blocks all have to be a certain known material/dmg value. (i.e. all yellow wool will be invisible to this player).
     
  7. At the time that came out there was a huge discussion about this on this forum, I believe something like this was achieved, but I am not sure.
     
  8. Offline

    CubieX

    I tested this lately for a plugin I made for fun.
    Sending a player a BlockChange to show a solid block as "AIR", will vanish the block.
    But as soon as the player (or another player nearby) triggers a BlockChange event by clicking the vanished block for example, the game will send BlockChange packets to all nearby players, and the block will become visible to those clients again.
    If a player runs into an invisible Block, the block will stay invisible, but the server will check if the player can go there and will send the client the message, "nope, there is a solid block. You can't do that!" and the player will run into this invisible wall.

    I also tested the other way: You send a BlockChange to a player to show an AIR block as a solid block.
    As soon as the player reaches this block, the Client will prevent the player from entering it. He will run into this block as if it was real.
    The player can break this block like it was real (no clue why this does not trigger a block change...),
    but no drop will ocurr if it's broken.
    If he right clicks the block, the server will send a BlockChange packet to all nearby players, and the block will vanish and be passable again.

    So the funny thing is: You can create solid walls with "sendBlockChange()" which are only present client-side,
    but will behave like a solid block until a "real" BlockChange ocurrs.
    And you can make blocks invisible and still solid and unpassable, until a real block change occurs.

    So as far as my testing went, you can only restrict a players movement by using block changes to deceive the client.
    But you cannot overrule the servers physics checks by sending false information to the client.
    If there is a real block, there is a real block. Even if you can't see it. ;)
     
Thread Status:
Not open for further replies.

Share This Page