Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Spear is a white box? Help!


TuxCraft
 Share

Recommended Posts

I'm making a mod with spears in it and when I try to render the spear as just an arrow it decides it wants to be a white box (kinda fun for pixel-arting villager houses though). How would I get it to render even just as a normal arrow.

 

My main mod file

public class mainMod_XXX {

 

static EnumToolMaterial toolIRON = EnumHelper.addToolMaterial("IRON", 2, 250, 6.0F, 2, 14);

static EnumToolMaterial toolGOLD = EnumHelper.addToolMaterial("GOLD", 0, 32, 12.0F, 0, 22);

static EnumToolMaterial toolDIAMOND = EnumHelper.addToolMaterial("DIAMOND", 3, 1561, 8.0F, 3, 10);

static EnumToolMaterial toolSTONE = EnumHelper.addToolMaterial("STONE", 1, 131, 4.0F, 1, 5);

static EnumToolMaterial toolWOOD = EnumHelper.addToolMaterial("WOOD", 0, 59, 2.0F, 0, 15);

 

//Spears

public static final Item ironSpear = new ItemSpear(9104, toolIRON, 1).setIconCoord(2, 0).setItemName("ironSpear");

public static final Item goldSpear = new ItemSpear(9106, toolGOLD, 2).setIconCoord(4, 0).setItemName("goldSpear");

public static final Item diamondSpear = new ItemSpear(9105, toolDIAMOND, 3).setIconCoord(3, 0).setItemName("diamondSpear");

public static final Item stoneSpear = new ItemSpear(9103, toolSTONE, 4).setIconCoord(1, 0).setItemName("stoneSpear");

public static final Item woodSpear = new ItemSpear(9102, toolWOOD, 5).setIconCoord(0, 0).setItemName("woodSpear");

 

// The instance of your mod that Forge uses.

        @Instance("weapons")

        public static mainMod_XXX instance;

       

        @PreInit

        public void preInit(FMLPreInitializationEvent event) {

                // Stub Method

        }

       

        public void init(FMLInitializationEvent preEvent) {

       

        }

       

        @Init

        public void load(FMLInitializationEvent event)

        {

        LanguageRegistry.addName(ironSpear, "Iron Spear");

        LanguageRegistry.addName(diamondSpear, "Diamond Spear");

        LanguageRegistry.addName(goldSpear, "Gold Spear");

        LanguageRegistry.addName(woodSpear, "Wood Spear");

        LanguageRegistry.addName(stoneSpear, "Stone Spear");

        }

       

        @PostInit

        public void postInit(FMLPostInitializationEvent event) {

                // Stub Method

        }

       

        public void load()

        {

                MinecraftForgeClient.preloadTexture("/Mod_XXX/textures.png");

        }

       

        public void AddRenderer(Map map)

        {

                map.put(EntitySpear.class, new RenderArrow());

        }

}

 

Item Spear is pretty much sword code mixed with bow code.

 

EntitySpear is an exact duplicate of EntityArrow except with a bunch of renames to make it work.

 

RenderSpear

 

@SideOnly(Side.CLIENT)

public class RenderSpear extends Render

{

    public void renderSpear(EntitySpear par1EntitySpear, double par2, double par4, double par6, float par8, float par9)

