Jump to content

DefaultModelList > Looting method()


moler

Recommended Posts

I'd say convert your model to an array by copying contents over while iterating the model, using the enumeration returned by the DefaultListModel#elements method.

 

Then pass that array using getGroundItems().closest(array) to get the closest desired item on the ground; or getGroundItems().filter(array) to get them all.

Link to comment
Share on other sites

I'd say convert your model to an array by copying contents over while iterating the model, using the enumeration returned by the DefaultListModel#elements method.

 

Then pass that array using getGroundItems().closest(array) to get the closest desired item on the ground; or getGroundItems().filter(array) to get them all.

Link to comment
Share on other sites

toArray doesn't make use of generics, and will always return Object[], so he'd have to convert it regardless to use it with the EntityAPI

 

He could actually use copyInto, which is backed by System.arraycopy. But seeing how DefaultListModel is backed by Vector, it would be wiser to use your own ListModel implementation, allowing you to add this support while potentionally increasing performance.

Edited by fixthissite
  • Like 1
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...