[EPIC] Runtime Texture Pack Change

Discussion in 'Plugin Development' started by Icyene, Aug 22, 2012.

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


    Is this possible? As of 1.3.1 servers can force clients to use a specific texture pack. Mods like Optifine allow you to switch texture packs on the client during runtime. So can this be done? This is a two-part question.

    1. Have 2 texture packs: a.zip | b.zip. Server is forcing a.zip, and plugin forces b.zip to the clients, and the clients start rendering with b.zip as the texture pack.

    2. Only send specific texture changes: I in particular want to make rain red. I have the .png file, I was wondering if there was a way to runtime-force players to use it.


    <Trying to bump here while still providing useful information>
    I have found a way to change the texture of a PLAYER. Haven't tested yet, but should work:

    EntityPlayer en = ((CraftPlayer)player).getHandle();
    en.a("http://a.test/a_skin.png", 16);
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 28, 2016
    gamerzap likes this.
  2. Offline


    That's changes their skin...? If that works, then that is very useful to know.
  3. Offline


    wat. WAT. Really?!

    I need to test this out right now! :3
  4. Offline


    I know! I was like :O when I saw that!
  5. Offline


    Firefly CorrieKay Don't get your hopes up! It might not work! I haven't gotten time to test it out yet!
  6. Offline


    Wait a sec, after thinking for a bit, it doesnt really make sense. One of my friends works with minecraft modifications, and this is similar to how he did it. If so, then this wont change anything to any clients. Im gonna test it of course, but, i really dont expect it to work.
  7. Offline


    Ya, now that I think about it, it doesn't seem that probable. Oh well :p
  8. Offline


    considering the client handles skin rendering, yeah?
  9. Offline


    Yup. Although it'd be cool if there was a packet you could send (like the Equipment packet) that you send to the other players that contains data about some player's skin.
  10. Offline


    Woah woah, hold the phone.

    I did this, and this popped up.

    So you cant force it on them, but you CAN ask them.
    Icyene likes this.
  11. Yeah I've tried that before and it doesn't work, I have no idea as to why textures of all entities are in the minecraft server when they are handled client side.

    I would've thought there would've been a packet for this, ill try and have a dig around later and let you know if I find anything
  12. Offline


    Cool... :D

    Also, lol @ "automagically" :p
  13. Offline


    CorrieKay AMAZING! THANK YOU FOR TRYING IT! Despite not forcing it on them, its amazing that it actually does work! Thanks!

    This is also a major step onto runtime forcing texture packs... It proves that it IS possible! Of course Spout still beats this, as it actually DOES force them. I guess you could fully force them by detecting if they said no, and if so, just displaying the message over and over again until they say yes. Even this itself is pretty good for a number of plugins:

    If it works on offline players, make all admins (or select group of players) look like kings. (In the case that they do not own premium accounts)

    Punishing players by making them look like walking dung.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 28, 2016
    CorrieKay likes this.
  14. Offline


    So did you use a File path to a ZIP file or a png like the code example above?
  15. Offline


    i used a link to imgur with a valid skin
  16. Offline


    CorrieKay and did the skin actually change once you clicked "Yes", or did it just display it and not change a thing?

    If only I can find the darned NMS class that handles texture packs! Then I could make a plugin that makes everything change at night, and revert during that day (just as a proof of concept). This would also be interesting for some apocalypse plugins: when apocalypse starts, change to another texture that looks more apocalyptic. Also, for plugins that add new weather (the reason I was looking for this :D). If the server is already asking users to use a custom texture, you could generate a new texture zip folder replacing, say enviroment/rain.png to green rain for acid rain. As long as server is already imposing texture, the players would be missing out if they said no.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 28, 2016
  17. Offline


    ...yknow, i actually didnt test that.

    I kinda just figured it would work..

    Sorry :\ (got a lot on my plate today.. We're finishing up the new map for my server, and im crunching on plugin features for it too)
  18. Offline


    OK, thanks anyways!

    md_5 Do you perhaps know which class takes care of server.properties?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 28, 2016
  19. Offline


    Texture pack changes can be invoked really easily. Just register the MC|TPack plugin channel and then send a message on that channel to the client with the url as the payload.
    No CraftBukkit required.
    Icyene likes this.
  20. Are there any other tricks like these that work without mods?
  21. Offline


    And would this be able to be sent to only given players? I don't want texture pack changes to player Y, I only want to send it to player X. Also is it possible only to send part - texture pack changes, like only a change for rain.png? Additionally, is there any docs I could study to find out more about this in depth?
  22. Offline


    I found this as an example for the new plugin channel api. Looks like you have to send it to every client manually.
    I don't think it is possible. On one hand this feature is very new and it could be added in the future, on the other hand it wouldn't make much sense to overwrite a single image because the player could already have a texture pack on where the new image doesn't really fit...
  23. Offline


    Thanks! Didn't quite get how to use them in this situation from the link, but at least now I know what to look for!
  24. Offline


    These channel thing is completely new to me too :p
    Looks very easy to use but I think that it could get very powerful in the future.
  25. So could someone explain what exactly those Channels are? And what i can do with them?
    Do you need a client-mod? I dont get it xD

    Thanks :D
  26. Offline


    I have gotten as far as to be able to say this: to make a message thing like you see in F3, where there is text rendered on-screen:

    public void onEnable() {
        // Register plugin channel
        getServer().getMessenger().registerOutgoingPluginChannel(this, "ForumDemo");
    //And this code somewhere else, where player is a Player
    String message = "Plugin channels are cool but confusing! I also do not see how to use them for texture packs!"
    if (player.getListeningPluginChannels().contains("ForumDemo")) {
        player.sendPluginMessage(plugin, "ForumDemo", message.getBytes(java.nio.charset.Charset.forName("UTF-8")));
    } else {
        // Do something else
    And at the top left hand side of game Player player will see "Plugin channels are cool but confusing! I also do not see how to use them for texture packs!". No client mod needed, from what I understand.

    CorrieKay Firefly @Anyone_Who_Might_Care

    Got it! You can also use Packet250CustomPayload instead of StandardMessenger.

    Some additional info: after the first time they say yes, they are never asked again. NEVER. Not even if you delete the file from the cache. Or upload a different file. So its really quite neat, and adds a great feel to the server. Its also per-player basis, so that means multiworld support.

    You CAN modify only textures that you want. I want to change rain to look acidic. I made a custom rain file, and added it in a folder called environment, which I then added to a zip file.

    The code:

    ((CraftPlayer)player).getHandle().netServerHandler.sendPacket(new Packet250CustomPayload("MC|TPack", ("https://dl.dropbox.com/u/67341745/Bukkit/Acid_Rain.zip"+"\0"+16).getBytes()));
    After the first time, it wont ask for permission anymore, as stated above. So you can change textures around as much as you please after that first time.

    It gets better: you don't have to include terrain and all that in the zip file: MC overlays your rain.

    This method reverts all client textures to default, albeit with the nice toxic green rain.

    Credits to V10lator who figured out that it overlays

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 28, 2016
  27. Offline


  28. Offline


    So useful!
  29. Offline


    can you force a texturepack beyond just forcing it to repeatedly ask you to install it?
  30. Offline


    Well, I think he said it only asks you the first time. After that, it wouldn't (on a per player basis)
Thread Status:
Not open for further replies.

Share This Page