TuxCraft Posted March 14, 2013 Share Posted March 14, 2013 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 Quote Link to comment Share on other sites More sharing options...
Kore Posted March 14, 2013 Share Posted March 14, 2013 unrelated but why do you create new enum tool mats with the same as the regular enums? Quote The Korecraft Mod Link to comment Share on other sites More sharing options...
TuxCraft Posted March 14, 2013 Author Share Posted March 14, 2013 Originally I was going to change the weapon damage through that but I found a better way and I haven't taken out the repetitive mats yet. Quote Link to comment Share on other sites More sharing options...
TuxCraft Posted March 14, 2013 Author Share Posted March 14, 2013 I also tried making a throwable item and that too is a white box when it's thrown. Quote Link to comment Share on other sites More sharing options...
SanAndreaP Posted March 14, 2013 Share Posted March 14, 2013 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. Quote 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 More sharing options...
TuxCraft Posted March 15, 2013 Author Share Posted March 15, 2013 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) Quote Link to comment Share on other sites More sharing options...
TuxCraft Posted March 18, 2013 Author Share Posted March 18, 2013 Please help, I bet it's a simple error and I'm a noob at java so I can't find it. Quote Link to comment Share on other sites More sharing options...
TuxCraft Posted March 21, 2013 Author Share Posted March 21, 2013 Should I make my own render class? Quote Link to comment Share on other sites More sharing options...
diesieben07 Posted March 21, 2013 Share Posted March 21, 2013 If you have a custom Entity you generally need a renderer for it or you'll get a white box. Quote Link to comment Share on other sites More sharing options...
ashtonr12 Posted March 22, 2013 Share Posted March 22, 2013 and how do you make a renderer? Quote Use examples, i have aspergers. Examples make sense to me. Link to comment Share on other sites More sharing options...
diesieben07 Posted March 22, 2013 Share Posted March 22, 2013 Either become a notch (he writes them in code) or use Techne. Quote Link to comment Share on other sites More sharing options...
TuxCraft Posted March 23, 2013 Author Share Posted March 23, 2013 I tried copying and pasting the arrow render code and other throwable objects render code for the renderer but it didn't work. Quote Link to comment Share on other sites More sharing options...
ashtonr12 Posted March 24, 2013 Share Posted March 24, 2013 how would i go about useing an existing renderer? like the one for the snowball? Quote Use examples, i have aspergers. Examples make sense to me. Link to comment Share on other sites More sharing options...
coolboy4531 Posted March 24, 2013 Share Posted March 24, 2013 Shouldn't you put public void addRenderer(Map map) { map.put(EntitySpear.class, new RenderSpear()); } Since you made your own RenderSpear, you should use RenderSpear, instead of RenderArrow, I suppose. Quote Link to comment Share on other sites More sharing options...
Senitiel Posted March 25, 2013 Share Posted March 25, 2013 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. Quote http://imageshack.us/a/img707/2757/senitielsspacemarinemod.png[/img] Link to comment Share on other sites More sharing options...
Recommended Posts
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.