Jump to content

Recommended Posts

Posted

I'm trying to make my mod show my optifine cape to people who don't have optifine. However I have this problem:

 

Dsr5hfJ.png

 

Heres my code:

 

CapeHandler:

public class CapeHandler {

private static ResourceLocation location = new ResourceLocation("DimCore:cape/Cape");

public static void registerCapeTexture() {
	URL url = null;

	try {
		url = new URL("https://optifine.net/capes/_RadiusOfRift_.png");
	} catch (MalformedURLException e) {
		e.printStackTrace();
	}

	Minecraft.getMinecraft().renderEngine.loadTexture(location, new ThreadDownloadImageData(null, url.toString(), null, new CapeBuffer()));
}

@SubscribeEvent
public void handlerCape(RenderPlayerEvent.Specials.Pre event) {
	if (event.entityPlayer.getUniqueID().equals(new UUID(you don't need to know my UUID))) {
		registerCapeTexture();
		((AbstractClientPlayer)event.entityPlayer).func_152121_a(MinecraftProfileTexture.Type.CAPE, location);
	}
}

}

 

CapeBuffer:

@SideOnly(Side.CLIENT)
public class CapeBuffer implements IImageBuffer {
    
@Override
    public BufferedImage parseUserSkin(BufferedImage texture) {
        if (texture == null)
            return null;
        int imageWidth = texture.getWidth(null) <= 64 ? 64 : texture.getWidth(null);
        int imageHeight = texture.getHeight(null) <= 32 ? 32 : texture.getHeight(null);

        BufferedImage capeImage = new BufferedImage(imageWidth, imageHeight, 2);

        Graphics graphics = capeImage.getGraphics();
        graphics.drawImage(texture, 0, 0, null);
        graphics.dispose();

        return capeImage;
    }

    @Override
    public void func_152634_a() {}
}

 

Why is my cape white?

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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