Solved Adding the CanPlaceOn to an item?!

Discussion in 'Plugin Development' started by mcrazmouze, Aug 27, 2016.

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

    mcrazmouze

    I have this:
    Code:
    ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
    
    SkullMeta meta = (SkullMeta) skull.getItemMeta();
    meta.setOwner("MHF_TNT2");
    meta.setDisplayName(ChatColor.GOLD + "TNT Piece 1/8");
    skull.setItemMeta(meta);
    
    So i wanna do so this item can't be placed..? HELP!

    Please keep in mind i'm new to Java
     
  2. Offline

    Zombie_Striker

    @mcrazmouze
    1. BlockPlaceEvent
    2. If the block that was placed is equal to this item.
    3. cancel the event.
     
  3. Offline

    mcrazmouze

    Can't i just add the NBT-Tag somehow?
     
  4. Offline

    Zombie_Striker

    @mcrazmouze
    You can, but you will then also need to check for that tag in the BlockPlaceEvent.
     
  5. Offline

    AlvinB

    I do believe he means this NBT tag, which regulates which blocks you can place the block on. However, you would need to be in adventure mode for it to have effect.
    [​IMG]
     
Thread Status:
Not open for further replies.

Share This Page