Jump to content

Recommended Posts

Posted

For my mod Guardsman i'm trying to allow players too add custom NPC texture to a folder outside of  my mod.zip. The problem is the texture is loaded in & given an ID but doesn't show on the NPC. If i load from inside the mod it works just fine and everything renders. From outside i get the white 'texture missing' texture. Anyone know why and how to solve this?

 

Here is the code though i don't think its the issue

public String getTexture()	 
     {
	 String textureName = Minecraft.getMinecraftDir() + "/Config/Guardsman/NpcTextures/" + getTeam() + getProfessionsName() + ".png";
     File textureFile = new File(textureName);
    	if(textureFile.exists())
    	{
    		 return textureName;
    	}
    	else
    	{
                      //Ignore, this is for another part that will download the texture from an SMP server if missing.
    		/**
    		if(worldObj.isRemote)
    		{
    			String url = getServerFile() + "/config/Guardsman/textures/";
                                String fileName = getTeam() + getProfessionsName() + ".png";
                                String saveLoc = Minecraft.getMinecraftDir()+"/config/Guardsman/textures/";
    			FileManager.download(url, fileName, saveLoc);
    		}
    		**/
    		return "/mob/char.png";
    	}
    	

	}

Posted

I looked at the GuiTexturePacks.java and found some interesting things that may or may not help.

 

For file location:

this.fileLocation = (new File(Minecraft.getMinecraftDir(), "texturepacks")).getAbsolutePath();

 

I don't know if that may be a use to you.  I am testing the code right now that you posted.

width=320 height=64http://www.slothygaming.com/img/ota.png[/img]

If your grammar is shit and you blatantly don't know what you're doing, I will not help you.

Posted

was the same as renderBiped which i have tested the this on. If loaded from inside my mod it renders just fine,but loaded from outside it doesn't load right.But here is my render class anyways:

 

public class RenderGuard extends RenderLiving
{
    protected ModelBiped modelBipedMain;
    protected float field_40296_d;

    public RenderGuard(ModelBiped par1ModelBiped, float par2)
    {
        this(par1ModelBiped, par2, 1.0F);
        this.modelBipedMain = par1ModelBiped;
    }

    public RenderGuard(ModelBiped par1ModelBiped, float par2, float par3)
    {
        super(par1ModelBiped, par2);
        this.modelBipedMain = par1ModelBiped;
        this.field_40296_d = par3;
    }

