Make any block invisible

Discussion in 'Plugin Development' started by jojodmo, Apr 12, 2014.

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

    jojodmo

    I would like to know if there's any way to make a block invisible. I know about block 36, and ladders and everything, but I would like to make an invisible CARPET block. I'm looking for something like this:

    Code:java
    1. Block b;
    2. b.setVisible(false);

    or
    Code:java
    1. Block b;
    2. for(Player p : Bukkit.getOnlinePlayers()){
    3. p.sendBlockUpdate(b, Material.AIR);
    4. }


    I'm fine with using craftbukkit or NMS code. Is there any way to make a block invisible?
     
  2. Offline

    Syd

    Player.sendBlockChange(Location, Material, byte);
     
  3. Offline

    jojodmo


    It isn't working... I'm trying
    Code:java
    1. player.sendBlockChange(location, Material.AIR, (byte) 0);

    does the byte at the end of the method set the data of the block? Is it not working because it's deprecated and there's a new way to do it? I'm sending the block change on PlayerJoinEvent if that would have anything to do with it...
     
  4. Offline

    Syd

    Yes the byte is the data value.
    I'm not sure how this behaves, when a player loads/unloads the given chunks and I would suspect that your problem lays there.
     
  5. Offline

    jojodmo


    Ah... So should I use a timer or something & send the block updates every 50-100 ticks? Or is there another work-around


    Okay so I made the timer and now it works fine, just now when you try to walk over it it gets all glitchy and you kind of bounce in and out of the invisible block really fast... Is there any way to achieve the same effect as the barrier block in 1.8, just with carpet? Because I'm trying to make it so that players can walk over lava using an invisible floor, and the only way it'll work is if I use carpets, because otherwise the player is going to have to be too far over the lava... is there any way to achieve the same effect as the barrier block in 1.8, just with carpet?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  6. Offline

    jojodmo

    Buuuuummmmmppp
     
  7. Offline

    RawCode

    block change works.

    post your code with debug trace to check.
     
  8. Offline

    BillyGalbreath

    Yes, and no.

    The reason "no" is, blocks cannot be invisible without some client modifications. However, yes, you can send a texturepack (resourcepack) to the client which has a certain carpet texture as invisible.

    Trying to use BlockChange will result in the client thinking no block is there, so it tries to fall/move through it. The Server knows there is a block there, so it updates the player position so they are not inside or moving through the block. This results in a nasty glitch, as mentioned before. The glitch normally wouldnt be there, however network latency prevails here, causing the glitch.

    The best way is you send the clients a new resourcepack with the invisible carpet texture.
     
Thread Status:
Not open for further replies.

Share This Page