Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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!

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)

  • Author

Thanks! That solution worked perfectly. I think I also have a much better understanding of how MC and Forge handle entities now.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.