Solved Setting block type with byte?

Discussion in 'Plugin Development' started by kampai, Jul 6, 2016.

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

    kampai

    I'm currently using block.setType to set a block near a player, however I'm placing a half slap thats toward the top of a block (if that makes sense) but I cant set byte using settype
     
  2. Offline

    kampai

    @bwfcwalshy
    How would I use that I'm kind of confused, setDurability can change the position of a half slab?
     
  3. @kampai Oh I get what you want now, I thought you wanted to edit the data value of it. I'm not actually sure how you would make the slab on the top or bottom, I will look into it.
     
  4. Offline

    kampai

    @bwfcwalshy
    Hopefully you can find something, i tried and I didnt find anything
     
  5. @kampai Do you have a Block or an ItemStack?
     
  6. Offline

    ArsenArsen

    That is the data.
    Slab has data values which correspond to type and orientation.
    I cannot find anything else but setData(theByte)
     
  7. I got it.

    Code:
    //I am using BlockPlaceEvent
    
    Block b = e.getBlock();
    b.setData((byte) 8);
    This will make it at the top, data 0 is bottom. This is deprecated, not sure what it was replaced with.

    @ArsenArsen Yeah I printed the data and found them
     
  8. Offline

    ArsenArsen

    I do not think it has a replacement. I thought its using material data, but I could not find it.
     
  9. Offline

    kampai

    @bwfcwalshy
    I needed as a blocked since thats the only thing block.setType accepts
    @ArsenArsen
    I've tried
    Code:
    .setData(new MaterialData(Material.STEP, (byte) 8));
    But it doesnt set hte block
    (fullcode)
    Code:
                    final Block block5 = location.getBlock().getRelative(BlockFace.WEST);
                    block5.setType(Material.getMaterial(44));
                    block5.getState().setData(new MaterialData(Material.STEP, (byte) 7));
     
  10. Offline

    ArsenArsen

    Ohh theres a replacement! Ok you missed block5.getState().update()
     
  11. Offline

    kampai

    Alright I got it to work! Thanks guys!
     
  12. @kampai No problem, please mark this thread as solved.

    Thread Tools > Edit Thread > Prefix > Solved
     
Thread Status:
Not open for further replies.

Share This Page