Help with item variations

Discussion in 'Plugin Development' started by StormEagleed, Aug 17, 2012.

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

    StormEagleed

    I am writing a plugin that disallows the placement of a variation of Logs. I can disallow the placement of all log variations, but not a specific kind (i.e Jungle Logs). This is what I have so far:

    Code:
        @EventHandler(priority = EventPriority.LOWEST)
        public void onBlockPlace(BlockPlaceEvent event){
            Player player = event.getPlayer();
            Block block = event.getBlock();
           
            if (block.getTypeId() == 17){
                player.sendMessage(ChatColor.DARK_RED + "That block is unplaceable.");
                event.setCancelled(true);
            }
    I understand that in-game, if you want a specific log variation, you would just use a colon and a number (i.e log:3) but it gives me errors if I do that in place of the "17" in the code.

    Thanks in advanced!
     
  2. Offline

    Timr

    Code:
    @EventHandler(priority = EventPriority.LOWEST)
    public void onBlockPlace(BlockPlaceEvent event){
        Player player = event.getPlayer();
        Block block = event.getBlock();
         
        if (block.getTypeId() == 17 && block.getData() == ((byte) 3)){
            player.sendMessage(ChatColor.DARK_RED + "That block is unplaceable.");
            event.setCancelled(true);
        }
    }
     
    StormEagleed likes this.
  3. Offline

    StormEagleed


    Oh awesome, glad to know it was that simple! Thanks for your help!
     
Thread Status:
Not open for further replies.

Share This Page