moler Posted September 14, 2015 Share Posted September 14, 2015 hi guys, iv got a - DefaultModelList myLoot; I'm kinda stuck converting this list into a working looting method. any help is appreciated. Quote Link to comment Share on other sites More sharing options...
FrostBug Posted September 14, 2015 Share Posted September 14, 2015 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. Quote Link to comment Share on other sites More sharing options...
Flamezzz Posted September 14, 2015 Share Posted September 14, 2015 toArray? Quote Link to comment Share on other sites More sharing options...
FrostBug Posted September 14, 2015 Share Posted September 14, 2015 toArray? 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 1 Quote Link to comment Share on other sites More sharing options...
Joseph Posted September 14, 2015 Share Posted September 14, 2015 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. Quote Link to comment Share on other sites More sharing options...
fixthissite Posted September 14, 2015 Share Posted September 14, 2015 (edited) 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 September 14, 2015 by fixthissite 1 Quote Link to comment Share on other sites More sharing options...