[1.13] How to put Torch or Sign on side block ?

Discussion in 'Spigot Plugin Development' started by Hakmay, Sep 16, 2018 at 10:55 AM.

  1. Hello everyone,

    I'm creating a mini-game plugin. In my mini-game i create a block tower ( 1 block width, 5 block height) and i'm trying to place torches or sign on side blocks but is not working.

    I create Block like this :

    Code (Java):

    Block block = player.getLocation().getBlock();
            block.setType(Material.OBSIDIAN);
     
    For this question many threads on this forum are outdated, i tried what is proposed in this thread https://www.spigotmc.org/threads/placing-wall-torches-in-1-13-not-possible-anymore.332329/

    Here's my code :
    Code (Java):

    Block block = player.getLocation().getBlock();
            block.setType(Material.OBSIDIAN);

            BlockState state = block.getState();
            state.setType(Material.WALL_TORCH);
            state.update(true);
     
    But it's not working for me. Wall torch appears but my block became an Air Block

    Someone can explain me how i can do it ?

    Thanks
     
  2. Do not use Block#getState, try using Block#setType directly.
     
  3. Thanks for the answer!

    If i use this my obsidian block will disappear :/

    I want this result : [​IMG]
     
  4. oh well then determine the coordinates (using a vector or something like that), use World#getBlockAt and then work with that. Should be pretty straight forward.

    (You might also want to set the correct facing, but I have no idea if you have to do this by your own or if its automatic already)

    /edit: It is probably smarter to use Location#getBlock()
     
    #4 Alex_qp, Sep 16, 2018 at 1:30 PM
    Last edited: Sep 16, 2018 at 1:37 PM
  5. You’re setting the block to obsidian then turning around and setting it as a torch. It’s working exactly as you’ve written it.

    You have to get a block adjacent to the pillar then set that to a torch, look into using something like Block SideBlock = obbyBlock.getRelative(BlockFace.EAST);

    You’ll need to do the same for the opposite side of you want it on two sides. Or it might look cool if it used north,east,south,west one after another so it kind of winds around the pillar as it goes up.

    You’ll have to add these torch blocks to your temp block list as well for removal. If you need to set the torch facing BlockFace.getOppositeFace() should help


    Sent from my iPhone using Tapatalk
     

Share This Page