Making Block Invisible?

Discussion in 'Plugin Development' started by TerroDoor, Dec 11, 2019.

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

    TerroDoor

    I’ve been googling for a couple hours on how to do this but basically I’m checking a bunch of BlockFace’s around the player and adding vines to the faces, I’m stuck with making them
    Invisible to the player

    Here’s what I got

    Code:
    
    Block b = p.getLocation().getBlock();
    
    If (b.getTypeId == 0 && BlockFace.NORTH.getTypeId != 0 ){
    
    
    P.setBlockChange(b.getLocation(), Mat.VINE, (byte), 0);
    
    
    This places them in front of me but sets them visible and flat, any help is appreciated thankyou!!


    Sent from my iPhone using Tapatalk
     
  2. Offline

    timtower Moderator Moderator

    @TerroDoor What is the end goal of this plugin?
     
  3. Offline

    TerroDoor

    It’s a KitPvP plugin every post I’ve made on here is for this project


    Sent from my iPhone using Tapatalk
     
  4. Offline

    timtower Moderator Moderator

    Why do you need the block,
     
  5. Offline

    TerroDoor

    So they can climb up the wall they’re facing but I’m having trouble with the vines dissapearing


    Sent from my iPhone using Tapatalk
     
  6. Offline

    KarimAKL

    1. You have a comma after casting to byte, remove that.
    2. "Mat" needs to be "Material".
    3. The second argument is the new block, which you want to be AIR. I'd recommend reading the javadocs on methods you aren't familiar with.
    4. I'd also recommend reading the Java naming conventions.
     
  7. Offline

    TerroDoor

    Thanks but I wrote this off my phone(I have it properly coded on my laptop)

    Sent from my iPhone using Tapatalk
     
    Last edited by a moderator: Dec 11, 2019
  8. Offline

    KarimAKL

  9. Offline

    TerroDoor

    Are you still online? I’m with my pc now

    Sent from my iPhone using Tapatalk
     
    Last edited by a moderator: Dec 12, 2019
  10. Offline

    timtower Moderator Moderator

    Being online is not needed as it is a forum. Just post the used code.
     
    TerroDoor likes this.
  11. Offline

    TerroDoor

    Code:
    
     Player p = (Player)e.getPlayer();
     Block b = p.getLocation().getBlock();
    
     if (selectkit.spiderab.contains(p)) {
    
     if (b.getType() == Material.AIR && (!(b.getRelative(BlockFace.NORTH).getType() == Material.AIR) || 
     !(b.getRelative(BlockFace.EAST).getType() == Material.AIR) || 
     !(b.getRelative(BlockFace.SOUTH).getType() == Material.AIR) || 
     !(b.getRelative(BlockFace.WEST).getType() == Material.AIR))) {
     
     p.setFlying(true);
     
     Block b2 = b.getRelative(BlockFace.UP);
    
     if (b2.getType() == Material.AIR && (!(b2.getRelative(BlockFace.NORTH).getType() == Material.AIR) || 
     !(b2.getRelative(BlockFace.EAST).getType() == Material.AIR) || 
     !(b2.getRelative(BlockFace.SOUTH).getType() == Material.AIR) || 
     !(b2.getRelative(BlockFace.WEST).getType() == Material.AIR))) {
    
     p.setFlying(true);
     b.getState().setType(Material.AIR);
     
     }
    
    
     
  12. Offline

    timtower Moderator Moderator

    @TerroDoor I don't see any sendBlockChanges in this.
     
  13. Offline

    TerroDoor

    I replaced with setFlying it was lagging my server so bad


    Sent from my iPhone using Tapatalk
     
  14. Offline

    timtower Moderator Moderator

    Try running it on a timer instead.
    PlayerMoveEvent gets called way to often for this.
     
  15. Offline

    TerroDoor

    So if I want to use vines to climb but have them invisible to the player I’d have to use a 1 second delay right? Because they need to be able to update the blocks to climb up


    Sent from my iPhone using Tapatalk
     
  16. Offline

    timtower Moderator Moderator

    I am not even sure if the player will start climbing if the client does not know that the vines are there.
     
  17. Offline

    TerroDoor

    Is there a way to set the vines against the block as I’m doing so above but have them set to the Id of 36? Just like world edit’s invisible blocks


    Sent from my iPhone using Tapatalk
     
  18. Offline

    timtower Moderator Moderator

    Use Materials, not ID's.
    The block with id 36 is a solid block, can't climb that.
    Set the block to vines first when you get close, and back when the player moves away again.
     
  19. Offline

    TerroDoor

    That’s a good idea, how would I make it so it only grows vines on the block the player is looking at? Maybe grow the whole Y axis of the wall with vines for x amount of seconds unseeable to other players?

    Sent from my iPhone using Tapatalk
     
  20. Offline

    timtower Moderator Moderator

    I believe that you can get the block the player is looking at, don't have the code for you though.
    Growing the entire wall is overkill, I would go 5 blocks up and 5 blocks down max.
     
Thread Status:
Not open for further replies.

Share This Page