NoSuchFieldException: goalSelector

Discussion in 'Plugin Development' started by Elimnator, Jan 26, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Elimnator

    I am getting this error: java.lang.NoSuchFieldException: goalSelector

    When I use this code:
    Code:java
    1. public void changeIntoWither(Skeleton skeleton){
    2. EntitySkeleton ent = ((CraftSkeleton)skeleton).getHandle();
    3. try {
    4. ent.setSkeletonType(1);
    5. Field selector = EntitySkeleton.class.getDeclaredField("goalSelector");
    6. selector.setAccessible(true);
    7. Field e = EntitySkeleton.class.getDeclaredField("e");
    8. e.setAccessible(true);
    9. PathfinderGoalSelector goals = (PathfinderGoalSelector) selector.get(ent);
    10. goals.a(4, (PathfinderGoal) e.get(ent));
    11. ItemStack sword = (new ItemStack(Material.STONE_SWORD, 1));
    12. //ent.setEquipment(0, new net.minecraft.server.v1_7_R1.ItemStack(Item.STONE_SWORD));
    13. EntityEquipment ee = ((LivingEntity) ent).getEquipment();
    14. ee.setItemInHand(sword);
    15. }
    16. catch (Throwable e) {
    17. e.printStackTrace();
    18. }
    19. }

    Can anyone help?

    Anyone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  2. Offline

    RawCode

    static public Field forName_Field(Class Source, String... Names)
    {
    Field[] f = Source.getDeclaredFields();
    for (Field f0 : f)
    {
    for (String s0 : Names)
    {
    if (f0.getName().equals(s0))
    return f0;
    }
    }
    if (Source.getSuperclass() == null)
    return null;
    return forName_Field(Source.getSuperclass(),Names);
    }
     
Thread Status:
Not open for further replies.

Share This Page