Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I have a link that gives out custom skins based on player name, e.g. "http://myserver/skins/name.png". The mod is client side, I need it to download the skin for a player from this link, store it somewhere (cache it?) and use it for rendering players. Here is what I have:

 

public class mySkins{

    Minecraft mc;
    public static String skinsURL = "http://myserver/skins/%s.png";
    public HashMap<String,ResourceLocation> skins = new HashMap<>();

    ...

@SubscribeEvent
public void onMyEvent(RenderPlayerEvent.Pre event){
    AbstractClientPlayer acp = (AbstractClientPlayer)event.getEntityPlayer();
    if (skins.containsKey(acp.getName())){
    } else {
        System.out.println("downloadskin started " + acp.getName() + " " + acp.getLocationSkin());

        ThreadDownloadImageData tdid = new ThreadDownloadImageData(
                (File)null,
                String.format(skinsURL,acp.getName()),
                acp.getLocationSkin(),
                new ImageBufferDownload());

        mc.getTextureManager().loadTexture(acp.getLocationSkin(),tdid);
        skins.put(acp.getName(),acp.getLocationSkin());
        System.out.println("downloadskin ended");
    }
}

 

This does download proper skin but applies it to "minecraft:textures/entity/alex.png", obviously. So basically this only shows that link and download is working fine.

 

I need to

1.  cache downloaded skin and get its ResourceLocation

2.  apply this ResourceLocation while rendering player

 

Now if I go like this

@SubscribeEvent
public void onMyEvent(RenderPlayerEvent.Pre event){
    AbstractClientPlayer acp = (AbstractClientPlayer)event.getEntityPlayer();
    if (skins.containsKey(acp.getName())){
        //i want to somehow appply skins.get(acp.getName())
    } else {
        System.out.println("downloadskin started " + acp.getName() + " " + acp.getLocationSkin());
        ResourceLocation res = new ResourceLocation("myskins/" + acp.getName().toLowerCase() + ".png");
        ThreadDownloadImageData tdid = new ThreadDownloadImageData((File)null,String.format(skinsURL,acp.getName()),res,new ImageBufferDownload());
        mc.getTextureManager().loadTexture(res,tdid);
        skins.put(acp.getName(),res);
        System.out.println("downloadskin ended");
    }
}

 

it gives NullPointer at loadTexture

 

[18:28:01] [Client thread/WARN]: Failed to load texture: minecraft:myskins/nickname.png
java.io.FileNotFoundException: minecraft:myskins/nickname.png

 

How do I go about this? I've tried changing first File argument in new ThreadDownloadImageData to non-null, also tried different ResrourceLocation's for res and still cant get it to work. To clarify, I dont need skins to be stored on hard drive, but only cached in memory while minecraft is running, so basically every time client joins the game, it will redownload skins for every player he meets

  • Author
2 hours ago, diesieben07 said:

Don't make custom skins.

Can I have more details on this? Should I not do this because it is against the rules or because it is not possible? 

Edited by Maxk

Out of my depth here. But if not possible to change skin directly (never looked into it)....

 

CarryOn and metamorph (both on github) use models to change how the client renders the player.  So, you could create a custom player model based on image or if not that many, server could return index to prefabs in your mod and simply (morph) player to use that model.

 

 

Edited by aw_wolfe

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.