Jump to content

Rendering a techne model as a 3D item when thrown? How would you do it?


Thornack

Recommended Posts

Hi,

 

I have been developing a mod where I wish to throw a 3D item. I have it rendered in 3D when it is held and at the moment when I right click it throws snowballs. I wish to add functionality to the item which would allow it to be thrown when the player right clicks while holding the item and land some distance away from the player. Does anyone know how to do this code wise? I have been looking for a way to accomplish this with no luck so far.

Link to comment
Share on other sites

Hi

 

I'm not sure I really understand your question - do you mean that you don't know how to throw your item, or that you don't know how to make it render using your techne model?

 

The answer to the first one is in ItemSnowball.onItemRightClick - i.e. you need to spawn an EntityItem.  The vanilla code has lots of examples on how to do it, it's quite straightforward.

 

The answer to the second one is that you can use the same rendering code for EntityItems as for when it is held.

For more information see here:

http://greyminecraftcoder.blogspot.com/2013/08/rendering-items.html

and

http://greyminecraftcoder.blogspot.com.au/2013/08/rendering-dropped-items.html

 

-TGG

Link to comment
Share on other sites

To clarify my question, I wish to render the item during flight so that as it flies through the air it looks like my 3D item and then lands as a 3D item/model on the ground. I have tried using the snowball code and currently my item is rendered in 3D in the players hand. Upon right click it throws a snowball when instead it should render itself and then upon 'landing' nothing happens and the item doesnt appear at all.

Link to comment
Share on other sites

When you are holding it in your hand it is an item which you can render differently using class implementing IItemRenderer. I'm guessing you have that part down.

 

When you release the mouse button it spawns an entity which again needs its own custom render class (just extending Render).

In there it is just a matter of rendering the model and applying any needed rotations and whatnot.

 

You could take a look at the RenderArrow class. You basically just need to do the same thing only instead of all the tessellator stuff you just call your model's render function.

 

Finally don't forget to register both the item and the entity render classes ^^.

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



×
×
  • Create New...

Important Information

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