Posted October 22, 201311 yr I'm doing the render things. Don't know why after the entity spawn, the render rendered for a few ticks and didn't work.... The render is not called after the first few ticks. code is like The entity private int livetime; public EntityMagicRenderTest(World par1World, double x, double y, double z) { super(par1World); this.setPosition(x,y,z); livetime = 200; } public EntityMagicRenderTest(World par1World, double x, double y, double z, int deadline) { super(par1World); this.setPosition(x,y,z); livetime = deadline; } public EntityMagicRenderTest(World par1World) { super(par1World); } @Override protected void entityInit() { } @Override public void onUpdate() { super.onUpdate(); --livetime; if (livetime <= 0) { this.setDead(); } //this.setPosition(this.posX, this.posY, this.posZ); if (!this.worldObj.isRemote && livetime % 20 == 0) { System.out.println("livetime = " + livetime); System.out.println(this.posX + " " + this.posY + " " + this.posZ); } } the renderer: public void doRender(Entity entity, double d0, double d1, double d2, float f, float f1) { System.out.println("try render"); GL11.glPushMatrix(); bindEntityTexture(entity); GL11.glTranslatef((float)d0, (float)d1, (float)d2); GL11.glRotatef(180F -renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-renderManager.playerViewX, 1.0F, 0.0F, 0.0F); Tessellator t = Tessellator.instance; t.startDrawingQuads(); t.setNormal(0, 0, 0); t.addVertexWithUV(-0.5, -0.5, 0.0, 0, 0); t.addVertexWithUV(-0.5, 0.5, 0.0, 0, 1); t.addVertexWithUV(0.5, 0.5, 0.0, 0.5, 1); t.addVertexWithUV(0.5, -0.5, 0.0, 0.5, 0); t.addVertexWithUV(-0.5, -0.5, 0.0, 0, 0); t.addVertexWithUV(0.5, -0.5, 0.0, 0.5, 0); t.addVertexWithUV(0.5, 0.5, 0.0, 0.5, 1); t.addVertexWithUV(-0.5, 0.5, 0.0, 0, 1); t.draw(); GL11.glPopMatrix(); } I've successed for a time.. But suddenly it didnt work again..
October 22, 201311 yr well to me that seems normal as you have a liveTime variable and you kill your entity when its under 0, maybe i missed something, does it stop rendering BEFORE it dies ? remember that server and client are 2 different program, maybe if youre testing with an actual client + server the server tick faster then the client or vice versa so there is a desynchronisation, in this case i would recommend DataWatching your livetime how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
October 22, 201311 yr Author I'm new to render. So it's just for test so I simply set the livetime. I know the difference between the client and the server. And yes, it stop rendering BEFORE it die as I could see messages in the onUpdate() method of the entity. And I try to delete "--livetime;". But nothing change. The "rendered entity" appear 2-3 ticks and then disappear while the entity is still alive.
October 22, 201311 yr ok, do you know for a fact that it hasn't moved extremmelly far? like can you hit it after it vanishes ? how is it spawned ? how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
October 22, 201311 yr Author I use a item and spawn it in the position where the player stand. And as there is almost nothing in the entity, I don't know if I can hit it, I'll try later. In my success case I try to make it move and succeed, and now I delete the code about its movement, so I think it could not move extremmelly far.
October 22, 201311 yr I think the client's livetime variable is never set so it stays at 0. Then in the update method this line will (also) trigger on the client: if (livetime <= 0) { this.setDead(); } Solution would be to add a server check: if (!worldObj.isRemote && livetime <= 0) { this.setDead(); } Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.
October 22, 201311 yr Author That's it.. It seems I don't know about the difference between server and client well :'( :'( Thx
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.