[SOLVED] Place Skull with Custom Texture

Discussion in 'Spigot Plugin Development' started by DevCubeHD, Jul 7, 2015.

  1. The answer to that is in the third reply to your old thread. :p


    Here's my slightly modified version of that method which uses the new BlockPosition class and updates the skull instead of the entire chunk.
    Code (Java):
    public static void setSkullUrl(String skinUrl, Block block) {
        Skull skullData = (Skull)block.getState();
        TileEntitySkull skullTile = (TileEntitySkull)((CraftWorld)block.getWorld()).getHandle().getTileEntity(new BlockPosition(block.getX(), block.getY(), block.getZ()));
    And in case you don't already have the getNonPlayerProfile method;
    Code (Java):
    public static GameProfile getNonPlayerProfile(String skinURL) {
        GameProfile newSkinProfile = new GameProfile(UUID.randomUUID(), null);
        newSkinProfile.getProperties().put("textures", new Property("textures", Base64Coder.encodeString("{textures:{SKIN:{url:\"" + skinURL + "\"}}}")));
        return newSkinProfile;
    Let me know if you encounter any issues.
    #2 Disoriented, Jul 7, 2015
    Last edited: Jul 7, 2015
    • Like Like x 2
    • Friendly Friendly x 2
  2. Anyway it doesn't work o_O sorry but thanks! Please help .. you have the code :D
  3. You're going to have to be a little more descriptive than that. And when i say a little, I mean a lot.
  4. I just tried this with the method I posted on Spigot 1.8.7 and it works without any issues.
    If you're typing the URL in a command, then it's likely that your client cuts it off because of the character limit. If not, then I'm not sure what could be wrong.

    Something that is worth to keep in mind is that since 1.8.3 (?) and onwards, the texture has to be located on textures.minecraft.net and cannot be uploaded to an external image host such as Imgur.
    #6 Disoriented, Jul 8, 2015
    Last edited: Jul 9, 2015
  5. I don't know why.. but mine don't work :eek:

    Code (Text):
    Location locb = new Location(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
                Block block = locb.getBlock();
                BlockState state = block.getState();
                if(state instanceof Skull) {
                    Skull skull = (Skull)state;
                    if(ItemEnum.normal.get(0).getSkullTexture().startsWith("http")) {
                        setSkullUrl(ItemEnum.normal.get(0).getSkullTexture(), block);
                    } else {
    Code (Text):
            GunManager.add("ยง6Steinschwert", 0, null, "http://textures.minecraft.net/texture/86fd37aaf22730e0dcae98dfca8b8e77771c6a18bb9efbf73387e4e2f1bdc", Material.STONE_SWORD, 0, ItemEnum.NORMAL, 8, new Location(lobbymap.getWorld(), -74, 14, 1311));

    (the link is the texture link)
  6. To start things off, change
    Code (Java):
    Code (Java):
    to forcefully update the block state.

    You can also try adding a debug message before the setSkullUrl method to make sure it is being called. If it is in fact being called, then there is something else that is wrong with your method. To make sure that the setSkullUrl method works, try adding this code to a command;
    Code (Java):
    setSkullUrl("http://textures.minecraft.net/texture/86fd37aaf22730e0dcae98dfca8b8e77771c6a18bb9efbf73387e4e2f1bdc", ((Player) sender).getLocation().getBlock());
    You'll have to change sender to whatever the name of your CommandSender object is.
    • Like Like x 1
  7. Works! Love U body <3333
    • Friendly Friendly x 2
    • Like Like x 1
  8. Awesome, glad I could help. <3
    • Optimistic Optimistic x 1
  9. Necroposting, yes, I know. Hoping someone else won't waste an hour trying to figure this out, since this post still shows up as the top Google search. (MANY servers are still running old API because of the shitty 1.13+ performance, so this is STILL VALID in 2019.)

    Code (Text):
    Using that code caused a 1.12.2 skull to float above the block where it was placed.

    In the client debug, all other skulls that were changed with the setOwningPlayer showed "facing: up", which is actually not a valid rotation for Skull. (???) Whatever, it works as expected.

    However, I needed a specific texture for an existing placed skull. If I block.setType to SKULL as in the above code, the client debug now shows the actual in-game facing direction of the skull, but the skull then floats above the block. As an added WTF bonus, the skull doesn't float above the center where it was placed, it hangs to one side. Bizarre.

    tl;dr, if you're trying to update an already PLACED skull for 1.12.2 API, don't setType on the block. You don't need to, since it's already a SKULL. Doing so makes it float.
  10. Still valid because of the bad performance since 1.13? 1.15 has really huge performance improvements because Mojang finally started working on this problem.
  11. Yeah, especially for mini-games that don't make use of any new blocks, mobs or entities from 1.8+ or 1.12.2+. Just the client loading time for 1.8 compared to 1.13+ is light years faster.
  12. I think this is not the right place to start the version discussion. But I think you did not read my post. 1.15 made big performance improvements, so you are false when you talk about the bad performance since 1.13. You should rather talk about the bad performance since 1.13 until 1.14.