Testing for block data

Discussion in 'Plugin Development' started by blue1, Feb 1, 2016.

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


    I am making a Checkers plugin wherein if a player in an ArrayList right-clicks a skeleton skull, it will send them a message. If they right click a zombie skull and are in a different ArrayList, it sends them a different message. How can I test which type of skull they clicked on? I am currently able to test whether they clicked on a skull or different block.
  2. Offline


    I believe each skull block has a different data value?
    So you can use this:
    if(block.getData() == (byte) <whatever> && arraylist.contains(player)) {
            //Rest of code stuff
  3. Offline


    I can't seem to get that to work, try as I might. Here's my code.
        public void onBlock(PlayerInteractEvent ev){
            Player p = ev.getPlayer();
            Action a = ev.getAction();
            if(a == Action.RIGHT_CLICK_BLOCK){
                Block b = ev.getClickedBlock();
                if(b.getType() == Material.SKULL){
                    if(b.getData() == (byte)3){
    When I click on any skull, it will say "testtt", and this works fine. But I can't even get it to say "Test" by only clicking the Steve skull.

    I left out the ArrayList part just because it's not essential for solving this problem. I can test for that easily enough, too. I just can't seem to get the Skull data. :confused:
  4. Offline


    Are you sure you have the right skull data? Prehaps try printing out the data value in the chat when the block is clicked just so you can check if it's correct:

    p.sendMessage(block.getData() + "")
  5. Offline


    This spoonfeeding be like >.>
  6. Offline


    Thanks for the idea!
    I did

                p.sendMessage(b.getData() + "");

    And it returned


    When the skull is placed on the side of a block instead of on the ground, the data was 3. I can't seem to do much with the metadata, but I'm not sure if that has to do with the type of skull anyways.

    The Data is based on where it is placed. face of block and data are shown below.
    Top = 1
    North = 2
    South = 3
    West = 4
    East = 5
    There is nothing about the direction it's facing though.
    Last edited: Feb 2, 2016
Thread Status:
Not open for further replies.

Share This Page