    protected void renderEquippedItems(EntityLiving par1EntityLiving, float par2)
    {
        super.renderEquippedItems(par1EntityLiving, par2);
        ItemStack var3 = par1EntityLiving.getHeldItem();

        if (var3 != null)
        {
            GL11.glPushMatrix();
            this.modelBipedMain.bipedRightArm.postRender(0.0625F);
            GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F);
            float var4;

            IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(var3, EQUIPPED);
            boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, var3, BLOCK_3D));
            
            if (var3.itemID < 256 && (is3D || RenderBlocks.renderItemIn3d(Block.blocksList[var3.itemID].getRenderType())))
            {
                var4 = 0.5F;
                GL11.glTranslatef(0.0F, 0.1875F, -0.3125F);
                var4 *= 0.75F;
                GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F);
                GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
                GL11.glScalef(var4, -var4, var4);
            }
            else if (var3.itemID == Item.bow.shiftedIndex)
            {
                var4 = 0.625F;
                GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
                GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F);
                GL11.glScalef(var4, -var4, var4);
                GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
                GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
            }
            else if (Item.itemsList[var3.itemID].isFull3D())
            {
                var4 = 0.625F;
                GL11.glTranslatef(0.0F, 0.1875F, 0.0F);
                GL11.glScalef(var4, -var4, var4);
                GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
                GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
            }
            else
            {
                var4 = 0.375F;
                GL11.glTranslatef(0.25F, 0.1875F, -0.1875F);
                GL11.glScalef(var4, var4, var4);
                GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F);
                GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
                GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F);
            }

            this.renderManager.itemRenderer.renderItem(par1EntityLiving, var3, 0);

            if (var3.getItem().requiresMultipleRenderPasses())
            {
                for (int x = 1; x < var3.getItem().getRenderPasses(var3.getItemDamage()); x++)
                {
                    this.renderManager.itemRenderer.renderItem(par1EntityLiving, var3, x);
                }
            }

            GL11.glPopMatrix();
        }
    }
    protected void renderName(EntityGuardBase par1EntityGuard, double par2, double par4, double par6)
    {
        if (Minecraft.isGuiEnabled() && par1EntityGuard != this.renderManager.livingPlayer)
        {
            float var8 = 1.6F;
            float var9 = 0.016666668F * var8;
            float var10 = par1EntityGuard.getDistanceToEntity(this.renderManager.livingPlayer);
            float var11 = par1EntityGuard.isSneaking() ? 4.0F : 32.0F;

            if (var10 < var11)
            {
                String var12 = par1EntityGuard.getRenderedName();

                if (!par1EntityGuard.isSneaking())
                {
                    if (par1EntityGuard.isPlayerSleeping())
                    {
                        this.renderLivingLabel(par1EntityGuard, var12, par2, par4 - 1.5D, par6, 64);
                    }
                    else
                    {
                        this.renderLivingLabel(par1EntityGuard, var12, par2, par4, par6, 64);
                    }
                }
                else
                {
                    FontRenderer var13 = this.getFontRendererFromRenderManager();
                    GL11.glPushMatrix();
                    GL11.glTranslatef((float)par2 + 0.0F, (float)par4 + 2.3F, (float)par6);
                    GL11.glNormal3f(0.0F, 1.0F, 0.0F);
                    GL11.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
                    GL11.glRotatef(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
                    GL11.glScalef(-var9, -var9, var9);
                    GL11.glDisable(GL11.GL_LIGHTING);
                    GL11.glTranslatef(0.0F, 0.25F / var9, 0.0F);
                    GL11.glDepthMask(false);
                    GL11.glEnable(GL11.GL_BLEND);
                    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                    Tessellator var14 = Tessellator.instance;
                    GL11.glDisable(GL11.GL_TEXTURE_2D);
                    var14.startDrawingQuads();
                    int var15 = var13.getStringWidth(var12) / 2;
                    var14.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
                    var14.addVertex((double)(-var15 - 1), -1.0D, 0.0D);
                    var14.addVertex((double)(-var15 - 1), 8.0D, 0.0D);
                    var14.addVertex((double)(var15 + 1), 8.0D, 0.0D);
                    var14.addVertex((double)(var15 + 1), -1.0D, 0.0D);
                    var14.draw();
                    GL11.glEnable(GL11.GL_TEXTURE_2D);
                    GL11.glDepthMask(true);
                    var13.drawString(var12, -var13.getStringWidth(var12) / 2, 0, 553648127);
                    GL11.glEnable(GL11.GL_LIGHTING);
                    GL11.glDisable(GL11.GL_BLEND);
                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                    GL11.glPopMatrix();
                }
            }
        }
    }
    public void renderGuard(EntityGuardBase par1Entity, double par2, double par4, double par6, float par8, float par9)
    {
    	double var13 = par4 - (double)par1Entity.yOffset;
        super.doRenderLiving(par1Entity, par2, var13, par6, par8, par9);
    }
    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    {
        this.renderGuard((EntityGuardBase)par1Entity, par2, par4, par6, par8, par9);
    }
    protected void passSpecialRender(EntityLiving par1EntityLiving, double par2, double par4, double par6)
    {
        this.renderName((EntityGuardBase)par1EntityLiving, par2, par4, par6);
    }

}

If you need to look at the rest of the code here is my github repo https://github.com/DarkGuardsman/GSM-Guardsman

Posted

I found this.  It could help if used correctly but I think a more efficient way exist.

http://www.roseindia.net/java/example/java/io/ZipFolderExample.shtml

Ty that will take some time for me to get it working how i want it, but if it works i can move on to the next step of my mod. Which is actual downloading the textures if they are not found :)

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.