vendredi 20 septembre 2019

How to access a field within a static inner class with a generic type? (very difficult)

I'm stuck on this problem for almost 3 months now and just can't resolve it myself. I hope it's possible. I'm trying to inject this code with my own custom entity class, which is hard to access, because the class is static and the field is final. Somehow i'm not sure if the generic type is a problem on accessing it.

    public class EntityTypes<T extends Entity> {

        [some code here]

        public interface b<T extends Entity> {
            T create(EntityTypes<T> entitytypes, World world);
        }

        public static class a<T extends Entity> {
            private final EntityTypes.b<T> a;
            [more code here]
        }
    }

So far i tried to use Reflections, but i keep getting:

java.lang.IllegalArgumentException: Can not set net.server.EntityTypes$b field net.server.EntityTypes$a.a to net.server.EntityTypes

       ReflectionUtils.setFinal(EntityTypes.a.class, EntityTypes.VILLAGER, "a", (EntityTypes.b<CustomVillager>) CustomVillager::new);





Aucun commentaire:

Enregistrer un commentaire