Jump to content

Parametrize Entity in method getEntitiesOfClass


Recommended Posts

This is beyond my knowledge of Java... and I have no idea how to do it. Declaration of function looks like this:


default <T extends Entity> java.util.List<T> getEntitiesOfClass(java.lang.Class<? extends T> p_217357_1_, AxisAlignedBB p_217357_2_)


I can put there param like PigEntity.class or ZombieEntity.class but is there a possibility to parametrize this "java.lang.Class<? extends T> p_217357_1_"  like this?


switch (sEntity)
	case "ZOMBIE":
		ent = ZombieEntity.class;
	case "SKELETON":
		ent = SkeletonEntity.class;
monsters = mc.level.getEntitiesOfClass(ent, new AxisAlignedBB((double)(posx - 5.0), (double)(posy - 5.0), (double)(posz - 5.0F),(double)(posx + 5.0),(double)(posy + 5),(double)(posz + 5)));

If Yes then what type "ent" and "monsters"  should be?


Or maybe it should be done totally different? The idea is to be able to look for defined type of Entities within a AxisAlignedBB or Range?



Link to comment
Share on other sites

sEntity is comming from input / String - I'm really know only basics of Java but why would You prefer this as enum (TBH I cannot imagine (with my poor language knowledge) how can it be Enum)? And regarding types - it has compiled properly - thank You.

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.

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.

  • Create New...

Important Information

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