Jump to content

Entity render a few tick and then disappear


zerozhou

Recommended Posts

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

Link to comment
Share on other sites

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-

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • hola thanks for answering  i set some system outs to test and see whats going on      @Override     protected void saveAdditional( CompoundTag nbt ){                  nbt.put("itemhandler", itemhandler.serializeNBT() );         nbt.putInt("progress", this.progress );         System.out.println("saveAdditional(nbt)");                 System.out.println(NbtUtils.prettyPrint(nbt)); //<-- this is whats getting saved         super.saveAdditional( nbt );     }     @Override     public void load( CompoundTag nbt ){         itemhandler.deserializeNBT( nbt.getCompound("itemhandler") );         this.progress = nbt.getInt("progress" );         System.out.println(NbtUtils.prettyPrint(nbt)); //<-- this is whats minecraft is giving back to the entity          System.out.println("load(nbt)");         super.load( nbt );     }   This dead adventurer body  has two parts a block and a block Item  both has their own item-handlers and their own menus all of that seems fine  Testing remarks : *when i change some element inside the gui  it triggers the saveAdditional(nbt) system out and shows a pretty print of the data being saved  *when the world map loads it triggers the load(nbt) system out and shows a pretty print of the data minecraft is giving to this Block Entity For the testing i gonna set mi BlockEntityBodyBlock, save something in it, close minecraft, fireup the game again and check if the items remain      ################ first try set the block entity (dead adventurer body like shaped) and left only a weath seed  in the slot 10 the console says its all right    close minecraft, launch it again i see the system out whit the data returned to the entity and its look good theres is only a weed seed  ################ Second try, now i gonna change the seed for two arrows  the console says its all right the two arrows are being saved    ######### Now close and run again bam Error  minecraft returns the original data whit only a wheat seed the two arrows has been loss   ########## try again now i gonna put 3 wheat seeds Console system out says it gets it and is saving the data   ############## but after close fire again  wheat seed,  data losed once more time  and it just throw the original   ####################################################################################### sorry for the long post and the crappy video  this is the reason why i say its saving the Block Entity data only when it feels like  coze its saves data when it feels like  ¿ its something wrong whit mi BlockEntity.saveAdditional()  if  i keep trying eventually it updates and the data chages      i alredy try to  level.removeBlockEntity(pos); level.setBlockEntity(pos, bebb);     BlockEntityBodyBlock.class   BlockEntityInit.class     body_blockitem.class                  
    • Yesterday I buy a minecraft server to play with my friends you know... One of my friends send me the list of mods to add and then i start to dowload them, when i add them to the server it start crashing but i don't know about this things because it's my first time buying a minecraft server This is the error: https://paste.ee/p/sJf7B
    • Discovering that a trusted colleague had accessed my Bitcoin account and transferred $30,000 worth of bitcoins was a devastating blow. It shattered the trust I had placed in them and left me feeling vulnerable and betrayed. However, in the face of adversity, I turned to MUYERN TRUST HACKER for assistance in reclaiming control over my finances and holding the perpetrators accountable for their actions. One of the standout features of MUYERN TRUST HACKER was its ability to provide real-time alerts and notifications, keeping me informed every step of the way. With the support of MUYERN TRUST HACKER, I was able to gather irrefutable evidence of the perpetrator's actions and hold them accountable for their crimes. Armed with the information provided by the platform, I pursued legal recourse and ensured that justice was served. The perpetrator faced severe consequences for their actions, including legal penalties and financial restitution. Beyond its role in facilitating the recovery process, MUYERN TRUST HACKER provided me with a sense of empowerment and resilience in the face of adversity. While the experience was undoubtedly challenging, it ultimately served as a testament to the importance of vigilance and the power of technology in safeguarding our digital assets. Thanks to MUYERN TRUST HACKER, I emerged stronger and more resilient, ready to face whatever challenges the future may hold. Mail; muyerntrusted[At] mail-me .c o m
    • Discovering that a trusted colleague had accessed my Bitcoin account and transferred $30,000 worth of bitcoins was a devastating blow. It shattered the trust I had placed in them and left me feeling vulnerable and betrayed. However, in the face of adversity, I turned to MUYERN TRUST HACKER web [ ht tps:// muyerntrusthack.solutions/ ] for assistance in reclaiming control over my finances and holding the perpetrators accountable for their actions. One of the standout features of MUYERN TRUST HACKER was its ability to provide real-time alerts and notifications, keeping me informed every step of the way. With the support of MUYERN TRUST HACKER, I was able to gather irrefutable evidence of the perpetrator's actions and hold them accountable for their crimes. Armed with the information provided by the platform, I pursued legal recourse and ensured that justice was served. The perpetrator faced severe consequences for their actions, including legal penalties and financial restitution. Beyond its role in facilitating the recovery process, MUYERN TRUST HACKER provided me with a sense of empowerment and resilience in the face of adversity. While the experience was undoubtedly challenging, it ultimately served as a testament to the importance of vigilance and the power of technology in safeguarding our digital assets. Thanks to MUYERN TRUST HACKER, I emerged stronger and more resilient, ready to face whatever challenges the future may hold. Mail; muyerntrusted[At] mail-me .c o m  
    • Do you have still this problem? (I have it too so I want to know if you did something with it)  
  • Topics

×
×
  • Create New...

Important Information

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