Posted June 20, 20214 yr 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; break; case "SKELETON": ent = SkeletonEntity.class; break; } 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?
June 20, 20214 yr Author 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.
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.