Player Skull Positioning

Discussion in 'Plugin Development' started by Zaaryus, Jul 11, 2014.

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

    Zaaryus

    Here's my code:
    Code:java
    1. public static void PlaceHead(Location l){
    2. Block b = l.getBlock();
    3. b.setType(Material.SKULL);
    4. if(b.getType() == Material.SKULL){
    5. Skull s = (Skull) b.getState();
    6. s.setSkullType(SkullType.PLAYER);
    7. s.setOwner("Zaaryus");
    8. s.setRawData(Byte.valueOf((byte) 1));
    9. s.update();
    10. }
    11. }

    The code works, but without setRawData the skull is acting like it's placed on a wall.
    It's now deprecated and I have no clue of how to replace it.
    Code:java
    1. s.setRawData(Byte.valueOf((byte) 1));

    Any ideas?

    Maybe there's also a better way to write this?
     
  2. Offline

    simolus3

    Code:java
    1. s.setFacingDirection(BlockFace.NORTH); //etc

    For more directions, check this.
     
  3. Offline

    Zaaryus

    setFacingDirection is not defined in the 1.7.9 release I have, is that something new?
    I also searched it up and found it's made for signs, is this really supposed to work for skulls?
     
  4. Offline

    simolus3

  5. Offline

    Zaaryus

    I can see that, but according to eclipse "setFacingDirection" is undefined for type "Skull".
    Have you tested this code before? Could you provide an example, maybe?
     
  6. Offline

    simolus3

    Zaaryus Oh, I think it was changed after 1.6, because the method is setRotation() now...
    If you still need an example
    Code:java
    1. Block b = p.getLocation().getBlock();
    2. if (b.getType() == Material.SKULL) {
    3. Skull s = (Skull)b.getState();
    4. s.setRotation(BlockFace.NORTH);
    5. s.setSkullType(SkullType.PLAYER);
    6. s.setOwner("simolus3");
    7. }
     
  7. Offline

    Zaaryus

    I know setRotation, but when I tried I'm pretty sure it didn't work (I'll try again)
    Thanks anyways :)

    Edit: Does not work. I tried it before and it doesn't work.. setRawData works, though.. :/
     
  8. Offline

    simolus3

    Zaaryus There is only on more thing that i can think of: after making changes, you should update the skull with s.update(); I had the same problem with writing to signs and after updating them, it worked. But I wonder whi setRawData works without updating the skull...
     
  9. Offline

    Zaaryus

    As you can see, I'm updating the skull. :confused:
    I have tried with updating the facing direction, but no success.
    I'll use this deprecated method for now, even though I don't like it. (I'll find a solution later on)
    Thanks for trying, though. ;)
     
  10. Offline

    JBoss925

    Don't know if this would work but, try setting down a skull in-game and using some code to select the skull and then System.out.print() the skull object. Then do the same but select the skull your plugin creates and compare what it prints out. Then you can usually find a method to change it.
     
  11. Offline

    Zaaryus

    JBoss925 Thanks, I'll look into that later! :D
     
  12. Offline

    _Filip

  13. Offline

    JBoss925

    When you print out the object it gives you a whole synopsis of what it is and some of it's attributes. I use it for finding errors when I think some patterns or math sequences may be retrieving the wrong values.

    EDIT: I only recommend doing this after searching through the actual jar files and finding nothing. As far as in this case, I searched through the jar and found nothing that wasn't already discussed as not working. That's why I'm saying printing out the attributes of different skulls in different rotations and positions could help reveal a change in attributes that could ultimately be altered in the code to receive the desired output.
     
    simolus3 likes this.
Thread Status:
Not open for further replies.

Share This Page