September 14, 201510 yr hi guys, iv got a - DefaultModelList myLoot; I'm kinda stuck converting this list into a working looting method. any help is appreciated.
September 14, 201510 yr 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.
September 14, 201510 yr 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
September 14, 201510 yr 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.
September 14, 201510 yr 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, 201510 yr by fixthissite
Create an account or sign in to comment