Posted October 10, 20159 yr Hello All! Sorry to be back so soon. Thanks to your help I was able to take care of most of the remaining issues and I finally have my mod into a playable state in 1.7. I have one last bug I could use some help with. I have two projectiles which I could render fine in the 1.6 version of my mod. They fire ok, I can shoot them at mobs and they do what I want them to, but they are completely invisible. I don't even get the untextured white cube. I've been looking through this for a while, so maybe a fresh set of eyes can figure out what I'm doing wrong. Thanks in advance! Client Proxy public class ClientProxy extends CommonProxy { public static KeyBinding[] keyBindings= new KeyBinding[4]; @Override public void registerRenderers() { EntityRegistry.registerModEntity(spiritBoltProjectile.class, "Spirit Bolt", 1, BaseClass.instance1, 64, 10, true); RenderingRegistry.registerEntityRenderingHandler(spiritBoltProjectile.class, new renderSpiritBolt(BaseClass.InrPwrSB)); EntityRegistry.registerModEntity(holyLightProjectile.class, "Holy Light", 2, BaseClass.instance1, 64, 10, true); RenderingRegistry.registerEntityRenderingHandler(holyLightProjectile.class, new renderHolyLight(BaseClass.InrPwrHL)); } @Override public EntityPlayer getPlayerEntity(MessageContext ctx) { // Double-check is inevitable! return (ctx.side.isClient() ? Minecraft.getMinecraft().thePlayer : super.getPlayerEntity(ctx)); } public void initKeys() { keyBindings[0]= new KeyBinding("Spell Slot 1", Keyboard.KEY_R, "Inner Power"); keyBindings[1]= new KeyBinding("Spell Slot 2", Keyboard.KEY_T, "Inner Power"); keyBindings[2]= new KeyBinding("Spell Slot 3", Keyboard.KEY_Y, "Inner Power"); keyBindings[3]= new KeyBinding("Spell Slot 4", Keyboard.KEY_U, "Inner Power"); for (int i=0; i<4; i++) ClientRegistry.registerKeyBinding(keyBindings); } } Load Function @EventHandler public void load(FMLInitializationEvent event) { MinecraftForge.EVENT_BUS.register(new manaHandler()); if(FMLCommonHandler.instance().getSide().isClient()) { ClientProxy cProxy= new ClientProxy(); cProxy.initKeys(); } GuiHandler guiHandler = new GuiHandler(); NetworkRegistry.INSTANCE.registerGuiHandler(instance, guiHandler); proxy.registerRenderers(); } SpiritBolt Renderer (copied from RenderSnowball). @SideOnly(Side.CLIENT) public class renderSpiritBolt extends Render { private Item field_94151_a; private int field_94150_f; public renderSpiritBolt(Item par1Item, int par2) { this.field_94151_a = par1Item; this.field_94150_f = par2; } public renderSpiritBolt(Item par1Item) { this(par1Item, 0); } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { IIcon icon = this.field_94151_a.getIconFromDamage(this.field_94150_f); if (icon != null) { GL11.glPushMatrix(); GL11.glTranslatef((float)par2, (float)par4, (float)par6); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glScalef(0.5F, 0.5F, 0.5F); // this.func_110777_b(par1Entity); // worked in Forge 804, but no longer; use this: this.bindEntityTexture(par1Entity); Tessellator tessellator = Tessellator.instance; // You can remove this whole section if you want, it's just for Potions if (icon == ItemPotion.func_94589_d("bottle_splash")) { int i = PotionHelper.func_77915_a(((EntityPotion)par1Entity).getPotionDamage(), false); float f2 = (float)(i >> 16 & 255) / 255.0F; float f3 = (float)(i >> 8 & 255) / 255.0F; float f4 = (float)(i & 255) / 255.0F; GL11.glColor3f(f2, f3, f4); GL11.glPushMatrix(); this.func_77026_a(tessellator, ItemPotion.func_94589_d("overlay")); GL11.glPopMatrix(); GL11.glColor3f(1.0F, 1.0F, 1.0F); } this.func_77026_a(tessellator, icon); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); } } @Override protected ResourceLocation getEntityTexture(Entity entity) { return TextureMap.locationItemsTexture; } private void func_77026_a(Tessellator par1Tessellator, IIcon par2Icon) { float f = par2Icon.getMinU(); float f1 = par2Icon.getMaxU(); float f2 = par2Icon.getMinV(); float f3 = par2Icon.getMaxV(); float f4 = 1.0F; float f5 = 0.5F; float f6 = 0.25F; GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); par1Tessellator.startDrawingQuads(); par1Tessellator.setNormal(0.0F, 1.0F, 0.0F); par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3); par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3); par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2); par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2); par1Tessellator.draw(); } } Holy Light Renderer (Much the same as Spirit Bolt Renderer) @SideOnly(Side.CLIENT) public class renderHolyLight extends Render { private Item field_94151_a; private int field_94150_f; public renderHolyLight(Item par1Item, int par2) { this.field_94151_a = par1Item; this.field_94150_f = par2; } public renderHolyLight(Item par1Item) { this(par1Item, 0); } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { IIcon icon = this.field_94151_a.getIconFromDamage(this.field_94150_f); if (icon != null) { GL11.glPushMatrix(); GL11.glTranslatef((float)par2, (float)par4, (float)par6); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glScalef(0.5F, 0.5F, 0.5F); // this.func_110777_b(par1Entity); // worked in Forge 804, but no longer; use this: this.bindEntityTexture(par1Entity); Tessellator tessellator = Tessellator.instance; // You can remove this whole section if you want, it's just for Potions if (icon == ItemPotion.func_94589_d("bottle_splash")) { int i = PotionHelper.func_77915_a(((EntityPotion)par1Entity).getPotionDamage(), false); float f2 = (float)(i >> 16 & 255) / 255.0F; float f3 = (float)(i >> 8 & 255) / 255.0F; float f4 = (float)(i & 255) / 255.0F; GL11.glColor3f(f2, f3, f4); GL11.glPushMatrix(); this.func_77026_a(tessellator, ItemPotion.func_94589_d("overlay")); GL11.glPopMatrix(); GL11.glColor3f(1.0F, 1.0F, 1.0F); } this.func_77026_a(tessellator, icon); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); } } @Override protected ResourceLocation getEntityTexture(Entity entity) { return TextureMap.locationItemsTexture; } private void func_77026_a(Tessellator par1Tessellator, IIcon par2Icon) { float f = par2Icon.getMinU(); float f1 = par2Icon.getMaxU(); float f2 = par2Icon.getMinV(); float f3 = par2Icon.getMaxV(); float f4 = 1.0F; float f5 = 0.5F; float f6 = 0.25F; GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); par1Tessellator.startDrawingQuads(); par1Tessellator.setNormal(0.0F, 1.0F, 0.0F); par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3); par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3); par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2); par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2); par1Tessellator.draw(); } } Thanks again! Once I fix this I get to start adding new content!
October 10, 20159 yr You are using the proxy incorrectly, for one. You should have an instance of the base Proxy class (e.g. 'CommonProxy') in your main class, and then use that instance when you need to call any methods in your proxy. Note that you never actually need to create the instance, i.e. you don't call 'new Proxy()', as it is created for you by FML / Forge. When you call 'proxy.method()', the correct proxy is used based on the which side is making the call, so you don't need to do any side checks in your load function area when making calls to the proxy. Also, you don't want to register mod entities in the client proxy - they need to be registered in the common area of your mod, so they are available to both sides; only the rendering, key bindings, and other client-only stuff should be isolated in that manner. I'm sure there's more, but that should give you enough to clean up for now. http://i.imgur.com/NdrFdld.png[/img]
October 13, 20159 yr Author I finally had a minute to look at this. I moved the registerModEntity() calls to the load function but the projectiles still will not render. Any other ideas? Thanks again.
October 13, 20159 yr Did you fix the other issues with your proxy setup? Because that is surely affecting it as well. Once you've fixed it, post your latest code. http://i.imgur.com/NdrFdld.png[/img]
October 14, 20159 yr Author I think I did. I added the initKeys() method to my common proxy and got rid of the client side only call. Here is my updated code. By the way, thank you for the explanation of the client/common proxy system. That was always a bit confusing to me but makes a lot more sencee now. Load: @EventHandler public void load(FMLInitializationEvent event) { MinecraftForge.EVENT_BUS.register(new manaHandler()); proxy.initKeys(); EntityRegistry.registerModEntity(holyLightProjectile.class, "Holy Light", 2, BaseClass.instance1, 64, 10, true); EntityRegistry.registerModEntity(spiritBoltProjectile.class, "Spirit Bolt", 1, BaseClass.instance1, 64, 10, true); GuiHandler guiHandler = new GuiHandler(); NetworkRegistry.INSTANCE.registerGuiHandler(instance, guiHandler); proxy.registerRenderers(); } ClientProxy: public class ClientProxy extends CommonProxy { public static KeyBinding[] keyBindings= new KeyBinding[4]; @Override public void registerRenderers() { //EntityRegistry.registerModEntity(spiritBoltProjectile.class, "Spirit Bolt", 1, BaseClass.instance1, 64, 10, true); RenderingRegistry.registerEntityRenderingHandler(spiritBoltProjectile.class, new renderSpiritBolt(BaseClass.InrPwrSB)); //EntityRegistry.registerModEntity(holyLightProjectile.class, "Holy Light", 2, BaseClass.instance1, 64, 10, true); RenderingRegistry.registerEntityRenderingHandler(holyLightProjectile.class, new renderHolyLight(BaseClass.InrPwrHL)); } @Override public EntityPlayer getPlayerEntity(MessageContext ctx) { // Double-check is inevitable! return (ctx.side.isClient() ? Minecraft.getMinecraft().thePlayer : super.getPlayerEntity(ctx)); } public void initKeys() { keyBindings[0]= new KeyBinding("Spell Slot 1", Keyboard.KEY_R, "Inner Power"); keyBindings[1]= new KeyBinding("Spell Slot 2", Keyboard.KEY_T, "Inner Power"); keyBindings[2]= new KeyBinding("Spell Slot 3", Keyboard.KEY_Y, "Inner Power"); keyBindings[3]= new KeyBinding("Spell Slot 4", Keyboard.KEY_U, "Inner Power"); for (int i=0; i<4; i++) ClientRegistry.registerKeyBinding(keyBindings); } } CommonProxy: public class CommonProxy implements IGuiHandler { // Client stuff private static final Map<String, NBTTagCompound> magicPlayerData = new HashMap<String, NBTTagCompound>(); public void registerRenderers() { // Nothing here as the server doesn't render graphics or entities! } public void initKeys() { } @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world,int x, int y, int z) { return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world,int x, int y, int z) { return null; } /** * Adds an entity's custom data to the map for temporary storage * @param compound An NBT Tag Compound that stores the IExtendedEntityProperties data only */ public static void storeEntityData(String name, NBTTagCompound compound) { magicPlayerData.put(name, compound); } /** * Removes the compound from the map and returns the NBT tag stored for name or null if none exists */ public static NBTTagCompound getEntityData(String name) { return magicPlayerData.remove(name); } /** * Returns a side-appropriate EntityPlayer for use during message handling. */ public EntityPlayer getPlayerEntity(MessageContext ctx) { return ctx.getServerHandler().playerEntity; } }
October 14, 20159 yr Looks about right, so the problem is probably in your rendering class - post that. Also, you are using an outdated method of persisting IEEP - your 'magicPlayerData' map in the CommonProxy can be replaced by subscribing to the PlayerEvent.Clone and copying the IEEP data from the old player to the new. http://i.imgur.com/NdrFdld.png[/img]
October 14, 20159 yr Author Ok thanks! I'll try updateing that. In the meantime here are the rendering classes in question. They are pretty much the same. I copied them from the snowball rendering class a long time ago, has something here depricated?I just realized I haven't thought to check the new snowball code since updating, I'll do that now. Thanks again! renderSpiritBolt: @SideOnly(Side.CLIENT) public class renderSpiritBolt extends Render { private Item field_94151_a; private int field_94150_f; public renderSpiritBolt(Item par1Item, int par2) { this.field_94151_a = par1Item; this.field_94150_f = par2; } public renderSpiritBolt(Item par1Item) { this(par1Item, 0); } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { IIcon icon = this.field_94151_a.getIconFromDamage(this.field_94150_f); if (icon != null) { GL11.glPushMatrix(); GL11.glTranslatef((float)par2, (float)par4, (float)par6); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glScalef(0.5F, 0.5F, 0.5F); // this.func_110777_b(par1Entity); // worked in Forge 804, but no longer; use this: this.bindEntityTexture(par1Entity); Tessellator tessellator = Tessellator.instance; // You can remove this whole section if you want, it's just for Potions if (icon == ItemPotion.func_94589_d("bottle_splash")) { int i = PotionHelper.func_77915_a(((EntityPotion)par1Entity).getPotionDamage(), false); float f2 = (float)(i >> 16 & 255) / 255.0F; float f3 = (float)(i >> 8 & 255) / 255.0F; float f4 = (float)(i & 255) / 255.0F; GL11.glColor3f(f2, f3, f4); GL11.glPushMatrix(); this.func_77026_a(tessellator, ItemPotion.func_94589_d("overlay")); GL11.glPopMatrix(); GL11.glColor3f(1.0F, 1.0F, 1.0F); } this.func_77026_a(tessellator, icon); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); } } @Override protected ResourceLocation getEntityTexture(Entity entity) { return TextureMap.locationItemsTexture; } private void func_77026_a(Tessellator par1Tessellator, IIcon par2Icon) { float f = par2Icon.getMinU(); float f1 = par2Icon.getMaxU(); float f2 = par2Icon.getMinV(); float f3 = par2Icon.getMaxV(); float f4 = 1.0F; float f5 = 0.5F; float f6 = 0.25F; GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); par1Tessellator.startDrawingQuads(); par1Tessellator.setNormal(0.0F, 1.0F, 0.0F); par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3); par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3); par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2); par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2); par1Tessellator.draw(); } } renderHolyLight @SideOnly(Side.CLIENT) public class renderHolyLight extends Render { private Item field_94151_a; private int field_94150_f; public renderHolyLight(Item par1Item, int par2) { this.field_94151_a = par1Item; this.field_94150_f = par2; } public renderHolyLight(Item par1Item) { this(par1Item, 0); } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { IIcon icon = this.field_94151_a.getIconFromDamage(this.field_94150_f); if (icon != null) { GL11.glPushMatrix(); GL11.glTranslatef((float)par2, (float)par4, (float)par6); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glScalef(0.5F, 0.5F, 0.5F); // this.func_110777_b(par1Entity); // worked in Forge 804, but no longer; use this: this.bindEntityTexture(par1Entity); Tessellator tessellator = Tessellator.instance; // You can remove this whole section if you want, it's just for Potions if (icon == ItemPotion.func_94589_d("bottle_splash")) { int i = PotionHelper.func_77915_a(((EntityPotion)par1Entity).getPotionDamage(), false); float f2 = (float)(i >> 16 & 255) / 255.0F; float f3 = (float)(i >> 8 & 255) / 255.0F; float f4 = (float)(i & 255) / 255.0F; GL11.glColor3f(f2, f3, f4); GL11.glPushMatrix(); this.func_77026_a(tessellator, ItemPotion.func_94589_d("overlay")); GL11.glPopMatrix(); GL11.glColor3f(1.0F, 1.0F, 1.0F); } this.func_77026_a(tessellator, icon); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); } } @Override protected ResourceLocation getEntityTexture(Entity entity) { return TextureMap.locationItemsTexture; } private void func_77026_a(Tessellator par1Tessellator, IIcon par2Icon) { float f = par2Icon.getMinU(); float f1 = par2Icon.getMaxU(); float f2 = par2Icon.getMinV(); float f3 = par2Icon.getMaxV(); float f4 = 1.0F; float f5 = 0.5F; float f6 = 0.25F; GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); par1Tessellator.startDrawingQuads(); par1Tessellator.setNormal(0.0F, 1.0F, 0.0F); par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3); par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3); par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2); par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2); par1Tessellator.draw(); } }
October 14, 20159 yr I'm not sure why your entity isn't rendering, but I have to ask: if you are using an Item-based renderer for your Entity, why not just use the RenderSnowball class? At the very least, you should try using it to rule out errors in your custom Render class code. http://i.imgur.com/NdrFdld.png[/img]
October 15, 20159 yr Author I updated it to use RenderSnowball() but still nothing Any other ideas? Thanks again for your help, I'll include the changed ClientProxy code below. Client Proxy: public class ClientProxy extends CommonProxy { public static KeyBinding[] keyBindings= new KeyBinding[4]; @Override public void registerRenderers() { RenderingRegistry.registerEntityRenderingHandler(spiritBoltProjectile.class, new RenderSnowball(BaseClass.InrPwrSB)); //renderSpiritBolt(BaseClass.InrPwrSB)); RenderingRegistry.registerEntityRenderingHandler(holyLightProjectile.class, new RenderSnowball(BaseClass.InrPwrHL)); //renderHolyLight(BaseClass.InrPwrHL)); } @Override public EntityPlayer getPlayerEntity(MessageContext ctx) { // Double-check is inevitable! return (ctx.side.isClient() ? Minecraft.getMinecraft().thePlayer : super.getPlayerEntity(ctx)); } public void initKeys() { keyBindings[0]= new KeyBinding("Spell Slot 1", Keyboard.KEY_R, "Inner Power"); keyBindings[1]= new KeyBinding("Spell Slot 2", Keyboard.KEY_T, "Inner Power"); keyBindings[2]= new KeyBinding("Spell Slot 3", Keyboard.KEY_Y, "Inner Power"); keyBindings[3]= new KeyBinding("Spell Slot 4", Keyboard.KEY_U, "Inner Power"); for (int i=0; i<4; i++) ClientRegistry.registerKeyBinding(keyBindings); } }
October 15, 20159 yr At this point I would check your Items, e.g. 'BaseClass.InrPwrHL' - have they been initialized and registered? Was that done BEFORE registering the renderer? Do they have textures? Did you override #getIconFromDamage to return anything other than the default icon? I mean, at the very least you should be getting the missing texture texture rendering... how are you spawning the entity? http://i.imgur.com/NdrFdld.png[/img]
October 15, 20159 yr Author ...I am literally so dumb. I quadruple checked the item initialization but never checked that I was actually registering it. As soon as you mentioned the registration I realized what was wrong. Both projectiles are now rendering. Thank you so much, I've been trying to figure this out for way too long. I was sure it was a rendering issue! Related question: Whenever I try to thank some one on this forum it doesn't look like it takes effect. I just hit the applaude button right? Thanks again, marking this as solved!
October 15, 20159 yr ...I am literally so dumb. I quadruple checked the item initialization but never checked that I was actually registering it. As soon as you mentioned the registration I realized what was wrong. Both projectiles are now rendering. Thank you so much, I've been trying to figure this out for way too long. I was sure it was a rendering issue! Related question: Whenever I try to thank some one on this forum it doesn't look like it takes effect. I just hit the applaude button right? Thanks again, marking this as solved! Applaud increases the poster's karma, the Thank You button in the top right of a post displays the thanks under the post. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
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.