Solved Getid changed

Discussion in 'Plugin Development' started by JJSfluffyduck, Dec 1, 2013.

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

    JJSfluffyduck

    I coming back to mine craft plugins, but on return, I found some of my older plugins that getid, getTargetBlock and setTypeId have been deprecated. I was after how you change these to the new forms. This is the code i am using.
    Code:
    public void OnPlayerInteract(PlayerInteractEvent event) {
            Player player= event.getPlayer();
            int blockId = player.getItemInHand().getType().getId();
            if(blockId == 280){
                Block block =player.getTargetBlock(null, 100);
                Location location = block.getLocation();
                location.setY(location.getY() +1);
                Block blockabove = location.getBlock();
                if(plugin.off==true){
                }else if(plugin.red==true){
                    blockabove.setTypeId(40);
                    player.sendMessage(ChatColor.GREEN+"Block set to Red Mushroom");
                }else if(plugin.brown==true){
                    blockabove.setTypeId(39);
                    player.sendMessage(ChatColor.GREEN+"Block set to Brown Mushroom");
                }
            }
        }
     
  2. Offline

    fireblast709

    JJSfluffyduck if possible use the Material you get from getType() instead of the getId(). Likewise, use block.setType(Material) instead of block.setTypeId(int)
     
    JJSfluffyduck likes this.
  3. Offline

    JJSfluffyduck

    Ok, thanks man for the help

    and what about getTargetBlock

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  4. Offline

    sgavster

    JJSfluffyduck Depricated still works. Just do
    @SupressWarnings("deprication")
     
  5. Offline

    fireblast709

    JJSfluffyduck I suppose you could use a BlockIterator (although I am not sure if they are as exact)
     
Thread Status:
Not open for further replies.

Share This Page