Jump to content

Rendered Entity is not Spawned Entity


kestred

Recommended Posts

So I have an entity spawned from an item (similar to Art).

When the entity is created, it is passed metadata from the item.

When it is hit, it drops the item with appropriate metadata.

That part works.

 

What is strange, is that the rendering function asks for the metadata but gets an incorrect value:

 

The Rendering code

	public void renderFoo(EntityFoo entity, double glX, double glY, double glZ, float glTheta, float glPhi) {
		GL11.glPushMatrix();
		GL11.glTranslatef((float)glX, (float)glY, (float)glZ);
		GL11.glRotatef(glTheta, 0.0F, 1.0F, 0.0F);
		GL11.glRotatef(180, 0.0F, 0.0F, 1.0F);
		this.loadTexture(CommonProxy.getFooTexture(entity.getFooData()));
		model.render(entity, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
		GL11.glPopMatrix();
	}

 

The Entity code

  public EntityFoo(World worldObject, int xPos, int yPos, int zPos, int facing, int fooData, Item itemDropped) {
    super(worldObject, xPos, yPos, zPos, facing);
    this.itemDropped = itemDropped;
    this.fooData = fooData;
    setSize(1.0F, 2.0F);
    setDirection(facing);
  }
  public int getFooData() { return this.fooData; }
  public void dropItemStack() { entityDropItem(new ItemStack(this.itemDropped, 1, this.fooData), 0.0F); }

 

One possible reason -- can't figure out solution

I have done println on the entity created vs the entity rendered and it seems they are different???

The metadata passed in is not the metadata returned when getFooData() is called, even though it drops the correct item when the entity is destroyed.

But I have tried to follow the path of the entity through the program and it doesn't look like another entity is created.

 

Thanks for any help!

Link to comment
Share on other sites

What I think is happening is the value is correct Serverside but not Clientside. This is why when it drops it, the itemstack has the right value. That's handled serverside. The clientside half, however, never is updated and so the metadata is off.

 

The easy solution is to add to EntityFoo's dataWatcher instance. Add a mapping for the metadata and update it accordingly. (To see how this is done, check out the various classes, such as Sheep, and Skeletons, which utilize it)

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.



×
×
  • Create New...

Important Information

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