Set Skull Types?

Discussion in 'Plugin Development' started by Marskon, Feb 21, 2013.

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

    Marskon

    I am a very nooby coder and am very new to plugin coding itself so forgive me if this sounds like the easiest thing to do ever. so basically i need to find out how to change the skull type of a skull. I have tried many different ways including skull.SetSkullType(SkullType.CREEPER); but keep getting an error under SetSkullType i was wondering if anybody could give me the code to change the skull type.
     
  2. Offline

    c0mp

    Moved to Plugin Development
     
  3. You can use SkullType enum or you can use its value directly, value for creeper is 4, player 3, zombie 2, wither 1 and skeleton 0.

    The method is diferent depending on what you're using it on...

    For Block objects:
    Code:
    block.setData((byte)4); // or SkullType.CREEPER.ordinal() instead of 4
    Or for ItemStack objects:
    Code:
    item.setDurability((short)4); // or SkullType.CREEPER.ordinal() instead of 4
     
  4. Offline

    Marskon

    Thank you so much been bugging me for a while and now i can finally get to releasing the plugin :p

    one more thing is there a way i can get a different mob like a blaze or an endermans head?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
    justcool393 likes this.
  5. No, only predefined ones in the game.

    But you could put a player head with an owner that has a enderman skin.

    You set the owner using ItemMeta class.... getItemMeta(), store it, check if it's instanceof SkullMeta, cast it, change owner, set it back to the item meta and set item's item meta back to the meta you've edited.
     
  6. Offline

    GyllieGyllie

    I'm using this but it only changes the direction my skulls are looking to. Can you please help me?

    Code:
    Location location = new Location(getServer().getWorld("world"), x, y, z);
                        location.getBlock().setTypeIdAndData(Material.SKULL.getId(), (byte) 2, true);
                        Block block = location.getBlock();
                        block.setData((byte) SkullType.CREEPER.ordinal());
     
  7. Offline

    mattrick

    I believe Mojang actually added mob accounts so you don't have to worry about people changing their skin.

    Show Spoiler
    Mobs:
    • MHF_Blaze
    • MHF_CaveSpider
    • MHF_Chicken
    • MHF_Cow
    • MHF_Enderman
    • MHF_Ghast
    • MHF_Golem
    • MHF_Herobrine
    • MHF_LavaSlime
    • MHF_MushroomCow
    • MHF_Ocelot
    • MHF_Pig
    • MHF_PigZombie
    • MHF_Sheep
    • MHF_Slime
    • MHF_Spider
    • MHF_Squid
    • MHF_Villager
    Blocks:
    • MHF_Cactus
    • MHF_Cake
    • MHF_Chest
    • MHF_Melon
    • MHF_OakLog
    • MHF_Pumpkin
    • MHF_TNT
    • MHF_TNT2
    Bonus:
    • MHF_ArrowUp
    • MHF_ArrowDown
    • MHF_ArrowLeft
    • MHF_ArrowRight
    • MHF_Exclamation
    • MHF_Question
     
    TigerHix and The_Doctor_123 like this.
  8. To change the look of skull you have to set owner. I know how to do it as a itemstack not a block tho.
     
  9. Offline

    The_Doctor_123

    mattrick16
    Awesome! Never knew those existed!
     
  10. Offline

    mattrick

    Me neither! I actually looked it up like 5 hours before this post. What a coincidence?
     
  11. Offline

    bradonminecraft

    um im doing custom recipes and I need it to craft a wither skull here is the code can anyone tell me how to make it a wither skull?


    package me.recipe.recipe;
    import java.util.Arrays;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.ShapedRecipe;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.plugin.java.JavaPlugin;
    public class Main extends JavaPlugin {
    public void onEnable() {
    hrecipe();
    }

    private void hrecipe() {
    ItemStack witherskull = new ItemStack(Material.SKULL_ITEM , 1);
    ItemMeta meta = witherskull.getItemMeta();
    meta.setDisplayName(ChatColor.RED + "wither skull");
    meta.setLore(Arrays.asList("Magic"));
    witherskull.setItemMeta(meta);


    ShapedRecipe hrecipe = new ShapedRecipe(witherskull);
    hrecipe.shape(
    "@@@",
    "@$@",
    "@@@");
    hrecipe.setIngredient('@', Material.SOUL_SAND);
    hrecipe.setIngredient('$', Material.BONE);
    Bukkit.getServer().addRecipe(hrecipe);
    }


    }

    can someone help me with this?
     
  12. Offline

    xigsag

    Hey, hey! 俺のでばんだ。

    Take a look at this. You might find this useful.
     
Thread Status:
Not open for further replies.

Share This Page