Jump to content

[1.6.2] [Solved] How does Minecraft handle capes now


Pow3rCut

Recommended Posts

The reason for my question is that you used to be able in a TickHandler to specify capes by changing the cloakUrl in EntityPlayer and then using "Minecraft.getMinecraft().renderEngine.obtainImageData(player.cloakUrl, new ImageBufferDownload());" to download the image.

 

cloakUrl seems to have moved, or minecraft has changed the way it handles them. If anyone can point me in the right direction I would be very grateful.

 

-Pow3rCut

If I helped you click the Thank You button

Link to comment
Share on other sites

Looks like it has been moved to AbstractClientPlayer and is field_110313_e and that is a ResourceLocation. But it is not public and hence inaccessible.

May be another way to change this, but I am not good at reading (even mildly) obfuscated code.

- Pow3rCut

If I helped you click the Thank You button

Link to comment
Share on other sites

Very true (to both the reflection and the overwriting), but either requires additional downloads by the player or for the mod to be installed as a coremod vs the old method where any mod could easily add capes. Perhaps a pull request in Forge, to make the field public?

 

I imagine reflection is the way to go, unless their is a simplier way that I am overlooking

If I helped you click the Thank You button

Link to comment
Share on other sites

Sorry to be a pain, but where is the Cape render code located (unless it is       

ModelBiped.bipedCloak = new ModelRenderer(this, 0, 0);
        ModelBiped.bipedCloak.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, par1);

 

Ignore me I am an idiot, it is obviously located in RenderPlayer.renderSpecials (P.S. check out the DeadMau5 stuff)

-Pow3rCut

If I helped you click the Thank You button

Link to comment
Share on other sites

Okay so I got around half way then hit a lot of trouble with event.renderer.anything being private, any advice?

	public static void init(net.minecraftforge.client.event.RenderPlayerEvent.Specials.Post event) 
{
	if(!playerHasCape(event.entityPlayer).isEmpty())
	{

		EntityPlayer abstractClientPlayer = event.entityPlayer;
		ThreadDownloadImageData imageDownload = downloadImage(new ResourceLocation("skins/" + StringUtils.stripControlCodes(playerHasCape(event.entityPlayer))), "http://www.minecraftcapes.com/userskins/Diamond_Cape_by_John.png", new ImageBufferDownload());
		boolean flag = imageDownload.func_110557_a();
        boolean flag1 = !abstractClientPlayer.isInvisible();
        boolean flag2 = !abstractClientPlayer.getHideCape();
        float f6;
        
        if (flag && flag1 && flag2)
        {
            event.renderer.func_110776_a(new ResourceLocation("cloaks/" + StringUtils.stripControlCodes(playerHasCape(event.entityPlayer))));
            GL11.glPushMatrix();
            GL11.glTranslatef(0.0F, 0.0F, 0.125F);
            double d0 = abstractClientPlayer.field_71091_bM + (abstractClientPlayer.field_71094_bP - abstractClientPlayer.field_71091_bM) * (double)par2 - (abstractClientPlayer.prevPosX + (abstractClientPlayer.posX - abstractClientPlayer.prevPosX) * (double)event.partialTicks);
            double d1 = abstractClientPlayer.field_71096_bN + (abstractClientPlayer.field_71095_bQ - abstractClientPlayer.field_71096_bN) * (double)par2 - (abstractClientPlayer.prevPosY + (abstractClientPlayer.posY - abstractClientPlayer.prevPosY) * (double)event.partialTicks);
            double d2 = abstractClientPlayer.field_71097_bO + (abstractClientPlayer.field_71085_bR - abstractClientPlayer.field_71097_bO) * (double)par2 - (abstractClientPlayer.prevPosZ + (abstractClientPlayer.posZ - abstractClientPlayer.prevPosZ) * (double)event.partialTicks);
            f6 = abstractClientPlayer.prevRenderYawOffset + (abstractClientPlayer.renderYawOffset - abstractClientPlayer.prevRenderYawOffset) * event.partialTicks;
            double d3 = (double)MathHelper.sin(f6 * (float)Math.PI / 180.0F);
            double d4 = (double)(-MathHelper.cos(f6 * (float)Math.PI / 180.0F));
            float f7 = (float)d1 * 10.0F;

            if (f7 < -6.0F)
            {
                f7 = -6.0F;
            }

            if (f7 > 32.0F)
            {
                f7 = 32.0F;
            }

            float f8 = (float)(d0 * d3 + d2 * d4) * 100.0F;
            float f9 = (float)(d0 * d4 - d2 * d3) * 100.0F;

            if (f8 < 0.0F)
            {
                f8 = 0.0F;
            }

            float f10 = abstractClientPlayer.prevCameraYaw + (abstractClientPlayer.cameraYaw - abstractClientPlayer.prevCameraYaw) * event.partialTicks;
            f7 += MathHelper.sin((abstractClientPlayer.prevDistanceWalkedModified + (abstractClientPlayer.distanceWalkedModified - abstractClientPlayer.prevDistanceWalkedModified) * event.partialTicks) * 6.0F) * 32.0F * f10;

            if (abstractClientPlayer.isSneaking())
            {
                f7 += 25.0F;
            }

            GL11.glRotatef(6.0F + f8 / 2.0F + f7, 1.0F, 0.0F, 0.0F);
            GL11.glRotatef(f9 / 2.0F, 0.0F, 0.0F, 1.0F);
            GL11.glRotatef(-f9 / 2.0F, 0.0F, 1.0F, 0.0F);
            GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
            event.renderer.modelBipedMain.renderCloak(0.0625F);
            GL11.glPopMatrix();
        }
	}
}

private static String playerHasCape(EntityPlayer entityPlayer) {
	if(entityPlayer.username.equalsIgnoreCase("pow3rcut"))
	{
		return "Pow3rCut";
	}
	else if(entityPlayer.username.equalsIgnoreCase("sad"))
	{
		return "";
	}
	else if(entityPlayer.username.equalsIgnoreCase("dsada"))
	{
		return "";
	}

	return "";
}

    private static ThreadDownloadImageData downloadImage(ResourceLocation par0ResourceLocation, String par1Str, IImageBuffer par3IImageBuffer)
    {
        TextureManager texturemanager = Minecraft.getMinecraft().func_110434_K();
        Object object = texturemanager.func_110581_b(par0ResourceLocation);

        return (ThreadDownloadImageData)object;
    }

If I helped you click the Thank You button

Link to comment
Share on other sites

  • 4 weeks later...

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.