#vulnerable code 
                                private static int spawnPacket(Location loc) throws Exception {
        Object world = Reflections.getHandle(loc.getWorld());
        Object crystal = enderCrystalClass.getConstructor(Reflections.getCraftClass("World")).newInstance(world);
        Reflections.getMethod(enderCrystalClass, "setLocation", double.class, double.class, double.class, float.class, float.class).invoke(crystal, loc.getX(), loc.getY(), loc.getZ(), 0, 0);
        Object packet = spawnEntityClass.getConstructor(new Class<?>[]{entityClass, int.class}).newInstance(crystal, 51);
        int id = (int) Reflections.getMethod(enderCrystalClass, "getId").invoke(crystal);
        ids.put(id, packet);
        return id;
    } 
                            #location 4 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                private static int spawnPacket(Location loc) throws Exception {
        Object world = Reflections.getHandle(loc.getWorld());
        Object crystal = enderCrystalConstructor.newInstance(world);
        setLocation.invoke(crystal, loc.getX(), loc.getY(), loc.getZ(), 0, 0);
        Object packet = spawnEntityConstructor.newInstance(crystal, 51);
        int id = (int) getId.invoke(crystal);
        ids.put(id, packet);
        return id;
    }