    {

        this.loadTexture("/Mod_XXX/spear.png");

        GL11.glPushMatrix();

        GL11.glTranslatef((float)par2, (float)par4, (float)par6);

        GL11.glRotatef(par1EntitySpear.prevRotationYaw + (par1EntitySpear.rotationYaw - par1EntitySpear.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F);

        GL11.glRotatef(par1EntitySpear.prevRotationPitch + (par1EntitySpear.rotationPitch - par1EntitySpear.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F);

        Tessellator var10 = Tessellator.instance;

        byte var11 = 0;

        float var12 = 0.0F;

        float var13 = 0.5F;

        float var14 = (float)(0 + var11 * 10) / 32.0F;

        float var15 = (float)(5 + var11 * 10) / 32.0F;

        float var16 = 0.0F;

        float var17 = 0.15625F;

        float var18 = (float)(5 + var11 * 10) / 32.0F;

        float var19 = (float)(10 + var11 * 10) / 32.0F;

        float var20 = 0.05625F;

        GL11.glEnable(GL12.GL_RESCALE_NORMAL);

        float var21 = (float)par1EntitySpear.spearShake - par9;

 

        if (var21 > 0.0F)

        {

            float var22 = -MathHelper.sin(var21 * 3.0F) * var21;

            GL11.glRotatef(var22, 0.0F, 0.0F, 1.0F);

        }

 

        GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);

        GL11.glScalef(var20, var20, var20);

        GL11.glTranslatef(-4.0F, 0.0F, 0.0F);

        GL11.glNormal3f(var20, 0.0F, 0.0F);

        var10.startDrawingQuads();

        var10.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)var16, (double)var18);

        var10.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)var17, (double)var18);

        var10.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)var17, (double)var19);

        var10.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)var16, (double)var19);

        var10.draw();

        GL11.glNormal3f(-var20, 0.0F, 0.0F);

        var10.startDrawingQuads();

        var10.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)var16, (double)var18);

        var10.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)var17, (double)var18);

        var10.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)var17, (double)var19);

        var10.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)var16, (double)var19);

        var10.draw();

 

        for (int var23 = 0; var23 < 4; ++var23)

        {

            GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);

            GL11.glNormal3f(0.0F, 0.0F, var20);

            var10.startDrawingQuads();

            var10.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)var12, (double)var14);

            var10.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)var13, (double)var14);

            var10.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)var13, (double)var15);

            var10.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)var12, (double)var15);

            var10.draw();

        }

 

        GL11.glDisable(GL12.GL_RESCALE_NORMAL);

        GL11.glPopMatrix();

    }

 

    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)

    {

        this.renderSpear((EntitySpear)par1Entity, par2, par4, par6, par8, par9);

    }

}

 

Also if you could point me towards the bit in the render spear code where I could elongate the arrow/spear that would be great  ;D

Link to comment
Share on other sites

Where's your proxy? Also AddRenderer doesn't get called. You have to register your stuff through RenderingRegistry. And for that you'll need to use a proxy, since you cannot use the RenderingRegistry on a server.

Look here on how to use the Proxy system: http://www.minecraftforge.net/wiki/Basic_Modding

Then look at the RenderingRegistry class or look in the wiki on how to register your renderer.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Ok, I created a common and client proxy and put this in the client proxy

[embed=425,349]@Override

    public void load()

    {       

        RenderingRegistry.registerEntityRenderingHandler(EntityFireB.class, new RenderFireball(0.5F));

    }[/embed]

But it doesn't work, it doesn't give me any errors but my throwable item is still a white cube (I'll be using my Fireball as an example for now because the code is much skinnier)

Link to comment
Share on other sites

In my mod I do the following

 

ClientProxy

void registerRenders()
{
                EntityRegistry.registerGlobalEntityID(EntityLaserBolt.class, "LaserBolt", ModLoader.getUniqueEntityId());
                RenderingRegistry.registerEntityRenderingHandler(EntityLaserBolt.class, new RenderLaserBolt());
}

 

In my mod class

@Init
public void load(FMLInitializationEvent event) throws Exception {
EntityRegistry.registerModEntity(EntityLaserBolt.class, "LaserBolt", 2, instance, 160, 1, false);
//2 is an index - get unique for every other entity
//160 I cant really rembember what it does
//1 is refresh rate - for some other entities You may give bigger values, if you want them to render every x ticks
}

 

Also note That in Your Spear entity you will need a constructor, which takes only World as parameter (even if You don't use it in Your code) - otherwise entity will be invisible.

Link to comment
Share on other sites

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

 Share

×
×
  • Create New...

Important Information

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