Runtime TPack Change - Quick & Dirty

Discussion in 'Resources' started by Icyene, Aug 31, 2012.

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

    Icyene

    With 1.3.x, MineCraft servers allow the option of "forcing" a texture pack on all clients. This of course, leads to interesting possibilities for plugins. In this thread are 2 methods for doing a runtime texture pack change on a player's client. No client mod required!

    Method 1 - Packet Sending:
    Code:
    public void setTexture(Player toSetOn, String pathToTexture) {
        ((CraftPlayer) toSetOn).getHandle().netServerHandler
            .sendPacket(new Packet250CustomPayload("MC|TPack",
                (pathToTexture + "\0" + 16).getBytes()));
        }
    
    Method 2 - EntityPlayer.a:
    Code:
    public void setTexture(Player toSetOn, String pathToTexture) {
        ((CraftPlayer) toSetOn).getHandle().a(pathToTexture,  16);
        }
    
    This can also be achieved by sending a call to the 'MC|TPack' plugin channel containing the URL of the texture pack.

    And it gets better: you don't even have to include a full TPack. If you want to say, just change rain, just include enviroment/rain.png! Minecraft will use the default textures by default. Oh, and automagically.

    Hope that helped!
     
    Derthmonuter, gomeow and WarmakerT like this.
  2. Offline

    rominos2

    Icyene
    Some questions.

    How to reset a TP ?
    More questions to come after I test it

    EDIT1 : In the second method remove the last parenthesis
    EDIT2 : Does this work for TP's URLs ?

    Thanks
     
  3. Offline

    Icyene

    rominos2

    You cannot reset texture packs. That is a backdraw of this method.

    Thanks, I must've missed that.
    It only works for URLs.
     
  4. Offline

    gomeow

    Can't you just send them the default texture pack?
     
  5. Offline

    Icyene

    gomeow

    I believe that he was asking about resetting the tpack to what it was before the change. And you don't even need to send a default tpack, just send an empty string as a URL.
     
    Derthmonuter likes this.
  6. Offline

    Derthmonuter

    Icyene
    This is brilliant! I was also taking a look at your meteor tutorial today--loved that one too.
     
    Icyene likes this.
Thread Status:
Not open for further replies.

Share This Page