Spawn players head

Discussion in 'Plugin Development' started by Sergiderakes, Jul 5, 2019.

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

    Sergiderakes

    Hi, I'm having an issue while trying to spawn a player's head when they die, it only places a regular face instead of it's own face and I don't know how to edit that, can someone help me? Thanks
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    Sergiderakes

    @timtower
    I tried with this:
    location.getBlock().setType(Material.PLAYER_HEAD)
    I know that's not enough information to place the head of the player but I don't know how to do it. I know how to create an item of the head I want but not to place it
     
  4. Offline

    timtower Administrator Administrator Moderator

    Moved to plugin development.
    @Sergiderakes This is a problem within minecraft. Client needs to fetch the head data first, so spawn the head, then set it again a tick later.
     
  5. Offline

    Sergiderakes

    @timtower
    What do you mean with set it again later?
     
  6. Offline

    timtower Administrator Administrator Moderator

    You call the line that you posted another time.
     
  7. Offline

    Sergiderakes

    @timtower
    Code:
    @EventHandler
        public void onPlayerDeath(PlayerDeathEvent event) {
            Player p = event.getEntity();
            Location loc = p.getLocation();
            loc.getBlock().setType(Material.LEGACY_NETHER_FENCE);
    
            loc.add(0, 1, 0);
            loc.getBlock().setType(Material.PLAYER_HEAD);
            try {
                Thread.sleep(125);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            loc.getBlock().setType(Material.PLAYER_HEAD);
           
        }
    Do you mean doing this?
     
  8. Offline

    timtower Administrator Administrator Moderator

    @Sergiderakes Never do a sleep in Bukkit.
    Use a BukkitRunnable that you start a single tick later.
     
  9. Offline

    Sergiderakes

  10. Offline

    Sergiderakes

    @timtower
    Code:
    loc.add(0, 1, 0);
            loc.getBlock().setType(Material.PLAYER_HEAD);
            new BukkitRunnable() {
    
                @Override
                public void run() {
                    loc.getBlock().setType(Material.PLAYER_HEAD);
                   
                }
               
            }.runTaskLater(plugin, 1);
    That's what i'm trying and it still doesn't work
     
  11. Offline

    timtower Administrator Administrator Moderator

  12. Offline

    Sergiderakes

  13. Offline

    timtower Administrator Administrator Moderator

  14. Offline

    Sergiderakes

    @timtower
    Thanks you a lot for all, now it's working perfectly : )
     
Thread Status:
Not open for further replies.

Share This Page